@ama-sdk/schematics 11.2.0-prerelease.9 → 11.3.0-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -19
- package/schematics/helpers/read-package.js +1 -1
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
- package/schematics/migrate/index.d.ts.map +1 -1
- package/schematics/migrate/index.js +2 -1
- package/schematics/ng-add/index.js +3 -3
- package/schematics/typescript/core/helpers/copy-referenced-files.d.ts +13 -0
- package/schematics/typescript/core/helpers/copy-referenced-files.d.ts.map +1 -0
- package/schematics/typescript/core/helpers/copy-referenced-files.js +87 -0
- package/schematics/typescript/core/index.d.ts.map +1 -1
- package/schematics/typescript/core/index.js +11 -1
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/schematics",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0-prerelease.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,18 +57,18 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@ama-sdk/core": "^11.
|
|
61
|
-
"@angular-devkit/core": "~18.
|
|
62
|
-
"@angular-devkit/schematics": "~18.
|
|
60
|
+
"@ama-sdk/core": "^11.3.0-prerelease.0",
|
|
61
|
+
"@angular-devkit/core": "~18.2.0",
|
|
62
|
+
"@angular-devkit/schematics": "~18.2.0",
|
|
63
63
|
"@angular-devkit/schematics-cli": "^18.0.5",
|
|
64
|
-
"@angular/cli": "~18.
|
|
65
|
-
"@o3r/schematics": "^11.
|
|
64
|
+
"@angular/cli": "~18.2.0",
|
|
65
|
+
"@o3r/schematics": "^11.3.0-prerelease.0",
|
|
66
66
|
"@openapitools/openapi-generator-cli": "~2.13.0",
|
|
67
|
-
"@schematics/angular": "~18.
|
|
67
|
+
"@schematics/angular": "~18.2.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@angular-devkit/core": "~18.
|
|
71
|
-
"@angular-devkit/schematics": "~18.
|
|
70
|
+
"@angular-devkit/core": "~18.2.0",
|
|
71
|
+
"@angular-devkit/schematics": "~18.2.0",
|
|
72
72
|
"chokidar": "^3.5.2",
|
|
73
73
|
"globby": "^11.1.0",
|
|
74
74
|
"js-yaml": "^4.1.0",
|
|
@@ -79,18 +79,18 @@
|
|
|
79
79
|
"tslib": "^2.6.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@ama-sdk/core": "^11.
|
|
82
|
+
"@ama-sdk/core": "^11.3.0-prerelease.0",
|
|
83
83
|
"@angular-devkit/schematics-cli": "^18.0.5",
|
|
84
|
-
"@angular-eslint/eslint-plugin": "~18.
|
|
85
|
-
"@angular/cli": "~18.
|
|
84
|
+
"@angular-eslint/eslint-plugin": "~18.3.0",
|
|
85
|
+
"@angular/cli": "~18.2.0",
|
|
86
86
|
"@nx/eslint-plugin": "~19.5.0",
|
|
87
87
|
"@nx/jest": "~19.5.0",
|
|
88
|
-
"@o3r/build-helpers": "^11.
|
|
89
|
-
"@o3r/eslint-plugin": "^11.
|
|
90
|
-
"@o3r/schematics": "^11.
|
|
91
|
-
"@o3r/test-helpers": "^11.
|
|
88
|
+
"@o3r/build-helpers": "^11.3.0-prerelease.0",
|
|
89
|
+
"@o3r/eslint-plugin": "^11.3.0-prerelease.0",
|
|
90
|
+
"@o3r/schematics": "^11.3.0-prerelease.0",
|
|
91
|
+
"@o3r/test-helpers": "^11.3.0-prerelease.0",
|
|
92
92
|
"@openapitools/openapi-generator-cli": "~2.13.0",
|
|
93
|
-
"@schematics/angular": "~18.
|
|
93
|
+
"@schematics/angular": "~18.2.0",
|
|
94
94
|
"@stylistic/eslint-plugin-ts": "~2.4.0",
|
|
95
95
|
"@types/jest": "~29.5.2",
|
|
96
96
|
"@types/js-yaml": "^4.0.5",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"cpy-cli": "^5.0.0",
|
|
108
108
|
"eslint": "^8.57.0",
|
|
109
109
|
"eslint-import-resolver-node": "^0.3.9",
|
|
110
|
-
"eslint-plugin-jest": "~28.
|
|
110
|
+
"eslint-plugin-jest": "~28.8.0",
|
|
111
111
|
"eslint-plugin-jsdoc": "~48.11.0",
|
|
112
112
|
"eslint-plugin-prefer-arrow": "~1.2.3",
|
|
113
113
|
"eslint-plugin-unicorn": "^54.0.0",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"tsc-watch": "^6.0.4",
|
|
141
141
|
"yaml-eslint-parser": "^1.2.2"
|
|
142
142
|
},
|
|
143
|
-
"openApiSupportedVersion": "~7.
|
|
143
|
+
"openApiSupportedVersion": "~7.8.0",
|
|
144
144
|
"engines": {
|
|
145
145
|
"node": "^18.19.1 || ^20.11.1 || >=22.0.0"
|
|
146
146
|
},
|
|
@@ -6,7 +6,7 @@ const path = require("node:path");
|
|
|
6
6
|
/** Get generator package.json */
|
|
7
7
|
const readPackageJson = async () => {
|
|
8
8
|
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
9
|
-
return JSON.parse(await node_fs_1.promises.readFile(packageJsonPath, { encoding: '
|
|
9
|
+
return JSON.parse(await node_fs_1.promises.readFile(packageJsonPath, { encoding: 'utf8' }));
|
|
10
10
|
};
|
|
11
11
|
exports.readPackageJson = readPackageJson;
|
|
12
12
|
//# sourceMappingURL=read-package.js.map
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/migrate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/migrate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAsC1D;;;GAGG;AACH,eAAO,MAAM,OAAO,YAAa,8BAA8B,wBAG9D,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.migrate = void 0;
|
|
4
4
|
const schematics_1 = require("@o3r/schematics");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
6
7
|
const update_regen_script_1 = require("../ng-update/typescript/v11.0/update-regen-script");
|
|
7
8
|
const semver_1 = require("semver");
|
|
8
9
|
const is_typescript_project_1 = require("../helpers/is-typescript-project");
|
|
@@ -20,7 +21,7 @@ const tsMigrationMap = {
|
|
|
20
21
|
* @param options
|
|
21
22
|
*/
|
|
22
23
|
function migrateFn(options) {
|
|
23
|
-
const currentVersion =
|
|
24
|
+
const currentVersion = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(__dirname, '..', '..', 'package.json'), { encoding: 'utf8' })).version;
|
|
24
25
|
const to = options.to || currentVersion;
|
|
25
26
|
const minimumVersion = (0, semver_1.minVersion)(to);
|
|
26
27
|
return (tree, context) => {
|
|
@@ -56,7 +56,7 @@ exports.updatePackageJsonScripts = updatePackageJsonScripts;
|
|
|
56
56
|
* @param tree
|
|
57
57
|
*/
|
|
58
58
|
const createOpenApiToolsConfig = (tree) => {
|
|
59
|
-
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: '
|
|
59
|
+
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: 'utf8' }));
|
|
60
60
|
const openApiGeneratorVersion = amaSdkSchematicsPackageJsonContent.openApiSupportedVersion.replace(/\^|~/, '');
|
|
61
61
|
const openApiDefaultStorageDir = '.openapi-generator';
|
|
62
62
|
if (tree.exists(openApiConfigPath)) {
|
|
@@ -85,7 +85,7 @@ const createOpenApiToolsConfig = (tree) => {
|
|
|
85
85
|
*/
|
|
86
86
|
const installOpenApiToolsCli = async (tree, context) => {
|
|
87
87
|
const packageJsonContent = tree.readJson(packageJsonPath);
|
|
88
|
-
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: '
|
|
88
|
+
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: 'utf8' }));
|
|
89
89
|
const amaSdkSchematicsOpenApiCliVersion = amaSdkSchematicsPackageJsonContent.peerDependencies?.['@openapitools/openapi-generator-cli'] || '';
|
|
90
90
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
91
91
|
packageJsonContent.devDependencies = { ...packageJsonContent.devDependencies, '@openapitools/openapi-generator-cli': amaSdkSchematicsOpenApiCliVersion };
|
|
@@ -114,7 +114,7 @@ const registerPackageSchematics = async (tree, context) => {
|
|
|
114
114
|
if (!tree.exists('angular.json')) {
|
|
115
115
|
return () => tree;
|
|
116
116
|
}
|
|
117
|
-
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: '
|
|
117
|
+
const amaSdkSchematicsPackageJsonContent = JSON.parse((0, node_fs_1.readFileSync)(path.resolve(__dirname, '..', '..', 'package.json'), { encoding: 'utf8' }));
|
|
118
118
|
const amaSdkSchematicsVersion = amaSdkSchematicsPackageJsonContent.version?.replace(/^v/, '');
|
|
119
119
|
const schematicsDependencies = ['@o3r/schematics'];
|
|
120
120
|
for (const dependency of schematicsDependencies) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace all the local relative references using the new base relative path
|
|
3
|
+
* @param specContent
|
|
4
|
+
* @param newBaseRelativePath
|
|
5
|
+
*/
|
|
6
|
+
export declare function updateLocalRelativeRefs(specContent: string, newBaseRelativePath: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Copy the local files referenced in the input spec file to the output directory
|
|
9
|
+
* @param specFilePath
|
|
10
|
+
* @param outputDirectory
|
|
11
|
+
*/
|
|
12
|
+
export declare function copyReferencedFiles(specFilePath: string, outputDirectory: string): Promise<string>;
|
|
13
|
+
//# sourceMappingURL=copy-referenced-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-referenced-files.d.ts","sourceRoot":"","sources":["../../../../../schematics/typescript/core/helpers/copy-referenced-files.ts"],"names":[],"mappings":"AA6CA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,UAQvF;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,mBA2BtF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateLocalRelativeRefs = updateLocalRelativeRefs;
|
|
4
|
+
exports.copyReferencedFiles = copyReferencedFiles;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const refMatcher = /\B['"]?[$]ref['"]?\s*:\s*([^#\n]+)/g;
|
|
9
|
+
/**
|
|
10
|
+
* Extract the list of local references from a single spec file content
|
|
11
|
+
* @param specContent
|
|
12
|
+
* @param basePath
|
|
13
|
+
*/
|
|
14
|
+
function extractRefPaths(specContent, basePath) {
|
|
15
|
+
const refs = specContent.match(refMatcher);
|
|
16
|
+
return refs ?
|
|
17
|
+
refs
|
|
18
|
+
.map((capture) => capture.replace(refMatcher, '$1').replace(/['"]/g, ''))
|
|
19
|
+
.filter((refPath) => refPath.startsWith('.'))
|
|
20
|
+
.map((refPath) => (0, node_path_1.join)(basePath, refPath))
|
|
21
|
+
: [];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Recursively extract the list of local references starting from the input spec file
|
|
25
|
+
* @param specFilePath
|
|
26
|
+
* @param referenceFilePath
|
|
27
|
+
* @param visited
|
|
28
|
+
*/
|
|
29
|
+
async function extractRefPathRecursive(specFilePath, referenceFilePath, visited) {
|
|
30
|
+
const resolvedFilePath = (0, node_path_1.resolve)(specFilePath);
|
|
31
|
+
if (!visited.has(resolvedFilePath)) {
|
|
32
|
+
visited.add(resolvedFilePath);
|
|
33
|
+
const specContent = await (0, promises_1.readFile)(specFilePath, { encoding: 'utf8' });
|
|
34
|
+
const refPaths = extractRefPaths(specContent, (0, node_path_1.relative)((0, node_path_1.dirname)(referenceFilePath), (0, node_path_1.dirname)(specFilePath)));
|
|
35
|
+
const recursiveRefPaths = await Promise.all(refPaths.map((refPath) => extractRefPathRecursive((0, node_path_1.join)((0, node_path_1.dirname)(referenceFilePath), refPath), referenceFilePath, visited)));
|
|
36
|
+
return [
|
|
37
|
+
...refPaths,
|
|
38
|
+
...recursiveRefPaths.flat()
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Replace all the local relative references using the new base relative path
|
|
45
|
+
* @param specContent
|
|
46
|
+
* @param newBaseRelativePath
|
|
47
|
+
*/
|
|
48
|
+
function updateLocalRelativeRefs(specContent, newBaseRelativePath) {
|
|
49
|
+
const formatPath = (inputPath) => (inputPath.startsWith('.') ? inputPath : `./${inputPath}`).replace(/\\+/g, '/');
|
|
50
|
+
return specContent.replace(refMatcher, (match, ref) => {
|
|
51
|
+
const refPath = ref.replace(/['"]/g, '');
|
|
52
|
+
return refPath.startsWith('.') ?
|
|
53
|
+
match.replace(refPath, formatPath((0, node_path_1.normalize)(node_path_1.posix.join(newBaseRelativePath.replaceAll(node_path_1.sep, node_path_1.posix.sep), refPath))))
|
|
54
|
+
: match;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Copy the local files referenced in the input spec file to the output directory
|
|
59
|
+
* @param specFilePath
|
|
60
|
+
* @param outputDirectory
|
|
61
|
+
*/
|
|
62
|
+
async function copyReferencedFiles(specFilePath, outputDirectory) {
|
|
63
|
+
const dedupe = (paths) => ([...new Set(paths)]);
|
|
64
|
+
const allRefPaths = await extractRefPathRecursive(specFilePath, specFilePath, new Set());
|
|
65
|
+
const refPaths = dedupe(allRefPaths);
|
|
66
|
+
if (refPaths.length) {
|
|
67
|
+
if ((0, node_fs_1.existsSync)(outputDirectory)) {
|
|
68
|
+
await (0, promises_1.rm)(outputDirectory, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
// Calculate the lowest level base path to keep the same directory structure
|
|
71
|
+
const maxDepth = Math.max(...refPaths.map((refPath) => refPath.split('..').length));
|
|
72
|
+
const basePath = (0, node_path_1.join)(specFilePath, '../'.repeat(maxDepth));
|
|
73
|
+
const baseRelativePath = (0, node_path_1.relative)(basePath, (0, node_path_1.dirname)(specFilePath));
|
|
74
|
+
// Copy the files
|
|
75
|
+
await Promise.all(refPaths.map(async (refPath) => {
|
|
76
|
+
const sourcePath = (0, node_path_1.join)((0, node_path_1.dirname)(specFilePath), refPath);
|
|
77
|
+
const destPath = (0, node_path_1.join)(outputDirectory, baseRelativePath, refPath);
|
|
78
|
+
if (!(0, node_fs_1.existsSync)((0, node_path_1.dirname)(destPath))) {
|
|
79
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(destPath), { recursive: true });
|
|
80
|
+
}
|
|
81
|
+
await (0, promises_1.copyFile)(sourcePath, destPath);
|
|
82
|
+
}));
|
|
83
|
+
return (0, node_path_1.join)(outputDirectory, baseRelativePath);
|
|
84
|
+
}
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=copy-referenced-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/typescript/core/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,IAAI,EAKL,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,UAAU,CAAC;AA2PvE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,YAAa,2CAA2C,wBAG3F,CAAC"}
|
|
@@ -9,6 +9,7 @@ const node_url_1 = require("node:url");
|
|
|
9
9
|
const semver = require("semver");
|
|
10
10
|
const tree_glob_1 = require("../../helpers/tree-glob");
|
|
11
11
|
const open_api_cli_generator_1 = require("../../code-generator/open-api-cli-generator/open-api-cli.generator");
|
|
12
|
+
const copy_referenced_files_1 = require("./helpers/copy-referenced-files");
|
|
12
13
|
const path_extractor_1 = require("./helpers/path-extractor");
|
|
13
14
|
const JAVA_OPTIONS = ['specPath', 'specConfigPath', 'globalProperty', 'outputPath'];
|
|
14
15
|
const OPEN_API_TOOLS_OPTIONS = ['generatorName', 'output', 'inputSpec', 'config', 'globalProperty'];
|
|
@@ -123,11 +124,20 @@ function ngGenerateTypescriptSDKFn(options) {
|
|
|
123
124
|
let specContent;
|
|
124
125
|
if (node_url_1.URL.canParse(generatorOptions.specPath) && (new node_url_1.URL(generatorOptions.specPath)).protocol.startsWith('http')) {
|
|
125
126
|
specContent = await (await fetch(generatorOptions.specPath)).text();
|
|
127
|
+
specContent = (0, copy_referenced_files_1.updateLocalRelativeRefs)(specContent, path.dirname(generatorOptions.specPath));
|
|
126
128
|
}
|
|
127
129
|
else {
|
|
128
130
|
const specPath = path.isAbsolute(generatorOptions.specPath) || !options.directory ?
|
|
129
131
|
generatorOptions.specPath : path.join(options.directory, generatorOptions.specPath);
|
|
130
|
-
specContent = (0, node_fs_1.readFileSync)(specPath, { encoding: '
|
|
132
|
+
specContent = (0, node_fs_1.readFileSync)(specPath, { encoding: 'utf8' }).toString();
|
|
133
|
+
if (path.relative(process.cwd(), specPath).startsWith('..')) {
|
|
134
|
+
// TODO would be better to create files on tree instead of FS
|
|
135
|
+
// https://github.com/AmadeusITGroup/otter/issues/2078
|
|
136
|
+
const newRelativePath = await (0, copy_referenced_files_1.copyReferencedFiles)(specPath, './spec-local-references');
|
|
137
|
+
if (newRelativePath) {
|
|
138
|
+
specContent = (0, copy_referenced_files_1.updateLocalRelativeRefs)(specContent, newRelativePath);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
try {
|
|
133
143
|
JSON.parse(specContent);
|
|
Binary file
|