Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fileContent = getFileContent(tree, visitor);
}
if (fileContent.match(/class.*{[\s\S]*?((?:[()'"`\s])window)/)) {
addDependencyInjection(tree, visitor, 'window', 'Window', '@ng-toolkit/universal', 'WINDOW');
updateCode(tree, visitor, 'window');
}
// if (fileContent.match(/class.*{[\s\S]*?((?:[()'"`\s])document)/)) {
// addDependencyInjection(tree, visitor, 'document', 'Document', '@ng-toolkit/universal', 'NGT_DOCUMENT');
// updateCode(tree, visitor, 'document');
// }
}
});
// add installation task
if (!options.skipInstall) {
context.addTask(new NodePackageInstallTask(options.directory));
}
//applying other schematics (if installed)
const ngToolkitSettings = getNgToolkitInfo(tree, options);
ngToolkitSettings.universal = options;
updateNgToolkitInfo(tree, options, ngToolkitSettings);
let externals: Rule[] = [];
if (ngToolkitSettings.serverless) {
ngToolkitSettings.serverless.directory = options.directory;
ngToolkitSettings.serverless.skipInstall = true;
externals.push(externalSchematic('@ng-toolkit/serverless', 'ng-add', ngToolkitSettings.serverless));
} else if(tree.exists(`${options.directory}/.firebaserc`)) {
ngToolkitSettings.serverless = {};
ngToolkitSettings.serverless.directory = options.directory;
ngToolkitSettings.serverless.skipInstall = true;
ngToolkitSettings.serverless.provider = 'firebase';
return (host: Tree, context: SchematicContext) => {
addPackageJsonDependency(host, {
type: NodeDependencyType.Default,
name: 'document-register-element',
version: '^1.7.2',
});
context.logger.info('Added "document-register-element" as a dependency.');
// Install the dependency
context.addTask(new NodePackageInstallTask());
};
}
}
}
else if (packageJson.peerDependencies && packageJson.peerDependencies[name]) {
updateDependency(packageJson.peerDependencies, name, target.version);
}
else {
logger.warn(`Package ${name} was not found in dependencies.`);
}
});
const newContent = JSON.stringify(packageJson, null, 2);
if (packageJsonContent.toString() != newContent || migrateOnly) {
let installTask = [];
if (!migrateOnly) {
// If something changed, also hook up the task.
tree.overwrite('/package.json', JSON.stringify(packageJson, null, 2));
installTask = [context.addTask(new tasks_1.NodePackageInstallTask())];
}
// Run the migrate schematics with the list of packages to use. The collection contains
// version information and we need to do this post installation. Please note that the
// migration COULD fail and leave side effects on disk.
// Run the schematics task of those packages.
toInstall.forEach(([name, target, installed]) => {
if (!target.updateMetadata.migrations) {
return;
}
const collection = (target.updateMetadata.migrations.match(/^[./]/)
? name + '/'
: '') + target.updateMetadata.migrations;
context.addTask(new tasks_1.RunSchematicTask('@schematics/update', 'migrate', {
package: name,
collection,
from: installed.version,
rules.push((tree: Tree, context: SchematicContext) => {
tree.exists('.'); // noop
context.addTask(new NodePackageInstallTask(options.directory));
})
}
return (host: Tree, context: SchematicContext) => {
if (!options.skipInstall) {
context.addTask(new NodePackageInstallTask());
}
};
}
var pkgPath = '/package.json';
var buffer = tree.read(pkgPath);
if (buffer == null) {
throw new schematics_1.SchematicsException('Could not read package.json');
}
var content = buffer.toString();
var pkg = JSON.parse(content);
if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
throw new schematics_1.SchematicsException('Error reading package.json');
}
if (!pkg.dependencies) {
pkg.dependencies = {};
}
pkg.dependencies['rxjs-compat'] = rxjsCompatVersion;
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
context.addTask(new tasks_1.NodePackageInstallTask());
return tree;
};
}
if (!collectionPath) {
collectionPath = normalize('/' + options.name + '/src/collection.json');
source = apply(url('./project-files'), [
applyTemplates({
...options as object,
coreVersion,
schematicsVersion,
dot: '.',
camelize: strings.camelize,
dasherize: strings.dasherize,
}),
mergeWith(source),
move(options.name),
]);
context.addTask(new NodePackageInstallTask(options.name));
}
return chain([
mergeWith(source),
addSchematicToCollectionJson(collectionPath, strings.dasherize(options.name), {
description: 'A blank schematic.',
factory: './' + strings.dasherize(options.name) + '/index#' +
strings.camelize(options.name),
}),
]);
};
}
return (host: Tree, context: SchematicContext) => {
addPackageToPackageJson(
host,
'dependencies',
'@ngrx/effects',
platformVersion
);
context.addTask(new NodePackageInstallTask());
return host;
};
}
return (host, context) => {
context.addTask(new tasks_1.NodePackageInstallTask());
context.logger.info(`🔍 Installing packages...`);
return host;
};
}
return (host: Tree, context: SchematicContext) => {
if (!options.skipInstall) {
context.addTask(new NodePackageInstallTask());
}
return host;
};
}