mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
fix(@schematics/angular): replace clientProject
with project
This commit is contained in:
parent
586226a305
commit
4ed1c4f42d
@ -153,7 +153,7 @@ function addAppShellConfigToWorkspace(options: AppShellOptions): Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return updateWorkspace((workspace) => {
|
return updateWorkspace((workspace) => {
|
||||||
const project = workspace.projects.get(options.clientProject);
|
const project = workspace.projects.get(options.project);
|
||||||
if (!project) {
|
if (!project) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -187,8 +187,8 @@ function addAppShellConfigToWorkspace(options: AppShellOptions): Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configurations[key] = {
|
configurations[key] = {
|
||||||
browserTarget: `${options.clientProject}:build:${key}`,
|
browserTarget: `${options.project}:build:${key}`,
|
||||||
serverTarget: `${options.clientProject}:server:${key}`,
|
serverTarget: `${options.project}:server:${key}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ function addServerRoutes(options: AppShellOptions): Rule {
|
|||||||
return async (host: Tree) => {
|
return async (host: Tree) => {
|
||||||
// The workspace gets updated so this needs to be reloaded
|
// The workspace gets updated so this needs to be reloaded
|
||||||
const workspace = await getWorkspace(host);
|
const workspace = await getWorkspace(host);
|
||||||
const clientProject = workspace.projects.get(options.clientProject);
|
const clientProject = workspace.projects.get(options.project);
|
||||||
if (!clientProject) {
|
if (!clientProject) {
|
||||||
throw new Error('Universal schematic removed client project.');
|
throw new Error('Universal schematic removed client project.');
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ function addShellComponent(options: AppShellOptions): Rule {
|
|||||||
const componentOptions: ComponentOptions = {
|
const componentOptions: ComponentOptions = {
|
||||||
name: 'app-shell',
|
name: 'app-shell',
|
||||||
module: options.rootModuleFileName,
|
module: options.rootModuleFileName,
|
||||||
project: options.clientProject,
|
project: options.project,
|
||||||
};
|
};
|
||||||
|
|
||||||
return schematic('component', componentOptions);
|
return schematic('component', componentOptions);
|
||||||
@ -318,7 +318,7 @@ function addShellComponent(options: AppShellOptions): Rule {
|
|||||||
export default function (options: AppShellOptions): Rule {
|
export default function (options: AppShellOptions): Rule {
|
||||||
return async (tree) => {
|
return async (tree) => {
|
||||||
const workspace = await getWorkspace(tree);
|
const workspace = await getWorkspace(tree);
|
||||||
const clientProject = workspace.projects.get(options.clientProject);
|
const clientProject = workspace.projects.get(options.project);
|
||||||
if (!clientProject || clientProject.extensions.projectType !== 'application') {
|
if (!clientProject || clientProject.extensions.projectType !== 'application') {
|
||||||
throw new SchematicsException(`A client project type of "application" is required.`);
|
throw new SchematicsException(`A client project type of "application" is required.`);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"long-description": "./app-shell-long.md",
|
"long-description": "./app-shell-long.md",
|
||||||
"properties": {
|
"properties": {
|
||||||
"clientProject": {
|
"project": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The name of the related client app.",
|
"description": "The name of the related client app.",
|
||||||
"$default": {
|
"$default": {
|
||||||
@ -50,5 +50,5 @@
|
|||||||
"default": "AppServerModule"
|
"default": "AppServerModule"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["clientProject"]
|
"required": ["project"]
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ describe('Migration to version 9', () => {
|
|||||||
require.resolve('../../collection.json'),
|
require.resolve('../../collection.json'),
|
||||||
'universal',
|
'universal',
|
||||||
{
|
{
|
||||||
clientProject: 'migration-test',
|
project: 'migration-test',
|
||||||
},
|
},
|
||||||
tree,
|
tree,
|
||||||
)
|
)
|
||||||
|
@ -52,7 +52,7 @@ describe('Migration to version 9', () => {
|
|||||||
require.resolve('../../collection.json'),
|
require.resolve('../../collection.json'),
|
||||||
'universal',
|
'universal',
|
||||||
{
|
{
|
||||||
clientProject: 'migration-test',
|
project: 'migration-test',
|
||||||
},
|
},
|
||||||
tree,
|
tree,
|
||||||
)
|
)
|
||||||
|
@ -300,7 +300,7 @@ describe('Migration to version 9', () => {
|
|||||||
require.resolve('../../collection.json'),
|
require.resolve('../../collection.json'),
|
||||||
'universal',
|
'universal',
|
||||||
{
|
{
|
||||||
clientProject: 'migration-test',
|
project: 'migration-test',
|
||||||
},
|
},
|
||||||
tree,
|
tree,
|
||||||
)
|
)
|
||||||
|
@ -33,7 +33,7 @@ import { Schema as UniversalOptions } from './schema';
|
|||||||
|
|
||||||
function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): Rule {
|
function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): Rule {
|
||||||
return updateWorkspace((workspace) => {
|
return updateWorkspace((workspace) => {
|
||||||
const clientProject = workspace.projects.get(options.clientProject);
|
const clientProject = workspace.projects.get(options.project);
|
||||||
|
|
||||||
if (clientProject) {
|
if (clientProject) {
|
||||||
// In case the browser builder hashes the assets
|
// In case the browser builder hashes the assets
|
||||||
@ -59,7 +59,7 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
|
|||||||
|
|
||||||
const buildTarget = clientProject.targets.get('build');
|
const buildTarget = clientProject.targets.get('build');
|
||||||
if (buildTarget?.options) {
|
if (buildTarget?.options) {
|
||||||
buildTarget.options.outputPath = `dist/${options.clientProject}/browser`;
|
buildTarget.options.outputPath = `dist/${options.project}/browser`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildConfigurations = buildTarget?.configurations;
|
const buildConfigurations = buildTarget?.configurations;
|
||||||
@ -77,7 +77,7 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R
|
|||||||
builder: Builders.Server,
|
builder: Builders.Server,
|
||||||
defaultConfiguration: 'production',
|
defaultConfiguration: 'production',
|
||||||
options: {
|
options: {
|
||||||
outputPath: `dist/${options.clientProject}/server`,
|
outputPath: `dist/${options.project}/server`,
|
||||||
main: join(
|
main: join(
|
||||||
normalize(clientProject.root),
|
normalize(clientProject.root),
|
||||||
'src',
|
'src',
|
||||||
@ -226,7 +226,7 @@ export default function (options: UniversalOptions): Rule {
|
|||||||
return async (host: Tree, context: SchematicContext) => {
|
return async (host: Tree, context: SchematicContext) => {
|
||||||
const workspace = await getWorkspace(host);
|
const workspace = await getWorkspace(host);
|
||||||
|
|
||||||
const clientProject = workspace.projects.get(options.clientProject);
|
const clientProject = workspace.projects.get(options.project);
|
||||||
if (!clientProject || clientProject.extensions.projectType !== 'application') {
|
if (!clientProject || clientProject.extensions.projectType !== 'application') {
|
||||||
throw new SchematicsException(`Universal requires a project type of "application".`);
|
throw new SchematicsException(`Universal requires a project type of "application".`);
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ describe('Universal Schematic', () => {
|
|||||||
require.resolve('../collection.json'),
|
require.resolve('../collection.json'),
|
||||||
);
|
);
|
||||||
const defaultOptions: UniversalOptions = {
|
const defaultOptions: UniversalOptions = {
|
||||||
clientProject: 'bar',
|
project: 'bar',
|
||||||
};
|
};
|
||||||
const workspaceUniversalOptions: UniversalOptions = {
|
const workspaceUniversalOptions: UniversalOptions = {
|
||||||
clientProject: 'workspace',
|
project: 'workspace',
|
||||||
};
|
};
|
||||||
|
|
||||||
const workspaceOptions: WorkspaceOptions = {
|
const workspaceOptions: WorkspaceOptions = {
|
||||||
|
@ -6,9 +6,12 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "Pass this schematic to the \"run\" command to set up server-side rendering for an app.",
|
"description": "Pass this schematic to the \"run\" command to set up server-side rendering for an app.",
|
||||||
"properties": {
|
"properties": {
|
||||||
"clientProject": {
|
"project": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The name of the related client app. Required in place of \"project\"."
|
"description": "The name of the project.",
|
||||||
|
"$default": {
|
||||||
|
"$source": "projectName"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appId": {
|
"appId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -45,5 +48,5 @@
|
|||||||
"default": false
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["clientProject"]
|
"required": ["project"]
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ const snapshots = require('../../ng-snapshot/package.json');
|
|||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
|
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
|
||||||
await ng('generate', 'appShell', '--client-project', 'test-project');
|
await ng('generate', 'appShell', '--project', 'test-project');
|
||||||
|
|
||||||
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
||||||
if (isSnapshotBuild) {
|
if (isSnapshotBuild) {
|
||||||
|
@ -8,7 +8,7 @@ import { updateJsonFile } from '../../utils/project';
|
|||||||
const snapshots = require('../../ng-snapshot/package.json');
|
const snapshots = require('../../ng-snapshot/package.json');
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
await ng('generate', 'universal', '--client-project', 'test-project');
|
await ng('generate', 'universal', '--project', 'test-project');
|
||||||
|
|
||||||
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
||||||
if (isSnapshotBuild) {
|
if (isSnapshotBuild) {
|
||||||
@ -48,7 +48,10 @@ export default async function () {
|
|||||||
|
|
||||||
await ng('run', 'test-project:server', '--optimization', 'false');
|
await ng('run', 'test-project:server', '--optimization', 'false');
|
||||||
|
|
||||||
await expectFileToMatch('dist/test-project/server/main.js', /exports.*AppServerModule|"AppServerModule":/);
|
await expectFileToMatch(
|
||||||
|
'dist/test-project/server/main.js',
|
||||||
|
/exports.*AppServerModule|"AppServerModule":/,
|
||||||
|
);
|
||||||
await exec(normalize('node'), 'dist/test-project/server/main.js');
|
await exec(normalize('node'), 'dist/test-project/server/main.js');
|
||||||
await expectFileToMatch(
|
await expectFileToMatch(
|
||||||
'dist/test-project/server/index.html',
|
'dist/test-project/server/index.html',
|
||||||
|
@ -13,7 +13,6 @@ export default async function () {
|
|||||||
// Generate component in application to verify that it's minimal
|
// Generate component in application to verify that it's minimal
|
||||||
const { stdout } = await ng('generate', 'component', 'foo');
|
const { stdout } = await ng('generate', 'component', 'foo');
|
||||||
if (!stdout.includes('foo.component.scss')) {
|
if (!stdout.includes('foo.component.scss')) {
|
||||||
console.log(stdout);
|
|
||||||
throw new Error('Expected "foo.component.scss" to exist.');
|
throw new Error('Expected "foo.component.scss" to exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ export default async function () {
|
|||||||
'test-project-two',
|
'test-project-two',
|
||||||
);
|
);
|
||||||
if (!stdout2.includes('foo.component.less')) {
|
if (!stdout2.includes('foo.component.less')) {
|
||||||
console.log(stdout2);
|
|
||||||
throw new Error('Expected "foo.component.less" to exist.');
|
throw new Error('Expected "foo.component.less" to exist.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ export default async function () {
|
|||||||
|
|
||||||
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
|
||||||
|
|
||||||
await updateJsonFile('package.json', packageJson => {
|
await updateJsonFile('package.json', (packageJson) => {
|
||||||
const dependencies = packageJson['dependencies'];
|
const dependencies = packageJson['dependencies'];
|
||||||
dependencies['@angular/localize'] = isSnapshotBuild
|
dependencies['@angular/localize'] = isSnapshotBuild
|
||||||
? snapshots.dependencies['@angular/localize']
|
? snapshots.dependencies['@angular/localize']
|
||||||
@ -29,10 +29,10 @@ export default async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
|
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
|
||||||
await ng('generate', 'appShell', '--client-project', 'test-project');
|
await ng('generate', 'appShell', '--project', 'test-project');
|
||||||
|
|
||||||
if (isSnapshotBuild) {
|
if (isSnapshotBuild) {
|
||||||
await updateJsonFile('package.json', packageJson => {
|
await updateJsonFile('package.json', (packageJson) => {
|
||||||
const dependencies = packageJson['dependencies'];
|
const dependencies = packageJson['dependencies'];
|
||||||
dependencies['@angular/platform-server'] = snapshots.dependencies['@angular/platform-server'];
|
dependencies['@angular/platform-server'] = snapshots.dependencies['@angular/platform-server'];
|
||||||
dependencies['@angular/router'] = snapshots.dependencies['@angular/router'];
|
dependencies['@angular/router'] = snapshots.dependencies['@angular/router'];
|
||||||
@ -49,7 +49,7 @@ export default async function () {
|
|||||||
{ lang: 'fr', translation: 'Bonjour i18n!' },
|
{ lang: 'fr', translation: 'Bonjour i18n!' },
|
||||||
];
|
];
|
||||||
|
|
||||||
await updateJsonFile('angular.json', workspaceJson => {
|
await updateJsonFile('angular.json', (workspaceJson) => {
|
||||||
const appProject = workspaceJson.projects['test-project'];
|
const appProject = workspaceJson.projects['test-project'];
|
||||||
const appArchitect = appProject.architect || appProject.targets;
|
const appArchitect = appProject.architect || appProject.targets;
|
||||||
const buildOptions = appArchitect['build'].options;
|
const buildOptions = appArchitect['build'].options;
|
||||||
@ -111,10 +111,7 @@ export default async function () {
|
|||||||
|
|
||||||
// Clean up app.component.html so that we can easily
|
// Clean up app.component.html so that we can easily
|
||||||
// find the translation text
|
// find the translation text
|
||||||
await writeFile(
|
await writeFile('src/app/app.component.html', '<router-outlet></router-outlet>');
|
||||||
'src/app/app.component.html',
|
|
||||||
'<router-outlet></router-outlet>',
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const { lang, translation } of langTranslations) {
|
for (const { lang, translation } of langTranslations) {
|
||||||
if (lang != 'en-US') {
|
if (lang != 'en-US') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user