How to use @angular-devkit/architect - 10 common examples

To help you get started, we’ve selected a few @angular-devkit/architect 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_webpack / src / test-utils.ts View on Github external
* @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';


const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
github angular / universal / modules / builders / testing / utils.ts View on Github external
cp(
  '-ru',
  testingAppSrc,
  templateRoot,
);

// link node packages
symlinkSync(
  path.join(require.resolve('npm/node_modules/@angular/core/package.json'), '../../../'),
  path.join(process.env.TEST_TMPDIR as string, 'node_modules'),
  'junction'
);

export const workspaceRoot = normalize(templateRoot);
export const host = new TestProjectHost(workspaceRoot);
export const outputPathBrowser = normalize('dist/app/browser');
export const outputPathServer = normalize('dist/app/server');

export async function createArchitect(root: Path) {
  const workspaceSysPath = getSystemPath(root);

  // link @nguniversal packages
  const nodeModuleDir = path.join(workspaceSysPath, 'node_modules');
  if (!existsSync(nodeModuleDir)) {
    mkdirSync(nodeModuleDir);
  }
  const ngUniversalNodePackages = path.join(nodeModuleDir, '@nguniversal');
  if (!existsSync(ngUniversalNodePackages)) {
    mkdirSync(ngUniversalNodePackages);
  }
github angular / angular-cli / packages / angular_devkit / build_webpack / src / test-utils.ts View on Github external
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';


const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
github angular / angular-cli / packages / angular_devkit / architect_cli / bin / architect.ts View on Github external
async function _executeTarget(
  parentLogger: logging.Logger,
  workspace: workspaces.WorkspaceDefinition,
  root: string,
  argv: minimist.ParsedArgs,
  registry: schema.SchemaRegistry,
) {
  const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, root);
  const architect = new Architect(architectHost, registry);

  // Split a target into its parts.
  const targetStr = argv._.shift() || '';
  const [project, target, configuration] = targetStr.split(':');
  const targetSpec = { project, target, configuration };

  delete argv['help'];
  delete argv['_'];

  const logger = new logging.Logger('jobs');
  const logs: logging.LogEntry[] = [];
  logger.subscribe(entry => logs.push({ ...entry, message: `${entry.name}: ` + entry.message }));

  const run = await architect.scheduleTarget(targetSpec, argv, { logger });
  const bars = new MultiProgressBar(':name :bar (:current/:total) :status');
github angular / angular-cli / packages / angular_devkit / architect_cli / bin / architect.ts View on Github external
async function _executeTarget(
  parentLogger: logging.Logger,
  workspace: workspaces.WorkspaceDefinition,
  root: string,
  argv: minimist.ParsedArgs,
  registry: schema.SchemaRegistry,
) {
  const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, root);
  const architect = new Architect(architectHost, registry);

  // Split a target into its parts.
  const targetStr = argv._.shift() || '';
  const [project, target, configuration] = targetStr.split(':');
  const targetSpec = { project, target, configuration };

  delete argv['help'];
  delete argv['_'];

  const logger = new logging.Logger('jobs');
  const logs: logging.LogEntry[] = [];
  logger.subscribe(entry => logs.push({ ...entry, message: `${entry.name}: ` + entry.message }));

  const run = await architect.scheduleTarget(targetSpec, argv, { logger });
  const bars = new MultiProgressBar(':name :bar (:current/:total) :status');
github nrwl / nx / packages / web / src / utils / third-party / utils / build-browser-features_spec.ts View on Github external
* Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { BuildBrowserFeatures } from './build-browser-features';

const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
  devkitRoot,
  'tests/angular_devkit/build_angular/hello-world-app/'
);

const host = new TestProjectHost(workspaceRoot);

describe('BuildBrowserFeatures', () => {
  let workspaceRootSysPath = '';
  beforeEach(async () => {
    await host.initialize().toPromise();
    workspaceRootSysPath = getSystemPath(host.root());
  });

  afterEach(async () => host.restore().toPromise());

  describe('isDifferentialLoadingNeeded', () => {
    it('should be true for for IE 9-11 and ES2015', () => {
      host.writeMultipleFiles({
        browserslist: 'IE 9-11'
      });
github angular / angular-cli / packages / angular_devkit / build_angular / src / utils / differential-loading_spec.ts View on Github external
* Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */


import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { isDifferentialLoadingNeeded } from './differential-loading';

const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
  devkitRoot,
  'tests/angular_devkit/build_angular/hello-world-app/');

const host = new TestProjectHost(workspaceRoot);


describe('differential loading', () => {

  beforeEach(async () => host.initialize().toPromise());
  afterEach(async () => host.restore().toPromise());

  it('detects the need for differential loading for IE 9-11 and ES2015', () => {
    host.writeMultipleFiles({
      'browserslist': 'IE 9-11',
    });

    const needed = isDifferentialLoadingNeeded(getSystemPath(host.root()), ScriptTarget.ES2015);
    expect(needed).toBe(true);
  });
github Tibing / platform-terminal / projects / platform-terminal-builder / terminal / index.ts View on Github external
import { BuilderContext, createBuilder } from '@angular-devkit/architect';
import { json } from '@angular-devkit/core';
import { Observable } from 'rxjs';
import { BrowserBuilderOutput, executeBrowserBuilder, ExecutionTransformer } from '@angular-devkit/build-angular';
import { IndexHtmlTransform } from '@angular-devkit/build-angular/src/angular-cli-files/utilities/index-file/write-index-html';
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack';
import * as webpack from 'webpack';
import { Configuration } from 'webpack';

import { TerminalSchema } from './schema';


export default createBuilder(createTerminal);

interface Transforms {
  webpackConfiguration?: ExecutionTransformer;
  logging?: WebpackLoggingCallback;
  indexHtml?: IndexHtmlTransform;
}

function createTerminal(schema: TerminalSchema, context: BuilderContext): Observable {
  const transforms: Transforms = createTransforms();
  // @ts-ignore
  return executeBrowserBuilder(schema, context, transforms);
}

function createTransforms(): Transforms {
  return {
    webpackConfiguration(input: Configuration) {
github BenjaminDobler / ngtron / builders / serve / index.1.ts View on Github external
// Logger.info("ELECTRON WATCH (stdout): " + data.toString());
    });

    ls.stderr.on("data", function(data) {
      // Logger.error("ELECTRON WATCH (stderr): " + data.toString());
    });

    ls.on("exit", function(code) {
      // Logger.info("ELECTRON WATCH (exit): " + code.toString());
      // reject(0);
      resolve();
    });
  });
}

export default createBuilder(
  execute
);
/*
export default createBuilder(
  serveCustomWebpackBrowser
);
*/
github nrwl / nx / packages / web / src / builders / build / build.impl.ts View on Github external
polyfills?: string;
  es2015Polyfills?: string;

  scripts: string[];
  styles: string[];

  vendorChunk?: boolean;
  commonChunk?: boolean;

  stylePreprocessingOptions?: any;
  subresourceIntegrity?: boolean;

  verbose?: boolean;
}

export default createBuilder(run);

export function run(options: WebBuildBuilderOptions, context: BuilderContext) {
  const host = new NodeJsSyncHost();
  const isScriptOptimizeOn =
    typeof options.optimization === 'boolean'
      ? options.optimization
      : options.optimization && options.optimization.scripts
      ? options.optimization.scripts
      : false;

  // Node versions 12.2-12.8 has a bug where prod builds will hang for 2-3 minutes
  // after the program exits.
  const nodeVersion = execSync(`node --version`)
    .toString('utf-8')
    .trim();
  const supportedRange = new Range('10 || >=12.9');