本文整理汇总了TypeScript中@angular-devkit/core.schema.CoreSchemaRegistry.addPostTransform方法的典型用法代码示例。如果您正苦于以下问题:TypeScript schema.CoreSchemaRegistry.addPostTransform方法的具体用法?TypeScript schema.CoreSchemaRegistry.addPostTransform怎么用?TypeScript schema.CoreSchemaRegistry.addPostTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/core.schema.CoreSchemaRegistry
的用法示例。
在下文中一共展示了schema.CoreSchemaRegistry.addPostTransform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(async () => {
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
testArchitectHost = new TestingArchitectHost();
architect = new Architect(testArchitectHost, registry);
options = {};
called = 0;
testArchitectHost.addBuilder('package:test', createBuilder(async o => {
called++;
options = o;
return new Promise<BuilderOutput>(resolve => {
setTimeout(() => resolve({ success: true }), 10);
});
}));
testArchitectHost.addBuilder('package:test-options', createBuilder(o => {
options = o;
return { success: true };
}));
testArchitectHost.addTarget(target1, 'package:test');
testArchitectHost.addTarget(target2, 'package:test');
});
示例2: generateBrowserWebpackConfigFromContext
export async function generateBrowserWebpackConfigFromContext(
options: BrowserBuilderSchema,
context: BuilderContext,
webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[],
host: virtualFs.Host<fs.Stats> = new NodeJsSyncHost(),
): Promise<{ workspace: experimental.workspace.Workspace, config: webpack.Configuration[] }> {
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspace = await experimental.workspace.Workspace.fromPath(
host,
normalize(context.workspaceRoot),
registry,
);
const projectName = context.target ? context.target.project : workspace.getDefaultProjectName();
if (!projectName) {
throw new Error('Must either have a target from the context or a default project.');
}
const config = await generateBrowserWebpackConfigFromWorkspace(
options,
context,
projectName,
workspace,
host,
webpackPartialGenerator,
context.logger,
);
return { workspace, config };
}
示例3: beforeEach
beforeEach(async () => {
await host.initialize().toPromise();
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspace = await experimental.workspace.Workspace.fromPath(host, host.root(), registry);
const architectHost = new TestingArchitectHost(
host.root(),
host.root(),
new WorkspaceNodeModulesArchitectHost(workspace, host.root()),
);
architect = new Architect(architectHost, registry);
});
示例4: main
async function main(args: string[]): Promise<number> {
/** Parse the command line. */
const argv = minimist(args, { boolean: ['help'] });
/** Create the DevKit Logger used through the CLI. */
const logger = createConsoleLogger(argv['verbose']);
// Check the target.
const targetStr = argv._[0] || '';
if (!targetStr || argv.help) {
// Show architect usage if there's no target.
usage(logger);
}
// Load workspace configuration file.
const currentPath = process.cwd();
const configFileNames = [
'angular.json',
'.angular.json',
'workspace.json',
'.workspace.json',
];
const configFilePath = findUp(configFileNames, currentPath);
if (!configFilePath) {
logger.fatal(`Workspace configuration file (${configFileNames.join(', ')}) cannot be found in `
+ `'${currentPath}' or in parent directories.`);
return 3;
}
const root = path.dirname(configFilePath);
const configContent = readFileSync(configFilePath, 'utf-8');
const workspaceJson = JSON.parse(configContent);
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const host = new NodeJsSyncHost();
const workspace = new experimental.workspace.Workspace(normalize(root), host);
await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();
// Clear the console.
process.stdout.write('\u001Bc');
return await _executeTarget(logger, workspace, root, argv, registry);
}
示例5: createArchitect
async function createArchitect(workspaceRoot: string) {
vfHost = new NodeJsSyncHost();
const configContent = fs.readFileSync(path.join(workspaceRoot, 'angular.json'), 'utf-8');
const workspaceJson = JSON.parse(configContent);
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspace = new experimental.workspace.Workspace(normalize(workspaceRoot), vfHost);
await workspace.loadWorkspaceFromJson(workspaceJson).toPromise();
testArchitectHost = new TestingArchitectHost(workspaceRoot, workspaceRoot,
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot));
architect = new Architect(testArchitectHost, registry);
}
示例6: createArchitect
export async function createArchitect(workspaceRoot: Path) {
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspaceSysPath = getSystemPath(workspaceRoot);
const workspace = await experimental.workspace.Workspace.fromPath(host, host.root(), registry);
const architectHost = new TestingArchitectHost(
workspaceSysPath,
workspaceSysPath,
new WorkspaceNodeModulesArchitectHost(workspace, workspaceSysPath),
);
const architect = new Architect(architectHost, registry);
return {
workspace,
architectHost,
architect,
};
}
示例7: _renderUniversal
async function _renderUniversal(
options: BuildWebpackAppShellSchema,
context: BuilderContext,
browserResult: BrowserBuilderOutput,
serverResult: ServerBuilderOutput,
): Promise<BrowserBuilderOutput> {
const browserIndexOutputPath = path.join(browserResult.outputPath || '', 'index.html');
const indexHtml = fs.readFileSync(browserIndexOutputPath, 'utf8');
const serverBundlePath = await _getServerModuleBundlePath(options, context, serverResult);
const root = context.workspaceRoot;
requireProjectModule(root, 'zone.js/dist/zone-node');
const renderModuleFactory = requireProjectModule(
root,
'@angular/platform-server',
).renderModuleFactory;
const AppServerModuleNgFactory = require(serverBundlePath).AppServerModuleNgFactory;
const outputIndexPath = options.outputIndexPath
? path.join(root, options.outputIndexPath)
: browserIndexOutputPath;
// Render to HTML and overwrite the client index file.
const html = await renderModuleFactory(AppServerModuleNgFactory, {
document: indexHtml,
url: options.route,
});
fs.writeFileSync(outputIndexPath, html);
const browserTarget = targetFromTargetString(options.browserTarget);
const rawBrowserOptions = await context.getTargetOptions(browserTarget);
const browserBuilderName = await context.getBuilderNameForTarget(browserTarget);
const browserOptions = await context.validateOptions<JsonObject & BrowserBuilderSchema>(
rawBrowserOptions,
browserBuilderName,
);
if (browserOptions.serviceWorker) {
const host = new NodeJsSyncHost();
// Create workspace.
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspace = await experimental.workspace.Workspace.fromPath(
host,
normalize(context.workspaceRoot),
registry,
);
const projectName = context.target ? context.target.project : workspace.getDefaultProjectName();
if (!projectName) {
throw new Error('Must either have a target from the context or a default project.');
}
const projectRoot = resolve(
workspace.root,
normalize(workspace.getProject(projectName).root),
);
await augmentAppWithServiceWorker(
host,
normalize(root),
projectRoot,
join(normalize(root), browserOptions.outputPath),
browserOptions.baseHref || '/',
browserOptions.ngswConfigPath,
);
}
return browserResult;
}