@bymbly/api-tools 1.0.0

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.
@@ -0,0 +1,80 @@
1
+ import { Command, Option, } from "@commander-js/extra-typings";
2
+ import { runBatchInputCommand, } from "../cli/helpers.js";
3
+ import { isQuiet, resolveDocuments, resolveStdio, } from "../cli/runtime.js";
4
+ import { resolveConfig, run } from "./cli.js";
5
+ const VALID_OUTPUT_FORMATS = [
6
+ "codeframe",
7
+ "stylish",
8
+ "json",
9
+ "checkstyle",
10
+ "codeclimate",
11
+ "github-actions",
12
+ "markdown",
13
+ "summary",
14
+ ];
15
+ export const lintCommand = new Command("lint")
16
+ .description("Validate and lint OpenAPI, AsyncAPI, Arazzo documents using Redocly")
17
+ .argument("[input]", "Document path (default: auto-detect)")
18
+ .option("--openapi", "Lint OpenAPI document at openapi/openapi.yaml", false)
19
+ .option("--asyncapi", "Lint AsyncAPI document at asyncapi/asyncapi.yaml", false)
20
+ .option("--arazzo", "Lint Arazzo document at arazzo/arazzo.yaml", false)
21
+ .addOption(new Option("--format <format>", "Output format")
22
+ .choices([...VALID_OUTPUT_FORMATS])
23
+ .default("codeframe"))
24
+ .option("--config <file>", "Config file path (overrides auto/bundled)")
25
+ .allowExcessArguments(true)
26
+ .action(runLint);
27
+ function runLint(input, options, cmd) {
28
+ runBatchInputCommand({
29
+ input,
30
+ options,
31
+ cmd,
32
+ resolveDocuments: resolveDocuments,
33
+ execute: lint,
34
+ });
35
+ }
36
+ export function lint(params) {
37
+ const { input, options, globals } = params;
38
+ const config = resolveConfig(options.config);
39
+ // prevent using --generate-ignore-file with bundled config
40
+ // since redocly writes the generated ignore file to the config's directory
41
+ // and this would be difficult for users to find/manage
42
+ if (config.source === "bundled" &&
43
+ params.passthrough.some((arg) => arg.includes("--generate-ignore-file"))) {
44
+ console.error(`
45
+ ❌ Error: Cannot use --generate-ignore-file with bundled config
46
+
47
+ The --generate-ignore-file option requires a local Redocly configuration file, but no local config was found.
48
+
49
+ To generate a starter config, run:
50
+
51
+ api-tools redocly init
52
+
53
+ Then re-run this command.
54
+ `.trim());
55
+ return 1;
56
+ }
57
+ const args = buildArgs(params, config);
58
+ const stdio = resolveStdio(globals);
59
+ const quiet = isQuiet(globals);
60
+ if (!quiet) {
61
+ console.log("🔍 Redocly lint...");
62
+ console.log(` Input: ${input}`);
63
+ console.log(` Format: ${options.format}`);
64
+ console.log(` Config: ${config.path ?? "auto"} (${config.source})`);
65
+ }
66
+ return run(args, stdio);
67
+ }
68
+ function buildArgs(params, config) {
69
+ const { input, options, passthrough } = params;
70
+ const args = ["lint", input, "--format", options.format];
71
+ // only pass --config if we resolved an explicit path (cli or bundled)
72
+ if (config.path)
73
+ args.push("--config", config.path);
74
+ // forward any passthrough args to redocly
75
+ if (passthrough.length > 0) {
76
+ args.push(...passthrough);
77
+ }
78
+ return args;
79
+ }
80
+ //# sourceMappingURL=lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/lib/redocly/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,OAAO,EAEP,gBAAgB,EAChB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,oBAAoB,GAAG;IAC3B,WAAW;IACX,SAAS;IACT,MAAM;IACN,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,UAAU;IACV,SAAS;CACD,CAAC;AASX,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CACV,qEAAqE,CACtE;KACA,QAAQ,CAAC,SAAS,EAAE,sCAAsC,CAAC;KAE3D,MAAM,CAAC,WAAW,EAA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AM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,EAAE,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,cAAc,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS,CAChB,MAAyC,EACzC,MAAsB;IAEtB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAE/C,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzD,sEAAsE;IACtE,IAAI,MAAM,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpD,0CAA0C;IAC1C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { Command, Option, } from "@commander-js/extra-typings";
2
+ import { runSingleInputCommand, } from "../cli/helpers.js";
3
+ import { isQuiet, resolveStdio } from "../cli/runtime.js";
4
+ import { run } from "./cli.js";
5
+ export const respectCommand = new Command("respect")
6
+ .description("Execute Arazzo workflow tests using Redocly")
7
+ .argument("[input]", "Arazzo document path (default: arazzo/arazzo.yaml)")
8
+ .addOption(new Option("--workflow <names...>", "Run only specified workflows").conflicts("skip"))
9
+ .addOption(new Option("--skip <names...>", "Skip specified workflows").conflicts("workflow"))
10
+ .option("--verbose", "Enable verbose output", false)
11
+ .option("--input <params...>", "Workflow input parameters (key=value or JSON)")
12
+ .option("--server <overrides...>", "Server overrides (format: name=url)")
13
+ .option("--json-output <file>", "Save results to JSON file")
14
+ .option("--har-output <file>", "Save HTTP interactions to HAR file")
15
+ .allowExcessArguments(true)
16
+ .action(runRespect);
17
+ function runRespect(input, options, cmd) {
18
+ runSingleInputCommand({
19
+ input,
20
+ options,
21
+ cmd,
22
+ defaultInput: "arazzo/arazzo.yaml",
23
+ execute: respect,
24
+ });
25
+ }
26
+ export function respect(params) {
27
+ const { input, options, globals } = params;
28
+ const args = buildArgs(params);
29
+ const stdio = resolveStdio(globals);
30
+ const quiet = isQuiet(globals);
31
+ if (!quiet) {
32
+ console.log(`🧪 Redocly respect...`);
33
+ console.log(` Input: ${input}`);
34
+ if (options.workflow && options.workflow.length > 0) {
35
+ console.log(` Workflows: ${options.workflow.join(", ")}`);
36
+ }
37
+ if (options.skip && options.skip.length > 0) {
38
+ console.log(` Skipped Workflows: ${options.skip.join(", ")}`);
39
+ }
40
+ if (options.server && options.server.length > 0) {
41
+ console.log(` Server Overrides: ${options.server.join(", ")}`);
42
+ }
43
+ if (options.jsonOutput) {
44
+ console.log(` JSON Output: ${options.jsonOutput}`);
45
+ }
46
+ if (options.harOutput) {
47
+ console.log(` HAR Output: ${options.harOutput}`);
48
+ }
49
+ }
50
+ return run(args, stdio);
51
+ }
52
+ function buildArgs(params) {
53
+ const { input, options, passthrough } = params;
54
+ const args = ["respect", input];
55
+ if (options.workflow && options.workflow.length > 0) {
56
+ args.push("--workflow", ...options.workflow);
57
+ }
58
+ if (options.skip && options.skip.length > 0) {
59
+ args.push("--skip", ...options.skip);
60
+ }
61
+ if (options.verbose) {
62
+ args.push("--verbose");
63
+ }
64
+ if (options.input && options.input.length > 0) {
65
+ options.input.forEach((param) => {
66
+ args.push("--input", param);
67
+ });
68
+ }
69
+ if (options.server && options.server.length > 0) {
70
+ args.push("--server", ...options.server);
71
+ }
72
+ if (options.jsonOutput) {
73
+ args.push("--json-output", options.jsonOutput);
74
+ }
75
+ if (options.harOutput) {
76
+ args.push("--har-output", options.harOutput);
77
+ }
78
+ // forward any passthrough args to redocly
79
+ if (passthrough.length > 0) {
80
+ args.push(...passthrough);
81
+ }
82
+ return args;
83
+ }
84
+ //# sourceMappingURL=respect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"respect.js","sourceRoot":"","sources":["../../../src/lib/redocly/respect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAY/B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;KACjD,WAAW,CAAC,6CAA6C,CAAC;KAC1D,QAAQ,CAAC,SAAS,EAAE,oDAAoD,CAAC;KAEzE,SAAS,CACR,IAAI,MAAM,CACR,uBAAuB,EACvB,8BAA8B,CAC/B,CAAC,SAAS,CAAC,MAAM,CAAC,CACpB;KACA,SAAS,CACR,IAAI,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,SAAS,CACnE,UAAU,CACX,CACF;KACA,MAAM,CAAC,WAAW,EAAE,uBAAuB,EAAE,KAAK,CAAC;KACnD,MAAM,CACL,qBAAqB,EACrB,+CAA+C,CAChD;KACA,MAAM,CAAC,yBAAyB,EAAE,qCAAqC,CAAC;KACxE,MAAM,CAAC,sBAAsB,EAAE,2BAA2B,CAAC;KAC3D,MAAM,CAAC,qBAAqB,EAAE,oCAAoC,CAAC;KACnE,oBAAoB,CAAC,IAAI,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;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,0CAA0C;IAC1C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,16 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { resolveConfigRuntime, runCli, } from "../cli/runtime.js";
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ export const BIN_PATH = "@stoplight/spectral-cli/dist/index.js";
7
+ // https://github.com/stoplightio/spectral/blob/develop/packages/core/src/ruleset/ruleset.ts#L24
8
+ const CONFIG_REGEX = /^\.?spectral\.(ya?ml|json|m?js)$/;
9
+ const DEFAULT_CONFIG_PATH = path.join(__dirname, "../../defaults/spectral.yaml");
10
+ export function resolveConfig(cliConfig) {
11
+ return resolveConfigRuntime(cliConfig, CONFIG_REGEX, DEFAULT_CONFIG_PATH);
12
+ }
13
+ export function run(args, stdio) {
14
+ return runCli(BIN_PATH, args, stdio);
15
+ }
16
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/lib/spectral/cli.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,oBAAoB,EAEpB,MAAM,GAEP,MAAM,mBAAmB,CAAC;AAE3B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,QAAQ,GAAG,uCAAuC,CAAC;AAEhE,gGAAgG;AAChG,MAAM,YAAY,GAAG,kCAAkC,CAAC;AAExD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CACnC,SAAS,EACT,8BAA8B,CAC/B,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,SAA6B;IACzD,OAAO,oBAAoB,CAAC,SAAS,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAc,EAAE,KAAgB;IAClD,OAAO,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { createInitCommand, handleRawPassthrough } from "../cli/helpers.js";
3
+ import { run } from "./cli.js";
4
+ import { lintCommand } from "./lint.js";
5
+ export const spectralCommand = new Command("spectral")
6
+ .description("Spectral-related commands")
7
+ .allowExcessArguments(true)
8
+ .configureHelp({
9
+ sortSubcommands: true,
10
+ sortOptions: true,
11
+ })
12
+ .action((opts, cmd) => {
13
+ handleRawPassthrough(opts, cmd, run);
14
+ })
15
+ .addCommand(createInitCommand("spectral.yaml"))
16
+ .addCommand(lintCommand);
17
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/lib/spectral/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,2BAA2B,CAAC;KACxC,oBAAoB,CAAC,IAAI,CAAC;KAC1B,aAAa,CAAC;IACb,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,IAAI;CAClB,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACpB,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC,CAAC;KACD,UAAU,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;KAC9C,UAAU,CAAC,WAAW,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { Command, Option, } from "@commander-js/extra-typings";
2
+ import { runBatchInputCommand, } from "../cli/helpers.js";
3
+ import { isQuiet, resolveDocuments, resolveStdio, } from "../cli/runtime.js";
4
+ import { resolveConfig, run } from "./cli.js";
5
+ export const VALID_OUTPUT_FORMATS = [
6
+ "json",
7
+ "stylish",
8
+ "junit",
9
+ "html",
10
+ "text",
11
+ "teamcity",
12
+ "pretty",
13
+ "github-actions",
14
+ "sarif",
15
+ "markdown",
16
+ "gitlab",
17
+ ];
18
+ const VALID_FAIL_SEVERITIES = ["error", "warn", "info", "hint"];
19
+ export const lintCommand = new Command("lint")
20
+ .description("Validate and lint OpenAPI, AsyncAPI, and Arazzo Documents using Spectral")
21
+ .argument("[input]", "Document path (default: auto-detect)")
22
+ .option("--openapi", "Lint OpenAPI document at openapi/openapi.yaml", false)
23
+ .option("--asyncapi", "Lint AsyncAPI document at asyncapi/asyncapi.yaml", false)
24
+ .option("--arazzo", "Lint Arazzo document at arazzo/arazzo.yaml", false)
25
+ .addOption(new Option("--format <format>", "Output format")
26
+ .choices([...VALID_OUTPUT_FORMATS])
27
+ .default("stylish"))
28
+ .option("--output <file>", "Write output to a file")
29
+ .option("--ruleset <file>", "Ruleset file path (overrides auto/bundled)")
30
+ .addOption(new Option("--fail-severity <level>", "Fail severity threshold")
31
+ .choices([...VALID_FAIL_SEVERITIES])
32
+ .default("warn"))
33
+ .option("--display-only-failures", "Display only failing results", false)
34
+ .option("--verbose", "Enable verbose output", false)
35
+ .allowExcessArguments(true)
36
+ .action(runLint);
37
+ function runLint(input, options, cmd) {
38
+ runBatchInputCommand({
39
+ input,
40
+ options,
41
+ cmd,
42
+ resolveDocuments: resolveDocuments,
43
+ execute: lint,
44
+ });
45
+ }
46
+ export function lint(params) {
47
+ const { input, options, globals } = params;
48
+ const ruleset = resolveConfig(options.ruleset);
49
+ const args = buildArgs(params, ruleset);
50
+ const stdio = resolveStdio(globals);
51
+ const quiet = isQuiet(globals);
52
+ if (!quiet) {
53
+ console.log(`🔍 Spectral lint...`);
54
+ console.log(` Input: ${input}`);
55
+ console.log(` Format: ${options.format}`);
56
+ console.log(` Ruleset: ${ruleset.path ?? "auto"} (${ruleset.source})`);
57
+ if (options.output) {
58
+ console.log(` Output: ${options.output}`);
59
+ }
60
+ console.log(` Fail Severity: ${options.failSeverity}`);
61
+ console.log(` Display Only Failures: ${String(options.displayOnlyFailures)}`);
62
+ console.log(` Verbose: ${String(options.verbose)}`);
63
+ }
64
+ return run(args, stdio);
65
+ }
66
+ function buildArgs(params, ruleset) {
67
+ const { input, options, passthrough } = params;
68
+ const args = [
69
+ "lint",
70
+ input,
71
+ "--format",
72
+ options.format,
73
+ "--fail-severity",
74
+ options.failSeverity,
75
+ ];
76
+ // only pass --ruleset if we resolved an explicit path (cli or bundled)
77
+ if (ruleset.path)
78
+ args.push("--ruleset", ruleset.path);
79
+ if (options.output)
80
+ args.push("--output", options.output);
81
+ if (options.displayOnlyFailures)
82
+ args.push("--display-only-failures");
83
+ if (options.verbose)
84
+ args.push("--verbose");
85
+ // forward any passthrough args to spectral
86
+ if (passthrough.length > 0) {
87
+ args.push(...passthrough);
88
+ }
89
+ return args;
90
+ }
91
+ //# sourceMappingURL=lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../src/lib/spectral/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,GAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,OAAO,EAEP,gBAAgB,EAChB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,UAAU;IACV,QAAQ;IACR,gBAAgB;IAChB,OAAO;IACP,UAAU;IACV,QAAQ;CACA,CAAC;AAEX,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAczE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CACV,0EAA0E,CAC3E;KACA,QAAQ,CAAC,SAAS,EAAE,sCAAsC,CAAC;KAE3D,MAAM,CAAC,WAAW,EAAE,+CAA+C,EAAE,KAAK,CAAC;KAC3E,MAAM,CACL,YAAY,EACZ,kDAAkD,EAClD,KAAK,CACN;KACA,MAAM,CAAC,UAAU,EAAE,4CAA4C,EAAE,KAAK,CAAC;KAEvE,SAAS,CACR,IAAI,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC;KAC7C,OAAO,CAAC,CAA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AE5C,2CAA2C;IAC3C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@bymbly/api-tools",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "Unified, opinionated CLI wrapper for API specification tooling.",
6
+ "license": "Apache-2.0",
7
+ "keywords": [
8
+ "openapi",
9
+ "asyncapi",
10
+ "arazzo",
11
+ "redocly",
12
+ "spectral",
13
+ "cli",
14
+ "tools",
15
+ "api"
16
+ ],
17
+ "files": [
18
+ "dist/**/*"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/bymbly/api-tools.git"
23
+ },
24
+ "bin": {
25
+ "api-tools": "dist/bin/api-tools.js"
26
+ },
27
+ "scripts": {
28
+ "dev": "npm run watch",
29
+ "build": "tsc -p tsconfig.build.json && npm run copy:defaults",
30
+ "test": "vitest run",
31
+ "build:clean": "npm run clean && npm run build",
32
+ "pretest": "npm run build",
33
+ "prepare": "npm run build",
34
+ "prepublishOnly": "npm run build:clean",
35
+ "watch": "npm run copy:defaults && tsc --watch",
36
+ "test:watch": "vitest",
37
+ "test:ui": "vitest --ui",
38
+ "typecheck": "tsc",
39
+ "lint": "npm run lint:md && npm run lint:eslint",
40
+ "lint:check": "npm run lint:md:check && npm run lint:eslint:check",
41
+ "format": "prettier --write .",
42
+ "format:check": "prettier --check .",
43
+ "lint:md": "markdownlint-cli2 --fix",
44
+ "lint:md:check": "markdownlint-cli2",
45
+ "lint:eslint": "eslint . --fix",
46
+ "lint:eslint:check": "eslint .",
47
+ "clean": "npm run clean:dist",
48
+ "clean:dist": "rm -rf ./dist",
49
+ "copy:defaults": "copyfiles --all defaults/* dist/"
50
+ },
51
+ "dependencies": {
52
+ "@commander-js/extra-typings": "^14.0.0",
53
+ "@redocly/cli": "^2.14.4",
54
+ "@stoplight/spectral-cli": "^6.15.0"
55
+ },
56
+ "devDependencies": {
57
+ "@eslint/js": "^9.39.2",
58
+ "@types/node": "^24.10.7",
59
+ "@vitest/ui": "^4.0.15",
60
+ "copyfiles": "^2.4.1",
61
+ "eslint": "^9.39.2",
62
+ "markdownlint-cli2": "0.20.0",
63
+ "prettier": "3.8.0",
64
+ "typescript": "^5.9.3",
65
+ "typescript-eslint": "^8.52.0",
66
+ "vitest": "^4.0.15"
67
+ }
68
+ }