@ama-sdk/schematics 10.3.0 → 10.3.3

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 CHANGED
@@ -242,6 +242,18 @@ yarn schematics @ama-sdk/schematics:typescript-core --generator-key example-sdk
242
242
  > The values provided by the parameter `--global-property` will actually be merged with the values of `globalProperty` from
243
243
  > `openapitools.json` (rather than override them like the other properties).
244
244
 
245
+ ### Migration
246
+
247
+ To help to apply changes on the Shell part of the SDK repository, a `migrate` schematic is exposed:
248
+
249
+ ```shell
250
+ yarn schematics @ama-sdk/schematics:migrate --from 10.0.0 [--to 11.0.0]
251
+ ```
252
+
253
+ > [!NOTE]
254
+ > - The `--from` parameter is mandatory to provide the version of the original `@ama-sdk/schematics` package from which the rules should be run.
255
+ > - The *optional* `--to` parameter allows to indicate a version until which the rules should be run. The current installed version will be used if not provided.
256
+
245
257
  ### Debug
246
258
 
247
259
  The OpenApi generator extracts an enhanced JSON data model from the specification YAML and uses this data model to feed the templates to generate the code.
package/collection.json CHANGED
@@ -7,6 +7,11 @@
7
7
  "schema": "./schematics/ng-add/schema.json",
8
8
  "aliases": ["install", "i"]
9
9
  },
10
+ "migrate": {
11
+ "description": "Execute migration scripts between 2 versions.",
12
+ "factory": "./schematics/migrate/index#migrate",
13
+ "schema": "./schematics/migrate/schema.json"
14
+ },
10
15
  "typescript-mock": {
11
16
  "description": "Generate an api mock into the project.",
12
17
  "factory": "./schematics/typescript/mock/index#ngGenerateMock",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/schematics",
3
- "version": "10.3.0",
3
+ "version": "10.3.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -48,12 +48,12 @@
48
48
  }
49
49
  },
50
50
  "peerDependencies": {
51
- "@ama-sdk/core": "^10.3.0",
51
+ "@ama-sdk/core": "^10.3.3",
52
52
  "@angular-devkit/core": "~17.3.0",
53
53
  "@angular-devkit/schematics": "~17.3.0",
54
54
  "@angular-devkit/schematics-cli": "^17.0.1",
55
55
  "@angular/cli": "^17.0.1",
56
- "@o3r/schematics": "^10.3.0",
56
+ "@o3r/schematics": "^10.3.3",
57
57
  "@openapitools/openapi-generator-cli": "~2.13.0",
58
58
  "@schematics/angular": "~17.3.0"
59
59
  },
@@ -67,16 +67,16 @@
67
67
  "tslib": "^2.6.2"
68
68
  },
