-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchange-mode.js
More file actions
111 lines (99 loc) · 2.87 KB
/
change-mode.js
File metadata and controls
111 lines (99 loc) · 2.87 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const fs = require("fs");
console.log("mode:", process.argv[2]);
const debugPkg = {
"main": "./src/index.ts",
"module": undefined,
"types": undefined,
"exports": undefined
}
const sdk3Pkg = {
"main": "./dist/earthsdk3.umd.cjs",
"module": "./dist/earthsdk3.js",
"types": "./dist/types/index.d.ts",
"exports": {
"require": "./dist/earthsdk3.umd.cjs",
"types": "./dist/types/index.d.ts",
"import": "./dist/earthsdk3.js"
}
}
const cesiumPkg = {
"main": "./dist/earthsdk3-cesium.umd.cjs",
"module": "./dist/earthsdk3-cesium.js",
"types": "./dist/types/index.d.ts",
"exports": {
"require": "./dist/earthsdk3-cesium.umd.cjs",
"types": "./dist/types/index.d.ts",
"import": "./dist/earthsdk3-cesium.js"
}
}
const uePkg = {
"main": "./dist/earthsdk3-ue.umd.cjs",
"module": "./dist/earthsdk3-ue.js",
"types": "./dist/types/index.d.ts",
"exports": {
"require": "./dist/earthsdk3-ue.umd.cjs",
"types": "./dist/types/index.d.ts",
"import": "./dist/earthsdk3-ue.js"
}
}
const olPkg = {
"main": "./dist/earthsdk3-ol.umd.cjs",
"module": "./dist/earthsdk3-ol.js",
"types": "./dist/types/index.d.ts",
"exports": {
"require": "./dist/earthsdk3-ol.umd.cjs",
"types": "./dist/types/index.d.ts",
"import": "./dist/earthsdk3-ol.js"
}
}
const mcpPkg = {
"main": "./dist/earthsdk3-mcp.umd.cjs",
"module": "./dist/earthsdk3-mcp.js",
"types": "./dist/types/index.d.ts",
"exports": {
"require": "./dist/earthsdk3-mcp.umd.cjs",
"types": "./dist/types/index.d.ts",
"import": "./dist/earthsdk3-mcp.js"
}
}
const pkgData = {
"earthsdk3": {
path: "earthsdk/earthsdk3/package.json",
debugpkg: debugPkg,
pkg: sdk3Pkg
},
"earthsdk3-cesium": {
path: "earthsdk/earthsdk3-cesium/package.json",
debugpkg: debugPkg,
pkg: cesiumPkg
},
"earthsdk3-ue": {
path: "earthsdk/earthsdk3-ue/package.json",
debugpkg: debugPkg,
pkg: uePkg
},
"earthsdk3-ol": {
path: "earthsdk/earthsdk3-ol/package.json",
debugpkg: debugPkg,
pkg: olPkg
},
"earthsdk3-mcp": {
path: "earthsdk/earthsdk3-mcp/package.json",
debugpkg: debugPkg,
pkg: mcpPkg
},
}
const param1 = process.argv[2];
Object.keys(pkgData).forEach((key) => {
const pkg = pkgData[key];
const path = pkg.path;
const pkgjson = JSON.parse(fs.readFileSync(path, "utf-8"));
if (param1 === "debug") {
const newPkgjson = { ...pkgjson, ...pkg.debugpkg };
fs.writeFileSync(path, JSON.stringify(newPkgjson, null, 2));
} else {
const newPkgjson = { ...pkgjson, ...pkg.pkg };
fs.writeFileSync(path, JSON.stringify(newPkgjson, null, 2));
}
})
console.log(`已全部切换为 ${param1} 模式`);