@ama-openapi/create 13.5.0-rc.1 → 13.6.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ It helps developers quickly set up new OpenAPI projects with best practices and
12
12
  ## Usage
13
13
 
14
14
  ```shell
15
- npm create @ama-openapi <command> -- [options]
15
+ npm create @ama-openapi -- [options]
16
16
  ```
17
17
 
18
18
  The following global options can be used with any command:
@@ -22,14 +22,12 @@ The following global options can be used with any command:
22
22
  | `--version`, `-v` | Display the current version of the generator. |
23
23
  | `--help`, `-h` | Display usage for the CLI commands. |
24
24
 
25
- ## Available commands
25
+ ## Generate Open Api basic project
26
26
 
27
- ### Design Project
28
-
29
- Create a new [OpenAPI](https://www.openapis.org/) design project via the following command :
27
+ Create a new [OpenAPI](https://www.openapis.org/) basic project via the following command :
30
28
 
31
29
  ```shell
32
- npm create @ama-openapi design <project-name> -- [options]
30
+ npm create @ama-openapi <project-name> -- [options]
33
31
  ```
34
32
 
35
33
  The following options are available:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-openapi/create",
3
- "version": "13.5.0-rc.1",
3
+ "version": "13.6.0-prerelease.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,6 +8,15 @@
8
8
  "keywords": [
9
9
  "create"
10
10
  ],
11
+ "main": "./src/index.js",
12
+ "exports": {
13
+ ".": {
14
+ "default": "./src/index.js"
15
+ },
16
+ "./package.json": {
17
+ "default": "./package.json"
18
+ }
19
+ },
11
20
  "bin": "./src/index.js",
12
21
  "scripts": {
13
22
  "nx": "nx",
@@ -18,7 +27,7 @@
18
27
  "postbuild": "cpy 'package.json' 'dist' && patch-package-json-main"
19
28
  },
20
29
  "peerDependencies": {
21
- "@o3r/telemetry": "~13.5.0-rc.1",
30
+ "@o3r/telemetry": "~13.6.0-prerelease.10",
22
31
  "type-fest": "^4.30.1"
23
32
  },
24
33
  "peerDependenciesMeta": {
@@ -30,7 +39,7 @@
30
39
  }
31
40
  },
32
41
  "dependencies": {
33
- "@ama-openapi/core": "~13.5.0-rc.1",
42
+ "@ama-openapi/core": "~13.6.0-prerelease.10",
34
43
  "ejs": "~3.1.9",
35
44
  "globby": "^11.1.0",
36
45
  "tslib": "^2.6.2",
@@ -43,11 +52,11 @@
43
52
  "@nx/eslint-plugin": "~21.6.0",
44
53
  "@nx/jest": "~21.6.0",
45
54
  "@nx/js": "~21.6.0",
46
- "@o3r/build-helpers": "~13.5.0-rc.1",
47
- "@o3r/eslint-config": "~13.5.0-rc.1",
48
- "@o3r/eslint-plugin": "~13.5.0-rc.1",
49
- "@o3r/telemetry": "~13.5.0-rc.1",
50
- "@o3r/test-helpers": "~13.5.0-rc.1",
55
+ "@o3r/build-helpers": "~13.6.0-prerelease.10",
56
+ "@o3r/eslint-config": "~13.6.0-prerelease.10",
57
+ "@o3r/eslint-plugin": "~13.6.0-prerelease.10",
58
+ "@o3r/telemetry": "~13.6.0-prerelease.10",
59
+ "@o3r/test-helpers": "~13.6.0-prerelease.10",
51
60
  "@schematics/angular": "~20.3.13",
52
61
  "@stylistic/eslint-plugin": "~5.6.0",
53
62
  "@types/ejs": "^3.1.2",
@@ -56,7 +65,7 @@
56
65
  "@types/node": "~24.10.0",
57
66
  "@types/semver": "^7.3.13",
58
67
  "@types/yargs": "~17.0.33",
59
- "@typescript-eslint/parser": "~8.49.0",
68
+ "@typescript-eslint/parser": "~8.51.0",
60
69
  "angular-eslint": "~20.6.0",
61
70
  "cpy-cli": "^6.0.0",
62
71
  "eslint": "~9.39.0",
@@ -64,7 +73,7 @@
64
73
  "eslint-import-resolver-typescript": "~4.4.0",
65
74
  "eslint-plugin-import": "~2.32.0",
66
75
  "eslint-plugin-import-newlines": "~1.4.0",
67
- "eslint-plugin-jest": "~29.2.0",
76
+ "eslint-plugin-jest": "~29.11.0",
68
77
  "eslint-plugin-jsdoc": "~54.7.0",
69
78
  "eslint-plugin-prefer-arrow": "~1.2.3",
70
79
  "eslint-plugin-unicorn": "~60.0.0",
@@ -81,7 +90,7 @@
81
90
  "ts-jest": "~29.4.0",
82
91
  "type-fest": "^4.30.1",
83
92
  "typescript": "~5.9.2",
84
- "typescript-eslint": "~8.49.0"
93
+ "typescript-eslint": "~8.51.0"
85
94
  },
86
95
  "generatorDependencies": {
87
96
  "@redocly/openapi-core": "~2.11.0"
@@ -10,3 +10,6 @@ node_modules/
10
10
 
11
11
  # Bundle specifications directory
12
12
  /bundle
13
+
14
+ # Local validation schemas
15
+ /schemas
@@ -1 +1 @@
1
- # yaml-language-server: $schema=https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/main/packages/@ama-openapi/core/schemas/manifest.schema.json
1
+ # yaml-language-server: $schema=./schemas/manifest.schema.json
@@ -1,10 +1,12 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/main/packages/@ama-openapi/core/schemas/manifest.schema.json",
2
+ "$schema": "./schemas/manifest.schema.json",
3
3
  "name": "<%- packageName %>",
4
4
  "keywords": [
5
- "open-api",
6
- "ama-open-api",
7
- "specification"
5
+ <%-
6
+ packageKeywords
7
+ .map((keyword)=> ` "${keyword}"`)
8
+ .join(',\n')
9
+ %>
8
10
  ],
9
11
  "preferUnplugged": true,
10
12
  "version": "0.0.0-placeholder",
@@ -22,6 +24,7 @@
22
24
  "build": "redocly bundle",
23
25
  "retrieve-externals": "ama-openapi install",
24
26
  "watch:retrieve-externals": "ama-openapi watch",
27
+ "prepare": "ama-openapi generate-schema"
25
28
  "postinstall": "ama-openapi install"
26
29
  },
27
30
  "dependencies": {
@@ -0,0 +1,3 @@
1
+ {
2
+ "$ref": "https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/main/packages/@ama-openapi/core/schemas/manifest.schema.json"
3
+ }
@@ -1,20 +0,0 @@
1
- /**
2
- * Options for template generation
3
- */
4
- export interface CreateOptions {
5
- /** Target directory */
6
- target: string;
7
- /** Path to external models */
8
- externalModelPath: string;
9
- /** Version of the generator */
10
- version: string;
11
- /** Name of the package/artifact */
12
- packageName: string;
13
- /** Logger */
14
- logger: typeof console;
15
- }
16
- /**
17
- * Generate Template files
18
- * @param options
19
- */
20
- export declare const generateTemplate: (options: CreateOptions) => Promise<void[]>;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateTemplate = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const core_1 = require("@ama-openapi/core");
7
- const ejs_1 = require("ejs");
8
- const globby_1 = require("globby");
9
- const TEMPLATE_EXTENSION = '.template';
10
- const GIT_IGNORE_IO_URL = 'https://www.toptal.com/developers/gitignore/api/node';
11
- /**
12
- * Retrieve the gitignore content generated by gitignore.io
13
- * @param options
14
- */
15
- const getGitIgnoreContent = async (options) => {
16
- let standardGitignoreNode = '';
17
- try {
18
- const gitignoreResponse = await fetch(GIT_IGNORE_IO_URL);
19
- if (!gitignoreResponse.ok) {
20
- throw new Error(`Non-OK response to ${GIT_IGNORE_IO_URL}`);
21
- }
22
- standardGitignoreNode = await gitignoreResponse.text();
23
- }
24
- catch (e) {
25
- options.logger.warn('gitignore.io service are not available, a default minimal gitignore will be generated');
26
- options.logger.debug(e);
27
- }
28
- return standardGitignoreNode;
29
- };
30
- /**
31
- * Generate Template files
32
- * @param options
33
- */
34
- const generateTemplate = async (options) => {
35
- const { generatorDependencies, engines } = JSON.parse(await node_fs_1.promises.readFile((0, node_path_1.resolve)(__dirname, '..', 'package.json'), { encoding: 'utf8' }));
36
- const templatesDirectory = (0, node_path_1.resolve)(__dirname, '..', 'templates');
37
- const regExpExtension = new RegExp(`\\${TEMPLATE_EXTENSION}$`);
38
- const exportedFiles = [
39
- 'bundle',
40
- 'models',
41
- ...core_1.DEFAULT_MANIFEST_FILENAMES
42
- ];
43
- const generatedCode = (0, globby_1.sync)('**/*', { cwd: templatesDirectory, dot: true })
44
- .map(async (templatePath) => {
45
- const templatePathAbsolute = (0, node_path_1.resolve)(templatesDirectory, templatePath);
46
- const content = await (0, ejs_1.renderFile)(templatePathAbsolute, {
47
- ...options,
48
- nodeSupportedRange: engines.node,
49
- projectFolder: (0, node_path_1.basename)(options.target),
50
- exportedFiles,
51
- redoclyVersion: generatorDependencies['@redocly/openapi-core'],
52
- standardGitignoreNode: await getGitIgnoreContent(options)
53
- }, { async: true });
54
- return {
55
- templatePath,
56
- content
57
- };
58
- })
59
- .map(async (file) => {
60
- const { templatePath, content } = await file;
61
- const outputPath = (0, node_path_1.resolve)(options.target, templatePath.replace(regExpExtension, ''));
62
- const outputDirectory = (0, node_path_1.dirname)(outputPath);
63
- if (!(0, node_fs_1.existsSync)(outputDirectory)) {
64
- await node_fs_1.promises.mkdir((0, node_path_1.dirname)(outputPath), { recursive: true });
65
- }
66
- await node_fs_1.promises.writeFile(outputPath, content, { encoding: 'utf8' });
67
- });
68
- return Promise.all(generatedCode);
69
- };
70
- exports.generateTemplate = generateTemplate;
package/src/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/src/index.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const core_1 = require("@ama-openapi/core");
7
- const yargs = require("yargs");
8
- const helpers_1 = require("yargs/helpers");
9
- const generate_template_1 = require("./generate-template");
10
- void (async () => {
11
- const version = JSON.parse(await node_fs_1.promises.readFile((0, node_path_1.resolve)(__dirname, '..', 'package.json'), { encoding: 'utf8' })).version;
12
- await yargs((0, helpers_1.hideBin)(process.argv))
13
- .option('target', {
14
- alias: 't',
15
- type: 'string',
16
- description: 'Target directory to generate the files into',
17
- default: process.cwd()
18
- })
19
- .command('design <name>', 'Name of the artifact / package to generate', (y) => {
20
- return y.positional('name', {
21
- type: 'string',
22
- demandOption: true,
23
- describe: 'Name of the artifact / package to generate'
24
- });
25
- }, async (argv) => {
26
- const options = {
27
- target: argv.target,
28
- externalModelPath: core_1.OUTPUT_DIRECTORY,
29
- version,
30
- packageName: argv.name,
31
- logger: console
32
- };
33
- await (0, generate_template_1.generateTemplate)(options);
34
- })
35
- .version(version)
36
- .alias('h', 'help')
37
- .alias('v', 'version')
38
- .parse();
39
- })();