@ama-openapi/create 0.0.0-placeholder.1 → 0.0.0-placeholder.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ama-openapi/create",
3
- "version": "0.0.0-placeholder.1",
3
+ "version": "0.0.0-placeholder.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  "postbuild": "cpy 'package.json' 'dist' && patch-package-json-main"
19
19
  },
20
20
  "peerDependencies": {
21
- "@o3r/telemetry": "~0.0.0",
21
+ "@o3r/telemetry": "~0.0.0-placeholder.10",
22
22
  "type-fest": "^4.30.1"
23
23
  },
24
24
  "peerDependenciesMeta": {
@@ -30,7 +30,7 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@ama-openapi/core": "~0.0.0",
33
+ "@ama-openapi/core": "~0.0.0-placeholder.10",
34
34
  "ejs": "~3.1.9",
35
35
  "globby": "^11.1.0",
36
36
  "tslib": "^2.6.2",
@@ -43,11 +43,11 @@
43
43
  "@nx/eslint-plugin": "~21.6.0",
44
44
  "@nx/jest": "~21.6.0",
45
45
  "@nx/js": "~21.6.0",
46
- "@o3r/build-helpers": "~0.0.0",
47
- "@o3r/eslint-config": "~0.0.0",
48
- "@o3r/eslint-plugin": "~0.0.0",
49
- "@o3r/telemetry": "~0.0.0",
50
- "@o3r/test-helpers": "~0.0.0",
46
+ "@o3r/build-helpers": "~0.0.0-placeholder.10",
47
+ "@o3r/eslint-config": "~0.0.0-placeholder.10",
48
+ "@o3r/eslint-plugin": "~0.0.0-placeholder.10",
49
+ "@o3r/telemetry": "~0.0.0-placeholder.10",
50
+ "@o3r/test-helpers": "~0.0.0-placeholder.10",
51
51
  "@schematics/angular": "~20.3.0",
52
52
  "@stylistic/eslint-plugin": "~5.5.0",
53
53
  "@types/ejs": "^3.1.2",
@@ -58,9 +58,9 @@
58
58
  "@types/semver": "^7.3.13",
59
59
  "@types/yargs": "~17.0.33",
60
60
  "@typescript-eslint/parser": "~8.46.0",
61
- "angular-eslint": "~20.4.0",
61
+ "angular-eslint": "~20.5.0",
62
62
  "cpy-cli": "^6.0.0",
63
- "eslint": "~9.38.0",
63
+ "eslint": "~9.39.0",
64
64
  "eslint-import-resolver-node": "~0.3.9",
65
65
  "eslint-import-resolver-typescript": "~4.4.0",
66
66
  "eslint-plugin-import": "~2.32.0",
@@ -86,7 +86,7 @@
86
86
  "typescript-eslint": "~8.46.0"
87
87
  },
88
88
  "generatorDependencies": {
89
- "@redocly/openapi-core": "~2.8.0"
89
+ "@redocly/openapi-core": "~2.11.0"
90
90
  },
