How to use the @schematics/angular/utility/project.getProject function in @schematics/angular

To help you get started, we’ve selected a few @schematics/angular 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 SAP / fundamental-ngx / libs / core / schematics / ng-add / index.ts View on Github external
return (tree: Tree) => {
        // tslint:disable-next-line:no-non-null-assertion
        const modulePath = getAppModulePath(tree, getProject(tree, options.project)!.architect!.build!.options!.main);

        if (options.animations) {
            if (hasModuleImport(tree, modulePath, noopAnimationsModuleName)) {
                return console.warn(chalk.red(`Could not set up "${chalk.bold(browserAnimationsModuleName)}" ` +
                    `because "${chalk.bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
                    `set up browser animations.`));
            }
            addImportToRootModule(tree, browserAnimationsModuleName,
                '@angular/platform-browser/animations', modulePath);
            console.log(chalk.green(`✅️ Added ${browserAnimationsModuleName} to root module.`));
        } else if (!hasModuleImport(tree, modulePath, browserAnimationsModuleName)) {
            addImportToRootModule(tree, noopAnimationsModuleName,
                '@angular/platform-browser/animations', modulePath);
            console.log(chalk.green(`✅️ Added ${noopAnimationsModuleName} to root module.`));
        }
        return tree;
github intershop / intershop-pwa / schematics / src / page / factory.js View on Github external
function determineRoutingModule(host, options) {
    const project = project_1.getProject(host, options.project);
    let routingModuleLocation;
    let child;
    const match = options.name.match(/(.*)\-([a-z0-9]+)/);
    if (match && match[1] && match[2]) {
        const parent = match[1];
        child = match[2];
        // tslint:disable-next-line:no-console
        console.log(`detected subpage, will insert '${child}' as sub page of '${parent}'`);
        routingModuleLocation = options.extension
            ? `extensions/${options.extension}/pages/${parent}/${parent}-page.module.ts`
            : `pages/${parent}/${parent}-page.module.ts`;
    }
    else {
        routingModuleLocation = options.extension
            ? `extensions/${options.extension}/pages/${options.extension}-routing.module.ts`
            : 'pages/app-routing.module.ts';
github intershop / intershop-pwa / schematics / src / utils / common.ts View on Github external
export function applyNameAndPath(
  artifact: string,
  host: Tree,
  options: {
    project?: string;
    name?: string;
    path?: string;
    restricted?: boolean;
    flat?: boolean;
    artifactFolder?: boolean;
  }
) {
  let path = options.path;
  let name = options.name;

  const project = getProject(host, options.project);

  // remove possible added path from root
  if (name && name.startsWith('src/app/')) {
    name = name.substr(8);
  }

  const parsedPath = parseName(path || buildDefaultPath(project), name);
  name = parsedPath.name;
  if (artifact) {
    name = name.replace(new RegExp(`\-?${artifact}$`), '');
  }

  if (!options.restricted) {
    path = parsedPath.path;
  }
  if (options.artifactFolder) {
github intershop / intershop-pwa / schematics / src / utils / common.js View on Github external
function detectExtension(artifact, host, options) {
    const project = project_1.getProject(host, options.project);
    let extension = options.extension;
    const regex = /extensions\/([a-z][a-z0-9-]+)/;
    const requestDestination = core_1.normalize(`${options.path}/${options.name}`);
    if (regex.test(requestDestination)) {
        extension = requestDestination.match(regex)[1];
    }
    let path = options.path;
    if (options.restricted) {
        if (!extension) {
            let rootLocation;
            if (artifact === 'cms') {
                rootLocation = 'shared/';
            }
            else if (['page', 'extension'].includes(artifact)) {
                rootLocation = '';
            }
github ionic-team / angular-toolkit / schematics / page / index.ts View on Github external
return (host, context) => {
    if (!options.project) {
      throw new SchematicsException('Option (project) is required.');
    }

    const project = getProject(host, options.project);

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

    options.module = findRoutingModuleFromOptions(host, options);

    const parsedPath = parseName(options.path, options.name);
    options.name = parsedPath.name;
    options.path = parsedPath.path;
    options.selector = options.selector ? options.selector : buildSelector(options, project.prefix);

    validateName(options.name);
    validateHtmlSelector(options.selector);

    const templateSource = apply(url('./files'), [
github BenjaminDobler / ngtron / schematics / ng-add / index.js View on Github external
return (tree, _context) => {
        const workspace = config_1.getWorkspace(tree);
        const project = project_1.getProject(tree, options.project);
        const projectName = options.project;
        if (!project.sourceRoot && !project.root) {
            project.sourceRoot = "src";
        }
        else if (!project.sourceRoot) {
            project.sourceRoot = path.join(project.root, "src");
        }
        const architect = workspace.projects[projectName].architect;
        if (!architect)
            throw new Error(`expected node projects/${projectName}/architect in angular.json`);
        architect["build-electron"] = {
            builder: "@richapps/ngtron:build",
            options: {
                browserTarget: projectName + ":build",
                electronMain: project.sourceRoot + "/electron.ts"
            }
github NativeScript / nativescript-schematics / src / angular-project-parser.ts View on Github external
export function getProjectObject(tree: Tree, projectName: string) {
  const workspace = getWorkspace(tree);
  const project = getProject(workspace, projectName);
  if (!project) {
    throw new SchematicsException(`Couldn't find project "${projectName}" in the workspace!`);
  }

  return project;
}
github BenjaminDobler / ngtron / schematics / ng-add / index.ts View on Github external
return (host: Tree, context: SchematicContext) => {
    const project = getProject(host, options.project);
    return mergeWith(
      apply(url(`./files`), [
        template({
          tmpl: ''
        }),
        move(project.root)
      ]));
  }
}