Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2316ea2
refactor: remove unused dependency and update package
hansl Jul 1, 2017
091a39f
refactor: move template implementation to core
hansl Sep 18, 2017
8701661
build: add support for requiring ejs files
hansl Sep 21, 2017
10309fc
test: allow benchmarks to disable tslint rules
hansl Sep 21, 2017
e8ee67e
refactor: add literal template handlers to core utils
hansl Sep 21, 2017
215c238
feat(@angular-devkit/core): add JSON-schema feature
hansl Sep 21, 2017
850c540
feat(@angular-devkit/schematics): use the new json-schema library
hansl Sep 21, 2017
d05fd29
feat(@angular-devkit/schematics): support -- args
hansl Sep 21, 2017
785436d
fix(@angular-devkit/schematics): transform options as part of observable
hansl Sep 21, 2017
12b616e
fix(@angular-devkit/core): fix node 6 support
hansl Sep 21, 2017
f7580bf
feat(@angular-devkit/schematics): descriptive error
hansl Sep 21, 2017
59b9f5e
feat(@angular-devkit/schematics): descriptive error
hansl Sep 21, 2017
9a0e46e
feat(@angular-devkit/core): add a generic node resolver
hansl Sep 23, 2017
ce90830
feat(@angular-devkit/schematics): add test engine host
hansl Sep 23, 2017
557783d
test: fix slow test
hansl Sep 23, 2017
081ad51
feat(@angular-devkit/schematics): add support for relative collection…
hansl Sep 24, 2017
81a42a3
refactor(@angular-devkit/schematics): create context in engine
hansl Sep 24, 2017
0cc5ad2
feat(@angular-devkit/schematics): add a --debug flag to schematics tool
hansl Sep 24, 2017
d069e72
feat(@angular-devkit/schematics): add a logger to the context
hansl Sep 24, 2017
d26acfd
refactor: add a literal, move color functions to its own namespace
hansl Sep 24, 2017
26fe09d
feat(@angular-devkit/schematics): add pretty colors to output
hansl Sep 24, 2017
22ba1bf
refactor: fix the literals a bit
hansl Sep 24, 2017
18f1649
refactor: require the rxjs operators necessary for devkit-admin
hansl Sep 24, 2017
2968fd0
refactor: move cli-logger to node and rename the factory function
hansl Sep 24, 2017
cfcffa7
fix(@angular-devkit/core): fix an indentation issue with literals
hansl Sep 25, 2017
390d754
feat(@angular-devkit/core): add support for source map in templates
hansl Sep 25, 2017
aec53db
refactor: simplify Logger in schematics context
hansl Sep 25, 2017
3d51bda
feat(@angular-devkit/schematics): rules return values are optional now
hansl Sep 26, 2017
3849357
feat(@angular-devkit/schematics): logger of new context is child of p…
hansl Sep 26, 2017
7a89dfa
feat(@angular-devkit/schematics): have a schema for collection.json
hansl Sep 26, 2017
78e3867
feat(@angular-devkit/schematics): use the core json schema for Schema…
hansl Sep 26, 2017
3842600
fix(@angular-devkit/schematics): use loose mode for collection.json
hansl Sep 26, 2017
494f87d
feat(@angular-devkit/core): add support for schema in template
hansl Sep 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/devkit-admin
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ process.chdir(path.join(__dirname, '..'));
let logger = null;
try {
logger = new (require('@angular-devkit/core').IndentLogger)('root');
require('rxjs/add/operator/filter');

logger
.filter(entry => (entry.level !== 'debug' || args.verbose))
Expand Down
9 changes: 9 additions & 0 deletions lib/bootstrap-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ require.extensions['.ts'] = function (m, filename) {
};


require.extensions['.ejs'] = function (m, filename) {
const source = fs.readFileSync(filename).toString();
const template = require('@angular-devkit/core').template;
const result = template(source, { sourceURL: filename, sourceMap: true });

return m._compile(result.source.replace(/return/, 'module.exports.default = '), filename);
};


// If we're running locally, meaning npm linked. This is basically "developer mode".
if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
const packages = require('./packages').packages;
Expand Down
1,232 changes: 582 additions & 650 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
"homepage": "https://github.com/angular/devkit",
"dependencies": {
"@ngtools/json-schema": "^1.0.9",
"@ngtools/logger": "^1.0.1",
"@types/common-tags": "^1.2.4",
"@types/glob": "^5.0.29",
"@types/istanbul": "^0.4.29",
"@types/jasmine": "^2.5.47",
Expand All @@ -53,7 +51,6 @@
"@types/source-map": "^0.5.0",
"@types/webpack": "^3.0.2",
"@types/webpack-sources": "^0.1.3",
"common-tags": "^1.3.1",
"conventional-changelog": "^1.1.0",
"glob": "^7.0.3",
"istanbul": "^0.4.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { oneLine, stripIndent } from 'common-tags';
import { tags } from '@angular-devkit/core';
import { RawSourceMap } from 'source-map';
import { buildOptimizer } from './build-optimizer';

Expand All @@ -18,7 +18,7 @@ describe('build-optimizer', () => {

describe('basic functionality', () => {
it('applies class-fold, scrub-file and prefix-functions', () => {
const input = stripIndent`
const input = tags.stripIndent`
${imports}
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
Expand All @@ -37,7 +37,7 @@ describe('build-optimizer', () => {
Clazz.ctorParameters = function () { return [{type: Injector}]; };
`;
// tslint:disable:max-line-length
const output = oneLine`
const output = tags.oneLine`
/** PURE_IMPORTS_START _angular_core,tslib PURE_IMPORTS_END */
${imports}
import { __extends } from "tslib";
Expand All @@ -52,12 +52,12 @@ describe('build-optimizer', () => {

const inputFilePath = '/node_modules/@angular/core/@angular/core.es5.js';
const boOutput = buildOptimizer({ content: input, inputFilePath });
expect(oneLine`${boOutput.content}`).toEqual(output);
expect(tags.oneLine`${boOutput.content}`).toEqual(output);
expect(boOutput.emitSkipped).toEqual(false);
});

it('doesn\'t process files without decorators/ctorParameters/outside Angular', () => {
const input = oneLine`
const input = tags.oneLine`
var Clazz = (function () { function Clazz() { } return Clazz; }());
${staticProperty}
`;
Expand All @@ -70,26 +70,26 @@ describe('build-optimizer', () => {
it('supports es2015 modules', () => {
// prefix-functions would add PURE_IMPORTS_START and PURE to the super call.
// This test ensures it isn't applied to es2015 modules.
const output = oneLine`
const output = tags.oneLine`
import { Injectable } from '@angular/core';
class Clazz extends BaseClazz { constructor(e) { super(e); } }
`;
const input = stripIndent`
const input = tags.stripIndent`
${output}
Clazz.ctorParameters = () => [ { type: Injectable } ];
`;

const inputFilePath = '/node_modules/@angular/core/@angular/core.js';
const boOutput = buildOptimizer({ content: input, inputFilePath });
expect(oneLine`${boOutput.content}`).toEqual(output);
expect(tags.oneLine`${boOutput.content}`).toEqual(output);
expect(boOutput.emitSkipped).toEqual(false);
});
});


describe('resilience', () => {
it('doesn\'t process files with invalid syntax by default', () => {
const input = oneLine`
const input = tags.oneLine`
))))invalid syntax
${clazz}
Clazz.decorators = [ { type: Injectable } ];
Expand All @@ -101,7 +101,7 @@ describe('build-optimizer', () => {
});

it('throws on files with invalid syntax in strict mode', () => {
const input = oneLine`
const input = tags.oneLine`
))))invalid syntax
${clazz}
Clazz.decorators = [ { type: Injectable } ];
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('build-optimizer', () => {
});

describe('sourcemaps', () => {
const transformableInput = oneLine`
const transformableInput = tags.oneLine`
${imports}
${clazz}
${decorators}
Expand All @@ -154,11 +154,11 @@ describe('build-optimizer', () => {
});

it('doesn\'t produce sourcemaps when emitting was skipped', () => {
const ignoredInput = oneLine`
const ignoredInput = tags.oneLine`
var Clazz = (function () { function Clazz() { } return Clazz; }());
${staticProperty}
`;
const invalidInput = oneLine`
const invalidInput = tags.oneLine`
))))invalid syntax
${clazz}
Clazz.decorators = [ { type: Injectable } ];
Expand Down
32 changes: 16 additions & 16 deletions packages/angular_devkit/build_optimizer/src/purify/purify_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,77 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { oneLine, stripIndent } from 'common-tags';
import { tags } from '@angular-devkit/core';
import { purify } from './purify';

// tslint:disable:max-line-length
describe('purify', () => {
it('prefixes safe imports with /*@__PURE__*/', () => {
const input = stripIndent`
const input = tags.stripIndent`
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Subject__ = __webpack_require__("EEr4");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_http__ = __webpack_require__(72);
/** PURE_IMPORTS_START rxjs_Subject,_angular_http PURE_IMPORTS_END */
`;
const output = stripIndent`
const output = tags.stripIndent`
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_Subject__ = /*@__PURE__*/__webpack_require__("EEr4");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_http__ = /*@__PURE__*/__webpack_require__(72);
/** PURE_IMPORTS_START rxjs_Subject,_angular_http PURE_IMPORTS_END */
`;

expect(oneLine`${purify(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${purify(input)}`).toEqual(tags.oneLine`${output}`);
});

it('prefixes safe default imports with /*@__PURE__*/', () => {
const input = stripIndent`
const input = tags.stripIndent`
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Subject__ = __webpack_require__("rlar");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Subject___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_rxjs_Subject__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zone_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zone_js__);
/** PURE_IMPORTS_START rxjs_Subject,zone_js PURE_IMPORTS_END */
`;
const output = stripIndent`
const output = tags.stripIndent`
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Subject__ = /*@__PURE__*/__webpack_require__("rlar");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rxjs_Subject___default = /*@__PURE__*/__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_rxjs_Subject__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zone_js___default = /*@__PURE__*/__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zone_js__);
/** PURE_IMPORTS_START rxjs_Subject,zone_js PURE_IMPORTS_END */
`;

expect(oneLine`${purify(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${purify(input)}`).toEqual(tags.oneLine`${output}`);
});

it('prefix createComponentFactory and createNgModuleFactory function calls', () => {
const input = stripIndent`
const input = tags.stripIndent`
var AppComponentNgFactory = __WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* ɵccf */]('app-root');
var AppModuleNgFactory = __WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* ɵcmf */]('app-root');
var SelectComponentNgFactory = select_component_ngfactory___WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* ɵccf */]('aio-select');
`;
const output = stripIndent`
const output = tags.stripIndent`
var AppComponentNgFactory = /*@__PURE__*/__WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* ɵccf */]('app-root');
var AppModuleNgFactory = /*@__PURE__*/__WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* ɵcmf */]('app-root');
var SelectComponentNgFactory = /*@__PURE__*/select_component_ngfactory___WEBPACK_IMPORTED_MODULE_0__angular_core__["U" /* ɵccf */]('aio-select');
`;

expect(oneLine`${purify(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${purify(input)}`).toEqual(tags.oneLine`${output}`);
});

it('should prefix createRendererType2 function calls', () => {
const input = stripIndent`
const input = tags.stripIndent`
var RenderType_MdOption = index_ngfactory___WEBPACK_IMPORTED_MODULE_0__angular_core__["W" /* ɵcrt */]({ encapsulation: 2, styles: styles_MdOption});
`;
const output = stripIndent`
const output = tags.stripIndent`
var RenderType_MdOption = /*@__PURE__*/index_ngfactory___WEBPACK_IMPORTED_MODULE_0__angular_core__["W" /* ɵcrt */]({ encapsulation: 2, styles: styles_MdOption});
`;

expect(oneLine`${purify(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${purify(input)}`).toEqual(tags.oneLine`${output}`);
});

it('prefix module statements', () => {
const input = stripIndent`
const input = tags.stripIndent`
var AppModuleNgFactory = new __WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* NgModuleFactory */];
`;
const output = stripIndent`
const output = tags.stripIndent`
var AppModuleNgFactory = /*@__PURE__*/new __WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* NgModuleFactory */];
`;

expect(oneLine`${purify(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${purify(input)}`).toEqual(tags.oneLine`${output}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { oneLine, stripIndent } from 'common-tags';
import { tags } from '@angular-devkit/core';
import { transformJavascript } from '../helpers/transform-javascript';
import { getFoldFileTransformer } from './class-fold';

Expand All @@ -16,31 +16,31 @@ const transform = (content: string) => transformJavascript(
describe('class-fold', () => {
it('folds static properties into class', () => {
const staticProperty = 'Clazz.prop = 1;';
const input = stripIndent`
const input = tags.stripIndent`
var Clazz = (function () { function Clazz() { } return Clazz; }());
${staticProperty}
`;
const output = stripIndent`
const output = tags.stripIndent`
var Clazz = (function () { function Clazz() { }
${staticProperty} return Clazz; }());
`;

expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('folds multiple static properties into class', () => {
const staticProperty = 'Clazz.prop = 1;';
const anotherStaticProperty = 'Clazz.anotherProp = 2;';
const input = stripIndent`
const input = tags.stripIndent`
var Clazz = (function () { function Clazz() { } return Clazz; }());
${staticProperty}
${anotherStaticProperty}
`;
const output = stripIndent`
const output = tags.stripIndent`
var Clazz = (function () { function Clazz() { }
${staticProperty} ${anotherStaticProperty} return Clazz; }());
`;

expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { oneLine, stripIndent } from 'common-tags';
import { tags } from '@angular-devkit/core';
import { transformJavascript } from '../helpers/transform-javascript';
import { getImportTslibTransformer, testImportTslib } from './import-tslib';

Expand All @@ -15,24 +15,24 @@ const transform = (content: string) => transformJavascript(

describe('import-tslib', () => {
it('replaces __extends', () => {
const input = stripIndent`
const input = tags.stripIndent`
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
`;
const output = stripIndent`
const output = tags.stripIndent`
import { __extends } from "tslib";
`;

expect(testImportTslib(input)).toBeTruthy();
expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('replaces __decorate', () => {
// tslint:disable:max-line-length
const input = stripIndent`
const input = tags.stripIndent`
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
Expand All @@ -41,59 +41,59 @@ describe('import-tslib', () => {
};
`;
// tslint:enable:max-line-length
const output = stripIndent`
const output = tags.stripIndent`
import { __decorate } from "tslib";
`;

expect(testImportTslib(input)).toBeTruthy();
expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('replaces __metadata', () => {
// tslint:disable:max-line-length
const input = stripIndent`
const input = tags.stripIndent`
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
`;
// tslint:enable:max-line-length
const output = stripIndent`
const output = tags.stripIndent`
import { __metadata } from "tslib";
`;

expect(testImportTslib(input)).toBeTruthy();
expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('replaces __param', () => {
const input = stripIndent`
const input = tags.stripIndent`
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
`;

const output = stripIndent`
const output = tags.stripIndent`
import { __param } from "tslib";
`;

expect(testImportTslib(input)).toBeTruthy();
expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});

it('replaces uses "require" instead of "import" on CJS modules', () => {
const input = stripIndent`
const input = tags.stripIndent`
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
exports.meaning = 42;
`;
const output = stripIndent`
const output = tags.stripIndent`
var __extends = /*@__PURE__*/ require("tslib").__extends;
exports.meaning = 42;
`;

expect(oneLine`${transform(input)}`).toEqual(oneLine`${output}`);
expect(tags.oneLine`${transform(input)}`).toEqual(tags.oneLine`${output}`);
});
});
Loading