Skip to content

Commit c643e71

Browse files
alan-agius4CaerusKaru
authored andcommitted
build: exclude schematics testing folder from being shipped (#1361)
Currently we are including the testing folder in the npm_package See: https://unpkg.com/browse/@nguniversal/express-engine@9.0.0-next.8/schematics
1 parent 5a46153 commit c643e71

File tree

6 files changed

+66
-51
lines changed

6 files changed

+66
-51
lines changed

modules/common/schematics/BUILD.bazel

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ts_library(
1515
srcs = glob(
1616
["**/*.ts"],
1717
exclude = [
18+
"testing/**/*",
1819
"**/*.spec.ts",
1920
"**/files/**/*",
2021
],
@@ -47,7 +48,10 @@ jasmine_node_test(
4748
ng_test_library(
4849
name = "schematics_test_sources",
4950
srcs = glob(
50-
["**/*.spec.ts"],
51+
[
52+
"testing/*.ts",
53+
"**/*.spec.ts",
54+
],
5155
exclude = ["**/files/**/*"],
5256
),
5357
tsconfig = ":tsconfig.json",

modules/common/schematics/testing/test-app.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
10-
import {switchMap} from 'rxjs/operators';
9+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1110

1211
/** Path to the collection file for the NgUniversal schematics */
1312
export const collectionPath = require.resolve('@schematics/angular/collection.json');
1413

1514
/** Create a base app used for testing. */
16-
export function createTestApp(appOptions = {}): Promise<UnitTestTree> {
15+
export async function createTestApp(appOptions = {}): Promise<UnitTestTree> {
1716
const baseRunner =
18-
new SchematicTestRunner('universal-schematics', collectionPath);
17+
new SchematicTestRunner('universal-schematics', collectionPath);
1918

20-
return baseRunner
21-
.runExternalSchematicAsync('@schematics/angular', 'workspace', {
22-
name: 'workspace',
23-
version: '6.0.0',
24-
newProjectRoot: 'projects',
25-
})
26-
.pipe(
27-
switchMap(workspaceTree => baseRunner.runExternalSchematicAsync(
28-
'@schematics/angular', 'application',
29-
{...appOptions, name: 'test-app'}, workspaceTree)),
30-
)
31-
.toPromise();
19+
const tree = await baseRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', {
20+
name: 'workspace',
21+
version: '6.0.0',
22+
newProjectRoot: 'projects',
23+
}).toPromise();
24+
25+
return baseRunner.runExternalSchematicAsync(
26+
'@schematics/angular', 'application',
27+
{
28+
...appOptions,
29+
name: 'test-app',
30+
},
31+
tree
32+
).toPromise();
3233
}

modules/express-engine/schematics/BUILD.bazel

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ts_library(
1717
srcs = glob(
1818
["**/*.ts"],
1919
exclude = [
20+
"testing/**/*",
2021
"**/*.spec.ts",
2122
"**/files/**/*",
2223
],
@@ -55,7 +56,10 @@ jasmine_node_test(
5556
ng_test_library(
5657
name = "schematics_test_sources",
5758
srcs = glob(
58-
["**/*.spec.ts"],
59+
[
60+
"testing/*.ts",
61+
"**/*.spec.ts",
62+
],
5963
exclude = ["**/files/**/*"],
6064
),
6165
tsconfig = ":tsconfig.json",

modules/express-engine/schematics/testing/test-app.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
10-
import {switchMap} from 'rxjs/operators';
9+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1110

1211
/** Path to the collection file for the NgUniversal schematics */
1312
export const collectionPath = require.resolve('../collection.json');
1413

1514
/** Create a base app used for testing. */
16-
export function createTestApp(appOptions = {}): Promise<UnitTestTree> {
15+
export async function createTestApp(appOptions = {}): Promise<UnitTestTree> {
1716
const baseRunner =
18-
new SchematicTestRunner('universal-schematics', collectionPath);
17+
new SchematicTestRunner('universal-schematics', collectionPath);
1918

20-
return baseRunner
21-
.runExternalSchematicAsync('@schematics/angular', 'workspace', {
22-
name: 'workspace',
23-
version: '6.0.0',
24-
newProjectRoot: 'projects',
25-
})
26-
.pipe(
27-
switchMap(workspaceTree => baseRunner.runExternalSchematicAsync(
28-
'@schematics/angular', 'application',
29-
{...appOptions, name: 'test-app'}, workspaceTree)),
30-
)
31-
.toPromise();
19+
const tree = await baseRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', {
20+
name: 'workspace',
21+
version: '6.0.0',
22+
newProjectRoot: 'projects',
23+
}).toPromise();
24+
25+
return baseRunner.runExternalSchematicAsync(
26+
'@schematics/angular', 'application',
27+
{
28+
...appOptions,
29+
name: 'test-app',
30+
},
31+
tree
32+
).toPromise();
3233
}

modules/hapi-engine/schematics/BUILD.bazel

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ts_library(
1717
srcs = glob(
1818
["**/*.ts"],
1919
exclude = [
20+
"testing/**/*",
2021
"**/*.spec.ts",
2122
"**/files/**/*",
2223
],
@@ -55,7 +56,10 @@ jasmine_node_test(
5556
ng_test_library(
5657
name = "schematics_test_sources",
5758
srcs = glob(
58-
["**/*.spec.ts"],
59+
[
60+
"testing/*.ts",
61+
"**/*.spec.ts",
62+
],
5963
exclude = ["**/files/**/*"],
6064
),
6165
tsconfig = ":tsconfig.json",

modules/hapi-engine/schematics/testing/test-app.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing';
10-
import {switchMap} from 'rxjs/operators';
9+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
1110

1211
/** Path to the collection file for the NgUniversal schematics */
1312
export const collectionPath = require.resolve('../collection.json');
1413

1514
/** Create a base app used for testing. */
16-
export function createTestApp(appOptions = {}): Promise<UnitTestTree> {
15+
export async function createTestApp(appOptions = {}): Promise<UnitTestTree> {
1716
const baseRunner =
18-
new SchematicTestRunner('universal-schematics', collectionPath);
17+
new SchematicTestRunner('universal-schematics', collectionPath);
1918

20-
return baseRunner
21-
.runExternalSchematicAsync('@schematics/angular', 'workspace', {
22-
name: 'workspace',
23-
version: '6.0.0',
24-
newProjectRoot: 'projects',
25-
})
26-
.pipe(
27-
switchMap(workspaceTree => baseRunner.runExternalSchematicAsync(
28-
'@schematics/angular', 'application',
29-
{...appOptions, name: 'test-app'}, workspaceTree)),
30-
)
31-
.toPromise();
19+
const tree = await baseRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', {
20+
name: 'workspace',
21+
version: '6.0.0',
22+
newProjectRoot: 'projects',
23+
}).toPromise();
24+
25+
return baseRunner.runExternalSchematicAsync(
26+
'@schematics/angular', 'application',
27+
{
28+
...appOptions,
29+
name: 'test-app',
30+
},
31+
tree
32+
).toPromise();
3233
}

0 commit comments

Comments
 (0)