MCPcopy Index your code
hub / github.com/angular/angular-cli / addScriptsRule

Function addScriptsRule

packages/schematics/angular/ssr/index.ts:116–141  ·  view source on GitHub ↗
({ project }: SSROptions, isUsingApplicationBuilder: boolean)

Source from the content-addressed store, hash-verified

114}
115
116function addScriptsRule({ project }: SSROptions, isUsingApplicationBuilder: boolean): Rule {
117 return async (host) => {
118 const pkgPath = '/package.json';
119 const pkg = host.readJson(pkgPath) as { scripts?: Record<string, string> } | null;
120 if (pkg === null) {
121 throw new SchematicsException('Could not find package.json');
122 }
123
124 if (isUsingApplicationBuilder) {
125 const { base, server } = await getApplicationBuilderOutputPaths(host, project);
126 pkg.scripts ??= {};
127 pkg.scripts[`serve:ssr:${project}`] = `node ${join(base, server)}/server.mjs`;
128 } else {
129 const serverDist = await getLegacyOutputPaths(host, project, 'server');
130 pkg.scripts = {
131 ...pkg.scripts,
132 'dev:ssr': `ng run ${project}:${SERVE_SSR_TARGET_NAME}`,
133 'serve:ssr': `node ${serverDist}/main.js`,
134 'build:ssr': `ng build && ng run ${project}:server`,
135 'prerender': `ng run ${project}:${PRERENDER_TARGET_NAME}`,
136 };
137 }
138
139 host.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
140 };
141}
142
143function updateApplicationBuilderTsConfigRule(options: SSROptions): Rule {
144 return async (host) => {

Callers 1

index.tsFile · 0.85

Calls 5

joinFunction · 0.85
getLegacyOutputPathsFunction · 0.85
readJsonMethod · 0.65
overwriteMethod · 0.65

Tested by

no test coverage detected