How to use the @angular-devkit/architect.targetFromTargetString 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 angular / universal / modules / builders / src / prerender / index.ts View on Github external
async function _scheduleBuilds(
  options: PrerenderBuilderOptions,
  context: BuilderContext
): Promise {
  const browserTarget = targetFromTargetString(options.browserTarget);
  const serverTarget = targetFromTargetString(options.serverTarget);

  const browserTargetRun = await context.scheduleTarget(browserTarget, {
    watch: false,
    serviceWorker: false,
    // todo: handle service worker augmentation
  });
  const serverTargetRun = await context.scheduleTarget(serverTarget, {
    watch: false,
  });

  try {
    const [browserResult, serverResult] = await Promise.all([
      browserTargetRun.result as unknown as BuildBuilderOutput,
      serverTargetRun.result as unknown as BuildBuilderOutput,
    ]);
github BenjaminDobler / ngtron / builders / serve / index.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            const browserTarget = architect_1.targetFromTargetString(options.browserTarget);
            serverOptions = yield context.getTargetOptions(browserTarget);
            const buildOptions = yield context.getTargetOptions({
                project: context.target.project,
                target: "build"
            });
            buildOptions.browserTarget = context.target.project + ":build";
            buildOptions.port = options.port ? options.port : 4200;
            buildOptions.watch = true;
            const electronBuildTarget = architect_1.targetFromTargetString(context.target.project + ":package-electron");
            buildElectronOptions = yield context.getTargetOptions(electronBuildTarget);
            return {
                buildOptions: buildOptions,
                buildElectronOptions: buildElectronOptions
            };
        });
    }
github nrwl / nx / packages / web / src / builders / dev-server / dev-server.impl.ts View on Github external
function getBuildOptions(
  options: WebDevServerOptions,
  context: BuilderContext,
  overrides?: Partial
): Observable {
  const target = targetFromTargetString(options.buildTarget);
  return from(
    Promise.all([
      context.getTargetOptions(target),
      context.getBuilderNameForTarget(target)
    ])
      .then(([options, builderName]) =>
        context.validateOptions(
          options,
          builderName
        )
      )
      .then(options => ({
        ...options,
        ...overrides
      }))
  );
github enten / udk / angular / lib / serve / devContainer.ts View on Github external
if (!targetString) {
      throw new Error('Must either have --target');
    }

    this.universalOptions = await this.validateTargetOptions(targetString);
    this.browserOptions = await this.validateTargetOptions(
      this.universalOptions.browserTarget,
      { watch: true },
    );
    this.serverOptions = await this.validateTargetOptions(
      this.universalOptions.serverTarget,
      { watch: true },
    );

    const udkTarget = targetFromTargetString(targetString);
    const udkBuilderName = await this.architectHost.getBuilderNameForTarget(udkTarget);
    const udkBuilderInfo = await this.architectHost.resolveBuilder(udkBuilderName);

    this.builderContext = {
      builder: udkBuilderInfo,
      workspaceRoot: root,
      currentDirectory: path.dirname(currentPath),
      target: udkTarget,
      logger: this.architectLogger,
      id: 0,
      getBuilderNameForTarget: (target: Target) => {
        return this.architectHost.getBuilderNameForTarget(target);
      },
      getProjectMetadata: (target: string | Target): Promise => {
        return this.architectHost.getProjectMetadata(target);
      },
github kyubisation / angular-server-side-configuration / builders / ngsscbuild / ngssc-builder.ts View on Github external
constructor(
    private _options: Options,
    private _context: BuilderContext,
  ) {
    this._browserTarget = targetFromTargetString(_options.browserTarget);
    this._ngsscEnvironmentFile = join(_context.workspaceRoot, _options.ngsscEnvironmentFile);
    this._tmpNgsscEnvironmentFile = `${_options.ngsscEnvironmentFile}_${randomBytes(10).toString('hex')}.tmp`;
    this._context.addTeardown(() => this._removeTmpNgsscEnvironmentFile());
  }
github BenjaminDobler / ngtron / builders / package / index.ts View on Github external
async function setup() {
    const browserTarget = targetFromTargetString(options.browserTarget);
    serverOptions = await context.getTargetOptions(browserTarget);
    const buildOptions = await context.getTargetOptions({
      project: context.target.project,
      configuration: context.target.configuration,
      target: "build"
    });
    buildOptions.browserTarget = context.target.project + ":package-electron";
    buildOptions.port = options.port ? options.port : 4200;
    buildOptions.watch = false;
    buildOptions.baseHref = "./";

    const electronBuildTarget = targetFromTargetString(context.target.project + ":package-electron");

    buildElectronOptions = await context.getTargetOptions(electronBuildTarget);

    return {
github bennymeg / nx-electron / src / builders / execute / execute.impl.ts View on Github external
function startBuild(options: ElectronExecuteBuilderOptions, context: BuilderContext): Observable {
  const target = targetFromTargetString(options.buildTarget);

  return from(
    Promise.all([
      context.getTargetOptions(target),
      context.getBuilderNameForTarget(target)
    ]).then(([options, builderName]) =>
      context.validateOptions(options, builderName)
    )
  ).pipe(
    tap(options => {
      if (options.optimization) {
        context.logger.warn(stripIndents`
            ************************************************
            This is a simple process manager for use in
            testing or debugging Electron applications locally.
            DO NOT USE IT FOR PRODUCTION!
github BenjaminDobler / ngtron / src / builders / build / index.ts View on Github external
const builderRuns$: Observable[] = options.rendererTargets.map((target) => {
      const rendererTarget = targetFromTargetString(target);
      const overrides = {
        outputPath: options.rendererOutputPath + '/' + rendererTarget.project,
        watch: options.watch,
        baseHref: "./",
        aot: false,
        optimization: false,
        webpackConfig: {
          externals: externals
        }
      }
      return from(context.scheduleTarget(rendererTarget, overrides));
    });
github enten / udk / angular / lib / devContainer.ts View on Github external
if (!builderInfo) {
          throw new Error(`No builder info were found for builder ${JSON.stringify(builderName)}.`);
        }

        const validate = await this.registry.compile(builderInfo.optionSchema).toPromise();
        const validation = await validate(options).toPromise();

        if (!validation.success) {
          throw new json.schema.SchemaValidationException(validation.errors);
        }

        return validation.data;
      },
    } as {} as BuilderContext;

    const browserTarget = targetFromTargetString(this.builderOptions.browserTarget);
    const browserOptionsRaw = await this.builderContext.getTargetOptions(browserTarget);

    if (browserOptionsRaw.index) {
      this.browserIndexHtml = browserOptionsRaw.index as string;
      this.browserIndexSourcePath = join(normalize(this.workspace.root), this.browserIndexHtml);
      this.browserIndexOutputPath = join(
        normalize(this.workspace.root),
        browserOptionsRaw.outputPath as string,
        basename(normalize(this.browserIndexHtml)),
      );
    }

    this.browserOptions = browserOptionsRaw as {} as BrowserBuilderSchema;

    await super.bootstrap();