@ama-sdk/create 11.0.0-next.1 → 11.0.0-prerelease.1

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 +30 -5
  3. package/package.json +8 -8
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 path inside the package where to find the spec file
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
@@ -52,7 +52,11 @@ const getYarnVersion = () => {
52
52
  return 'latest';
53
53
  }
54
54
  };
55
- const schematicArgs = [
55
+ if (argv['spec-path'] && argv['spec-package-name']) {
56
+ console.error('--spec-path cannot be set with --spec-package-name');
57
+ process.exit(-4);
58
+ }
59
+ const commonSchematicArgs = [
56
60
  argv.debug !== undefined ? `--debug=${argv.debug}` : '--debug=false', // schematics enable debug mode per default when using schematics with relative path
57
61
  ...(name ? ['--name', name] : []),
58
62
  '--package', pck,
@@ -64,18 +68,39 @@ const schematicArgs = [
64
68
  const resolveTargetDirectory = (0, node_path_1.resolve)(process.cwd(), targetDirectory);
65
69
  const run = () => {
66
70
  const isSpecRelativePath = !!argv['spec-path'] && !(0, node_path_1.parse)(argv['spec-path']).root;
71
+ const shellSchematicArgs = [
72
+ ...commonSchematicArgs,
73
+ ...(argv['spec-package-name'] ? ['--spec-package-name', argv['spec-package-name']] : []),
74
+ ...(argv['spec-package-registry'] ? ['--spec-package-registry', argv['spec-package-registry']] : []),
75
+ ...(argv['spec-package-path'] ? ['--spec-package-path', argv['spec-package-path']] : []),
76
+ ...(argv['spec-package-version'] ? ['--spec-package-version', argv['spec-package-version']] : [])
77
+ ];
78
+ const coreSchematicArgs = [
79
+ ...commonSchematicArgs,
80
+ '--spec-path', argv['spec-package-name'] ? './openapi.yml' : isSpecRelativePath ? (0, node_path_1.relative)(resolveTargetDirectory, (0, node_path_1.resolve)(process.cwd(), argv['spec-path'])) : argv['spec-path']
81
+ ];
67
82
  const runner = process.platform === 'win32' ? `${packageManager}.cmd` : packageManager;
68
83
  const steps = [
69
- { args: [binPath, `${schematicsPackage}:typescript-shell`, ...schematicArgs, '--directory', targetDirectory] },
84
+ { args: [binPath, `${schematicsPackage}:typescript-shell`, ...shellSchematicArgs, '--directory', targetDirectory] },
70
85
  ...(packageManager === 'yarn'
71
86
  ? [{ runner, args: ['set', 'version', getYarnVersion()], cwd: resolveTargetDirectory }]
72
87
  : []),
73
- ...(argv['spec-path'] ? [{
88
+ ...(argv['spec-package-name'] ? [{
89
+ runner,
90
+ args: [
91
+ 'exec',
92
+ 'amasdk-update-spec-from-npm',
93
+ argv['spec-package-name'],
94
+ ...packageManager === 'npm' ? ['--'] : [],
95
+ '--package-path', argv['spec-package-path']
96
+ ],
97
+ cwd: resolveTargetDirectory
98
+ }] : []),
99
+ ...((argv['spec-path'] || argv['spec-package-name']) ? [{
74
100
  args: [
75
101
  binPath,
76
102
  `${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']
103
+ ...coreSchematicArgs
79
104
  ],
80
105
  cwd: resolveTargetDirectory
81
106
  }] : [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-sdk/create",
3
- "version": "11.0.0-next.1",
3
+ "version": "11.0.0-prerelease.1",
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.1",
21
- "@ama-sdk/schematics": "11.0.0-next.1",
20
+ "@ama-sdk/core": "11.0.0-prerelease.1",
21
+ "@ama-sdk/schematics": "11.0.0-prerelease.1",
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.1",
26
+ "@o3r/schematics": "11.0.0-prerelease.1",
27
27
  "@openapitools/openapi-generator-cli": "~2.13.0",
28
28
  "@schematics/angular": "~17.3.0",
29
29
  "minimist": "^1.2.6",
@@ -37,10 +37,10 @@
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.1",
41
- "@o3r/eslint-config-otter": "^11.0.0-next.1",
42
- "@o3r/eslint-plugin": "^11.0.0-next.1",
43
- "@o3r/test-helpers": "^11.0.0-next.1",
40
+ "@o3r/build-helpers": "^11.0.0-prerelease.1",
41
+ "@o3r/eslint-config-otter": "^11.0.0-prerelease.1",
42
+ "@o3r/eslint-plugin": "^11.0.0-prerelease.1",
43
+ "@o3r/test-helpers": "^11.0.0-prerelease.1",
44
44
  "@stylistic/eslint-plugin-ts": "^1.5.4",
45
45
  "@types/jest": "~29.5.2",
46
46
  "@types/minimist": "^1.2.2",