swaggie 1.4.2 → 1.5.0-beta.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.
package/dist/cli.js CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
2
+ "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3
3
  var _nanocolors = require('nanocolors');
4
4
  var _commander = require('commander');
5
+ var _nodefs = require('node:fs'); var _nodefs2 = _interopRequireDefault(_nodefs);
6
+ var _nodepath = require('node:path'); var _nodepath2 = _interopRequireDefault(_nodepath);
5
7
 
6
8
  var _index = require('./index');
7
9
 
@@ -11,9 +13,11 @@ const arrayFormatOption = new (0, _commander.Option)(
11
13
  'Determines how arrays should be serialized'
12
14
  ).choices(['indices', 'repeat', 'brackets']);
13
15
 
16
+ const packageJson = readPackageJson();
17
+
14
18
  const program = new (0, _commander.Command)();
15
19
  program
16
- .version(require('../package.json').version)
20
+ .version(packageJson.version)
17
21
  .option(
18
22
  '-c, --config <path>',
19
23
  'The path to the configuration JSON file. You can do all the set up there instead of parameters in the CLI',
@@ -73,3 +77,11 @@ function error(e) {
73
77
  console.error(_nanocolors.red.call(void 0, msg));
74
78
  process.exit(1);
75
79
  }
80
+
81
+ function readPackageJson() {
82
+ try {
83
+ return JSON.parse(_nodefs2.default.readFileSync(_nodepath2.default.join(__dirname, '../package.json'), 'utf8'));
84
+ } catch (e) {
85
+ throw new Error('Could not read package.json file');
86
+ }
87
+ }
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ function gen(spec, options) {
55
55
  return prepareAppOptions({ ...parsedConfig, ...options });
56
56
  } catch (e) {
57
57
  return Promise.reject(
58
- 'Could not correctly load config file. It does not exist or you cannot access it'
58
+ new Error('Could not correctly load config file. It does not exist or you cannot access it')
59
59
  );
60
60
  }
61
61
  } exports.applyConfigFile = applyConfigFile;
@@ -1,7 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _nodefs = require('node:fs'); var _nodefs2 = _interopRequireDefault(_nodefs);
2
2
  var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
3
3
 
4
- var _undici = require('undici');
5
4
 
6
5
  /**
7
6
  * Function that loads an OpenAPI document from a path or URL
@@ -25,8 +24,11 @@ function loadFile(src) {
25
24
  }
26
25
 
27
26
  async function loadFromUrl(url) {
28
- const { body } = await _undici.request.call(void 0, url);
29
- const contents = await body.text();
27
+ const response = await fetch(url);
28
+ if (!response.ok) {
29
+ throw new Error(`Failed to load API from '${url}': ${response.statusText}`);
30
+ }
31
+ const contents = await response.text();
30
32
  return parseFileContents(contents, url);
31
33
  }
32
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swaggie",
3
- "version": "1.4.2",
3
+ "version": "1.5.0-beta.1",
4
4
  "description": "Generate TypeScript REST client code from an OpenAPI spec",
5
5
  "author": {
6
6
  "name": "Piotr Dabrowski",
@@ -24,11 +24,9 @@
24
24
  "swaggie": "dist/cli.js"
25
25
  },
26
26
  "scripts": {
27
- "build": "sucrase ./src -d ./dist --transforms typescript,imports && yarn rm-tests && yarn types",
27
+ "build": "sucrase ./src -d ./dist --transforms typescript,imports && bun run rm-tests && bun run types",
28
28
  "rm-tests": "find dist/ \\( -name '*.spec.js' -o -name 'types.js' \\) -type f -delete",
29
- "types": "tsc src/types.ts --outDir dist/ --declaration --emitDeclarationOnly && cp test/index.d.ts ./dist/",
30
- "test": "tsx --test 'src/**/*.spec.ts' 'test/**/*.spec.ts'",
31
- "coverage": "npx c8 yarn test"
29
+ "types": "tsc src/types.ts --outDir dist/ --declaration --emitDeclarationOnly && cp test/index.d.ts ./dist/"
32
30
  },
33
31
  "files": [
34
32
  "dist",
@@ -52,18 +50,16 @@
52
50
  ],
53
51
  "dependencies": {
54
52
  "case": "^1.6.3",
55
- "commander": "^13.1.0",
56
- "eta": "^3.5.0",
53
+ "commander": "^14.0.2",
54
+ "eta": "^4.5.0",
57
55
  "js-yaml": "^4.1.0",
58
- "nanocolors": "^0.2.0",
59
- "undici": "^6.21.1"
56
+ "nanocolors": "^0.2.0"
60
57
  },
61
58
  "devDependencies": {
62
59
  "@types/js-yaml": "4.0.9",
63
- "@types/node": "24.3.0",
60
+ "bun-types": "1.3.5",
64
61
  "openapi-types": "^12.1.3",
65
- "sucrase": "3.35.0",
66
- "tsx": "^4.20.5",
67
- "typescript": "5.9.2"
62
+ "sucrase": "3.35.1",
63
+ "typescript": "5.9.3"
68
64
  }
69
65
  }