mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 04:26:01 +08:00
Updates for all angular.io links to the new angular.dev domain. Additionally, adjustment to new resources where the equivalent does not exist on the new site (e.g. Tour of Heroes tutorial)
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
import {
|
|
Rule,
|
|
Tree,
|
|
apply,
|
|
applyTemplates,
|
|
chain,
|
|
filter,
|
|
mergeWith,
|
|
move,
|
|
noop,
|
|
strings,
|
|
url,
|
|
} from '@angular-devkit/schematics';
|
|
import { addDeclarationToNgModule } from '../utility/add-declaration-to-ng-module';
|
|
import { findModuleFromOptions } from '../utility/find-module';
|
|
import { parseName } from '../utility/parse-name';
|
|
import { validateClassName } from '../utility/validation';
|
|
import { createDefaultPath } from '../utility/workspace';
|
|
import { Schema as PipeOptions } from './schema';
|
|
|
|
export default function (options: PipeOptions): Rule {
|
|
return async (host: Tree) => {
|
|
options.path ??= await createDefaultPath(host, options.project as string);
|
|
options.module = findModuleFromOptions(host, options);
|
|
|
|
const parsedPath = parseName(options.path, options.name);
|
|
options.name = parsedPath.name;
|
|
options.path = parsedPath.path;
|
|
validateClassName(strings.classify(options.name));
|
|
|
|
const templateSource = apply(url('./files'), [
|
|
options.skipTests ? filter((path) => !path.endsWith('.spec.ts.template')) : noop(),
|
|
applyTemplates({
|
|
...strings,
|
|
'if-flat': (s: string) => (options.flat ? '' : s),
|
|
...options,
|
|
}),
|
|
move(parsedPath.path),
|
|
]);
|
|
|
|
return chain([
|
|
addDeclarationToNgModule({
|
|
type: 'pipe',
|
|
|
|
...options,
|
|
}),
|
|
mergeWith(templateSource),
|
|
]);
|
|
};
|
|
}
|