Skip to content

Commit

Permalink
⚗️ Merge remote-tracking branch 'origin/fix-tasks-types' into extensi…
Browse files Browse the repository at this point in the history
…on-fix
  • Loading branch information
coyotte508 committed Nov 14, 2024
2 parents 5c89e98 + 451a223 commit d0f9fde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/src/index.d.ts",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
Expand All @@ -24,13 +23,14 @@
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepublishOnly": "pnpm run inference-codegen && git diff --name-only --exit-code src && pnpm run build",
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --declaration",
"build": "tsup src/index.ts --format cjs,esm --clean && tsc --emitDeclarationOnly --declaration && pnpm run generate-cts",
"watch:export": "tsup src/index.ts --format cjs,esm --watch",
"watch:types": "tsc --emitDeclarationOnly --declaration --watch",
"watch": "npm-run-all --parallel watch:export watch:types",
"prepare": "pnpm run build",
"check": "tsc",
"test": "vitest run",
"generate-cts": "tsx scripts/generate-cts.ts",
"inference-codegen": "tsx scripts/inference-codegen.ts && prettier --write src/tasks/*/inference.ts",
"inference-tgi-import": "tsx scripts/inference-tgi-import.ts && prettier --write src/tasks/text-generation/spec/*.json && prettier --write src/tasks/chat-completion/spec/*.json",
"inference-tei-import": "tsx scripts/inference-tei-import.ts && prettier --write src/tasks/feature-extraction/spec/*.json"
Expand Down
18 changes: 18 additions & 0 deletions packages/tasks/scripts/generate-cts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
import { join } from "node:path";

function recursiveCopy(path: string) {
for (const item of readdirSync(path)) {
if (item.endsWith(".d.ts")) {
const content = readFileSync(join(path, item), "utf-8");
writeFileSync(join(path, item.replace(".d.ts", ".d.cts")), content.replaceAll(".d.ts.map", ".d.cts.map"));
} else if (item.endsWith(".d.ts.map")) {
const content = readFileSync(join(path, item), "utf-8");
writeFileSync(join(path, item.replace(".d.ts.map", ".d.cts.map")), content.replaceAll(".d.ts", ".d.cts"));
} else if (statSync(join(path, item)).isDirectory()) {
recursiveCopy(join(path, item));
}
}
}

recursiveCopy("dist");
1 change: 1 addition & 0 deletions packages/tasks/src/snippets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import * as inputs from "./inputs.js";
import * as curl from "./curl.js";
import * as python from "./python.js";
import * as js from "./js.js";
export * from "./types.js";

export { inputs, curl, python, js };

0 comments on commit d0f9fde

Please sign in to comment.