@hyper-fetch/cli 7.5.3 → 8.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.
Files changed (83) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/__tests__/codegen/openapi/v3/generator.spec.ts +3 -2
  3. package/__tests__/codegen/openapi/v3/operations.spec.ts +2 -2
  4. package/__tests__/codegen/openapi/v3/utils.spec.ts +1 -1
  5. package/__tests__/commands/generate/generate.spec.ts +17 -17
  6. package/__tests__/tsconfig.json +15 -4
  7. package/__tests__/vitest.setup.ts +10 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.d.ts.map +1 -0
  10. package/dist/cli.js +12969 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/codegen/index.d.ts +2 -0
  13. package/dist/codegen/index.d.ts.map +1 -0
  14. package/dist/codegen/openapi/generator.d.ts +61 -0
  15. package/dist/codegen/openapi/generator.d.ts.map +1 -0
  16. package/dist/codegen/openapi/http-methods.enum.d.ts +11 -0
  17. package/dist/codegen/openapi/http-methods.enum.d.ts.map +1 -0
  18. package/dist/codegen/openapi/index.d.ts +4 -0
  19. package/dist/codegen/openapi/index.d.ts.map +1 -0
  20. package/dist/codegen/openapi/openapi.types.d.ts +11 -0
  21. package/dist/codegen/openapi/openapi.types.d.ts.map +1 -0
  22. package/dist/codegen/openapi/operations.d.ts +6 -0
  23. package/dist/codegen/openapi/operations.d.ts.map +1 -0
  24. package/dist/codegen/openapi/utils.d.ts +7 -0
  25. package/dist/codegen/openapi/utils.d.ts.map +1 -0
  26. package/dist/commands/add.d.ts +10 -0
  27. package/dist/commands/add.d.ts.map +1 -0
  28. package/dist/commands/generate.d.ts +14 -0
  29. package/dist/commands/generate.d.ts.map +1 -0
  30. package/dist/commands/init.d.ts +3 -0
  31. package/dist/commands/init.d.ts.map +1 -0
  32. package/dist/config/auto-init.d.ts +6 -0
  33. package/dist/config/auto-init.d.ts.map +1 -0
  34. package/dist/config/get-config.d.ts +4 -0
  35. package/dist/config/get-config.d.ts.map +1 -0
  36. package/dist/config/get-ts-alias.d.ts +2 -0
  37. package/dist/config/get-ts-alias.d.ts.map +1 -0
  38. package/dist/config/schema.d.ts +21 -0
  39. package/dist/config/schema.d.ts.map +1 -0
  40. package/dist/generator-f5QJtrBW.js +194000 -0
  41. package/dist/generator-f5QJtrBW.js.map +1 -0
  42. package/dist/index.d.ts +2 -103
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +3 -3091
  45. package/dist/preflights/preflight-add.d.ts +27 -0
  46. package/dist/preflights/preflight-add.d.ts.map +1 -0
  47. package/dist/preflights/preflight-generate.d.ts +8 -0
  48. package/dist/preflights/preflight-generate.d.ts.map +1 -0
  49. package/dist/utils/errors.d.ts +14 -0
  50. package/dist/utils/errors.d.ts.map +1 -0
  51. package/dist/utils/handle-error.d.ts +2 -0
  52. package/dist/utils/handle-error.d.ts.map +1 -0
  53. package/dist/utils/highlighter.d.ts +7 -0
  54. package/dist/utils/highlighter.d.ts.map +1 -0
  55. package/dist/utils/logger.d.ts +8 -0
  56. package/dist/utils/logger.d.ts.map +1 -0
  57. package/dist/utils/resolve-import.d.ts +3 -0
  58. package/dist/utils/resolve-import.d.ts.map +1 -0
  59. package/dist/utils/show-help.d.ts +3 -0
  60. package/dist/utils/show-help.d.ts.map +1 -0
  61. package/dist/utils/spinner.d.ts +5 -0
  62. package/dist/utils/spinner.d.ts.map +1 -0
  63. package/dist/utils/zod-to-table.d.ts +6 -0
  64. package/dist/utils/zod-to-table.d.ts.map +1 -0
  65. package/package.json +5 -8
  66. package/src/codegen/openapi/generator.ts +4 -3
  67. package/src/codegen/openapi/openapi.types.ts +2 -2
  68. package/src/codegen/openapi/operations.ts +1 -1
  69. package/src/codegen/openapi/utils.ts +1 -1
  70. package/src/commands/add.ts +2 -2
  71. package/src/commands/init.ts +4 -3
  72. package/src/config/auto-init.ts +54 -0
  73. package/src/config/get-config.ts +5 -14
  74. package/src/preflights/preflight-add.ts +2 -2
  75. package/src/preflights/preflight-generate.ts +3 -3
  76. package/src/utils/show-help.ts +1 -1
  77. package/tsconfig.json +1 -1
  78. package/vite.config.ts +45 -0
  79. package/.eslintrc.json +0 -11
  80. package/__tests__/global.d.ts +0 -1
  81. package/__tests__/jest.setup.ts +0 -5
  82. package/dist/index.js.map +0 -7
  83. package/jest.config.ts +0 -6
