How to use the @angular-devkit/architect.createBuilder function in @angular-devkit/architect

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 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');
github aigoncharov / angular-builder-custom-terser-options / src / dev-server / index.ts View on Github external
import { createBuilder } from '@angular-devkit/architect'
import { executeDevServerBuilder } from '@angular-devkit/build-angular'
import { Schema as DevServerBuilderSchema } from '@angular-devkit/build-angular/src/dev-server/schema'
import { json } from '@angular-devkit/core'

import { decorateBuilder } from '../common'

export * from '@angular-devkit/build-angular/src/dev-server'
export default createBuilder(decorateBuilder(executeDevServerBuilder))
github angular-guru / electron-builder / src / electron / index.ts View on Github external
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
import { executeBrowserBuilder } from '@angular-devkit/build-angular';
import { json } from '@angular-devkit/core';
import { Observable } from 'rxjs';

export function buildElectron(options: any, context: BuilderContext): Observable {
  return executeBrowserBuilder(options, context, {
    webpackConfiguration: (config) => {
      return { ...config, target: 'electron-renderer' };
    }
  });
}

export default createBuilder(buildElectron);
github nrwl / nx / packages / cypress / src / builders / cypress / cypress.impl.ts View on Github external
record: boolean;
  key?: string;
  tsConfig: string;
  watch: boolean;
  browser?: string;
  env?: Record;
  spec?: string;
  copyFiles?: string;
  ciBuildId?: string;
}

try {
  require('dotenv').config();
} catch (e) {}

export default createBuilder(run);

/**
 * @whatItDoes This is the starting point of the builder.
 * @param options
 * @param context
 */
function run(
  options: CypressBuilderOptions,
  context: BuilderContext
): Observable {
  const legacy = isLegacy(options, context);
  if (legacy) {
    showLegacyWarning(context);
  }
  options.env = options.env || {};
  if (options.tsConfig) {
github dynatrace-oss / barista / tools / builders / packager / index.ts View on Github external
*
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { createBuilder } from '@angular-devkit/architect';
import { PackagerOptions } from './schema';
import { packager } from './build';
import { JsonObject } from '@angular-devkit/core';

export default createBuilder(packager);
github briebug / cypress-schematic / src / builders / cypress / index.ts View on Github external
import {
  BuilderContext,
  BuilderOutput,
  createBuilder,
  scheduleTargetAndForget,
  targetFromTargetString
} from "@angular-devkit/architect";
import { asWindowsPath, experimental, normalize } from "@angular-devkit/core";
import { NodeJsSyncHost } from "@angular-devkit/core/node";

import { CypressBuilderOptions } from "./cypress-builder-options";

const cypress = require("cypress");

export default createBuilder(run);

function run(
  options: CypressBuilderOptions,
  context: BuilderContext
): Observable {
  options.env = options.env || {};

  if (options.tsConfig) {
    options.env.tsConfig = join(context.workspaceRoot, options.tsConfig);
  }

  const workspace = new experimental.workspace.Workspace(
    normalize(context.workspaceRoot),
    new NodeJsSyncHost()
  );
github nrwl / nx / packages / workspace / src / builders / run-commands / run-commands.impl.ts View on Github external
import { Observable } from 'rxjs';
import { TEN_MEGABYTES } from '@nrwl/workspace/src/core/file-utils';

try {
  require('dotenv').config();
} catch (e) {}

export interface RunCommandsBuilderOptions extends JsonObject {
  commands: { command: string }[];
  parallel?: boolean;
  readyWhen?: string;
  args?: string;
  parsedArgs?: { [key: string]: string };
}

export default createBuilder(run);

function run(
  options: RunCommandsBuilderOptions,
  context: BuilderContext
): Observable {
  options.parsedArgs = parseArgs(options.args);
  return Observable.create(async observer => {
    if (!options.commands) {
      observer.next({
        success: false,
        error:
          'ERROR: Bad builder config for @nrwl/run-command - "commands" option is required'
      });
      return;
    }
github nrwl / nx / packages / web / src / builders / dev-server / dev-server.impl.ts View on Github external
export interface WebDevServerOptions extends JsonObject {
  host: string;
  port: number;
  publicHost?: string;
  ssl: boolean;
  sslKey?: string;
  sslCert?: string;
  proxyConfig?: string;
  buildTarget: string;
  open: boolean;
  liveReload: boolean;
  watch: boolean;
  allowedHosts: string;
}

export default createBuilder(run);

function run(
  serveOptions: WebDevServerOptions,
  context: BuilderContext
): Observable {
  const host = new NodeJsSyncHost();
  return forkJoin(
    getBuildOptions(serveOptions, context),
    from(getSourceRoot(context, host))
  ).pipe(
    map(([buildOptions, sourceRoot]) => {
      buildOptions = normalizeWebBuildOptions(
        buildOptions,
        context.workspaceRoot,
        sourceRoot
      );