Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit f903728

Browse files
committed
refactor: resolve comments from Mike and Ben
Also added linting and fix those.
1 parent bd11991 commit f903728

25 files changed

+283
-197
lines changed

.travis.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
dist: trusty
2+
3+
language: node_js
4+
5+
env:
6+
global:
7+
- DBUS_SESSION_BUS_ADDRESS=/dev/null
8+
9+
matrix:
10+
fast_finish: true
11+
include:
12+
- node_js: "6"
13+
os: linux
14+
env: SCRIPT=lint
15+
- node_js: "6"
16+
os: linux
17+
env: SCRIPT=test
18+
- node_js: "6"
19+
os: linux
20+
env: NODE_SCRIPT="tests/run_e2e.js --glob=tests/build/**"
21+
- node_js: "6"
22+
os: linux
23+
env: NODE_SCRIPT="tests/run_e2e.js --ignore=**/tests/build/**"
24+
- node_js: "6"
25+
os: linux
26+
env: NODE_SCRIPT="tests/run_e2e.js --eject --glob=tests/build/**"
27+
28+
# Deploy builds.
29+
- node_js: "6"
30+
os: linux
31+
env:
32+
- DEPLOY_SCRIPT="scripts/git-builds.js"
33+
# GITHUB_ACCESS_TOKEN=<github token, a personal access token of the angular-builds account, account access in valentine>
34+
# This is needed for the e2e Travis matrix task to publish packages to github for continuous packages delivery.
35+
- secure: "XUM1RCN/ZH34ju2PI9eHPRMnSlbj45XcBx/ZnZ13wfau60iJCveU7Ded8SC8uwGDp58rGGePXyJfh5l5dAnIWbSAGNKlrEgGTr41RSCbyzrV6m4lAcwNzUo/PkKum1vAApk21PqscrSSWOBAOC3nMCln25GLzgUMm6G8FBOc599NuszcoQvru+H+4JthSHn4l/nmeTZDs2oCBvwnmng/78rEW5CXvJEpAwuaaZLvzzIFdoZu+SuceYvGnL5xHo0ppPF/0NYzZlb7KBKREp44Lq1lOKlDtH5wqjEi7b2aA7/GnesOgLUBmbbSVUzmCxs6PtzGhD56aiL2Qtu8c4LZyvNfzPXSLbx8ljYmdytHkio9w3377wWFRXJDfIsgv9JKHxxyA0T34yzQkqWbgWKPMgJ3om+lb875iXAtXfNyS0trnN+rwLZZtFxygjHyx8IWY+NZD5i5fyjMdFyetNxbHe3ktI73nY+Tl6hDqJXvN8WwQlMovLNUMcY4wGUoPooLka9L+94uetbf3U4KVgshrLHI59jMZsO0qrDGsCZMubHEy80acrNkCTi/uGIbVR0KF94z81VF+S7edYv80AkQTRijpgNV34045L/IqSHgbueozRgVFj2arkAGGFjLlZJifmsRC/Eq1ZWkKsKY/1NusKssCRtycJQjeLOW0qV1T0w="
36+
37+
# Optional builds.
38+
- node_js: "6"
39+
os: linux
40+
env: NODE_SCRIPT="tests/run_e2e.js --ng2"
41+
- node_js: "6"
42+
os: linux
43+
env: NODE_SCRIPT="tests/run_e2e.js --nightly"
44+
- node_js: "7"
45+
os: linux
46+
env: NODE_SCRIPT=tests/run_e2e.js
47+
48+
before_install:
49+
# Use a virtual display.
50+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
51+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi
52+
# Install latest chrome.
53+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=/usr/bin/google-chrome; fi
54+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
55+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libappindicator1 fonts-liberation; fi
56+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; fi
57+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo dpkg -i google-chrome*.deb; fi
58+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo "--no-sandbox" > ~/.config/chrome-flags.conf; fi
59+
# Install yarn.
60+
- curl -o- -L https://yarnpkg.com/install.sh | bash
61+
- export PATH="$HOME/.yarn/bin:$PATH"
62+
- yarn config set spin false
63+
- yarn config set progress false
64+
65+
script:
66+
- if [[ "$SCRIPT" ]]; then npm run-script $SCRIPT; fi
67+
- if [[ "$NODE_SCRIPT" ]]; then node $NODE_SCRIPT; fi
68+
- if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$DEPLOY_SCRIPT" != "" ]]; then node $DEPLOY_SCRIPT; fi

