本文整理汇总了TypeScript中@angular-devkit/schematics.externalSchematic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript externalSchematic函数的具体用法?TypeScript externalSchematic怎么用?TypeScript externalSchematic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了externalSchematic函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (host: Tree) => {
validateProjectName(options.name);
return chain([
externalSchematic('@schematics/angular', 'ng-new', options),
schematic('ng-add', options, {
scope: options.name,
}),
]);
};
示例2: return
return (host: Tree, context: SchematicContext) => {
context.logger.debug('Adding service worker...');
const swOptions = {
...options,
};
delete swOptions.title;
return externalSchematic('@schematics/angular', 'service-worker', swOptions);
};
示例3: return
return (host: Tree) => {
validateProjectName(options.name);
return chain([
externalSchematic('@schematics/angular', 'ng-new', {
...options,
skipInstall: true,
}),
addDevDependenciesToPackageJson(options),
schematic('bazel-workspace', options),
overwriteMainAndIndex(options),
updateWorkspaceFileToUseBazelBuilder(options),
]);
};
示例4: return
return (host: Tree) => {
validateProjectName(options.name);
return chain([
externalSchematic('@schematics/angular', 'ng-new', options),
schematic(
'ng-add', {
name: options.name,
// skip install since `ng-new` above will schedule the task
skipInstall: true,
},
{
scope: options.name,
}),
]);
};
示例5: return
return (host: Tree) => {
validateProjectName(options.name);
return chain([
externalSchematic(
'@schematics/angular', 'ng-new',
{
...options,
}),
addDevDependenciesToPackageJson(options),
addDevAndProdMainForAot(options),
schematic('bazel-workspace', options, {
scope: options.name,
}),
overwriteGitignore(options),
updateWorkspaceFileToUseBazelBuilder(options),
]);
};
示例6: externalSchematic
const rules = schematicsToRun.map(x => externalSchematic(options.collection, x.name, {}));
示例7: return
return (host: Tree, context: SchematicContext) => {
context.logger.debug('Adding service worker...');
return externalSchematic('@schematics/angular', 'service-worker', options)(host, context);
};
示例8: return
return (host: Tree, context: SchematicContext) => {
if (!options.title) {
options.title = options.project;
}
const {path: workspacePath, workspace } = getWorkspace(host);
if (!options.project) {
throw new SchematicsException('Option "project" is required.');
}
const project = workspace.projects[options.project];
if (!project) {
throw new SchematicsException(`Project is not defined in this workspace.`);
}
if (project.projectType !== 'application') {
throw new SchematicsException(`PWA requires a project type of "application".`);
}
// Find all the relevant targets for the project
const projectTargets = project.targets || project.architect;
if (!projectTargets || Object.keys(projectTargets).length === 0) {
throw new SchematicsException(`Targets are not defined for this project.`);
}
const buildTargets = [];
const testTargets = [];
for (const targetName in projectTargets) {
const target = projectTargets[targetName];
if (!target) {
continue;
}
if (target.builder === '@angular-devkit/build-angular:browser') {
buildTargets.push(target);
} else if (target.builder === '@angular-devkit/build-angular:karma') {
testTargets.push(target);
}
}
// Add manifest to asset configuration
const assetEntry = join(normalize(project.root), 'src', 'manifest.webmanifest');
for (const target of [...buildTargets, ...testTargets]) {
if (target.options) {
if (target.options.assets) {
target.options.assets.push(assetEntry);
} else {
target.options.assets = [ assetEntry ];
}
} else {
target.options = { assets: [ assetEntry ] };
}
}
host.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
// Find all index.html files in build targets
const indexFiles = new Set<string>();
for (const target of buildTargets) {
if (target.options && target.options.index) {
indexFiles.add(target.options.index);
}
if (!target.configurations) {
continue;
}
for (const configName in target.configurations) {
const configuration = target.configurations[configName];
if (configuration && configuration.index) {
indexFiles.add(configuration.index);
}
}
}
// Setup sources for the assets files to add to the project
const sourcePath = join(normalize(project.root), 'src');
const assetsPath = join(sourcePath, 'assets');
const rootTemplateSource = apply(url('./files/root'), [
template({ ...options }),
move(getSystemPath(sourcePath)),
]);
const assetsTemplateSource = apply(url('./files/assets'), [
template({ ...options }),
move(getSystemPath(assetsPath)),
]);
// Setup service worker schematic options
const swOptions = { ...options };
delete swOptions.title;
// Chain the rules and return
return chain([
externalSchematic('@schematics/angular', 'service-worker', swOptions),
mergeWith(rootTemplateSource),
mergeWith(assetsTemplateSource),
...[...indexFiles].map(path => updateIndexFile(path)),
])(host, context);
};