@ngneat/helipopper 4.2.0 → 5.0.2
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 +2 -1
- package/esm2020/lib/defaults.mjs +25 -0
- package/esm2020/lib/tippy.directive.mjs +347 -0
- package/esm2020/lib/tippy.module.mjs +28 -0
- package/esm2020/lib/tippy.service.mjs +73 -0
- package/esm2020/lib/tippy.types.mjs +12 -0
- package/{esm2015/lib/utils.js → esm2020/lib/utils.mjs} +3 -2
- package/{esm2015/ngneat-helipopper.js → esm2020/ngneat-helipopper.mjs} +1 -1
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/fesm2015/{ngneat-helipopper.js → ngneat-helipopper.mjs} +116 -66
- package/fesm2015/ngneat-helipopper.mjs.map +1 -0
- package/fesm2020/ngneat-helipopper.mjs +564 -0
- package/fesm2020/ngneat-helipopper.mjs.map +1 -0
- package/lib/tippy.directive.d.ts +3 -0
- package/lib/tippy.module.d.ts +5 -0
- package/lib/tippy.service.d.ts +3 -0
- package/lib/tippy.types.d.ts +5 -2
- package/ngneat-helipopper.d.ts +1 -1
- package/package.json +23 -11
- package/bundles/ngneat-helipopper.umd.js +0 -898
- package/bundles/ngneat-helipopper.umd.js.map +0 -1
- package/esm2015/lib/defaults.js +0 -19
- package/esm2015/lib/tippy.directive.js +0 -308
- package/esm2015/lib/tippy.module.js +0 -23
- package/esm2015/lib/tippy.service.js +0 -61
- package/esm2015/lib/tippy.types.js +0 -12
- package/fesm2015/ngneat-helipopper.js.map +0 -1
- package/ngneat-helipopper.metadata.json +0 -1
- package/schematics/collection.json +0 -12
- package/schematics/ng-add/index.js +0 -73
- package/schematics/ng-add/index.js.map +0 -1
- package/schematics/ng-add/index.ts +0 -79
- package/schematics/ng-add/schema.js +0 -3
- package/schematics/ng-add/schema.js.map +0 -1
- package/schematics/ng-add/schema.json +0 -18
- package/schematics/ng-add/schema.ts +0 -10
- package/schematics/schematics.consts.js +0 -5
- package/schematics/schematics.consts.js.map +0 -1
- package/schematics/schematics.consts.ts +0 -1
- package/schematics/utils/ast-utils.js +0 -500
- package/schematics/utils/ast-utils.js.map +0 -1
- package/schematics/utils/ast-utils.ts +0 -596
- package/schematics/utils/change.js +0 -127
- package/schematics/utils/change.js.map +0 -1
- package/schematics/utils/change.ts +0 -162
- package/schematics/utils/find-module.js +0 -113
- package/schematics/utils/find-module.js.map +0 -1
- package/schematics/utils/find-module.ts +0 -125
- package/schematics/utils/package.js +0 -22
- package/schematics/utils/package.js.map +0 -1
- package/schematics/utils/package.ts +0 -22
- package/schematics/utils/projects.js +0 -31
- package/schematics/utils/projects.js.map +0 -1
- package/schematics/utils/projects.ts +0 -31
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commitChanges = exports.createChangeRecorder = exports.createReplaceChange = exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* An operation that does nothing.
|
|
6
|
-
*/
|
|
7
|
-
class NoopChange {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.description = 'No operation.';
|
|
10
|
-
this.order = Infinity;
|
|
11
|
-
this.path = null;
|
|
12
|
-
}
|
|
13
|
-
apply() {
|
|
14
|
-
return Promise.resolve();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.NoopChange = NoopChange;
|
|
18
|
-
/**
|
|
19
|
-
* Will add text to the source code.
|
|
20
|
-
*/
|
|
21
|
-
class InsertChange {
|
|
22
|
-
constructor(path, pos, toAdd) {
|
|
23
|
-
this.path = path;
|
|
24
|
-
this.pos = pos;
|
|
25
|
-
this.toAdd = toAdd;
|
|
26
|
-
if (pos < 0) {
|
|
27
|
-
throw new Error('Negative positions are invalid');
|
|
28
|
-
}
|
|
29
|
-
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
30
|
-
this.order = pos;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* This method does not insert spaces if there is none in the original string.
|
|
34
|
-
*/
|
|
35
|
-
apply(host) {
|
|
36
|
-
return host.read(this.path).then(content => {
|
|
37
|
-
const prefix = content.substring(0, this.pos);
|
|
38
|
-
const suffix = content.substring(this.pos);
|
|
39
|
-
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.InsertChange = InsertChange;
|
|
44
|
-
/**
|
|
45
|
-
* Will remove text from the source code.
|
|
46
|
-
*/
|
|
47
|
-
class RemoveChange {
|
|
48
|
-
constructor(path, pos, end) {
|
|
49
|
-
this.path = path;
|
|
50
|
-
this.pos = pos;
|
|
51
|
-
this.end = end;
|
|
52
|
-
if (pos < 0 || end < 0) {
|
|
53
|
-
throw new Error('Negative positions are invalid');
|
|
54
|
-
}
|
|
55
|
-
this.description = `Removed text in position ${pos} to ${end} of ${path}`;
|
|
56
|
-
this.order = pos;
|
|
57
|
-
}
|
|
58
|
-
apply(host) {
|
|
59
|
-
return host.read(this.path).then(content => {
|
|
60
|
-
const prefix = content.substring(0, this.pos);
|
|
61
|
-
const suffix = content.substring(this.end);
|
|
62
|
-
// TODO: throw error if toRemove doesn't match removed string.
|
|
63
|
-
return host.write(this.path, `${prefix}${suffix}`);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.RemoveChange = RemoveChange;
|
|
68
|
-
/**
|
|
69
|
-
* Will replace text from the source code.
|
|
70
|
-
*/
|
|
71
|
-
class ReplaceChange {
|
|
72
|
-
constructor(path, pos, oldText, newText) {
|
|
73
|
-
this.path = path;
|
|
74
|
-
this.pos = pos;
|
|
75
|
-
this.oldText = oldText;
|
|
76
|
-
this.newText = newText;
|
|
77
|
-
if (pos < 0) {
|
|
78
|
-
throw new Error('Negative positions are invalid');
|
|
79
|
-
}
|
|
80
|
-
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
81
|
-
this.order = pos;
|
|
82
|
-
}
|
|
83
|
-
apply(host) {
|
|
84
|
-
return host.read(this.path).then(content => {
|
|
85
|
-
const prefix = content.substring(0, this.pos);
|
|
86
|
-
const suffix = content.substring(this.pos + this.oldText.length);
|
|
87
|
-
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
88
|
-
if (text !== this.oldText) {
|
|
89
|
-
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
90
|
-
}
|
|
91
|
-
// TODO: throw error if oldText doesn't match removed string.
|
|
92
|
-
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.ReplaceChange = ReplaceChange;
|
|
97
|
-
function createReplaceChange(sourceFile, node, oldText, newText) {
|
|
98
|
-
return new ReplaceChange(sourceFile.fileName, node.getStart(sourceFile), oldText, newText);
|
|
99
|
-
}
|
|
100
|
-
exports.createReplaceChange = createReplaceChange;
|
|
101
|
-
function createChangeRecorder(tree, path, changes) {
|
|
102
|
-
const recorder = tree.beginUpdate(path);
|
|
103
|
-
for (const change of changes) {
|
|
104
|
-
if (change instanceof InsertChange) {
|
|
105
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
106
|
-
}
|
|
107
|
-
else if (change instanceof RemoveChange) {
|
|
108
|
-
recorder.remove(change.pos, change.end - change.pos);
|
|
109
|
-
}
|
|
110
|
-
else if (change instanceof ReplaceChange) {
|
|
111
|
-
recorder.remove(change.pos, change.oldText.length);
|
|
112
|
-
recorder.insertLeft(change.pos, change.newText);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return recorder;
|
|
116
|
-
}
|
|
117
|
-
exports.createChangeRecorder = createChangeRecorder;
|
|
118
|
-
function commitChanges(tree, path, changes) {
|
|
119
|
-
if (changes.length === 0) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const recorder = createChangeRecorder(tree, path, changes);
|
|
123
|
-
tree.commitUpdate(recorder);
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
exports.commitChanges = commitChanges;
|
|
127
|
-
//# sourceMappingURL=change.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":";;;AAgCA;;GAEG;AACH,MAAa,UAAU;IAAvB;QACE,gBAAW,GAAG,eAAe,CAAC;QAC9B,UAAK,GAAG,QAAQ,CAAC;QACjB,SAAI,GAAG,IAAI,CAAC;IAId,CAAC;IAHC,KAAK;QACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAPD,gCAOC;AAED;;GAEG;AACH,MAAa,YAAY;IAIvB,YAAmB,IAAY,EAAS,GAAW,EAAS,KAAa;QAAtD,SAAI,GAAJ,IAAI,CAAQ;QAAS,QAAG,GAAH,GAAG,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QACvE,IAAI,GAAG,GAAG,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,WAAW,GAAG,YAAY,KAAK,kBAAkB,GAAG,OAAO,IAAI,EAAE,CAAC;QACvE,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAU;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YACzC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE3C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GA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|
|
5
|
-
/* istanbul ignore file */
|
|
6
|
-
/**
|
|
7
|
-
* @license
|
|
8
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
9
|
-
*
|
|
10
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
11
|
-
* found in the LICENSE file at https://angular.io/license
|
|
12
|
-
*/
|
|
13
|
-
export interface Host {
|
|
14
|
-
write(path: string, content: string): Promise<void>;
|
|
15
|
-
read(path: string): Promise<string>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Change {
|
|
19
|
-
apply(host: Host): Promise<void>;
|
|
20
|
-
|
|
21
|
-
// The file this change should be applied to. Some changes might not apply to
|
|
22
|
-
// a file (maybe the config).
|
|
23
|
-
readonly path: string | null;
|
|
24
|
-
|
|
25
|
-
// The order this change should be applied. Normally the position inside the file.
|
|
26
|
-
// Changes are applied from the bottom of a file to the top.
|
|
27
|
-
readonly order: number;
|
|
28
|
-
|
|
29
|
-
// The description of this change. This will be outputted in a dry or verbose run.
|
|
30
|
-
readonly description: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* An operation that does nothing.
|
|
35
|
-
*/
|
|
36
|
-
export class NoopChange implements Change {
|
|
37
|
-
description = 'No operation.';
|
|
38
|
-
order = Infinity;
|
|
39
|
-
path = null;
|
|
40
|
-
apply() {
|
|
41
|
-
return Promise.resolve();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Will add text to the source code.
|
|
47
|
-
*/
|
|
48
|
-
export class InsertChange implements Change {
|
|
49
|
-
order: number;
|
|
50
|
-
description: string;
|
|
51
|
-
|
|
52
|
-
constructor(public path: string, public pos: number, public toAdd: string) {
|
|
53
|
-
if (pos < 0) {
|
|
54
|
-
throw new Error('Negative positions are invalid');
|
|
55
|
-
}
|
|
56
|
-
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
57
|
-
this.order = pos;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* This method does not insert spaces if there is none in the original string.
|
|
62
|
-
*/
|
|
63
|
-
apply(host: Host) {
|
|
64
|
-
return host.read(this.path).then(content => {
|
|
65
|
-
const prefix = content.substring(0, this.pos);
|
|
66
|
-
const suffix = content.substring(this.pos);
|
|
67
|
-
|
|
68
|
-
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Will remove text from the source code.
|
|
75
|
-
*/
|
|
76
|
-
export class RemoveChange implements Change {
|
|
77
|
-
order: number;
|
|
78
|
-
description: string;
|
|
79
|
-
|
|
80
|
-
constructor(public path: string, public pos: number, public end: number) {
|
|
81
|
-
if (pos < 0 || end < 0) {
|
|
82
|
-
throw new Error('Negative positions are invalid');
|
|
83
|
-
}
|
|
84
|
-
this.description = `Removed text in position ${pos} to ${end} of ${path}`;
|
|
85
|
-
this.order = pos;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
apply(host: Host): Promise<void> {
|
|
89
|
-
return host.read(this.path).then(content => {
|
|
90
|
-
const prefix = content.substring(0, this.pos);
|
|
91
|
-
const suffix = content.substring(this.end);
|
|
92
|
-
|
|
93
|
-
// TODO: throw error if toRemove doesn't match removed string.
|
|
94
|
-
return host.write(this.path, `${prefix}${suffix}`);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Will replace text from the source code.
|
|
101
|
-
*/
|
|
102
|
-
export class ReplaceChange implements Change {
|
|
103
|
-
order: number;
|
|
104
|
-
description: string;
|
|
105
|
-
|
|
106
|
-
constructor(public path: string, public pos: number, public oldText: string, public newText: string) {
|
|
107
|
-
if (pos < 0) {
|
|
108
|
-
throw new Error('Negative positions are invalid');
|
|
109
|
-
}
|
|
110
|
-
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
111
|
-
this.order = pos;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
apply(host: Host): Promise<void> {
|
|
115
|
-
return host.read(this.path).then(content => {
|
|
116
|
-
const prefix = content.substring(0, this.pos);
|
|
117
|
-
const suffix = content.substring(this.pos + this.oldText.length);
|
|
118
|
-
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
119
|
-
|
|
120
|
-
if (text !== this.oldText) {
|
|
121
|
-
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// TODO: throw error if oldText doesn't match removed string.
|
|
125
|
-
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function createReplaceChange(
|
|
131
|
-
sourceFile: ts.SourceFile,
|
|
132
|
-
node: ts.Node,
|
|
133
|
-
oldText: string,
|
|
134
|
-
newText: string
|
|
135
|
-
): ReplaceChange {
|
|
136
|
-
return new ReplaceChange(sourceFile.fileName, node.getStart(sourceFile), oldText, newText);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function createChangeRecorder(tree: Tree, path: string, changes: Change[]): UpdateRecorder {
|
|
140
|
-
const recorder = tree.beginUpdate(path);
|
|
141
|
-
for (const change of changes) {
|
|
142
|
-
if (change instanceof InsertChange) {
|
|
143
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
144
|
-
} else if (change instanceof RemoveChange) {
|
|
145
|
-
recorder.remove(change.pos, change.end - change.pos);
|
|
146
|
-
} else if (change instanceof ReplaceChange) {
|
|
147
|
-
recorder.remove(change.pos, change.oldText.length);
|
|
148
|
-
recorder.insertLeft(change.pos, change.newText);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return recorder;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function commitChanges(tree: Tree, path: string, changes: Change[]) {
|
|
155
|
-
if (changes.length === 0) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const recorder = createChangeRecorder(tree, path, changes);
|
|
160
|
-
tree.commitUpdate(recorder);
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findModule = exports.findModuleFromOptions = exports.findRootModule = exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
-
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*/
|
|
11
|
-
const core_1 = require("@angular-devkit/core");
|
|
12
|
-
exports.MODULE_EXT = '.module.ts';
|
|
13
|
-
exports.ROUTING_MODULE_EXT = '-routing.module.ts';
|
|
14
|
-
/**
|
|
15
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
16
|
-
*/
|
|
17
|
-
function findRootModule(host, module, rootPath = '', skipImport = false) {
|
|
18
|
-
if (skipImport || !module) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const modulePath = core_1.normalize(`${rootPath}/${module}`);
|
|
22
|
-
if (host.exists(modulePath)) {
|
|
23
|
-
return modulePath;
|
|
24
|
-
}
|
|
25
|
-
else if (host.exists(modulePath + '.ts')) {
|
|
26
|
-
return core_1.normalize(modulePath + '.ts');
|
|
27
|
-
}
|
|
28
|
-
else if (host.exists(modulePath + exports.MODULE_EXT)) {
|
|
29
|
-
return core_1.normalize(modulePath + exports.MODULE_EXT);
|
|
30
|
-
}
|
|
31
|
-
else if (host.exists(`${modulePath}/${module}${exports.MODULE_EXT}`)) {
|
|
32
|
-
return core_1.normalize(`${modulePath}/${module}${exports.MODULE_EXT}`);
|
|
33
|
-
}
|
|
34
|
-
else if (host.exists(`${modulePath}/${module}.ts`)) {
|
|
35
|
-
return core_1.normalize(`${modulePath}/${module}.ts`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
throw new Error(`Specified module path ${modulePath} does not exist`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.findRootModule = findRootModule;
|
|
42
|
-
/**
|
|
43
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
44
|
-
*/
|
|
45
|
-
function findModuleFromOptions(host, options, projectPath) {
|
|
46
|
-
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
const moduleExt = options.moduleExt || exports.MODULE_EXT;
|
|
50
|
-
const routingModuleExt = options.routingModuleExt || exports.ROUTING_MODULE_EXT;
|
|
51
|
-
if (!options.module) {
|
|
52
|
-
const pathToCheck = (projectPath || '') + '/' + options.name;
|
|
53
|
-
const module = findModule(host, pathToCheck, moduleExt, routingModuleExt);
|
|
54
|
-
return module ? core_1.normalize(module) : null;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const modulePath = core_1.normalize(`/${projectPath}/${options.module}`);
|
|
58
|
-
const componentPath = core_1.normalize(`/${projectPath}/${options.name}`);
|
|
59
|
-
const moduleBaseName = core_1.normalize(modulePath)
|
|
60
|
-
.split('/')
|
|
61
|
-
.pop();
|
|
62
|
-
const candidateSet = new Set([core_1.normalize(projectPath || '/')]);
|
|
63
|
-
for (let dir = modulePath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
|
|
64
|
-
candidateSet.add(dir);
|
|
65
|
-
}
|
|
66
|
-
for (let dir = componentPath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
|
|
67
|
-
candidateSet.add(dir);
|
|
68
|
-
}
|
|
69
|
-
const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
|
|
70
|
-
for (const c of candidatesDirs) {
|
|
71
|
-
const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map(x => core_1.join(c, x));
|
|
72
|
-
for (const sc of candidateFiles) {
|
|
73
|
-
if (host.exists(sc)) {
|
|
74
|
-
return core_1.normalize(sc);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
throw new Error(`Specified module '${options.module}' does not exist.\n` +
|
|
80
|
-
`Looked in the following directories:\n ${candidatesDirs.join('\n ')}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.findModuleFromOptions = findModuleFromOptions;
|
|
84
|
-
/**
|
|
85
|
-
* Function to find the "closest" module to a generated file's path.
|
|
86
|
-
*/
|
|
87
|
-
function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingModuleExt = exports.ROUTING_MODULE_EXT) {
|
|
88
|
-
let dir = host.getDir('/' + generateDir);
|
|
89
|
-
let foundRoutingModule = false;
|
|
90
|
-
while (dir) {
|
|
91
|
-
const allMatches = dir.subfiles.filter(p => p.endsWith(moduleExt));
|
|
92
|
-
const filteredMatches = allMatches.filter(p => !p.endsWith(routingModuleExt));
|
|
93
|
-
foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
|
|
94
|
-
if (filteredMatches.length == 1) {
|
|
95
|
-
return core_1.join(dir.path, filteredMatches[0]);
|
|
96
|
-
}
|
|
97
|
-
else if (filteredMatches.length > 1) {
|
|
98
|
-
return null;
|
|
99
|
-
throw new Error('More than one module matches. Use skip-import option to skip importing ' +
|
|
100
|
-
'the component into the closest module.');
|
|
101
|
-
}
|
|
102
|
-
dir = dir.parent;
|
|
103
|
-
}
|
|
104
|
-
const errorMsg = foundRoutingModule
|
|
105
|
-
? 'Could not find a non Routing NgModule.' +
|
|
106
|
-
`\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
|
|
107
|
-
'\nUse the skip-import option to skip importing in NgModule.'
|
|
108
|
-
: 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
|
|
109
|
-
return null;
|
|
110
|
-
throw new Error(errorMsg);
|
|
111
|
-
}
|
|
112
|
-
exports.findModule = findModule;
|
|
113
|
-
//# sourceMappingURL=find-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-module.js","sourceRoot":"","sources":["find-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,+CAAsF;AAGzE,QAAA,UAAU,GAAG,YAAY,CAAC;AAC1B,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAU,EAAE,MAAc,EAAE,QAAQ,GAAG,EAAE,EAAE,UAAU,GAAG,KAAK;IAC1F,IAAI,UAAU,IAAI,CAAC,MAAM,EAAE;QACzB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,UAAU,GAAG,gBAAS,CAAC,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC;IACtD,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QAC3B,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE;QAC1C,OAAO,gBAAS,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC;KACtC;SAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,kBAAU,CAAC,EAAE;QAC/C,OAAO,gBAAS,CAAC,UAAU,GAAG,kBAAU,CAAC,CAAC;KAC3C;SAAM,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,IAAI,MAAM,GAAG,kBAAU,EAAE,CAAC,EAAE;QAC9D,OAAO,gBAAS,CAAC,GAAG,UAAU,IAAI,MAAM,GAAG,kBAAU,EAAE,CAAC,CAAC;KAC1D;SAAM,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,IAAI,MAAM,KAAK,CAAC,EAAE;QACpD,OAAO,gBAAS,CAAC,GAAG,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,KAAK,CAAC;IAE/B,OAAO,GAAG,EAAE;QACV,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACnE,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAE9E,kBAAkB,GAAG,kBAAkB,IAAI,UAAU,CAAC,MAAM,KAAK,eAAe,CAAC,MAAM,CAAC;QAExF,IAAI,eAAe,CAAC,MAAM,IAAI,CAAC,EAAE;YAC/B,OAAO,WAAI,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C;aAAM,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;YACrC,OAAO,IAAI,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,yEAAyE;gBACvE,wCAAwC,CAC3C,CAAC;SACH;QAED,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;KAClB;IAED,MAAM,QAAQ,GAAG,kBAAkB;QACjC,CAAC,CAAC,wCAAwC;YACxC,0BAA0B,gBAAgB,sCAAsC;YAChF,6DAA6D;QAC/D,CAAC,CAAC,uFAAuF,CAAC;IAC5F,OAAO,IAAI,CAAC;IACZ,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC;AAnCD,gCAmCC"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. 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
|
-
*/
|
|
8
|
-
import { Path, join, normalize, dirname, NormalizedRoot } from '@angular-devkit/core';
|
|
9
|
-
import { DirEntry, Tree } from '@angular-devkit/schematics';
|
|
10
|
-
|
|
11
|
-
export const MODULE_EXT = '.module.ts';
|
|
12
|
-
export const ROUTING_MODULE_EXT = '-routing.module.ts';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
16
|
-
*/
|
|
17
|
-
export function findRootModule(host: Tree, module: string, rootPath = '', skipImport = false): string | undefined {
|
|
18
|
-
if (skipImport || !module) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const modulePath = normalize(`${rootPath}/${module}`);
|
|
23
|
-
if (host.exists(modulePath)) {
|
|
24
|
-
return modulePath;
|
|
25
|
-
} else if (host.exists(modulePath + '.ts')) {
|
|
26
|
-
return normalize(modulePath + '.ts');
|
|
27
|
-
} else if (host.exists(modulePath + MODULE_EXT)) {
|
|
28
|
-
return normalize(modulePath + MODULE_EXT);
|
|
29
|
-
} else if (host.exists(`${modulePath}/${module}${MODULE_EXT}`)) {
|
|
30
|
-
return normalize(`${modulePath}/${module}${MODULE_EXT}`);
|
|
31
|
-
} else if (host.exists(`${modulePath}/${module}.ts`)) {
|
|
32
|
-
return normalize(`${modulePath}/${module}.ts`);
|
|
33
|
-
} else {
|
|
34
|
-
throw new Error(`Specified module path ${modulePath} does not exist`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
40
|
-
*/
|
|
41
|
-
export function findModuleFromOptions(host: Tree, options, projectPath): Path | undefined {
|
|
42
|
-
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const moduleExt = options.moduleExt || MODULE_EXT;
|
|
47
|
-
const routingModuleExt = options.routingModuleExt || ROUTING_MODULE_EXT;
|
|
48
|
-
|
|
49
|
-
if (!options.module) {
|
|
50
|
-
const pathToCheck = (projectPath || '') + '/' + options.name;
|
|
51
|
-
const module = findModule(host, pathToCheck, moduleExt, routingModuleExt);
|
|
52
|
-
return module ? normalize(module) : null;
|
|
53
|
-
} else {
|
|
54
|
-
const modulePath = normalize(`/${projectPath}/${options.module}`);
|
|
55
|
-
const componentPath = normalize(`/${projectPath}/${options.name}`);
|
|
56
|
-
const moduleBaseName = normalize(modulePath)
|
|
57
|
-
.split('/')
|
|
58
|
-
.pop();
|
|
59
|
-
|
|
60
|
-
const candidateSet = new Set<Path>([normalize(projectPath || '/')]);
|
|
61
|
-
|
|
62
|
-
for (let dir = modulePath; dir != NormalizedRoot; dir = dirname(dir)) {
|
|
63
|
-
candidateSet.add(dir);
|
|
64
|
-
}
|
|
65
|
-
for (let dir = componentPath; dir != NormalizedRoot; dir = dirname(dir)) {
|
|
66
|
-
candidateSet.add(dir);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
|
|
70
|
-
for (const c of candidatesDirs) {
|
|
71
|
-
const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map(x => join(c, x));
|
|
72
|
-
|
|
73
|
-
for (const sc of candidateFiles) {
|
|
74
|
-
if (host.exists(sc)) {
|
|
75
|
-
return normalize(sc);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Specified module '${options.module}' does not exist.\n` +
|
|
82
|
-
`Looked in the following directories:\n ${candidatesDirs.join('\n ')}`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Function to find the "closest" module to a generated file's path.
|
|
89
|
-
*/
|
|
90
|
-
export function findModule(
|
|
91
|
-
host: Tree,
|
|
92
|
-
generateDir: string,
|
|
93
|
-
moduleExt = MODULE_EXT,
|
|
94
|
-
routingModuleExt = ROUTING_MODULE_EXT
|
|
95
|
-
): Path {
|
|
96
|
-
let dir: DirEntry | null = host.getDir('/' + generateDir);
|
|
97
|
-
let foundRoutingModule = false;
|
|
98
|
-
|
|
99
|
-
while (dir) {
|
|
100
|
-
const allMatches = dir.subfiles.filter(p => p.endsWith(moduleExt));
|
|
101
|
-
const filteredMatches = allMatches.filter(p => !p.endsWith(routingModuleExt));
|
|
102
|
-
|
|
103
|
-
foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
|
|
104
|
-
|
|
105
|
-
if (filteredMatches.length == 1) {
|
|
106
|
-
return join(dir.path, filteredMatches[0]);
|
|
107
|
-
} else if (filteredMatches.length > 1) {
|
|
108
|
-
return null;
|
|
109
|
-
throw new Error(
|
|
110
|
-
'More than one module matches. Use skip-import option to skip importing ' +
|
|
111
|
-
'the component into the closest module.'
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
dir = dir.parent;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const errorMsg = foundRoutingModule
|
|
119
|
-
? 'Could not find a non Routing NgModule.' +
|
|
120
|
-
`\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
|
|
121
|
-
'\nUse the skip-import option to skip importing in NgModule.'
|
|
122
|
-
: 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
|
|
123
|
-
return null;
|
|
124
|
-
throw new Error(errorMsg);
|
|
125
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addPackageToPackageJson = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Adds a package to the package.json
|
|
6
|
-
*/
|
|
7
|
-
function addPackageToPackageJson(host, type, pkg, version) {
|
|
8
|
-
if (host.exists("package.json")) {
|
|
9
|
-
const sourceText = host.read("package.json").toString("utf-8");
|
|
10
|
-
const json = JSON.parse(sourceText);
|
|
11
|
-
if (!json[type]) {
|
|
12
|
-
json[type] = {};
|
|
13
|
-
}
|
|
14
|
-
if (!json[type][pkg]) {
|
|
15
|
-
json[type][pkg] = version;
|
|
16
|
-
}
|
|
17
|
-
host.overwrite("package.json", JSON.stringify(json, null, 2));
|
|
18
|
-
}
|
|
19
|
-
return host;
|
|
20
|
-
}
|
|
21
|
-
exports.addPackageToPackageJson = addPackageToPackageJson;
|
|
22
|
-
//# sourceMappingURL=package.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["package.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,uBAAuB,CAAC,IAAU,EAAE,IAAY,EAAE,GAAW,EAAE,OAAe;IAC5F,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SACjB;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;SAC3B;QAED,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC/D;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,0DAgBC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Tree } from "@angular-devkit/schematics";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds a package to the package.json
|
|
5
|
-
*/
|
|
6
|
-
export function addPackageToPackageJson(host: Tree, type: string, pkg: string, version: string): Tree {
|
|
7
|
-
if (host.exists("package.json")) {
|
|
8
|
-
const sourceText = host.read("package.json")!.toString("utf-8");
|
|
9
|
-
const json = JSON.parse(sourceText);
|
|
10
|
-
if (!json[type]) {
|
|
11
|
-
json[type] = {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (!json[type][pkg]) {
|
|
15
|
-
json[type][pkg] = version;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
host.overwrite("package.json", JSON.stringify(json, null, 2));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return host;
|
|
22
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProject = exports.getWorkspace = exports.getWorkspacePath = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
function getWorkspacePath(host) {
|
|
6
|
-
const possibleFiles = ['/angular.json', '/.angular.json', '/workspace.json'];
|
|
7
|
-
const path = possibleFiles.filter(path => host.exists(path))[0];
|
|
8
|
-
return path;
|
|
9
|
-
}
|
|
10
|
-
exports.getWorkspacePath = getWorkspacePath;
|
|
11
|
-
function getWorkspace(host) {
|
|
12
|
-
const path = getWorkspacePath(host);
|
|
13
|
-
const configBuffer = host.read(path);
|
|
14
|
-
if (configBuffer === null) {
|
|
15
|
-
throw new schematics_1.SchematicsException(`Could not find (${path})`);
|
|
16
|
-
}
|
|
17
|
-
const config = configBuffer.toString();
|
|
18
|
-
return JSON.parse(config);
|
|
19
|
-
}
|
|
20
|
-
exports.getWorkspace = getWorkspace;
|
|
21
|
-
function getProject(host, projectName) {
|
|
22
|
-
const workspace = getWorkspace(host);
|
|
23
|
-
projectName = projectName || workspace.defaultProject;
|
|
24
|
-
const project = workspace.projects[projectName];
|
|
25
|
-
if (!project) {
|
|
26
|
-
throw new schematics_1.SchematicsException(`Invalid project name: ${projectName}`);
|
|
27
|
-
}
|
|
28
|
-
return project;
|
|
29
|
-
}
|
|
30
|
-
exports.getProject = getProject;
|
|
31
|
-
//# sourceMappingURL=projects.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["projects.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,SAAgB,gBAAgB,CAAC,IAAU;IACzC,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,OAAO,IAAI,CAAC;AACd,CAAC;AALD,4CAKC;AAED,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,YAAY,KAAK,IAAI,EAAE;QACzB,MAAM,IAAI,gCAAmB,CAAC,mBAAmB,IAAI,GAAG,CAAC,CAAC;KAC3D;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAEvC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AATD,oCASC;AAED,SAAgB,UAAU,CAAC,IAAU,EAAE,WAAoB;IACzD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,WAAW,GAAG,WAAW,IAAI,SAAS,CAAC,cAAc,CAAC;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEhD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,gCAAmB,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;KACvE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAVD,gCAUC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SchematicsException, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
|
|
3
|
-
export function getWorkspacePath(host: Tree): string {
|
|
4
|
-
const possibleFiles = ['/angular.json', '/.angular.json', '/workspace.json'];
|
|
5
|
-
const path = possibleFiles.filter(path => host.exists(path))[0];
|
|
6
|
-
|
|
7
|
-
return path;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getWorkspace(host: Tree) {
|
|
11
|
-
const path = getWorkspacePath(host);
|
|
12
|
-
const configBuffer = host.read(path);
|
|
13
|
-
if (configBuffer === null) {
|
|
14
|
-
throw new SchematicsException(`Could not find (${path})`);
|
|
15
|
-
}
|
|
16
|
-
const config = configBuffer.toString();
|
|
17
|
-
|
|
18
|
-
return JSON.parse(config);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getProject(host: Tree, projectName?: string) {
|
|
22
|
-
const workspace = getWorkspace(host);
|
|
23
|
-
projectName = projectName || workspace.defaultProject;
|
|
24
|
-
const project = workspace.projects[projectName];
|
|
25
|
-
|
|
26
|
-
if (!project) {
|
|
27
|
-
throw new SchematicsException(`Invalid project name: ${projectName}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return project;
|
|
31
|
-
}
|