How to use the @angular-devkit/core.schema.CoreSchemaRegistry 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 just-jeb / angular-builders / packages / jest / src / index.ts View on Github external
export async function getRoots(
  context: BuilderContext
): Promise<{ workspaceRoot: Path; projectRoot: Path }> {
  const host = new NodeJsSyncHost();
  const registry = new schema.CoreSchemaRegistry();
  registry.addPostTransform(schema.transforms.addUndefinedDefaults);
  const workspace = await experimental.workspace.Workspace.fromPath(
    host,
    normalize(context.workspaceRoot),
    registry
  );
  const projectName = context.target ? context.target.project : workspace.getDefaultProjectName();

  if (!projectName) {
    throw new Error('Must either have a target from the context or a default project.');
  }

  // const projectRoot = resolve(
  //     workspace.root,
  //     normalize(workspace.getProject(projectName).root),
  // );
github angular / angular-cli / packages / angular / cli / models / schematic-command.ts View on Github external
protected async createWorkflow(options: BaseSchematicSchema): Promise {
    if (this._workflow) {
      return this._workflow;
    }

    const { force, dryRun } = options;
    const fsHost = new virtualFs.ScopedHost(new NodeJsSyncHost(), normalize(this.workspace.root));

    const workflow = new NodeWorkflow(fsHost, {
      force,
      dryRun,
      packageManager: await getPackageManager(this.workspace.root),
      root: normalize(this.workspace.root),
      registry: new schema.CoreSchemaRegistry(formats.standardFormats),
      resolvePaths: !!this.workspace.configFile
        // Workspace
        ? [process.cwd(), this.workspace.root]
        // Global
        : [__dirname, process.cwd()],
    });
    workflow.engineHost.registerContextTransform(context => {
      // This is run by ALL schematics, so if someone uses `externalSchematics(...)` which
      // is safelisted, it would move to the right analytics (even if their own isn't).
      const collectionName: string = context.schematic.collection.description.name;
      if (isPackageNameSafeForAnalytics(collectionName)) {
        return {
          ...context,
          analytics: this.analytics,
        };
      } else {
github nrwl / nx / packages / storybook / src / utils / testing.ts View on Github external
export async function getTestArchitect() {
  const tmpDir = getTempDir();
  const architectHost = new TestingArchitectHost(tmpDir, tmpDir);
  const registry = new schema.CoreSchemaRegistry();
  registry.addPostTransform(schema.transforms.addUndefinedDefaults);

  const architect = new Architect(architectHost, registry);

  await architectHost.addBuilderFromPackage(join(__dirname, '../..'));

  return [architect, architectHost] as [Architect, TestingArchitectHost];
}
github angular / angular-cli / packages / angular_devkit / schematics / testing / schematic-test-runner.ts View on Github external
constructor(private _collectionName: string, collectionPath: string) {
    this._engineHost.registerCollection(_collectionName, collectionPath);
    this._logger = new logging.Logger('test');

    const registry = new schema.CoreSchemaRegistry(formats.standardFormats);
    registry.addPostTransform(schema.transforms.addUndefinedDefaults);

    this._engineHost.registerOptionsTransform(validateOptionsWithSchema(registry));
    this._engineHost.registerTaskExecutor(BuiltinTaskExecutor.NodePackage);
    this._engineHost.registerTaskExecutor(BuiltinTaskExecutor.RepositoryInitializer);
    this._engineHost.registerTaskExecutor(BuiltinTaskExecutor.RunSchematic);
    this._engineHost.registerTaskExecutor(BuiltinTaskExecutor.TslintFix);

    this._collection = this._engine.createCollection(this._collectionName);
  }
github bennymeg / nx-electron / src / utils / testing.ts View on Github external
export async function getTestArchitect() {
  const architectHost = new TestingArchitectHost('/root', '/root');
  const registry = new schema.CoreSchemaRegistry();
  registry.addPostTransform(schema.transforms.addUndefinedDefaults);

  const architect = new Architect(architectHost, registry);

  await architectHost.addBuilderFromPackage(join(__dirname, '../..'));

  return [architect, architectHost] as [Architect, TestingArchitectHost];
}
github angular / angular-cli / packages / angular_devkit / schematics / src / workflow / base.ts View on Github external
constructor(options: BaseWorkflowOptions) {
    this._host = options.host;
    this._engineHost = options.engineHost;

    if (options.registry) {
      this._registry = options.registry;
    } else {
      this._registry = new schema.CoreSchemaRegistry(standardFormats);
      this._registry.addPostTransform(schema.transforms.addUndefinedDefaults);
    }

    this._engine = new SchematicEngine(this._engineHost, this);

    this._context = [];

    this._force = options.force || false;
    this._dryRun = options.dryRun || false;
  }
github angular / angular-cli / packages / angular_devkit / schematics / src / formats / format-validator.ts View on Github external
export function formatValidator(
  data: JsonValue,
  dataSchema: JsonObject,
  formats: schema.SchemaFormat[],
): Observable {
  const registry = new schema.CoreSchemaRegistry();

  for (const format of formats) {
    registry.addFormat(format);
  }

  return registry
    .compile(dataSchema)
    .pipe(mergeMap(validator => validator(data)));
}
github nrwl / nx / packages / workspace / src / command-line / workspace-schematic.ts View on Github external
function createWorkflow(dryRun: boolean) {
  const root = normalize(rootDirectory);
  const host = new virtualFs.ScopedHost(new NodeJsSyncHost(), root);
  return new NodeWorkflow(host, {
    packageManager: detectPackageManager(),
    root,
    dryRun,
    registry: new schema.CoreSchemaRegistry(formats.standardFormats)
  });
}
github nrwl / nx / packages / workspace / src / builders / run-commands / run-commands.impl.spec.ts View on Github external
beforeEach(async () => {
    const registry = new schema.CoreSchemaRegistry();
    registry.addPostTransform(schema.transforms.addUndefinedDefaults);
    const testArchitectHost = new TestingArchitectHost('/root', '/root');

    architect = new Architect(testArchitectHost, registry);
    await testArchitectHost.addBuilderFromPackage(join(__dirname, '../../..'));
  });