@acmekit/acmekit-oas-cli 2.13.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 (44) hide show
  1. package/README.md +155 -0
  2. package/dist/command-docs.d.ts +13 -0
  3. package/dist/command-docs.d.ts.map +1 -0
  4. package/dist/command-docs.js +233 -0
  5. package/dist/command-docs.js.map +1 -0
  6. package/dist/command-oas.d.ts +13 -0
  7. package/dist/command-oas.d.ts.map +1 -0
  8. package/dist/command-oas.js +210 -0
  9. package/dist/command-oas.js.map +1 -0
  10. package/dist/index.d.ts +4 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +37 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/tsconfig.tsbuildinfo +1 -0
  15. package/dist/types.d.ts +10 -0
  16. package/dist/types.d.ts.map +1 -0
  17. package/dist/types.js +1 -0
  18. package/dist/types.js.map +1 -0
  19. package/dist/utils/circular-patch-utils.d.ts +8 -0
  20. package/dist/utils/circular-patch-utils.d.ts.map +1 -0
  21. package/dist/utils/circular-patch-utils.js +70 -0
  22. package/dist/utils/circular-patch-utils.js.map +1 -0
  23. package/dist/utils/combine-oas.d.ts +3 -0
  24. package/dist/utils/combine-oas.d.ts.map +1 -0
  25. package/dist/utils/combine-oas.js +97 -0
  26. package/dist/utils/combine-oas.js.map +1 -0
  27. package/dist/utils/fs-utils.d.ts +4 -0
  28. package/dist/utils/fs-utils.d.ts.map +1 -0
  29. package/dist/utils/fs-utils.js +69 -0
  30. package/dist/utils/fs-utils.js.map +1 -0
  31. package/dist/utils/json-utils.d.ts +3 -0
  32. package/dist/utils/json-utils.d.ts.map +1 -0
  33. package/dist/utils/json-utils.js +18 -0
  34. package/dist/utils/json-utils.js.map +1 -0
  35. package/dist/utils/merge-oas.d.ts +4 -0
  36. package/dist/utils/merge-oas.d.ts.map +1 -0
  37. package/dist/utils/merge-oas.js +87 -0
  38. package/dist/utils/merge-oas.js.map +1 -0
  39. package/dist/utils/yaml-utils.d.ts +6 -0
  40. package/dist/utils/yaml-utils.d.ts.map +1 -0
  41. package/dist/utils/yaml-utils.js +67 -0
  42. package/dist/utils/yaml-utils.js.map +1 -0
  43. package/oas/default.oas.base.yaml +5 -0
  44. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # acmekit-oas-cli - 0.1.0 - experimental