package/.eslintrc.cjs ADDED
@@ -0,0 +1,18 @@
1
+ module.exports = {
2
+ extends: ["plugin:@nx/react", "../../.eslintrc.js"],
3
+ parserOptions: {
4
+ tsconfigRootDir: __dirname,
5
+ project: ["./tsconfig.json", "./__tests__/tsconfig.json"],
6
+ },
7
+ rules: {
8
+ "react/jsx-props-no-spreading": 0,
9
+ "react/require-default-props": 0,
10
+ },
11
+ ignorePatterns: [
12
+ "dist/",
13
+ "coverage/",
14
+ "vite.config.ts",
15
+ "/*.js",
16
+ "__tests__/codegen/openapi/__temp__/",
17
+ ],
18
+ };
@@ -1,13 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/ban-ts-comment */
2
2
  /**
3
- * @jest-environment node
3
+ * @vitest-environment node
4
4
  */
5
5
 
6
6
  import { promises as fsPromises } from "fs";
7
7
  import * as path from "path";
8
8
  import * as fs from "fs-extra";
9
9
 
10
- import { OpenapiRequestGenerator, Document, getAvailableOperations, Operation } from "codegen/openapi";
10
+ import type { Document, Operation } from "codegen/openapi";
11
+ import { OpenapiRequestGenerator, getAvailableOperations } from "codegen/openapi";
11
12
  import { HttpMethod } from "codegen/openapi/http-methods.enum";
12
13
 
