本文整理匯總了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);
};