69
69
  "devDependencies": {
70
- "@ama-sdk/core": "^10.3.0",
70
+ "@ama-sdk/core": "^10.3.3",
71
71
  "@angular-devkit/schematics-cli": "~17.3.0",
72
72
  "@angular-eslint/eslint-plugin": "~17.3.0",
73
73
  "@angular/cli": "~17.3.0",
74
74
  "@nx/eslint-plugin": "~18.3.0",
75
75
  "@nx/jest": "~18.3.0",
76
- "@o3r/build-helpers": "^10.3.0",
77
- "@o3r/eslint-plugin": "^10.3.0",
78
- "@o3r/schematics": "^10.3.0",
79
- "@o3r/test-helpers": "^10.3.0",
76
+ "@o3r/build-helpers": "^10.3.3",
77
+ "@o3r/eslint-plugin": "^10.3.3",
78
+ "@o3r/schematics": "^10.3.3",
79
+ "@o3r/test-helpers": "^10.3.3",
80
80
  "@openapitools/openapi-generator-cli": "~2.13.0",
81
81
  "@schematics/angular": "~17.3.0",
82
82
  "@stylistic/eslint-plugin-ts": "^1.5.4",
@@ -0,0 +1,8 @@
1
+ import type { Tree } from '@angular-devkit/schematics';
2
+ /**
3
+ * Determine if the targeted SDK is typescript based
4
+ * @param tree Schematic Tree
5
+ * @param pathInTree Path to the SDK in the tree
6
+ */
7
+ export declare const isTypescriptSdk: (tree: Tree, pathInTree?: string) => boolean;
8
+ //# sourceMappingURL=is-typescript-project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-typescript-project.d.ts","sourceRoot":"","sources":["../../../schematics/helpers/is-typescript-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,eAAe,SAAU,IAAI,iCAIzC,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTypescriptSdk = void 0;
4
+ /**
5
+ * Determine if the targeted SDK is typescript based
6
+ * @param tree Schematic Tree
7
+ * @param pathInTree Path to the SDK in the tree
8
+ */
9
+ const isTypescriptSdk = (tree, pathInTree = '/') => {
10
+ return tree.getDir(pathInTree)
11
+ .subfiles
12
+ .some((filePath) => /tsconfig[^/\\]*\.json$/.test(filePath));
13
+ };
14
+ exports.isTypescriptSdk = isTypescriptSdk;
15
+ //# sourceMappingURL=is-typescript-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-typescript-project.js","sourceRoot":"","sources":["../../../schematics/helpers/is-typescript-project.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,IAAU,EAAE,UAAU,GAAG,GAAG,EAAE,EAAE;IAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;SAC3B,QAAQ;SACR,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B"}
@@ -0,0 +1,8 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
2
+ import { MigrateSchematicsSchemaOptions } from './schema';
3
+ /**
4
+ * Facilitate the migration of a version to another by the run of migration rules
5
+ * @param options
6
+ */
7
+ export declare const migrate: (options: MigrateSchematicsSchemaOptions) => () => Promise<Rule>;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;AA8B1D;;;GAGG;AACH,eAAO,MAAM,OAAO,YAAa,8BAA8B,wBAG9D,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrate = void 0;
4
+ const schematics_1 = require("@o3r/schematics");
5
+ const node_path_1 = require("node:path");
6
+ const semver_1 = require("semver");
7
+ const is_typescript_project_1 = require("../helpers/is-typescript-project");
8
+ const tsMigrationMap = {};
9
+ /**
10
+ * Facilitate the migration of a version to another by the run of migration rules
11
+ * @param options
12
+ */
13
+ function migrateFn(options) {
14
+ const currentVersion = JSON.parse(require((0, node_path_1.resolve)(__dirname, '..', '..', 'package.json'))).version;
15
+ const to = options.to || currentVersion;
16
+ const minimumVersion = (0, semver_1.minVersion)(to);
17
+ return (tree, context) => {
18
+ if (minimumVersion && (0, semver_1.gt)(minimumVersion, currentVersion)) {
19
+ context.logger.warn(`The specified range "${to}" has a minimum supported version higher than the current version of @ama-sdk/schematics (${currentVersion}).` +
20
+ ' The migration may not have any effect.');
21
+ }
22
+ const workingDirectory = options?.projectName && (0, schematics_1.getWorkspaceConfig)(tree)?.projects[options.projectName]?.root || '/';
23
+ const runMigrateSchematic = (0, is_typescript_project_1.isTypescriptSdk)(tree, workingDirectory) ? (0, schematics_1.getMigrationRuleRunner)(tsMigrationMap, { logger: context.logger }) : undefined;
24
+ return runMigrateSchematic?.({ from: options.from, to });
25
+ };
26
+ }
27
+ /**
28
+ * Facilitate the migration of a version to another by the run of migration rules
29
+ * @param options
30
+ */
31
+ const migrate = (options) => async () => {
32
+ const { createSchematicWithMetricsIfInstalled } = await Promise.resolve().then(() => require('@o3r/schematics'));
33
+ return createSchematicWithMetricsIfInstalled(migrateFn)(options);
34
+ };
35
+ exports.migrate = migrate;
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/migrate/index.ts"],"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C,KAAK,IAAI,EAAE;IAC7E,MAAM,EAAE,qCAAqC,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;IAClF,OAAO,qCAAqC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB"}
@@ -0,0 +1,10 @@
1
+ /** Schematic Option */
2
+ export interface MigrateSchematicsSchemaOptions {
3
+ /** Starting version from which the migration scripts are executed */
4
+ from: string;
5
+ /** Version of the package to migrate to (will use the current version if not specified) */
6
+ to?: string;
7
+ /** Project name */
8
+ projectName?: string | undefined;
9
+ }
10
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/migrate/schema.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,MAAM,WAAW,8BAA8B;IAC7C,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../schematics/migrate/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "MigrateSchematicsSchema",
4
+ "title": "Execute migration scripts between 2 versions",
5
+ "description": "Schematics to migrate from a specific version to another one",
6
+ "properties": {
7
+ "from": {
8
+ "type": "string",
9
+ "description": "Starting version from which the migration scripts are executed",
10
+ "x-prompt": "What was the original version before migration?"
11
+ },
12
+ "to": {
13
+ "type": "string",
14
+ "description": "Version of the package to migrate to (will use the current version if not specified)"
15
+ },
16
+ "projectName": {
17
+ "type": "string",
18
+ "description": "Project name (in case it is applied to a module from an Angular Project)",
19
+ "$default": {
20
+ "$source": "projectName"
21
+ }
22
+ }
23
+ },
24
+ "additionalProperties": true,
25
+ "required": [
26
+ "from"
27
+ ]
28
+ }
@@ -1,4 +1,4 @@
1
- import { Rule } from '@angular-devkit/schematics';
1
+ import type { Rule } from '@angular-devkit/schematics';
2
2
  /**
3
3
  * update of Otter library V10.0
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-update/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAQ,MAAM,4BAA4B,CAAC;AAWxD;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAQlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-update/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAIvD;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAQlC"}
@@ -4,19 +4,13 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.updateV10_0 = void 0;
6
6
  const typescript_1 = require("./typescript");
7
- /**
8
- * Determine if the script is run in a Typescript SDK
9
- * @param tree
10
- */
11
- const isTypescriptSdk = (tree) => {
12
- return tree.exists('/tsconfig.json');
13
- };
7
+ const is_typescript_project_1 = require("../helpers/is-typescript-project");
14
8
  /**
15
9
  * update of Otter library V10.0
16
10
  */
