@rxap/plugin-library 16.0.1-dev.0 → 16.1.0-dev.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/CHANGELOG.md +11 -0
- package/README.md +15 -1
- package/generators.json +10 -0
- package/package.json +6 -6
- package/src/generators/bundle-json-schema/generator.d.ts +4 -0
- package/src/generators/bundle-json-schema/generator.js +88 -0
- package/src/generators/bundle-json-schema/generator.js.map +1 -0
- package/src/generators/bundle-json-schema/index.d.ts +2 -0
- package/src/generators/bundle-json-schema/index.js +8 -0
- package/src/generators/bundle-json-schema/index.js.map +1 -0
- package/src/generators/bundle-json-schema/schema.d.ts +3 -0
- package/src/generators/bundle-json-schema/schema.json +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [16.1.0-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/plugin-library@16.0.1-dev.0...@rxap/plugin-library@16.1.0-dev.0) (2024-02-25)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- add nested definition cleanup ([f9c5637](https://gitlab.com/rxap/packages/commit/f9c5637fdba8ba458443c923c584564761e077ca))
|
|
11
|
+
- cleanup bundled schema ([4af344f](https://gitlab.com/rxap/packages/commit/4af344fa89837f228f04f96166f5b21932b50018))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- add bundle-json-schema generator ([8c4b9d9](https://gitlab.com/rxap/packages/commit/8c4b9d93730290c9b40ecf20490e87de34e6b1d2))
|
|
16
|
+
|
|
6
17
|
## [16.0.1-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/plugin-library@16.0.0...@rxap/plugin-library@16.0.1-dev.0) (2024-02-09)
|
|
7
18
|
|
|
8
19
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ yarn add @rxap/plugin-library
|
|
|
19
19
|
```
|
|
20
20
|
**Install peer dependencies:**
|
|
21
21
|
```bash
|
|
22
|
-
yarn add @nx/devkit@^16.5.0 @rxap/generator-ts-morph@^1.0.1 @rxap/generator-utilities@^1.1.0 @rxap/node-utilities@^1.1.0 @rxap/plugin-angular@^16.1.0 @rxap/plugin-nestjs@^16.1.0 @rxap/plugin-utilities@^16.1.0 @rxap/ts-morph@^1.0.
|
|
22
|
+
yarn add @nx/devkit@^16.5.0 @rxap/generator-ts-morph@^1.0.1 @rxap/generator-utilities@^1.1.0 @rxap/node-utilities@^1.1.0 @rxap/plugin-angular@^16.1.1-dev.0 @rxap/plugin-nestjs@^16.1.0 @rxap/plugin-utilities@^16.1.0 @rxap/ts-morph@^1.1.0-dev.0 @rxap/utilities@^16.0.0 @rxap/workspace-utilities@^16.0.1 handlebars@^4.7.7 nx@^16.5.0 semver@^7.5.3 ts-morph@^18.0.0 tslib@2.6.2
|
|
23
23
|
```
|
|
24
24
|
**Execute the init generator:**
|
|
25
25
|
```bash
|
|
@@ -76,6 +76,13 @@ yarn nx g @rxap/plugin-library:init-publishable
|
|
|
76
76
|
yarn nx g @rxap/plugin-library:expose-as-schematic
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
## bundle-json-schema
|
|
80
|
+
> bundle-json-schema generator
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
yarn nx g @rxap/plugin-library:bundle-json-schema
|
|
84
|
+
```
|
|
85
|
+
|
|
79
86
|
## init
|
|
80
87
|
> Create and update configurations to use rxap package publish concept
|
|
81
88
|
|
|
@@ -124,6 +131,13 @@ yarn nx g @rxap/plugin-library:init-publishable
|
|
|
124
131
|
```bash
|
|
125
132
|
yarn nx g @rxap/plugin-library:expose-as-schematic
|
|
126
133
|
```
|
|
134
|
+
|
|
135
|
+
## bundle-json-schema
|
|
136
|
+
> bundle-json-schema generator
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
yarn nx g @rxap/plugin-library:bundle-json-schema
|
|
140
|
+
```
|
|
127
141
|
# Executors
|
|
128
142
|
|
|
129
143
|
## update-dependencies
|
package/generators.json
CHANGED
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"factory": "./src/generators/expose-as-schematic/generator",
|
|
35
35
|
"schema": "./src/generators/expose-as-schematic/schema.json",
|
|
36
36
|
"description": "expose-as-schematic generator"
|
|
37
|
+
},
|
|
38
|
+
"bundle-json-schema": {
|
|
39
|
+
"factory": "./src/generators/bundle-json-schema/generator",
|
|
40
|
+
"schema": "./src/generators/bundle-json-schema/schema.json",
|
|
41
|
+
"description": "bundle-json-schema generator"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"schematics": {
|
|
@@ -71,6 +76,11 @@
|
|
|
71
76
|
"factory": "./src/generators/expose-as-schematic/index",
|
|
72
77
|
"schema": "./src/generators/expose-as-schematic/schema.json",
|
|
73
78
|
"description": "expose-as-schematic generator"
|
|
79
|
+
},
|
|
80
|
+
"bundle-json-schema": {
|
|
81
|
+
"factory": "./src/generators/bundle-json-schema/index",
|
|
82
|
+
"schema": "./src/generators/bundle-json-schema/schema.json",
|
|
83
|
+
"description": "bundle-json-schema generator"
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "16.0
|
|
2
|
+
"version": "16.1.0-dev.0",
|
|
3
3
|
"name": "@rxap/plugin-library",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@rxap/generator-ts-morph": "^1.0.1",
|
|
15
15
|
"@rxap/generator-utilities": "^1.1.0",
|
|
16
16
|
"@rxap/node-utilities": "^1.1.0",
|
|
17
|
-
"@rxap/plugin-angular": "^16.1.0",
|
|
17
|
+
"@rxap/plugin-angular": "^16.1.1-dev.0",
|
|
18
18
|
"@rxap/plugin-nestjs": "^16.1.0",
|
|
19
19
|
"@rxap/plugin-utilities": "^16.1.0",
|
|
20
|
-
"@rxap/ts-morph": "^1.0.
|
|
20
|
+
"@rxap/ts-morph": "^1.1.0-dev.0",
|
|
21
21
|
"@rxap/utilities": "^16.0.0",
|
|
22
22
|
"@rxap/workspace-utilities": "^16.0.1",
|
|
23
23
|
"handlebars": "^4.7.7",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
"package": "@rxap/plugin-angular",
|
|
65
|
-
"version": "16.1.0"
|
|
65
|
+
"version": "16.1.1-dev.0"
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"package": "@rxap/plugin-nestjs",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"package": "@rxap/ts-morph",
|
|
81
|
-
"version": "1.0.
|
|
81
|
+
"version": "1.1.0-dev.0"
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"package": "@rxap/utilities",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"schematics": "./generators.json",
|
|
103
103
|
"type": "commonjs",
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "58070f2586b30e6bb1a13247cef1330da97279a1",
|
|
105
105
|
"main": "./src/index.js",
|
|
106
106
|
"types": "./src/index.d.ts"
|
|
107
107
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bundleJsonSchemaGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const json_schema_ref_parser_1 = tslib_1.__importDefault(require("@apidevtools/json-schema-ref-parser"));
|
|
6
|
+
const utilities_1 = require("@rxap/utilities");
|
|
7
|
+
const workspace_utilities_1 = require("@rxap/workspace-utilities");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
function bundleJsonSchemaGenerator(tree, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const projectSourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, options.project);
|
|
12
|
+
const workspaceRoot = tree.root;
|
|
13
|
+
for (const file of (0, workspace_utilities_1.SearchFile)(tree, projectSourceRoot)) {
|
|
14
|
+
if (file.path.endsWith('template.schema.json')) {
|
|
15
|
+
const relativePathFromProjectSourceRoot = (0, path_1.dirname)((0, path_1.relative)(projectSourceRoot, file.path));
|
|
16
|
+
const schema = JSON.parse(file.content.toString());
|
|
17
|
+
const bundledSchema = yield json_schema_ref_parser_1.default.bundle(schema, {
|
|
18
|
+
resolve: {
|
|
19
|
+
file: {
|
|
20
|
+
canRead: ({ url }) => {
|
|
21
|
+
if (url.startsWith('http')) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const relativeFromSchemaJsonFile = (0, path_1.relative)(workspaceRoot, url);
|
|
25
|
+
const absoluteFromSourceRoot = (0, path_1.join)(relativePathFromProjectSourceRoot, relativeFromSchemaJsonFile);
|
|
26
|
+
const absoluteFromWorkspaceRoot = (0, path_1.join)(projectSourceRoot, absoluteFromSourceRoot);
|
|
27
|
+
return tree.isFile(absoluteFromWorkspaceRoot);
|
|
28
|
+
},
|
|
29
|
+
read: ({ url }) => {
|
|
30
|
+
const relativeFromSchemaJsonFile = (0, path_1.relative)(workspaceRoot, url);
|
|
31
|
+
const absoluteFromSourceRoot = (0, path_1.join)(relativePathFromProjectSourceRoot, relativeFromSchemaJsonFile);
|
|
32
|
+
const absoluteFromWorkspaceRoot = (0, path_1.join)(projectSourceRoot, absoluteFromSourceRoot);
|
|
33
|
+
return tree.read(absoluteFromWorkspaceRoot).toString();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
removeProperty(bundledSchema, 'definitions');
|
|
39
|
+
removeProperty(bundledSchema, '$id');
|
|
40
|
+
removeProperty(bundledSchema, '$schema');
|
|
41
|
+
fixNestaedDefinitions(bundledSchema);
|
|
42
|
+
tree.write(file.path.replace('template.schema.json', 'schema.json'), JSON.stringify(bundledSchema, null, 2));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.bundleJsonSchemaGenerator = bundleJsonSchemaGenerator;
|
|
48
|
+
function removeProperty(obj, propertyName) {
|
|
49
|
+
const propertyPaths = [];
|
|
50
|
+
for (const { key, propertyPath } of (0, utilities_1.EachProperty)(obj)) {
|
|
51
|
+
if (key === propertyName) {
|
|
52
|
+
propertyPaths.push(propertyPath);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const propertyPath of propertyPaths) {
|
|
56
|
+
if (propertyPath === propertyName) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
(0, utilities_1.RemoveFromObject)(obj, propertyPath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function fixNestaedDefinitions({ definitions }) {
|
|
63
|
+
var _a;
|
|
64
|
+
if (!definitions) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const [key, definition] of Object.entries(definitions)) {
|
|
68
|
+
const nestedDefinitions = [];
|
|
69
|
+
for (const { key, value } of (0, utilities_1.EachProperty)(definition)) {
|
|
70
|
+
if (key === '$ref') {
|
|
71
|
+
nestedDefinitions.push(value);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const nested of nestedDefinitions) {
|
|
75
|
+
const definitionName = nested.replace('#/definitions/', '');
|
|
76
|
+
if (!definitions[definitionName]) {
|
|
77
|
+
console.log(`Definition '${key}' has nested definition '${definitionName}' which is not defined!`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
(_a = definition['definitions']) !== null && _a !== void 0 ? _a : (definition['definitions'] = {});
|
|
81
|
+
definition['definitions'][definitionName] = definitions[definitionName];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
console.log(`Definition '${key}' has nested definitions:`, nestedDefinitions);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = bundleJsonSchemaGenerator;
|
|
88
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/library/src/generators/bundle-json-schema/generator.ts"],"names":[],"mappings":";;;;AAAA,yGAA6D;AAE7D,+CAGyB;AACzB,mEAGmC;AACnC,+BAIc;AAId,SAAsB,yBAAyB,CAC7C,IAAU,EACV,OAAwC;;QAExC,MAAM,iBAAiB,GAAG,IAAA,0CAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,IAAA,gCAAU,EAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE;YACtD,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE;gBAC9C,MAAM,iCAAiC,GAAG,IAAA,cAAO,EAAC,IAAA,eAAQ,EAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACnD,MAAM,aAAa,GAAG,MAAM,gCAAU,CAAC,MAAM,CAAC,MAAM,EAAE;oBACpD,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;gCACnB,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;oCAC1B,OAAO,KAAK,CAAC;iCACd;gCACD,MAAM,0BAA0B,GAAG,IAAA,eAAQ,EAAC,aAAa,E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AAyB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const generator_1 = tslib_1.__importDefault(require("./generator"));
|
|
6
|
+
const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
7
|
+
exports.default = schematic;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/library/src/generators/bundle-json-schema/index.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAChD,oEAAoC;AAEpC,MAAM,SAAS,GAAG,IAAA,2BAAkB,EAAC,mBAAS,CAAC,CAAC;AAChD,kBAAe,SAAS,CAAC"}
|