How to use the @angular-devkit/schematics.url function in @angular-devkit/schematics

To help you get started, we’ve selected a few @angular-devkit/schematics 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 xmlking / ngx-starter-kit / tools / src / schematics / store / index.ts View on Github external
const project = getProject(host, id);

    if (options.path === undefined) {
      options.path = buildDefaultPath(project);
    }

    options.module = findModuleFromOptions(host, options);

    const parsedPath = parseName(options.path, options.name);
    options.name = parsedPath.name;
    options.path = parsedPath.path;

    validateName(options.name);
    console.log(options);

    const templateSource = apply(url('./_files'), [
      template({
        ...strings,
        ...options,
      }),
      // move(parsedPath.path),
    ]);

    const rule = chain([branchAndMerge(chain([mergeWith(templateSource)]))]);

    return rule(host, context);
  };
}
github johandb / svg-drawing-tool / node_modules / @schematics / angular / directive / index.js View on Github external
if (!options.project) {
            throw new schematics_1.SchematicsException('Option (project) is required.');
        }
        const project = project_1.getProject(host, options.project);
        if (options.path === undefined) {
            options.path = project_1.buildDefaultPath(project);
        }
        options.module = find_module_1.findModuleFromOptions(host, options);
        const parsedPath = parse_name_1.parseName(options.path, options.name);
        options.name = parsedPath.name;
        options.path = parsedPath.path;
        options.selector = options.selector || buildSelector(options, project.prefix);
        validation_1.validateHtmlSelector(options.selector);
        // todo remove these when we remove the deprecations
        options.skipTests = options.skipTests || !options.spec;
        const templateSource = schematics_1.apply(schematics_1.url('./files'), [
            options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts')) : schematics_1.noop(),
            schematics_1.template(Object.assign({}, core_1.strings, { 'if-flat': (s) => options.flat ? '' : s }, options)),
            schematics_1.move(parsedPath.path),
        ]);
        return schematics_1.chain([
            schematics_1.branchAndMerge(schematics_1.chain([
                addDeclarationToNgModule(options),
                schematics_1.mergeWith(templateSource),
            ])),
            options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
        ]);
    };
}
github nrwl / nx / packages / bazel / src / schematics / sync / sync.ts View on Github external
return host => {
    return mergeWith(
      apply(url('./files/root-build-file'), [
        template({
          tmpl: '',
          rootFiles: host
            .getDir('/')
            .subfiles.filter(f => !ignoredFromRootBuildFile.includes(f))
        }),
        () => {
          if (host.exists('BUILD.bazel')) {
            host.delete('BUILD.bazel');
          }
        }
      ]),
      MergeStrategy.Overwrite
    );
  };
}
github fossasia / susper.com / node_modules / @schematics / angular / interface / index.js View on Github external
function default_1(options) {
    options.prefix = options.prefix ? options.prefix : '';
    options.type = !!options.type ? `.${options.type}` : '';
    options.path = options.path ? core_1.normalize(options.path) : options.path;
    const sourceDir = options.sourceDir;
    if (!sourceDir) {
        throw new schematics_1.SchematicsException(`sourceDir option is required.`);
    }
    const templateSource = schematics_1.apply(schematics_1.url('./files'), [
        schematics_1.template(Object.assign({}, stringUtils, options)),
        schematics_1.move(sourceDir),
    ]);
    return schematics_1.chain([
        schematics_1.branchAndMerge(schematics_1.chain([
            schematics_1.mergeWith(templateSource),
        ])),
    ]);
}
exports.default = default_1;
github nestjs / schematics / src / lib / provider / provider.factory.ts View on Github external
return (context: SchematicContext) =>
    apply(url(join('./files' as Path, options.language)), [
      options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
      template({
        ...strings,
        ...options,
      }),
      move(options.path),
    ])(context);
}
github nstudio / xplat / packages / workspace / src / utils / xplat.ts View on Github external
export function addFiles(
    options: Schema,
    target: string = '',
    projectName: string = '',
    extra: string = ''
  ) {
    let moveTo: string;
    if (target) {
      moveTo = getMoveTo(options, target, projectName);
    } else {
      target = 'lib';
      moveTo = `libs/features/${options.name.toLowerCase()}`;
    }
    return branchAndMerge(
      mergeWith(
        apply(url(`./${extra}_files`), [
          template(getTemplateOptions(options)),
          move(moveTo)
        ])
      )
    );
  };
github nstudio / xplat / packages / nativescript-angular / src / schematics / application / index.ts View on Github external
function addAppFiles(
  options: Schema,
  appPath: string,
  extra: string = ''
): Rule {
  extra = extra ? `${extra}_` : '';
  const appname = getAppName(options, 'nativescript');
  const directory = options.directory ? `${options.directory}/` : '';
  return branchAndMerge(
    mergeWith(
      apply(url(`./_${extra}files`), [
        template({
          ...(options as any),
          ...getDefaultTemplateOptions(),
          appname,
          pathOffset: directory ? '../../../' : '../../',
          xplatFolderName: XplatHelpers.getXplatFoldername(
            'nativescript',
            'angular'
          )
        }),
        move(`apps/${directory}${appPath}`)
      ])
    )
  );
}
github nrwl / nx / packages / schematics / migrations / update-6-2-0 / update-6-2-0.ts View on Github external
function addGlobalKarmaConf() {
  const templateSource = url('./files');
  return mergeWith(templateSource);
}
github rxweb / rxweb / rxweb.io / node_modules / @schematics / angular / guard / index.js View on Github external
return (host) => {
        const workspace = config_1.getWorkspace(host);
        if (!options.project) {
            throw new schematics_1.SchematicsException('Option (project) is required.');
        }
        const project = workspace.projects[options.project];
        if (options.path === undefined) {
            options.path = project_1.buildDefaultPath(project);
        }
        const parsedPath = parse_name_1.parseName(options.path, options.name);
        options.name = parsedPath.name;
        options.path = parsedPath.path;
        const templateSource = schematics_1.apply(schematics_1.url('./files'), [
            options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
            schematics_1.template(Object.assign({}, core_1.strings, options)),
            schematics_1.move(parsedPath.path),
        ]);
        return schematics_1.chain([
            schematics_1.branchAndMerge(schematics_1.chain([
                schematics_1.mergeWith(templateSource),
            ])),
        ]);
    };
}