17
11
  function updateV10_0() {
18
12
  return (tree, context) => {
19
- if (isTypescriptSdk(tree)) {
13
+ if ((0, is_typescript_project_1.isTypescriptSdk)(tree)) {
20
14
  return (0, typescript_1.updateV10_0)()(tree, context);
21
15
  }
22
16
  return tree;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-update/index.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,8BAA8B;;;AAG9B,6CAA4D;AAE5D;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,IAAU,EAAE,EAAE;IACrC,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAA,wBAAa,GAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AARD,kCAQC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-update/index.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,8BAA8B;;;AAG9B,6CAA4D;AAC5D,4EAAmE;AAEnE;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,IAAA,uCAAe,EAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAA,wBAAa,GAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AARD,kCAQC"}
@@ -29,6 +29,7 @@
29
29
  }
30
30
  },
31
31
  "scripts": {
32
+ "schematics": "schematics",
32
33
  "clean": "rimraf test/ test-dev/ dist/ dist-dev/ dist-test/ build/",
33
34
  "lint:ci": "eslint \"**/*[jt]s\" --quiet --format junit --output-file ./dist-lint/result.xml",
34
35
  "lint": "eslint \"**/*[jt]s\" --cache",
@@ -82,7 +83,7 @@
82
83
  "@openapitools/openapi-generator-cli": "<%= versions['@openapitools/openapi-generator-cli'] %>",
83
84
  "@stylistic/eslint-plugin-ts": "<%= versions['@stylistic/eslint-plugin-ts'] %>",
84
85
  "@swc/cli": "^0.1.57",
85
- "@swc/core": "^1.3.85",
86
+ "@swc/core": "1.5.7",
86
87
  "@types/jest": "<%= versions['@types/jest'] %>",
87
88
  "@types/node": "<%= versions['@types/node'] %>",
88
89
  "@typescript-eslint/eslint-plugin": "<%= versions['@typescript-eslint/eslint-plugin'] %>",