Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit be91d49

Browse files
committed
build: replace clientProject with project
(cherry picked from commit 775bcf3)
1 parent e8ae6f1 commit be91d49

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

modules/common/schematics/ng-add/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Schema as NgAddOptions } from './schema';
1313

1414
describe('ng-add schematic (clover)', () => {
1515
const defaultOptions: NgAddOptions = {
16-
clientProject: 'foo',
16+
project: 'foo',
1717
prerender: false,
1818
ssr: false,
1919
skipInstall: true,

modules/common/schematics/ng-add/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ import { Schema as NgAddOptions } from './schema';
4040
export default function (options: NgAddOptions): Rule {
4141
return async (host, context) => {
4242
const workspace = await getWorkspace(host);
43-
const clientProject = workspace.projects.get(options.clientProject);
43+
const project = workspace.projects.get(options.project);
4444

45-
if (clientProject.extensions.projectType !== 'application') {
45+
if (project.extensions.projectType !== 'application') {
4646
throw new SchematicsException(`Universal requires a project type of "application".`);
4747
}
4848

49-
const clientBuildTarget = clientProject.targets.get('build');
49+
const clientBuildTarget = project.targets.get('build');
5050
if (!clientBuildTarget) {
5151
throw new SchematicsException(`Project target "build" not found.`);
5252
}
@@ -56,8 +56,8 @@ export default function (options: NgAddOptions): Rule {
5656
}
5757

5858
return chain([
59-
augmentAppModuleRule(clientProject, clientBuildTarget, options),
60-
options.ssr ? addSSRRule(clientProject, clientBuildTarget) : noop(),
59+
augmentAppModuleRule(project, clientBuildTarget, options),
60+
options.ssr ? addSSRRule(project, clientBuildTarget) : noop(),
6161
options.prerender ? addPreRenderRule() : noop(),
6262
addScriptsRule(options),
6363
updateWorkspaceRule(options),
@@ -117,16 +117,16 @@ function addScriptsRule(options: NgAddOptions): Rule {
117117
if (options.prerender) {
118118
pkg.scripts = {
119119
...pkg.scripts,
120-
'prerender': `ng run ${options.clientProject}:prerender`,
120+
'prerender': `ng run ${options.project}:prerender`,
121121
};
122122
}
123123

124124
if (options.ssr) {
125125
pkg.scripts = {
126126
...pkg.scripts,
127-
'build:client-and-server': `ng build ${options.clientProject} && ng run ${options.clientProject}:server`,
128-
'build:server': `ng run ${options.clientProject}:server`,
129-
'serve:ssr': `node dist/${options.clientProject}/server/main.js`,
127+
'build:client-and-server': `ng build ${options.project} && ng run ${options.project}:server`,
128+
'build:server': `ng run ${options.project}:server`,
129+
'serve:ssr': `node dist/${options.project}/server/main.js`,
130130
};
131131
}
132132

@@ -136,13 +136,13 @@ function addScriptsRule(options: NgAddOptions): Rule {
136136

137137
function updateWorkspaceRule(options: NgAddOptions): Rule {
138138
return updateWorkspace((workspace) => {
139-
const project = workspace.projects.get(options.clientProject);
139+
const project = workspace.projects.get(options.project);
140140
if (options.ssr) {
141141
project.targets.add({
142142
name: 'server',
143143
builder: '@angular-devkit/build-angular:server',
144144
options: {
145-
outputPath: `dist/${options.clientProject}/server`,
145+
outputPath: `dist/${options.project}/server`,
146146
main: posix.join(project.sourceRoot ?? '', 'server.ts'),
147147
tsConfig: posix.join(project.root, 'tsconfig.server.json'),
148148
bundleDependencies: false,
@@ -152,7 +152,7 @@ function updateWorkspaceRule(options: NgAddOptions): Rule {
152152

153153
const buildTarget = project.targets.get('build');
154154
if (project.targets.get('build')?.options) {
155-
buildTarget.options.outputPath = `dist/${options.clientProject}/browser`;
155+
buildTarget.options.outputPath = `dist/${options.project}/browser`;
156156
}
157157
}
158158

@@ -164,10 +164,10 @@ function updateWorkspaceRule(options: NgAddOptions): Rule {
164164
options: {},
165165
configurations: {
166166
production: {
167-
browserTarget: `${options.clientProject}:build:production`,
167+
browserTarget: `${options.project}:build:production`,
168168
},
169169
development: {
170-
browserTarget: `${options.clientProject}:build:development`,
170+
browserTarget: `${options.project}:build:development`,
171171
},
172172
},
173173
});

modules/common/schematics/ng-add/schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"title": "Express Engine Install Options Schema",
55
"type": "object",
66
"properties": {
7-
"clientProject": {
7+
"project": {
88
"type": "string",
9-
"description": "Name of related client app.",
9+
"description": "The name of the project.",
1010
"$default": {
1111
"$source": "projectName"
1212
}
@@ -39,6 +39,6 @@
3939
{ "properties": { "ssr": { "const": true } } },
4040
{ "properties": { "prerender": { "const": true } } }
4141
],
42-
"required": ["clientProject"],
42+
"required": ["project"],
4343
"additionalProperties": false
4444
}

modules/common/schematics/ng-add/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
export interface Schema {
10-
clientProject: string;
10+
project: string;
1111
appId?: string;
1212
ssr?: boolean;
1313
prerender?: boolean;

modules/express-engine/schematics/install/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Schema as UniversalOptions } from './schema';
1616

1717
describe('Universal Schematic', () => {
1818
const defaultOptions: UniversalOptions = {
19-
clientProject: 'test-app',
19+
project: 'test-app',
2020
};
2121

2222
let schematicRunner: SchematicTestRunner;

modules/express-engine/schematics/install/index.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ function addScriptsRule(options: AddUniversalOptions): Rule {
5252
throw new SchematicsException('Could not find package.json');
5353
}
5454

55-
const serverDist = await getOutputPath(host, options.clientProject, 'server');
55+
const serverDist = await getOutputPath(host, options.project, 'server');
5656
const pkg = JSON.parse(buffer.toString()) as any;
5757
pkg.scripts = {
5858
...pkg.scripts,
59-
'dev:ssr': `ng run ${options.clientProject}:${SERVE_SSR_TARGET_NAME}`,
59+
'dev:ssr': `ng run ${options.project}:${SERVE_SSR_TARGET_NAME}`,
6060
'serve:ssr': `node ${serverDist}/main.js`,
61-
'build:ssr': `ng build && ng run ${options.clientProject}:server`,
62-
'prerender': `ng run ${options.clientProject}:${PRERENDER_TARGET_NAME}`,
61+
'build:ssr': `ng build && ng run ${options.project}:server`,
62+
'prerender': `ng run ${options.project}:${PRERENDER_TARGET_NAME}`,
6363
};
6464

6565
host.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
@@ -69,7 +69,7 @@ function addScriptsRule(options: AddUniversalOptions): Rule {
6969
function updateWorkspaceConfigRule(options: AddUniversalOptions): Rule {
7070
return () => {
7171
return updateWorkspace((workspace) => {
72-
const projectName = options.clientProject;
72+
const projectName = options.project;
7373
const project = workspace.projects.get(projectName);
7474
if (!project) {
7575
return;
@@ -117,10 +117,10 @@ function updateWorkspaceConfigRule(options: AddUniversalOptions): Rule {
117117
},
118118
configurations: {
119119
production: {
120-
browserTarget: `${options.clientProject}:build:production`,
120+
browserTarget: `${options.project}:build:production`,
121121
},
122122
development: {
123-
browserTarget: `${options.clientProject}:build:development`,
123+
browserTarget: `${options.project}:build:development`,
124124
},
125125
},
126126
});
@@ -130,8 +130,8 @@ function updateWorkspaceConfigRule(options: AddUniversalOptions): Rule {
130130

131131
function updateServerTsConfigRule(options: AddUniversalOptions): Rule {
132132
return async (host) => {
133-
const clientProject = await getProject(host, options.clientProject);
134-
const serverTarget = clientProject.targets.get('server');
133+
const project = await getProject(host, options.project);
134+
const serverTarget = project.targets.get('server');
135135
if (!serverTarget || !serverTarget.options) {
136136
return;
137137
}
@@ -153,8 +153,8 @@ function updateServerTsConfigRule(options: AddUniversalOptions): Rule {
153153

154154
function routingInitialNavigationRule(options: UniversalOptions): Rule {
155155
return async (host) => {
156-
const clientProject = await getProject(host, options.clientProject);
157-
const serverTarget = clientProject.targets.get('server');
156+
const project = await getProject(host, options.project);
157+
const serverTarget = project.targets.get('server');
158158
if (!serverTarget || !serverTarget.options) {
159159
return;
160160
}
@@ -293,8 +293,8 @@ function addDependencies(options: UniversalOptions): Rule {
293293

294294
function addServerFile(options: UniversalOptions): Rule {
295295
return async (host) => {
296-
const clientProject = await getProject(host, options.clientProject);
297-
const browserDistDirectory = await getOutputPath(host, options.clientProject, 'build');
296+
const project = await getProject(host, options.project);
297+
const browserDistDirectory = await getOutputPath(host, options.project, 'build');
298298

299299
return mergeWith(
300300
apply(url('./files'), [
@@ -304,15 +304,15 @@ function addServerFile(options: UniversalOptions): Rule {
304304
stripTsExtension,
305305
browserDistDirectory,
306306
}),
307-
move(clientProject.root),
307+
move(project.root),
308308
]),
309309
);
310310
};
311311
}
312312

313313
export default function (options: AddUniversalOptions): Rule {
314314
return async (host) => {
315-
const clientProject = await getProject(host, options.clientProject);
315+
const project = await getProject(host, options.project);
316316
const universalOptions = {
317317
...options,
318318
skipInstall: true,
@@ -322,7 +322,7 @@ export default function (options: AddUniversalOptions): Rule {
322322
delete universalOptions.serverPort;
323323

324324
return chain([
325-
clientProject.targets.has('server')
325+
project.targets.has('server')
326326
? noop()
327327
: externalSchematic('@schematics/angular', 'universal', universalOptions),
328328
addScriptsRule(options),

modules/express-engine/schematics/install/schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"title": "Express Engine Install Options Schema",
55
"type": "object",
66
"properties": {
7-
"clientProject": {
7+
"project": {
88
"type": "string",
9-
"description": "Name of related client app.",
9+
"description": "The name of the project.",
1010
"$default": {
1111
"$source": "projectName"
1212
}
@@ -56,6 +56,6 @@
5656
"default": false
5757
}
5858
},
59-
"required": ["clientProject"],
59+
"required": ["project"],
6060
"additionalProperties": false
6161
}

modules/express-engine/schematics/install/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface Schema {
1010
/**
1111
* Name or index of related client app.
1212
*/
13-
clientProject: string;
13+
project: string;
1414
/**
1515
* The appId to use withServerTransition.
1616
*/

0 commit comments

Comments
 (0)