13
14
  const expectedMetadata = {
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @jest-environment node
2
+ * @vitest-environment node
3
3
  */
4
4
 
5
5
  import { promises as fsPromises } from "fs";
6
6
  import * as path from "path";
7
7
 
8
- import { Document } from "codegen/openapi";
8
+ import type { Document } from "codegen/openapi";
9
9
  import { getAvailableOperations } from "codegen/openapi/operations";
10
10
 
11
11
  describe("Operations", () => {
@@ -2,7 +2,7 @@ import { promises as fsPromises } from "fs";
2
2
  import path from "path";
3
3
 
4
4
  import { getBaseUrl, isUrl, normalizeOperationId } from "codegen/openapi/utils";
5
- import { Document } from "codegen/openapi";
5
+ import type { Document } from "codegen/openapi";
6
6
 
7
7
  describe("Utils", () => {
8
8
  it("should check if provided path is url or not", () => {
@@ -1,4 +1,4 @@
1
- import { jest } from "@jest/globals";
1
+ import { vi } from "vitest";
2
2
  import { input, select, confirm } from "@inquirer/prompts";
3
3
 
4
4
  import { generate } from "commands/generate";
@@ -7,44 +7,44 @@ import { preFlightGenerate } from "preflights/preflight-generate";
7
7
  import { OpenapiRequestGenerator } from "codegen/openapi/generator";
8
8
 
9
9
  // Mocks
10
- jest.mock("utils/handle-error", () => ({ handleError: jest.fn() }));
11
- jest.mock("preflights/preflight-generate", () => {
10
+ vi.mock("utils/handle-error", () => ({ handleError: vi.fn() }));
11
+ vi.mock("preflights/preflight-generate", () => {
12
12
  const fakeConfig = {
13
13
  tsx: true,
14
14
  aliases: { api: "/tmp", hooks: "/tmp", ui: "/tmp", components: "/tmp", lib: "/tmp" },
15
15
  resolvedPaths: { cwd: "/tmp", api: "/tmp", hooks: "/tmp", ui: "/tmp", components: "/tmp", lib: "/tmp" },
16
16
  };
17
17
  return {
18
- preFlightGenerate: jest.fn(async () => ({ errors: {}, config: fakeConfig })),
18
+ preFlightGenerate: vi.fn(async () => ({ errors: {}, config: fakeConfig })),
19
19
  };
20
20
  });
21
- jest.mock("codegen/openapi/generator", () => {
21
+ vi.mock("codegen/openapi/generator", () => {
22
22
  class FakeGenerator {
23
- static getSchemaFromUrl = jest.fn(async () => ({ openapi: "3.0.0", paths: {} }));
24
- generateFile = jest.fn(async () => undefined);
23
+ static getSchemaFromUrl = vi.fn(async () => ({ openapi: "3.0.0", paths: {} }));
24
+ generateFile = vi.fn(async () => undefined);
25
25
  }
26
26
  return { OpenapiRequestGenerator: FakeGenerator };
27
27
  });
28
- jest.mock("utils/spinner", () => ({
29
- spinner: jest.fn(() => ({
30
- start: jest.fn(() => ({ succeed: jest.fn(), fail: jest.fn() })),
28
+ vi.mock("utils/spinner", () => ({
29
+ spinner: vi.fn(() => ({
30
+ start: vi.fn(() => ({ succeed: vi.fn(), fail: vi.fn() })),
31
31
  })),
32
32
  }));
33
- jest.mock("utils/logger", () => ({ logger: { info: jest.fn(), error: jest.fn(), log: jest.fn() } }));
34
- jest.mock("@inquirer/prompts", () => ({
35
- input: jest.fn(),
36
- select: jest.fn(),
37
- confirm: jest.fn(),
33
+ vi.mock("utils/logger", () => ({ logger: { info: vi.fn(), error: vi.fn(), log: vi.fn() } }));
34
+ vi.mock("@inquirer/prompts", () => ({
35
+ input: vi.fn(),
36
+ select: vi.fn(),
37
+ confirm: vi.fn(),
38
38
  }));
39
39
 
40
40
  describe("cli generate command", () => {
41
41
  const originalArgv = process.argv;
42
- const exitSpy = jest
42
+ const exitSpy = vi
43
43
  .spyOn(process, "exit")
44
44
  .mockImplementation((() => undefined) as (code?: string | number | null | undefined) => never);
45
45
 
46
46
  beforeEach(() => {
47
- jest.clearAllMocks();
47
+ vi.clearAllMocks();
48
48
  });
49
49
 
50
50
  afterAll(() => {
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["dom", "dom.iterable", "ESNext"],
3
7
  "strict": true,
4
8
  "noEmit": true,
5
- "baseUrl": "../src",
6
- "moduleResolution": "node",
9
+ "skipLibCheck": true,
7
10
  "esModuleInterop": true,
8
- "allowSyntheticDefaultImports": true
11
+ "allowSyntheticDefaultImports": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noUnusedLocals": false,
15
+ "noUnusedParameters": false,
16
+ "types": ["vitest/globals", "@types/node"],
17
+ "baseUrl": "../src",
18
+ "paths": {}
9
19
  },
10
- "exclude": ["node_modules", "dist", "__temp__"]
20
+ "include": ["**/*.ts", "**/*.tsx", "../../../global.d.ts", "../../../vitest.d.ts"],
21
+ "exclude": ["node_modules", "dist", "**/__temp__"]
11
22
  }
@@ -0,0 +1,10 @@
1
+ /// <reference types="vitest/globals" />
2
+ import { AbortController } from "abortcontroller-polyfill/dist/cjs-ponyfill";
3
+ import * as matchers from "jest-extended";
4
+ import { expect } from "vitest";
5
+
6
+ expect.extend(matchers);
7
+
8
+ if (!globalThis.AbortController) {
9
+ globalThis.AbortController = AbortController as any;
10
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}