@simplysm/sd-cli 12.9.2 → 12.9.12

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env node
2
+ import yargs from "yargs";
3
+ import { hideBin } from "yargs/helpers";
4
+ import { SdCliProject } from "./entry/sd-cli-project";
5
+ import { SdLogger, SdLoggerSeverity } from "@simplysm/sd-core-node";
6
+ import { EventEmitter } from "events";
7
+ import { SdCliElectron } from "./entry/sd-cli-electron";
8
+ import { SdCliLocalUpdate } from "./entry/sd-cli-local-update";
9
+ import { SdCliCordova } from "./entry/sd-cli-cordova";
10
+ import { SdCliAiCommand } from "./entry/sd-cli-ai-command";
11
+ import { SdCliPostinstall } from "./entry/sd-cli-postinstall";
12
+ Error.stackTraceLimit = Infinity;
13
+ EventEmitter.defaultMaxListeners = 0;
14
+ const argv = (await yargs(hideBin(process.argv))
15
+ .help("help", "도움말")
16
+ .alias("help", "h")
17
+ .options({
18
+ debug: {
19
+ type: "boolean",
20
+ describe: "디버그 로그를 표시할 것인지 여부",
21
+ default: false,
22
+ },
23
+ })
24
+ .command("local-update", "로컬 라이브러리 업데이트를 수행합니다.", (cmd) => cmd
25
+ .version(false)
26
+ .hide("help")
27
+ .hide("debug")
28
+ .options({
29
+ config: {
30
+ string: true,
31
+ describe: "simplysm.js 파일 경로",
32
+ },
33
+ options: {
34
+ string: true,
35
+ array: true,
36
+ describe: "옵션 설정",
37
+ },
38
+ }))
39
+ .command("watch", "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.", (cmd) => cmd
40
+ .version(false)
41
+ .hide("help")
42
+ .hide("debug")
43
+ .options({
44
+ config: {
45
+ string: true,
46
+ describe: "simplysm.js 파일 경로",
47
+ },
48
+ options: {
49
+ string: true,
50
+ array: true,
51
+ describe: "옵션 설정",
52
+ },
53
+ packages: {
54
+ string: true,
55
+ array: true,
56
+ describe: "수행할 패키지 설정",
57
+ },
58
+ inspects: {
59
+ string: true,
60
+ array: true,
61
+ describe: "크롬 inspect를 수행할 패키지 설정",
62
+ },
63
+ }))
64
+ .command("build", "프로젝트의 각 패키지에 대한 빌드를 수행합니다.", (cmd) => cmd
65
+ .version(false)
66
+ .hide("help")
67
+ .hide("debug")
68
+ .options({
69
+ config: {
70
+ string: true,
71
+ describe: "simplysm.js 파일 경로",
72
+ },
73
+ options: {
74
+ string: true,
75
+ array: true,
76
+ describe: "옵션 설정",
77
+ },
78
+ packages: {
79
+ string: true,
80
+ array: true,
81
+ describe: "수행할 패키지 설정",
82
+ },
83
+ }))
84
+ .command("publish", "프로젝트의 각 패키지를 배포합니다.", (cmd) => cmd
85
+ .version(false)
86
+ .hide("help")
87
+ .hide("debug")
88
+ .options({
89
+ noBuild: {
90
+ type: "boolean",
91
+ describe: "빌드를 하지않고 배포합니다.",
92
+ default: false,
93
+ },
94
+ config: {
95
+ type: "string",
96
+ describe: "simplysm.js 파일 경로",
97
+ },
98
+ options: {
99
+ type: "string",
100
+ array: true,
101
+ describe: "옵션 설정",
102
+ },
103
+ packages: {
104
+ type: "string",
105
+ array: true,
106
+ describe: "수행할 패키지 설정",
107
+ },
108
+ }))
109
+ .command("run-electron <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) => cmd
110
+ .positional("package", {
111
+ type: "string",
112
+ describe: "패키지명",
113
+ demandOption: true,
114
+ })
115
+ .options({
116
+ config: {
117
+ type: "string",
118
+ describe: "simplysm.js 파일 경로",
119
+ },
120
+ options: {
121
+ type: "string",
122
+ array: true,
123
+ describe: "옵션 설정",
124
+ },
125
+ }))
126
+ .command("build-electron-for-dev <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) => cmd
127
+ .positional("package", {
128
+ type: "string",
129
+ describe: "패키지명",
130
+ demandOption: true,
131
+ })
132
+ .options({
133
+ config: {
134
+ type: "string",
135
+ describe: "simplysm.js 파일 경로",
136
+ },
137
+ options: {
138
+ type: "string",
139
+ array: true,
140
+ describe: "옵션 설정",
141
+ },
142
+ }))
143
+ .command("run-cordova <platform> <package> [url]", "변경감지중인 플랫폼을 코도바 디바이스에 앱 형태로 띄웁니다.", (cmd) => cmd
144
+ .positional("platform", {
145
+ type: "string",
146
+ describe: "빌드 플랫폼(android,...)",
147
+ demandOption: true,
148
+ })
149
+ .positional("package", {
150
+ type: "string",
151
+ describe: "패키지명",
152
+ demandOption: true,
153
+ })
154
+ .positional("url", {
155
+ type: "string",
156
+ describe: "Webview로 오픈할 URL",
157
+ demandOption: true,
158
+ }))
159
+ .command("commit", "AI를 통해 변경사항에 대한 커밋 메시지를 작성하여, 커밋 및 푸쉬를 수행합니다.")
160
+ .command("postinstall", "설치후 자동실행할 작업")
161
+ .parseAsync());
162
+ if (Boolean(argv.debug)) {
163
+ process.env["SD_DEBUG"] = "true";
164
+ SdLogger.setConfig({
165
+ console: {
166
+ level: SdLoggerSeverity.debug,
167
+ },
168
+ });
169
+ }
170
+ else {
171
+ SdLogger.setConfig({
172
+ dot: true,
173
+ });
174
+ }
175
+ if (argv._[0] === "local-update") {
176
+ await SdCliLocalUpdate.runAsync(argv);
177
+ }
178
+ else if (argv._[0] === "watch") {
179
+ await SdCliProject.watchAsync(argv);
180
+ }
181
+ else if (argv._[0] === "build") {
182
+ await SdCliProject.buildAsync(argv);
183
+ }
184
+ else if (argv._[0] === "publish") {
185
+ await SdCliProject.publishAsync(argv);
186
+ }
187
+ else if (argv._[0] === "run-electron") {
188
+ await SdCliElectron.runAsync(argv);
189
+ }
190
+ else if (argv._[0] === "build-electron-for-dev") {
191
+ await SdCliElectron.buildForDevAsync(argv);
192
+ }
193
+ else if (argv._[0] === "run-cordova") {
194
+ await SdCliCordova.runWebviewOnDeviceAsync(argv);
195
+ }
196
+ else if (argv._[0] === "commit") {
197
+ await SdCliAiCommand.commitAsync();
198
+ }
199
+ else if (argv._[0] === "postinstall") {
200
+ SdCliPostinstall.run();
201
+ }
202
+ else {
203
+ throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
204
+ }
205
+ //# sourceMappingURL=sd-cli-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sd-cli-entry.js","sourceRoot":"","sources":["../src/sd-cli-entry.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC7C,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;KACnB,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;KAClB,OAAO,CAAC;IACP,KAAK,EAAE;QACL,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,oBAAoB;QAC9B,OAAO,EAAE,KAAK;KACf;CACF,CAAC;KACD,OAAO,CAAC,cAAc,EAAE,uBAAuB,EAAE,CAAC,GAAG,EAAE,EAAE,CACxD,GAAG;KACA,OAAO,CAAC,KAAK,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2
- import yargs from "yargs";
3
- import { hideBin } from "yargs/helpers";
4
- import { SdCliProject } from "./entry/sd-cli-project";
5
- import { SdLogger, SdLoggerSeverity } from "@simplysm/sd-core-node";
6
- import { EventEmitter } from "events";
7
- import { SdCliElectron } from "./entry/sd-cli-electron";
8
- import { SdCliLocalUpdate } from "./entry/sd-cli-local-update";
9
- import { SdCliCordova } from "./entry/sd-cli-cordova";
10
- import { SdCliAiCommand } from "./entry/sd-cli-ai-command";
11
- import { SdCliPostinstall } from "./entry/sd-cli-postinstall";
12
- Error.stackTraceLimit = Infinity;
13
- EventEmitter.defaultMaxListeners = 0;
14
- const argv = (await yargs(hideBin(process.argv))
15
- .help("help", "도움말")
16
- .alias("help", "h")
17
- .options({
18
- debug: {
19
- type: "boolean",
20
- describe: "디버그 로그를 표시할 것인지 여부",
21
- default: false,
22
- },
23
- })
24
- .command("local-update", "로컬 라이브러리 업데이트를 수행합니다.", (cmd) => cmd
25
- .version(false)
26
- .hide("help")
27
- .hide("debug")
28
- .options({
29
- config: {
30
- string: true,
31
- describe: "simplysm.js 파일 경로",
32
- },
33
- options: {
34
- string: true,
35
- array: true,
36
- describe: "옵션 설정",
37
- },
38
- }))
39
- .command("watch", "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.", (cmd) => cmd
40
- .version(false)
41
- .hide("help")
42
- .hide("debug")
43
- .options({
44
- config: {
45
- string: true,
46
- describe: "simplysm.js 파일 경로",
47
- },
48
- options: {
49
- string: true,
50
- array: true,
51
- describe: "옵션 설정",
52
- },
53
- packages: {
54
- string: true,
55
- array: true,
56
- describe: "수행할 패키지 설정",
57
- },
58
- inspects: {
59
- string: true,
60
- array: true,
61
- describe: "크롬 inspect를 수행할 패키지 설정",
62
- },
63
- }))
64
- .command("build", "프로젝트의 각 패키지에 대한 빌드를 수행합니다.", (cmd) => cmd
65
- .version(false)
66
- .hide("help")
67
- .hide("debug")
68
- .options({
69
- config: {
70
- string: true,
71
- describe: "simplysm.js 파일 경로",
72
- },
73
- options: {
74
- string: true,
75
- array: true,
76
- describe: "옵션 설정",
77
- },
78
- packages: {
79
- string: true,
80
- array: true,
81
- describe: "수행할 패키지 설정",
82
- },
83
- }))
84
- .command("publish", "프로젝트의 각 패키지를 배포합니다.", (cmd) => cmd
85
- .version(false)
86
- .hide("help")
87
- .hide("debug")
88
- .options({
89
- noBuild: {
90
- type: "boolean",
91
- describe: "빌드를 하지않고 배포합니다.",
92
- default: false,
93
- },
94
- config: {
95
- type: "string",
96
- describe: "simplysm.js 파일 경로",
97
- },
98
- options: {
99
- type: "string",
100
- array: true,
101
- describe: "옵션 설정",
102
- },
103
- packages: {
104
- type: "string",
105
- array: true,
106
- describe: "수행할 패키지 설정",
107
- },
108
- }))
109
- .command("run-electron <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) => cmd
110
- .positional("package", {
111
- type: "string",
112
- describe: "패키지명",
113
- demandOption: true,
114
- })
115
- .options({
116
- config: {
117
- type: "string",
118
- describe: "simplysm.js 파일 경로",
119
- },
120
- options: {
121
- type: "string",
122
- array: true,
123
- describe: "옵션 설정",
124
- },
125
- }))
126
- .command("build-electron-for-dev <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) => cmd
127
- .positional("package", {
128
- type: "string",
129
- describe: "패키지명",
130
- demandOption: true,
131
- })
132
- .options({
133
- config: {
134
- type: "string",
135
- describe: "simplysm.js 파일 경로",
136
- },
137
- options: {
138
- type: "string",
139
- array: true,
140
- describe: "옵션 설정",
141
- },
142
- }))
143
- .command("run-cordova <platform> <package> [url]", "변경감지중인 플랫폼을 코도바 디바이스에 앱 형태로 띄웁니다.", (cmd) => cmd
144
- .positional("platform", {
145
- type: "string",
146
- describe: "빌드 플랫폼(android,...)",
147
- demandOption: true,
148
- })
149
- .positional("package", {
150
- type: "string",
151
- describe: "패키지명",
152
- demandOption: true,
153
- })
154
- .positional("url", {
155
- type: "string",
156
- describe: "Webview로 오픈할 URL",
157
- demandOption: true,
158
- }))
159
- .command("commit", "AI를 통해 변경사항에 대한 커밋 메시지를 작성하여, 커밋 및 푸쉬를 수행합니다.")
160
- .command("postinstall", "설치후 자동실행할 작업")
161
- .parseAsync());
162
- if (Boolean(argv.debug)) {
163
- process.env["SD_DEBUG"] = "true";
164
- SdLogger.setConfig({
165
- console: {
166
- level: SdLoggerSeverity.debug,
167
- },
2
+ import { exec, spawn } from "child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ import os from "os";
5
+ import path from "path";
6
+ // ProcessorAffinity 마스크 계산
7
+ function calculateAffinityMask(cpuCount) {
8
+ const exclude = cpuCount <= 1 ? 0 : Math.ceil(cpuCount / 12); // 12개당 1개씩 뺌
9
+ const usable = cpuCount - exclude;
10
+ if (usable <= 0) {
11
+ throw new Error(`CPU 사용 가능 개수가 0 이하입니다 (총: ${cpuCount}, 제외: ${exclude})`);
12
+ }
13
+ const maskValue = (1 << usable) - 1;
14
+ return "0x" + maskValue.toString(16).toUpperCase();
15
+ }
16
+ // 논리 CPU 수 기반 affinity mask 계산 (전체 - 1)
17
+ const cpuCount = os.cpus().length;
18
+ const affinityMask = calculateAffinityMask(cpuCount);
19
+ // CLI 경로 확인
20
+ const cliPath = import.meta.resolve("./sd-cli-entry");
21
+ if (path.extname(cliPath) === ".ts") {
22
+ // 현재 프로세스에 affinity 적용
23
+ const pid = process.pid;
24
+ const command = `powershell -Command "$p = Get-Process -Id ${pid}; $p.ProcessorAffinity = ${affinityMask}"`;
25
+ exec(command, (err) => {
26
+ if (err) {
27
+ console.error("Affinity 설정 실패:", err.message);
28
+ }
168
29
  });
30
+ await import(cliPath);
169
31
  }
170
32
  else {
171
- SdLogger.setConfig({
172
- dot: true,
33
+ // .js 등의 번들 실행
34
+ const child = spawn("node", [
35
+ "--import=specifier-resolution-node/register",
36
+ fileURLToPath(cliPath),
37
+ ...process.argv.slice(2),
38
+ ], { stdio: "inherit" });
39
+ child.on("spawn", () => {
40
+ const pid = child.pid;
41
+ const command = `powershell -Command "$p = Get-Process -Id ${pid}; $p.ProcessorAffinity = ${affinityMask}"`;
42
+ exec(command, (err) => {
43
+ if (err) {
44
+ console.error("Affinity 설정 실패:", err.message);
45
+ }
46
+ });
173
47
  });
174
48
  }
175
- if (argv._[0] === "local-update") {
176
- await SdCliLocalUpdate.runAsync(argv);
177
- }
178
- else if (argv._[0] === "watch") {
179
- await SdCliProject.watchAsync(argv);
180
- }
181
- else if (argv._[0] === "build") {
182
- await SdCliProject.buildAsync(argv);
183
- }
184
- else if (argv._[0] === "publish") {
185
- await SdCliProject.publishAsync(argv);
186
- }
187
- else if (argv._[0] === "run-electron") {
188
- await SdCliElectron.runAsync(argv);
189
- }
190
- else if (argv._[0] === "build-electron-for-dev") {
191
- await SdCliElectron.buildForDevAsync(argv);
192
- }
193
- else if (argv._[0] === "run-cordova") {
194
- await SdCliCordova.runWebviewOnDeviceAsync(argv);
195
- }
196
- else if (argv._[0] === "commit") {
197
- await SdCliAiCommand.commitAsync();
198
- }
199
- else if (argv._[0] === "postinstall") {
200
- SdCliPostinstall.run();
201
- }
202
- else {
203
- throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
204
- }
205
49
  //# sourceMappingURL=sd-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sd-cli.js","sourceRoot":"","sources":["../src/sd-cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,E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,EAAE,CAAC,GAAG,EAAE,EAAE;YACpB,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -5,34 +5,45 @@ export class SdCliPerformanceTimer {
5
5
  this._resultMap = new Map();
6
6
  }
7
7
  start(name) {
8
- this._startingMap.set(name, new Date().getTime());
8
+ this._startingMap.set(name, {
9
+ time: new Date().getTime(),
10
+ cpu: process.cpuUsage(),
11
+ });
9
12
  }
10
13
  end(name) {
11
- const val = this._startingMap.get(name);
12
- if (val == null)
13
- throw new Error();
14
- this._resultMap.set(name, new Date().getTime() - val);
14
+ const start = this._startingMap.get(name);
15
+ if (start == null)
16
+ throw new Error(`No start record for '${name}'`);
17
+ const time = new Date().getTime() - start.time;
18
+ const cpuUsage = process.cpuUsage(start.cpu);
19
+ const cpu = (cpuUsage.user + cpuUsage.system) / 1000; // μs -> ms
20
+ this._resultMap.set(name, { time, cpu });
15
21
  this._startingMap.delete(name);
16
22
  }
17
23
  run(name, fn) {
18
24
  const startTime = new Date().getTime();
19
- let res = fn();
20
- if (res instanceof Promise) {
21
- return res.then((realRes) => {
22
- const duration = new Date().getTime() - startTime;
23
- this._resultMap.update(name, (v) => (v ?? 0) + duration);
24
- return realRes;
25
+ const startCpu = process.cpuUsage();
26
+ const finish = (res, start) => {
27
+ const duration = new Date().getTime() - start;
28
+ const cpu = (process.cpuUsage(startCpu).user + process.cpuUsage(startCpu).system) / 1000;
29
+ const prev = this._resultMap.get(name);
30
+ this._resultMap.set(name, {
31
+ time: (prev?.time ?? 0) + duration,
32
+ cpu: (prev?.cpu ?? 0) + cpu,
25
33
  });
34
+ return res;
35
+ };
36
+ const res = fn();
37
+ if (res instanceof Promise) {
38
+ return res.then(realRes => finish(realRes, startTime));
26
39
  }
27
- const duration = new Date().getTime() - startTime;
28
- this._resultMap.update(name, (v) => (v ?? 0) + duration);
29
- return res;
40
+ return finish(res, startTime);
30
41
  }
31
42
  toString() {
32
43
  return `${this._name} 성능 보고서
33
44
  ------------------------------------
34
45
  ${Array.from(this._resultMap.entries())
35
- .map((en) => `${en[0]}: ${en[1].toLocaleString()}ms`)
46
+ .map(([key, val]) => `${key}: ${val.time.toLocaleString()}ms (${val.cpu.toLocaleString()}ms CPU)`)
36
47
  .join("\n")}
37
48
  ------------------------------------`;
38
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sd-cli-performance-time.js","sourceRoot":"","sources":["../../src/utils/sd-cli-performance-time.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,qBAAqB;IAIhC,YAAoB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAHzB,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,eAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEX,CAAC;IAErC,KAAK,CAAC,IAAY;QAChB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,IAAY;QACd,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,GAAG,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC;QACtD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAI,IAAY,EAAE,EAAW;QAC9B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,GAAG,GAAG,EAAE,EAAE,CAAC;QACf,IAAI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O,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;YAEzF,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE;gBACxB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,GAAG,QAAQ;gBAClC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG;aAC5B,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,GAAG,GAAG,EAAE,EAAE,CAAC;QACjB,IAAI,GAAG,YAAY,OAAO,EAAE,CAAC;YAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAM,CAAC;QAC9D,CAAC;QAED,OAAO,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,KAAK;;EAEtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;aAChC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAClB,GAAG,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAC7E;aACA,IAAI,CAAC,IAAI,CAAC;qCACoB,CAAC;IACpC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/sd-cli",
3
- "version": "12.9.2",
3
+ "version": "12.9.12",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "directory": "packages/sd-cli"
10
10
  },
11
11
  "license": "MIT",
12
- "bin": "./bin/sd-cli.js",
12
+ "bin": "./dist/sd-cli.js",
13
13
  "type": "module",
14
14
  "dependencies": {
15
15
  "@angular/build": "^19.2.10",
@@ -17,10 +17,10 @@
17
17
  "@angular/compiler-cli": "^19.2.9",
18
18
  "@anthropic-ai/sdk": "^0.40.1",
19
19
  "@electron/rebuild": "^4.0.1",
20
- "@simplysm/sd-core-common": "12.9.2",
21
- "@simplysm/sd-core-node": "12.9.2",
22
- "@simplysm/sd-service-server": "12.9.2",
23
- "@simplysm/sd-storage": "12.9.2",
20
+ "@simplysm/sd-core-common": "12.9.12",
21
+ "@simplysm/sd-core-node": "12.9.12",
22
+ "@simplysm/sd-service-server": "12.9.12",
23
+ "@simplysm/sd-storage": "12.9.12",
24
24
  "browserslist": "^4.24.5",
25
25
  "cordova": "^12.0.0",
26
26
  "css-has-pseudo": "^7.0.2",
@@ -0,0 +1,232 @@
1
+ #!/usr/bin/env node
2
+
3
+ import yargs from "yargs";
4
+ import { hideBin } from "yargs/helpers";
5
+ import { SdCliProject } from "./entry/sd-cli-project";
6
+ import { SdLogger, SdLoggerSeverity } from "@simplysm/sd-core-node";
7
+ import { EventEmitter } from "events";
8
+ import { SdCliElectron } from "./entry/sd-cli-electron";
9
+ import { SdCliLocalUpdate } from "./entry/sd-cli-local-update";
10
+ import { SdCliCordova } from "./entry/sd-cli-cordova";
11
+ import { SdCliAiCommand } from "./entry/sd-cli-ai-command";
12
+ import { SdCliPostinstall } from "./entry/sd-cli-postinstall";
13
+
14
+ Error.stackTraceLimit = Infinity;
15
+ EventEmitter.defaultMaxListeners = 0;
16
+
17
+ const argv = (await yargs(hideBin(process.argv))
18
+ .help("help", "도움말")
19
+ .alias("help", "h")
20
+ .options({
21
+ debug: {
22
+ type: "boolean",
23
+ describe: "디버그 로그를 표시할 것인지 여부",
24
+ default: false,
25
+ },
26
+ })
27
+ .command("local-update", "로컬 라이브러리 업데이트를 수행합니다.", (cmd) =>
28
+ cmd
29
+ .version(false)
30
+ .hide("help")
31
+ .hide("debug")
32
+ .options({
33
+ config: {
34
+ string: true,
35
+ describe: "simplysm.js 파일 경로",
36
+ },
37
+ options: {
38
+ string: true,
39
+ array: true,
40
+ describe: "옵션 설정",
41
+ },
42
+ }),
43
+ )
44
+ .command("watch", "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.", (cmd) =>
45
+ cmd
46
+ .version(false)
47
+ .hide("help")
48
+ .hide("debug")
49
+ .options({
50
+ config: {
51
+ string: true,
52
+ describe: "simplysm.js 파일 경로",
53
+ },
54
+ options: {
55
+ string: true,
56
+ array: true,
57
+ describe: "옵션 설정",
58
+ },
59
+ packages: {
60
+ string: true,
61
+ array: true,
62
+ describe: "수행할 패키지 설정",
63
+ },
64
+ inspects: {
65
+ string: true,
66
+ array: true,
67
+ describe: "크롬 inspect를 수행할 패키지 설정",
68
+ },
69
+ }),
70
+ )
71
+ .command("build", "프로젝트의 각 패키지에 대한 빌드를 수행합니다.", (cmd) =>
72
+ cmd
73
+ .version(false)
74
+ .hide("help")
75
+ .hide("debug")
76
+ .options({
77
+ config: {
78
+ string: true,
79
+ describe: "simplysm.js 파일 경로",
80
+ },
81
+ options: {
82
+ string: true,
83
+ array: true,
84
+ describe: "옵션 설정",
85
+ },
86
+ packages: {
87
+ string: true,
88
+ array: true,
89
+ describe: "수행할 패키지 설정",
90
+ },
91
+ }),
92
+ )
93
+ .command("publish", "프로젝트의 각 패키지를 배포합니다.", (cmd) =>
94
+ cmd
95
+ .version(false)
96
+ .hide("help")
97
+ .hide("debug")
98
+ .options({
99
+ noBuild: {
100
+ type: "boolean",
101
+ describe: "빌드를 하지않고 배포합니다.",
102
+ default: false,
103
+ },
104
+ config: {
105
+ type: "string",
106
+ describe: "simplysm.js 파일 경로",
107
+ },
108
+ options: {
109
+ type: "string",
110
+ array: true,
111
+ describe: "옵션 설정",
112
+ },
113
+ packages: {
114
+ type: "string",
115
+ array: true,
116
+ describe: "수행할 패키지 설정",
117
+ },
118
+ }),
119
+ )
120
+ .command("run-electron <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) =>
121
+ cmd
122
+ .positional("package", {
123
+ type: "string",
124
+ describe: "패키지명",
125
+ demandOption: true,
126
+ })
127
+ .options({
128
+ config: {
129
+ type: "string",
130
+ describe: "simplysm.js 파일 경로",
131
+ },
132
+ options: {
133
+ type: "string",
134
+ array: true,
135
+ describe: "옵션 설정",
136
+ },
137
+ }),
138
+ )
139
+ .command("build-electron-for-dev <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) =>
140
+ cmd
141
+ .positional("package", {
142
+ type: "string",
143
+ describe: "패키지명",
144
+ demandOption: true,
145
+ })
146
+ .options({
147
+ config: {
148
+ type: "string",
149
+ describe: "simplysm.js 파일 경로",
150
+ },
151
+ options: {
152
+ type: "string",
153
+ array: true,
154
+ describe: "옵션 설정",
155
+ },
156
+ }),
157
+ )
158
+ .command(
159
+ "run-cordova <platform> <package> [url]",
160
+ "변경감지중인 플랫폼을 코도바 디바이스에 앱 형태로 띄웁니다.",
161
+ (cmd) =>
162
+ cmd
163
+ .positional("platform", {
164
+ type: "string",
165
+ describe: "빌드 플랫폼(android,...)",
166
+ demandOption: true,
167
+ })
168
+ .positional("package", {
169
+ type: "string",
170
+ describe: "패키지명",
171
+ demandOption: true,
172
+ })
173
+ .positional("url", {
174
+ type: "string",
175
+ describe: "Webview로 오픈할 URL",
176
+ demandOption: true,
177
+ }),
178
+ )
179
+ .command(
180
+ "commit",
181
+ "AI를 통해 변경사항에 대한 커밋 메시지를 작성하여, 커밋 및 푸쉬를 수행합니다.",
182
+ )
183
+ .command(
184
+ "postinstall",
185
+ "설치후 자동실행할 작업",
186
+ )
187
+ .parseAsync()) as any;
188
+
189
+ if (Boolean(argv.debug)) {
190
+ process.env["SD_DEBUG"] = "true";
191
+ SdLogger.setConfig({
192
+ console: {
193
+ level: SdLoggerSeverity.debug,
194
+ },
195
+ });
196
+ }
197
+ else {
198
+ SdLogger.setConfig({
199
+ dot: true,
200
+ });
201
+ }
202
+
203
+ if (argv._[0] === "local-update") {
204
+ await SdCliLocalUpdate.runAsync(argv);
205
+ }
206
+ else if (argv._[0] === "watch") {
207
+ await SdCliProject.watchAsync(argv);
208
+ }
209
+ else if (argv._[0] === "build") {
210
+ await SdCliProject.buildAsync(argv);
211
+ }
212
+ else if (argv._[0] === "publish") {
213
+ await SdCliProject.publishAsync(argv);
214
+ }
215
+ else if (argv._[0] === "run-electron") {
216
+ await SdCliElectron.runAsync(argv);
217
+ }
218
+ else if (argv._[0] === "build-electron-for-dev") {
219
+ await SdCliElectron.buildForDevAsync(argv);
220
+ }
221
+ else if (argv._[0] === "run-cordova") {
222
+ await SdCliCordova.runWebviewOnDeviceAsync(argv);
223
+ }
224
+ else if (argv._[0] === "commit") {
225
+ await SdCliAiCommand.commitAsync();
226
+ }
227
+ else if (argv._[0] === "postinstall") {
228
+ SdCliPostinstall.run();
229
+ }
230
+ else {
231
+ throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
232
+ }
package/src/sd-cli.ts CHANGED
@@ -1,232 +1,63 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import yargs from "yargs";
4
- import { hideBin } from "yargs/helpers";
5
- import { SdCliProject } from "./entry/sd-cli-project";
6
- import { SdLogger, SdLoggerSeverity } from "@simplysm/sd-core-node";
7
- import { EventEmitter } from "events";
8
- import { SdCliElectron } from "./entry/sd-cli-electron";
9
- import { SdCliLocalUpdate } from "./entry/sd-cli-local-update";
10
- import { SdCliCordova } from "./entry/sd-cli-cordova";
11
- import { SdCliAiCommand } from "./entry/sd-cli-ai-command";
12
- import { SdCliPostinstall } from "./entry/sd-cli-postinstall";
3
+ import { exec, spawn } from "child_process";
4
+ import { fileURLToPath } from "node:url";
5
+ import os from "os";
6
+ import path from "path";
13
7
 
14
- Error.stackTraceLimit = Infinity;
15
- EventEmitter.defaultMaxListeners = 0;
8
+ // ProcessorAffinity 마스크 계산
9
+ function calculateAffinityMask(cpuCount: number): string {
10
+ const exclude = cpuCount <= 1 ? 0 : Math.ceil(cpuCount / 12); // 12개당 1개씩 뺌
11
+ const usable = cpuCount - exclude;
16
12
 
17
- const argv = (await yargs(hideBin(process.argv))
18
- .help("help", "도움말")
19
- .alias("help", "h")
20
- .options({
21
- debug: {
22
- type: "boolean",
23
- describe: "디버그 로그를 표시할 것인지 여부",
24
- default: false,
25
- },
26
- })
27
- .command("local-update", "로컬 라이브러리 업데이트를 수행합니다.", (cmd) =>
28
- cmd
29
- .version(false)
30
- .hide("help")
31
- .hide("debug")
32
- .options({
33
- config: {
34
- string: true,
35
- describe: "simplysm.js 파일 경로",
36
- },
37
- options: {
38
- string: true,
39
- array: true,
40
- describe: "옵션 설정",
41
- },
42
- }),
43
- )
44
- .command("watch", "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.", (cmd) =>
45
- cmd
46
- .version(false)
47
- .hide("help")
48
- .hide("debug")
49
- .options({
50
- config: {
51
- string: true,
52
- describe: "simplysm.js 파일 경로",
53
- },
54
- options: {
55
- string: true,
56
- array: true,
57
- describe: "옵션 설정",
58
- },
59
- packages: {
60
- string: true,
61
- array: true,
62
- describe: "수행할 패키지 설정",
63
- },
64
- inspects: {
65
- string: true,
66
- array: true,
67
- describe: "크롬 inspect를 수행할 패키지 설정",
68
- },
69
- }),
70
- )
71
- .command("build", "프로젝트의 각 패키지에 대한 빌드를 수행합니다.", (cmd) =>
72
- cmd
73
- .version(false)
74
- .hide("help")
75
- .hide("debug")
76
- .options({
77
- config: {
78
- string: true,
79
- describe: "simplysm.js 파일 경로",
80
- },
81
- options: {
82
- string: true,
83
- array: true,
84
- describe: "옵션 설정",
85
- },
86
- packages: {
87
- string: true,
88
- array: true,
89
- describe: "수행할 패키지 설정",
90
- },
91
- }),
92
- )
93
- .command("publish", "프로젝트의 각 패키지를 배포합니다.", (cmd) =>
94
- cmd
95
- .version(false)
96
- .hide("help")
97
- .hide("debug")
98
- .options({
99
- noBuild: {
100
- type: "boolean",
101
- describe: "빌드를 하지않고 배포합니다.",
102
- default: false,
103
- },
104
- config: {
105
- type: "string",
106
- describe: "simplysm.js 파일 경로",
107
- },
108
- options: {
109
- type: "string",
110
- array: true,
111
- describe: "옵션 설정",
112
- },
113
- packages: {
114
- type: "string",
115
- array: true,
116
- describe: "수행할 패키지 설정",
117
- },
118
- }),
119
- )
120
- .command("run-electron <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) =>
121
- cmd
122
- .positional("package", {
123
- type: "string",
124
- describe: "패키지명",
125
- demandOption: true,
126
- })
127
- .options({
128
- config: {
129
- type: "string",
130
- describe: "simplysm.js 파일 경로",
131
- },
132
- options: {
133
- type: "string",
134
- array: true,
135
- describe: "옵션 설정",
136
- },
137
- }),
138
- )
139
- .command("build-electron-for-dev <package>", "변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.", (cmd) =>
140
- cmd
141
- .positional("package", {
142
- type: "string",
143
- describe: "패키지명",
144
- demandOption: true,
145
- })
146
- .options({
147
- config: {
148
- type: "string",
149
- describe: "simplysm.js 파일 경로",
150
- },
151
- options: {
152
- type: "string",
153
- array: true,
154
- describe: "옵션 설정",
155
- },
156
- }),
157
- )
158
- .command(
159
- "run-cordova <platform> <package> [url]",
160
- "변경감지중인 플랫폼을 코도바 디바이스에 앱 형태로 띄웁니다.",
161
- (cmd) =>
162
- cmd
163
- .positional("platform", {
164
- type: "string",
165
- describe: "빌드 플랫폼(android,...)",
166
- demandOption: true,
167
- })
168
- .positional("package", {
169
- type: "string",
170
- describe: "패키지명",
171
- demandOption: true,
172
- })
173
- .positional("url", {
174
- type: "string",
175
- describe: "Webview로 오픈할 URL",
176
- demandOption: true,
177
- }),
178
- )
179
- .command(
180
- "commit",
181
- "AI를 통해 변경사항에 대한 커밋 메시지를 작성하여, 커밋 및 푸쉬를 수행합니다.",
182
- )
183
- .command(
184
- "postinstall",
185
- "설치후 자동실행할 작업",
186
- )
187
- .parseAsync()) as any;
13
+ if (usable <= 0) {
14
+ throw new Error(`CPU 사용 가능 개수가 0 이하입니다 (총: ${cpuCount}, 제외: ${exclude})`);
15
+ }
188
16
 
189
- if (Boolean(argv.debug)) {
190
- process.env["SD_DEBUG"] = "true";
191
- SdLogger.setConfig({
192
- console: {
193
- level: SdLoggerSeverity.debug,
194
- },
195
- });
17
+ const maskValue = (1 << usable) - 1;
18
+ return "0x" + maskValue.toString(16).toUpperCase();
196
19
  }
197
- else {
198
- SdLogger.setConfig({
199
- dot: true,
20
+
21
+ // 논리 CPU 수 기반 affinity mask 계산 (전체 - 1)
22
+ const cpuCount = os.cpus().length;
23
+ const affinityMask = calculateAffinityMask(cpuCount);
24
+
25
+ // CLI 경로 확인
26
+ const cliPath = import.meta.resolve("./sd-cli-entry");
27
+
28
+ if (path.extname(cliPath) === ".ts") {
29
+ // 현재 프로세스에 affinity 적용
30
+ const pid = process.pid;
31
+ const command = `powershell -Command "$p = Get-Process -Id ${pid}; $p.ProcessorAffinity = ${affinityMask}"`;
32
+
33
+ exec(command, (err) => {
34
+ if (err) {
35
+ console.error("Affinity 설정 실패:", err.message);
36
+ }
200
37
  });
201
- }
202
38
 
203
- if (argv._[0] === "local-update") {
204
- await SdCliLocalUpdate.runAsync(argv);
205
- }
206
- else if (argv._[0] === "watch") {
207
- await SdCliProject.watchAsync(argv);
208
- }
209
- else if (argv._[0] === "build") {
210
- await SdCliProject.buildAsync(argv);
211
- }
212
- else if (argv._[0] === "publish") {
213
- await SdCliProject.publishAsync(argv);
214
- }
215
- else if (argv._[0] === "run-electron") {
216
- await SdCliElectron.runAsync(argv);
217
- }
218
- else if (argv._[0] === "build-electron-for-dev") {
219
- await SdCliElectron.buildForDevAsync(argv);
220
- }
221
- else if (argv._[0] === "run-cordova") {
222
- await SdCliCordova.runWebviewOnDeviceAsync(argv);
223
- }
224
- else if (argv._[0] === "commit") {
225
- await SdCliAiCommand.commitAsync();
226
- }
227
- else if (argv._[0] === "postinstall") {
228
- SdCliPostinstall.run();
39
+ await import(cliPath);
229
40
  }
230
41
  else {
231
- throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
232
- }
42
+ // .js 등의 번들 실행
43
+ const child = spawn(
44
+ "node",
45
+ [
46
+ "--import=specifier-resolution-node/register",
47
+ fileURLToPath(cliPath),
48
+ ...process.argv.slice(2),
49
+ ],
50
+ { stdio: "inherit" },
51
+ );
52
+
53
+ child.on("spawn", () => {
54
+ const pid = child.pid;
55
+ const command = `powershell -Command "$p = Get-Process -Id ${pid}; $p.ProcessorAffinity = ${affinityMask}"`;
56
+
57
+ exec(command, (err) => {
58
+ if (err) {
59
+ console.error("Affinity 설정 실패:", err.message);
60
+ }
61
+ });
62
+ });
63
+ }
@@ -1,42 +1,62 @@
1
1
  export class SdCliPerformanceTimer {
2
- private _startingMap = new Map<string, number>();
3
- private _resultMap = new Map<string, number>();
2
+ private _startingMap = new Map<string, { time: number; cpu: NodeJS.CpuUsage }>();
3
+ private _resultMap = new Map<string, { time: number; cpu: number }>();
4
4
 
5
- constructor(private _name: string) {}
5
+ constructor(private _name: string) {
6
+ }
6
7
 
7
8
  start(name: string) {
8
- this._startingMap.set(name, new Date().getTime());
9
+ this._startingMap.set(name, {
10
+ time: new Date().getTime(),
11
+ cpu: process.cpuUsage(),
12
+ });
9
13
  }
10
14
 
11
15
  end(name: string) {
12
- const val = this._startingMap.get(name);
13
- if (val == null) throw new Error();
14
- this._resultMap.set(name, new Date().getTime() - val);
16
+ const start = this._startingMap.get(name);
17
+ if (start == null) throw new Error(`No start record for '${name}'`);
18
+
19
+ const time = new Date().getTime() - start.time;
20
+ const cpuUsage = process.cpuUsage(start.cpu);
21
+ const cpu = (cpuUsage.user + cpuUsage.system) / 1000; // μs -> ms
22
+
23
+ this._resultMap.set(name, { time, cpu });
15
24
  this._startingMap.delete(name);
16
25
  }
17
26
 
18
27
  run<R>(name: string, fn: () => R): R {
19
28
  const startTime = new Date().getTime();
20
- let res = fn();
29
+ const startCpu = process.cpuUsage();
30
+
31
+ const finish = (res: R, start: number) => {
32
+ const duration = new Date().getTime() - start;
33
+ const cpu = (process.cpuUsage(startCpu).user + process.cpuUsage(startCpu).system) / 1000;
34
+
35
+ const prev = this._resultMap.get(name);
36
+ this._resultMap.set(name, {
37
+ time: (prev?.time ?? 0) + duration,
38
+ cpu: (prev?.cpu ?? 0) + cpu,
39
+ });
40
+
41
+ return res;
42
+ };
43
+
44
+ const res = fn();
21
45
  if (res instanceof Promise) {
22
- return res.then((realRes) => {
23
- const duration = new Date().getTime() - startTime;
24
- this._resultMap.update(name, (v) => (v ?? 0) + duration);
25
- return realRes;
26
- }) as R;
46
+ return res.then(realRes => finish(realRes, startTime)) as R;
27
47
  }
28
48
 
29
- const duration = new Date().getTime() - startTime;
30
- this._resultMap.update(name, (v) => (v ?? 0) + duration);
31
- return res;
49
+ return finish(res, startTime);
32
50
  }
33
51
 
34
52
  toString() {
35
53
  return `${this._name} 성능 보고서
36
54
  ------------------------------------
37
55
  ${Array.from(this._resultMap.entries())
38
- .map((en) => `${en[0]}: ${en[1].toLocaleString()}ms`)
39
- .join("\n")}
56
+ .map(([key, val]) =>
57
+ `${key}: ${val.time.toLocaleString()}ms (${val.cpu.toLocaleString()}ms CPU)`,
58
+ )
59
+ .join("\n")}
40
60
  ------------------------------------`;
41
61
  }
42
62
  }
package/bin/sd-cli.js DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { spawn } from "node:child_process";
4
- import { fileURLToPath } from "node:url";
5
- import { dirname, join } from "node:path";
6
-
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const cliPath = join(__dirname, "../dist/sd-cli.js");
9
-
10
- spawn("node", ["--import=specifier-resolution-node/register", cliPath, ...process.argv.slice(2)], {
11
- stdio: "inherit"
12
- });