Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
}
const sourceText = text.toString('utf-8');
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
const storeModuleReducers = options.minimal ? `{}` : `reducers`;
const storeModuleConfig = options.minimal
? `{}`
: `{
metaReducers
}`;
const storeModuleSetup = `StoreModule.forRoot(${storeModuleReducers}, ${storeModuleConfig})`;
const statePath = `/${options.path}/${options.statePath}`;
const relativePath = schematics_core_1.buildRelativePath(modulePath, statePath);
const [storeNgModuleImport] = schematics_core_1.addImportToModule(source, modulePath, storeModuleSetup, relativePath);
let changes = [
schematics_core_1.insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
storeNgModuleImport,
];
if (!options.minimal) {
changes = changes.concat([
schematics_core_1.insertImport(source, modulePath, 'reducers, metaReducers', relativePath),
]);
}
const recorder = host.beginUpdate(modulePath);
for (const change of changes) {
if (change instanceof schematics_core_1.InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(recorder);
return host;
};
const storeModuleConfig = options.minimal
? `{}`
: `{
metaReducers
}`;
const storeModuleSetup = `StoreModule.forRoot(${storeModuleReducers}, ${storeModuleConfig})`;
const statePath = `/${options.path}/${options.statePath}`;
const relativePath = schematics_core_1.buildRelativePath(modulePath, statePath);
const [storeNgModuleImport] = schematics_core_1.addImportToModule(source, modulePath, storeModuleSetup, relativePath);
let changes = [
schematics_core_1.insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
storeNgModuleImport,
];
if (!options.minimal) {
changes = changes.concat([
schematics_core_1.insertImport(source, modulePath, 'reducers, metaReducers', relativePath),
]);
}
const recorder = host.beginUpdate(modulePath);
for (const change of changes) {
if (change instanceof schematics_core_1.InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(recorder);
return host;
};
}
strictActionImmutability: true
}
}`;
const storeModuleSetup = `StoreModule.forRoot(${storeModuleReducers}, ${storeModuleConfig})`;
const statePath = `/${options.path}/${options.statePath}`;
const relativePath = buildRelativePath(modulePath, statePath);
const [storeNgModuleImport] = addImportToModule(
source,
modulePath,
storeModuleSetup,
relativePath
);
let changes = [
insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
storeNgModuleImport,
];
if (!options.minimal) {
changes = changes.concat([
insertImport(
source,
modulePath,
'reducers, metaReducers',
relativePath
),
]);
}
const recorder = host.beginUpdate(modulePath);
const relativePath = buildRelativePath(modulePath, statePath);
const [storeNgModuleImport] = addImportToModule(
source,
modulePath,
storeModuleSetup,
relativePath
);
let changes = [
insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
storeNgModuleImport,
];
if (!options.minimal) {
changes = changes.concat([
insertImport(
source,
modulePath,
'reducers, metaReducers',
relativePath
),
]);
}
const recorder = host.beginUpdate(modulePath);
for (const change of changes) {
if (change instanceof InsertChange) {
recorder.insertLeft(change.pos, change.toAdd);
}
}
host.commitUpdate(recorder);