How to use the @angular-devkit/core.getSystemPath function in @angular-devkit/core

To help you get started, we’ve selected a few @angular-devkit/core 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 angular / angular-cli / packages / angular_devkit / build_angular / src / dev-server / index.ts View on Github external
private _buildServerConfig(
    root: Path,
    options: DevServerBuilderSchema,
    browserOptions: NormalizedBrowserBuilderSchema,
  ) {
    const systemRoot = getSystemPath(root);
    if (options.host) {
      // Check that the host is either localhost or prints out a message.
      if (!/^127\.\d+\.\d+\.\d+/g.test(options.host) && options.host !== 'localhost') {
        this.context.logger.warn(tags.stripIndent`
          WARNING: This is a simple server for use in testing or debugging Angular applications
          locally. It hasn't been reviewed for security issues.

          Binding this server to an open connection can result in compromising your application or
          computer. Using a different host than the one passed to the "--host" flag might result in
          websocket connection issues. You might need to use "--disableHostCheck" if that's the
          case.
        `);
      }
    }
    if (options.disableHostCheck) {
      this.context.logger.warn(tags.oneLine`
github rxweb / rxweb / rxweb.io / node_modules / @angular-devkit / build-angular / src / browser / index.js View on Github external
buildWebpackConfig(root, projectRoot, host, options) {
        // Ensure Build Optimizer is only used with AOT.
        if (options.buildOptimizer && !options.aot) {
            throw new Error('The `--build-optimizer` option cannot be used without `--aot`.');
        }
        let wco;
        const tsConfigPath = core_1.getSystemPath(core_1.normalize(core_1.resolve(root, core_1.normalize(options.tsConfig))));
        const tsConfig = read_tsconfig_1.readTsconfig(tsConfigPath);
        const projectTs = require_project_module_1.requireProjectModule(core_1.getSystemPath(projectRoot), 'typescript');
        const supportES2015 = tsConfig.options.target !== projectTs.ScriptTarget.ES3
            && tsConfig.options.target !== projectTs.ScriptTarget.ES5;
        wco = {
            root: core_1.getSystemPath(root),
            projectRoot: core_1.getSystemPath(projectRoot),
            buildOptions: options,
            tsConfig,
            tsConfigPath,
            supportES2015,
        };
        wco.buildOptions.progress = utils_1.defaultProgress(wco.buildOptions.progress);
        const webpackConfigs = [
            webpack_configs_1.getCommonConfig(wco),
            webpack_configs_1.getBrowserConfig(wco),
github angular / angular-cli / packages / angular_devkit / build_angular / src / protractor / index.ts View on Github external
private _updateWebdriver(projectRoot: Path) {
    // The webdriver-manager update command can only be accessed via a deep import.
    const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';
    let webdriverUpdate: any; // tslint:disable-line:no-any

    try {
      // When using npm, webdriver is within protractor/node_modules.
      webdriverUpdate = requireProjectModule(getSystemPath(projectRoot),
        `protractor/node_modules/${webdriverDeepImport}`);
    } catch {
      try {
        // When using yarn, webdriver is found as a root module.
        webdriverUpdate = requireProjectModule(getSystemPath(projectRoot), webdriverDeepImport);
      } catch {
        throw new Error(tags.stripIndents`
          Cannot automatically find webdriver-manager to update.
          Update webdriver-manager manually and run 'ng e2e --no-webdriver-update' instead.
        `);
      }
    }

    // run `webdriver-manager update --standalone false --gecko false --quiet`
    // if you change this, update the command comment in prev line
    return from(webdriverUpdate.program.run({
github johandb / svg-drawing-tool / node_modules / @angular-devkit / build-angular / src / angular-cli-files / utilities / service-worker / index.js View on Github external
function augmentAppWithServiceWorker(host, projectRoot, appRoot, outputPath, baseHref, ngswConfigPath) {
    // Path to the worker script itself.
    const distPath = core_1.normalize(outputPath);
    const workerPath = core_1.normalize(require_project_module_1.resolveProjectModule(core_1.getSystemPath(projectRoot), '@angular/service-worker/ngsw-worker.js'));
    const swConfigPath = require_project_module_1.resolveProjectModule(core_1.getSystemPath(projectRoot), '@angular/service-worker/config');
    const safetyPath = core_1.join(core_1.dirname(workerPath), 'safety-worker.js');
    const configPath = ngswConfigPath || core_1.join(appRoot, 'ngsw-config.json');
    return host.exists(configPath).pipe(operators_1.switchMap(exists => {
        if (!exists) {
            throw new Error(core_1.tags.oneLine `
          Error: Expected to find an ngsw-config.json configuration
          file in the ${appRoot} folder. Either provide one or disable Service Worker
          in your angular.json configuration file.`);
        }
        return host.read(configPath);
    }), operators_1.map(content => JSON.parse(core_1.virtualFs.fileBufferToString(content))), operators_1.switchMap(configJson => {
        const GeneratorConstructor = require(swConfigPath).Generator;
        const gen = new GeneratorConstructor(new CliFilesystem(host, outputPath), baseHref);
        return gen.process(configJson);
    }), operators_1.switchMap(output => {
        const manifest = JSON.stringify(output, null, 2);
github angular / angular-cli / packages / angular_devkit / build_angular / src / protractor / index.ts View on Github external
private _runProtractor(root: Path, options: ProtractorBuilderOptions): Observable {
    const additionalProtractorConfig: Partial = {
      elementExplorer: options.elementExplorer,
      baseUrl: options.baseUrl,
      specs: options.specs.length ? options.specs : undefined,
      suite: options.suite,
    };

    // TODO: Protractor manages process.exit itself, so this target will allways quit the
    // process. To work around this we run it in a subprocess.
    // https://github.com/angular/protractor/issues/4160
    return runModuleAsObservableFork(
      getSystemPath(root),
      'protractor/built/launcher',
      'init',
      [
        getSystemPath(resolve(root, normalize(options.protractorConfig))),
        additionalProtractorConfig,
      ],
    );
  }
}
github nrwl / nx / packages / web / src / builders / build / build.builder.ts View on Github external
constructor(private context: BuilderContext) {
    this.webpackBuilder = new WebpackBuilder(this.context);
    this.root = getSystemPath(this.context.workspace.root);
  }
github johandb / svg-drawing-tool / node_modules / @ngtools / webpack / src / compiler_host.js View on Github external
denormalizePath(path) {
        return core_1.getSystemPath(core_1.normalize(path));
    }
    resolve(path) {
github nrwl / nx / packages / web / src / utils / third-party / utils / build-browser-features_spec.ts View on Github external
beforeEach(async () => {
    await host.initialize().toPromise();
    workspaceRootSysPath = getSystemPath(host.root());
  });
github linnenschmidt / build-ng-packagr / packages / builders / src / build-ng-packagr / src / build / assets.ts View on Github external
export function handleAssets(
  context: BuilderContext,
  options: NgPackagrBuilderOptions,
): Observable {
  const host = new NodeJsSyncHost();
  const projectPath = resolve(normalize(context.workspaceRoot), normalize(path.dirname(options.project)));
  const projectRoot = getSystemPath(projectPath);

  return from(discoverPackages({ project: projectRoot }).then(ngPackage => {
    log.info('Copying Assets');
    const syncHost = new virtualFs.SyncDelegateHost(host);

    if (options.assets.length === 0) {
      return Promise.resolve();
    }

    const assets = normalizeAssetPatterns(
      options.assets,
      syncHost,
      projectPath,
      projectPath,
      undefined,
    );
github manfredsteyer / ngx-build-plus / lib / src / utils / index.ts View on Github external
}
      if (!options.keepPolyfills && config.entry && config.entry['polyfills-es5']) {
        delete config.entry['polyfills-es5'];
      }      
      if (config.optimization) {
        delete config.optimization.runtimeChunk;
        delete config.optimization.splitChunks;
      }
    }

    if (options.singleBundle && (options.bundleStyles !== false || options.keepStyles) && config.entry && config.entry['styles']) {
      delete config.entry['styles'];
    }

    if (options.extraWebpackConfig) {
      const filePath = path.resolve(getSystemPath(normalize(context.workspaceRoot)), options.extraWebpackConfig);
      const additionalConfig = require(filePath);
      config = webpackMerge([config, additionalConfig]);
    }
    if (plugin && plugin.config) {
      config = plugin.config(config, options);
    }

    if (options.configHook) {
        const hook = loadHook(options.configHook);
        config = hook(config);
    }

    if (originalConfigFn) {
      return originalConfigFn(config);
    }
    else {