bin/sdk-admin renamed to bin/devkit-admin

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
require('../lib/bootstrap-local');
1111

1212
const minimist = require('minimist');
13+
const path = require('path');
1314

1415
const args = minimist(process.argv.slice(2));
16+
const scriptName = path.join('../scripts', args._.shift());
1517

16-
17-
switch (args._[0]) {
18-
case 'test': require('../scripts/test').default(args); break;
19-
20-
default: console.log('Unknown command: ' + args._[0]); break;
21-
}
18+
require(scriptName).default(args);

lib/bootstrap-local.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const ts = require('typescript');
1515

1616
Error.stackTraceLimit = Infinity;
1717

18-
global._SdkIsLocal = true;
19-
global._SdkRoot = path.resolve(__dirname, '..');
20-
global._SdkPackages = require('./packages').packages;
21-
global._SdkTools = require('./packages').tools;
18+
global._DevKitIsLocal = true;
19+
global._DevKitRoot = path.resolve(__dirname, '..');
20+
global._DevKitPackages = require('./packages').packages;
21+
global._DevKitTools = require('./packages').tools;
2222

23-
global._SdkRequireHook = null;
23+
global._DevKitRequireHook = null;
2424

2525

2626
const compilerOptions = ts.readConfigFile(path.join(__dirname, '../tsconfig.json'), p => {
@@ -32,7 +32,7 @@ const oldRequireTs = require.extensions['.ts'];
3232
require.extensions['.ts'] = function (m, filename) {
3333
// If we're in node module, either call the old hook or simply compile the
3434
// file without transpilation. We do not touch node_modules/**.
35-
// We do touch `Angular SDK` files anywhere though.
35+
// We do touch `Angular DevK` files anywhere though.
3636
if (!filename.match(/@angular\/cli\b/) && filename.match(/node_modules/)) {
3737
if (oldRequireTs) {
3838
return oldRequireTs(m, filename);
@@ -46,8 +46,8 @@ require.extensions['.ts'] = function (m, filename) {
4646
try {
4747
let result = ts.transpile(source, compilerOptions['compilerOptions'], filename);
4848

49-
if (global._SdkRequireHook) {
50-
result = global._SdkRequireHook(result, filename);
49+
if (global._DevKitRequireHook) {
50+
result = global._DevKitRequireHook(result, filename);
5151
}
5252

5353
// Send it to node to execute.

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
{
2-
"name": "@angular/sdk",
2+
"name": "@angular/devkit",
33
"version": "0.0.0",
44
"description": "Software Development Kit for Angular",
55
"bin": {
6-
"sdk-admin": "./bin/sdk-admin",
6+
"devkit-admin": "./bin/devkit-admin",
77
"schematics": "./bin/schematics"
88
},
99
"keywords": [],
1010
"scripts": {
11-
"test": "./bin/sdk-admin test"
11+
"admin": "./bin/devkit-admin",
12+
"build": "tsc -p tsconfig.json",
13+
"fix": "npm run lint -- --fix",
14+
"lint": "tslint --config tslint.json --project tsconfig.json --type-check",
15+
"test": "./bin/devkit-admin test"
1216
},
1317
"repository": {
1418
"type": "git",
15-
"url": "https://github.com/angular/sdk.git"
19+
"url": "https://github.com/angular/devkit.git"
1620
},
1721
"engines": {
1822
"node": ">= 6.9.0",
@@ -21,9 +25,9 @@
2125
"author": "Angular Authors",
2226
"license": "MIT",
2327
"bugs": {
24-
"url": "https://github.com/angular/sdk/issues"
28+
"url": "https://github.com/angular/devkit/issues"
2529
},
26-
"homepage": "https://github.com/angular/sdk",
30+
"homepage": "https://github.com/angular/devkit",
2731
"dependencies": {
2832
"@ngtools/json-schema": "^1.0.9",
2933
"@ngtools/logger": "^1.0.1",

packages/schematics/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"blueprints",
1111
"code generation",
1212
"schematics",
13-
"Angular SDK"
13+
"Angular DevKit"
1414
],
1515
"repository": {
1616
"type": "git",
17-
"url": "https://github.com/angular/sdk.git"
17+
"url": "https://github.com/angular/devkit.git"
1818
},
1919
"engines": {
2020
"node": ">= 6.9.0",
@@ -23,9 +23,9 @@
2323
"author": "Angular Authors",
2424
"license": "MIT",
2525
"bugs": {
26-
"url": "https://github.com/angular/sdk/issues"
26+
"url": "https://github.com/angular/devkit/issues"
2727
},
28-
"homepage": "https://github.com/angular/sdk",
28+
"homepage": "https://github.com/angular/devkit",
2929
"dependencies": {
3030
}
3131
}

packages/schematics/src/engine/engine.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class UnknownCollectionException extends BaseException {
3333
}
3434
export class UnknownSchematicException extends BaseException {
3535
constructor(name: string, collection: Collection<any, any>) {
36-
super(`Schematic "${name}" not found in collection "${collection.name}".`);
36+
super(`Schematic "${name}" not found in collection "${collection.description.name}".`);
3737
}
3838
}
3939

@@ -68,11 +68,11 @@ export class SchematicEngine<CollectionT, SchematicT> implements Engine<Collecti
6868
createSchematic(
6969
name: string,
7070
collection: Collection<CollectionT, SchematicT>): Schematic<CollectionT, SchematicT> {
71-
const collectionImpl = this._collectionCache.get(collection.name);
72-
const schematicMap = this._schematicCache.get(collection.name);
71+
const collectionImpl = this._collectionCache.get(collection.description.name);
72+
const schematicMap = this._schematicCache.get(collection.description.name);
7373
if (!collectionImpl || !schematicMap || collectionImpl !== collection) {
7474
// This is weird, maybe the collection was created by another engine?
75-
throw new UnknownCollectionException(collection.name);
75+
throw new UnknownCollectionException(collection.description.name);
7676
}
7777

7878
let schematic = schematicMap.get(name);

packages/schematics/src/engine/interface.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,39 @@ import {Url} from 'url';
1313

1414
/**
1515
* The description (metadata) of a collection. This type contains every information the engine
16-
* needs to run. The CollectionT type parameter contains additional metadata that you want to
17-
* store while remaining type-safe.
16+
* needs to run. The CollectionMetadataT type parameter contains additional metadata that you
17+
* want to store while remaining type-safe.
1818
*/
19-
export type CollectionDescription<CollectionT extends {}> = CollectionT & {
19+
export type CollectionDescription<CollectionMetadataT extends {}> = CollectionMetadataT & {
2020
readonly name: string;
2121
};
2222

2323
/**
2424
* The description (metadata) of a schematic. This type contains every information the engine
25-
* needs to run. The SchematicT and CollectionT type parameters contain additional metadata
26-
* that you want to store while remaining type-safe.
25+
* needs to run. The SchematicMetadataT and CollectionMetadataT type parameters contain additional
26+
* metadata that you want to store while remaining type-safe.
2727
*/
28-
export type SchematicDescription<CollectionT extends {}, SchematicT extends {}> = SchematicT & {
29-
readonly collection: CollectionDescription<CollectionT>;
28+
export type SchematicDescription<CollectionMetadataT extends {},
29+
SchematicMetadataT extends {}> = SchematicMetadataT & {
30+
readonly collection: CollectionDescription<CollectionMetadataT>;
3031
readonly name: string;
3132
};
3233

3334

3435
/**
3536
* The Host for the Engine. Specifically, the piece of the tooling responsible for resolving
36-
* collections and schematics descriptions. The SchematicT and CollectionT type parameters contain
37-
* additional metadata that you want to store while remaining type-safe.
37+
* collections and schematics descriptions. The SchematicMetadataT and CollectionMetadataT type
38+
* parameters contain additional metadata that you want to store while remaining type-safe.
3839
*/
39-
export interface EngineHost<CollectionT extends {}, SchematicT extends {}> {
40-
createCollectionDescription(name: string): CollectionDescription<CollectionT> | null;
40+
export interface EngineHost<CollectionMetadataT extends {}, SchematicMetadataT extends {}> {
41+
createCollectionDescription(name: string): CollectionDescription<CollectionMetadataT> | null;
4142
createSchematicDescription(
4243
name: string,
43-
collection: CollectionDescription<CollectionT>):
44-
SchematicDescription<CollectionT, SchematicT> | null;
44+
collection: CollectionDescription<CollectionMetadataT>):
45+
SchematicDescription<CollectionMetadataT, SchematicMetadataT> | null;
4546
getSchematicRuleFactory<OptionT>(
46-
schematic: SchematicDescription<CollectionT, SchematicT>,
47-
collection: CollectionDescription<CollectionT>): RuleFactory<OptionT>;
47+
schematic: SchematicDescription<CollectionMetadataT, SchematicMetadataT>,
48+
collection: CollectionDescription<CollectionMetadataT>): RuleFactory<OptionT>;
4849
createSourceFromUrl(url: Url): Source | null;
4950

5051
readonly defaultMergeStrategy?: MergeStrategy;
@@ -55,16 +56,18 @@ export interface EngineHost<CollectionT extends {}, SchematicT extends {}> {
5556
* The root Engine for creating and running schematics and collections. Everything related to
5657
* a schematic execution starts from this interface.
5758
*
58-
* CollectionT is, by default, a generic Collection metadata type. This is used throughout the
59-
* engine typings so that you can use a type that's merged into descriptions, while being type-safe.
59+
* CollectionMetadataT is, by default, a generic Collection metadata type. This is used throughout
60+
* the engine typings so that you can use a type that's merged into descriptions, while being
61+
* type-safe.
6062
*
61-
* SchematicT is a type that contains additional typing for the Schematic Description.
63+
* SchematicMetadataT is a type that contains additional typing for the Schematic Description.
6264
*/
63-
export interface Engine<CollectionT extends {}, SchematicT extends {}> {
64-
createCollection(name: string): Collection<CollectionT, SchematicT>;
65+
export interface Engine<CollectionMetadataT extends {}, SchematicMetadataT extends {}> {
66+
createCollection(name: string): Collection<CollectionMetadataT, SchematicMetadataT>;
6567
createSchematic(
6668
name: string,
67-
collection: Collection<CollectionT, SchematicT>): Schematic<CollectionT, SchematicT>;
69+
collection: Collection<CollectionMetadataT, SchematicMetadataT>
70+
): Schematic<CollectionMetadataT, SchematicMetadataT>;
6871
createSourceFromUrl(url: Url): Source;
6972

7073
readonly defaultMergeStrategy: MergeStrategy;
@@ -75,21 +78,20 @@ export interface Engine<CollectionT extends {}, SchematicT extends {}> {
7578
* A Collection as created by the Engine. This should be used by the tool to create schematics,
7679
* or by rules to create other schematics as well.
7780
*/
78-
export interface Collection<CollectionT, SchematicT> {
79-
readonly name: string;
80-
readonly description: CollectionDescription<CollectionT>;
81+
export interface Collection<CollectionMetadataT, SchematicMetadataT> {
82+
readonly description: CollectionDescription<CollectionMetadataT>;
8183

82-
createSchematic(name: string): Schematic<CollectionT, SchematicT>;
84+
createSchematic(name: string): Schematic<CollectionMetadataT, SchematicMetadataT>;
8385
}
8486

8587

8688
/**
8789
* A Schematic as created by the Engine. This should be used by the tool to execute the main
8890
* schematics, or by rules to execute other schematics as well.
8991
*/
90-
export interface Schematic<CollectionT, SchematicT> {
91-
readonly description: SchematicDescription<CollectionT, SchematicT>;
92-
readonly collection: Collection<CollectionT, SchematicT>;
92+
export interface Schematic<CollectionMetadataT, SchematicMetadataT> {
93+
readonly description: SchematicDescription<CollectionMetadataT, SchematicMetadataT>;
94+
readonly collection: Collection<CollectionMetadataT, SchematicMetadataT>;
9395

9496
call<T>(options: T, host: Observable<Tree>): Observable<Tree>;
9597
}
@@ -99,9 +101,9 @@ export interface Schematic<CollectionT, SchematicT> {
99101
* A SchematicContext. Contains information necessary for Schematics to execute some rules, for
100102
* example when using another schematics, as we need the engine and collection.
101103
*/
102-
export interface TypedSchematicContext<CollectionT, SchematicT> {
103-
readonly engine: Engine<CollectionT, SchematicT>;
104-
readonly schematic: Schematic<CollectionT, SchematicT>;
104+
export interface TypedSchematicContext<CollectionMetadataT, SchematicMetadataT> {
105+
readonly engine: Engine<CollectionMetadataT, SchematicMetadataT>;
106+
readonly schematic: Schematic<CollectionMetadataT, SchematicMetadataT>;
105107
readonly host: Observable<Tree>;
106108
readonly strategy: MergeStrategy;
107109
}

packages/schematics/src/engine/schematic.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {Tree} from '../tree/interface';
1717
import {BaseException} from '../exception/exception';
1818

1919
import {Observable} from 'rxjs/Observable';
20-
import 'rxjs/add/observable/fromPromise';
2120
import 'rxjs/add/observable/of';
2221
import 'rxjs/add/operator/concatMap';
2322

0 commit comments

Comments
 (0)