How to use the @schematics/angular/utility/dependencies.addPackageJsonDependency function in @schematics/angular

To help you get started, we’ve selected a few @schematics/angular 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 SAP / fundamental-ngx / libs / core / schematics / ng-add / index.ts View on Github external
dependencies.forEach(dependency => {
            addPackageJsonDependency(tree, dependency);
            console.log(chalk.green(`✅️ Added ${dependency.name} to ${dependency.type}.`));
        });
github DevExpress / devextreme-schematics / src / add-layout / index_spec.ts View on Github external
it('should set static flag', async () => {
    removePackageJsonDependency(appTree, '@angular/core');
    addPackageJsonDependency(appTree, {
      type: NodeDependencyType.Default,
      name: '@angular/core',
      version: '7.0.0'
    });

    const runner = new SchematicTestRunner('schematics', collectionPath);
    const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
    const navigationMenu = tree.readContent(
      '/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts');

    expect(navigationMenu).toContain('@ViewChild(DxTreeViewComponent)');
  });
github mattlewis92 / angular-calendar / projects / angular-calendar / schematics / ng-add / index.ts View on Github external
const dateAdapters: { [key: string]: string } = {
      moment: momentVersion,
      'date-fns': dateFnsVersion
    };

    const angularCalendarDependency: NodeDependency = nodeDependencyFactory(
      'angular-calendar',
      angularCalendarVersion
    );
    const dateAdapterLibrary = options.dateAdapter;
    const dateAdapterLibraryDependency: NodeDependency = nodeDependencyFactory(
      dateAdapterLibrary,
      dateAdapters[dateAdapterLibrary]
    );

    addPackageJsonDependency(host, angularCalendarDependency);
    context.logger.log(
      'info',
      `Added "${angularCalendarDependency.name}" into ${angularCalendarDependency.type}`
    );

    addPackageJsonDependency(host, dateAdapterLibraryDependency);
    context.logger.log(
      'info',
      `Added "${dateAdapterLibraryDependency.name}" into ${dateAdapterLibraryDependency.type}`
    );

    return host;
  };
}
github mattlewis92 / angular-calendar / projects / angular-calendar / schematics / ng-add / index.ts View on Github external
'angular-calendar',
      angularCalendarVersion
    );
    const dateAdapterLibrary = options.dateAdapter;
    const dateAdapterLibraryDependency: NodeDependency = nodeDependencyFactory(
      dateAdapterLibrary,
      dateAdapters[dateAdapterLibrary]
    );

    addPackageJsonDependency(host, angularCalendarDependency);
    context.logger.log(
      'info',
      `Added "${angularCalendarDependency.name}" into ${angularCalendarDependency.type}`
    );

    addPackageJsonDependency(host, dateAdapterLibraryDependency);
    context.logger.log(
      'info',
      `Added "${dateAdapterLibraryDependency.name}" into ${dateAdapterLibraryDependency.type}`
    );

    return host;
  };
}
github SAP / cloud-commerce-spartacus-storefront / projects / schematics / src / add-spartacus / index.ts View on Github external
dependencies.forEach(dependency => {
      addPackageJsonDependency(tree, dependency);
      context.logger.log(
        'info',
        `✅️ Added '${dependency.name}' into ${dependency.type}`
      );
    });
github nestjs / azure-storage / schematics / install / index.ts View on Github external
return (host: Tree) => {
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: '@nestjs/azure-storage',
      version: '^1.0.0',
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: '@azure/storage-blob',
      version: '^10.4.0',
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: 'dotenv',
      version: '^8.0.0',
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
github DevExpress / devextreme-schematics / src / install / index.ts View on Github external
function addDevExtremeDependency(host: Tree, options: any) {
  addPackageJsonDependency(host, {
    type: NodeDependencyType.Default,
    name: 'devextreme',
    version: options.dxversion || latestVersions['devextreme']
  });
  addPackageJsonDependency(host, {
    type: NodeDependencyType.Default,
    name: 'devextreme-angular',
    version: options.dxversion || latestVersions['devextreme-angular']
  });
  addPackageJsonDependency(host, {
    type: NodeDependencyType.Dev,
    name: 'devextreme-cli',
    version: latestVersions['devextreme-cli']
  });
  addPackageJsonDependency(host, {
    type: NodeDependencyType.Dev,
github nestjs / ng-universal / schematics / install / index.ts View on Github external
addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: 'ts-loader',
      version: '^5.2.0'
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: 'wait-on',
      version: '^3.2.0'
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: 'webpack-cli',
      version: '^3.1.0'
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: 'rimraf',
      version: '^2.6.3'
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: 'nodemon',
      version: '^1.18.11'
    });

    const pkgPath = '/package.json';
    const buffer = host.read(pkgPath);
    if (buffer === null) {
      throw new SchematicsException('Could not find package.json');
    }
github nestjs / azure-func-http / schematics / install / index.ts View on Github external
return (host: Tree) => {
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: '@azure/functions',
      version: '^1.0.3'
    });
    const pkgPath = '/package.json';
    const buffer = host.read(pkgPath);
    if (buffer === null) {
      throw new SchematicsException('Could not find package.json');
    }

    const pkg = JSON.parse(buffer.toString());
    pkg.scripts['start:azure'] = 'npm run build && func host start';

    host.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
    return host;
  };
github angular / universal / modules / express-engine / schematics / install / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    if (!options.skipInstall) {
      context.addTask(new NodePackageInstallTask());
    }
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: '@nguniversal/express-engine',
      version: '^0.0.0-PLACEHOLDER',
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Default,
      name: 'express',
      version: 'EXPRESS_VERSION',
    });
    addPackageJsonDependency(host, {
      type: NodeDependencyType.Dev,
      name: '@types/express',
      version: 'EXPRESS_TYPES_VERSION',
    });

    return host;
  };
}