@ama-sdk/create 11.0.0-next.2 → 11.0.0-prerelease.10

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.
Files changed (3) hide show
  1. package/README.md +10 -2
  2. package/index.js +38 -5
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -37,11 +37,19 @@ npm create @ama-sdk typescript <project-name> -- --package-manager=yarn [...opti
37
37
 
38
38
  ## Options list
39
39
 
40
- - `--spec-path`: Path to the swagger/open-api specification used to generate the SDK
41
40
  - `--package-manager`: Node package manager to be used (`npm` and `yarn` are available).
42
41
  - `--debug --no-dry-run`: Enable schematics debug mode (dry-run is not currently supported).
43
42
  - `--o3r-metrics`: Enable or disable the collection of anonymous data for Otter
44
43
  - `--exact-o3r-version` : use a pinned version for [otter packages](https://github.com/AmadeusITGroup/otter/blob/main/docs/README.md).
45
44
 
45
+ - `--spec-path`: Path to the swagger/open-api specification used to generate the SDK
46
+ - `--spec-package-name`: The npm package name where the spec file can be fetched
47
+ - `--spec-package-path`: The export path inside the package.json where to find the spec file. Defaults to _./openapi.[yml|yaml|json]_
48
+ - `--spec-package-version`: The version to target for the npm package where the spec file can be fetched
49
+ - `--spec-package-registry`: The npm registry where the spec file can be fetched
50
+
51
+ > [!NOTE]
52
+ > If `--spec-path` or `--spec-package-name` is specified, the SDK will be generated based on this specification at the creation time.
53
+
46
54
  > [!NOTE]
47
- > If the `--spec-path` is specified, the SDK will be generated based on this specification at the creation time.
55
+ > > `--spec-package-registry` option assumes that the authentication is set up globally (See [npm setup](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc#auth-related-configuration), [yarn setup](https://yarnpkg.com/configuration/yarnrc#npmRegistries))
package/index.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const node_path_1 = require("node:path");
7
7
  const minimist = require("minimist");
8
+ const core_1 = require("@ama-sdk/core");
8
9
  const packageManagerEnv = process.env.npm_config_user_agent?.split('/')[0];
9
10
  const binPath = (0, node_path_1.resolve)(require.resolve('@angular-devkit/schematics-cli/package.json'), '../bin/schematics.js');
10
11
  const args = process.argv.slice(2);
@@ -52,7 +53,17 @@ const getYarnVersion = () => {
52
53
  return 'latest';
53
54
  }
54
55
  };
55
- const schematicArgs = [
56
+ if (argv['spec-path'] && argv['spec-package-name']) {
57
+ console.error('--spec-path cannot be set with --spec-package-name');
58
+ process.exit(-4);
59
+ }
60
+ /* The local file (path) which will be created in case of generation using specs from an npm module */
61
+ let localFilePathToBeCreated;
62
+ if (argv['spec-package-name']) {
63
+ const localSpecFileComputedExtension = argv['spec-package-path'] && (0, node_path_1.extname)(argv['spec-package-path']) === '.json' ? `.${core_1.SPEC_JSON_EXTENSION}` : `.${core_1.SPEC_YAML_EXTENSION}`;
64
+ localFilePathToBeCreated = `./${core_1.LOCAL_SPEC_FILENAME}${localSpecFileComputedExtension}`;
65
+ }
66
+ const commonSchematicArgs = [
56
67
  argv.debug !== undefined ? `--debug=${argv.debug}` : '--debug=false', // schematics enable debug mode per default when using schematics with relative path
57
68
  ...(name ? ['--name', name] : []),
58
69
  '--package', pck,
@@ -64,18 +75,40 @@ const schematicArgs = [
64
75
  const resolveTargetDirectory = (0, node_path_1.resolve)(process.cwd(), targetDirectory);
65
76
  const run = () => {
66
77
  const isSpecRelativePath = !!argv['spec-path'] && !(0, node_path_1.parse)(argv['spec-path']).root;
78
+ const shellSchematicArgs = [
79
+ ...commonSchematicArgs,
80
+ ...(argv['spec-package-name'] ? ['--spec-package-name', argv['spec-package-name']] : []),
81
+ ...(argv['spec-package-registry'] ? ['--spec-package-registry', argv['spec-package-registry']] : []),
82
+ ...(argv['spec-package-path'] ? ['--spec-package-path', argv['spec-package-path']] : []),
83
+ ...(argv['spec-package-version'] ? ['--spec-package-version', argv['spec-package-version']] : [])
84
+ ];
85
+ const coreSchematicArgs = [
86
+ ...commonSchematicArgs,
87
+ '--spec-path',
88
+ localFilePathToBeCreated || (isSpecRelativePath ? (0, node_path_1.relative)(resolveTargetDirectory, (0, node_path_1.resolve)(process.cwd(), argv['spec-path'])) : argv['spec-path'])
89
+ ];
67
90
  const runner = process.platform === 'win32' ? `${packageManager}.cmd` : packageManager;
68
91
  const steps = [
69
- { args: [binPath, `${schematicsPackage}:typescript-shell`, ...schematicArgs, '--directory', targetDirectory] },
92
+ { args: [binPath, `${schematicsPackage}:typescript-shell`, ...shellSchematicArgs, '--directory', targetDirectory] },
70
93
  ...(packageManager === 'yarn'
71
94
  ? [{ runner, args: ['set', 'version', getYarnVersion()], cwd: resolveTargetDirectory }]
72
95
  : []),
73
- ...(argv['spec-path'] ? [{
96
+ ...(argv['spec-package-name'] ? [{
97
+ runner,
98
+ args: [
99
+ 'exec',
100
+ 'amasdk-update-spec-from-npm',
101
+ argv['spec-package-name'],
102
+ ...packageManager === 'npm' ? ['--'] : [],
103
+ '--package-path', argv['spec-package-path']
104
+ ],
105
+ cwd: resolveTargetDirectory
106
+ }] : []),
107
+ ...((argv['spec-path'] || argv['spec-package-name']) ? [{
74
108
  args: [
75
109
  binPath,
76
110
  `${schematicsPackage}:typescript-core`,
77
- ...schematicArgs,
78
- '--spec-path', isSpecRelativePath ? (0, node_path_1.relative)(resolveTargetDirectory, (0, node_path_1.resolve)(process.cwd(), argv['spec-path'])) : argv['spec-path']
111
+ ...coreSchematicArgs
79
112
  ],
80
113
  cwd: resolveTargetDirectory
81
114
  }] : [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/create",
3
- "version": "11.0.0-next.2",
3
+ "version": "11.0.0-prerelease.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -17,13 +17,13 @@
17
17
  "prepare:publish": "prepare-publish ./dist"
18
18
  },
19
19
  "dependencies": {
20
- "@ama-sdk/core": "11.0.0-next.2",
21
- "@ama-sdk/schematics": "11.0.0-next.2",
20
+ "@ama-sdk/core": "11.0.0-prerelease.10",
21
+ "@ama-sdk/schematics": "11.0.0-prerelease.10",
22
22
  "@angular-devkit/core": "~17.3.0",
23
23
  "@angular-devkit/schematics": "~17.3.0",
24
24
  "@angular-devkit/schematics-cli": "~17.3.0",
25
25
  "@angular/cli": "~17.3.0",
26
- "@o3r/schematics": "11.0.0-next.2",
26
+ "@o3r/schematics": "11.0.0-prerelease.10",
27
27
  "@openapitools/openapi-generator-cli": "~2.13.0",
28
28
  "@schematics/angular": "~17.3.0",
29
29
  "minimist": "^1.2.6",
@@ -31,16 +31,16 @@
31
31
  "typescript": "~5.4.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@angular-eslint/eslint-plugin": "~17.3.0",
35
- "@angular-eslint/eslint-plugin-template": "~17.3.0",
34
+ "@angular-eslint/eslint-plugin": "~17.5.0",
35
+ "@angular-eslint/eslint-plugin-template": "~17.5.0",
36
36
  "@nx/eslint": "~18.3.0",
37
37
  "@nx/eslint-plugin": "~18.3.0",
38
38
  "@nx/jest": "~18.3.0",
39
39
  "@nx/js": "~18.3.0",
40
- "@o3r/build-helpers": "^11.0.0-next.2",
41
- "@o3r/eslint-config-otter": "^11.0.0-next.2",
42
- "@o3r/eslint-plugin": "^11.0.0-next.2",
43
- "@o3r/test-helpers": "^11.0.0-next.2",
40
+ "@o3r/build-helpers": "^11.0.0-prerelease.10",
41
+ "@o3r/eslint-config-otter": "^11.0.0-prerelease.10",
42
+ "@o3r/eslint-plugin": "^11.0.0-prerelease.10",
43
+ "@o3r/test-helpers": "^11.0.0-prerelease.10",
44
44
  "@stylistic/eslint-plugin-ts": "^1.5.4",
45
45
  "@types/jest": "~29.5.2",
46
46
  "@types/minimist": "^1.2.2",