Skip to content

Commit 76530d0

Browse files
committed
feat(@angular/cli): disable broken commands for platform server
1 parent daebbf4 commit 76530d0

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

packages/@angular/cli/tasks/e2e.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { stripIndents } from 'common-tags';
44
import { E2eTaskOptions } from '../commands/e2e';
55
import { CliConfig } from '../models/config';
66
import { requireProjectModule } from '../utilities/require-project-module';
7+
import { getAppFromConfig } from '../utilities/app-utils';
78

89
const Task = require('../ember-cli/lib/models/task');
910
const SilentError = require('silent-error');
@@ -14,10 +15,14 @@ export const E2eTask = Task.extend({
1415
const projectConfig = CliConfig.fromProject().config;
1516
const projectRoot = this.project.root;
1617
const protractorLauncher = requireProjectModule(projectRoot, 'protractor/built/launcher');
18+
const appConfig = getAppFromConfig(e2eTaskOptions.app);
1719

1820
if (projectConfig.project && projectConfig.project.ejected) {
1921
throw new SilentError('An ejected project cannot use the build command anymore.');
2022
}
23+
if (appConfig.platform === 'server') {
24+
throw new SilentError('ng test for platform server applications is coming soon!');
25+
}
2126

2227
return new Promise(function () {
2328
let promise = Promise.resolve();

packages/@angular/cli/tasks/eject.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ export default Task.extend({
436436
if (project.root === path.resolve(outputPath)) {
437437
throw new SilentError ('Output path MUST not be project root directory!');
438438
}
439+
if (appConfig.platform && appConfig.platform === 'server') {
440+
throw new SilentError('ng eject for platform server applications is coming soon!');
441+
}
439442

440443
const webpackConfig = new NgCliWebpackConfig(runTaskOptions, appConfig).buildConfig();
441444
const serializer = new JsonWebpackSerializer(process.cwd(), outputPath, appConfig.root);

packages/@angular/cli/tasks/serve.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default Task.extend({
3131
if (projectConfig.project && projectConfig.project.ejected) {
3232
throw new SilentError('An ejected project cannot use the build command anymore.');
3333
}
34+
if (appConfig.platform === 'server') {
35+
throw new SilentError('ng serve for platform server applications is coming soon!');
36+
}
3437
if (serveTaskOptions.deleteOutputPath) {
3538
fs.removeSync(path.resolve(this.project.root, outputPath));
3639
}

packages/@angular/cli/tasks/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'path';
33
import { TestOptions } from '../commands/test';
44
import { CliConfig } from '../models/config';
55
import { requireProjectModule } from '../utilities/require-project-module';
6+
import { getAppFromConfig } from '../utilities/app-utils';
67

78
const Task = require('../ember-cli/lib/models/task');
89
const SilentError = require('silent-error');
@@ -12,10 +13,14 @@ export default Task.extend({
1213
run: function (options: TestOptions) {
1314
const projectConfig = CliConfig.fromProject().config;
1415
const projectRoot = this.project.root;
16+
const appConfig = getAppFromConfig(options.app);
1517

1618
if (projectConfig.project && projectConfig.project.ejected) {
1719
throw new SilentError('An ejected project cannot use the build command anymore.');
1820
}
21+
if (appConfig.platform === 'server') {
22+
throw new SilentError('ng test for platform server applications is coming soon!');
23+
}
1924

2025
return new Promise((resolve) => {
2126
const karma = requireProjectModule(projectRoot, 'karma');

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default function () {
1111
return Promise.resolve();
1212
}
1313

14+
// Skip this for ejected tests.
15+
if (getGlobalVariable('argv').eject) {
16+
return Promise.resolve();
17+
}
18+
1419
return Promise.resolve()
1520
.then(() => updateJsonFile('.angular-cli.json', configJson => {
1621
const app = configJson['apps'][0];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ng } from '../../utils/process';
2+
import { updateJsonFile } from '../../utils/project';
3+
import { expectToFail } from '../../utils/utils';
4+
5+
export default function () {
6+
return Promise.resolve()
7+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
8+
const app = configJson['apps'][0];
9+
app['platform'] = 'server';
10+
}))
11+
.then(() => expectToFail(() => ng('serve')))
12+
.then(() => expectToFail(() => ng('test')))
13+
.then(() => expectToFail(() => ng('e2e')))
14+
.then(() => expectToFail(() => ng('eject')));
15+
}

0 commit comments

Comments
 (0)