@sdk-it/cli 0.12.11 → 0.14.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.
package/dist/index.js CHANGED
@@ -54,7 +54,12 @@ function loadSpec(location) {
54
54
  }
55
55
  return loadLocal(location);
56
56
  }
57
- var generate_default = new Command("generate").description(`Generate SDK out of a openapi spec file.`).addOption(specOption.makeOptionMandatory(true)).addOption(outputOption.makeOptionMandatory(true)).option("-l, --language <language>", "Programming language for the SDK").option(
57
+ var generate_default = new Command("generate").description(`Generate SDK out of a openapi spec file.`).addOption(specOption.makeOptionMandatory(true)).addOption(outputOption.makeOptionMandatory(true)).option(
58
+ "--useTsExtension [value]",
59
+ "Use .ts extension for generated files",
60
+ (value) => value === "false" ? false : true,
61
+ true
62
+ ).option("-l, --language <language>", "Programming language for the SDK").option(
58
63
  "-m, --mode <mode>",
59
64
  "full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces minimal: generate only the client sdk"
60
65
  ).option("-n, --name <name>", "Name of the generated client", "Client").option("--formatter <formatter>", "Formatter to use for the generated code").action(async (options) => {
@@ -63,6 +68,7 @@ var generate_default = new Command("generate").description(`Generate SDK out of
63
68
  output: options.output,
64
69
  mode: options.mode || "minimal",
65
70
  name: options.name,
71
+ useTsExtension: options.useTsExtension,
66
72
  formatCode: ({ env, output }) => {
67
73
  if (options.formatter) {
68
74
  const [command, ...args] = options.formatter.split(" ");
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/lib/cli.ts", "../src/lib/generate.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\nimport { Command, program } from 'commander';\n\nimport generate from './generate.ts';\n\nconst cli = program\n .description(`CLI tool to interact with SDK-IT.`)\n .addCommand(generate, { isDefault: true })\n .addCommand(\n new Command('_internal').action(() => {\n // do nothing\n }),\n { hidden: true },\n )\n .parse(process.argv);\n\nexport default cli;\n", "import { Command, Option } from 'commander';\nimport { execFile } from 'node:child_process';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nimport { generate } from '@sdk-it/typescript';\n\ninterface Options {\n spec: string;\n output: string;\n language: string;\n mode?: 'full' | 'minimal';\n name?: string;\n /**\n * Command to run the formatter.\n * @example 'biome check $SDK_IT_OUTPUT --write'\n * @example 'prettier $SDK_IT_OUTPUT --write'\n */\n formatter?: string;\n}\n\nconst specOption = new Option(\n '-s, --spec <spec>',\n 'Path to OpenAPI specification file',\n);\n\nconst outputOption = new Option(\n '-o, --output <output>',\n 'Output directory for the generated SDK',\n);\n\nasync function loadRemote(location: string) {\n const extName = extname(location);\n const response = await fetch(location);\n switch (extName) {\n case '.json':\n return response.json();\n case '.yaml':\n case '.yml': {\n const text = await response.text();\n return parse(text);\n }\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n\nasync function loadLocal(location: string) {\n const extName = extname(location);\n switch (extName) {\n case '.json':\n return import(location);\n case '.yaml':\n case '.yml': {\n const text = await await readFile(location, 'utf-8');\n return parse(text);\n }\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n\nfunction loadSpec(location: string) {\n const [protocol] = location.split(':');\n if (protocol === 'http' || protocol === 'https') {\n return loadRemote(location);\n }\n return loadLocal(location);\n}\n\nexport default new Command('generate')\n .description(`Generate SDK out of a openapi spec file.`)\n .addOption(specOption.makeOptionMandatory(true))\n .addOption(outputOption.makeOptionMandatory(true))\n .option('-l, --language <language>', 'Programming language for the SDK')\n .option(\n '-m, --mode <mode>',\n 'full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces minimal: generate only the client sdk',\n )\n .option('-n, --name <name>', 'Name of the generated client', 'Client')\n .option('--formatter <formatter>', 'Formatter to use for the generated code')\n .action(async (options: Options) => {\n const spec = await loadSpec(options.spec);\n await generate(spec, {\n output: options.output,\n mode: options.mode || 'minimal',\n name: options.name,\n formatCode: ({ env, output }) => {\n if (options.formatter) {\n const [command, ...args] = options.formatter.split(' ');\n execFile(command, args, { env: { ...env, SDK_IT_OUTPUT: output } });\n }\n },\n });\n });\n"],
5
- "mappings": ";;;AACA,SAAS,WAAAA,UAAS,eAAe;;;ACDjC,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AAgBzB,IAAM,aAAa,IAAI;AAAA,EACrB;AAAA,EACA;AACF;AAEA,IAAM,eAAe,IAAI;AAAA,EACvB;AAAA,EACA;AACF;AAEA,eAAe,WAAW,UAAkB;AAC1C,QAAM,UAAU,QAAQ,QAAQ;AAChC,QAAM,WAAW,MAAM,MAAM,QAAQ;AACrC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,SAAS,KAAK;AAAA,IACvB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,aAAO,MAAM,IAAI;AAAA,IACnB;AAAA,IACA;AACE,YAAM,IAAI,MAAM,+BAA+B,OAAO,EAAE;AAAA,EAC5D;AACF;AAEA,eAAe,UAAU,UAAkB;AACzC,QAAM,UAAU,QAAQ,QAAQ;AAChC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,OAAO;AAAA,IAChB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX,YAAM,OAAO,MAAM,MAAM,SAAS,UAAU,OAAO;AACnD,aAAO,MAAM,IAAI;AAAA,IACnB;AAAA,IACA;AACE,YAAM,IAAI,MAAM,+BAA+B,OAAO,EAAE;AAAA,EAC5D;AACF;AAEA,SAAS,SAAS,UAAkB;AAClC,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM,GAAG;AACrC,MAAI,aAAa,UAAU,aAAa,SAAS;AAC/C,WAAO,WAAW,QAAQ;AAAA,EAC5B;AACA,SAAO,UAAU,QAAQ;AAC3B;AAEA,IAAO,mBAAQ,IAAI,QAAQ,UAAU,EAClC,YAAY,0CAA0C,EACtD,UAAU,WAAW,oBAAoB,IAAI,CAAC,EAC9C,UAAU,aAAa,oBAAoB,IAAI,CAAC,EAChD,OAAO,6BAA6B,kCAAkC,EACtE;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,qBAAqB,gCAAgC,QAAQ,EACpE,OAAO,2BAA2B,yCAAyC,EAC3E,OAAO,OAAO,YAAqB;AAClC,QAAM,OAAO,MAAM,SAAS,QAAQ,IAAI;AACxC,QAAM,SAAS,MAAM;AAAA,IACnB,QAAQ,QAAQ;AAAA,IAChB,MAAM,QAAQ,QAAQ;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,YAAY,CAAC,EAAE,KAAK,OAAO,MAAM;AAC/B,UAAI,QAAQ,WAAW;AACrB,cAAM,CAAC,SAAS,GAAG,IAAI,IAAI,QAAQ,UAAU,MAAM,GAAG;AACtD,iBAAS,SAAS,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,eAAe,OAAO,EAAE,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;;;AD1FH,IAAM,MAAM,QACT,YAAY,mCAAmC,EAC/C,WAAW,kBAAU,EAAE,WAAW,KAAK,CAAC,EACxC;AAAA,EACC,IAAIC,SAAQ,WAAW,EAAE,OAAO,MAAM;AAAA,EAEtC,CAAC;AAAA,EACD,EAAE,QAAQ,KAAK;AACjB,EACC,MAAM,QAAQ,IAAI;",
4
+ "sourcesContent": ["#!/usr/bin/env node\nimport { Command, program } from 'commander';\n\nimport generate from './generate.ts';\n\nconst cli = program\n .description(`CLI tool to interact with SDK-IT.`)\n .addCommand(generate, { isDefault: true })\n .addCommand(\n new Command('_internal').action(() => {\n // do nothing\n }),\n { hidden: true },\n )\n .parse(process.argv);\n\nexport default cli;\n", "import { Command, Option } from 'commander';\nimport { execFile } from 'node:child_process';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { parse } from 'yaml';\n\nimport { generate } from '@sdk-it/typescript';\n\ninterface Options {\n spec: string;\n output: string;\n language: string;\n mode?: 'full' | 'minimal';\n name?: string;\n useTsExtension: boolean;\n /**\n * Command to run the formatter.\n * @example 'biome check $SDK_IT_OUTPUT --write'\n * @example 'prettier $SDK_IT_OUTPUT --write'\n */\n formatter?: string;\n}\n\nconst specOption = new Option(\n '-s, --spec <spec>',\n 'Path to OpenAPI specification file',\n);\n\nconst outputOption = new Option(\n '-o, --output <output>',\n 'Output directory for the generated SDK',\n);\n\nasync function loadRemote(location: string) {\n const extName = extname(location);\n const response = await fetch(location);\n switch (extName) {\n case '.json':\n return response.json();\n case '.yaml':\n case '.yml': {\n const text = await response.text();\n return parse(text);\n }\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n\nasync function loadLocal(location: string) {\n const extName = extname(location);\n switch (extName) {\n case '.json':\n return import(location);\n case '.yaml':\n case '.yml': {\n const text = await await readFile(location, 'utf-8');\n return parse(text);\n }\n default:\n throw new Error(`Unsupported file extension: ${extName}`);\n }\n}\n\nfunction loadSpec(location: string) {\n const [protocol] = location.split(':');\n if (protocol === 'http' || protocol === 'https') {\n return loadRemote(location);\n }\n return loadLocal(location);\n}\n\nexport default new Command('generate')\n .description(`Generate SDK out of a openapi spec file.`)\n .addOption(specOption.makeOptionMandatory(true))\n .addOption(outputOption.makeOptionMandatory(true))\n .option(\n '--useTsExtension [value]',\n 'Use .ts extension for generated files',\n (value) => (value === 'false' ? false : true),\n true,\n )\n .option('-l, --language <language>', 'Programming language for the SDK')\n .option(\n '-m, --mode <mode>',\n 'full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces minimal: generate only the client sdk',\n )\n .option('-n, --name <name>', 'Name of the generated client', 'Client')\n .option('--formatter <formatter>', 'Formatter to use for the generated code')\n .action(async (options: Options) => {\n const spec = await loadSpec(options.spec);\n await generate(spec, {\n output: options.output,\n mode: options.mode || 'minimal',\n name: options.name,\n useTsExtension: options.useTsExtension,\n formatCode: ({ env, output }) => {\n if (options.formatter) {\n const [command, ...args] = options.formatter.split(' ');\n execFile(command, args, { env: { ...env, SDK_IT_OUTPUT: output } });\n }\n },\n });\n });\n"],
5
+ "mappings": ";;;AACA,SAAS,WAAAA,UAAS,eAAe;;;ACDjC,SAAS,SAAS,cAAc;AAChC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,aAAa;AAEtB,SAAS,gBAAgB;AAiBzB,IAAM,aAAa,IAAI;AAAA,EACrB;AAAA,EACA;AACF;AAEA,IAAM,eAAe,IAAI;AAAA,EACvB;AAAA,EACA;AACF;AAEA,eAAe,WAAW,UAAkB;AAC1C,QAAM,UAAU,QAAQ,QAAQ;AAChC,QAAM,WAAW,MAAM,MAAM,QAAQ;AACrC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,SAAS,KAAK;AAAA,IACvB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,aAAO,MAAM,IAAI;AAAA,IACnB;AAAA,IACA;AACE,YAAM,IAAI,MAAM,+BAA+B,OAAO,EAAE;AAAA,EAC5D;AACF;AAEA,eAAe,UAAU,UAAkB;AACzC,QAAM,UAAU,QAAQ,QAAQ;AAChC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,OAAO;AAAA,IAChB,KAAK;AAAA,IACL,KAAK,QAAQ;AACX,YAAM,OAAO,MAAM,MAAM,SAAS,UAAU,OAAO;AACnD,aAAO,MAAM,IAAI;AAAA,IACnB;AAAA,IACA;AACE,YAAM,IAAI,MAAM,+BAA+B,OAAO,EAAE;AAAA,EAC5D;AACF;AAEA,SAAS,SAAS,UAAkB;AAClC,QAAM,CAAC,QAAQ,IAAI,SAAS,MAAM,GAAG;AACrC,MAAI,aAAa,UAAU,aAAa,SAAS;AAC/C,WAAO,WAAW,QAAQ;AAAA,EAC5B;AACA,SAAO,UAAU,QAAQ;AAC3B;AAEA,IAAO,mBAAQ,IAAI,QAAQ,UAAU,EAClC,YAAY,0CAA0C,EACtD,UAAU,WAAW,oBAAoB,IAAI,CAAC,EAC9C,UAAU,aAAa,oBAAoB,IAAI,CAAC,EAChD;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAC,UAAW,UAAU,UAAU,QAAQ;AAAA,EACxC;AACF,EACC,OAAO,6BAA6B,kCAAkC,EACtE;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,qBAAqB,gCAAgC,QAAQ,EACpE,OAAO,2BAA2B,yCAAyC,EAC3E,OAAO,OAAO,YAAqB;AAClC,QAAM,OAAO,MAAM,SAAS,QAAQ,IAAI;AACxC,QAAM,SAAS,MAAM;AAAA,IACnB,QAAQ,QAAQ;AAAA,IAChB,MAAM,QAAQ,QAAQ;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,gBAAgB,QAAQ;AAAA,IACxB,YAAY,CAAC,EAAE,KAAK,OAAO,MAAM;AAC/B,UAAI,QAAQ,WAAW;AACrB,cAAM,CAAC,SAAS,GAAG,IAAI,IAAI,QAAQ,UAAU,MAAM,GAAG;AACtD,iBAAS,SAAS,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,eAAe,OAAO,EAAE,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;;;ADlGH,IAAM,MAAM,QACT,YAAY,mCAAmC,EAC/C,WAAW,kBAAU,EAAE,WAAW,KAAK,CAAC,EACxC;AAAA,EACC,IAAIC,SAAQ,WAAW,EAAE,OAAO,MAAM;AAAA,EAEtC,CAAC;AAAA,EACD,EAAE,QAAQ,KAAK;AACjB,EACC,MAAM,QAAQ,IAAI;",
6
6
  "names": ["Command", "Command"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;;AAuE5C,wBAwBK"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;;AAwE5C,wBA+BK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/cli",
3
- "version": "0.12.11",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "commander": "^13.1.0",
23
- "@sdk-it/typescript": "0.12.11",
23
+ "@sdk-it/typescript": "0.14.0",
24
24
  "yaml": "^2.7.0"
25
25
  },
26
26
  "publishConfig": {