Skip to content

Commit 3fdb68f

Browse files
committed
fix: πŸ› cli build and upgrade of the deps
1 parent 03282eb commit 3fdb68f

File tree

9 files changed

+197
-169
lines changed

9 files changed

+197
-169
lines changed

β€Žpackage.jsonβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
"core-js": "^3.6.5",
8888
"cypress": "12.17.4",
8989
"docusaurus-docgen": "^1.1.4",
90-
"esbuild": "0.19.9",
91-
"esbuild-node-externals": "^1.4.1",
90+
"esbuild": "0.25.8",
91+
"esbuild-node-externals": "^1.18.0",
9292
"eslint": "8.57.0",
9393
"eslint-config-airbnb": "^19.0.4",
9494
"eslint-config-airbnb-typescript": "^18.0.0",

β€Žpackages/cli/package.jsonβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"types": "dist/index.d.ts",
1111
"source": "src/index.ts",
1212
"cli": "src/cli/index.ts",
13-
"climain": "dist/cli.cjs.js",
14-
"bin": "dist/cli.cjs.js",
13+
"climain": "dist/index.js",
14+
"bin": "dist/index.js",
1515
"scripts": {
1616
"clean": "npx rimraf dist",
1717
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest --watchAll --maxWorkers=3 --forceExit",
@@ -40,7 +40,7 @@
4040
"url": "https://github.com/BetterTyped/hyper-fetch/issues"
4141
},
4242
"dependencies": {
43-
"@anttiviljami/dtsgenerator": "^3.12.2",
43+
"@anttiviljami/dtsgenerator": "^3.20.0",
4444
"@apidevtools/json-schema-ref-parser": "^11.9.3",
4545
"@hyper-fetch/core": "*",
4646
"@inquirer/prompts": "^7.6.0",

β€Žpackages/cli/src/codegen/openapi/generator.tsβ€Ž

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import DtsGenerator, { ExportedType } from "@anttiviljami/dtsgenerator/dist/core/dtsGenerator";
1+
import DtsGenerator, { ExportedType } from "@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js";
22
import RefParser from "@apidevtools/json-schema-ref-parser";
3-
import { parseSchema } from "@anttiviljami/dtsgenerator/dist/core/type";
4-
import { find, chain, isEmpty } from "lodash";
3+
import { parseSchema } from "@anttiviljami/dtsgenerator/dist/core/type.js";
4+
import * as lodash from "lodash";
55
import * as prettier from "prettier";
66
import * as fs from "fs-extra";
7-
import * as path from "path";
7+
import * as path from "node:path";
88
import { createClient } from "@hyper-fetch/core";
99

1010
import { Document, Operation, GeneratedTypes } from "./openapi.types";
@@ -239,18 +239,22 @@ export const createSdk = <Client extends ClientInstance>(client: Client) => {
239239
) {
240240
const { operationId, method, path: relPath } = operation;
241241
const normalizedOperationId = normalizeOperationId(operationId);
242-
const pathParametersType = find(exportTypes, {
242+
const pathParametersType = lodash.find(exportTypes, {
243243
schemaRef: `#/paths/${normalizedOperationId}/pathParameters`,
244244
})?.path;
245-
const queryParametersType = find(exportTypes, {
245+
const queryParametersType = lodash.find(exportTypes, {
246246
schemaRef: `#/paths/${normalizedOperationId}/queryParameters`,
247247
})?.path;
248-
const requestBodyType = find(exportTypes, { schemaRef: `#/paths/${normalizedOperationId}/requestBody` })?.path;
249-
const responseTypePaths = chain(exportTypes)
248+
const requestBodyType = lodash.find(exportTypes, {
249+
schemaRef: `#/paths/${normalizedOperationId}/requestBody`,
250+
})?.path;
251+
const responseTypePaths = lodash
252+
.chain(exportTypes)
250253
.filter(({ schemaRef }) => schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/2`))
251254
.map(({ path: responsePath }) => responsePath)
252255
.value();
253-
const errorTypePaths = chain(exportTypes)
256+
const errorTypePaths = lodash
257+
.chain(exportTypes)
254258
.filter(
255259
({ schemaRef }) =>
256260
schemaRef.startsWith(`#/paths/${normalizedOperationId}/responses/4`) ||
@@ -259,8 +263,8 @@ export const createSdk = <Client extends ClientInstance>(client: Client) => {
259263
.map(({ path: errorPath }) => errorPath)
260264
.value();
261265

262-
const responseType = !isEmpty(responseTypePaths) ? responseTypePaths.join(" | ") : "any";
263-
const errorType = !isEmpty(errorTypePaths) ? errorTypePaths.join(" | ") : "undefined";
266+
const responseType = !lodash.isEmpty(responseTypePaths) ? responseTypePaths.join(" | ") : "any";
267+
const errorType = !lodash.isEmpty(errorTypePaths) ? errorTypePaths.join(" | ") : "undefined";
264268

265269
return {
266270
id: normalizedOperationId,

β€Žpackages/cli/src/commands/generate.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable no-param-reassign */
22
import { Command } from "commander";
33
import { z } from "zod";
4-
import path from "path";
5-
import fs from "fs-extra";
4+
import * as path from "node:path";
5+
import * as fs from "fs-extra";
66
import { input, select, confirm } from "@inquirer/prompts";
77

88
import { handleError } from "utils/handle-error";

β€Žpackages/cli/src/commands/init.tsβ€Ž

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Command } from "commander";
22
import { input, select } from "@inquirer/prompts";
33
import { z } from "zod";
4-
import path from "path";
5-
import { existsSync, mkdir, readFileSync, writeFile } from "fs-extra";
4+
import * as path from "node:path";
5+
import * as fs from "fs-extra";
66

77
import { handleError } from "../utils/handle-error";
88
import { spinner } from "../utils/spinner";
@@ -103,16 +103,16 @@ export const init = new Command()
103103
{
104104
name: `Initialize API directory at ${relativePath}`,
105105
action: async () => {
106-
if (!existsSync(fullPath)) {
107-
await mkdir(fullPath, { recursive: true });
106+
if (!fs.existsSync(fullPath)) {
107+
await fs.mkdir(fullPath, { recursive: true });
108108
}
109109
},
110110
},
111111
{
112112
name: "Setup configuration",
113113
action: async (currentConfig) => {
114-
if (existsSync(configPath)) {
115-
const existingConfig = JSON.parse(readFileSync(configPath, "utf8"));
114+
if (fs.existsSync(configPath)) {
115+
const existingConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
116116
const { success, error, data } = configSchema.omit({ resolvedPaths: true }).safeParse({
117117
...defaultConfig,
118118
...existingConfig,
@@ -163,7 +163,7 @@ export const init = new Command()
163163

164164
configSchema.omit({ resolvedPaths: true }).parse(finalConfig);
165165

166-
await writeFile(configPath, JSON.stringify(finalConfig, null, 2));
166+
await fs.writeFile(configPath, JSON.stringify(finalConfig, null, 2));
167167
},
168168
},
169169
];

β€Žpackages/cli/src/config/get-config.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from "path";
2-
import fs from "fs-extra";
1+
import * as path from "node:path";
2+
import * as fs from "fs-extra";
33
import { loadConfig } from "tsconfig-paths";
44

55
import { highlighter } from "utils/highlighter";

β€Žpackages/cli/src/preflights/preflight-add.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from "path";
2-
import fs from "fs-extra";
1+
import * as path from "node:path";
2+
import * as fs from "fs-extra";
33
import { z } from "zod";
44

55
import { addOptionsSchema } from "commands/add";

β€Žpackages/cli/src/preflights/preflight-generate.tsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from "path";
2-
import fs from "fs-extra";
1+
import * as path from "node:path";
2+
import * as fs from "fs-extra";
33
import { z } from "zod";
44

55
import { generateOptionsSchema } from "commands/generate";

0 commit comments

Comments
Β (0)