@angular-devkit/schematics 12.0.0-rc.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -61
- package/collection-schema.json +2 -7
- package/package.json +3 -3
- package/src/_golden-api.d.ts +1 -1
- package/src/_golden-api.js +1 -1
- package/src/engine/engine.d.ts +2 -2
- package/src/engine/engine.js +35 -22
- package/src/engine/index.d.ts +1 -1
- package/src/engine/index.js +7 -7
- package/src/engine/interface.d.ts +2 -2
- package/src/engine/interface.js +7 -0
- package/src/engine/schematic.d.ts +1 -1
- package/src/engine/schematic.js +13 -8
- package/src/exception/exception.d.ts +1 -1
- package/src/exception/exception.js +15 -7
- package/src/formats/format-validator.d.ts +1 -1
- package/src/formats/format-validator.js +4 -6
- package/src/formats/html-selector.d.ts +1 -1
- package/src/formats/html-selector.js +19 -12
- package/src/formats/index.d.ts +1 -1
- package/src/formats/index.js +3 -6
- package/src/formats/path.d.ts +1 -1
- package/src/formats/path.js +1 -1
- package/src/index.d.ts +3 -3
- package/src/index.js +20 -14
- package/src/rules/base.d.ts +7 -0
- package/src/rules/base.js +10 -10
- package/src/rules/call.d.ts +1 -1
- package/src/rules/call.js +7 -7
- package/src/rules/move.d.ts +7 -0
- package/src/rules/move.js +5 -5
- package/src/rules/random.d.ts +1 -1
- package/src/rules/random.js +17 -5
- package/src/rules/rename.d.ts +7 -0
- package/src/rules/rename.js +4 -4
- package/src/rules/schematic.d.ts +7 -0
- package/src/rules/schematic.js +5 -5
- package/src/rules/template.d.ts +1 -1
- package/src/rules/template.js +15 -9
- package/src/rules/url.d.ts +7 -0
- package/src/rules/url.js +3 -3
- package/src/sink/dryrun.d.ts +2 -2
- package/src/sink/dryrun.js +8 -8
- package/src/sink/host.d.ts +2 -2
- package/src/sink/host.js +8 -1
- package/src/sink/sink.d.ts +2 -2
- package/src/sink/sink.js +41 -29
- package/src/tree/action.d.ts +2 -2
- package/src/tree/action.js +24 -13
- package/src/tree/delegate.d.ts +2 -2
- package/src/tree/delegate.js +46 -13
- package/src/tree/empty.d.ts +1 -1
- package/src/tree/empty.js +6 -4
- package/src/tree/entry.d.ts +2 -2
- package/src/tree/entry.js +19 -4
- package/src/tree/host-tree.d.ts +2 -2
- package/src/tree/host-tree.js +18 -20
- package/src/tree/interface.d.ts +2 -2
- package/src/tree/interface.js +12 -3
- package/src/tree/null.d.ts +2 -2
- package/src/tree/null.js +22 -12
- package/src/tree/recorder.d.ts +7 -0
- package/src/tree/recorder.js +9 -7
- package/src/tree/scoped.d.ts +2 -2
- package/src/tree/scoped.js +31 -14
- package/src/tree/static.d.ts +7 -0
- package/src/tree/static.js +3 -3
- package/src/utility/linked-list.d.ts +1 -1
- package/src/utility/linked-list.js +4 -2
- package/src/utility/update-buffer.d.ts +2 -2
- package/src/utility/update-buffer.js +11 -11
- package/src/workflow/base.d.ts +1 -1
- package/src/workflow/base.js +16 -12
- package/src/workflow/index.d.ts +1 -1
- package/src/workflow/index.js +7 -7
- package/src/workflow/interface.d.ts +1 -1
- package/src/workflow/interface.js +7 -0
- package/tasks/index.d.ts +1 -1
- package/tasks/index.js +3 -3
- package/tasks/node/index.d.ts +1 -1
- package/tasks/node/index.js +11 -4
- package/tasks/package-manager/executor.d.ts +1 -1
- package/tasks/package-manager/executor.js +9 -7
- package/tasks/package-manager/install-task.d.ts +1 -1
- package/tasks/package-manager/install-task.js +7 -0
- package/tasks/package-manager/link-task.d.ts +1 -1
- package/tasks/package-manager/link-task.js +7 -0
- package/tasks/package-manager/options.d.ts +2 -1
- package/tasks/package-manager/options.js +3 -3
- package/tasks/repo-init/executor.d.ts +7 -0
- package/tasks/repo-init/executor.js +6 -11
- package/tasks/repo-init/init-task.d.ts +1 -1
- package/tasks/repo-init/init-task.js +7 -0
- package/tasks/repo-init/options.d.ts +1 -1
- package/tasks/repo-init/options.js +3 -3
- package/tasks/run-schematic/executor.d.ts +1 -1
- package/tasks/run-schematic/executor.js +7 -0
- package/tasks/run-schematic/options.d.ts +1 -1
- package/tasks/run-schematic/options.js +3 -3
- package/tasks/run-schematic/task.d.ts +1 -1
- package/tasks/run-schematic/task.js +7 -0
- package/tasks/tslint-fix/executor.d.ts +7 -0
- package/tasks/tslint-fix/executor.js +23 -19
- package/tasks/tslint-fix/options.d.ts +1 -1
- package/tasks/tslint-fix/options.js +7 -0
- package/tasks/tslint-fix/task.d.ts +1 -1
- package/tasks/tslint-fix/task.js +7 -0
- package/tasks/tslint-fix/test/custom-rule.d.ts +1 -1
- package/tasks/tslint-fix/test/custom-rule.js +8 -1
- package/tasks/tslint-fix/test/rules/customRuleRule.js +5 -5
- package/tasks/tslint-fix/test/run-task.d.ts +1 -1
- package/tasks/tslint-fix/test/run-task.js +8 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +7 -7
- package/testing/schematic-test-runner.d.ts +1 -1
- package/testing/schematic-test-runner.js +21 -13
- package/tools/description.d.ts +1 -1
- package/tools/description.js +7 -0
- package/tools/export-ref.d.ts +7 -0
- package/tools/export-ref.js +12 -6
- package/tools/fallback-engine-host.d.ts +2 -3
- package/tools/fallback-engine-host.js +9 -12
- package/tools/file-system-engine-host-base.d.ts +2 -2
- package/tools/file-system-engine-host-base.js +23 -16
- package/tools/file-system-engine-host.d.ts +7 -0
- package/tools/file-system-engine-host.js +4 -4
- package/tools/file-system-utility.d.ts +1 -1
- package/tools/file-system-utility.js +6 -6
- package/tools/index.d.ts +1 -1
- package/tools/index.js +7 -7
- package/tools/node-module-engine-host.d.ts +1 -1
- package/tools/node-module-engine-host.js +5 -4
- package/tools/node-modules-test-engine-host.d.ts +1 -1
- package/tools/node-modules-test-engine-host.js +13 -2
- package/tools/schema-option-transform.d.ts +1 -1
- package/tools/schema-option-transform.js +4 -6
- package/tools/workflow/node-workflow.d.ts +2 -1
- package/tools/workflow/node-workflow.js +5 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnimplementedException = exports.UnsuccessfulWorkflowExecution = exports.MergeConflictException = exports.InvalidUpdateRecordException = exports.ContentHasMutatedException = exports.FileAlreadyExistException = exports.FileDoesNotExistException = exports.SchematicsException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.UnimplementedException = exports.UnsuccessfulWorkflowExecution = exports.MergeConflictException = exports.InvalidUpdateRecordException = exports.ContentHasMutatedException = exports.FileAlreadyExistException = exports.FileDoesNotExistException = exports.SchematicsException = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
// Used by schematics to throw exceptions.
|
|
13
13
|
class SchematicsException extends core_1.BaseException {
|
|
@@ -15,11 +15,15 @@ class SchematicsException extends core_1.BaseException {
|
|
|
15
15
|
exports.SchematicsException = SchematicsException;
|
|
16
16
|
// Exceptions
|
|
17
17
|
class FileDoesNotExistException extends core_1.BaseException {
|
|
18
|
-
constructor(path) {
|
|
18
|
+
constructor(path) {
|
|
19
|
+
super(`Path "${path}" does not exist.`);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
exports.FileDoesNotExistException = FileDoesNotExistException;
|
|
21
23
|
class FileAlreadyExistException extends core_1.BaseException {
|
|
22
|
-
constructor(path) {
|
|
24
|
+
constructor(path) {
|
|
25
|
+
super(`Path "${path}" already exist.`);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
exports.FileAlreadyExistException = FileAlreadyExistException;
|
|
25
29
|
class ContentHasMutatedException extends core_1.BaseException {
|
|
@@ -29,7 +33,9 @@ class ContentHasMutatedException extends core_1.BaseException {
|
|
|
29
33
|
}
|
|
30
34
|
exports.ContentHasMutatedException = ContentHasMutatedException;
|
|
31
35
|
class InvalidUpdateRecordException extends core_1.BaseException {
|
|
32
|
-
constructor() {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(`Invalid record instance.`);
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
exports.InvalidUpdateRecordException = InvalidUpdateRecordException;
|
|
35
41
|
class MergeConflictException extends core_1.BaseException {
|
|
@@ -45,6 +51,8 @@ class UnsuccessfulWorkflowExecution extends core_1.BaseException {
|
|
|
45
51
|
}
|
|
46
52
|
exports.UnsuccessfulWorkflowExecution = UnsuccessfulWorkflowExecution;
|
|
47
53
|
class UnimplementedException extends core_1.BaseException {
|
|
48
|
-
constructor() {
|
|
54
|
+
constructor() {
|
|
55
|
+
super('This function is unimplemented.');
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
exports.UnimplementedException = UnimplementedException;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatValidator = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.formatValidator = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const operators_1 = require("rxjs/operators");
|
|
13
13
|
function formatValidator(data, dataSchema, formats) {
|
|
@@ -15,8 +15,6 @@ function formatValidator(data, dataSchema, formats) {
|
|
|
15
15
|
for (const format of formats) {
|
|
16
16
|
registry.addFormat(format);
|
|
17
17
|
}
|
|
18
|
-
return registry
|
|
19
|
-
.compile(dataSchema)
|
|
20
|
-
.pipe(operators_1.mergeMap(validator => validator(data)));
|
|
18
|
+
return registry.compile(dataSchema).pipe(operators_1.mergeMap((validator) => validator(data)));
|
|
21
19
|
}
|
|
22
20
|
exports.formatValidator = formatValidator;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.htmlSelectorFormat = void 0;
|
|
4
11
|
// As per https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
@@ -6,18 +13,18 @@ exports.htmlSelectorFormat = void 0;
|
|
|
6
13
|
// * And an allowance for upper alpha characters
|
|
7
14
|
// NOTE: This should eventually be broken out into two formats: full and partial (allows for prefix)
|
|
8
15
|
const unicodeRanges = [
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[0x2070,
|
|
16
|
-
[
|
|
17
|
-
[0x3001,
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[0x10000,
|
|
16
|
+
[0xc0, 0xd6],
|
|
17
|
+
[0xd8, 0xf6],
|
|
18
|
+
[0xf8, 0x37d],
|
|
19
|
+
[0x37f, 0x1fff],
|
|
20
|
+
[0x200c, 0x200d],
|
|
21
|
+
[0x203f, 0x2040],
|
|
22
|
+
[0x2070, 0x218f],
|
|
23
|
+
[0x2c00, 0x2fef],
|
|
24
|
+
[0x3001, 0xd7ff],
|
|
25
|
+
[0xf900, 0xfdcf],
|
|
26
|
+
[0xfdf0, 0xfffd],
|
|
27
|
+
[0x10000, 0xeffff],
|
|
21
28
|
];
|
|
22
29
|
function isValidElementName(name) {
|
|
23
30
|
let regex = '^[a-zA-Z][';
|
package/src/formats/index.d.ts
CHANGED
package/src/formats/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.standardFormats = exports.pathFormat = exports.htmlSelectorFormat = void 0;
|
|
11
11
|
const html_selector_1 = require("./html-selector");
|
|
12
|
+
const path_1 = require("./path");
|
|
12
13
|
var html_selector_2 = require("./html-selector");
|
|
13
14
|
Object.defineProperty(exports, "htmlSelectorFormat", { enumerable: true, get: function () { return html_selector_2.htmlSelectorFormat; } });
|
|
14
|
-
const path_1 = require("./path");
|
|
15
15
|
var path_2 = require("./path");
|
|
16
16
|
Object.defineProperty(exports, "pathFormat", { enumerable: true, get: function () { return path_2.pathFormat; } });
|
|
17
|
-
exports.standardFormats = [
|
|
18
|
-
html_selector_1.htmlSelectorFormat,
|
|
19
|
-
path_1.pathFormat,
|
|
20
|
-
];
|
|
17
|
+
exports.standardFormats = [html_selector_1.htmlSelectorFormat, path_1.pathFormat];
|
package/src/formats/path.d.ts
CHANGED
package/src/formats/path.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
import * as formats from './formats/index';
|
|
8
9
|
import { FilePredicate, MergeStrategy, Tree as TreeInterface } from './tree/interface';
|
|
10
|
+
import * as workflow from './workflow/index';
|
|
9
11
|
export { SchematicsException } from './exception/exception';
|
|
10
12
|
export * from './tree/action';
|
|
11
13
|
export * from './engine/index';
|
|
@@ -26,9 +28,7 @@ export * from './engine/schematic';
|
|
|
26
28
|
export * from './sink/dryrun';
|
|
27
29
|
export * from './sink/host';
|
|
28
30
|
export * from './sink/sink';
|
|
29
|
-
import * as formats from './formats/index';
|
|
30
31
|
export { formats };
|
|
31
|
-
import * as workflow from './workflow/index';
|
|
32
32
|
export { workflow };
|
|
33
33
|
export interface TreeConstructor {
|
|
34
34
|
empty(): TreeInterface;
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -11,15 +18,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
20
|
exports.Tree = exports.workflow = exports.formats = exports.SchematicsException = void 0;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
17
|
-
*
|
|
18
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
19
|
-
* found in the LICENSE file at https://angular.io/license
|
|
20
|
-
*/
|
|
21
|
+
const formats = require("./formats/index");
|
|
22
|
+
exports.formats = formats;
|
|
21
23
|
const interface_1 = require("./tree/interface");
|
|
22
24
|
const static_1 = require("./tree/static");
|
|
25
|
+
const workflow = require("./workflow/index");
|
|
26
|
+
exports.workflow = workflow;
|
|
23
27
|
var exception_1 = require("./exception/exception");
|
|
24
28
|
Object.defineProperty(exports, "SchematicsException", { enumerable: true, get: function () { return exception_1.SchematicsException; } });
|
|
25
29
|
__exportStar(require("./tree/action"), exports);
|
|
@@ -40,18 +44,20 @@ __exportStar(require("./engine/schematic"), exports);
|
|
|
40
44
|
__exportStar(require("./sink/dryrun"), exports);
|
|
41
45
|
__exportStar(require("./sink/host"), exports);
|
|
42
46
|
__exportStar(require("./sink/sink"), exports);
|
|
43
|
-
const formats = require("./formats/index");
|
|
44
|
-
exports.formats = formats;
|
|
45
|
-
const workflow = require("./workflow/index");
|
|
46
|
-
exports.workflow = workflow;
|
|
47
47
|
exports.Tree = {
|
|
48
|
-
empty() {
|
|
49
|
-
|
|
48
|
+
empty() {
|
|
49
|
+
return static_1.empty();
|
|
50
|
+
},
|
|
51
|
+
branch(tree) {
|
|
52
|
+
return static_1.branch(tree);
|
|
53
|
+
},
|
|
50
54
|
merge(tree, other, strategy = interface_1.MergeStrategy.Default) {
|
|
51
55
|
return static_1.merge(tree, other, strategy);
|
|
52
56
|
},
|
|
53
57
|
partition(tree, predicate) {
|
|
54
58
|
return static_1.partition(tree, predicate);
|
|
55
59
|
},
|
|
56
|
-
optimize(tree) {
|
|
60
|
+
optimize(tree) {
|
|
61
|
+
return tree;
|
|
62
|
+
},
|
|
57
63
|
};
|
package/src/rules/base.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
import { FileOperator, Rule, Source } from '../engine/interface';
|
|
2
9
|
import { FilePredicate, MergeStrategy, Tree } from '../tree/interface';
|
|
3
10
|
/**
|
package/src/rules/base.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyToSubtree = exports.composeFileOperators = exports.forEach = exports.partitionApplyMerge = exports.when = exports.branchAndMerge = exports.asSource = exports.filter = exports.noop = exports.mergeWith = exports.apply = exports.chain = exports.empty = exports.source = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.applyToSubtree = exports.composeFileOperators = exports.forEach = exports.partitionApplyMerge = exports.when = exports.branchAndMerge = exports.asSource = exports.filter = exports.noop = exports.mergeWith = exports.apply = exports.chain = exports.empty = exports.source = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const operators_1 = require("rxjs/operators");
|
|
13
13
|
const exception_1 = require("../exception/exception");
|
|
@@ -43,7 +43,7 @@ exports.chain = chain;
|
|
|
43
43
|
* Apply multiple rules to a source, and returns the source transformed.
|
|
44
44
|
*/
|
|
45
45
|
function apply(source, rules) {
|
|
46
|
-
return context => call_1.callRule(chain(rules), call_1.callSource(source, context), context);
|
|
46
|
+
return (context) => call_1.callRule(chain(rules), call_1.callSource(source, context), context);
|
|
47
47
|
}
|
|
48
48
|
exports.apply = apply;
|
|
49
49
|
/**
|
|
@@ -51,7 +51,7 @@ exports.apply = apply;
|
|
|
51
51
|
*/
|
|
52
52
|
function mergeWith(source, strategy = interface_1.MergeStrategy.Default) {
|
|
53
53
|
return (tree, context) => {
|
|
54
|
-
return call_1.callSource(source, context).pipe(operators_1.map(sourceTree => tree.merge(sourceTree, strategy || context.strategy)), operators_1.mapTo(tree));
|
|
54
|
+
return call_1.callSource(source, context).pipe(operators_1.map((sourceTree) => tree.merge(sourceTree, strategy || context.strategy)), operators_1.mapTo(tree));
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
exports.mergeWith = mergeWith;
|
|
@@ -60,23 +60,23 @@ function noop() {
|
|
|
60
60
|
}
|
|
61
61
|
exports.noop = noop;
|
|
62
62
|
function filter(predicate) {
|
|
63
|
-
return (
|
|
63
|
+
return (tree) => {
|
|
64
64
|
if (host_tree_1.HostTree.isHostTree(tree)) {
|
|
65
65
|
return new host_tree_1.FilterHostTree(tree, predicate);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
68
|
throw new exception_1.SchematicsException('Tree type is not supported.');
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
}
|
|
72
72
|
exports.filter = filter;
|
|
73
73
|
function asSource(rule) {
|
|
74
|
-
return context => call_1.callRule(rule, static_1.empty(), context);
|
|
74
|
+
return (context) => call_1.callRule(rule, static_1.empty(), context);
|
|
75
75
|
}
|
|
76
76
|
exports.asSource = asSource;
|
|
77
77
|
function branchAndMerge(rule, strategy = interface_1.MergeStrategy.Default) {
|
|
78
78
|
return (tree, context) => {
|
|
79
|
-
return call_1.callRule(rule, tree.branch(), context).pipe(operators_1.map(branch => tree.merge(branch, strategy || context.strategy)), operators_1.mapTo(tree));
|
|
79
|
+
return call_1.callRule(rule, tree.branch(), context).pipe(operators_1.map((branch) => tree.merge(branch, strategy || context.strategy)), operators_1.mapTo(tree));
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
exports.branchAndMerge = branchAndMerge;
|
|
@@ -142,7 +142,7 @@ exports.composeFileOperators = composeFileOperators;
|
|
|
142
142
|
function applyToSubtree(path, rules) {
|
|
143
143
|
return (tree, context) => {
|
|
144
144
|
const scoped = new scoped_1.ScopedTree(tree, path);
|
|
145
|
-
return call_1.callRule(chain(rules), scoped, context).pipe(operators_1.map(result => {
|
|
145
|
+
return call_1.callRule(chain(rules), scoped, context).pipe(operators_1.map((result) => {
|
|
146
146
|
if (result === scoped) {
|
|
147
147
|
return tree;
|
|
148
148
|
}
|
package/src/rules/call.d.ts
CHANGED
package/src/rules/call.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.callRule = exports.callSource = exports.InvalidSourceResultException = exports.InvalidRuleResultException = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.callRule = exports.callSource = exports.InvalidSourceResultException = exports.InvalidRuleResultException = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
13
|
const operators_1 = require("rxjs/operators");
|
|
@@ -56,7 +56,7 @@ function callSource(source, context) {
|
|
|
56
56
|
const result = source(context);
|
|
57
57
|
if (rxjs_1.isObservable(result)) {
|
|
58
58
|
// Only return the last Tree, and make sure it's a Tree.
|
|
59
|
-
return result.pipe(operators_1.defaultIfEmpty(), operators_1.last(), operators_1.tap(inner => {
|
|
59
|
+
return result.pipe(operators_1.defaultIfEmpty(), operators_1.last(), operators_1.tap((inner) => {
|
|
60
60
|
if (!inner || !(interface_1.TreeSymbol in inner)) {
|
|
61
61
|
throw new InvalidSourceResultException(inner);
|
|
62
62
|
}
|
|
@@ -71,7 +71,7 @@ function callSource(source, context) {
|
|
|
71
71
|
}
|
|
72
72
|
exports.callSource = callSource;
|
|
73
73
|
function callRule(rule, input, context) {
|
|
74
|
-
return (rxjs_1.isObservable(input) ? input : rxjs_1.of(input)).pipe(operators_1.mergeMap(inputTree => {
|
|
74
|
+
return (rxjs_1.isObservable(input) ? input : rxjs_1.of(input)).pipe(operators_1.mergeMap((inputTree) => {
|
|
75
75
|
const result = rule(inputTree, context);
|
|
76
76
|
if (!result) {
|
|
77
77
|
return rxjs_1.of(inputTree);
|
|
@@ -82,14 +82,14 @@ function callRule(rule, input, context) {
|
|
|
82
82
|
}
|
|
83
83
|
else if (rxjs_1.isObservable(result)) {
|
|
84
84
|
// Only return the last Tree, and make sure it's a Tree.
|
|
85
|
-
return result.pipe(operators_1.defaultIfEmpty(), operators_1.last(), operators_1.tap(inner => {
|
|
85
|
+
return result.pipe(operators_1.defaultIfEmpty(), operators_1.last(), operators_1.tap((inner) => {
|
|
86
86
|
if (!inner || !(interface_1.TreeSymbol in inner)) {
|
|
87
87
|
throw new InvalidRuleResultException(inner);
|
|
88
88
|
}
|
|
89
89
|
}));
|
|
90
90
|
}
|
|
91
91
|
else if (core_1.isPromise(result)) {
|
|
92
|
-
return rxjs_1.from(result).pipe(operators_1.mergeMap(inner => {
|
|
92
|
+
return rxjs_1.from(result).pipe(operators_1.mergeMap((inner) => {
|
|
93
93
|
if (typeof inner === 'function') {
|
|
94
94
|
// This is considered a Rule, chain the rule and return its output.
|
|
95
95
|
return callRule(inner, inputTree, context);
|
package/src/rules/move.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
import { Rule } from '../engine/interface';
|
|
2
9
|
export declare function move(from: string, to?: string): Rule;
|
package/src/rules/move.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.move = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.move = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const base_1 = require("./base");
|
|
13
13
|
function move(from, to) {
|
|
@@ -20,14 +20,14 @@ function move(from, to) {
|
|
|
20
20
|
if (fromPath === toPath) {
|
|
21
21
|
return base_1.noop;
|
|
22
22
|
}
|
|
23
|
-
return tree => {
|
|
23
|
+
return (tree) => {
|
|
24
24
|
if (tree.exists(fromPath)) {
|
|
25
25
|
// fromPath is a file
|
|
26
26
|
tree.rename(fromPath, toPath);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
// fromPath is a directory
|
|
30
|
-
tree.getDir(fromPath).visit(path => {
|
|
30
|
+
tree.getDir(fromPath).visit((path) => {
|
|
31
31
|
tree.rename(path, core_1.join(toPath, path.substr(fromPath.length)));
|
|
32
32
|
});
|
|
33
33
|
}
|
package/src/rules/random.d.ts
CHANGED
package/src/rules/random.js
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
const host_tree_1 = require("../tree/host-tree");
|
|
4
11
|
function generateStringOfLength(l) {
|
|
5
|
-
return new Array(l)
|
|
12
|
+
return new Array(l)
|
|
13
|
+
.fill(0)
|
|
14
|
+
.map((_x) => {
|
|
6
15
|
return 'abcdefghijklmnopqrstuvwxyz'[Math.floor(Math.random() * 26)];
|
|
7
|
-
})
|
|
16
|
+
})
|
|
17
|
+
.join('');
|
|
8
18
|
}
|
|
9
19
|
function random(from, to) {
|
|
10
20
|
return Math.floor(Math.random() * (to - from)) + from;
|
|
11
21
|
}
|
|
12
22
|
function default_1(options) {
|
|
13
23
|
return () => {
|
|
14
|
-
const root =
|
|
24
|
+
const root = 'root' in options ? options.root : '/';
|
|
15
25
|
const map = new host_tree_1.HostTree();
|
|
16
|
-
const nbFiles =
|
|
17
|
-
?
|
|
26
|
+
const nbFiles = 'multiFiles' in options
|
|
27
|
+
? typeof options.multiFiles == 'number'
|
|
28
|
+
? options.multiFiles
|
|
29
|
+
: random(2, 12)
|
|
18
30
|
: 1;
|
|
19
31
|
for (let i = 0; i < nbFiles; i++) {
|
|
20
32
|
const path = 'a/b/c/d/e/f'.slice(Math.random() * 10);
|
package/src/rules/rename.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
import { Rule } from '../engine/interface';
|
|
2
9
|
import { FilePredicate } from '../tree/interface';
|
|
3
10
|
export declare function rename(match: FilePredicate<boolean>, to: FilePredicate<string>): Rule;
|
package/src/rules/rename.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rename = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.rename = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const base_1 = require("./base");
|
|
13
13
|
function rename(match, to) {
|
|
14
|
-
return base_1.forEach(entry => {
|
|
14
|
+
return base_1.forEach((entry) => {
|
|
15
15
|
if (match(entry.path, entry)) {
|
|
16
16
|
return {
|
|
17
17
|
content: entry.content,
|
package/src/rules/schematic.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
import { ExecutionOptions, Rule } from '../engine/interface';
|
|
2
9
|
/**
|
|
3
10
|
* Run a schematic from a separate collection.
|
package/src/rules/schematic.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schematic = exports.externalSchematic = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.schematic = exports.externalSchematic = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const operators_1 = require("rxjs/operators");
|
|
13
13
|
const interface_1 = require("../tree/interface");
|
|
@@ -23,7 +23,7 @@ function externalSchematic(collectionName, schematicName, options, executionOpti
|
|
|
23
23
|
return (input, context) => {
|
|
24
24
|
const collection = context.engine.createCollection(collectionName, context.schematic.collection);
|
|
25
25
|
const schematic = collection.createSchematic(schematicName);
|
|
26
|
-
return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map(x => {
|
|
26
|
+
return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map((x) => {
|
|
27
27
|
input.merge(x, interface_1.MergeStrategy.AllowOverwriteConflict);
|
|
28
28
|
return input;
|
|
29
29
|
}));
|
|
@@ -40,7 +40,7 @@ function schematic(schematicName, options, executionOptions) {
|
|
|
40
40
|
return (input, context) => {
|
|
41
41
|
const collection = context.schematic.collection;
|
|
42
42
|
const schematic = collection.createSchematic(schematicName, true);
|
|
43
|
-
return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map(x => {
|
|
43
|
+
return schematic.call(options, rxjs_1.of(static_1.branch(input)), context, executionOptions).pipe(operators_1.last(), operators_1.map((x) => {
|
|
44
44
|
// We allow overwrite conflict here because they're the only merge conflict we particularly
|
|
45
45
|
// don't want to deal with; the input tree might have an OVERWRITE which the sub
|
|
46
46
|
input.merge(x, interface_1.MergeStrategy.AllowOverwriteConflict);
|
package/src/rules/template.d.ts
CHANGED