@simplysm/sd-cli 10.0.58 → 10.0.60
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.
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js +5 -5
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js.map +1 -1
- package/dist/utils/sdCliTsDefineTransformer.js +1 -1
- package/dist/utils/sdCliTsDefineTransformer.js.map +1 -1
- package/package.json +5 -5
- package/src/utils/SdCliViteElectronMainPlugin.ts +102 -102
- package/src/utils/SdCliViteServeOptimizeExcludePlugin.ts +5 -5
- package/src/utils/sdCliTsDefineTransformer.ts +30 -30
|
@@ -9,20 +9,20 @@ export const SdCliViteServeOptimizeExcludePlugin = (moduleGlobs) => {
|
|
|
9
9
|
const pkgPath = path.resolve(conf.root, "..");
|
|
10
10
|
const pkgNpmConf = FsUtil.readJson(path.resolve(pkgPath, "package.json"));
|
|
11
11
|
const pkgDeps = Object.keys(pkgNpmConf.dependencies ?? {});
|
|
12
|
-
const modulePaths = moduleGlobs.mapMany(item => FsUtil.glob(path.resolve(process.cwd(), "node_modules", item))).distinct();
|
|
13
|
-
const moduleNames = modulePaths.map(item => item.match(/[\\\/]node_modules[\\\/](.*)/)[1].replace(/\\/g, "/"))
|
|
14
|
-
.filter(item => pkgDeps.includes(item))
|
|
12
|
+
const modulePaths = moduleGlobs.mapMany((item) => FsUtil.glob(path.resolve(process.cwd(), "node_modules", item))).distinct();
|
|
13
|
+
const moduleNames = modulePaths.map((item) => item.match(/[\\\/]node_modules[\\\/](.*)/)[1].replace(/\\/g, "/"))
|
|
14
|
+
.filter((item) => pkgDeps.includes(item))
|
|
15
15
|
.distinct();
|
|
16
16
|
const subDeps = [];
|
|
17
17
|
for (const moduleName of moduleNames) {
|
|
18
18
|
const moduleNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "node_modules", moduleName, "package.json"));
|
|
19
19
|
const depNames = Object.keys(moduleNpmConf.dependencies ?? {});
|
|
20
|
-
subDeps.push(...depNames.filter(item => !moduleNames.includes(item)));
|
|
20
|
+
subDeps.push(...depNames.filter((item) => !moduleNames.includes(item)));
|
|
21
21
|
}
|
|
22
22
|
return {
|
|
23
23
|
server: {
|
|
24
24
|
watch: {
|
|
25
|
-
ignored: moduleNames.map(item => `!**/node_modules/${item}/**`)
|
|
25
|
+
ignored: moduleNames.map((item) => `!**/node_modules/${item}/**`)
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
optimizeDeps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteServeOptimizeExcludePlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteServeOptimizeExcludePlugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAG9C,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,WAAqB,EAAkB,EAAE;IAC3F,OAAO,CAAC;YACN,IAAI,EAAE,oCAAoC;YAC1C,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBACf,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,CAAC;gBAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,CAAe,CAAC;gBACxF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;gBAE3D,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"SdCliViteServeOptimizeExcludePlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteServeOptimizeExcludePlugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAA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O,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,CAAC,CAAe,CAAC;oBAC7H,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;oBAC/D,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACzE;gBAED,OAAO;oBACL,MAAM,EAAE;wBACN,KAAK,EAAE;4BACL,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,IAAI,KAAK,CAAC;yBAClE;qBACF;oBACD,YAAY,EAAE;wBACZ,OAAO,EAAE,WAAW;wBACpB,OAAO,EAAE,OAAO;qBACjB;iBACF,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ export function sdCliTsDefineTransformer(_, args) {
|
|
|
10
10
|
ts.isTypeOfExpression(node) ||
|
|
11
11
|
ts.isElementAccessExpression(node)) {
|
|
12
12
|
const regex = /\[["'`](.*)["'`]]/;
|
|
13
|
-
const replaceKey = node.getText().replace(new RegExp(regex, "g"), str => `.${str.match(regex)[1]}`);
|
|
13
|
+
const replaceKey = node.getText().replace(new RegExp(regex, "g"), (str) => `.${str.match(regex)[1]}`);
|
|
14
14
|
const replaceValue = args.replace[replaceKey];
|
|
15
15
|
if (replaceValue !== undefined) {
|
|
16
16
|
return ts.factory.createIdentifier(replaceValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdCliTsDefineTransformer.js","sourceRoot":"","sources":["../../src/utils/sdCliTsDefineTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,wBAAwB,CAAC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C;oBAClC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACvG,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;oBAC9C,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;qBAClD;oBAED,OAAO,IAAI,CAAC;iBACb;gBAED,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACnD,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAkB,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/sd-cli",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.60",
|
|
4
4
|
"description": "심플리즘 패키지 - CLI",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@electron/rebuild": "^3.3.0",
|
|
21
21
|
"@rollup/plugin-inject": "^5.0.3",
|
|
22
|
-
"@simplysm/sd-core-common": "10.0.
|
|
23
|
-
"@simplysm/sd-core-node": "10.0.
|
|
24
|
-
"@simplysm/sd-service-server": "10.0.
|
|
25
|
-
"@simplysm/sd-storage": "10.0.
|
|
22
|
+
"@simplysm/sd-core-common": "10.0.60",
|
|
23
|
+
"@simplysm/sd-core-node": "10.0.60",
|
|
24
|
+
"@simplysm/sd-service-server": "10.0.60",
|
|
25
|
+
"@simplysm/sd-storage": "10.0.60",
|
|
26
26
|
"@swc/core": "^1.3.90",
|
|
27
27
|
"@vite-pwa/assets-generator": "^0.0.10",
|
|
28
28
|
"@vitejs/plugin-react-swc": "^3.4.0",
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import {build, defineConfig, PluginOption, UserConfig} from "vite";
|
|
2
|
-
import {SdCliViteExternalPlugin} from "./SdCliViteExternalPlugin";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import {SdCliViteLoggerPlugin} from "./SdCliViteLoggerPlugin";
|
|
5
|
-
import {Logger} from "@simplysm/sd-core-node";
|
|
6
|
-
|
|
7
|
-
export const SdCliViteElectronMainPlugin = (opt: {
|
|
8
|
-
entry: string;
|
|
9
|
-
distPath: string;
|
|
10
|
-
cachePath: string;
|
|
11
|
-
}): PluginOption[] => {
|
|
12
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
|
|
13
|
-
|
|
14
|
-
let mainConfig: UserConfig;
|
|
15
|
-
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
name: "sd-cli:vite:electron-main",
|
|
19
|
-
apply: "serve",
|
|
20
|
-
configureServer: (server) => {
|
|
21
|
-
server.httpServer?.on("listening", async () => {
|
|
22
|
-
mainConfig = defineConfig({
|
|
23
|
-
mode: server.config.mode,
|
|
24
|
-
define: server.config.define,
|
|
25
|
-
root: server.config.root,
|
|
26
|
-
optimizeDeps: {
|
|
27
|
-
force: server.config.optimizeDeps?.force
|
|
28
|
-
},
|
|
29
|
-
build: {
|
|
30
|
-
sourcemap: true,
|
|
31
|
-
minify: false,
|
|
32
|
-
outDir: opt.distPath,
|
|
33
|
-
lib: {
|
|
34
|
-
entry: opt.entry,
|
|
35
|
-
formats: ["cjs"],
|
|
36
|
-
fileName: () => "[name].js"
|
|
37
|
-
},
|
|
38
|
-
emptyOutDir: false
|
|
39
|
-
},
|
|
40
|
-
plugins: [
|
|
41
|
-
SdCliViteLoggerPlugin({
|
|
42
|
-
logger,
|
|
43
|
-
name: path.basename(opt.entry)
|
|
44
|
-
}),
|
|
45
|
-
SdCliViteExternalPlugin({
|
|
46
|
-
target: "node",
|
|
47
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
48
|
-
includes: ["electron"]
|
|
49
|
-
}),
|
|
50
|
-
{
|
|
51
|
-
name: ":startup",
|
|
52
|
-
closeBundle: () => {
|
|
53
|
-
server.ws.send({type: "full-reload"});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
});
|
|
58
|
-
await build(mainConfig);
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "sd-cli:vite:electron-main",
|
|
64
|
-
apply: "build",
|
|
65
|
-
config: (config) => {
|
|
66
|
-
mainConfig = defineConfig({
|
|
67
|
-
mode: config.mode,
|
|
68
|
-
define: config.define,
|
|
69
|
-
root: config.root,
|
|
70
|
-
optimizeDeps: {
|
|
71
|
-
force: config.optimizeDeps?.force
|
|
72
|
-
},
|
|
73
|
-
build: {
|
|
74
|
-
sourcemap: false,
|
|
75
|
-
minify: true,
|
|
76
|
-
outDir: opt.distPath,
|
|
77
|
-
lib: {
|
|
78
|
-
entry: opt.entry,
|
|
79
|
-
formats: ["cjs"],
|
|
80
|
-
fileName: () => "[name].js"
|
|
81
|
-
},
|
|
82
|
-
emptyOutDir: false
|
|
83
|
-
},
|
|
84
|
-
plugins: [
|
|
85
|
-
SdCliViteLoggerPlugin({
|
|
86
|
-
logger,
|
|
87
|
-
name: path.basename(opt.entry)
|
|
88
|
-
}),
|
|
89
|
-
SdCliViteExternalPlugin({
|
|
90
|
-
target: "node",
|
|
91
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
92
|
-
includes: ["electron"]
|
|
93
|
-
}),
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
closeBundle: async () => {
|
|
98
|
-
await build(mainConfig);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
|
-
};
|
|
1
|
+
import {build, defineConfig, PluginOption, UserConfig} from "vite";
|
|
2
|
+
import {SdCliViteExternalPlugin} from "./SdCliViteExternalPlugin";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import {SdCliViteLoggerPlugin} from "./SdCliViteLoggerPlugin";
|
|
5
|
+
import {Logger} from "@simplysm/sd-core-node";
|
|
6
|
+
|
|
7
|
+
export const SdCliViteElectronMainPlugin = (opt: {
|
|
8
|
+
entry: string;
|
|
9
|
+
distPath: string;
|
|
10
|
+
cachePath: string;
|
|
11
|
+
}): PluginOption[] => {
|
|
12
|
+
const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
|
|
13
|
+
|
|
14
|
+
let mainConfig: UserConfig;
|
|
15
|
+
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
name: "sd-cli:vite:electron-main",
|
|
19
|
+
apply: "serve",
|
|
20
|
+
configureServer: (server) => {
|
|
21
|
+
server.httpServer?.on("listening", async () => {
|
|
22
|
+
mainConfig = defineConfig({
|
|
23
|
+
mode: server.config.mode,
|
|
24
|
+
define: server.config.define,
|
|
25
|
+
root: server.config.root,
|
|
26
|
+
optimizeDeps: {
|
|
27
|
+
force: server.config.optimizeDeps?.force
|
|
28
|
+
},
|
|
29
|
+
build: {
|
|
30
|
+
sourcemap: true,
|
|
31
|
+
minify: false,
|
|
32
|
+
outDir: opt.distPath,
|
|
33
|
+
lib: {
|
|
34
|
+
entry: opt.entry,
|
|
35
|
+
formats: ["cjs"],
|
|
36
|
+
fileName: () => "[name].js"
|
|
37
|
+
},
|
|
38
|
+
emptyOutDir: false
|
|
39
|
+
},
|
|
40
|
+
plugins: [
|
|
41
|
+
SdCliViteLoggerPlugin({
|
|
42
|
+
logger,
|
|
43
|
+
name: path.basename(opt.entry)
|
|
44
|
+
}),
|
|
45
|
+
SdCliViteExternalPlugin({
|
|
46
|
+
target: "node",
|
|
47
|
+
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
48
|
+
includes: ["electron"]
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
name: ":startup",
|
|
52
|
+
closeBundle: () => {
|
|
53
|
+
server.ws.send({type: "full-reload"});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
await build(mainConfig);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "sd-cli:vite:electron-main",
|
|
64
|
+
apply: "build",
|
|
65
|
+
config: (config) => {
|
|
66
|
+
mainConfig = defineConfig({
|
|
67
|
+
mode: config.mode,
|
|
68
|
+
define: config.define,
|
|
69
|
+
root: config.root,
|
|
70
|
+
optimizeDeps: {
|
|
71
|
+
force: config.optimizeDeps?.force
|
|
72
|
+
},
|
|
73
|
+
build: {
|
|
74
|
+
sourcemap: false,
|
|
75
|
+
minify: true,
|
|
76
|
+
outDir: opt.distPath,
|
|
77
|
+
lib: {
|
|
78
|
+
entry: opt.entry,
|
|
79
|
+
formats: ["cjs"],
|
|
80
|
+
fileName: () => "[name].js"
|
|
81
|
+
},
|
|
82
|
+
emptyOutDir: false
|
|
83
|
+
},
|
|
84
|
+
plugins: [
|
|
85
|
+
SdCliViteLoggerPlugin({
|
|
86
|
+
logger,
|
|
87
|
+
name: path.basename(opt.entry)
|
|
88
|
+
}),
|
|
89
|
+
SdCliViteExternalPlugin({
|
|
90
|
+
target: "node",
|
|
91
|
+
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
92
|
+
includes: ["electron"]
|
|
93
|
+
}),
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
closeBundle: async () => {
|
|
98
|
+
await build(mainConfig);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
};
|
|
@@ -14,22 +14,22 @@ export const SdCliViteServeOptimizeExcludePlugin = (moduleGlobs: string[]): Plug
|
|
|
14
14
|
const pkgNpmConf = FsUtil.readJson(path.resolve(pkgPath, "package.json")) as INpmConfig;
|
|
15
15
|
const pkgDeps = Object.keys(pkgNpmConf.dependencies ?? {});
|
|
16
16
|
|
|
17
|
-
const modulePaths = moduleGlobs.mapMany(item => FsUtil.glob(path.resolve(process.cwd(), "node_modules", item))).distinct();
|
|
18
|
-
const moduleNames = modulePaths.map(item => item.match(/[\\\/]node_modules[\\\/](.*)/)![1].replace(/\\/g, "/"))
|
|
19
|
-
.filter(item => pkgDeps.includes(item))
|
|
17
|
+
const modulePaths = moduleGlobs.mapMany((item) => FsUtil.glob(path.resolve(process.cwd(), "node_modules", item))).distinct();
|
|
18
|
+
const moduleNames = modulePaths.map((item) => item.match(/[\\\/]node_modules[\\\/](.*)/)![1].replace(/\\/g, "/"))
|
|
19
|
+
.filter((item) => pkgDeps.includes(item))
|
|
20
20
|
.distinct();
|
|
21
21
|
|
|
22
22
|
const subDeps: string[] = [];
|
|
23
23
|
for (const moduleName of moduleNames) {
|
|
24
24
|
const moduleNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "node_modules", moduleName, "package.json")) as INpmConfig;
|
|
25
25
|
const depNames = Object.keys(moduleNpmConf.dependencies ?? {});
|
|
26
|
-
subDeps.push(...depNames.filter(item => !moduleNames.includes(item)));
|
|
26
|
+
subDeps.push(...depNames.filter((item) => !moduleNames.includes(item)));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
server: {
|
|
31
31
|
watch: {
|
|
32
|
-
ignored: moduleNames.map(item => `!**/node_modules/${item}/**`)
|
|
32
|
+
ignored: moduleNames.map((item) => `!**/node_modules/${item}/**`)
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
optimizeDeps: {
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export function sdCliTsDefineTransformer(_: ts.Program, args: { replace: Record<string, string> }): ts.TransformerFactory<ts.SourceFile> {
|
|
4
|
-
return (context: ts.TransformationContext) => {
|
|
5
|
-
return (sourceFile: ts.SourceFile): ts.SourceFile => {
|
|
6
|
-
const visitor = (node: ts.Node): ts.Node => {
|
|
7
|
-
if (
|
|
8
|
-
ts.isCallExpression(node) ||
|
|
9
|
-
ts.isIdentifier(node) ||
|
|
10
|
-
ts.isExpressionStatement(node) ||
|
|
11
|
-
ts.isPropertyAccessExpression(node) ||
|
|
12
|
-
ts.isTypeOfExpression(node) ||
|
|
13
|
-
ts.isElementAccessExpression(node)
|
|
14
|
-
) {
|
|
15
|
-
const regex = /\[["'`](.*)["'`]]/;
|
|
16
|
-
const replaceKey = node.getText().replace(new RegExp(regex, "g"), str => `.${str.match(regex)![1]}`);
|
|
17
|
-
const replaceValue = args.replace[replaceKey];
|
|
18
|
-
if (replaceValue !== undefined) {
|
|
19
|
-
return ts.factory.createIdentifier(replaceValue);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return node;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return ts.visitEachChild(node, visitor, context);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export function sdCliTsDefineTransformer(_: ts.Program, args: { replace: Record<string, string> }): ts.TransformerFactory<ts.SourceFile> {
|
|
4
|
+
return (context: ts.TransformationContext) => {
|
|
5
|
+
return (sourceFile: ts.SourceFile): ts.SourceFile => {
|
|
6
|
+
const visitor = (node: ts.Node): ts.Node => {
|
|
7
|
+
if (
|
|
8
|
+
ts.isCallExpression(node) ||
|
|
9
|
+
ts.isIdentifier(node) ||
|
|
10
|
+
ts.isExpressionStatement(node) ||
|
|
11
|
+
ts.isPropertyAccessExpression(node) ||
|
|
12
|
+
ts.isTypeOfExpression(node) ||
|
|
13
|
+
ts.isElementAccessExpression(node)
|
|
14
|
+
) {
|
|
15
|
+
const regex = /\[["'`](.*)["'`]]/;
|
|
16
|
+
const replaceKey = node.getText().replace(new RegExp(regex, "g"), (str) => `.${str.match(regex)![1]}`);
|
|
17
|
+
const replaceValue = args.replace[replaceKey];
|
|
18
|
+
if (replaceValue !== undefined) {
|
|
19
|
+
return ts.factory.createIdentifier(replaceValue);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ts.visitEachChild(node, visitor, context);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
31
|
}
|