@ama-openapi/create 0.0.0-placeholder

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 ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@ama-openapi/create",
3
+ "version": "0.0.0-placeholder",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Create a new OpenApi Specification project",
8
+ "keywords": [
9
+ "create"
10
+ ],
11
+ "bin": "./src/index.js",
12
+ "scripts": {
13
+ "nx": "nx",
14
+ "ng": "yarn nx",
15
+ "compile": "tsc -b tsconfig.build.json",
16
+ "build": "yarn nx build ama-openapi-create",
17
+ "copy:templates": "cpy 'templates/**' dist/templates/",
18
+ "postbuild": "cpy 'package.json' 'dist' && patch-package-json-main"
19
+ },
20
+ "peerDependencies": {
21
+ "@o3r/telemetry": "workspace:~",
22
+ "type-fest": "^4.30.1"
23
+ },
24
+ "peerDependenciesMeta": {
25
+ "@o3r/telemetry": {
26
+ "optional": true
27
+ },
28
+ "type-fest": {
29
+ "optional": true
30
+ }
31
+ },
32
+ "dependencies": {
33
+ "@ama-openapi/core": "workspace:~",
34
+ "ejs": "~3.1.9",
35
+ "globby": "^11.1.0",
36
+ "tslib": "^2.6.2",
37
+ "yargs": "~18.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@angular-devkit/schematics": "~20.3.0",
41
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
42
+ "@nx/eslint": "~21.6.0",
43
+ "@nx/eslint-plugin": "~21.6.0",
44
+ "@nx/jest": "~21.6.0",
45
+ "@nx/js": "~21.6.0",
46
+ "@o3r/build-helpers": "workspace:~",
47
+ "@o3r/eslint-config": "workspace:~",
48
+ "@o3r/eslint-plugin": "workspace:~",
49
+ "@o3r/telemetry": "workspace:~",
50
+ "@o3r/test-helpers": "workspace:~",
51
+ "@schematics/angular": "~20.3.0",
52
+ "@stylistic/eslint-plugin": "~5.5.0",
53
+ "@types/ejs": "^3.1.2",
54
+ "@types/jest": "~29.5.2",
55
+ "@types/minimist": "^1.2.2",
56
+ "@types/node": "~22.18.0",
57
+ "@types/pid-from-port": "^1.1.0",
58
+ "@types/semver": "^7.3.13",
59
+ "@types/yargs": "~17.0.33",
60
+ "@typescript-eslint/parser": "~8.46.0",
61
+ "angular-eslint": "~20.4.0",
62
+ "cpy-cli": "^6.0.0",
63
+ "eslint": "~9.38.0",
64
+ "eslint-import-resolver-node": "~0.3.9",
65
+ "eslint-import-resolver-typescript": "~4.4.0",
66
+ "eslint-plugin-import": "~2.32.0",
67
+ "eslint-plugin-import-newlines": "~1.4.0",
68
+ "eslint-plugin-jest": "~29.0.0",
69
+ "eslint-plugin-jsdoc": "~54.7.0",
70
+ "eslint-plugin-prefer-arrow": "~1.2.3",
71
+ "eslint-plugin-unicorn": "~60.0.0",
72
+ "eslint-plugin-unused-imports": "~4.3.0",
73
+ "globals": "^16.0.0",
74
+ "jest": "~29.7.0",
75
+ "jest-junit": "~16.0.0",
76
+ "jest-util": "~29.7.0",
77
+ "jsonc-eslint-parser": "~2.4.0",
78
+ "nx": "~21.6.0",
79
+ "pid-from-port": "^1.1.3",
80
+ "rimraf": "^6.0.1",
81
+ "rxjs": "^7.8.1",
82
+ "semver": "^7.5.2",
83
+ "ts-jest": "~29.4.0",
84
+ "type-fest": "^4.30.1",
85
+ "typescript": "~5.9.2",
86
+ "typescript-eslint": "~8.46.0"
87
+ },
88
+ "generatorDependencies": {
89
+ "@redocly/openapi-core": "~2.8.0"
90
+ },
91
+ "engines": {
92
+ "node": "^20.19.0 || ^22.17.0 || ^24.0.0",
93
+ "yarn": ">=2.0.0 <5.0.0",
94
+ "npm": ">=4"
95
+ }
96
+ }
@@ -0,0 +1,18 @@
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
+ }
14
+ /**
15
+ * Generate Template files
16
+ * @param options
17
+ */
18
+ export declare const generateTemplate: (options: CreateOptions) => Promise<void[]>;
@@ -0,0 +1,43 @@
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 ejs_1 = require("ejs");
7
+ const globby_1 = require("globby");
8
+ const TEMPLATE_EXTENSION = '.template';
9
+ /**
10
+ * Generate Template files
11
+ * @param options
12
+ */
13
+ 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' }));
15
+ const templatesDirectory = (0, node_path_1.resolve)(__dirname, '..', 'templates');
16
+ const regExpExtension = new RegExp(`\\${TEMPLATE_EXTENSION}$`);
17
+ const generatedCode = (0, globby_1.sync)('**/*', { cwd: templatesDirectory, dot: true })
18
+ .map(async (templatePath) => {
19
+ const templatePathAbsolute = (0, node_path_1.resolve)(templatesDirectory, templatePath);
20
+ const content = await (0, ejs_1.renderFile)(templatePathAbsolute, {
21
+ ...options,
22
+ redoclyVersion: generatorDependencies['@redocly/openapi-core'],
23
+ standardGitignoreNode: await (await fetch('https://www.toptal.com/developers/gitignore/api/node')).text()
24
+ }, { async: true });
25
+ return {
26
+ templatePath,
27
+ content
28
+ };
29
+ })
30
+ .map(async (file) => {
31
+ const { templatePath, content } = await file;
32
+ const outputPath = (0, node_path_1.resolve)(options.target, templatePath.replace(regExpExtension, ''));
33
+ try {
34
+ await node_fs_1.promises.mkdir((0, node_path_1.dirname)(outputPath), { recursive: true });
35
+ }
36
+ catch {
37
+ // ignore error if folder already exists
38
+ }
39
+ await node_fs_1.promises.writeFile(outputPath, content, { encoding: 'utf8' });
40
+ });
41
+ return Promise.all(generatedCode);
42
+ };
43
+ exports.generateTemplate = generateTemplate;
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/src/index.js ADDED
@@ -0,0 +1,38 @@
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
+ };
32
+ await (0, generate_template_1.generateTemplate)(options);
33
+ })
34
+ .version(version)
35
+ .alias('h', 'help')
36
+ .alias('v', 'version')
37
+ .parse();
38
+ })();
@@ -0,0 +1,4 @@
1
+ <%= standardGitignoreNode %>
2
+
3
+ # Ignore external models
4
+ /<%= externalModelPath %>
@@ -0,0 +1,6 @@
1
+ {
2
+ "recommendations": [
3
+ "42Crunch.vscode-openapi",
4
+ "stoplight.spectral"
5
+ ]
6
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "editor.defaultFormatter": "42Crunch.vscode-openapi",
3
+ "files.readonlyFromPermissions": true,
4
+ "files.readonlyInclude": {
5
+ "**/.cache/**": true,
6
+ "**/node_modules/**": true,
7
+ "**/<%= externalModelPath %>/**/*.{json,yaml,yml}": true
8
+ }
9
+ }
@@ -0,0 +1,28 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ title: My first OpenApi Model
4
+ version: '1.0'
5
+ description: Example of an OpenAPI specification
6
+
7
+ servers:
8
+ - url: 'https://{environment}.my-api.com'
9
+ variables:
10
+ environment:
11
+ enum:
12
+ - 'dev'
13
+ - 'prd'
14
+ default: 'prd'
15
+ description: Software environment
16
+ security: []
17
+ paths:
18
+ '/v1/example':
19
+ get:
20
+ summary: Retrieve an example.
21
+ tags:
22
+ - ExampleTag
23
+ operationId: example-tag
24
+ responses:
25
+ '200':
26
+ $ref: '../responses/ExampleResponse.v1.yaml'
27
+ description: |-
28
+ Example endpoint description.
@@ -0,0 +1,8 @@
1
+ title: Example
2
+ description: |-
3
+ Example model for demonstration purposes.
4
+ type: object
5
+ properties:
6
+ field:
7
+ type: string
8
+ description: Sample data field
@@ -0,0 +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
@@ -0,0 +1,34 @@
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 %>",
4
+ "preferUnplugged": true,
5
+ "version": "0.0.0-placeholder",
6
+ "description": "My Specification description",
7
+ "main": "bundle/specification.yaml",
8
+ "files": [
9
+ "bundle",
10
+ "models"
11
+ ],
12
+ "readme": "README.md",
13
+ "scripts": {
14
+ "build": "redocly bundle",
15
+ "retrieve-externals": "ama-openapi install",
16
+ "postinstall": "ama-openapi install"
17
+ },
18
+ "dependencies": {
19
+ "@ama-openapi/cli": "~<%= version %>"
20
+ },
21
+ "devDependencies": {
22
+ "@ama-openapi/redocly-plugin": "~<%= version %>",
23
+ "@redocly/cli": "<%= redoclyVersion %>"
24
+ },
25
+ "exports": {
26
+ "./package.json": "./package.json",
27
+ "./models/*": "./models/*",
28
+ "./bundle/*": "./bundle/*",
29
+ ".": {
30
+ "module": "./bundle/specification.yaml",
31
+ "default": "./bundle/specification.yaml"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,11 @@
1
+ extends:
2
+ - recommended
3
+
4
+ plugins:
5
+ - '@ama-openapi/redocly-plugin'
6
+
7
+ apis:
8
+ example@v1:
9
+ root: apis/example.v1.yaml
10
+ output: bundle/specification.yaml
11
+ prepare-publish
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>AmadeusITGroup/otter//packages/@ama-openapi/core/renovate#<%= version %>"
5
+ ]
6
+ }
@@ -0,0 +1,9 @@
1
+ description: |-
2
+ Example response model for demonstration purposes.
3
+ content:
4
+ application/json:
5
+ schema:
6
+ type: object
7
+ properties:
8
+ data:
9
+ $ref: '../models/ExampleModel.v1.yaml'