Skip to content

Commit ec7f3ad

Browse files
alan-agius4clydin
authored andcommitted
fix(@schematics/angular): replace clientProject with project
(cherry picked from commit 4ed1c4f)
1 parent bc01593 commit ec7f3ad

File tree

12 files changed

+34
-33
lines changed

12 files changed

+34
-33
lines changed

packages/schematics/angular/app-shell/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function addAppShellConfigToWorkspace(options: AppShellOptions): Rule {
153153
}
154154

155155
return updateWorkspace((workspace) => {
156-
const project = workspace.projects.get(options.clientProject);
156+
const project = workspace.projects.get(options.project);
157157
if (!project) {
158158
return;
159159
}
@@ -187,8 +187,8 @@ function addAppShellConfigToWorkspace(options: AppShellOptions): Rule {
187187
}
188188

189189
configurations[key] = {
190-
browserTarget: `${options.clientProject}:build:${key}`,
191-
serverTarget: `${options.clientProject}:server:${key}`,
190+
browserTarget: `${options.project}:build:${key}`,
191+
serverTarget: `${options.project}:server:${key}`,
192192
};
193193
}
194194

@@ -239,7 +239,7 @@ function addServerRoutes(options: AppShellOptions): Rule {
239239
return async (host: Tree) => {
240240
// The workspace gets updated so this needs to be reloaded
241241
const workspace = await getWorkspace(host);
242-
const clientProject = workspace.projects.get(options.clientProject);
242+
const clientProject = workspace.projects.get(options.project);
243243
if (!clientProject) {
244244
throw new Error('Universal schematic removed client project.');
245245
}
@@ -309,7 +309,7 @@ function addShellComponent(options: AppShellOptions): Rule {
309309
const componentOptions: ComponentOptions = {
310310
name: 'app-shell',
311311
module: options.rootModuleFileName,
312-
project: options.clientProject,
312+
project: options.project,
313313
};
314314

315315
return schematic('component', componentOptions);
@@ -318,7 +318,7 @@ function addShellComponent(options: AppShellOptions): Rule {
318318
export default function (options: AppShellOptions): Rule {
319319
return async (tree) => {
320320
const workspace = await getWorkspace(tree);
321-
const clientProject = workspace.projects.get(options.clientProject);
321+
const clientProject = workspace.projects.get(options.project);
322322
if (!clientProject || clientProject.extensions.projectType !== 'application') {
323323
throw new SchematicsException(`A client project type of "application" is required.`);
324324
}

packages/schematics/angular/app-shell/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"additionalProperties": false,
88
"long-description": "./app-shell-long.md",
99
"properties": {
10-
"clientProject": {
10+
"project": {
1111
"type": "string",
1212
"description": "The name of the related client app.",
1313
"$default": {
@@ -50,5 +50,5 @@
5050
"default": "AppServerModule"
5151
}
5252
},
53-
"required": ["clientProject"]
53+
"required": ["project"]
5454
}

packages/schematics/angular/migrations/update-9/update-app-tsconfigs_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ describe('Migration to version 9', () => {
251251
require.resolve('../../collection.json'),
252252
'universal',
253253
{
254-
clientProject: 'migration-test',
254+
project: 'migration-test',
255255
},
256256
tree,
257257
)

packages/schematics/angular/migrations/update-9/update-server-main-file_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Migration to version 9', () => {
5252
require.resolve('../../collection.json'),
5353
'universal',
5454
{
55-
clientProject: 'migration-test',
55+
project: 'migration-test',
5656
},
5757
tree,
5858
)

packages/schematics/angular/migrations/update-9/update-workspace-config_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ describe('Migration to version 9', () => {
300300
require.resolve('../../collection.json'),
301301
'universal',
302302
{
303-
clientProject: 'migration-test',
303+
project: 'migration-test',
304304
},
305305
tree,
306306
)

packages/schematics/angular/universal/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Schema as UniversalOptions } from './schema';
3333

3434
function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): Rule {
3535
return updateWorkspace((workspace) => {
36-
const clientProject = workspace.projects.get(options.clientProject);
36+
const clientProject = workspace.projects.get(options.project);
3737

3838
if (clientProject) {
3939
// In case the browser builder hashes the assets
@@ -59,7 +59,7 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
5959

6060
const buildTarget = clientProject.targets.get('build');
6161
if (buildTarget?.options) {
62-
buildTarget.options.outputPath = `dist/${options.clientProject}/browser`;
62+
buildTarget.options.outputPath = `dist/${options.project}/browser`;
6363
}
6464

6565
const buildConfigurations = buildTarget?.configurations;
@@ -77,7 +77,7 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
7777
builder: Builders.Server,
7878
defaultConfiguration: 'production',
7979
options: {
80-
outputPath: `dist/${options.clientProject}/server`,
80+
outputPath: `dist/${options.project}/server`,
8181
main: join(
8282
normalize(clientProject.root),
8383
'src',
@@ -226,7 +226,7 @@ export default function (options: UniversalOptions): Rule {
226226
return async (host: Tree, context: SchematicContext) => {
227227
const workspace = await getWorkspace(host);
228228

229-
const clientProject = workspace.projects.get(options.clientProject);
229+
const clientProject = workspace.projects.get(options.project);
230230
if (!clientProject || clientProject.extensions.projectType !== 'application') {
231231
throw new SchematicsException(`Universal requires a project type of "application".`);
232232
}

packages/schematics/angular/universal/index_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ describe('Universal Schematic', () => {
1919
require.resolve('../collection.json'),
2020
);
2121
const defaultOptions: UniversalOptions = {
22-
clientProject: 'bar',
22+
project: 'bar',
2323
};
2424
const workspaceUniversalOptions: UniversalOptions = {
25-
clientProject: 'workspace',
25+
project: 'workspace',
2626
};
2727

2828
const workspaceOptions: WorkspaceOptions = {

packages/schematics/angular/universal/schema.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
"additionalProperties": false,
77
"description": "Pass this schematic to the \"run\" command to set up server-side rendering for an app.",
88
"properties": {
9-
"clientProject": {
9+
"project": {
1010
"type": "string",
11-
"description": "The name of the related client app. Required in place of \"project\"."
11+
"description": "The name of the project.",
12+
"$default": {
13+
"$source": "projectName"
14+
}
1215
},
1316
"appId": {
1417
"type": "string",
@@ -45,5 +48,5 @@
4548
"default": false
4649
}
4750
},
48-
"required": ["clientProject"]
51+
"required": ["project"]
4952
}

tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const snapshots = require('../../ng-snapshot/package.json');
88

99
export default async function () {
1010
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
11-
await ng('generate', 'appShell', '--client-project', 'test-project');
11+
await ng('generate', 'appShell', '--project', 'test-project');
1212

1313
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
1414
if (isSnapshotBuild) {

tests/legacy-cli/e2e/tests/build/platform-server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { updateJsonFile } from '../../utils/project';
88
const snapshots = require('../../ng-snapshot/package.json');
99

1010
export default async function () {
11-
await ng('generate', 'universal', '--client-project', 'test-project');
11+
await ng('generate', 'universal', '--project', 'test-project');
1212

1313
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
1414
if (isSnapshotBuild) {
@@ -48,7 +48,10 @@ export default async function () {
4848

4949
await ng('run', 'test-project:server', '--optimization', 'false');
5050

51-
await expectFileToMatch('dist/test-project/server/main.js', /exports.*AppServerModule|"AppServerModule":/);
51+
await expectFileToMatch(
52+
'dist/test-project/server/main.js',
53+
/exports.*AppServerModule|"AppServerModule":/,
54+
);
5255
await exec(normalize('node'), 'dist/test-project/server/main.js');
5356
await expectFileToMatch(
5457
'dist/test-project/server/index.html',

0 commit comments

Comments
 (0)