2
+
3
+ A command-line tool for all OpenAPI Specifications (OAS) related tooling.
4
+
5
+ ## Install
6
+
7
+ `yarn add --dev @acmekit/acmekit-oas-cli`
8
+
9
+ Install in the global namespace is not yet supported.
10
+ ~~`npm install -g @acmekit/acmekit-oas-cli`~~
11
+
12
+ ## Configuration / First time setup
13
+
14
+ N/A
15
+
16
+ ## How to use
17
+
18
+ ```bash
19
+ yarn acmekit-oas <command>
20
+ ```
21
+
22
+ ---
23
+
24
+ ### Command - `oas`
25
+
26
+ This command will scan the `@acmekit/acmekit` package in order to extract JSDoc OAS into a json file.
27
+
28
+ The command will output one of three the files `admin.oas.json`, `store.oas.json` or `combined.oas.json` in the same
29
+ directory that the command was run.
30
+
31
+ Invalid OAS with throw an error and will prevent the files from being outputted.
32
+
33
+ #### `--type <string>`
34
+
35
+ Specify which API OAS to create. Accepts `admin`, `store`, `combined`.
36
+
37
+ The `combined` option will merge both the admin and the store APIs into a single OAS file.
38
+
39
+ ```bash
40
+ yarn acmekit-oas oas --type admin
41
+ ```
42
+
43
+ #### `--out-dir <path>`
44
+
45
+ Specify in which directory should the files be outputted. It accepts a relative or absolute path.
46
+ If the directory doesn't exist, it will be created. Defaults to `./`.
47
+
48
+ ```bash
49
+ yarm acmekit-oas oas --out-dir
50
+ ```
51
+
52
+ #### `--paths <paths...>`
53
+
54
+ Allows passing additional directory paths to crawl for JSDoc OAS and include in the generated OAS.
55
+ It accepts multiple entries.
56
+
57
+ ```bash
58
+ yarn acmekit-oas oas --paths ~/acmekit-server/src
59
+ ```
60
+
61
+ #### `--base <path>`
62
+
63
+ Allows overwriting the content the API's base.yaml OAS that is fed to swagger-inline.
64
+ Paths, tags, and components will be merged together. Other OAS properties will be overwritten.
65
+
66
+ ```bash
67
+ yarn acmekit-oas oas --base ~/acmekit-server/oas/custom.oas.base.yaml
68
+ ```
69
+
70
+ #### `--dry-run`
71
+
72
+ Will package the OAS but will not output file. Useful for validating OAS.
73
+
74
+ ```bash
75
+ yarn acmekit-oas oas --dry-run
76
+ ```
77
+
78
+ #### `--force`
79
+
80
+ Ignore OAS errors and attempt to output generated OAS files.
81
+
82
+ ```bash
83
+ yarn acmekit-oas oas --force
84
+ ```
85
+
86
+ ---
87
+
88
+ ### Command - `docs`
89
+
90
+ Will sanitize OAS for use with Redocly's API documentation viewer.
91
+
92
+ #### `--src-file <path>`
93
+
94
+ Specify the path to the OAS JSON file.
95
+
96
+ ```bash
97
+ yarm acmekit-oas docs --src-file ./store.oas.json
98
+ ```
99
+
100
+ #### `--out-dir <path>`
101
+
102
+ Specify in which directory should the files be outputted. Accepts relative and absolute path.
103
+ If the directory doesn't exist, it will be created. Defaults to `./`.
104
+
105
+ ```bash
106
+ yarn acmekit-oas docs --src-file ./store.oas.json --out-dir ./docs`
107
+ ```
108
+
109
+ #### `--config <path>`
110
+
111
+ Specify the path to a Redocly config file.
112
+
113
+ ```bash
114
+ yarn acmekit-oas --src-file ./store.oas.json --config ./redocly-config.yaml
115
+ ```
116
+
117
+ #### `--dry-run`
118
+
119
+ Will sanitize the OAS but will not output file. Useful for troubleshooting circular reference issues.
120
+
121
+ ```bash
122
+ yarn acmekit-oas docs --src-file ./store.oas.json --dry-run
123
+ ```
124
+
125
+ #### `--clean`
126
+
127
+ Delete destination directory content before generating the docs.
128
+
129
+ ```bash
130
+ yarn acmekit-oas docs --src-file ./store.oas.json --clean
131
+ ```
132
+
133
+ #### `--split`
134
+
135
+ Creates a multi-file structure output. Uses `redocly split` internally.
136
+
137
+ ```bash
138
+ yarn acmekit-oas docs --src-file ./store.oas.json --split
139
+ ```
140
+
141
+ #### `--preview`
142
+
143
+ Generate a preview of the API documentation in a browser. Does not output files. Uses `redocly preview-docs` internally.
144
+
145
+ ```bash
146
+ yarn acmekit-oas docs --src-file ../../../www/apps/api-reference/specs/store.oas.json --preview
147
+ ```
148
+
149
+ #### `--html`
150
+
151
+ Generate a zero-dependency static HTML file. Uses `redocly build-docs` internally.
152
+
153
+ ```bash
154
+ yarn acmekit-oas docs --src-file ./store.oas.json --html
155
+ ```
@@ -0,0 +1,13 @@
1
+ import { Command, Option, OptionValues } from "commander";
2
+ /**
3
+ * CLI Command declaration
4
+ */
5
+ export declare const commandName = "docs";
6
+ export declare const commandDescription = "Sanitize OAS for use with Redocly's API documentation viewer.";
7
+ export declare const commandOptions: Option[];
8
+ export declare function getCommand(): Command;
9
+ /**
10
+ * Main
11
+ */
12
+ export declare function execute(cliParams: OptionValues): Promise<void>;
13
+ //# sourceMappingURL=command-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-docs.d.ts","sourceRoot":"","sources":["../src/command-docs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAiCzD;;GAEG;AACH,eAAO,MAAM,WAAW,SAAS,CAAA;AACjC,eAAO,MAAM,kBAAkB,kEACkC,CAAA;AAEjE,eAAO,MAAM,cAAc,EAAE,MAAM,EA+BlC,CAAA;AAED,wBAAgB,UAAU,IAAI,OAAO,CASpC;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkFpE"}
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.commandOptions = exports.commandDescription = exports.commandName = void 0;
40
+ exports.getCommand = getCommand;
41
+ exports.execute = execute;
42
+ const preview_docs_1 = require("@redocly/cli/lib/commands/preview-docs");
43
+ const wrapper_1 = require("@redocly/cli/lib/wrapper");
44
+ const commander_1 = require("commander");
45
+ const execa_1 = __importDefault(require("execa"));
46
+ const promises_1 = __importStar(require("fs/promises"));
47
+ const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
48
+ const path = __importStar(require("path"));
49
+ const circular_patch_utils_1 = require("./utils/circular-patch-utils");
50
+ const fs_utils_1 = require("./utils/fs-utils");
51
+ const json_utils_1 = require("./utils/json-utils");
52
+ const yaml_utils_1 = require("./utils/yaml-utils");
53
+ /**
54
+ * Constants
55
+ */
56
+ const basePath = path.resolve(__dirname, "../");
57
+ const acmekitPluginRelativePath = "./plugins/acmekit/index.js";
58
+ const acmekitPluginAbsolutePath = path.resolve(basePath, "redocly/plugins/acmekit/index.js");
59
+ const configFileDefault = path.resolve(basePath, "redocly/redocly-config.yaml");
60
+ /**
61
+ * CLI Command declaration
62
+ */
63
+ exports.commandName = "docs";
64
+ exports.commandDescription = "Sanitize OAS for use with Redocly's API documentation viewer.";
65
+ exports.commandOptions = [
66
+ new commander_1.Option("-s, --src-file <srcFile>", "Path to source OAS JSON file.").makeOptionMandatory(),
67
+ new commander_1.Option("-o, --out-dir <outDir>", "Destination directory to output the sanitized OAS files.").default(process.cwd()),
68
+ new commander_1.Option("--config <config>", "Configuration file to merge with default configuration before passing to Redocly's CLI."),
69
+ new commander_1.Option("-D, --dry-run", "Do not output files."),
70
+ new commander_1.Option("--clean", "Delete destination directory content before generating documentation."),
71
+ new commander_1.Option("--split", "Creates a multi-file structure output."),
72
+ new commander_1.Option("--preview", "Open a preview of the documentation. Does not output files."),
73
+ new commander_1.Option("--html", "Generate a static HTML using Redocly's build-docs command."),
74
+ new commander_1.Option("--main-file-name <mainFileName>", "The name of the main YAML file.").default("openapi.yaml"),
75
+ ];
76
+ function getCommand() {
77
+ const command = new commander_1.Command(exports.commandName);
78
+ command.description(exports.commandDescription);
79
+ for (const opt of exports.commandOptions) {
80
+ command.addOption(opt);
81
+ }
82
+ command.action(async (options) => await execute(options));
83
+ command.showHelpAfterError(true);
84
+ return command;
85
+ }
86
+ /**
87
+ * Main
88
+ */
89
+ async function execute(cliParams) {
90
+ /**
91
+ * Process CLI options
92
+ */
93
+ const shouldClean = !!cliParams.clean;
94
+ const shouldSplit = !!cliParams.split;
95
+ const shouldPreview = !!cliParams.preview;
96
+ const shouldBuildHTML = !!cliParams.html;
97
+ const dryRun = !!cliParams.dryRun;
98
+ const srcFile = path.resolve(cliParams.srcFile);
99
+ const outDir = path.resolve(cliParams.outDir);
100
+ const configFileCustom = cliParams.config
101
+ ? path.resolve(cliParams.config)
102
+ : undefined;
103
+ if (configFileCustom) {
104
+ if (!(await (0, fs_utils_1.isFile)(configFileCustom))) {
105
+ throw new Error(`--config must be a file - ${configFileCustom}`);
106
+ }
107
+ if (![".json", ".yaml"].includes(path.extname(configFileCustom))) {
108
+ throw new Error(`--config file must be of type .json or .yaml - ${configFileCustom}`);
109
+ }
110
+ }
111
+ /**
112
+ * Command execution
113
+ */
114
+ console.log(`🟣 Generating API documentation`);
115
+ const tmpDir = await (0, fs_utils_1.getTmpDirectory)();
116
+ const configTmpFile = path.resolve(tmpDir, "redocly-config.yaml");
117
+ /** matches naming convention from `redocly split` */
118
+ const finalOASFile = cliParams.mainFileName;
119
+ await createTmpConfig(configFileDefault, configTmpFile);
120
+ if (configFileCustom) {
121
+ console.log(`🔵 Merging configuration file - ${configFileCustom} > ${configTmpFile}`);
122
+ await mergeConfig(configTmpFile, configFileCustom, configTmpFile);
123
+ }
124
+ if (!dryRun) {
125
+ if (shouldClean) {
126
+ console.log(`🟠 Cleaning output directory`);
127
+ await promises_1.default.rm(outDir, { recursive: true, force: true });
128
+ }
129
+ await (0, promises_1.mkdir)(outDir, { recursive: true });
130
+ }
131
+ const srcFileSanitized = path.resolve(tmpDir, "tmp.oas.yaml");
132
+ await sanitizeOAS(srcFile, srcFileSanitized, configTmpFile);
133
+ await fixCirclularReferences(srcFileSanitized);
134
+ if (dryRun) {
135
+ console.log(`⚫️ Dry run - no files generated`);
136
+ // check out possible changes in redocly config
137
+ await (0, execa_1.default)("git", [
138
+ "checkout",
139
+ path.join(basePath, "redocly", "redocly-config.yaml"),
140
+ ]);
141
+ return;
142
+ }
143
+ if (shouldPreview) {
144
+ await preview(srcFileSanitized, configTmpFile);
145
+ return;
146
+ }
147
+ if (shouldSplit) {
148
+ await generateReference(srcFileSanitized, outDir);
149
+ }
150
+ else {
151
+ await (0, yaml_utils_1.writeYaml)(path.join(outDir, finalOASFile), await promises_1.default.readFile(srcFileSanitized, "utf8"));
152
+ }
153
+ if (shouldBuildHTML) {
154
+ const outHTMLFile = path.resolve(outDir, "index.html");
155
+ await buildHTML(finalOASFile, outHTMLFile, configTmpFile);
156
+ }
157
+ console.log(`⚫️ API documentation generated - ${outDir}`);
158
+ }
159
+ const mergeConfig = async (configFileDefault, configFileCustom, configFileOut) => {
160
+ const configDefault = await (0, yaml_utils_1.readYaml)(configFileDefault);
161
+ const configCustom = path.extname(configFileCustom) === ".yaml"
162
+ ? await (0, yaml_utils_1.readYaml)(configFileCustom)
163
+ : await (0, json_utils_1.readJson)(configFileCustom);
164
+ const config = (0, lodash_mergewith_1.default)(configDefault, configCustom, (objValue, srcValue) => Array.isArray(objValue) ? objValue.concat(srcValue) : undefined);
165
+ await (0, yaml_utils_1.writeYamlFromJson)(configFileOut, config);
166
+ };
167
+ const createTmpConfig = async (configFileDefault, configFileOut) => {
168
+ var _a;
169
+ const config = (await (0, yaml_utils_1.readYaml)(configFileDefault));
170
+ config.plugins = ((_a = config.plugins) !== null && _a !== void 0 ? _a : []).filter((plugin) => plugin !== acmekitPluginRelativePath);
171
+ config.plugins.push(acmekitPluginAbsolutePath);
172
+ await (0, yaml_utils_1.writeYamlFromJson)(configFileOut, config);
173
+ };
174
+ const sanitizeOAS = async (srcFile, outFile, configFile) => {
175
+ const { all: logs } = await (0, execa_1.default)("yarn", [
176
+ "redocly",
177
+ "bundle",
178
+ srcFile,
179
+ `--output=${outFile}`,
180
+ `--config=${configFile}`,
181
+ ], { cwd: basePath, all: true });
182
+ console.log(logs);
183
+ };
184
+ const fixCirclularReferences = async (srcFile) => {
185
+ const { circularRefs, oas } = await (0, circular_patch_utils_1.getCircularReferences)(srcFile);
186
+ if (circularRefs.length) {
187
+ const recommendation = (0, circular_patch_utils_1.getCircularPatchRecommendation)(circularRefs, oas);
188
+ if (Object.keys(recommendation).length) {
189
+ const hint = (0, circular_patch_utils_1.formatHintRecommendation)(recommendation);
190
+ const hintMessage = `
191
+ ###
192
+ ${hint}
193
+ ###
194
+ `;
195
+ const redoclyConfigPath = path.join(basePath, "redocly", "redocly-config.yaml");
196
+ const originalContent = (await (0, yaml_utils_1.readYaml)(redoclyConfigPath));
197
+ Object.keys(recommendation).forEach((recKey) => {
198
+ originalContent.decorators["acmekit/circular-patch"].schemas[recKey] = [
199
+ ...(originalContent.decorators["acmekit/circular-patch"].schemas[recKey] || []),
200
+ ...recommendation[recKey],
201
+ ];
202
+ });
203
+ await (0, yaml_utils_1.writeYaml)(redoclyConfigPath, (0, yaml_utils_1.jsonObjectToYamlString)(originalContent));
204
+ console.log(`🟡 Added the following unhandled circular references to redocly-config.ts:` +
205
+ hintMessage);
206
+ }
207
+ }
208
+ console.log(`🟢 All circular references are handled`);
209
+ };
210
+ const generateReference = async (srcFile, outDir) => {
211
+ const { all: logs } = await (0, execa_1.default)("yarn", ["redocly", "split", srcFile, `--outDir=${outDir}`], { cwd: basePath, all: true });
212
+ console.log(logs);
213
+ };
214
+ const preview = async (oasFile, configFile) => {
215
+ await (0, wrapper_1.commandWrapper)(preview_docs_1.previewDocs)({
216
+ port: 8080,
217
+ host: "127.0.0.1",
218
+ api: oasFile,
219
+ config: configFile,
220
+ });
221
+ };
222
+ const buildHTML = async (srcFile, outFile, configFile) => {
223
+ const { all: logs } = await (0, execa_1.default)("yarn", [
224
+ "redocly",
225
+ "build-docs",
226
+ srcFile,
227
+ `--output=${outFile}`,
228
+ `--config=${configFile}`,
229
+ `--cdn=true`,
230
+ ], { cwd: basePath, all: true });
231
+ console.log(logs);
232
+ };
233
+ //# sourceMappingURL=command-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-docs.js","sourceRoot":"","sources":["../src/command-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,gCASC;AAKD,0BAkFC;AA9KD,yEAG+C;AAC/C,sDAAyD;AACzD,yCAAyD;AACzD,kDAAyB;AACzB,wDAAuC;AACvC,wEAAwC;AAExC,2CAA4B;AAE5B,uEAIqC;AACrC,+CAA0D;AAC1D,mD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AAE,YAAY,MAAM,EAAE,CAAC,EACnD,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAC7B,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAE,UAAkB,EAAiB,EAAE;IAC3E,MAAM,IAAA,wBAAc,EAAC,0BAAW,CAAC,CAAC;QAChC,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,UAAU;KACoB,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,KAAK,EACrB,OAAe,EACf,OAAe,EACf,UAAkB,EACH,EAAE;IACjB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,eAAK,EAC/B,MAAM,EACN;QACE,SAAS;QACT,YAAY;QACZ,OAAO;QACP,YAAY,OAAO,EAAE;QACrB,YAAY,UAAU,EAAE;QACxB,YAAY;KACb,EACD,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAC7B,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Command, Option, OptionValues } from "commander";
2
+ /**
3
+ * CLI Command declaration
4
+ */
5
+ export declare const commandName = "oas";
6
+ export declare const commandDescription = "Compile full OAS from swagger-inline compliant JSDoc.";
7
+ export declare const commandOptions: Option[];
8
+ export declare function getCommand(): Command;
9
+ /**
10
+ * Main
11
+ */
12
+ export declare function execute(cliParams: OptionValues): Promise<void>;
13
+ //# sourceMappingURL=command-oas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-oas.d.ts","sourceRoot":"","sources":["../src/command-oas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAmBzD;;GAEG;AACH,eAAO,MAAM,WAAW,QAAQ,CAAA;AAChC,eAAO,MAAM,kBAAkB,0DAC0B,CAAA;AAEzD,eAAO,MAAM,cAAc,EAAE,MAAM,EAsBlC,CAAA;AAED,wBAAgB,UAAU,YASzB;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,SAAS,EAAE,YAAY,iBAqEpD"}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.commandOptions = exports.commandDescription = exports.commandName = void 0;
40
+ exports.getCommand = getCommand;
41
+ exports.execute = execute;
42
+ const openapi_parser_1 = __importDefault(require("@readme/openapi-parser"));
43
+ const commander_1 = require("commander");
44
+ const promises_1 = require("fs/promises");
45
+ const path = __importStar(require("path"));
46
+ const swagger_inline_1 = __importDefault(require("swagger-inline"));
47
+ const combine_oas_1 = require("./utils/combine-oas");
48
+ const merge_oas_1 = require("./utils/merge-oas");
49
+ const fs_utils_1 = require("./utils/fs-utils");
50
+ /**
51
+ * Constants
52
+ */
53
+ // AcmeKit core package directory
54
+ const acmekitPackagePath = path.dirname(require.resolve("@acmekit/acmekit"));
55
+ const basePath = path.resolve(__dirname, "../");
56
+ /**
57
+ * CLI Command declaration
58
+ */
59
+ exports.commandName = "oas";
60
+ exports.commandDescription = "Compile full OAS from swagger-inline compliant JSDoc.";
61
+ exports.commandOptions = [
62
+ new commander_1.Option("-t, --type <type>", "API type to compile.")
63
+ .choices(["admin", "store", "combined"])
64
+ .makeOptionMandatory(),
65
+ new commander_1.Option("-o, --out-dir <outDir>", "Destination directory to output generated OAS files.").default(process.cwd()),
66
+ new commander_1.Option("-D, --dry-run", "Do not output files."),
67
+ new commander_1.Option("-p, --paths <paths...>", "Additional paths to crawl for OAS JSDoc."),
68
+ new commander_1.Option("-b, --base <base>", "Custom base OAS file to use for swagger-inline."),
69
+ new commander_1.Option("-F, --force", "Ignore OAS validation and output OAS files."),
70
+ new commander_1.Option("--local", "Generate OAS from local files rather than public OAS. This is useful for generating references in the AcmeKit monorepo."),
71
+ ];
72
+ function getCommand() {
73
+ const command = new commander_1.Command(exports.commandName);
74
+ command.description(exports.commandDescription);
75
+ for (const opt of exports.commandOptions) {
76
+ command.addOption(opt);
77
+ }
78
+ command.action(async (options) => await execute(options));
79
+ command.showHelpAfterError(true);
80
+ return command;
81
+ }
82
+ /**
83
+ * Main
84
+ */
85
+ async function execute(cliParams) {
86
+ var _a;
87
+ /**
88
+ * Process CLI options
89
+ */
90
+ const dryRun = !!cliParams.dryRun;
91
+ const force = !!cliParams.force;
92
+ const v2 = !!cliParams.v2;
93
+ const local = !!cliParams.local;
94
+ const apiType = cliParams.type;
95
+ const outDir = path.resolve(cliParams.outDir);
96
+ const additionalPaths = ((_a = cliParams.paths) !== null && _a !== void 0 ? _a : []).map((additionalPath) => path.resolve(additionalPath));
97
+ for (const additionalPath of additionalPaths) {
98
+ if (!(await isDirectory(additionalPath))) {
99
+ throw new Error(`--paths must be a directory - ${additionalPath}`);
100
+ }
101
+ }
102
+ const baseFile = cliParams.base ? path.resolve(cliParams.base) : undefined;
103
+ if (baseFile) {
104
+ if (!(await (0, fs_utils_1.isFile)(cliParams.base))) {
105
+ throw new Error(`--base must be a file - ${baseFile}`);
106
+ }
107
+ }
108
+ /**
109
+ * Command execution
110
+ */
111
+ if (!dryRun) {
112
+ await (0, promises_1.mkdir)(outDir, { recursive: true });
113
+ }
114
+ let oas;
115
+ console.log(`🟣 Generating OAS - ${apiType}`);
116
+ if (apiType === "combined") {
117
+ const adminOAS = !local
118
+ ? await getPublicOas("admin")
119
+ : await getOASFromCodebase("admin");
120
+ const storeOAS = !local
121
+ ? await getPublicOas("store")
122
+ : await getOASFromCodebase("store");
123
+ oas = await (0, combine_oas_1.combineOAS)(adminOAS, storeOAS);
124
+ }
125
+ else {
126
+ oas = !local
127
+ ? await getPublicOas(apiType)
128
+ : await getOASFromCodebase(apiType);
129
+ }
130
+ if (additionalPaths.length || baseFile) {
131
+ const customOAS = await getOASFromPaths(additionalPaths, baseFile);
132
+ if (baseFile) {
133
+ (0, merge_oas_1.mergeBaseIntoOAS)(oas, customOAS);
134
+ }
135
+ if (additionalPaths.length) {
136
+ (0, merge_oas_1.mergePathsAndSchemasIntoOAS)(oas, customOAS);
137
+ }
138
+ }
139
+ await validateOAS(oas, apiType, force);
140
+ if (dryRun) {
141
+ console.log(`⚫️ Dry run - no files generated`);
142
+ return;
143
+ }
144
+ await exportOASToJSON(oas, apiType, outDir);
145
+ }
146
+ /**
147
+ * Methods
148
+ */
149
+ async function getOASFromCodebase(apiType) {
150
+ /**
151
+ * OAS output directory
152
+ */
153
+ const oasOutputPath = path.resolve(__dirname, "..", "..", "..", "..", "..", "www", "utils", "generated", "oas-output");
154
+ const gen = await (0, swagger_inline_1.default)([
155
+ path.resolve(oasOutputPath, "operations", apiType),
156
+ path.resolve(oasOutputPath, "schemas"),
157
+ // We currently load error schemas from here. If we change
158
+ // that in the future, we should change the path.
159
+ path.resolve(acmekitPackagePath, "dist", "utils/middlewares"),
160
+ ], {
161
+ base: path.resolve(oasOutputPath, "base", `${apiType}.oas.base.yaml`),
162
+ format: ".json",
163
+ });
164
+ return (await openapi_parser_1.default.parse(JSON.parse(gen)));
165
+ }
166
+ async function getPublicOas(apiType) {
167
+ const url = `https://docs.acmekit.com/api/download/${apiType}`;
168
+ return (await openapi_parser_1.default.parse(url));
169
+ }
170
+ async function getOASFromPaths(additionalPaths = [], customBaseFile) {
171
+ console.log(`🔵 Gathering custom OAS`);
172
+ const gen = await (0, swagger_inline_1.default)(additionalPaths.map((additionalPath) => {
173
+ return additionalPath.replace(/\\/g, "/");
174
+ }), {
175
+ base: customBaseFile !== null && customBaseFile !== void 0 ? customBaseFile : path.resolve(basePath, "oas", "default.oas.base.yaml"),
176
+ format: ".json",
177
+ logger: (log) => {
178
+ console.log(log);
179
+ },
180
+ });
181
+ return (await openapi_parser_1.default.parse(JSON.parse(gen)));
182
+ }
183
+ async function validateOAS(oas, apiType, force = false) {
184
+ try {
185
+ await openapi_parser_1.default.validate(JSON.parse(JSON.stringify(oas)));
186
+ console.log(`🟢 Valid OAS - ${apiType}`);
187
+ }
188
+ catch (err) {
189
+ console.error(`🔴 Invalid OAS - ${apiType}`, err);
190
+ if (!force) {
191
+ process.exit(1);
192
+ }
193
+ }
194
+ }
195
+ async function exportOASToJSON(oas, apiType, targetDir) {
196
+ const json = JSON.stringify(oas, null, 2);
197
+ const filePath = path.resolve(targetDir, `${apiType}.oas.json`);
198
+ await (0, promises_1.writeFile)(filePath, json);
199
+ console.log(`⚫️ Exported OAS - ${apiType} - ${filePath}`);
200
+ }
201
+ async function isDirectory(dirPath) {
202
+ try {
203
+ return (await (0, promises_1.lstat)(path.resolve(dirPath))).isDirectory();
204
+ }
205
+ catch (err) {
206
+ console.log(err);
207
+ return false;
208
+ }
209
+ }
210
+ //# sourceMappingURL=command-oas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-oas.js","sourceRoot":"","sources":["../src/command-oas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,gCASC;AAKD,0BAqEC;AAtID,4EAAkD;AAClD,yCAAyD;AACzD,0CAAqD;AAErD,2CAA4B;AAC5B,oEAA0C;AAC1C,qDAAgD;AAChD,iDAG0B;AAC1B,+CAAyC;AAEzC;;GAEG;AACH,iCAAiC;AACjC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AAE/C;;GAEG;AACU,QAAA,WAAW,GAAG,KAAK,CAAA;AACnB,QAAA,kBAAkB,GAC7B,uDAAuD,CAAA;AAE5C,QAAA,cAAc,GAAa;IACtC,IAAI,kBAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;SACpD,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;SACvC,mBAAmB,EAAE;IACxB,IAAI,kBAAM,CACR,wBAAwB,EACxB,sDAAsD,CACvD,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IACxB,IAAI,kBAAM,CAAC,eAAe,EAAE,sBAAsB,CAAC;IACnD,IAAI,kBAAM,CACR,wBAAwB,EACxB,0CAA0C,CAC3C;IACD,IAAI,kBAA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GAAG,CAAC,CAAC,CAAC,CAAA;QAC7D,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAA;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,GAAG,CAAC,CAAA;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,eAAe,CAC5B,GAAkB,EAClB,OAAgB,EAChB,SAAiB;IAEjB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,OAAO,WAAW,CAAC,CAAA;IAC/D,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC/B,OAAO,CAAC,GAAG,CAAC,qBAAqB,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAA;AAC3D,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAA,gBAAK,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env node
2
+ import { Command } from "commander";
3
+ export declare function getBaseCommand(): Command;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuBnC,wBAAgB,cAAc,YAU7B"}