@tech4good/angular-schematics 0.0.2 → 13.1.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 +46 -46
- package/package.json +27 -27
- package/src/collection.json +25 -25
- package/src/component/files/__name@dasherize__/__name@dasherize__.animations.ts.template +4 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.html.template +3 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.scss.template +7 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +25 -0
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +30 -0
- package/src/component/index.d.ts +2 -2
- package/src/component/index.js +93 -102
- package/src/component/index.js.map +1 -1
- package/src/component/index_spec.d.ts +1 -1
- package/src/component/index_spec.js +22 -22
- package/src/component/schema.json +47 -29
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +27 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +47 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +20 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +13 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +4 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +3 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +5 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +25 -0
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +81 -0
- package/src/container/index.d.ts +2 -2
- package/src/container/index.js +115 -282
- package/src/container/index.js.map +1 -1
- package/src/container/index_spec.d.ts +1 -1
- package/src/container/index_spec.js +22 -22
- package/src/container/schema.json +47 -24
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +270 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +131 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +7 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +13 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +51 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +50 -0
- package/src/entity/index.d.ts +2 -2
- package/src/entity/index.js +123 -524
- package/src/entity/index.js.map +1 -1
- package/src/entity/index_spec.d.ts +1 -1
- package/src/entity/index_spec.js +22 -22
- package/src/entity/schema.json +42 -19
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +13 -0
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +13 -0
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +24 -0
- package/src/module/index.d.ts +2 -2
- package/src/module/index.js +96 -87
- package/src/module/index.js.map +1 -1
- package/src/module/index_spec.d.ts +1 -1
- package/src/module/index_spec.js +22 -22
- package/src/module/schema.json +38 -19
- package/src/shared/camelcase-formatter.d.ts +1 -1
- package/src/shared/camelcase-formatter.js +18 -18
- package/src/shared/statements-adder.d.ts +8 -5
- package/src/shared/statements-adder.js +52 -31
- package/src/shared/statements-adder.js.map +1 -1
- package/tsconfig.json +34 -34
package/src/entity/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAIoC;AAEpC,+DAA0E;AAC1E,yEAAmG;AACnG,uEAAmE;AACnE,qEAAuF;AACvF,+CAA+C;AAE/C,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ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C,OAAO,EAAE;YACZ,MAAM,IAAI,gCAAmB,CAAC,YAAY,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAC;SAC/E;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;YAC9B,OAAO,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAC;SAC1C;QAED,OAAO,CAAC,MAAM,GAAG,IAAA,mCAAqB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEtD,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,OAAO,CAAC,IAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC/B,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE/B,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,IAAA,2BAAc,kCACT,cAAO,GACP,OAAO,EACV;YACF,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,UAAU,CAAC,OAAO,CAAC;YACnB,IAAA,sBAAS,EAAC,cAAc,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AAvCD,wBAuCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/src/entity/index_spec.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
-
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
-
const path = require("path");
|
|
15
|
-
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
-
describe('entity', () => {
|
|
17
|
-
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
-
const tree = yield runner.runSchematicAsync('entity', {}, schematics_1.Tree.empty()).toPromise();
|
|
20
|
-
expect(tree.files).toEqual([]);
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
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
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('entity', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematicAsync('entity', {}, schematics_1.Tree.empty()).toPromise();
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
23
|
//# sourceMappingURL=index_spec.js.map
|
package/src/entity/schema.json
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "
|
|
4
|
-
"title": "
|
|
5
|
-
"type": "object",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "EntitySchema",
|
|
4
|
+
"title": "Entity Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Creates a new entity in the default project.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"index": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"default": 1
|
|
11
|
+
},
|
|
12
|
+
"path": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"format": "path",
|
|
15
|
+
"description": "The path at which to create the entity file, relative to the current workspace. Should typically be within /src/app/core/store.",
|
|
16
|
+
"visible": false
|
|
17
|
+
},
|
|
18
|
+
"project": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The name of the project.",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "projectName"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"name": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The name of the entity.",
|
|
28
|
+
"$default": {
|
|
29
|
+
"$source": "argv",
|
|
30
|
+
"index": 0
|
|
31
|
+
},
|
|
32
|
+
"x-prompt": "What name would you like to use for the entity?"
|
|
33
|
+
},
|
|
34
|
+
"inDirectory": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"x-prompt": "Are you currently in the directory where you want to generate the entity? (typically directly in src/app/core/store)"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": [
|
|
40
|
+
"name"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { Routes, RouterModule } from '@angular/router';
|
|
3
|
+
|
|
4
|
+
// Containers
|
|
5
|
+
|
|
6
|
+
const routes: Routes = [
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
imports: [RouterModule.forChild(routes)],
|
|
11
|
+
exports: [RouterModule],
|
|
12
|
+
})
|
|
13
|
+
export class <%= classify(name) %>RoutingModule { }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { <%= classify(name) %>Module } from './<%= dasherize(name) %>.module';
|
|
2
|
+
|
|
3
|
+
describe('<%= classify(name) %>Module', () => {
|
|
4
|
+
let <%= camelize(name) %>Module: <%= classify(name) %>Module;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
<%= camelize(name) %>Module = new <%= classify(name) %>Module();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should create an instance', () => {
|
|
11
|
+
expect(<%= camelize(name) %>Module).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { EffectsModule } from '@ngrx/effects';
|
|
4
|
+
import { SharedModule } from '../shared/shared.module';
|
|
5
|
+
import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing.module';
|
|
6
|
+
|
|
7
|
+
// Containers
|
|
8
|
+
|
|
9
|
+
// Components
|
|
10
|
+
|
|
11
|
+
@NgModule({
|
|
12
|
+
imports: [
|
|
13
|
+
CommonModule,
|
|
14
|
+
SharedModule,
|
|
15
|
+
<%= classify(name) %>RoutingModule,
|
|
16
|
+
EffectsModule.forFeature([
|
|
17
|
+
]),
|
|
18
|
+
],
|
|
19
|
+
declarations: [
|
|
20
|
+
// Containers
|
|
21
|
+
// Components
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
export class <%= classify(name) %>Module { }
|
package/src/module/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function module(
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
export declare function module(options: any): Rule;
|
package/src/module/index.js
CHANGED
|
@@ -1,88 +1,97 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
${
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
exports.module = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
15
|
+
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
16
|
+
const parse_name_1 = require("@schematics/angular/utility/parse-name");
|
|
17
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
18
|
+
const core_1 = require("@angular-devkit/core");
|
|
19
|
+
const statements_adder_1 = require("../shared/statements-adder");
|
|
20
|
+
function addInserts(options) {
|
|
21
|
+
return (host, context) => {
|
|
22
|
+
const classifiedName = core_1.strings.classify(options.name);
|
|
23
|
+
const dasherizedName = core_1.strings.dasherize(options.name);
|
|
24
|
+
const modulePath = '//src/app/' +
|
|
25
|
+
core_1.strings.dasherize(options.name) + '/' +
|
|
26
|
+
core_1.strings.dasherize(options.name) + '.module';
|
|
27
|
+
context.logger.info(`modulePath: ${modulePath}`);
|
|
28
|
+
if (!options.lazyLoading) {
|
|
29
|
+
// Add app module changes if not lazy loaded
|
|
30
|
+
const appModulePath = '//src/app/app.module.ts';
|
|
31
|
+
const appModuleText = (0, statements_adder_1.getSourceText)(host, appModulePath);
|
|
32
|
+
context.logger.info(`appModulePath: ${appModulePath}`);
|
|
33
|
+
const appModuleToModulePath = (0, find_module_1.buildRelativePath)(appModulePath, modulePath);
|
|
34
|
+
let insertChanges = (0, statements_adder_1.simpleInsert)(appModuleText, appModulePath, [
|
|
35
|
+
'// Feature Modules',
|
|
36
|
+
'// Feature Modules'
|
|
37
|
+
], [
|
|
38
|
+
`import { ${classifiedName}Module } from '${appModuleToModulePath}';`,
|
|
39
|
+
` ${classifiedName}Module,`
|
|
40
|
+
]);
|
|
41
|
+
const declarationRecorder = host.beginUpdate(appModulePath);
|
|
42
|
+
for (const change of insertChanges) {
|
|
43
|
+
if (change instanceof change_1.InsertChange) {
|
|
44
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
host.commitUpdate(declarationRecorder);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Add app-routing module changes if lazy loaded
|
|
51
|
+
const appRoutingModulePath = '//src/app/app-routing.module.ts';
|
|
52
|
+
const appRoutingModuleText = (0, statements_adder_1.getSourceText)(host, appRoutingModulePath);
|
|
53
|
+
const appRoutingModuleToModulePath = (0, find_module_1.buildRelativePath)(appRoutingModulePath, modulePath);
|
|
54
|
+
context.logger.info(`appRoutingModuleToModulePath: ${appRoutingModuleToModulePath}`);
|
|
55
|
+
let insertChanges = (0, statements_adder_1.simpleInsert)(appRoutingModuleText, appRoutingModulePath, [
|
|
56
|
+
'const appRoutes: Routes = ['
|
|
57
|
+
], [
|
|
58
|
+
` { path: '${dasherizedName}', loadChildren: () => import('${appRoutingModuleToModulePath}').then((mod) => mod.${classifiedName}Module) },`
|
|
59
|
+
]);
|
|
60
|
+
context.logger.info(`insertChanges: ${insertChanges}`);
|
|
61
|
+
const declarationRecorder = host.beginUpdate(appRoutingModulePath);
|
|
62
|
+
for (const change of insertChanges) {
|
|
63
|
+
if (change instanceof change_1.InsertChange) {
|
|
64
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
host.commitUpdate(declarationRecorder);
|
|
68
|
+
}
|
|
69
|
+
return host;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function module(options) {
|
|
73
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
context.logger.info("Starting module generation");
|
|
75
|
+
const workspace = yield (0, workspace_1.getWorkspace)(tree);
|
|
76
|
+
const project = workspace.projects.get(options.project);
|
|
77
|
+
if (!project) {
|
|
78
|
+
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
79
|
+
}
|
|
80
|
+
if (options.path === undefined) {
|
|
81
|
+
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
82
|
+
}
|
|
83
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
84
|
+
options.name = parsedPath.name;
|
|
85
|
+
options.path = parsedPath.path;
|
|
86
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
87
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
88
|
+
(0, schematics_1.move)(parsedPath.path),
|
|
89
|
+
]);
|
|
90
|
+
return (0, schematics_1.chain)([
|
|
91
|
+
addInserts(options),
|
|
92
|
+
(0, schematics_1.mergeWith)(templateSource)
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.module = module;
|
|
88
97
|
//# sourceMappingURL=index.js.map
|
package/src/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAIoC;AAEpC,+DAAkE;AAClE,yEAA4E;AAC5E,uEAAmE;AACnE,qEAAuF;AACvF,+CAA+C;AAE/C,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvD,MAAM,UAAU,GAAG,YAAY;YAC7B,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG;YACrC,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,UAAU,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YACxB,4CAA4C;YAC5C,MAAM,aAAa,GAAG,yBAAyB,CAAC;YAChD,MAAM,aAAa,GAAG,IAAA,gCAAa,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;YACzD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,aAAa,EAAE,CAAC,CAAC;YACvD,MAAM,qBAAqB,GAAG,IAAA,+BAAiB,EAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YAE3E,IAAI,aAAa,GAAG,IAAA,+BA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hCD,wBAgCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/src/module/index_spec.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
-
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
-
const path = require("path");
|
|
15
|
-
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
-
describe('module', () => {
|
|
17
|
-
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
-
const tree = yield runner.runSchematicAsync('module', {}, schematics_1.Tree.empty()).toPromise();
|
|
20
|
-
expect(tree.files).toEqual([]);
|
|
21
|
-
}));
|
|
22
|
-
});
|
|
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
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('module', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematicAsync('module', {}, schematics_1.Tree.empty()).toPromise();
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
23
|
//# sourceMappingURL=index_spec.js.map
|
package/src/module/schema.json
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "
|
|
4
|
-
"title": "
|
|
5
|
-
"type": "object",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "ModuleSchema",
|
|
4
|
+
"title": "Module Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "Creates a new module in the default project.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"index": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"default": 1
|
|
11
|
+
},
|
|
12
|
+
"project": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the project.",
|
|
15
|
+
"$default": {
|
|
16
|
+
"$source": "projectName"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the module.",
|
|
22
|
+
"$default": {
|
|
23
|
+
"$source": "argv",
|
|
24
|
+
"index": 0
|
|
25
|
+
},
|
|
26
|
+
"x-prompt": "What name would you like to use for the module?"
|
|
27
|
+
},
|
|
28
|
+
"lazyLoading": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Have it lazy loaded.",
|
|
31
|
+
"default": false,
|
|
32
|
+
"x-prompt": "Would you like the module to be lazy loaded?"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": [
|
|
36
|
+
"name"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function CamelCaseFormatter(name: string, lower: boolean): string;
|
|
1
|
+
export declare function CamelCaseFormatter(name: string, lower: boolean): string;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamelCaseFormatter = void 0;
|
|
4
|
-
function CamelCaseFormatter(name, lower) {
|
|
5
|
-
// e.g. list-style-image to ListStyleImage
|
|
6
|
-
let camelName = name.charAt(0).toUpperCase() + name.substr(1);
|
|
7
|
-
if (name.indexOf('-') != -1) {
|
|
8
|
-
const names = name.split('-');
|
|
9
|
-
for (var i = 0; i < names.length; i++) {
|
|
10
|
-
names[i] = names[i].charAt(0).toUpperCase() + names[i].substr(1);
|
|
11
|
-
}
|
|
12
|
-
camelName = names.join("");
|
|
13
|
-
}
|
|
14
|
-
if (lower)
|
|
15
|
-
camelName = camelName.charAt(0).toLowerCase() + camelName.substr(1);
|
|
16
|
-
return camelName;
|
|
17
|
-
}
|
|
18
|
-
exports.CamelCaseFormatter = CamelCaseFormatter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CamelCaseFormatter = void 0;
|
|
4
|
+
function CamelCaseFormatter(name, lower) {
|
|
5
|
+
// e.g. list-style-image to ListStyleImage
|
|
6
|
+
let camelName = name.charAt(0).toUpperCase() + name.substr(1);
|
|
7
|
+
if (name.indexOf('-') != -1) {
|
|
8
|
+
const names = name.split('-');
|
|
9
|
+
for (var i = 0; i < names.length; i++) {
|
|
10
|
+
names[i] = names[i].charAt(0).toUpperCase() + names[i].substr(1);
|
|
11
|
+
}
|
|
12
|
+
camelName = names.join("");
|
|
13
|
+
}
|
|
14
|
+
if (lower)
|
|
15
|
+
camelName = camelName.charAt(0).toLowerCase() + camelName.substr(1);
|
|
16
|
+
return camelName;
|
|
17
|
+
}
|
|
18
|
+
exports.CamelCaseFormatter = CamelCaseFormatter;
|
|
19
19
|
//# sourceMappingURL=camelcase-formatter.js.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { Change } from '@schematics/angular/utility/change';
|
|
3
|
+
export interface IHash {
|
|
4
|
+
[details: string]: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function getSourceText(host: Tree, filePath: string): string;
|
|
7
|
+
export declare function simpleInsert(sourceText: string, fileToEdit: string, labels: string[], statements: string[]): Change[];
|
|
8
|
+
export declare function AddStatements(filePath: string, labels: string[], statements: string[], tree: Tree): void;
|