@abp/ng.schematics 6.0.0-rc.4 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collection.json +5 -0
- package/commands/api/index.js +38 -28
- package/commands/api/index.js.map +1 -1
- package/commands/api/schema.json +9 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/.eslintrc.json.template +44 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/ng-package.json.template +7 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/__libraryName@kebab__-config.module.ts.template +12 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/enums/index.ts.template +1 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/enums/route-names.ts.template +3 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/providers/index.ts.template +1 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/providers/route.provider.ts.template +26 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/config/src/public-api.ts.template +3 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/karma.conf.js.template +44 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/ng-package.json.template +7 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/package.json.template +11 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/src/lib/__libraryName@kebab__-routing.module.ts.template +18 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/src/lib/__libraryName@kebab__.module.ts.template +22 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/src/public-api.ts.template +4 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/src/test.ts.template +26 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/tsconfig.lib.json.template +20 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/tsconfig.lib.prod.json.template +10 -0
- package/commands/create-lib/files-package/__libraryName@kebab__/tsconfig.spec.json.template +17 -0
- package/commands/create-lib/files-secondary-entrypoint/__libraryName@kebab__/ng-package.json.template +7 -0
- package/commands/create-lib/files-secondary-entrypoint/__libraryName@kebab__/src/lib/__target@kebab__-__libraryName@kebab__.module.ts.template +11 -0
- package/commands/create-lib/files-secondary-entrypoint/__libraryName@kebab__/src/lib/index.ts.template +1 -0
- package/commands/create-lib/files-secondary-entrypoint/__libraryName@kebab__/src/public-api.ts.template +1 -0
- package/commands/create-lib/index.d.ts +6 -0
- package/commands/create-lib/index.js +124 -0
- package/commands/create-lib/index.js.map +1 -0
- package/commands/create-lib/models/generate-lib-schema.d.ts +13 -0
- package/commands/create-lib/models/generate-lib-schema.js +3 -0
- package/commands/create-lib/models/generate-lib-schema.js.map +1 -0
- package/commands/create-lib/models/index.d.ts +1 -0
- package/commands/create-lib/models/index.js +18 -0
- package/commands/create-lib/models/index.js.map +1 -0
- package/commands/create-lib/schema.json +36 -0
- package/commands/proxy-add/index.js +15 -15
- package/commands/proxy-add/index.js.map +1 -1
- package/commands/proxy-add/schema.json +9 -0
- package/commands/proxy-index/index.d.ts +3 -2
- package/commands/proxy-index/index.js +5 -5
- package/commands/proxy-index/index.js.map +1 -1
- package/commands/proxy-index/schema.json +9 -0
- package/commands/proxy-refresh/index.d.ts +2 -2
- package/commands/proxy-refresh/index.js +13 -13
- package/commands/proxy-refresh/index.js.map +1 -1
- package/commands/proxy-refresh/schema.json +10 -0
- package/commands/proxy-remove/index.d.ts +2 -2
- package/commands/proxy-remove/index.js +13 -13
- package/commands/proxy-remove/index.js.map +1 -1
- package/commands/proxy-remove/schema.json +9 -0
- package/constants/index.js +6 -2
- package/constants/index.js.map +1 -1
- package/constants/symbols.d.ts +1 -0
- package/constants/symbols.js +5 -0
- package/constants/symbols.js.map +1 -0
- package/enums/exception.d.ts +2 -1
- package/enums/index.js +6 -2
- package/enums/index.js.map +1 -1
- package/models/generate-proxy-schema.d.ts +4 -0
- package/models/index.js +6 -2
- package/models/index.js.map +1 -1
- package/models/method.js +3 -3
- package/models/method.js.map +1 -1
- package/package.json +6 -5
- package/test-setup.js +2 -2
- package/test-setup.js.map +1 -1
- package/utils/angular/ast-utils.d.ts +1 -14
- package/utils/angular/ast-utils.js +45 -117
- package/utils/angular/ast-utils.js.map +1 -1
- package/utils/angular/change.d.ts +6 -4
- package/utils/angular/change.js +29 -4
- package/utils/angular/change.js.map +1 -1
- package/utils/angular/dependencies.d.ts +1 -1
- package/utils/angular/dependencies.js +7 -9
- package/utils/angular/dependencies.js.map +1 -1
- package/utils/angular/dependency.d.ts +96 -0
- package/utils/angular/dependency.js +123 -0
- package/utils/angular/dependency.js.map +1 -0
- package/utils/angular/find-module.d.ts +2 -4
- package/utils/angular/find-module.js +22 -22
- package/utils/angular/find-module.js.map +1 -1
- package/utils/angular/generate-from-files.d.ts +17 -0
- package/utils/angular/generate-from-files.js +37 -0
- package/utils/angular/generate-from-files.js.map +1 -0
- package/utils/angular/index.d.ts +1 -5
- package/utils/angular/index.js +7 -7
- package/utils/angular/index.js.map +1 -1
- package/utils/angular/json-file.d.ts +4 -4
- package/utils/angular/json-file.js +24 -17
- package/utils/angular/json-file.js.map +1 -1
- package/utils/angular/ng-ast-utils.d.ts +7 -0
- package/utils/angular/ng-ast-utils.js +13 -21
- package/utils/angular/ng-ast-utils.js.map +1 -1
- package/utils/angular/parse-name.d.ts +1 -1
- package/utils/angular/parse-name.js +6 -6
- package/utils/angular/parse-name.js.map +1 -1
- package/utils/angular/paths.d.ts +1 -1
- package/utils/angular/paths.js +2 -2
- package/utils/angular/paths.js.map +1 -1
- package/utils/angular/project-targets.d.ts +1 -1
- package/utils/angular/project-targets.js +1 -1
- package/utils/angular/validation.d.ts +8 -2
- package/utils/angular/validation.js +10 -55
- package/utils/angular/validation.js.map +1 -1
- package/utils/angular/workspace-models.d.ts +16 -15
- package/utils/angular/workspace-models.js +9 -4
- package/utils/angular/workspace-models.js.map +1 -1
- package/utils/angular/workspace.d.ts +40 -5
- package/utils/angular/workspace.js +96 -38
- package/utils/angular/workspace.js.map +1 -1
- package/utils/angular-schematic/generate-lib.d.ts +3 -0
- package/utils/angular-schematic/generate-lib.js +54 -0
- package/utils/angular-schematic/generate-lib.js.map +1 -0
- package/utils/angular-schematic/index.d.ts +1 -0
- package/utils/angular-schematic/index.js +18 -0
- package/utils/angular-schematic/index.js.map +1 -0
- package/utils/api.js +1 -1
- package/utils/api.js.map +1 -1
- package/utils/ast.js +3 -3
- package/utils/ast.js.map +1 -1
- package/utils/barrel.js +1 -1
- package/utils/barrel.js.map +1 -1
- package/utils/common.js +1 -1
- package/utils/common.js.map +1 -1
- package/utils/enum.js +2 -2
- package/utils/enum.js.map +1 -1
- package/utils/generics.js +1 -2
- package/utils/generics.js.map +1 -1
- package/utils/index.js +6 -2
- package/utils/index.js.map +1 -1
- package/utils/methods.js +2 -1
- package/utils/methods.js.map +1 -1
- package/utils/model.js +17 -19
- package/utils/model.js.map +1 -1
- package/utils/namespace.js +1 -1
- package/utils/namespace.js.map +1 -1
- package/utils/path.js +1 -1
- package/utils/path.js.map +1 -1
- package/utils/rule.js +3 -3
- package/utils/rule.js.map +1 -1
- package/utils/service.js +15 -11
- package/utils/service.js.map +1 -1
- package/utils/source.js +19 -19
- package/utils/source.js.map +1 -1
- package/utils/text.js +18 -9
- package/utils/text.js.map +1 -1
- package/utils/type.js +6 -6
- package/utils/type.js.map +1 -1
- package/utils/workspace.d.ts +9 -1
- package/utils/workspace.js +51 -9
- package/utils/workspace.js.map +1 -1
- package/utils/angular/config.d.ts +0 -455
- package/utils/angular/config.js +0 -71
- package/utils/angular/config.js.map +0 -1
- package/utils/angular/json-utils.d.ts +0 -14
- package/utils/angular/json-utils.js +0 -159
- package/utils/angular/json-utils.js.map +0 -1
- package/utils/angular/latest-versions.d.ts +0 -18
- package/utils/angular/latest-versions.js +0 -27
- package/utils/angular/latest-versions.js.map +0 -1
- package/utils/angular/lint-fix.d.ts +0 -9
- package/utils/angular/lint-fix.js +0 -42
- package/utils/angular/lint-fix.js.map +0 -1
- package/utils/angular/tsconfig.d.ts +0 -16
- package/utils/angular/tsconfig.js +0 -63
- package/utils/angular/tsconfig.js.map +0 -1
package/collection.json
CHANGED
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"description": "ABP API Generator Schematics",
|
|
25
25
|
"factory": "./commands/api",
|
|
26
26
|
"schema": "./commands/api/schema.json"
|
|
27
|
+
},
|
|
28
|
+
"create-lib": {
|
|
29
|
+
"description": "ABP Create Library Schematics",
|
|
30
|
+
"factory": "./commands/create-lib",
|
|
31
|
+
"schema": "./commands/create-lib/schema.json"
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
}
|
package/commands/api/index.js
CHANGED
|
@@ -5,25 +5,25 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const cases = require("../../utils/text");
|
|
7
7
|
function default_1(schema) {
|
|
8
|
-
const params = utils_1.removeDefaultPlaceholders(schema);
|
|
8
|
+
const params = (0, utils_1.removeDefaultPlaceholders)(schema);
|
|
9
9
|
const moduleName = params.module || 'app';
|
|
10
|
-
return schematics_1.chain([
|
|
11
|
-
async (tree
|
|
12
|
-
const getRootNamespace = utils_1.createRootNamespaceGetter(params);
|
|
10
|
+
return (0, schematics_1.chain)([
|
|
11
|
+
async (tree) => {
|
|
12
|
+
const getRootNamespace = (0, utils_1.createRootNamespaceGetter)(params);
|
|
13
13
|
const solution = await getRootNamespace(tree);
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
|
-
const target = await utils_1.resolveProject(tree, params.target);
|
|
16
|
-
const targetPath = utils_1.
|
|
17
|
-
const readProxyConfig = utils_1.createProxyConfigReader(targetPath);
|
|
18
|
-
const createProxyConfigWriter = utils_1.createProxyConfigWriterCreator(targetPath);
|
|
15
|
+
const target = await (0, utils_1.resolveProject)(tree, params.target);
|
|
16
|
+
const targetPath = (0, utils_1.buildTargetPath)(target.definition, params.entryPoint);
|
|
17
|
+
const readProxyConfig = (0, utils_1.createProxyConfigReader)(targetPath);
|
|
18
|
+
const createProxyConfigWriter = (0, utils_1.createProxyConfigWriterCreator)(targetPath);
|
|
19
19
|
const data = readProxyConfig(tree);
|
|
20
20
|
const types = data.types;
|
|
21
21
|
const modules = data.modules;
|
|
22
22
|
if (!types || !modules)
|
|
23
|
-
throw new schematics_1.SchematicsException("[Invalid API Definition] The provided API definition is invalid." /* InvalidApiDefinition */);
|
|
23
|
+
throw new schematics_1.SchematicsException("[Invalid API Definition] The provided API definition is invalid." /* Exception.InvalidApiDefinition */);
|
|
24
24
|
const definition = data.modules[moduleName];
|
|
25
25
|
if (!definition)
|
|
26
|
-
throw new schematics_1.SchematicsException(utils_1.interpolate("[Invalid Module] Backend module \"{0}\" does not exist in API definition." /* InvalidModule */, moduleName));
|
|
26
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Invalid Module] Backend module \"{0}\" does not exist in API definition." /* Exception.InvalidModule */, moduleName));
|
|
27
27
|
const apiName = definition.remoteServiceName;
|
|
28
28
|
const controllers = Object.values(definition.controllers || {});
|
|
29
29
|
const serviceImports = {};
|
|
@@ -53,32 +53,35 @@ function default_1(schema) {
|
|
|
53
53
|
if (!data.generated.includes(moduleName))
|
|
54
54
|
data.generated.push(moduleName);
|
|
55
55
|
data.generated.sort();
|
|
56
|
-
const json = utils_1.generateProxyConfigJson(data);
|
|
56
|
+
const json = (0, utils_1.generateProxyConfigJson)(data);
|
|
57
57
|
const overwriteProxyConfig = createProxyConfigWriter('overwrite', json);
|
|
58
|
-
return schematics_1.branchAndMerge(schematics_1.chain([generateServices, generateModels, generateEnums, overwriteProxyConfig]));
|
|
58
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([generateServices, generateModels, generateEnums, overwriteProxyConfig]));
|
|
59
59
|
},
|
|
60
60
|
]);
|
|
61
61
|
}
|
|
62
62
|
exports.default = default_1;
|
|
63
63
|
function createEnumGenerator(params) {
|
|
64
64
|
const { targetPath, serviceImports, modelImports } = params;
|
|
65
|
-
const mapImportRefToEnum = utils_1.createImportRefToEnumMapper(params);
|
|
65
|
+
const mapImportRefToEnum = (0, utils_1.createImportRefToEnumMapper)(params);
|
|
66
66
|
const enumRefs = [
|
|
67
67
|
...new Set([
|
|
68
|
-
...utils_1.getEnumNamesFromImports(serviceImports),
|
|
69
|
-
...utils_1.getEnumNamesFromImports(modelImports),
|
|
68
|
+
...(0, utils_1.getEnumNamesFromImports)(serviceImports),
|
|
69
|
+
...(0, utils_1.getEnumNamesFromImports)(modelImports),
|
|
70
70
|
]),
|
|
71
71
|
];
|
|
72
|
-
return schematics_1.chain(enumRefs.map(ref => {
|
|
73
|
-
return utils_1.applyWithOverwrite(schematics_1.url('./files-enum'), [
|
|
74
|
-
schematics_1.applyTemplates(
|
|
75
|
-
|
|
72
|
+
return (0, schematics_1.chain)(enumRefs.map(ref => {
|
|
73
|
+
return (0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-enum'), [
|
|
74
|
+
(0, schematics_1.applyTemplates)({
|
|
75
|
+
...cases,
|
|
76
|
+
...mapImportRefToEnum(ref),
|
|
77
|
+
}),
|
|
78
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetPath)),
|
|
76
79
|
]);
|
|
77
80
|
}));
|
|
78
81
|
}
|
|
79
82
|
function createModelGenerator(params) {
|
|
80
83
|
const { targetPath, serviceImports, modelImports } = params;
|
|
81
|
-
const reduceImportRefsToModels = utils_1.createImportRefsToModelReducer(params);
|
|
84
|
+
const reduceImportRefsToModels = (0, utils_1.createImportRefsToModelReducer)(params);
|
|
82
85
|
const models = Object.values(serviceImports).reduce(reduceImportRefsToModels, []);
|
|
83
86
|
models.forEach(({ imports }) => imports.forEach(({ refs, path }) => refs.forEach(ref => {
|
|
84
87
|
if (path === '@abp/ng.core')
|
|
@@ -87,15 +90,18 @@ function createModelGenerator(params) {
|
|
|
87
90
|
return (modelImports[path] = [ref]);
|
|
88
91
|
modelImports[path] = [...new Set([...modelImports[path], ref])];
|
|
89
92
|
})));
|
|
90
|
-
return schematics_1.chain(models.map(model => utils_1.applyWithOverwrite(schematics_1.url('./files-model'), [
|
|
91
|
-
schematics_1.applyTemplates(
|
|
92
|
-
|
|
93
|
+
return (0, schematics_1.chain)(models.map(model => (0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-model'), [
|
|
94
|
+
(0, schematics_1.applyTemplates)({
|
|
95
|
+
...cases,
|
|
96
|
+
...model,
|
|
97
|
+
}),
|
|
98
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetPath)),
|
|
93
99
|
])));
|
|
94
100
|
}
|
|
95
101
|
function createServiceGenerator(params) {
|
|
96
102
|
const { targetPath, controllers, serviceImports } = params;
|
|
97
|
-
const mapControllerToService = utils_1.createControllerToServiceMapper(params);
|
|
98
|
-
return schematics_1.chain(controllers.map(controller => {
|
|
103
|
+
const mapControllerToService = (0, utils_1.createControllerToServiceMapper)(params);
|
|
104
|
+
return (0, schematics_1.chain)(controllers.map(controller => {
|
|
99
105
|
const service = mapControllerToService(controller);
|
|
100
106
|
service.imports.forEach(({ refs, path }) => refs.forEach(ref => {
|
|
101
107
|
if (path === '@abp/ng.core')
|
|
@@ -104,9 +110,13 @@ function createServiceGenerator(params) {
|
|
|
104
110
|
return (serviceImports[path] = [ref]);
|
|
105
111
|
serviceImports[path] = [...new Set([...serviceImports[path], ref])];
|
|
106
112
|
}));
|
|
107
|
-
return utils_1.applyWithOverwrite(schematics_1.url('./files-service'), [
|
|
108
|
-
schematics_1.applyTemplates(
|
|
109
|
-
|
|
113
|
+
return (0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-service'), [
|
|
114
|
+
(0, schematics_1.applyTemplates)({
|
|
115
|
+
...cases,
|
|
116
|
+
serializeParameters: utils_1.serializeParameters,
|
|
117
|
+
...service,
|
|
118
|
+
}),
|
|
119
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetPath)),
|
|
110
120
|
]);
|
|
111
121
|
}));
|
|
112
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/commands/api/index.ts"],"names":[],"mappings":";;AAAA,+CAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/schematics/src/commands/api/index.ts"],"names":[],"mappings":";;AAAA,+CAAiD;AACjD,2DAQoC;AAGpC,uCAiBqB;AACrB,0CAA0C;AAE1C,mBAAyB,MAA2B;IAClD,MAAM,MAAM,GAAG,IAAA,iCAAyB,EAAC,MAAM,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;IAE1C,OAAO,IAAA,kBAAK,EAAC;QACX,KAAK,EAAE,IAAU,EAAE,EAAE;YACnB,MAAM,gBAAgB,GAAG,IAAA,iCAAyB,EAAC,MAAM,CAAC,CAAC;YAC3D,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAE9C,oEAAoE;YACpE,MAAM,MAAM,GAAG,MAAM,IAAA,sBAAc,EAAC,IAAI,EAAE,MAAM,CAAC,MAAO,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,IAAA,uBAAe,EAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;YACzE,MAAM,eAAe,GAAG,IAAA,+BAAuB,EAAC,UAAU,CAAC,CAAC;YAC5D,MAAM,uBAAuB,GAAG,IAAA,sCAA8B,EAAC,UAAU,CAAC,CAAC;YAC3E,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,gCAAmB,yGAAgC,CAAC;YAEtF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC,UAA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GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,IAAA,0BAAkB,EAAC,IAAA,gBAAG,EAAC,iBAAiB,CAAC,EAAE;YAChD,IAAA,2BAAc,EAAC;gBACb,GAAG,KAAK;gBACR,mBAAmB,EAAnB,2BAAmB;gBACnB,GAAG,OAAO;aACX,CAAC;YACF,IAAA,iBAAI,EAAC,IAAA,gBAAS,EAAC,UAAU,CAAC,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/commands/api/schema.json
CHANGED
|
@@ -39,6 +39,15 @@
|
|
|
39
39
|
"index": 3
|
|
40
40
|
},
|
|
41
41
|
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
|
|
42
|
+
},
|
|
43
|
+
"entryPoint": {
|
|
44
|
+
"description": "Target Angular project to place the generated code",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"$default": {
|
|
47
|
+
"$source": "argv",
|
|
48
|
+
"index": 5
|
|
49
|
+
},
|
|
50
|
+
"x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")"
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
"required": []
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../.eslintrc.json",
|
|
3
|
+
"ignorePatterns": [
|
|
4
|
+
"!**/*"
|
|
5
|
+
],
|
|
6
|
+
"overrides": [
|
|
7
|
+
{
|
|
8
|
+
"files": [
|
|
9
|
+
"*.ts"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": [
|
|
13
|
+
"projects/<%= kebab(libraryName) %>/tsconfig.lib.json",
|
|
14
|
+
"projects/<%= kebab(libraryName) %>/tsconfig.spec.json"
|
|
15
|
+
],
|
|
16
|
+
"createDefaultProgram": true
|
|
17
|
+
},
|
|
18
|
+
"rules": {
|
|
19
|
+
"@angular-eslint/directive-selector": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
"type": "attribute",
|
|
23
|
+
"prefix": "lib",
|
|
24
|
+
"style": "camelCase"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"@angular-eslint/component-selector": [
|
|
28
|
+
"error",
|
|
29
|
+
{
|
|
30
|
+
"type": "element",
|
|
31
|
+
"prefix": "lib",
|
|
32
|
+
"style": "kebab-case"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"files": [
|
|
39
|
+
"*.html"
|
|
40
|
+
],
|
|
41
|
+
"rules": {}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleWithProviders, NgModule } from '@angular/core';
|
|
2
|
+
import { <%= macro(libraryName) %>_ROUTE_PROVIDERS } from './providers/route.provider';
|
|
3
|
+
|
|
4
|
+
@NgModule()
|
|
5
|
+
export class <%= pascal(libraryName) %>ConfigModule {
|
|
6
|
+
static forRoot(): ModuleWithProviders<<%= pascal(libraryName) %>ConfigModule> {
|
|
7
|
+
return {
|
|
8
|
+
ngModule: <%= pascal(libraryName) %>ConfigModule,
|
|
9
|
+
providers: [<%= macro(libraryName) %>_ROUTE_PROVIDERS],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
package/commands/create-lib/files-package/__libraryName@kebab__/config/src/enums/index.ts.template
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './route-names';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './route.provider';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { eLayoutType, RoutesService } from '@abp/ng.core';
|
|
2
|
+
import { APP_INITIALIZER } from '@angular/core';
|
|
3
|
+
import { e<%= pascal(libraryName) %>RouteNames } from '../enums/route-names';
|
|
4
|
+
|
|
5
|
+
export const <%= macro(libraryName) %>_ROUTE_PROVIDERS = [
|
|
6
|
+
{
|
|
7
|
+
provide: APP_INITIALIZER,
|
|
8
|
+
useFactory: configureRoutes,
|
|
9
|
+
deps: [RoutesService],
|
|
10
|
+
multi: true,
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export function configureRoutes(routesService: RoutesService) {
|
|
15
|
+
return () => {
|
|
16
|
+
routesService.add([
|
|
17
|
+
{
|
|
18
|
+
path: '/<%= kebab(libraryName) %>',
|
|
19
|
+
name: e<%= pascal(libraryName) %>RouteNames.<%= pascal(libraryName) %>,
|
|
20
|
+
iconClass: 'fas fa-book',
|
|
21
|
+
layout: eLayoutType.application,
|
|
22
|
+
order: 3,
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
jasmine: {
|
|
17
|
+
// you can add configuration options for Jasmine here
|
|
18
|
+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
+
// for example, you can disable the random execution with `random: false`
|
|
20
|
+
// or set a specific seed with `seed: 4321`
|
|
21
|
+
},
|
|
22
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
+
},
|
|
24
|
+
jasmineHtmlReporter: {
|
|
25
|
+
suppressAll: true // removes the duplicated traces
|
|
26
|
+
},
|
|
27
|
+
coverageReporter: {
|
|
28
|
+
dir: require('path').join(__dirname, '../../coverage/my-project-name'),
|
|
29
|
+
subdir: '.',
|
|
30
|
+
reporters: [
|
|
31
|
+
{ type: 'html' },
|
|
32
|
+
{ type: 'text-summary' }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
reporters: ['progress', 'kjhtml'],
|
|
36
|
+
port: 9876,
|
|
37
|
+
colors: true,
|
|
38
|
+
logLevel: config.LOG_INFO,
|
|
39
|
+
autoWatch: true,
|
|
40
|
+
browsers: ['Chrome'],
|
|
41
|
+
singleRun: false,
|
|
42
|
+
restartOnFileChange: true
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { DynamicLayoutComponent } from '@abp/ng.core';
|
|
3
|
+
import { Routes, RouterModule } from '@angular/router';
|
|
4
|
+
|
|
5
|
+
const routes: Routes = [
|
|
6
|
+
{
|
|
7
|
+
path: '',
|
|
8
|
+
pathMatch: 'full',
|
|
9
|
+
component: DynamicLayoutComponent,
|
|
10
|
+
children: [],
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
@NgModule({
|
|
15
|
+
imports: [RouterModule.forChild(routes)],
|
|
16
|
+
exports: [RouterModule],
|
|
17
|
+
})
|
|
18
|
+
export class <%= pascal(libraryName) %>RoutingModule {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NgModule, NgModuleFactory, ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { CoreModule, LazyModuleFactory } from '@abp/ng.core';
|
|
3
|
+
import { ThemeSharedModule } from '@abp/ng.theme.shared';
|
|
4
|
+
import { <%= pascal(libraryName) %>RoutingModule } from './<%= kebab(libraryName) %>-routing.module';
|
|
5
|
+
|
|
6
|
+
@NgModule({
|
|
7
|
+
declarations: [],
|
|
8
|
+
imports: [CoreModule, ThemeSharedModule, <%= pascal(libraryName) %>RoutingModule],
|
|
9
|
+
exports: [],
|
|
10
|
+
})
|
|
11
|
+
export class <%= pascal(libraryName) %>Module {
|
|
12
|
+
static forChild(): ModuleWithProviders<<%= pascal(libraryName) %>Module> {
|
|
13
|
+
return {
|
|
14
|
+
ngModule: <%= pascal(libraryName) %>Module,
|
|
15
|
+
providers: [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static forLazy(): NgModuleFactory<<%= pascal(libraryName) %>Module> {
|
|
20
|
+
return new LazyModuleFactory(<%= pascal(libraryName) %>Module.forChild());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
import 'zone.js';
|
|
4
|
+
import 'zone.js/testing';
|
|
5
|
+
import { getTestBed } from '@angular/core/testing';
|
|
6
|
+
import {
|
|
7
|
+
BrowserDynamicTestingModule,
|
|
8
|
+
platformBrowserDynamicTesting
|
|
9
|
+
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
+
|
|
11
|
+
declare const require: {
|
|
12
|
+
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
+
keys(): string[];
|
|
14
|
+
<T>(id: string): T;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// First, initialize the Angular testing environment.
|
|
19
|
+
getTestBed().initTestEnvironment(
|
|
20
|
+
BrowserDynamicTestingModule,
|
|
21
|
+
platformBrowserDynamicTesting()
|
|
22
|
+
);
|
|
23
|
+
// Then we find all the tests.
|
|
24
|
+
const context = require.context('./', true, /\.spec\.ts$/);
|
|
25
|
+
// And load the modules.
|
|
26
|
+
context.keys().map(context);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/lib",
|
|
6
|
+
"target": "es2020",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"types": [],
|
|
11
|
+
"lib": [
|
|
12
|
+
"dom",
|
|
13
|
+
"es2018"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"exclude": [
|
|
17
|
+
"src/test.ts",
|
|
18
|
+
"**/*.spec.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../out-tsc/spec",
|
|
6
|
+
"types": [
|
|
7
|
+
"jasmine"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/test.ts"
|
|
12
|
+
],
|
|
13
|
+
"include": [
|
|
14
|
+
"**/*.spec.ts",
|
|
15
|
+
"**/*.d.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleWithProviders, NgModule } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@NgModule()
|
|
4
|
+
export class <%= pascal(target) %><%= pascal(libraryName) %>Module {
|
|
5
|
+
static forRoot(): ModuleWithProviders<<%= pascal(target) %><%= pascal(libraryName) %>Module> {
|
|
6
|
+
return {
|
|
7
|
+
ngModule:<%= pascal(target) %><%= pascal(libraryName) %>Module,
|
|
8
|
+
providers: []
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './<%= kebab(target) %>-<%= kebab(libraryName) %>.module';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/index';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { GenerateLibSchema } from './models/generate-lib-schema';
|
|
3
|
+
export default function (schema: GenerateLibSchema): (tree: Tree) => Promise<Rule | undefined>;
|
|
4
|
+
export declare function addLibToWorkspaceIfNotExist(name: string, packagesDir: string): Rule;
|
|
5
|
+
export declare function updateTsConfig(packageName: string, path: string): (host: Tree) => import("@angular-devkit/schematics/src/tree/interface").Tree | undefined;
|
|
6
|
+
export declare function createLibSecondaryEntry(tree: Tree, options: GenerateLibSchema): Promise<Rule>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLibSecondaryEntry = exports.updateTsConfig = exports.addLibToWorkspaceIfNotExist = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const cases = require("../../utils/text");
|
|
7
|
+
const core_1 = require("@angular-devkit/core");
|
|
8
|
+
const generate_lib_1 = require("../../utils/angular-schematic/generate-lib");
|
|
9
|
+
function default_1(schema) {
|
|
10
|
+
return async (tree) => {
|
|
11
|
+
if (schema.override || !(await checkLibExist(schema, tree))) {
|
|
12
|
+
return (0, schematics_1.chain)([createLibrary(schema)]);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.default = default_1;
|
|
17
|
+
async function checkLibExist(options, tree) {
|
|
18
|
+
const packageName = (0, utils_1.kebab)(options.packageName);
|
|
19
|
+
if (options.isSecondaryEntrypoint) {
|
|
20
|
+
const lib = await (0, utils_1.resolveProject)(tree, options.target);
|
|
21
|
+
const ngPackagePath = `${lib?.definition.root}/${packageName}/ng-package.json`;
|
|
22
|
+
const packageInfo = tree.read(ngPackagePath);
|
|
23
|
+
if (packageInfo) {
|
|
24
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, `${lib.name}/${packageName}`));
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const target = await (0, utils_1.resolveProject)(tree, options.packageName, null);
|
|
29
|
+
if (target) {
|
|
30
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, packageName));
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function createLibrary(options) {
|
|
35
|
+
return async (tree) => {
|
|
36
|
+
const target = await (0, utils_1.resolveProject)(tree, options.packageName, null);
|
|
37
|
+
if (!target || options.override) {
|
|
38
|
+
if (options.isModuleTemplate) {
|
|
39
|
+
return createLibFromModuleTemplate(tree, options);
|
|
40
|
+
}
|
|
41
|
+
if (options.isSecondaryEntrypoint) {
|
|
42
|
+
return createLibSecondaryEntry(tree, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, options.packageName));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function resolvePackagesDirFromAngularJson(host) {
|
|
51
|
+
const workspace = await (0, utils_1.getWorkspace)(host);
|
|
52
|
+
const projectFolder = readFirstLibInAngularJson(workspace);
|
|
53
|
+
return projectFolder?.root?.split('/')?.[0] || 'projects';
|
|
54
|
+
}
|
|
55
|
+
function readFirstLibInAngularJson(workspace) {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
+
return Array.from(workspace.projects.values()).find(value => (0, utils_1.isLibrary)(value));
|
|
58
|
+
}
|
|
59
|
+
async function createLibFromModuleTemplate(tree, options) {
|
|
60
|
+
const packagesDir = await resolvePackagesDirFromAngularJson(tree);
|
|
61
|
+
const packageJson = JSON.parse(tree.read('./package.json').toString());
|
|
62
|
+
const abpVersion = packageJson.dependencies['@abp/ng.core'];
|
|
63
|
+
return (0, schematics_1.chain)([
|
|
64
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-package'), [
|
|
65
|
+
(0, schematics_1.applyTemplates)({
|
|
66
|
+
...cases,
|
|
67
|
+
libraryName: options.packageName,
|
|
68
|
+
abpVersion,
|
|
69
|
+
}),
|
|
70
|
+
(0, schematics_1.move)((0, core_1.normalize)(packagesDir)),
|
|
71
|
+
]),
|
|
72
|
+
addLibToWorkspaceIfNotExist(options.packageName, packagesDir),
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
function addLibToWorkspaceIfNotExist(name, packagesDir) {
|
|
76
|
+
return async (tree) => {
|
|
77
|
+
const workspace = await (0, utils_1.getWorkspace)(tree);
|
|
78
|
+
const packageName = (0, utils_1.kebab)(name);
|
|
79
|
+
const isProjectExist = workspace.projects.has(packageName);
|
|
80
|
+
const projectRoot = (0, core_1.join)((0, core_1.normalize)(packagesDir), packageName);
|
|
81
|
+
const pathImportLib = `${packagesDir}/${packageName}`;
|
|
82
|
+
return (0, schematics_1.chain)([
|
|
83
|
+
isProjectExist
|
|
84
|
+
? (0, utils_1.updateWorkspace)(w => {
|
|
85
|
+
w.projects.delete(packageName);
|
|
86
|
+
})
|
|
87
|
+
: (0, schematics_1.noop)(),
|
|
88
|
+
(0, generate_lib_1.addLibToWorkspaceFile)(projectRoot, packageName),
|
|
89
|
+
updateTsConfig(packageName, pathImportLib),
|
|
90
|
+
]);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.addLibToWorkspaceIfNotExist = addLibToWorkspaceIfNotExist;
|
|
94
|
+
function updateTsConfig(packageName, path) {
|
|
95
|
+
return (host) => {
|
|
96
|
+
const files = ['tsconfig.json', 'tsconfig.app.json', 'tsconfig.base.json'];
|
|
97
|
+
const tsConfig = files.find(f => host.exists(f));
|
|
98
|
+
if (!tsConfig) {
|
|
99
|
+
return host;
|
|
100
|
+
}
|
|
101
|
+
const file = new utils_1.JSONFile(host, tsConfig);
|
|
102
|
+
const jsonPath = ['compilerOptions', 'paths', packageName];
|
|
103
|
+
file.modify(jsonPath, [`${path}/src/public-api.ts`]);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
exports.updateTsConfig = updateTsConfig;
|
|
107
|
+
async function createLibSecondaryEntry(tree, options) {
|
|
108
|
+
const targetLib = await (0, utils_1.resolveProject)(tree, options.target);
|
|
109
|
+
const packageName = `${(0, utils_1.kebab)(targetLib.name)}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
110
|
+
const importPath = `${targetLib.definition.root}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
111
|
+
return (0, schematics_1.chain)([
|
|
112
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-secondary-entrypoint'), [
|
|
113
|
+
(0, schematics_1.applyTemplates)({
|
|
114
|
+
...cases,
|
|
115
|
+
libraryName: options.packageName,
|
|
116
|
+
target: targetLib.name,
|
|
117
|
+
}),
|
|
118
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetLib.definition.root)),
|
|
119
|
+
updateTsConfig(packageName, importPath),
|
|
120
|
+
]),
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
exports.createLibSecondaryEntry = createLibSecondaryEntry;
|
|
124
|
+
//# sourceMappingURL=index.js.map
|