-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_transform.ts
65 lines (56 loc) · 1.52 KB
/
_transform.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { build, emptyDir } from "jsr:@deno/[email protected]";
import { Project } from "jsr:@ts-morph/[email protected]";
const { name, version } = JSON.parse(Deno.readTextFileSync("deno.json"));
const project = new Project();
await emptyDir("./dist");
project.addSourceFilesAtPaths("**/*.ts");
for (const sourceFile of project.getSourceFiles()) {
for (const importDeclaration of sourceFile.getImportDeclarations()) {
if (
importDeclaration.getModuleSpecifier().getLiteralValue() ==
"@mtkruto/mtkruto"
) {
importDeclaration.setModuleSpecifier("@mtkruto/node");
}
}
}
await project.save();
await build({
entryPoints: ["mod.ts"],
outDir: "./dist",
typeCheck: false,
test: false,
compilerOptions: {
lib: ["ESNext", "DOM", "ESNext.AsyncIterable"],
},
shims: {},
packageManager: "pnpm",
package: {
name,
version,
description: "MTKruto Parse",
author: "Roj <[email protected]>",
license: "LGPL-3.0-or-later",
repository: {
type: "git",
url: "git+https://github.com/MTKruto/parse.git",
},
devDependencies: {
"@mtkruto/node": "^0.6.1",
},
},
postBuild() {
Deno.copyFileSync("LICENSE", "dist/LICENSE");
},
});
for (const sourceFile of project.getSourceFiles()) {
for (const importDeclaration of sourceFile.getImportDeclarations()) {
if (
importDeclaration.getModuleSpecifier().getLiteralValue() ==
"@mtkruto/node"
) {
importDeclaration.setModuleSpecifier("@mtkruto/mtkruto");
}
}
}
await project.save();