How to use the @angular-devkit/core.tags.oneLine 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 angular / angular-cli / packages / angular_devkit / schematics / tasks / repo-init / executor.ts View on Github external
reject(code);
            }
        });
      });
    };

    const hasCommand = await execute(['--version'])
      .then(() => true, () => false);
    if (!hasCommand) {
      return;
    }

    const insideRepo = await execute(['rev-parse', '--is-inside-work-tree'], true)
      .then(() => true, () => false);
    if (insideRepo) {
      context.logger.info(tags.oneLine`
        Directory is already under version control.
        Skipping initialization of git.
      `);

      return;
    }

    // if git is not found or an error was thrown during the `git`
    // init process just swallow any errors here
    // NOTE: This will be removed once task error handling is implemented
    try {
      await execute(['init']);
      await execute(['add', '.']);

      if (options.commit) {
        const message = options.message || 'initial commit';
github angular / angular-cli / packages / ngtools / webpack / src / transformers / export_ngfactory_spec.ts View on Github external
it('should not do anything if shouldTransform returns false', () => {
      const input = tags.stripIndent`
        export { AppModule } from './app/app.module';
      `;

      const transformer = exportNgFactory(
        () => false,
        () => ({ path: '/project/src/app/app.module', className: 'AppModule' }),
      );
      const result = transformTypescript(input, [transformer]);

      expect(tags.oneLine`${result}`).toEqual(tags.oneLine`${input}`);
    });
  });
github angular / angular-cli / packages / angular_devkit / build_optimizer / src / transforms / import-tslib_spec.ts View on Github external
it('replaces wrapped __extends', () => {
    const input = tags.stripIndent`
    export default function appGlobal() {
        var __extends = (this && this.__extends) || function (d, b) {
          for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
          function __() { this.constructor = d; }
          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    }
    `;
    const output = tags.stripIndent`
      import { __extends } from "tslib";
      export default function appGlobal() { }
    `;

    expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
  });
github nrwl / nx / packages / tao / src / commands / generate.ts View on Github external
logger.warn(
        `ERROR! ${eventPath} ${
          event.description == 'alreadyExist'
            ? 'already exists'
            : 'does not exist.'
        }.`
      );
    } else if (event.kind === 'update') {
      record.loggingQueue.push(
        tags.oneLine`${terminal.white('UPDATE')} ${eventPath} (${
          event.content.length
        } bytes)`
      );
    } else if (event.kind === 'create') {
      record.loggingQueue.push(
        tags.oneLine`${terminal.green('CREATE')} ${eventPath} (${
          event.content.length
        } bytes)`
      );
    } else if (event.kind === 'delete') {
      record.loggingQueue.push(`${terminal.yellow('DELETE')} ${eventPath}`);
    } else if (event.kind === 'rename') {
      record.loggingQueue.push(
        `${terminal.blue('RENAME')} ${eventPath} => ${event.to}`
      );
    }
  };
}
github angular / angular-cli / packages / @angular / cli / utilities / validate-project-name.ts View on Github external
export function validateProjectName(projectName: string) {
  const errorIndex = getRegExpFailPosition(projectName);
  if (errorIndex !== null) {
    const firstMessage = tags.oneLine`
      Project name "${projectName}" is not valid. New project names must
      start with a letter, and must contain only alphanumeric characters or dashes.
      When adding a dash the segment after the dash must also start with a letter.
    `;
    const msg = tags.stripIndent`
      ${firstMessage}
      ${projectName}
      ${Array(errorIndex + 1).join(' ') + '^'}
    `;
    throw new SilentError(msg);
  } else if (unsupportedProjectNames.indexOf(projectName) !== -1) {
    throw new SilentError(`Project name "${projectName}" is not a supported name.`);
  }

}
github angular / angular-cli / packages / angular / cli / models / schematic-command.ts View on Github external
const getProjectName = () => {
      if (this._workspace) {
        const projectNames = getProjectsByPath(this._workspace, process.cwd(), this.workspace.root);

        if (projectNames.length === 1) {
          return projectNames[0];
        } else {
          if (projectNames.length > 1) {
            this.logger.warn(tags.oneLine`
              Two or more projects are using identical roots.
              Unable to determine project using current working directory.
              Using default workspace project instead.
            `);
          }

          const defaultProjectName = this._workspace.extensions['defaultProject'];
          if (typeof defaultProjectName === 'string' && defaultProjectName) {
            return defaultProjectName;
          }
        }
      }

      return undefined;
    };
github angular / angular-cli / packages / angular_devkit / build_optimizer / src / transforms / scrub-file_spec.ts View on Github external
${clazz}
        Clazz.propDecorators = {
          'notNgIf': [{ type: NotInput }]
        };
      `;
      const input = tags.stripIndent`
        import { Input } from '@angular/core';
        import { NotInput } from 'another-lib';
        ${clazz}
        Clazz.propDecorators = {
          'ngIf': [{ type: Input }],
          'notNgIf': [{ type: NotInput }]
        };
      `;

      expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
    });
  });
github angular / angular-cli / packages / angular / cli / commands / add-impl.ts View on Github external
collectionName: string,
    options: string[] = [],
  ): Promise {
    const runOptions: RunSchematicOptions = {
      schematicOptions: options,
      collectionName,
      schematicName: 'ng-add',
      dryRun: false,
      force: false,
    };

    try {
      return await this.runSchematic(runOptions);
    } catch (e) {
      if (e instanceof NodePackageDoesNotSupportSchematics) {
        this.logger.error(tags.oneLine`
          The package that you are trying to add does not support schematics. You can try using
          a different version of the package or contact the package author to add ng-add support.
        `);

        return 1;
      }

      throw e;
    }
  }
github angular / angular-cli / packages / ngtools / webpack / src / transformers / register_locale_data_spec.ts View on Github external
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

        import { AppModule } from './app/app.module';
        import { environment } from './environments/environment';

        if (environment.production) {
          enableProdMode();
        }

        platformBrowserDynamic().bootstrapModule(AppModule);
      `;

      const transformer = registerLocaleData(() => true, () => null, 'fr');
      const result = transformTypescript(input, [transformer]);

      expect(tags.oneLine`${result}`).toEqual(tags.oneLine`${input}`);
    });
  });
github kentan-official / kentan / packages / schematics / src / lib / console-messages / warning.ts View on Github external
export function Warning(message: string) {
  return tags.oneLine`  ${color.bgYellow(color.black('WARNING'))} ${message}`;
}