@ama-sdk/core 11.0.0-prerelease.32 → 11.0.0-prerelease.33
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/cjs/fwk/index.js +0 -1
- package/cjs/utils/index.js +0 -1
- package/esm2015/fwk/index.js +0 -1
- package/esm2015/utils/index.js +0 -1
- package/package.json +5 -16
- package/src/fwk/index.d.ts +0 -1
- package/src/fwk/index.d.ts.map +1 -1
- package/src/fwk/index.js +0 -1
- package/src/fwk/index.js.map +1 -1
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +0 -1
- package/src/utils/index.js.map +1 -1
- package/cjs/fwk/open-api-tools-configuration.js +0 -4
- package/cjs/utils/generators.js +0 -25
- package/cli/clear-index.cjs +0 -35
- package/cli/clear-index.d.cts +0 -3
- package/cli/clear-index.d.cts.map +0 -1
- package/cli/files-pack.cjs +0 -96
- package/cli/files-pack.d.cts +0 -3
- package/cli/files-pack.d.cts.map +0 -1
- package/cli/package.json +0 -3
- package/cli/update-spec-from-npm.cjs +0 -75
- package/cli/update-spec-from-npm.d.cts +0 -3
- package/cli/update-spec-from-npm.d.cts.map +0 -1
- package/esm2015/fwk/open-api-tools-configuration.js +0 -1
- package/esm2015/utils/generators.js +0 -5
- package/src/fwk/open-api-tools-configuration.d.ts +0 -28
- package/src/fwk/open-api-tools-configuration.d.ts.map +0 -1
- package/src/fwk/open-api-tools-configuration.js +0 -2
- package/src/fwk/open-api-tools-configuration.js.map +0 -1
- package/src/utils/generators.d.ts +0 -7
- package/src/utils/generators.d.ts.map +0 -1
- package/src/utils/generators.js +0 -9
- package/src/utils/generators.js.map +0 -1
package/cjs/fwk/index.js
CHANGED
|
@@ -11,7 +11,6 @@ _export_star(require("./errors"), exports);
|
|
|
11
11
|
_export_star(require("./ignore-enum.type"), exports);
|
|
12
12
|
_export_star(require("./logger"), exports);
|
|
13
13
|
_export_star(require("./mocks/index"), exports);
|
|
14
|
-
_export_star(require("./open-api-tools-configuration"), exports);
|
|
15
14
|
_export_star(require("./Reviver"), exports);
|
|
16
15
|
function _export_star(from, to) {
|
|
17
16
|
Object.keys(from).forEach(function(k) {
|
package/cjs/utils/index.js
CHANGED
|
@@ -8,7 +8,6 @@ _export_star(require("./ie11"), exports);
|
|
|
8
8
|
_export_star(require("./json-token"), exports);
|
|
9
9
|
_export_star(require("./mime-types"), exports);
|
|
10
10
|
_export_star(require("./generic-api"), exports);
|
|
11
|
-
_export_star(require("./generators"), exports);
|
|
12
11
|
function _export_star(from, to) {
|
|
13
12
|
Object.keys(from).forEach(function(k) {
|
|
14
13
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/esm2015/fwk/index.js
CHANGED
package/esm2015/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/core",
|
|
3
|
-
"version": "11.0.0-prerelease.
|
|
3
|
+
"version": "11.0.0-prerelease.33",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -67,14 +67,11 @@
|
|
|
67
67
|
"build:esm2020": "tsc -b tsconfig.build.json",
|
|
68
68
|
"postbuild": "yarn cpy './package.json' dist && patch-package-json-main",
|
|
69
69
|
"prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy 'collection.json' dist",
|
|
70
|
-
"build:cli": "tsc -b tsconfig.cli.json --pretty && yarn generate-cjs-manifest",
|
|
71
70
|
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
|
|
72
71
|
"prepare:publish": "prepare-publish ./dist"
|
|
73
72
|
},
|
|
74
73
|
"dependencies": {
|
|
75
74
|
"@swc/helpers": "~0.5.0",
|
|
76
|
-
"chokidar": "^3.5.2",
|
|
77
|
-
"minimist": "^1.2.6",
|
|
78
75
|
"tslib": "^2.6.2",
|
|
79
76
|
"uuid": "^9.0.0"
|
|
80
77
|
},
|
|
@@ -82,9 +79,8 @@
|
|
|
82
79
|
"@angular-devkit/schematics": "~17.3.0",
|
|
83
80
|
"@angular/cli": "~17.3.0",
|
|
84
81
|
"@angular/common": "~17.3.0",
|
|
85
|
-
"@o3r/schematics": "^11.0.0-prerelease.
|
|
82
|
+
"@o3r/schematics": "^11.0.0-prerelease.33",
|
|
86
83
|
"@schematics/angular": "~17.3.0",
|
|
87
|
-
"globby": "^11.1.0",
|
|
88
84
|
"isomorphic-fetch": "^3.0.0",
|
|
89
85
|
"rxjs": "^7.8.1",
|
|
90
86
|
"typescript": "~5.4.2"
|
|
@@ -123,15 +119,14 @@
|
|
|
123
119
|
"@angular/core": "~17.3.0",
|
|
124
120
|
"@nx/eslint-plugin": "~18.3.0",
|
|
125
121
|
"@nx/jest": "~18.3.0",
|
|
126
|
-
"@o3r/build-helpers": "^11.0.0-prerelease.
|
|
127
|
-
"@o3r/eslint-plugin": "^11.0.0-prerelease.
|
|
128
|
-
"@o3r/test-helpers": "^11.0.0-prerelease.
|
|
122
|
+
"@o3r/build-helpers": "^11.0.0-prerelease.33",
|
|
123
|
+
"@o3r/eslint-plugin": "^11.0.0-prerelease.33",
|
|
124
|
+
"@o3r/test-helpers": "^11.0.0-prerelease.33",
|
|
129
125
|
"@schematics/angular": "~17.3.0",
|
|
130
126
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
|
131
127
|
"@swc/cli": "~0.3.0",
|
|
132
128
|
"@swc/core": "~1.5.24",
|
|
133
129
|
"@types/jest": "~29.5.2",
|
|
134
|
-
"@types/minimist": "^1.2.2",
|
|
135
130
|
"@types/node": "^20.0.0",
|
|
136
131
|
"@types/uuid": "^9.0.0",
|
|
137
132
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
@@ -144,7 +139,6 @@
|
|
|
144
139
|
"eslint-plugin-jsdoc": "~48.2.1",
|
|
145
140
|
"eslint-plugin-prefer-arrow": "~1.2.3",
|
|
146
141
|
"eslint-plugin-unicorn": "^51.0.1",
|
|
147
|
-
"globby": "^11.1.0",
|
|
148
142
|
"isomorphic-fetch": "~3.0.0",
|
|
149
143
|
"jest": "~29.7.0",
|
|
150
144
|
"jest-junit": "~16.0.0",
|
|
@@ -164,11 +158,6 @@
|
|
|
164
158
|
"node": ">=18.0.0"
|
|
165
159
|
},
|
|
166
160
|
"schematics": "./collection.json",
|
|
167
|
-
"bin": {
|
|
168
|
-
"amasdk-clear-index": "./cli/clear-index.cjs",
|
|
169
|
-
"amasdk-files-pack": "./cli/files-pack.cjs",
|
|
170
|
-
"amasdk-update-spec-from-npm": "./cli/update-spec-from-npm.cjs"
|
|
171
|
-
},
|
|
172
161
|
"contributors": [
|
|
173
162
|
{
|
|
174
163
|
"name": "Yannick Adam",
|
package/src/fwk/index.d.ts
CHANGED
package/src/fwk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
package/src/fwk/index.js
CHANGED
package/src/fwk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fwk/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
package/src/utils/index.d.ts
CHANGED
package/src/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/src/utils/index.js
CHANGED
package/src/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/cjs/utils/generators.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// TODO: Change to `openapi` in v11 (ref: #1745)
|
|
2
|
-
/** Name of the specification file copied locally (without extension) */ "use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
function _export(target, all) {
|
|
7
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
LOCAL_SPEC_FILENAME: function() {
|
|
14
|
-
return LOCAL_SPEC_FILENAME;
|
|
15
|
-
},
|
|
16
|
-
SPEC_JSON_EXTENSION: function() {
|
|
17
|
-
return SPEC_JSON_EXTENSION;
|
|
18
|
-
},
|
|
19
|
-
SPEC_YAML_EXTENSION: function() {
|
|
20
|
-
return SPEC_YAML_EXTENSION;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var LOCAL_SPEC_FILENAME = 'swagger-spec';
|
|
24
|
-
var SPEC_YAML_EXTENSION = 'yaml';
|
|
25
|
-
var SPEC_JSON_EXTENSION = 'yaml';
|
package/cli/clear-index.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/*
|
|
4
|
-
* Remove deleted models' exports
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const minimist = require("minimist");
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const node_path_1 = require("node:path");
|
|
10
|
-
const argv = minimist(process.argv.slice(2));
|
|
11
|
-
const { help } = argv;
|
|
12
|
-
const baseDir = (0, node_path_1.resolve)(process.cwd(), 'src', 'models', 'base');
|
|
13
|
-
if (help) {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.log(`Remove the index files that are no longer necessary after the deletion of the associated model.
|
|
16
|
-
Usage: amasdk-clear-index
|
|
17
|
-
`);
|
|
18
|
-
process.exit(0);
|
|
19
|
-
}
|
|
20
|
-
void (async () => {
|
|
21
|
-
const models = await node_fs_1.promises.readdir(baseDir);
|
|
22
|
-
const shouldRemoveModels = (await Promise.all(models
|
|
23
|
-
.filter((file) => (0, node_fs_1.statSync)((0, node_path_1.resolve)(baseDir, file)).isDirectory())
|
|
24
|
-
.map(async (model) => {
|
|
25
|
-
const files = await node_fs_1.promises.readdir((0, node_path_1.resolve)(baseDir, model));
|
|
26
|
-
return { model, removeIndex: files.length === 1 };
|
|
27
|
-
}))).filter(({ removeIndex }) => removeIndex)
|
|
28
|
-
.map(({ model }) => model);
|
|
29
|
-
await Promise.all(shouldRemoveModels
|
|
30
|
-
.map((model) => {
|
|
31
|
-
console.warn(`Removing ${model} model`);
|
|
32
|
-
return node_fs_1.promises.unlink((0, node_path_1.resolve)(baseDir, model, 'index.ts'));
|
|
33
|
-
}));
|
|
34
|
-
})();
|
|
35
|
-
//# sourceMappingURL=clear-index.cjs.map
|
package/cli/clear-index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clear-index.d.cts","sourceRoot":"","sources":["../../cli/clear-index.cts"],"names":[],"mappings":""}
|
package/cli/files-pack.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/*
|
|
4
|
-
* Update the Typescript SDK Package to expose the sub modules
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const node_fs_1 = require("node:fs");
|
|
8
|
-
const minimist = require("minimist");
|
|
9
|
-
const path = require("node:path");
|
|
10
|
-
const node_fs_2 = require("node:fs");
|
|
11
|
-
const globby = require("globby");
|
|
12
|
-
const argv = minimist(process.argv.slice(2));
|
|
13
|
-
const distFolder = argv.dist || 'dist';
|
|
14
|
-
const baseDir = argv.cwd && path.resolve(process.cwd(), argv.cwd) || process.cwd();
|
|
15
|
-
const { help, watch, noExports } = argv;
|
|
16
|
-
if (help) {
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
console.log(`Prepare the dist folder for publication. This will copy necessary files from src and update the exports in package.json.
|
|
19
|
-
Usage: amasdk-files-pack [--exports] [--watch]
|
|
20
|
-
|
|
21
|
-
--exports Update the exports in package.json. (Default: true)
|
|
22
|
-
--watch Watch for files changes and run the updates
|
|
23
|
-
`);
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
const files = [
|
|
27
|
-
{ glob: 'README.md', cwdForCopy: baseDir },
|
|
28
|
-
{ glob: 'LICENSE', cwdForCopy: baseDir },
|
|
29
|
-
{ glob: 'package.json', cwdForCopy: baseDir },
|
|
30
|
-
{ glob: 'src/**/package.json', cwdForCopy: path.join(baseDir, 'src') }
|
|
31
|
-
];
|
|
32
|
-
/** Update package.json exports */
|
|
33
|
-
const updateExports = async () => {
|
|
34
|
-
const packageJson = JSON.parse(await node_fs_2.promises.readFile(path.join(baseDir, 'package.json'), { encoding: 'utf8' }));
|
|
35
|
-
const packageJsonFiles = globby.sync(path.posix.join(distFolder, '*', '**', 'package.json'), { absolute: true });
|
|
36
|
-
packageJson.exports = packageJson.exports || {};
|
|
37
|
-
for (const packageJsonFile of packageJsonFiles) {
|
|
38
|
-
try {
|
|
39
|
-
const subPackageJson = JSON.parse(await node_fs_2.promises.readFile(packageJsonFile, { encoding: 'utf8' }));
|
|
40
|
-
const folder = './' + path.relative(path.join(baseDir, distFolder), path.dirname(packageJsonFile)).replace(/[/\\]+/g, '/');
|
|
41
|
-
packageJson.exports[folder] = packageJson.exports[folder] || {};
|
|
42
|
-
Object.entries(subPackageJson).forEach(([key, value]) => {
|
|
43
|
-
if (['name', 'sideEffects'].includes(key)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
packageJson.exports[folder][key] = './' + path.relative(path.join(baseDir, distFolder), path.resolve(path.dirname(packageJsonFile), value)).replace(/[/\\]+/g, '/');
|
|
47
|
-
});
|
|
48
|
-
packageJson.exports[folder].import = packageJson.exports[folder].module || packageJson.exports[folder].esm2020 || packageJson.exports[folder].esm2015 || packageJson.exports[folder].node;
|
|
49
|
-
packageJson.exports[folder].require = packageJson.exports[folder].node;
|
|
50
|
-
packageJson.exports[folder].main = packageJson.exports[folder].import || packageJson.exports[folder].require;
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
if (watch) {
|
|
54
|
-
console.warn(`Exception in ${packageJsonFile}`, e);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
delete packageJson.scripts;
|
|
62
|
-
await node_fs_2.promises.writeFile(path.join(baseDir, distFolder, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
63
|
-
};
|
|
64
|
-
void (async () => {
|
|
65
|
-
const copyToDist = (file, cwdForCopy) => {
|
|
66
|
-
const distFile = path.resolve(baseDir, distFolder, path.relative(cwdForCopy, file));
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
console.log(`${file} copied to ${distFile}`);
|
|
69
|
-
try {
|
|
70
|
-
(0, node_fs_1.mkdirSync)(path.dirname(distFile), { recursive: true });
|
|
71
|
-
}
|
|
72
|
-
catch { /* ignore error */ }
|
|
73
|
-
return (0, node_fs_1.copyFileSync)(file, distFile);
|
|
74
|
-
};
|
|
75
|
-
// Move files into the dist folder
|
|
76
|
-
const copies = files.map(async ({ glob, cwdForCopy }) => {
|
|
77
|
-
return watch ?
|
|
78
|
-
Promise.resolve().then(() => require('chokidar')).then((chokidar) => chokidar.watch(glob, { cwd: baseDir }))
|
|
79
|
-
.then((watcher) => watcher.on('all', async (event, file) => {
|
|
80
|
-
if (event !== 'unlink' && event !== 'unlinkDir') {
|
|
81
|
-
copyToDist(file, cwdForCopy);
|
|
82
|
-
if (!noExports) {
|
|
83
|
-
await updateExports();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
})) :
|
|
87
|
-
globby.sync(glob)
|
|
88
|
-
.forEach((file) => copyToDist(file, cwdForCopy));
|
|
89
|
-
});
|
|
90
|
-
await Promise.all(copies);
|
|
91
|
-
// Edit package.json exports
|
|
92
|
-
if (!noExports && !watch) {
|
|
93
|
-
await updateExports();
|
|
94
|
-
}
|
|
95
|
-
})();
|
|
96
|
-
//# sourceMappingURL=files-pack.cjs.map
|
package/cli/files-pack.d.cts
DELETED
package/cli/files-pack.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"files-pack.d.cts","sourceRoot":"","sources":["../../cli/files-pack.cts"],"names":[],"mappings":""}
|
package/cli/package.json
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/*
|
|
4
|
-
* Update the OpenAPI spec from an NPM package
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const minimist = require("minimist");
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const node_module_1 = require("node:module");
|
|
10
|
-
const node_path_1 = require("node:path");
|
|
11
|
-
const promises_1 = require("node:fs/promises");
|
|
12
|
-
const core_1 = require("@ama-sdk/core");
|
|
13
|
-
const argv = minimist(process.argv.slice(2));
|
|
14
|
-
const packageName = argv._[0];
|
|
15
|
-
const { help, output, 'package-path': packagePath, quiet } = argv;
|
|
16
|
-
const openApiConfigDefaultPath = './openapitools.json';
|
|
17
|
-
const noop = () => undefined;
|
|
18
|
-
const logger = quiet ? { error: noop, warn: noop, log: noop, info: noop, debug: noop } : console;
|
|
19
|
-
const SPEC_YML_EXTENSION = 'yml';
|
|
20
|
-
const DEFAULT_SPEC_EXPORT_PATH_IN_NPM_MODULE = 'openapi';
|
|
21
|
-
const supportedExtensions = [core_1.SPEC_JSON_EXTENSION, core_1.SPEC_YAML_EXTENSION, SPEC_YML_EXTENSION];
|
|
22
|
-
if (help) {
|
|
23
|
-
// eslint-disable-next-line no-console
|
|
24
|
-
console.log(`This script can be used to update your local spec file from a given locally installed npm package.
|
|
25
|
-
Usage: amasdk-update-spec-from-npm <package-name> [--package-path] [--output] [--quiet]
|
|
26
|
-
|
|
27
|
-
package-name The full identifier of the npm package (e.g. @my-scope/my-package)
|
|
28
|
-
--package-path The relative path inside the npm package where to find the spec file (default: './openapi.yml')
|
|
29
|
-
--output The path where the spec file should be copied (default: './${core_1.LOCAL_SPEC_FILENAME}.${core_1.SPEC_YAML_EXTENSION}')
|
|
30
|
-
--quiet Don't log anything
|
|
31
|
-
`);
|
|
32
|
-
process.exit(0);
|
|
33
|
-
}
|
|
34
|
-
if (!packageName) {
|
|
35
|
-
logger.error('Need to provide packageName, use `amasdk-update-spec-from-npm --help` for more information');
|
|
36
|
-
process.exit(-1);
|
|
37
|
-
}
|
|
38
|
-
void (async () => {
|
|
39
|
-
let specSourcePath;
|
|
40
|
-
const appRequire = (0, node_module_1.createRequire)(node_path_1.posix.join(process.cwd(), 'package.json'));
|
|
41
|
-
const packageJsonPath = appRequire.resolve(`${packageName}/package.json`);
|
|
42
|
-
if (!packagePath) {
|
|
43
|
-
const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, { encoding: 'utf8' }));
|
|
44
|
-
const exportMatcher = new RegExp(`^\\./${DEFAULT_SPEC_EXPORT_PATH_IN_NPM_MODULE}\\.(?:${supportedExtensions.join('|')})$`);
|
|
45
|
-
const matchingExport = packageJson.exports && Object.keys(packageJson.exports).find((exportPath) => exportMatcher.test(exportPath));
|
|
46
|
-
if (matchingExport) {
|
|
47
|
-
specSourcePath = appRequire.resolve(node_path_1.posix.join(packageName, matchingExport));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
specSourcePath = packageJsonPath.replace(/package.json$/, packagePath);
|
|
52
|
-
}
|
|
53
|
-
if (!specSourcePath || !(0, node_fs_1.existsSync)(specSourcePath)) {
|
|
54
|
-
logger.error(`Unable to find source spec from ${packageName}, please make sure it is correctly exported in package.json`);
|
|
55
|
-
process.exit(-2);
|
|
56
|
-
}
|
|
57
|
-
let specDestinationPath = output;
|
|
58
|
-
if (!specDestinationPath) {
|
|
59
|
-
let specSourceExtension = (0, node_path_1.extname)(specSourcePath);
|
|
60
|
-
if (specSourceExtension === `.${SPEC_YML_EXTENSION}`) {
|
|
61
|
-
specSourceExtension = `.${core_1.SPEC_YAML_EXTENSION}`;
|
|
62
|
-
}
|
|
63
|
-
specDestinationPath = `./${core_1.LOCAL_SPEC_FILENAME}${specSourceExtension}`;
|
|
64
|
-
if ((0, node_fs_1.existsSync)(openApiConfigDefaultPath)) {
|
|
65
|
-
const openApiConfig = JSON.parse(await (0, promises_1.readFile)(openApiConfigDefaultPath, { encoding: 'utf8' }));
|
|
66
|
-
const generators = Object.values(openApiConfig['generator-cli']?.generators ?? {});
|
|
67
|
-
if (generators.length === 1 && generators[0].inputSpec && (0, node_path_1.extname)(generators[0].inputSpec) === specSourceExtension) {
|
|
68
|
-
specDestinationPath = generators[0].inputSpec;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
logger.info(`Updating spec file from "${specSourcePath}" to "${specDestinationPath}" (CWD: "${process.cwd()}")`);
|
|
73
|
-
await (0, promises_1.copyFile)(specSourcePath, specDestinationPath);
|
|
74
|
-
})();
|
|
75
|
-
//# sourceMappingURL=update-spec-from-npm.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-spec-from-npm.d.cts","sourceRoot":"","sources":["../../cli/update-spec-from-npm.cts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/** Configuration of an Open API generator */ /** Global configuration of Open API Tools */ export { };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// TODO: Change to `openapi` in v11 (ref: #1745)
|
|
2
|
-
/** Name of the specification file copied locally (without extension) */ export var LOCAL_SPEC_FILENAME = 'swagger-spec';
|
|
3
|
-
/** Extension of the Specification file in YAML format */ export var SPEC_YAML_EXTENSION = 'yaml';
|
|
4
|
-
// TODO: Change to `json` in v11 (ref: #1745)
|
|
5
|
-
/** Extension of the Specification file in JSON format */ export var SPEC_JSON_EXTENSION = 'yaml';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** Configuration of an Open API generator */
|
|
2
|
-
export interface OpenApiToolsGenerator {
|
|
3
|
-
/** Location of the OpenAPI spec, as URL or file */
|
|
4
|
-
inputSpec: string;
|
|
5
|
-
/** Output path for the generated SDK */
|
|
6
|
-
output: string;
|
|
7
|
-
/** Generator to use */
|
|
8
|
-
generatorName: string;
|
|
9
|
-
/** Path to configuration file. It can be JSON or YAML */
|
|
10
|
-
config?: string;
|
|
11
|
-
/** Sets specified global properties */
|
|
12
|
-
globalProperty?: string | Record<string, any>;
|
|
13
|
-
}
|
|
14
|
-
/** Global configuration of Open API generators */
|
|
15
|
-
export interface OpenApiToolsGeneratorCli {
|
|
16
|
-
/** Open API version */
|
|
17
|
-
version: string;
|
|
18
|
-
/** Location of the generator JAR file */
|
|
19
|
-
storageDir?: string;
|
|
20
|
-
/** Generators configuration */
|
|
21
|
-
generators: Record<string, OpenApiToolsGenerator>;
|
|
22
|
-
}
|
|
23
|
-
/** Global configuration of Open API Tools */
|
|
24
|
-
export interface OpenApiToolsConfiguration {
|
|
25
|
-
/** Generators CLI configuration */
|
|
26
|
-
'generator-cli': OpenApiToolsGeneratorCli;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=open-api-tools-configuration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-tools-configuration.d.ts","sourceRoot":"","sources":["../../../src/fwk/open-api-tools-configuration.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/C;AAED,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACnD;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC,mCAAmC;IAEnC,eAAe,EAAE,wBAAwB,CAAC;CAC3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-tools-configuration.js","sourceRoot":"","sources":["../../../src/fwk/open-api-tools-configuration.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Name of the specification file copied locally (without extension) */
|
|
2
|
-
export declare const LOCAL_SPEC_FILENAME = "swagger-spec";
|
|
3
|
-
/** Extension of the Specification file in YAML format */
|
|
4
|
-
export declare const SPEC_YAML_EXTENSION = "yaml";
|
|
5
|
-
/** Extension of the Specification file in JSON format */
|
|
6
|
-
export declare const SPEC_JSON_EXTENSION = "yaml";
|
|
7
|
-
//# sourceMappingURL=generators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../../src/utils/generators.ts"],"names":[],"mappings":"AACA,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAG1C,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,SAAS,CAAC"}
|
package/src/utils/generators.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// TODO: Change to `openapi` in v11 (ref: #1745)
|
|
2
|
-
/** Name of the specification file copied locally (without extension) */
|
|
3
|
-
export const LOCAL_SPEC_FILENAME = 'swagger-spec';
|
|
4
|
-
/** Extension of the Specification file in YAML format */
|
|
5
|
-
export const SPEC_YAML_EXTENSION = 'yaml';
|
|
6
|
-
// TODO: Change to `json` in v11 (ref: #1745)
|
|
7
|
-
/** Extension of the Specification file in JSON format */
|
|
8
|
-
export const SPEC_JSON_EXTENSION = 'yaml';
|
|
9
|
-
//# sourceMappingURL=generators.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../src/utils/generators.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAElD,yDAAyD;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,6CAA6C;AAC7C,yDAAyD;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC"}
|