How to use the @angular-devkit/schematics/tasks.NodePackageInstallTask function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/schematics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maciejtreder / ng-toolkit / schematics / universal / src / schematics.ts View on Github external
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';
github angular / angular / packages / elements / schematics / ng-add / index.ts View on Github external
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());
  };
}
github rxweb / rxweb / rxweb.io / node_modules / @schematics / update / update / index.js View on Github external
}
        }
        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,
github maciejtreder / ng-toolkit / schematics / serverless / src / index.ts View on Github external
rules.push((tree: Tree, context: SchematicContext) => {
            tree.exists('.'); // noop
            context.addTask(new NodePackageInstallTask(options.directory));
        })
    }
github angular / angular / packages / bazel / src / schematics / ng-add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }
  };
}
github crisbeto / angular-svg-round-progressbar / vendor / rxjs / migrations / update-6_0_0 / index.js View on Github external
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;
    };
}
github angular / angular-cli / packages / schematics / schematics / blank / factory.ts View on Github external
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),
      }),
    ]);
  };
}
github ngrx / platform / modules / effects / schematics / ng-add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    addPackageToPackageJson(
      host,
      'dependencies',
      '@ngrx/effects',
      platformVersion
    );
    context.addTask(new NodePackageInstallTask());
    return host;
  };
}
github ngneat / spectator / projects / spectator / schematics / src / ng-add / index.js View on Github external
return (host, context) => {
        context.addTask(new tasks_1.NodePackageInstallTask());
        context.logger.info(`🔍 Installing packages...`);
        return host;
    };
}
github nrwl / nx / packages / workspace / src / schematics / init / init.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }
    return host;
  };
}