@coolon/angular-ui-powerups 11.1.1 → 11.2.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/package.json +1 -1
- package/schematics/activity/index.d.ts +3 -0
- package/schematics/activity/index.js +32 -0
- package/schematics/activity/index.js.map +1 -0
- package/schematics/activity/index.spec.d.ts +1 -0
- package/schematics/activity/index.spec.js +364 -0
- package/schematics/activity/index.spec.js.map +1 -0
- package/schematics/activity/schema.d.ts +4 -0
- package/schematics/activity/schema.js +3 -0
- package/schematics/activity/schema.js.map +1 -0
- package/schematics/activity/schema.json +27 -0
- package/schematics/activity/templates/component/__name@dasherize__.component.html.template +1 -0
- package/schematics/activity/templates/component/__name@dasherize__.component.scss.template +5 -0
- package/schematics/activity/templates/component/__name@dasherize__.component.spec.ts.template +25 -0
- package/schematics/activity/templates/component/__name@dasherize__.component.ts.template +28 -0
- package/schematics/activity/templates/component/__name@dasherize__.i18n.yml.template +11 -0
- package/schematics/bootstrap-app/templates/src/styles.scss.template +0 -1
- package/schematics/collection.json +11 -1
- package/schematics/component/index.d.ts +3 -0
- package/schematics/component/index.js +32 -0
- package/schematics/component/index.js.map +1 -0
- package/schematics/component/index.spec.d.ts +1 -0
- package/schematics/component/index.spec.js +364 -0
- package/schematics/component/index.spec.js.map +1 -0
- package/schematics/component/schema.d.ts +4 -0
- package/schematics/component/schema.js +3 -0
- package/schematics/component/schema.js.map +1 -0
- package/schematics/component/schema.json +27 -0
- package/schematics/component/templates/component/__name@dasherize__.component.html.template +1 -0
- package/schematics/component/templates/component/__name@dasherize__.component.scss.template +5 -0
- package/schematics/component/templates/component/__name@dasherize__.component.spec.ts.template +25 -0
- package/schematics/component/templates/component/__name@dasherize__.component.ts.template +23 -0
- package/schematics/component/templates/component/__name@dasherize__.i18n.yml.template +1 -0
- package/schematics/place-add/index.js +2 -1
- package/schematics/place-add/index.js.map +1 -1
- package/schematics/place-add/templates/component/__name@dasherize__.component.ts.template +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addActivity = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const typescript_utilities_1 = require("@coolon/typescript-utilities");
|
|
6
|
+
const template_utilities_1 = require("../utils/template-utilities");
|
|
7
|
+
const workspace_1 = require("../utils/workspace");
|
|
8
|
+
function addActivity(_options) {
|
|
9
|
+
return (tree, context) => {
|
|
10
|
+
const workspace = workspace_1.Workspace.load(tree, context);
|
|
11
|
+
const buildContext = workspace.getApplication(_options.project);
|
|
12
|
+
const nameParts = _options.name.split('/');
|
|
13
|
+
const componentName = nameParts[nameParts.length - 1];
|
|
14
|
+
const componentPathParts = nameParts.slice(0, nameParts.length - 1);
|
|
15
|
+
const pathToSourceRoot = [buildContext.sourceCodeRoot].concat(componentPathParts);
|
|
16
|
+
// we'll let angular do it by just create a default component then we'll clobber it with our real templates later.
|
|
17
|
+
const updateModule = schematics_1.externalSchematic('@schematics/angular', 'component', {
|
|
18
|
+
project: _options.project,
|
|
19
|
+
name: _options.name
|
|
20
|
+
});
|
|
21
|
+
const i18nNamespace = `I18n.${componentPathParts.concat(componentName).map(p => typescript_utilities_1.Stringy.from(p).camelizeLower().toString()).join('.')}`;
|
|
22
|
+
const componentFiles = template_utilities_1.applyTemplatesWithOverwrite(tree, 'templates/component', {
|
|
23
|
+
name: componentName,
|
|
24
|
+
selectorPrefix: buildContext.selectorPrefix,
|
|
25
|
+
pathToRoot: pathToSourceRoot.map(p => '..').join('/'),
|
|
26
|
+
i18nNamespace
|
|
27
|
+
}, `${(pathToSourceRoot.join('/'))}/${componentName}`);
|
|
28
|
+
return schematics_1.chain([updateModule, componentFiles])(tree, context);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.addActivity = addActivity;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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qBAAqB,EACrB;YACE,IAAI,EAAE,aAAa;YACnB,cAAc,EAAE,YAAY,CAAC,cAAc;YAC3C,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACrD,aAAa;SACd,EACD,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,EAAE,CACnD,CAAC;QAGF,OAAO,kBAAK,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,CAAC,CAAC;AAEJ,CAAC;AArCD,kCAqCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
15
|
+
*
|
|
16
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
17
|
+
* found in the LICENSE file at https://angular.io/license
|
|
18
|
+
*/
|
|
19
|
+
// tslint:disable:no-big-function
|
|
20
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
21
|
+
// import { Schema as ApplicationOptions } from '../application/schema';
|
|
22
|
+
// import { createAppModule } from '../utility/test';
|
|
23
|
+
// import { Schema as WorkspaceOptions } from '../workspace/schema';
|
|
24
|
+
// import { ChangeDetection, Schema as ComponentOptions, Style } from './schema';
|
|
25
|
+
describe('Add Place Schematic', () => {
|
|
26
|
+
const schematicRunner = new testing_1.SchematicTestRunner('@coolon/angular-ui-powerups', require.resolve('../collection.json'));
|
|
27
|
+
const workspaceOptions = {
|
|
28
|
+
name: 'testWorkspace',
|
|
29
|
+
newProjectRoot: 'apps',
|
|
30
|
+
version: '10.1.1'
|
|
31
|
+
};
|
|
32
|
+
// const appOptions: ApplicationOptions = {
|
|
33
|
+
const appOptions = {
|
|
34
|
+
name: 'bar',
|
|
35
|
+
routing: true,
|
|
36
|
+
prefix: 'the-prefix',
|
|
37
|
+
};
|
|
38
|
+
const defaultOptions = {
|
|
39
|
+
project: appOptions.name,
|
|
40
|
+
name: 'places/new-place'
|
|
41
|
+
};
|
|
42
|
+
let appTree;
|
|
43
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
appTree = yield schematicRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions).toPromise();
|
|
45
|
+
appTree = yield schematicRunner.runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree).toPromise();
|
|
46
|
+
appTree = yield schematicRunner
|
|
47
|
+
.runSchematicAsync('bootstrap-app', {
|
|
48
|
+
project: appOptions.name,
|
|
49
|
+
initialPlaceName: undefined // need to disable this for the test as bootstrap will invoke us if specified
|
|
50
|
+
}, appTree)
|
|
51
|
+
.toPromise();
|
|
52
|
+
}));
|
|
53
|
+
it('should create a component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const options = Object.assign({}, defaultOptions);
|
|
55
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
56
|
+
const files = tree.files;
|
|
57
|
+
expect(files).toEqual(jasmine.arrayContaining([
|
|
58
|
+
'/apps/bar/src/app/places/new-place/new-place.component.scss',
|
|
59
|
+
'/apps/bar/src/app/places/new-place/new-place.component.html',
|
|
60
|
+
'/apps/bar/src/app/places/new-place/new-place.component.spec.ts',
|
|
61
|
+
'/apps/bar/src/app/places/new-place/new-place.component.ts'
|
|
62
|
+
]));
|
|
63
|
+
const moduleContent = tree.readContent('/apps/bar/src/app/places/new-place/new-place.component.ts');
|
|
64
|
+
expect(moduleContent).toMatch(/export class NewPlaceComponent extends PlaceComponent/);
|
|
65
|
+
expect(moduleContent).toMatch(/path: 'new-place'/);
|
|
66
|
+
expect(moduleContent).toMatch(/nav: I18n.places.newPlace.nav/);
|
|
67
|
+
expect(moduleContent).toMatch(/selector: 'the-prefix-new-place'/);
|
|
68
|
+
expect(moduleContent).toMatch(/import.*I18n.*from '\.\.\/\.\.\/i18n'/);
|
|
69
|
+
}));
|
|
70
|
+
it('should add it to the place module', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const options = Object.assign({}, defaultOptions);
|
|
72
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
73
|
+
// const moduleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
74
|
+
// expect(moduleContent).toMatch(/import.*Foo.*from '.\/foo\/foo.component'/);
|
|
75
|
+
// expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
|
76
|
+
}));
|
|
77
|
+
it('should create an i18n file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const options = Object.assign({}, defaultOptions);
|
|
79
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
80
|
+
const files = tree.files;
|
|
81
|
+
expect(files).toEqual(jasmine.arrayContaining([
|
|
82
|
+
'/apps/bar/src/i18n/places/new-place.yml',
|
|
83
|
+
]));
|
|
84
|
+
}));
|
|
85
|
+
// it('should set change detection to OnPush', async () => {
|
|
86
|
+
// const options = { ...defaultOptions, changeDetection: 'OnPush' };
|
|
87
|
+
//
|
|
88
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
89
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
90
|
+
// expect(tsContent).toMatch(/changeDetection: ChangeDetectionStrategy.OnPush/);
|
|
91
|
+
// });
|
|
92
|
+
// it('should not set view encapsulation', async () => {
|
|
93
|
+
// const options = { ...defaultOptions };
|
|
94
|
+
//
|
|
95
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
96
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
97
|
+
// expect(tsContent).not.toMatch(/encapsulation: ViewEncapsulation/);
|
|
98
|
+
// });
|
|
99
|
+
//
|
|
100
|
+
// it('should set view encapsulation to Emulated', async () => {
|
|
101
|
+
// const options = { ...defaultOptions, viewEncapsulation: 'Emulated' };
|
|
102
|
+
//
|
|
103
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
104
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
105
|
+
// expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.Emulated/);
|
|
106
|
+
// });
|
|
107
|
+
//
|
|
108
|
+
// it('should set view encapsulation to None', async () => {
|
|
109
|
+
// const options = { ...defaultOptions, viewEncapsulation: 'None' };
|
|
110
|
+
//
|
|
111
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
112
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
113
|
+
// expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.None/);
|
|
114
|
+
// });
|
|
115
|
+
// it('should create a flat component', async () => {
|
|
116
|
+
// const options = { ...defaultOptions, flat: true };
|
|
117
|
+
//
|
|
118
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
119
|
+
// const files = tree.files;
|
|
120
|
+
// expect(files).toEqual(
|
|
121
|
+
// jasmine.arrayContaining([
|
|
122
|
+
// '/projects/bar/src/app/foo.component.css',
|
|
123
|
+
// '/projects/bar/src/app/foo.component.html',
|
|
124
|
+
// '/projects/bar/src/app/foo.component.spec.ts',
|
|
125
|
+
// '/projects/bar/src/app/foo.component.ts',
|
|
126
|
+
// ]),
|
|
127
|
+
// );
|
|
128
|
+
// });
|
|
129
|
+
// it('should find the closest module', async () => {
|
|
130
|
+
// const options = { ...defaultOptions };
|
|
131
|
+
// const fooModule = '/projects/bar/src/app/foo/foo.module.ts';
|
|
132
|
+
// appTree.create(
|
|
133
|
+
// fooModule,
|
|
134
|
+
// `
|
|
135
|
+
// import { NgModule } from '@angular/core';
|
|
136
|
+
// @NgModule({
|
|
137
|
+
// imports: [],
|
|
138
|
+
// declarations: []
|
|
139
|
+
// })
|
|
140
|
+
// export class FooModule { }
|
|
141
|
+
// `
|
|
142
|
+
// );
|
|
143
|
+
//
|
|
144
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
145
|
+
// const fooModuleContent = tree.readContent(fooModule);
|
|
146
|
+
// expect(fooModuleContent).toMatch(/import { FooComponent } from '.\/foo.component'/);
|
|
147
|
+
// });
|
|
148
|
+
// it('should export the component', async () => {
|
|
149
|
+
// const options = { ...defaultOptions, export: true };
|
|
150
|
+
//
|
|
151
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
152
|
+
// const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
153
|
+
// expect(appModuleContent).toMatch(/exports: \[FooComponent\]/);
|
|
154
|
+
// });
|
|
155
|
+
// it('should set the entry component', async () => {
|
|
156
|
+
// const options = { ...defaultOptions, entryComponent: true };
|
|
157
|
+
//
|
|
158
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
159
|
+
// const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
160
|
+
// expect(appModuleContent).toMatch(/entryComponents: \[FooComponent\]/);
|
|
161
|
+
// });
|
|
162
|
+
// it('should import into a specified module', async () => {
|
|
163
|
+
// const options = { ...defaultOptions, module: 'app.module.ts' };
|
|
164
|
+
//
|
|
165
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
166
|
+
// const appModule = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
167
|
+
//
|
|
168
|
+
// expect(appModule).toMatch(/import { FooComponent } from '.\/foo\/foo.component'/);
|
|
169
|
+
// });
|
|
170
|
+
// it('should fail if specified module does not exist', async () => {
|
|
171
|
+
// const options = { ...defaultOptions, module: '/projects/bar/src/app.moduleXXX.ts' };
|
|
172
|
+
// let thrownError: Error | null = null;
|
|
173
|
+
// try {
|
|
174
|
+
// await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
175
|
+
// } catch (err) {
|
|
176
|
+
// thrownError = err;
|
|
177
|
+
// }
|
|
178
|
+
// expect(thrownError).toBeDefined();
|
|
179
|
+
// });
|
|
180
|
+
// it('should handle upper case paths', async () => {
|
|
181
|
+
// const pathOption = 'projects/bar/src/app/SOME/UPPER/DIR';
|
|
182
|
+
// const options = { ...defaultOptions, path: pathOption };
|
|
183
|
+
//
|
|
184
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
185
|
+
// let files = tree.files;
|
|
186
|
+
// let root = `/${pathOption}/foo/foo.component`;
|
|
187
|
+
// expect(files).toEqual(
|
|
188
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
189
|
+
// );
|
|
190
|
+
//
|
|
191
|
+
// const options2 = { ...options, name: 'BAR' };
|
|
192
|
+
// const tree2 = await schematicRunner.runSchematicAsync('component', options2, tree).toPromise();
|
|
193
|
+
// files = tree2.files;
|
|
194
|
+
// root = `/${pathOption}/bar/bar.component`;
|
|
195
|
+
// expect(files).toEqual(
|
|
196
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
197
|
+
// );
|
|
198
|
+
// });
|
|
199
|
+
// it('should create a component in a sub-directory', async () => {
|
|
200
|
+
// const options = { ...defaultOptions, path: 'projects/bar/src/app/a/b/c' };
|
|
201
|
+
//
|
|
202
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
203
|
+
// const files = tree.files;
|
|
204
|
+
// const root = `/${options.path}/foo/foo.component`;
|
|
205
|
+
// expect(files).toEqual(
|
|
206
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
207
|
+
// );
|
|
208
|
+
// });
|
|
209
|
+
// it('should use the prefix', async () => {
|
|
210
|
+
// const options = { ...defaultOptions, prefix: 'pre' };
|
|
211
|
+
//
|
|
212
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
213
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
214
|
+
// expect(content).toMatch(/selector: 'pre-foo'/);
|
|
215
|
+
// });
|
|
216
|
+
// it('should use the default project prefix if none is passed', async () => {
|
|
217
|
+
// const options = { ...defaultOptions, prefix: undefined };
|
|
218
|
+
//
|
|
219
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
220
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
221
|
+
// expect(content).toMatch(/selector: 'app-foo'/);
|
|
222
|
+
// });
|
|
223
|
+
// it('should use the supplied prefix if it is ""', async () => {
|
|
224
|
+
// const options = { ...defaultOptions, prefix: '' };
|
|
225
|
+
//
|
|
226
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
227
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
228
|
+
// expect(content).toMatch(/selector: 'foo'/);
|
|
229
|
+
// });
|
|
230
|
+
// it('should respect the inlineTemplate option', async () => {
|
|
231
|
+
// const options = { ...defaultOptions, inlineTemplate: true };
|
|
232
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
233
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
234
|
+
// expect(content).toMatch(/template: /);
|
|
235
|
+
// expect(content).not.toMatch(/templateUrl: /);
|
|
236
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.html');
|
|
237
|
+
// });
|
|
238
|
+
//
|
|
239
|
+
// it('should respect the inlineStyle option', async () => {
|
|
240
|
+
// const options = { ...defaultOptions, inlineStyle: true };
|
|
241
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
242
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
243
|
+
// expect(content).toMatch(/styles: \[/);
|
|
244
|
+
// expect(content).not.toMatch(/styleUrls: /);
|
|
245
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.css');
|
|
246
|
+
// });
|
|
247
|
+
//
|
|
248
|
+
// it('should respect the displayBlock option when inlineStyle is `false`', async () => {
|
|
249
|
+
// const options = { ...defaultOptions, displayBlock: true };
|
|
250
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
251
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.css');
|
|
252
|
+
// expect(content).toMatch(/:host {\r?\n display: block;\r?\n}/);
|
|
253
|
+
// });
|
|
254
|
+
//
|
|
255
|
+
// it('should respect the displayBlock option when inlineStyle is `false` and use correct syntax for `scss`', async () => {
|
|
256
|
+
// const options = { ...defaultOptions, displayBlock: true, style: 'scss' };
|
|
257
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
258
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.scss');
|
|
259
|
+
// expect(content).toMatch(/:host {\r?\n display: block;\r?\n}/);
|
|
260
|
+
// });
|
|
261
|
+
//
|
|
262
|
+
// it('should respect the displayBlock option when inlineStyle is `false` and use correct syntax for `sass', async () => {
|
|
263
|
+
// const options = { ...defaultOptions, displayBlock: true, style: 'sass' };
|
|
264
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
265
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.sass');
|
|
266
|
+
// expect(content).toMatch(/\\:host\r?\n display: block;\r?\n/);
|
|
267
|
+
// });
|
|
268
|
+
//
|
|
269
|
+
// it('should respect the displayBlock option when inlineStyle is `true`', async () => {
|
|
270
|
+
// const options = { ...defaultOptions, displayBlock: true, inlineStyle: true };
|
|
271
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
272
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
273
|
+
// expect(content).toMatch(/:host {\r?\n(\s*)display: block;(\s*)}\r?\n/);
|
|
274
|
+
// });
|
|
275
|
+
// it('should respect the style option', async () => {
|
|
276
|
+
// const options = { ...defaultOptions, style: Style.Sass };
|
|
277
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
278
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
279
|
+
// expect(content).toMatch(/styleUrls: \['.\/foo.component.sass/);
|
|
280
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.sass');
|
|
281
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.css');
|
|
282
|
+
// });
|
|
283
|
+
// it('should respect the type option', async () => {
|
|
284
|
+
// const options = { ...defaultOptions, type: 'Route' };
|
|
285
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
286
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.route.ts');
|
|
287
|
+
// const testContent = tree.readContent('/projects/bar/src/app/foo/foo.route.spec.ts');
|
|
288
|
+
// expect(content).toContain('export class FooRoute implements OnInit');
|
|
289
|
+
// expect(testContent).toContain("describe('FooRoute'");
|
|
290
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.css');
|
|
291
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.html');
|
|
292
|
+
// });
|
|
293
|
+
// it('should allow empty string in the type option', async () => {
|
|
294
|
+
// const options = { ...defaultOptions, type: '' };
|
|
295
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
296
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.ts');
|
|
297
|
+
// const testContent = tree.readContent('/projects/bar/src/app/foo/foo.spec.ts');
|
|
298
|
+
// expect(content).toContain('export class Foo implements OnInit');
|
|
299
|
+
// expect(testContent).toContain("describe('Foo'");
|
|
300
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.css');
|
|
301
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.html');
|
|
302
|
+
// });
|
|
303
|
+
// it('should use the module flag even if the module is a routing module', async () => {
|
|
304
|
+
// const routingFileName = 'app-routing.module.ts';
|
|
305
|
+
// const routingModulePath = `/projects/bar/src/app/${routingFileName}`;
|
|
306
|
+
// const newTree = createAppModule(appTree, routingModulePath);
|
|
307
|
+
// const options = { ...defaultOptions, module: routingFileName };
|
|
308
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, newTree).toPromise();
|
|
309
|
+
// const content = tree.readContent(routingModulePath);
|
|
310
|
+
// expect(content).toMatch(/import { FooComponent } from '.\/foo\/foo.component/);
|
|
311
|
+
// });
|
|
312
|
+
// it('should handle a path in the name option', async () => {
|
|
313
|
+
// const options = { ...defaultOptions, name: 'dir/test-component' };
|
|
314
|
+
//
|
|
315
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
316
|
+
// const content = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
317
|
+
// expect(content).toMatch(
|
|
318
|
+
// /import { TestComponentComponent } from '\.\/dir\/test-component\/test-component.component'/
|
|
319
|
+
// );
|
|
320
|
+
// });
|
|
321
|
+
// it('should handle a path in the name and module options', async () => {
|
|
322
|
+
// appTree = await schematicRunner
|
|
323
|
+
// .runSchematicAsync('module', { name: 'admin/module', project: 'bar' }, appTree)
|
|
324
|
+
// .toPromise();
|
|
325
|
+
//
|
|
326
|
+
// const options = { ...defaultOptions, name: 'other/test-component', module: 'admin/module' };
|
|
327
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
328
|
+
//
|
|
329
|
+
// const content = appTree.readContent('/projects/bar/src/app/admin/module/module.module.ts');
|
|
330
|
+
// expect(content).toMatch(
|
|
331
|
+
// /import { TestComponentComponent } from '..\/..\/other\/test-component\/test-component.component'/
|
|
332
|
+
// );
|
|
333
|
+
// });
|
|
334
|
+
// it('should create the right selector with a path in the name', async () => {
|
|
335
|
+
// const options = { ...defaultOptions, name: 'sub/test' };
|
|
336
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
337
|
+
// const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
|
|
338
|
+
// expect(content).toMatch(/selector: 'app-test'/);
|
|
339
|
+
// });
|
|
340
|
+
// it('should respect the skipSelector option', async () => {
|
|
341
|
+
// const options = { ...defaultOptions, name: 'sub/test', skipSelector: true };
|
|
342
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
343
|
+
// const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
|
|
344
|
+
// expect(content).not.toMatch(/selector: 'app-test'/);
|
|
345
|
+
// });
|
|
346
|
+
// it('should respect the sourceRoot value', async () => {
|
|
347
|
+
// const config = JSON.parse(appTree.readContent('/angular.json'));
|
|
348
|
+
// config.projects.bar.sourceRoot = 'projects/bar/custom';
|
|
349
|
+
// appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
|
|
350
|
+
//
|
|
351
|
+
// // should fail without a module in that dir
|
|
352
|
+
// await expectAsync(
|
|
353
|
+
// schematicRunner.runSchematicAsync('component', defaultOptions, appTree).toPromise(),
|
|
354
|
+
// ).toBeRejected();
|
|
355
|
+
//
|
|
356
|
+
// // move the module
|
|
357
|
+
// appTree.rename('/projects/bar/src/app/app.module.ts', '/projects/bar/custom/app/app.module.ts');
|
|
358
|
+
// appTree = await schematicRunner
|
|
359
|
+
// .runSchematicAsync('component', defaultOptions, appTree)
|
|
360
|
+
// .toPromise();
|
|
361
|
+
// expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.component.ts');
|
|
362
|
+
// });
|
|
363
|
+
});
|
|
364
|
+
//# sourceMappingURL=index.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/activity/index.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;GAMG;AACH,iCAAiC;AACjC,gEAAuF;AACvF,wEAAwE;AACxE,qDAAqD;AACrD,oEAAoE;AACpE,iFAAiF;AAEjF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,eAAe,GAAG,IAAI,6BAAmB,CAC7C,6BAA6B,EAC7B,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CACtC,CAAC;IAEF,MAAM,gBAAgB,GAAG;QACvB,IAAI,EAAE,eAAe;QACrB,cAAc,EAAE,MAAM;QACtB,OAAO,EAAE,QAAQ;KAClB,CAAC;IAEF,2CAA2C;IAC3C,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,YAAY;KACrB,CAAC;IAEF,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,UAAU,CAAC,IAAI;QACxB,IAAI,EAAE,kBAAkB;KACzB,CAAC;IACF,IAAI,OAAqB,CAAC;IAE1B,UAAU,CAAC,GAAS,EAAE;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AAmF;IACnF,qEAAqE;IACrE,qDAAqD;IACrD,uEAAuE;IACvE,wEAAwE;IACxE,MAAM;IAEN,wFAAwF;IACxF,qDAAqD;IACrD,0EAA0E;IAC1E,iEAAiE;IACjE,oEAAoE;IACpE,qGAAqG;IACrG,yDAAyD;IACzD,oFAAoF;IACpF,MAAM;IAEN,8DAA8D;IAC9D,uEAAuE;IACvE,EAAE;IACF,qGAAqG;IACrG,6EAA6E;IAC7E,6BAA6B;IAC7B,mGAAmG;IACnG,OAAO;IACP,MAAM;IAEN,0EAA0E;IAC1E,oCAAoC;IACpC,sFAAsF;IACtF,oBAAoB;IACpB,EAAE;IACF,iGAAiG;IACjG,kGAAkG;IAClG,EAAE;IACF,gGAAgG;IAChG,6BAA6B;IAC7B,yGAAyG;IACzG,OAAO;IACP,MAAM;IAEN,+EAA+E;IAC/E,6DAA6D;IAC7D,kGAAkG;IAClG,6FAA6F;IAC7F,qDAAqD;IACrD,MAAM;IAEN,6DAA6D;IAC7D,iFAAiF;IACjF,kGAAkG;IAClG,6FAA6F;IAC7F,yDAAyD;IACzD,MAAM;IAEN,0DAA0D;IAC1D,qEAAqE;IACrE,4DAA4D;IAC5D,yEAAyE;IACzE,EAAE;IACF,gDAAgD;IAChD,uBAAuB;IACvB,2FAA2F;IAC3F,sBAAsB;IACtB,EAAE;IACF,uBAAuB;IACvB,qGAAqG;IACrG,oCAAoC;IACpC,+DAA+D;IAC/D,oBAAoB;IACpB,sFAAsF;IACtF,MAAM;AAER,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/activity/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "AddActivitySchematic",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "Add a new activity component",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The name of the activity component.",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"x-prompt": "What name would you like to use for the activity?"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"name"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p><%=name%> works!</p>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { <%=capitalize(camelize(name))%>Component } from './<%=dasherize(name)%>.component';
|
|
4
|
+
|
|
5
|
+
describe('<%=capitalize(camelize(name))%>Component', () => {
|
|
6
|
+
let component: <%=capitalize(camelize(name))%>Component;
|
|
7
|
+
let fixture: ComponentFixture<<%=capitalize(camelize(name))%>Component>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ <%=capitalize(camelize(name))%>Component ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(<%=capitalize(camelize(name))%>Component);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { Dsl } from '@coolon/pectin';
|
|
3
|
+
import {Activity, ACTIVITY_DATA} from "@coolon/angular-ui-powerups";
|
|
4
|
+
import { I18n } from '<%=pathToRoot%>/i18n';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: '<%=selectorPrefix%>-<%=dasherize(name)%>',
|
|
8
|
+
templateUrl: './<%=dasherize(name)%>.component.html',
|
|
9
|
+
styleUrls: ['./<%=dasherize(name)%>.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class <%=capitalize(camelize(name))%>Component extends Activity<<%=capitalize(camelize(name))%>.Data, void> implements OnInit {
|
|
12
|
+
|
|
13
|
+
readonly i18n = <%=i18nNamespace%>;
|
|
14
|
+
|
|
15
|
+
constructor(@Inject(ACTIVITY_DATA) private readonly data: <%=capitalize(camelize(name))%>.Data) {
|
|
16
|
+
super();
|
|
17
|
+
const {chain} = Dsl.disposeWith(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ngOnInit() {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export namespace <%=capitalize(camelize(name))%> {
|
|
26
|
+
export interface Data {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -29,10 +29,20 @@
|
|
|
29
29
|
"factory": "./place-routes/index#generateRoutes",
|
|
30
30
|
"schema": "./place-routes/schema.json"
|
|
31
31
|
},
|
|
32
|
-
"place
|
|
32
|
+
"place": {
|
|
33
33
|
"description": "Creates a new place component and associated files",
|
|
34
34
|
"factory": "./place-add/index#addPlace",
|
|
35
35
|
"schema": "./place-add/schema.json"
|
|
36
|
+
},
|
|
37
|
+
"component": {
|
|
38
|
+
"description": "Creates a new component and associated files",
|
|
39
|
+
"factory": "./component/index#addComponent",
|
|
40
|
+
"schema": "./component/schema.json"
|
|
41
|
+
},
|
|
42
|
+
"activity": {
|
|
43
|
+
"description": "Creates a new activity component and associated files",
|
|
44
|
+
"factory": "./activity/index#addActivity",
|
|
45
|
+
"schema": "./activity/schema.json"
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
48
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addComponent = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const typescript_utilities_1 = require("@coolon/typescript-utilities");
|
|
6
|
+
const template_utilities_1 = require("../utils/template-utilities");
|
|
7
|
+
const workspace_1 = require("../utils/workspace");
|
|
8
|
+
function addComponent(_options) {
|
|
9
|
+
return (tree, context) => {
|
|
10
|
+
const workspace = workspace_1.Workspace.load(tree, context);
|
|
11
|
+
const buildContext = workspace.getApplication(_options.project);
|
|
12
|
+
const nameParts = _options.name.split('/');
|
|
13
|
+
const componentName = nameParts[nameParts.length - 1];
|
|
14
|
+
const componentPathParts = nameParts.slice(0, nameParts.length - 1);
|
|
15
|
+
const pathToSourceRoot = [buildContext.sourceCodeRoot].concat(componentPathParts);
|
|
16
|
+
// we'll let angular do it by just create a default component then we'll clobber it with our real templates later.
|
|
17
|
+
const updateModule = schematics_1.externalSchematic('@schematics/angular', 'component', {
|
|
18
|
+
project: _options.project,
|
|
19
|
+
name: _options.name
|
|
20
|
+
});
|
|
21
|
+
const i18nNamespace = `I18n.${componentPathParts.concat(componentName).map(p => typescript_utilities_1.Stringy.from(p).camelizeLower().toString()).join('.')}`;
|
|
22
|
+
const componentFiles = template_utilities_1.applyTemplatesWithOverwrite(tree, 'templates/component', {
|
|
23
|
+
name: componentName,
|
|
24
|
+
selectorPrefix: buildContext.selectorPrefix,
|
|
25
|
+
pathToRoot: pathToSourceRoot.map(p => '..').join('/'),
|
|
26
|
+
i18nNamespace
|
|
27
|
+
}, `${(pathToSourceRoot.join('/'))}/${componentName}`);
|
|
28
|
+
return schematics_1.chain([updateModule, componentFiles])(tree, context);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.addComponent = addComponent;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/component/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoG;AACpG,uEAAuD;AACvD,oEAA0E;AAC1E,kDAA+C;AAI/C,SAAgB,YAAY,CAAC,QAAgB;IAE3C,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,SAAS,GAAG,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,YAAY,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEhE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtD,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpE,MAAM,gBAAgB,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAElF,kHAAkH;QAClH,MAAM,YAAY,GAAG,8BAAiB,CAAC,qBAAqB,EAAE,WAAW,EAAE;YACzE,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,QAAQ,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,8BAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAExI,MAAM,cAAc,GAAG,gDAA2B,CAChD,IAAI,EACJ,qBAAqB,EACrB;YACE,IAAI,EAAE,aAAa;YACnB,cAAc,EAAE,YAAY,CAAC,cAAc;YAC3C,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACrD,aAAa;SACd,EACD,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,EAAE,CACnD,CAAC;QAGF,OAAO,kBAAK,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,CAAC,CAAC;AAEJ,CAAC;AArCD,oCAqCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
15
|
+
*
|
|
16
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
17
|
+
* found in the LICENSE file at https://angular.io/license
|
|
18
|
+
*/
|
|
19
|
+
// tslint:disable:no-big-function
|
|
20
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
21
|
+
// import { Schema as ApplicationOptions } from '../application/schema';
|
|
22
|
+
// import { createAppModule } from '../utility/test';
|
|
23
|
+
// import { Schema as WorkspaceOptions } from '../workspace/schema';
|
|
24
|
+
// import { ChangeDetection, Schema as ComponentOptions, Style } from './schema';
|
|
25
|
+
describe('Add Place Schematic', () => {
|
|
26
|
+
const schematicRunner = new testing_1.SchematicTestRunner('@coolon/angular-ui-powerups', require.resolve('../collection.json'));
|
|
27
|
+
const workspaceOptions = {
|
|
28
|
+
name: 'testWorkspace',
|
|
29
|
+
newProjectRoot: 'apps',
|
|
30
|
+
version: '10.1.1'
|
|
31
|
+
};
|
|
32
|
+
// const appOptions: ApplicationOptions = {
|
|
33
|
+
const appOptions = {
|
|
34
|
+
name: 'bar',
|
|
35
|
+
routing: true,
|
|
36
|
+
prefix: 'the-prefix',
|
|
37
|
+
};
|
|
38
|
+
const defaultOptions = {
|
|
39
|
+
project: appOptions.name,
|
|
40
|
+
name: 'places/new-place'
|
|
41
|
+
};
|
|
42
|
+
let appTree;
|
|
43
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
appTree = yield schematicRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions).toPromise();
|
|
45
|
+
appTree = yield schematicRunner.runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree).toPromise();
|
|
46
|
+
appTree = yield schematicRunner
|
|
47
|
+
.runSchematicAsync('bootstrap-app', {
|
|
48
|
+
project: appOptions.name,
|
|
49
|
+
initialPlaceName: undefined // need to disable this for the test as bootstrap will invoke us if specified
|
|
50
|
+
}, appTree)
|
|
51
|
+
.toPromise();
|
|
52
|
+
}));
|
|
53
|
+
it('should create a component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const options = Object.assign({}, defaultOptions);
|
|
55
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
56
|
+
const files = tree.files;
|
|
57
|
+
expect(files).toEqual(jasmine.arrayContaining([
|
|
58
|
+
'/apps/bar/src/app/places/new-place/new-place.component.scss',
|
|
59
|
+
'/apps/bar/src/app/places/new-place/new-place.component.html',
|
|
60
|
+
'/apps/bar/src/app/places/new-place/new-place.component.spec.ts',
|
|
61
|
+
'/apps/bar/src/app/places/new-place/new-place.component.ts'
|
|
62
|
+
]));
|
|
63
|
+
const moduleContent = tree.readContent('/apps/bar/src/app/places/new-place/new-place.component.ts');
|
|
64
|
+
expect(moduleContent).toMatch(/export class NewPlaceComponent extends PlaceComponent/);
|
|
65
|
+
expect(moduleContent).toMatch(/path: 'new-place'/);
|
|
66
|
+
expect(moduleContent).toMatch(/nav: I18n.places.newPlace.nav/);
|
|
67
|
+
expect(moduleContent).toMatch(/selector: 'the-prefix-new-place'/);
|
|
68
|
+
expect(moduleContent).toMatch(/import.*I18n.*from '\.\.\/\.\.\/i18n'/);
|
|
69
|
+
}));
|
|
70
|
+
it('should add it to the place module', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const options = Object.assign({}, defaultOptions);
|
|
72
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
73
|
+
// const moduleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
74
|
+
// expect(moduleContent).toMatch(/import.*Foo.*from '.\/foo\/foo.component'/);
|
|
75
|
+
// expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
|
76
|
+
}));
|
|
77
|
+
it('should create an i18n file', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const options = Object.assign({}, defaultOptions);
|
|
79
|
+
const tree = yield schematicRunner.runSchematicAsync('place-add', options, appTree).toPromise();
|
|
80
|
+
const files = tree.files;
|
|
81
|
+
expect(files).toEqual(jasmine.arrayContaining([
|
|
82
|
+
'/apps/bar/src/i18n/places/new-place.yml',
|
|
83
|
+
]));
|
|
84
|
+
}));
|
|
85
|
+
// it('should set change detection to OnPush', async () => {
|
|
86
|
+
// const options = { ...defaultOptions, changeDetection: 'OnPush' };
|
|
87
|
+
//
|
|
88
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
89
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
90
|
+
// expect(tsContent).toMatch(/changeDetection: ChangeDetectionStrategy.OnPush/);
|
|
91
|
+
// });
|
|
92
|
+
// it('should not set view encapsulation', async () => {
|
|
93
|
+
// const options = { ...defaultOptions };
|
|
94
|
+
//
|
|
95
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
96
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
97
|
+
// expect(tsContent).not.toMatch(/encapsulation: ViewEncapsulation/);
|
|
98
|
+
// });
|
|
99
|
+
//
|
|
100
|
+
// it('should set view encapsulation to Emulated', async () => {
|
|
101
|
+
// const options = { ...defaultOptions, viewEncapsulation: 'Emulated' };
|
|
102
|
+
//
|
|
103
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
104
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
105
|
+
// expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.Emulated/);
|
|
106
|
+
// });
|
|
107
|
+
//
|
|
108
|
+
// it('should set view encapsulation to None', async () => {
|
|
109
|
+
// const options = { ...defaultOptions, viewEncapsulation: 'None' };
|
|
110
|
+
//
|
|
111
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
112
|
+
// const tsContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
113
|
+
// expect(tsContent).toMatch(/encapsulation: ViewEncapsulation.None/);
|
|
114
|
+
// });
|
|
115
|
+
// it('should create a flat component', async () => {
|
|
116
|
+
// const options = { ...defaultOptions, flat: true };
|
|
117
|
+
//
|
|
118
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
119
|
+
// const files = tree.files;
|
|
120
|
+
// expect(files).toEqual(
|
|
121
|
+
// jasmine.arrayContaining([
|
|
122
|
+
// '/projects/bar/src/app/foo.component.css',
|
|
123
|
+
// '/projects/bar/src/app/foo.component.html',
|
|
124
|
+
// '/projects/bar/src/app/foo.component.spec.ts',
|
|
125
|
+
// '/projects/bar/src/app/foo.component.ts',
|
|
126
|
+
// ]),
|
|
127
|
+
// );
|
|
128
|
+
// });
|
|
129
|
+
// it('should find the closest module', async () => {
|
|
130
|
+
// const options = { ...defaultOptions };
|
|
131
|
+
// const fooModule = '/projects/bar/src/app/foo/foo.module.ts';
|
|
132
|
+
// appTree.create(
|
|
133
|
+
// fooModule,
|
|
134
|
+
// `
|
|
135
|
+
// import { NgModule } from '@angular/core';
|
|
136
|
+
// @NgModule({
|
|
137
|
+
// imports: [],
|
|
138
|
+
// declarations: []
|
|
139
|
+
// })
|
|
140
|
+
// export class FooModule { }
|
|
141
|
+
// `
|
|
142
|
+
// );
|
|
143
|
+
//
|
|
144
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
145
|
+
// const fooModuleContent = tree.readContent(fooModule);
|
|
146
|
+
// expect(fooModuleContent).toMatch(/import { FooComponent } from '.\/foo.component'/);
|
|
147
|
+
// });
|
|
148
|
+
// it('should export the component', async () => {
|
|
149
|
+
// const options = { ...defaultOptions, export: true };
|
|
150
|
+
//
|
|
151
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
152
|
+
// const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
153
|
+
// expect(appModuleContent).toMatch(/exports: \[FooComponent\]/);
|
|
154
|
+
// });
|
|
155
|
+
// it('should set the entry component', async () => {
|
|
156
|
+
// const options = { ...defaultOptions, entryComponent: true };
|
|
157
|
+
//
|
|
158
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
159
|
+
// const appModuleContent = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
160
|
+
// expect(appModuleContent).toMatch(/entryComponents: \[FooComponent\]/);
|
|
161
|
+
// });
|
|
162
|
+
// it('should import into a specified module', async () => {
|
|
163
|
+
// const options = { ...defaultOptions, module: 'app.module.ts' };
|
|
164
|
+
//
|
|
165
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
166
|
+
// const appModule = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
167
|
+
//
|
|
168
|
+
// expect(appModule).toMatch(/import { FooComponent } from '.\/foo\/foo.component'/);
|
|
169
|
+
// });
|
|
170
|
+
// it('should fail if specified module does not exist', async () => {
|
|
171
|
+
// const options = { ...defaultOptions, module: '/projects/bar/src/app.moduleXXX.ts' };
|
|
172
|
+
// let thrownError: Error | null = null;
|
|
173
|
+
// try {
|
|
174
|
+
// await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
175
|
+
// } catch (err) {
|
|
176
|
+
// thrownError = err;
|
|
177
|
+
// }
|
|
178
|
+
// expect(thrownError).toBeDefined();
|
|
179
|
+
// });
|
|
180
|
+
// it('should handle upper case paths', async () => {
|
|
181
|
+
// const pathOption = 'projects/bar/src/app/SOME/UPPER/DIR';
|
|
182
|
+
// const options = { ...defaultOptions, path: pathOption };
|
|
183
|
+
//
|
|
184
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
185
|
+
// let files = tree.files;
|
|
186
|
+
// let root = `/${pathOption}/foo/foo.component`;
|
|
187
|
+
// expect(files).toEqual(
|
|
188
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
189
|
+
// );
|
|
190
|
+
//
|
|
191
|
+
// const options2 = { ...options, name: 'BAR' };
|
|
192
|
+
// const tree2 = await schematicRunner.runSchematicAsync('component', options2, tree).toPromise();
|
|
193
|
+
// files = tree2.files;
|
|
194
|
+
// root = `/${pathOption}/bar/bar.component`;
|
|
195
|
+
// expect(files).toEqual(
|
|
196
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
197
|
+
// );
|
|
198
|
+
// });
|
|
199
|
+
// it('should create a component in a sub-directory', async () => {
|
|
200
|
+
// const options = { ...defaultOptions, path: 'projects/bar/src/app/a/b/c' };
|
|
201
|
+
//
|
|
202
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
203
|
+
// const files = tree.files;
|
|
204
|
+
// const root = `/${options.path}/foo/foo.component`;
|
|
205
|
+
// expect(files).toEqual(
|
|
206
|
+
// jasmine.arrayContaining([`${root}.css`, `${root}.html`, `${root}.spec.ts`, `${root}.ts`])
|
|
207
|
+
// );
|
|
208
|
+
// });
|
|
209
|
+
// it('should use the prefix', async () => {
|
|
210
|
+
// const options = { ...defaultOptions, prefix: 'pre' };
|
|
211
|
+
//
|
|
212
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
213
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
214
|
+
// expect(content).toMatch(/selector: 'pre-foo'/);
|
|
215
|
+
// });
|
|
216
|
+
// it('should use the default project prefix if none is passed', async () => {
|
|
217
|
+
// const options = { ...defaultOptions, prefix: undefined };
|
|
218
|
+
//
|
|
219
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
220
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
221
|
+
// expect(content).toMatch(/selector: 'app-foo'/);
|
|
222
|
+
// });
|
|
223
|
+
// it('should use the supplied prefix if it is ""', async () => {
|
|
224
|
+
// const options = { ...defaultOptions, prefix: '' };
|
|
225
|
+
//
|
|
226
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
227
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
228
|
+
// expect(content).toMatch(/selector: 'foo'/);
|
|
229
|
+
// });
|
|
230
|
+
// it('should respect the inlineTemplate option', async () => {
|
|
231
|
+
// const options = { ...defaultOptions, inlineTemplate: true };
|
|
232
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
233
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
234
|
+
// expect(content).toMatch(/template: /);
|
|
235
|
+
// expect(content).not.toMatch(/templateUrl: /);
|
|
236
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.html');
|
|
237
|
+
// });
|
|
238
|
+
//
|
|
239
|
+
// it('should respect the inlineStyle option', async () => {
|
|
240
|
+
// const options = { ...defaultOptions, inlineStyle: true };
|
|
241
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
242
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
243
|
+
// expect(content).toMatch(/styles: \[/);
|
|
244
|
+
// expect(content).not.toMatch(/styleUrls: /);
|
|
245
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.css');
|
|
246
|
+
// });
|
|
247
|
+
//
|
|
248
|
+
// it('should respect the displayBlock option when inlineStyle is `false`', async () => {
|
|
249
|
+
// const options = { ...defaultOptions, displayBlock: true };
|
|
250
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
251
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.css');
|
|
252
|
+
// expect(content).toMatch(/:host {\r?\n display: block;\r?\n}/);
|
|
253
|
+
// });
|
|
254
|
+
//
|
|
255
|
+
// it('should respect the displayBlock option when inlineStyle is `false` and use correct syntax for `scss`', async () => {
|
|
256
|
+
// const options = { ...defaultOptions, displayBlock: true, style: 'scss' };
|
|
257
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
258
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.scss');
|
|
259
|
+
// expect(content).toMatch(/:host {\r?\n display: block;\r?\n}/);
|
|
260
|
+
// });
|
|
261
|
+
//
|
|
262
|
+
// it('should respect the displayBlock option when inlineStyle is `false` and use correct syntax for `sass', async () => {
|
|
263
|
+
// const options = { ...defaultOptions, displayBlock: true, style: 'sass' };
|
|
264
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
265
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.sass');
|
|
266
|
+
// expect(content).toMatch(/\\:host\r?\n display: block;\r?\n/);
|
|
267
|
+
// });
|
|
268
|
+
//
|
|
269
|
+
// it('should respect the displayBlock option when inlineStyle is `true`', async () => {
|
|
270
|
+
// const options = { ...defaultOptions, displayBlock: true, inlineStyle: true };
|
|
271
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
272
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
273
|
+
// expect(content).toMatch(/:host {\r?\n(\s*)display: block;(\s*)}\r?\n/);
|
|
274
|
+
// });
|
|
275
|
+
// it('should respect the style option', async () => {
|
|
276
|
+
// const options = { ...defaultOptions, style: Style.Sass };
|
|
277
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
278
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
|
|
279
|
+
// expect(content).toMatch(/styleUrls: \['.\/foo.component.sass/);
|
|
280
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.sass');
|
|
281
|
+
// expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.css');
|
|
282
|
+
// });
|
|
283
|
+
// it('should respect the type option', async () => {
|
|
284
|
+
// const options = { ...defaultOptions, type: 'Route' };
|
|
285
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
286
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.route.ts');
|
|
287
|
+
// const testContent = tree.readContent('/projects/bar/src/app/foo/foo.route.spec.ts');
|
|
288
|
+
// expect(content).toContain('export class FooRoute implements OnInit');
|
|
289
|
+
// expect(testContent).toContain("describe('FooRoute'");
|
|
290
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.css');
|
|
291
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.html');
|
|
292
|
+
// });
|
|
293
|
+
// it('should allow empty string in the type option', async () => {
|
|
294
|
+
// const options = { ...defaultOptions, type: '' };
|
|
295
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
296
|
+
// const content = tree.readContent('/projects/bar/src/app/foo/foo.ts');
|
|
297
|
+
// const testContent = tree.readContent('/projects/bar/src/app/foo/foo.spec.ts');
|
|
298
|
+
// expect(content).toContain('export class Foo implements OnInit');
|
|
299
|
+
// expect(testContent).toContain("describe('Foo'");
|
|
300
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.css');
|
|
301
|
+
// expect(tree.files).toContain('/projects/bar/src/app/foo/foo.html');
|
|
302
|
+
// });
|
|
303
|
+
// it('should use the module flag even if the module is a routing module', async () => {
|
|
304
|
+
// const routingFileName = 'app-routing.module.ts';
|
|
305
|
+
// const routingModulePath = `/projects/bar/src/app/${routingFileName}`;
|
|
306
|
+
// const newTree = createAppModule(appTree, routingModulePath);
|
|
307
|
+
// const options = { ...defaultOptions, module: routingFileName };
|
|
308
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, newTree).toPromise();
|
|
309
|
+
// const content = tree.readContent(routingModulePath);
|
|
310
|
+
// expect(content).toMatch(/import { FooComponent } from '.\/foo\/foo.component/);
|
|
311
|
+
// });
|
|
312
|
+
// it('should handle a path in the name option', async () => {
|
|
313
|
+
// const options = { ...defaultOptions, name: 'dir/test-component' };
|
|
314
|
+
//
|
|
315
|
+
// const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
316
|
+
// const content = tree.readContent('/projects/bar/src/app/app.module.ts');
|
|
317
|
+
// expect(content).toMatch(
|
|
318
|
+
// /import { TestComponentComponent } from '\.\/dir\/test-component\/test-component.component'/
|
|
319
|
+
// );
|
|
320
|
+
// });
|
|
321
|
+
// it('should handle a path in the name and module options', async () => {
|
|
322
|
+
// appTree = await schematicRunner
|
|
323
|
+
// .runSchematicAsync('module', { name: 'admin/module', project: 'bar' }, appTree)
|
|
324
|
+
// .toPromise();
|
|
325
|
+
//
|
|
326
|
+
// const options = { ...defaultOptions, name: 'other/test-component', module: 'admin/module' };
|
|
327
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
328
|
+
//
|
|
329
|
+
// const content = appTree.readContent('/projects/bar/src/app/admin/module/module.module.ts');
|
|
330
|
+
// expect(content).toMatch(
|
|
331
|
+
// /import { TestComponentComponent } from '..\/..\/other\/test-component\/test-component.component'/
|
|
332
|
+
// );
|
|
333
|
+
// });
|
|
334
|
+
// it('should create the right selector with a path in the name', async () => {
|
|
335
|
+
// const options = { ...defaultOptions, name: 'sub/test' };
|
|
336
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
337
|
+
// const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
|
|
338
|
+
// expect(content).toMatch(/selector: 'app-test'/);
|
|
339
|
+
// });
|
|
340
|
+
// it('should respect the skipSelector option', async () => {
|
|
341
|
+
// const options = { ...defaultOptions, name: 'sub/test', skipSelector: true };
|
|
342
|
+
// appTree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise();
|
|
343
|
+
// const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
|
|
344
|
+
// expect(content).not.toMatch(/selector: 'app-test'/);
|
|
345
|
+
// });
|
|
346
|
+
// it('should respect the sourceRoot value', async () => {
|
|
347
|
+
// const config = JSON.parse(appTree.readContent('/angular.json'));
|
|
348
|
+
// config.projects.bar.sourceRoot = 'projects/bar/custom';
|
|
349
|
+
// appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
|
|
350
|
+
//
|
|
351
|
+
// // should fail without a module in that dir
|
|
352
|
+
// await expectAsync(
|
|
353
|
+
// schematicRunner.runSchematicAsync('component', defaultOptions, appTree).toPromise(),
|
|
354
|
+
// ).toBeRejected();
|
|
355
|
+
//
|
|
356
|
+
// // move the module
|
|
357
|
+
// appTree.rename('/projects/bar/src/app/app.module.ts', '/projects/bar/custom/app/app.module.ts');
|
|
358
|
+
// appTree = await schematicRunner
|
|
359
|
+
// .runSchematicAsync('component', defaultOptions, appTree)
|
|
360
|
+
// .toPromise();
|
|
361
|
+
// expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.component.ts');
|
|
362
|
+
// });
|
|
363
|
+
});
|
|
364
|
+
//# sourceMappingURL=index.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/component/index.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;GAMG;AACH,iCAAiC;AACjC,gEAAuF;AACvF,wEAAwE;AACxE,qDAAqD;AACrD,oEAAoE;AACpE,iFAAiF;AAEjF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,eAAe,GAAG,IAAI,6BAAmB,CAC7C,6BAA6B,EAC7B,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CACtC,CAAC;IAEF,MAAM,gBAAgB,GAAG;QACvB,IAAI,EAAE,eAAe;QACrB,cAAc,EAAE,MAAM;QACtB,OAAO,EAAE,QAAQ;KAClB,CAAC;IAEF,2CAA2C;IAC3C,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,YAAY;KACrB,CAAC;IAEF,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,UAAU,CAAC,IAAI;QACxB,IAAI,EAAE,kBAAkB;K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AEN,mEAAmE;IACnE,qDAAqD;IACrD,qGAAqG;IACrG,0EAA0E;IAC1E,mFAAmF;IACnF,qEAAqE;IACrE,qDAAqD;IACrD,uEAAuE;IACvE,wEAAwE;IACxE,MAAM;IAEN,wFAAwF;IACxF,qDAAqD;IACrD,0EAA0E;IAC1E,iEAAiE;IACjE,oEAAoE;IACpE,qGAAqG;IACrG,yDAAyD;IACzD,oFAAoF;IACpF,MAAM;IAEN,8DAA8D;IAC9D,uEAAuE;IACvE,EAAE;IACF,qGAAqG;IACrG,6EAA6E;IAC7E,6BAA6B;IAC7B,mGAAmG;IACnG,OAAO;IACP,MAAM;IAEN,0EAA0E;IAC1E,oCAAoC;IACpC,sFAAsF;IACtF,oBAAoB;IACpB,EAAE;IACF,iGAAiG;IACjG,kGAAkG;IAClG,EAAE;IACF,gGAAgG;IAChG,6BAA6B;IAC7B,yGAAyG;IACzG,OAAO;IACP,MAAM;IAEN,+EAA+E;IAC/E,6DAA6D;IAC7D,kGAAkG;IAClG,6FAA6F;IAC7F,qDAAqD;IACrD,MAAM;IAEN,6DAA6D;IAC7D,iFAAiF;IACjF,kGAAkG;IAClG,6FAA6F;IAC7F,yDAAyD;IACzD,MAAM;IAEN,0DAA0D;IAC1D,qEAAqE;IACrE,4DAA4D;IAC5D,yEAAyE;IACzE,EAAE;IACF,gDAAgD;IAChD,uBAAuB;IACvB,2FAA2F;IAC3F,sBAAsB;IACtB,EAAE;IACF,uBAAuB;IACvB,qGAAqG;IACrG,oCAAoC;IACpC,+DAA+D;IAC/D,oBAAoB;IACpB,sFAAsF;IACtF,MAAM;AAER,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/component/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "AddComponentSchematic",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "Add a new component",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The name of the component.",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"x-prompt": "What name would you like to use for the component?"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"name"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p><%=name%> works!</p>
|
package/schematics/component/templates/component/__name@dasherize__.component.spec.ts.template
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { <%=capitalize(camelize(name))%>Component } from './<%=dasherize(name)%>.component';
|
|
4
|
+
|
|
5
|
+
describe('<%=capitalize(camelize(name))%>Component', () => {
|
|
6
|
+
let component: <%=capitalize(camelize(name))%>Component;
|
|
7
|
+
let fixture: ComponentFixture<<%=capitalize(camelize(name))%>Component>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ <%=capitalize(camelize(name))%>Component ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(<%=capitalize(camelize(name))%>Component);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { Dsl } from '@coolon/pectin';
|
|
3
|
+
import { DisposableComponent } from '@coolon/angular-ui-powerups';
|
|
4
|
+
import { I18n } from '<%=pathToRoot%>/i18n';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: '<%=selectorPrefix%>-<%=dasherize(name)%>',
|
|
8
|
+
templateUrl: './<%=dasherize(name)%>.component.html',
|
|
9
|
+
styleUrls: ['./<%=dasherize(name)%>.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class <%=capitalize(camelize(name))%>Component extends DisposableComponent implements OnInit {
|
|
12
|
+
|
|
13
|
+
readonly i18n = <%=i18nNamespace%>;
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
const {chain} = Dsl.disposeWith(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ngOnInit() {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
name: "<%=capitalize(camelize(name))%>"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addPlace = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const typescript_utilities_1 = require("@coolon/typescript-utilities");
|
|
5
6
|
const template_utilities_1 = require("../utils/template-utilities");
|
|
6
7
|
const workspace_1 = require("../utils/workspace");
|
|
7
8
|
function addPlace(_options) {
|
|
@@ -22,7 +23,7 @@ function addPlace(_options) {
|
|
|
22
23
|
name: _options.name,
|
|
23
24
|
module: placeModulePath.slice(buildContext.sourceCodeRoot.length)
|
|
24
25
|
});
|
|
25
|
-
const i18nNamespace = `I18n.${componentPathParts.concat(componentName).join('.')}`;
|
|
26
|
+
const i18nNamespace = `I18n.${componentPathParts.concat(componentName).map(p => typescript_utilities_1.Stringy.from(p).camelizeLower().toString()).join('.')}`;
|
|
26
27
|
const componentFiles = template_utilities_1.applyTemplatesWithOverwrite(tree, 'templates/component', {
|
|
27
28
|
name: componentName,
|
|
28
29
|
selectorPrefix: buildContext.selectorPrefix,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoG;AACpG,oEAA0E;AAC1E,kDAA+C;AAI/C,SAAgB,QAAQ,CAAC,QAAgB;IAEvC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,SAAS,GAAG,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,YAAY,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEhE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtD,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpE,MAAM,gBAAgB,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAClF,MAAM,eAAe,GAAG,YAAY,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;QAClG,IAAI,CAAC,eAAe,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,2GAA2G,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,6HAA6H,CAAC,CAAC;SACrR;QACD,kHAAkH;QAClH,MAAM,YAAY,GAAG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=capitalize(camelize(name))%>Component extends PlaceComponent imp
|
|
|
23
24
|
|
|
24
25
|
constructor() {
|
|
25
26
|
super();
|
|
27
|
+
const {chain} = Dsl.disposeWith(this);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
ngOnInit() {
|