91
91
  "engines": {
92
92
  "node": "^20.19.0 || ^22.17.0 || ^24.0.0",
@@ -10,6 +10,8 @@ export interface CreateOptions {
10
10
  version: string;
11
11
  /** Name of the package/artifact */
12
12
  packageName: string;
13
+ /** Logger */
14
+ logger: typeof console;
13
15
  }
14
16
  /**
15
17
  * Generate Template files
@@ -3,24 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTemplate = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
+ const core_1 = require("@ama-openapi/core");
6
7
  const ejs_1 = require("ejs");
7
8
  const globby_1 = require("globby");
8
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
+ };
9
30
  /**
10
31
  * Generate Template files
11
32
  * @param options
12
33
  */
13
34
  const generateTemplate = async (options) => {
14
- const { generatorDependencies } = JSON.parse(await node_fs_1.promises.readFile((0, node_path_1.resolve)(__dirname, '..', 'package.json'), { encoding: 'utf8' }));
35
+ const { generatorDependencies, engines } = JSON.parse(await node_fs_1.promises.readFile((0, node_path_1.resolve)(__dirname, '..', 'package.json'), { encoding: 'utf8' }));
15
36
  const templatesDirectory = (0, node_path_1.resolve)(__dirname, '..', 'templates');
16
37
  const regExpExtension = new RegExp(`\\${TEMPLATE_EXTENSION}$`);
38
+ const exportedFiles = [
39
+ 'bundle',
40
+ 'models',
41
+ ...core_1.DEFAULT_MANIFEST_FILENAMES
42
+ ];
17
43
  const generatedCode = (0, globby_1.sync)('**/*', { cwd: templatesDirectory, dot: true })
18
44
  .map(async (templatePath) => {
19
45
  const templatePathAbsolute = (0, node_path_1.resolve)(templatesDirectory, templatePath);
20
46
  const content = await (0, ejs_1.renderFile)(templatePathAbsolute, {
21
47
  ...options,
48
+ nodeSupportedRange: engines.node,
49
+ projectFolder: (0, node_path_1.basename)(options.target),
50
+ exportedFiles,
22
51
  redoclyVersion: generatorDependencies['@redocly/openapi-core'],
23
- standardGitignoreNode: await (await fetch('https://www.toptal.com/developers/gitignore/api/node')).text()
52
+ standardGitignoreNode: await getGitIgnoreContent(options)
24
53
  }, { async: true });
25
54
  return {
26
55
  templatePath,
@@ -30,12 +59,10 @@ const generateTemplate = async (options) => {
30
59
  .map(async (file) => {
31
60
  const { templatePath, content } = await file;
32
61
  const outputPath = (0, node_path_1.resolve)(options.target, templatePath.replace(regExpExtension, ''));
33
- try {
62
+ const outputDirectory = (0, node_path_1.dirname)(outputPath);
63
+ if (!(0, node_fs_1.existsSync)(outputDirectory)) {
34
64
  await node_fs_1.promises.mkdir((0, node_path_1.dirname)(outputPath), { recursive: true });
35
65
  }
36
- catch {
37
- // ignore error if folder already exists
38
- }
39
66
  await node_fs_1.promises.writeFile(outputPath, content, { encoding: 'utf8' });
40
67
  });
41
68
  return Promise.all(generatedCode);
package/src/index.js CHANGED
@@ -27,7 +27,8 @@ void (async () => {
27
27
  target: argv.target,
28
28
  externalModelPath: core_1.OUTPUT_DIRECTORY,
29
29
  version,
30
- packageName: argv.name
30
+ packageName: argv.name,
31
+ logger: console
31
32
  };
32
33
  await (0, generate_template_1.generateTemplate)(options);
33
34
  })
@@ -1,4 +1,12 @@
1
- <%= standardGitignoreNode %>
1
+ <% if (standardGitignoreNode) { %>
2
+ <%- standardGitignoreNode %>
3
+ <% } else { %>
4
+ # Dependency directory
5
+ node_modules/
6
+ <% } %>
2
7
 
3
- # Ignore external models
4
- /<%= externalModelPath %>
8
+ # External models directory
9
+ /<%- externalModelPath %>
10
+
11
+ # Bundle specifications directory
12
+ /bundle
@@ -4,6 +4,9 @@
4
4
  "files.readonlyInclude": {
5
5
  "**/.cache/**": true,
6
6
  "**/node_modules/**": true,
7
- "**/<%= externalModelPath %>/**/*.{json,yaml,yml}": true
7
+ "**/<%- externalModelPath %>/**/*.{json,yaml,yml}": true
8
+ },
9
+ "explorer.fileNesting.patterns": {
10
+ "package.json": "package-lock.json, openapi.manifest.yaml"
8
11
  }
9
12
  }
@@ -0,0 +1,52 @@
1
+ # <%- packageName %>
2
+
3
+ This package exposes [OpenApi specification](https://swagger.io/specification/) which can be used to use to generate an SDK or be referred in another specification.
4
+
5
+ ## How to work on it
6
+
7
+ **Requirements:**
8
+
9
+ - Code editor [Visual Studio Code](https://code.visualstudio.com/) with the recommended extension (proposed on start).
10
+ - [NodeJs](https://nodejs.org/) with a odd [LTS (or latest) version](https://nodejs.org/en/about/previous-releases).
11
+
12
+ **Setup:**
13
+
14
+ ```shell
15
+ npm install
16
+ ```
17
+
18
+ ### Add dependency
19
+
20
+ ```shell
21
+ npm install <artifact_name>
22
+ ```
23
+
24
+ and refer to its models via config in the [manifest](https://github.com/AmadeusITGroup/otter/tree/main/docs/openapi/MANIFEST_CONFIGURATION.md):
25
+
26
+ ```yaml
27
+ models:
28
+ <artifact_name>:
29
+ - models/first-model.yaml
30
+ - models/second-model.yaml
31
+ ```
32
+
33
+ > [!NOTE]
34
+ > The complete documentation is available on [Dependency concept documentation](https://github.com/AmadeusITGroup/otter/tree/main/docs/openapi/DEPENDENCY_RESOLUTION_CONCEPT.md).
35
+
36
+ ## Repository structure
37
+
38
+ The current repository has the following structure:
39
+
40
+ ```text
41
+ <%- projectFolder %>/
42
+ ├── .vscode/ # VsCode options and recommended extension
43
+ ├── apis/ # List of the Apis to bundle in the final specification
44
+ ├── models/ # Models to be referred locally and shared
45
+ ├── responses/ # List of responses used in the APIs
46
+ ├── .gitignore
47
+ ├── openapi.manifest.yaml
48
+ ├── package.json
49
+ ├── redocly.yaml
50
+ ├── README.md
51
+ └── renovate.json
52
+ ```
@@ -1 +1 @@
1
- # yaml-language-server: $schema=https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/feature/open-api/packages/@ama-openapi/core/schemas/manifest.schema.json
1
+ # yaml-language-server: $schema=https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/feature/openapi-solution/packages/@ama-openapi/core/schemas/manifest.schema.json
@@ -1,26 +1,30 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/feature/open-api/packages/@ama-openapi/core/schemas/manifest.schema.json",
3
- "name": "<%= packageName %>",
2
+ "$schema": "https://raw.githubusercontent.com/AmadeusITGroup/otter/refs/heads/feature/openapi-solution/packages/@ama-openapi/core/schemas/manifest.schema.json",
3
+ "name": "<%- packageName %>",
4
4
  "preferUnplugged": true,
5
- "version": "0.0.0-placeholder.1",
5
+ "version": "0.0.0-placeholder",
6
6
  "description": "My Specification description",
7
7
  "main": "bundle/specification.yaml",
8
8
  "files": [
9
- "bundle",
10
- "models"
9
+ <%-
10
+ exportedFiles
11
+ .map((file) => ` "${file}"`)
12
+ .join(',\n')
13
+ %>
11
14
  ],
12
15
  "readme": "README.md",
13
16
  "scripts": {
14
17
  "build": "redocly bundle",
15
18
  "retrieve-externals": "ama-openapi install",
19
+ "watch:retrieve-externals": "ama-openapi watch",
16
20
  "postinstall": "ama-openapi install"
17
21
  },
18
22
  "dependencies": {
19
- "@ama-openapi/cli": "~<%= version %>"
23
+ "@ama-openapi/cli": "~<%- version %>"
20
24
  },
21
25
  "devDependencies": {
22
- "@ama-openapi/redocly-plugin": "~<%= version %>",
23
- "@redocly/cli": "<%= redoclyVersion %>"
26
+ "@ama-openapi/redocly-plugin": "~<%- version %>",
27
+ "@redocly/cli": "<%- redoclyVersion %>"
24
28
  },
25
29
  "exports": {
26
30
  "./package.json": "./package.json",
@@ -30,5 +34,8 @@
30
34
  "module": "./bundle/specification.yaml",
31
35
  "default": "./bundle/specification.yaml"
32
36
  }
37
+ },
38
+ "engines": {
39
+ "node": "<%- nodeSupportedRange %>"
33
40
  }
34
41
  }
@@ -8,4 +8,3 @@ apis:
8
8
  example@v1:
9
9
  root: apis/example.v1.yaml
10
10
  output: bundle/specification.yaml
11
- prepare-publish
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
3
  "extends": [
4
- "github>AmadeusITGroup/otter//packages/@ama-openapi/core/renovate#<%= version %>"
4
+ "github>AmadeusITGroup/otter//packages/@ama-openapi/core/renovate#<%- version %>"
5
5
  ]
6
6
  }