@nstudio/angular 13.0.1 → 13.4.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 +2 -2
- package/package.json +2 -2
- package/src/schematics/application/index.js +33 -23
- package/src/schematics/application/index.spec.js +8 -8
- package/src/schematics/application/schema.json +0 -5
- package/src/schematics/component/index.js +16 -16
- package/src/schematics/component/index.spec.js +22 -22
- package/src/schematics/directive/index.js +1 -1
- package/src/schematics/directive/index.spec.js +23 -23
- package/src/schematics/elements/index.js +18 -18
- package/src/schematics/elements/index.spec.js +21 -21
- package/src/schematics/feature/index.js +10 -10
- package/src/schematics/feature/index.spec.js +37 -37
- package/src/schematics/helpers/applitools/index.js +8 -8
- package/src/schematics/helpers/index.js +4 -4
- package/src/schematics/helpers/index.spec.js +15 -15
- package/src/schematics/ng-add/index.js +4 -4
- package/src/schematics/ngrx/index.js +1 -1
- package/src/schematics/ngrx/index.spec.js +16 -16
- package/src/schematics/pipe/index.js +1 -1
- package/src/schematics/pipe/index.spec.js +20 -20
- package/src/schematics/service/index.js +1 -1
- package/src/schematics/service/index.spec.js +20 -20
- package/src/schematics/xplat/index.js +7 -7
- package/src/schematics/xplat/index.spec.js +13 -13
- package/src/utils/ast.js +8 -8
- package/src/utils/generator.js +48 -48
- package/src/utils/testing.js +1 -1
- package/src/utils/versions.d.ts +7 -7
- package/src/utils/versions.js +8 -8
- package/src/utils/xplat.js +21 -21
@@ -19,61 +19,61 @@ describe('pipe schematic', () => {
|
|
19
19
|
};
|
20
20
|
beforeEach(() => {
|
21
21
|
appTree = schematics_1.Tree.empty();
|
22
|
-
appTree = testing_1.createXplatWithNativeScriptWeb(appTree, null, 'angular');
|
22
|
+
appTree = (0, testing_1.createXplatWithNativeScriptWeb)(appTree, null, 'angular');
|
23
23
|
});
|
24
24
|
it('should create pipe in libs by default for use across any platform and apps', () => __awaiter(void 0, void 0, void 0, function* () {
|
25
25
|
// console.log('appTree:', appTree);
|
26
|
-
let tree = yield testing_2.runSchematic('feature', {
|
26
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
27
27
|
name: 'foo',
|
28
28
|
platforms: 'nativescript,web',
|
29
29
|
}, appTree);
|
30
30
|
let options = Object.assign({}, defaultOptions);
|
31
|
-
tree = yield testing_2.runSchematic('pipe', options, tree);
|
31
|
+
tree = yield (0, testing_2.runSchematic)('pipe', options, tree);
|
32
32
|
// let files = tree.files;
|
33
33
|
// console.log(files.slice(91,files.length));
|
34
34
|
// component
|
35
35
|
expect(tree.exists('/libs/xplat/features/src/lib/ui/pipes/truncate.pipe.ts')).toBeTruthy();
|
36
36
|
// file content
|
37
|
-
let content = testing_1.getFileContent(tree, '/libs/xplat/features/src/lib/ui/pipes/truncate.pipe.ts');
|
37
|
+
let content = (0, testing_1.getFileContent)(tree, '/libs/xplat/features/src/lib/ui/pipes/truncate.pipe.ts');
|
38
38
|
// console.log(content);
|
39
39
|
expect(content.indexOf(`@Pipe({`)).toBeGreaterThanOrEqual(0);
|
40
40
|
expect(content.indexOf(`name: 'truncate'`)).toBeGreaterThanOrEqual(0);
|
41
41
|
let modulePath = '/libs/xplat/features/src/lib/ui/ui.module.ts';
|
42
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
42
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
43
43
|
// console.log(modulePath + ':');
|
44
44
|
// console.log(moduleContent);
|
45
45
|
expect(moduleContent.indexOf(`...UI_PIPES`)).toBeGreaterThanOrEqual(0);
|
46
46
|
options = Object.assign(Object.assign({}, defaultOptions), { feature: 'foo' });
|
47
|
-
tree = yield testing_2.runSchematic('pipe', options, tree);
|
47
|
+
tree = yield (0, testing_2.runSchematic)('pipe', options, tree);
|
48
48
|
// files = tree.files;
|
49
49
|
// console.log(files.slice(91,files.length));
|
50
50
|
// component
|
51
51
|
expect(tree.exists('/libs/xplat/features/src/lib/foo/pipes/truncate.pipe.ts')).toBeTruthy();
|
52
52
|
// file content
|
53
|
-
content = testing_1.getFileContent(tree, '/libs/xplat/features/src/lib/foo/pipes/truncate.pipe.ts');
|
53
|
+
content = (0, testing_1.getFileContent)(tree, '/libs/xplat/features/src/lib/foo/pipes/truncate.pipe.ts');
|
54
54
|
// console.log(content);
|
55
55
|
expect(content.indexOf(`@Pipe({`)).toBeGreaterThanOrEqual(0);
|
56
56
|
expect(content.indexOf(`name: 'truncate'`)).toBeGreaterThanOrEqual(0);
|
57
57
|
modulePath = '/libs/xplat/features/src/lib/foo/foo.module.ts';
|
58
|
-
moduleContent = testing_1.getFileContent(tree, modulePath);
|
58
|
+
moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
59
59
|
// console.log(modulePath + ':');
|
60
60
|
// console.log(moduleContent);
|
61
61
|
expect(moduleContent.indexOf(`...FOO_PIPES`)).toBeGreaterThanOrEqual(0);
|
62
62
|
}));
|
63
63
|
it('should create pipe in libs and handle camel case properly', () => __awaiter(void 0, void 0, void 0, function* () {
|
64
64
|
// console.log('appTree:', appTree);
|
65
|
-
let tree = yield testing_2.runSchematic('feature', {
|
65
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
66
66
|
name: 'foo',
|
67
67
|
platforms: 'nativescript,web',
|
68
68
|
}, appTree);
|
69
69
|
let options = Object.assign(Object.assign({}, defaultOptions), { name: 'test-with-dashes' });
|
70
|
-
tree = yield testing_2.runSchematic('pipe', options, tree);
|
70
|
+
tree = yield (0, testing_2.runSchematic)('pipe', options, tree);
|
71
71
|
const files = tree.files;
|
72
72
|
// console.log(files.slice(91,files.length));
|
73
73
|
// component
|
74
74
|
expect(tree.exists('/libs/xplat/features/src/lib/ui/pipes/test-with-dashes.pipe.ts')).toBeTruthy();
|
75
75
|
// file content
|
76
|
-
let content = testing_1.getFileContent(tree, '/libs/xplat/features/src/lib/ui/pipes/test-with-dashes.pipe.ts');
|
76
|
+
let content = (0, testing_1.getFileContent)(tree, '/libs/xplat/features/src/lib/ui/pipes/test-with-dashes.pipe.ts');
|
77
77
|
// console.log(content);
|
78
78
|
expect(content.indexOf(`@Pipe({`)).toBeGreaterThanOrEqual(0);
|
79
79
|
expect(content.indexOf(`name: 'testWithDashes'`)).toBeGreaterThanOrEqual(0);
|
@@ -83,11 +83,11 @@ describe('pipe schematic', () => {
|
|
83
83
|
let tree;
|
84
84
|
const options = Object.assign({}, defaultOptions);
|
85
85
|
options.feature = 'register';
|
86
|
-
yield expect(testing_2.runSchematic('pipe', options, appTree)).rejects.toThrow(`libs/xplat/features/src/lib/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register`);
|
86
|
+
yield expect((0, testing_2.runSchematic)('pipe', options, appTree)).rejects.toThrow(`libs/xplat/features/src/lib/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register`);
|
87
87
|
}));
|
88
88
|
it('should create pipe for specified projects only', () => __awaiter(void 0, void 0, void 0, function* () {
|
89
89
|
// console.log('appTree:', appTree);
|
90
|
-
let tree = yield testing_2.runSchematic('feature', {
|
90
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
91
91
|
name: 'foo',
|
92
92
|
projects: 'nativescript-viewer,web-viewer',
|
93
93
|
onlyProject: true,
|
@@ -97,7 +97,7 @@ describe('pipe schematic', () => {
|
|
97
97
|
feature: 'foo',
|
98
98
|
projects: 'nativescript-viewer,web-viewer',
|
99
99
|
};
|
100
|
-
tree = yield testing_2.runSchematic('pipe', options, tree);
|
100
|
+
tree = yield (0, testing_2.runSchematic)('pipe', options, tree);
|
101
101
|
const files = tree.files;
|
102
102
|
// console.log(files. slice(91,files.length));
|
103
103
|
// pipe should not be setup to share
|
@@ -109,23 +109,23 @@ describe('pipe schematic', () => {
|
|
109
109
|
expect(tree.exists('/apps/web-viewer/src/app/features/foo/pipes/truncate.pipe.ts')).toBeTruthy();
|
110
110
|
// file content
|
111
111
|
let pipeIndexPath = '/apps/nativescript-viewer/src/features/foo/pipes/index.ts';
|
112
|
-
let pipeIndex = testing_1.getFileContent(tree, pipeIndexPath);
|
112
|
+
let pipeIndex = (0, testing_1.getFileContent)(tree, pipeIndexPath);
|
113
113
|
// console.log(barrelPath + ':');
|
114
114
|
// console.log(barrelIndex);
|
115
115
|
// component symbol should be at end of components collection
|
116
116
|
expect(pipeIndex.indexOf(`TruncatePipe`)).toBeGreaterThanOrEqual(0);
|
117
117
|
let modulePath = '/apps/nativescript-viewer/src/features/foo/foo.module.ts';
|
118
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
118
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
119
119
|
// console.log(modulePath + ':');
|
120
120
|
// console.log(moduleContent);
|
121
121
|
expect(moduleContent.indexOf(`...FOO_PIPES`)).toBeGreaterThanOrEqual(0);
|
122
122
|
pipeIndexPath = '/apps/web-viewer/src/app/features/foo/pipes/index.ts';
|
123
|
-
pipeIndex = testing_1.getFileContent(tree, pipeIndexPath);
|
123
|
+
pipeIndex = (0, testing_1.getFileContent)(tree, pipeIndexPath);
|
124
124
|
// console.log(barrelPath + ':');
|
125
125
|
// console.log(barrelIndex);
|
126
126
|
expect(pipeIndex.indexOf(`TruncatePipe`)).toBeGreaterThanOrEqual(0);
|
127
127
|
modulePath = '/apps/web-viewer/src/app/features/foo/foo.module.ts';
|
128
|
-
moduleContent = testing_1.getFileContent(tree, modulePath);
|
128
|
+
moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
129
129
|
// console.log(modulePath + ':');
|
130
130
|
// console.log(moduleContent);
|
131
131
|
expect(moduleContent.indexOf(`...FOO_PIPES`)).toBeGreaterThanOrEqual(0);
|
@@ -138,7 +138,7 @@ describe('pipe schematic', () => {
|
|
138
138
|
feature: 'register',
|
139
139
|
platforms: 'nativescript,web',
|
140
140
|
};
|
141
|
-
yield expect(testing_2.runSchematic('pipe', options, appTree)).rejects.toThrow(`libs/xplat/nativescript/features/src/lib/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register --platforms=nativescript --onlyModule`);
|
141
|
+
yield expect((0, testing_2.runSchematic)('pipe', options, appTree)).rejects.toThrow(`libs/xplat/nativescript/features/src/lib/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register --platforms=nativescript --onlyModule`);
|
142
142
|
}));
|
143
143
|
it('should THROW if feature module does not exist in projects', () => __awaiter(void 0, void 0, void 0, function* () {
|
144
144
|
// console.log('appTree:', appTree);
|
@@ -148,6 +148,6 @@ describe('pipe schematic', () => {
|
|
148
148
|
feature: 'register',
|
149
149
|
projects: 'nativescript-viewer,web-viewer',
|
150
150
|
};
|
151
|
-
yield expect(testing_2.runSchematic('pipe', options, appTree)).rejects.toThrow(`apps/nativescript-viewer/src/features/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register --projects=nativescript-viewer --onlyModule`);
|
151
|
+
yield expect((0, testing_2.runSchematic)('pipe', options, appTree)).rejects.toThrow(`apps/nativescript-viewer/src/features/register/register.module.ts does not exist. Create the feature module first. For example: nx g @nstudio/angular:feature register --projects=nativescript-viewer --onlyModule`);
|
152
152
|
}));
|
153
153
|
});
|
@@ -2,6 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const angular_1 = require("@nstudio/angular");
|
4
4
|
function default_1(options) {
|
5
|
-
return angular_1.generate('service', options);
|
5
|
+
return (0, angular_1.generate)('service', options);
|
6
6
|
}
|
7
7
|
exports.default = default_1;
|
@@ -19,35 +19,35 @@ describe('service schematic', () => {
|
|
19
19
|
};
|
20
20
|
beforeEach(() => {
|
21
21
|
appTree = schematics_1.Tree.empty();
|
22
|
-
appTree = testing_1.createXplatWithNativeScriptWeb(appTree, null, 'angular');
|
22
|
+
appTree = (0, testing_1.createXplatWithNativeScriptWeb)(appTree, null, 'angular');
|
23
23
|
});
|
24
24
|
it('should create service in libs by default for use across any platform and apps', () => __awaiter(void 0, void 0, void 0, function* () {
|
25
25
|
// console.log('appTree:', appTree);
|
26
|
-
let tree = yield testing_2.runSchematic('feature', {
|
26
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
27
27
|
name: 'foo',
|
28
28
|
platforms: 'nativescript,web',
|
29
29
|
}, appTree);
|
30
30
|
const options = Object.assign({}, defaultOptions);
|
31
|
-
tree = yield testing_2.runSchematic('service', options, tree);
|
31
|
+
tree = yield (0, testing_2.runSchematic)('service', options, tree);
|
32
32
|
// console.log(files.slice(91,files.length));
|
33
33
|
expect(tree.exists('/libs/xplat/core/src/lib/services/auth.service.ts')).toBeTruthy();
|
34
34
|
// file content
|
35
|
-
let content = testing_1.getFileContent(tree, '/libs/xplat/core/src/lib/services/auth.service.ts');
|
35
|
+
let content = (0, testing_1.getFileContent)(tree, '/libs/xplat/core/src/lib/services/auth.service.ts');
|
36
36
|
// console.log(content);
|
37
37
|
expect(content.indexOf(`@Injectable({`)).toBeGreaterThanOrEqual(0);
|
38
38
|
expect(content.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);
|
39
|
-
content = testing_1.getFileContent(tree, '/libs/xplat/core/src/lib/services/index.ts');
|
39
|
+
content = (0, testing_1.getFileContent)(tree, '/libs/xplat/core/src/lib/services/index.ts');
|
40
40
|
// console.log(content);
|
41
41
|
expect(content.indexOf(`./auth.service`)).toBeGreaterThanOrEqual(0);
|
42
42
|
let modulePath = '/libs/xplat/core/src/lib/core.module.ts';
|
43
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
43
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
44
44
|
// console.log(modulePath + ':');
|
45
45
|
// console.log(moduleContent);
|
46
46
|
expect(moduleContent.indexOf(`AuthService`)).toBe(-1);
|
47
47
|
}));
|
48
48
|
it('should create service for specified projects only', () => __awaiter(void 0, void 0, void 0, function* () {
|
49
49
|
// console.log('appTree:', appTree);
|
50
|
-
let tree = yield testing_2.runSchematic('feature', {
|
50
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
51
51
|
name: 'foo',
|
52
52
|
projects: 'nativescript-viewer,web-viewer',
|
53
53
|
onlyProject: true,
|
@@ -57,7 +57,7 @@ describe('service schematic', () => {
|
|
57
57
|
feature: 'foo',
|
58
58
|
projects: 'nativescript-viewer,web-viewer',
|
59
59
|
};
|
60
|
-
tree = yield testing_2.runSchematic('service', options, tree);
|
60
|
+
tree = yield (0, testing_2.runSchematic)('service', options, tree);
|
61
61
|
const files = tree.files;
|
62
62
|
// console.log(files. slice(91,files.length));
|
63
63
|
// service should not be setup to share
|
@@ -69,25 +69,25 @@ describe('service schematic', () => {
|
|
69
69
|
expect(files.indexOf('/apps/web-viewer/src/app/features/foo/services/auth.service.ts')).toBeGreaterThanOrEqual(0);
|
70
70
|
// file content
|
71
71
|
let indexPath = '/apps/nativescript-viewer/src/features/foo/services/index.ts';
|
72
|
-
let index = testing_1.getFileContent(tree, indexPath);
|
72
|
+
let index = (0, testing_1.getFileContent)(tree, indexPath);
|
73
73
|
// console.log(barrelPath + ':');
|
74
74
|
// console.log(barrelIndex);
|
75
75
|
// symbol should be at end of components collection
|
76
76
|
expect(index.indexOf(`./auth.service`)).toBeGreaterThanOrEqual(0);
|
77
77
|
let modulePath = '/apps/nativescript-viewer/src/features/foo/foo.module.ts';
|
78
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
78
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
79
79
|
// console.log(modulePath + ':');
|
80
80
|
// console.log(moduleContent);
|
81
81
|
expect(moduleContent.indexOf(`./services`)).toBe(-1);
|
82
82
|
indexPath = '/apps/web-viewer/src/app/features/foo/services/index.ts';
|
83
|
-
index = testing_1.getFileContent(tree, indexPath);
|
83
|
+
index = (0, testing_1.getFileContent)(tree, indexPath);
|
84
84
|
// console.log(barrelPath + ':');
|
85
85
|
// console.log(barrelIndex);
|
86
86
|
expect(index.indexOf(`./auth.service`)).toBeGreaterThanOrEqual(0);
|
87
87
|
}));
|
88
88
|
it('should create service for specified platform with targeted feature only', () => __awaiter(void 0, void 0, void 0, function* () {
|
89
89
|
// console.log('appTree:', appTree);
|
90
|
-
let tree = yield testing_2.runSchematic('feature', {
|
90
|
+
let tree = yield (0, testing_2.runSchematic)('feature', {
|
91
91
|
name: 'foo',
|
92
92
|
platforms: 'nativescript',
|
93
93
|
}, appTree);
|
@@ -96,22 +96,22 @@ describe('service schematic', () => {
|
|
96
96
|
feature: 'foo',
|
97
97
|
platforms: 'nativescript',
|
98
98
|
};
|
99
|
-
tree = yield testing_2.runSchematic('service', options, tree);
|
99
|
+
tree = yield (0, testing_2.runSchematic)('service', options, tree);
|
100
100
|
const files = tree.files;
|
101
101
|
// console.log(files.slice(91,files.length));
|
102
102
|
expect(files.indexOf('/libs/xplat/nativescript/features/src/lib/foo/services/auth.service.ts')).toBeGreaterThanOrEqual(0);
|
103
103
|
// should NOT add for other platform
|
104
104
|
expect(files.indexOf('/libs/xplat/web/features/src/lib/foo/services/auth.service.ts')).toBe(-1);
|
105
105
|
// file content
|
106
|
-
let content = testing_1.getFileContent(tree, '/libs/xplat/nativescript/features/src/lib/foo/services/auth.service.ts');
|
106
|
+
let content = (0, testing_1.getFileContent)(tree, '/libs/xplat/nativescript/features/src/lib/foo/services/auth.service.ts');
|
107
107
|
// console.log(content);
|
108
108
|
expect(content.indexOf(`@Injectable({`)).toBeGreaterThanOrEqual(0);
|
109
109
|
expect(content.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);
|
110
|
-
content = testing_1.getFileContent(tree, '/libs/xplat/nativescript/features/src/lib/foo/services/index.ts');
|
110
|
+
content = (0, testing_1.getFileContent)(tree, '/libs/xplat/nativescript/features/src/lib/foo/services/index.ts');
|
111
111
|
// console.log(content);
|
112
112
|
expect(content.indexOf(`./auth.service`)).toBeGreaterThanOrEqual(0);
|
113
113
|
let modulePath = '/libs/xplat/nativescript/features/src/lib/foo/foo.module.ts';
|
114
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
114
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
115
115
|
// console.log(modulePath + ':');
|
116
116
|
// console.log(moduleContent);
|
117
117
|
expect(moduleContent.indexOf(`AuthService`)).toBe(-1);
|
@@ -122,22 +122,22 @@ describe('service schematic', () => {
|
|
122
122
|
name: 'auth',
|
123
123
|
platforms: 'nativescript',
|
124
124
|
};
|
125
|
-
let tree = yield testing_2.runSchematic('service', options, appTree);
|
125
|
+
let tree = yield (0, testing_2.runSchematic)('service', options, appTree);
|
126
126
|
const files = tree.files;
|
127
127
|
// console.log(files.slice(91,files.length));
|
128
128
|
expect(files.indexOf('/libs/xplat/nativescript/core/src/lib/services/auth.service.ts')).toBeGreaterThanOrEqual(0);
|
129
129
|
// should NOT add for other platform
|
130
130
|
expect(files.indexOf('/libs/xplat/web/core/src/lib/services/auth.service.ts')).toBe(-1);
|
131
131
|
// file content
|
132
|
-
let content = testing_1.getFileContent(tree, '/libs/xplat/nativescript/core/src/lib/services/auth.service.ts');
|
132
|
+
let content = (0, testing_1.getFileContent)(tree, '/libs/xplat/nativescript/core/src/lib/services/auth.service.ts');
|
133
133
|
// console.log(content);
|
134
134
|
expect(content.indexOf(`@Injectable({`)).toBeGreaterThanOrEqual(0);
|
135
135
|
expect(content.indexOf(`AuthService`)).toBeGreaterThanOrEqual(0);
|
136
|
-
content = testing_1.getFileContent(tree, '/libs/xplat/nativescript/core/src/lib/services/index.ts');
|
136
|
+
content = (0, testing_1.getFileContent)(tree, '/libs/xplat/nativescript/core/src/lib/services/index.ts');
|
137
137
|
// console.log(content);
|
138
138
|
expect(content.indexOf(`./auth.service`)).toBeGreaterThanOrEqual(0);
|
139
139
|
let modulePath = '/libs/xplat/nativescript/core/src/lib/core.module.ts';
|
140
|
-
let moduleContent = testing_1.getFileContent(tree, modulePath);
|
140
|
+
let moduleContent = (0, testing_1.getFileContent)(tree, modulePath);
|
141
141
|
// console.log(modulePath + ':');
|
142
142
|
// console.log(moduleContent);
|
143
143
|
expect(moduleContent.indexOf(`AuthService`)).toBe(-1);
|
@@ -9,8 +9,8 @@ const focus_1 = require("@nstudio/focus");
|
|
9
9
|
function default_1(options) {
|
10
10
|
// console.log(`Generating xplat angular support for: ${options.platforms}`);
|
11
11
|
const externalChains = xplat_2.XplatAngularHelpers.externalChains(options);
|
12
|
-
return schematics_1.chain([
|
13
|
-
xplat_utils_1.prerun(options, true),
|
12
|
+
return (0, schematics_1.chain)([
|
13
|
+
(0, xplat_utils_1.prerun)(options, true),
|
14
14
|
// libs
|
15
15
|
xplat_1.XplatHelpers.generateLib(options, 'core', 'xplat', 'node'),
|
16
16
|
xplat_1.XplatHelpers.cleanupLib(options, 'core', 'xplat'),
|
@@ -25,22 +25,22 @@ function default_1(options) {
|
|
25
25
|
xplat_1.XplatHelpers.cleanupLib(options, 'utils', 'xplat'),
|
26
26
|
xplat_2.XplatAngularHelpers.addLibFiles(options, './', 'utils'),
|
27
27
|
// cross platform support
|
28
|
-
(tree, context) => schematics_1.chain(externalChains),
|
28
|
+
(tree, context) => (0, schematics_1.chain)(externalChains),
|
29
29
|
xplat_2.XplatAngularHelpers.updateRootDeps(options),
|
30
30
|
// adjust root tsconfig
|
31
31
|
(tree, context) => {
|
32
|
-
return xplat_1.updateTsConfig(tree, (tsConfig) => {
|
32
|
+
return (0, xplat_1.updateTsConfig)(tree, (tsConfig) => {
|
33
33
|
if (tsConfig) {
|
34
34
|
if (!tsConfig.compilerOptions) {
|
35
35
|
tsConfig.compilerOptions = {};
|
36
36
|
}
|
37
|
-
if (!tsConfig.compilerOptions.paths[`@${xplat_utils_1.getNpmScope()}/xplat/environments`]) {
|
38
|
-
tsConfig.compilerOptions.paths[`@${xplat_utils_1.getNpmScope()}/xplat/environments`] = [`libs/xplat/core/src/lib/environments/base/index.ts`];
|
37
|
+
if (!tsConfig.compilerOptions.paths[`@${(0, xplat_utils_1.getNpmScope)()}/xplat/environments`]) {
|
38
|
+
tsConfig.compilerOptions.paths[`@${(0, xplat_utils_1.getNpmScope)()}/xplat/environments`] = [`libs/xplat/core/src/lib/environments/base/index.ts`];
|
39
39
|
}
|
40
40
|
}
|
41
41
|
});
|
42
42
|
},
|
43
|
-
workspace_1.formatFiles({ skipFormat: options.skipFormat }),
|
43
|
+
(0, workspace_1.formatFiles)({ skipFormat: options.skipFormat }),
|
44
44
|
// clean shared code script - don't believe need this anymore
|
45
45
|
// (tree: Tree) => {
|
46
46
|
// const scripts = {};
|
@@ -13,7 +13,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
13
13
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
14
14
|
const testing_1 = require("@nstudio/xplat/testing");
|
15
15
|
const testing_2 = require("../../utils/testing");
|
16
|
-
xplat_utils_1.setTest();
|
16
|
+
(0, xplat_utils_1.setTest)();
|
17
17
|
describe('xplat schematic', () => {
|
18
18
|
let appTree;
|
19
19
|
const defaultOptions = {
|
@@ -22,12 +22,12 @@ describe('xplat schematic', () => {
|
|
22
22
|
};
|
23
23
|
beforeEach(() => {
|
24
24
|
appTree = schematics_1.Tree.empty();
|
25
|
-
appTree = testing_1.createEmptyWorkspace(appTree, 'angular');
|
25
|
+
appTree = (0, testing_1.createEmptyWorkspace)(appTree, 'angular');
|
26
26
|
});
|
27
27
|
it('should create default xplat support for web,nativescript + libs + testing support', () => __awaiter(void 0, void 0, void 0, function* () {
|
28
28
|
const options = Object.assign({}, defaultOptions);
|
29
29
|
options.platforms = 'web,nativescript';
|
30
|
-
const tree = yield testing_2.runSchematic('xplat', options, appTree);
|
30
|
+
const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree);
|
31
31
|
const files = tree.files;
|
32
32
|
// console.log(files);
|
33
33
|
expect(files.indexOf('/libs/xplat/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
@@ -36,14 +36,14 @@ describe('xplat schematic', () => {
|
|
36
36
|
expect(files.indexOf('/libs/xplat/web/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
37
37
|
expect(files.indexOf('/libs/xplat/nativescript/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
38
38
|
let filePath = '/tsconfig.base.json';
|
39
|
-
let fileContent = xplat_utils_1.jsonParse(testing_1.getFileContent(tree, filePath));
|
39
|
+
let fileContent = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, filePath));
|
40
40
|
// console.log(fileContent);
|
41
41
|
expect(fileContent.compilerOptions.paths['@testing/xplat/environments']).toBeTruthy();
|
42
42
|
}));
|
43
43
|
it('should create default xplat support for web,nativescript', () => __awaiter(void 0, void 0, void 0, function* () {
|
44
44
|
const options = Object.assign({}, defaultOptions);
|
45
45
|
options.platforms = 'web,nativescript';
|
46
|
-
const tree = yield testing_2.runSchematic('xplat', options, appTree);
|
46
|
+
const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree);
|
47
47
|
const files = tree.files;
|
48
48
|
expect(files.indexOf('/libs/xplat/web/features/src/lib/items/items.module.ts')).toBe(-1);
|
49
49
|
expect(files.indexOf('/libs/xplat/web/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
@@ -54,13 +54,13 @@ describe('xplat schematic', () => {
|
|
54
54
|
const options = Object.assign({}, defaultOptions);
|
55
55
|
options.platforms = 'ionic';
|
56
56
|
options.framework = 'angular';
|
57
|
-
const tree = yield testing_2.runSchematic('xplat', options, appTree);
|
57
|
+
const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree);
|
58
58
|
const files = tree.files;
|
59
59
|
expect(files.indexOf('/xplat/web/index.ts')).toBeGreaterThanOrEqual(0);
|
60
60
|
expect(files.indexOf('/xplat/ionic/index.ts')).toBeGreaterThanOrEqual(0);
|
61
61
|
expect(files.indexOf('/xplat/nativescript/index.ts')).toBeGreaterThanOrEqual(-1);
|
62
62
|
const packagePath = '/package.json';
|
63
|
-
const packageFile = xplat_utils_1.jsonParse(testing_1.getFileContent(tree, packagePath));
|
63
|
+
const packageFile = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, packagePath));
|
64
64
|
const hasScss = packageFile.dependencies[`@testing/scss`];
|
65
65
|
expect(hasScss).not.toBeUndefined();
|
66
66
|
const hasWebScss = packageFile.dependencies[`@testing/web-scss`];
|
@@ -72,13 +72,13 @@ describe('xplat schematic', () => {
|
|
72
72
|
it('should create default xplat support for electron which should always include web as well', () => __awaiter(void 0, void 0, void 0, function* () {
|
73
73
|
const options = Object.assign({}, defaultOptions);
|
74
74
|
options.platforms = 'electron';
|
75
|
-
const tree = yield testing_2.runSchematic('xplat', options, appTree);
|
75
|
+
const tree = yield (0, testing_2.runSchematic)('xplat', options, appTree);
|
76
76
|
const files = tree.files;
|
77
77
|
expect(files.indexOf('/libs/xplat/web/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
78
78
|
expect(files.indexOf('/libs/xplat/electron/core/src/lib/index.ts')).toBeGreaterThanOrEqual(0);
|
79
79
|
expect(files.indexOf('/libs/xplat/nativescript/core/src/lib/index.ts')).toBeGreaterThanOrEqual(-1);
|
80
80
|
const packagePath = '/package.json';
|
81
|
-
const packageFile = xplat_utils_1.jsonParse(testing_1.getFileContent(tree, packagePath));
|
81
|
+
const packageFile = (0, xplat_utils_1.jsonParse)((0, testing_1.getFileContent)(tree, packagePath));
|
82
82
|
const hasScss = packageFile.dependencies[`@testing/xplat-scss`];
|
83
83
|
expect(hasScss).not.toBeUndefined();
|
84
84
|
// const hasWebScss = packageFile.dependencies[`@testing/xplat-web-scss`];
|
@@ -93,7 +93,7 @@ describe('xplat schematic', () => {
|
|
93
93
|
const options = Object.assign({}, defaultOptions);
|
94
94
|
options.platforms = 'ionic,web';
|
95
95
|
options.framework = 'angular';
|
96
|
-
let tree = yield testing_2.runSchematic('xplat', options, appTree);
|
96
|
+
let tree = yield (0, testing_2.runSchematic)('xplat', options, appTree);
|
97
97
|
// let files = tree.files;
|
98
98
|
expect(tree.exists('/libs/xplat/web/core/src/lib/index.ts')).toBeTruthy();
|
99
99
|
expect(tree.exists('/libs/xplat/ionic/core/src/lib/index.ts')).toBeTruthy();
|
@@ -101,7 +101,7 @@ describe('xplat schematic', () => {
|
|
101
101
|
options.platforms = 'nativescript';
|
102
102
|
// let packageFile = jsonParse(getFileContent(tree, 'package.json'));
|
103
103
|
// console.log('packageFile.xplat:', packageFile.xplat);
|
104
|
-
tree = yield testing_2.runSchematic('xplat', options, tree);
|
104
|
+
tree = yield (0, testing_2.runSchematic)('xplat', options, tree);
|
105
105
|
// packageFile = jsonParse(getFileContent(tree, 'package.json'));
|
106
106
|
// console.log('after 2nd xplat run packageFile.xplat:', packageFile.xplat);
|
107
107
|
// files = tree.files;
|
@@ -113,11 +113,11 @@ describe('xplat schematic', () => {
|
|
113
113
|
}));
|
114
114
|
it('should NOT create xplat unless platforms are specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
115
115
|
const options = Object.assign({}, defaultOptions);
|
116
|
-
yield expect(testing_2.runSchematic('xplat', options, appTree)).rejects.toThrow(`You must specify which platforms you wish to generate support for. For example: nx g @nstudio/xplat:init --prefix=foo --platforms=${xplat_utils_1.supportedPlatforms.join(',')}`);
|
116
|
+
yield expect((0, testing_2.runSchematic)('xplat', options, appTree)).rejects.toThrow(`You must specify which platforms you wish to generate support for. For example: nx g @nstudio/xplat:init --prefix=foo --platforms=${xplat_utils_1.supportedPlatforms.join(',')}`);
|
117
117
|
}));
|
118
118
|
it('should NOT create unsupported xplat option and throw', () => __awaiter(void 0, void 0, void 0, function* () {
|
119
119
|
const options = Object.assign({}, defaultOptions);
|
120
120
|
options.platforms = 'desktop';
|
121
|
-
yield expect(testing_2.runSchematic('xplat', options, appTree)).rejects.toThrow(`desktop is currently not a supported platform. Supported at the moment: ${xplat_utils_1.supportedPlatforms}. Please request support for this platform if you'd like and/or submit a PR which we would greatly appreciate.`);
|
121
|
+
yield expect((0, testing_2.runSchematic)('xplat', options, appTree)).rejects.toThrow(`desktop is currently not a supported platform. Supported at the moment: ${xplat_utils_1.supportedPlatforms}. Please request support for this platform if you'd like and/or submit a PR which we would greatly appreciate.`);
|
122
122
|
}));
|
123
123
|
});
|
package/src/utils/ast.js
CHANGED
@@ -4,7 +4,7 @@ exports.getDecoratorPropertyValueNode = exports.readBootstrapInfo = exports.addE
|
|
4
4
|
const ts = require("typescript");
|
5
5
|
const ast_utils_1 = require("@nrwl/workspace/src/utils/ast-utils");
|
6
6
|
const path = require("path");
|
7
|
-
const
|
7
|
+
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
8
8
|
function addToCollection(source, barrelIndexPath, symbolName, insertSpaces = '') {
|
9
9
|
const collection = getCollection(source);
|
10
10
|
if (!collection)
|
@@ -22,7 +22,7 @@ function addToCollection(source, barrelIndexPath, symbolName, insertSpaces = '')
|
|
22
22
|
}
|
23
23
|
exports.addToCollection = addToCollection;
|
24
24
|
function getCollection(source) {
|
25
|
-
const allCollections = ast_utils_1.findNodes(source, ts.SyntaxKind.ArrayLiteralExpression);
|
25
|
+
const allCollections = (0, ast_utils_1.findNodes)(source, ts.SyntaxKind.ArrayLiteralExpression);
|
26
26
|
// console.log('allCollections:', allCollections);
|
27
27
|
// allCollections.forEach((i: ts.ArrayLiteralExpression) => {
|
28
28
|
// console.log('getText:',i.getText());
|
@@ -79,7 +79,7 @@ function _angularImportsFromNode(node, _sourceFile) {
|
|
79
79
|
}
|
80
80
|
}
|
81
81
|
function getDecoratorMetadata(source, identifier, module) {
|
82
|
-
const angularImports = ast_utils_1.findNodes(source, ts.SyntaxKind.ImportDeclaration)
|
82
|
+
const angularImports = (0, ast_utils_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration)
|
83
83
|
.map((node) => _angularImportsFromNode(node, source))
|
84
84
|
.reduce((acc, current) => {
|
85
85
|
for (const key of Object.keys(current)) {
|
@@ -87,7 +87,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
87
87
|
}
|
88
88
|
return acc;
|
89
89
|
}, {});
|
90
|
-
return ast_utils_1.getSourceNodes(source)
|
90
|
+
return (0, ast_utils_1.getSourceNodes)(source)
|
91
91
|
.filter((node) => {
|
92
92
|
return (node.kind == ts.SyntaxKind.Decorator &&
|
93
93
|
node.expression.kind == ts.SyntaxKind.CallExpression);
|
@@ -258,7 +258,7 @@ function addImportToModule(source, modulePath, symbolName) {
|
|
258
258
|
}
|
259
259
|
exports.addImportToModule = addImportToModule;
|
260
260
|
function addImportToTestBed(source, specPath, symbolName) {
|
261
|
-
const allCalls = (ast_utils_1.findNodes(source, ts.SyntaxKind.CallExpression));
|
261
|
+
const allCalls = ((0, ast_utils_1.findNodes)(source, ts.SyntaxKind.CallExpression));
|
262
262
|
const configureTestingModuleObjectLiterals = allCalls
|
263
263
|
.filter((c) => c.expression.kind === ts.SyntaxKind.PropertyAccessExpression)
|
264
264
|
.filter((c) => c.expression.name.getText(source) === 'configureTestingModule')
|
@@ -346,7 +346,7 @@ function addEntryComponents(source, modulePath, symbolName) {
|
|
346
346
|
}
|
347
347
|
exports.addEntryComponents = addEntryComponents;
|
348
348
|
function readBootstrapInfo(host, app) {
|
349
|
-
const config = ast_utils_1.getProjectConfig(host, app);
|
349
|
+
const config = (0, ast_utils_1.getProjectConfig)(host, app);
|
350
350
|
let mainPath;
|
351
351
|
try {
|
352
352
|
mainPath = config.architect.build.options.main;
|
@@ -359,7 +359,7 @@ function readBootstrapInfo(host, app) {
|
|
359
359
|
}
|
360
360
|
const mainSource = host.read(mainPath).toString('utf-8');
|
361
361
|
const main = ts.createSourceFile(mainPath, mainSource, ts.ScriptTarget.Latest, true);
|
362
|
-
const moduleImports = ast_utils_1.getImport(main, (s) => s.indexOf('.module') > -1);
|
362
|
+
const moduleImports = (0, ast_utils_1.getImport)(main, (s) => s.indexOf('.module') > -1);
|
363
363
|
if (moduleImports.length !== 1) {
|
364
364
|
throw new Error(`main.ts can only import a single module`);
|
365
365
|
}
|
@@ -372,7 +372,7 @@ function readBootstrapInfo(host, app) {
|
|
372
372
|
const moduleSourceText = host.read(modulePath).toString('utf-8');
|
373
373
|
const moduleSource = ts.createSourceFile(modulePath, moduleSourceText, ts.ScriptTarget.Latest, true);
|
374
374
|
const bootstrapComponentClassName = getBootstrapComponent(moduleSource, moduleClassName);
|
375
|
-
const bootstrapComponentFileName = `./${path.join(path.dirname(moduleImport.moduleSpec), `${
|
375
|
+
const bootstrapComponentFileName = `./${path.join(path.dirname(moduleImport.moduleSpec), `${(0, xplat_utils_1.toFileName)(bootstrapComponentClassName.substring(0, bootstrapComponentClassName.length - 9))}.component`)}`;
|
376
376
|
return {
|
377
377
|
moduleSpec: moduleImport.moduleSpec,
|
378
378
|
mainPath,
|