@eliceio/cdk-cli 0.0.0-stage → 0.1.0-alpha.2
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/README.md +526 -2
- package/es/bin/index.d.ts +2 -0
- package/es/bin/index.js +10 -0
- package/es/cli.d.ts +5 -0
- package/es/cli.js +209 -0
- package/es/commands/build/index.d.ts +30 -0
- package/es/commands/build/index.js +163 -0
- package/es/commands/check/index.d.ts +9 -0
- package/es/commands/check/index.js +31 -0
- package/es/commands/create/index.d.ts +8 -0
- package/es/commands/create/index.js +22 -0
- package/es/commands/create/scaffold.d.ts +24 -0
- package/es/commands/create/scaffold.js +82 -0
- package/es/commands/dev/index.d.ts +6 -0
- package/es/commands/dev/index.js +40 -0
- package/es/commands/doctor/index.d.ts +34 -0
- package/es/commands/doctor/index.js +311 -0
- package/es/commands/guide/index.d.ts +29 -0
- package/es/commands/guide/index.js +120 -0
- package/es/commands/skill/index.d.ts +48 -0
- package/es/commands/skill/index.js +173 -0
- package/es/core/collect.d.ts +21 -0
- package/es/core/collect.js +89 -0
- package/es/core/config.d.ts +55 -0
- package/es/core/config.js +109 -0
- package/es/core/manifest.d.ts +15 -0
- package/es/core/manifest.js +43 -0
- package/es/core/minify.d.ts +18 -0
- package/es/core/minify.js +93 -0
- package/es/core/prepare.d.ts +12 -0
- package/es/core/prepare.js +86 -0
- package/es/core/protocol.d.ts +2 -0
- package/es/core/protocol.js +4 -0
- package/es/core/sandbox.d.ts +17 -0
- package/es/core/sandbox.js +182 -0
- package/es/core/zip.d.ts +4 -0
- package/es/core/zip.js +17 -0
- package/es/dev/grading.d.ts +15 -0
- package/es/dev/grading.js +37 -0
- package/es/dev/host-page.d.ts +7 -0
- package/es/dev/host-page.js +240 -0
- package/es/dev/inject.d.ts +8 -0
- package/es/dev/inject.js +38 -0
- package/es/dev/mock-api.d.ts +65 -0
- package/es/dev/mock-api.js +269 -0
- package/es/dev/server.d.ts +25 -0
- package/es/dev/server.js +309 -0
- package/es/engines/static/index.d.ts +3 -0
- package/es/engines/static/index.js +11 -0
- package/es/engines/types.d.ts +12 -0
- package/es/engines/vite/index.d.ts +2 -0
- package/es/engines/vite/index.js +4 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/rules/check.d.ts +2 -0
- package/es/rules/check.js +282 -0
- package/es/rules/index.d.ts +8 -0
- package/es/rules/index.js +7 -0
- package/es/rules/manifest.d.ts +39 -0
- package/es/rules/manifest.js +168 -0
- package/es/rules/node.d.ts +11 -0
- package/es/rules/node.js +87 -0
- package/es/rules/path.d.ts +7 -0
- package/es/rules/path.js +35 -0
- package/es/rules/refs.d.ts +19 -0
- package/es/rules/refs.js +111 -0
- package/es/rules/skip.d.ts +12 -0
- package/es/rules/skip.js +55 -0
- package/es/rules/spec.d.ts +3 -0
- package/es/rules/spec.js +6 -0
- package/es/rules/types.d.ts +140 -0
- package/es/rules/unused.d.ts +7 -0
- package/es/rules/unused.js +21 -0
- package/es/rules/zip.d.ts +13 -0
- package/es/rules/zip.js +45 -0
- package/es/rules.json.js +3 -0
- package/es/types.d.ts +4 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +7 -0
- package/guides/content-development.md +207 -0
- package/package.json +50 -3
- package/rules.json +608 -0
- package/skills/_shared/always.md +7 -0
- package/skills/elice-content-check/SKILL.md +22 -0
- package/skills/elice-content-create/SKILL.md +21 -0
- package/skills/elice-content-migrate/SKILL.md +21 -0
- package/templates/_shared/lib/cdk-mock.d.ts +94 -0
- package/templates/_shared/lib/cdk-mock.js +429 -0
- package/templates/_shared/lib/cdk.js +3 -0
- package/templates/_shared/lib/elice-content.css +262 -0
- package/templates/_shared/lib/elice-content.d.ts +123 -0
- package/templates/_shared/lib/elice-content.js +534 -0
- package/templates/_shared/lib/elice-tokens.css +446 -0
- package/templates/blank/README.md +64 -0
- package/templates/blank/commentary.txt +2 -0
- package/templates/blank/content.json +4 -0
- package/templates/blank/edit.html +15 -0
- package/templates/blank/elice.config.json +12 -0
- package/templates/blank/gitignore +3 -0
- package/templates/blank/index.html +15 -0
- package/templates/blank/instructor.html +15 -0
- package/templates/blank/screens/edit.js +21 -0
- package/templates/blank/screens/instructor.js +9 -0
- package/templates/blank/screens/learn.js +19 -0
- package/templates/blank/styles.css +1 -0
- package/templates/quiz/README.md +108 -0
- package/templates/quiz/commentary.txt +2 -0
- package/templates/quiz/content.json +81 -0
- package/templates/quiz/core/behaviors.d.ts +59 -0
- package/templates/quiz/core/behaviors.js +310 -0
- package/templates/quiz/core/dom.d.ts +13 -0
- package/templates/quiz/core/dom.js +83 -0
- package/templates/quiz/core/editor.d.ts +48 -0
- package/templates/quiz/core/editor.js +206 -0
- package/templates/quiz/core/markdown.d.ts +2 -0
- package/templates/quiz/core/markdown.js +84 -0
- package/templates/quiz/core/model.d.ts +20 -0
- package/templates/quiz/core/model.js +203 -0
- package/templates/quiz/edit.html +17 -0
- package/templates/quiz/elice.config.json +14 -0
- package/templates/quiz/gitignore +3 -0
- package/templates/quiz/grading.json +13 -0
- package/templates/quiz/index.html +17 -0
- package/templates/quiz/instructor.html +17 -0
- package/templates/quiz/screens/edit.js +139 -0
- package/templates/quiz/screens/instructor.js +27 -0
- package/templates/quiz/screens/learn.js +55 -0
- package/templates/quiz/styles.css +570 -0
- package/templates/quiz/ui/templates/choice.js +22 -0
- package/templates/quiz/ui/templates/edit.d.ts +13 -0
- package/templates/quiz/ui/templates/edit.js +183 -0
- package/templates/quiz/ui/templates/group.js +68 -0
- package/templates/quiz/ui/templates/index.d.ts +5 -0
- package/templates/quiz/ui/templates/index.js +17 -0
- package/templates/quiz/ui/templates/order.js +35 -0
- package/templates/quiz/ui/templates/page.js +29 -0
- package/templates/quiz/ui/templates/question.js +28 -0
- package/templates/quiz/ui/templates/text.js +16 -0
- package/templates/quiz/ui/texts.d.ts +3 -0
- package/templates/quiz/ui/texts.js +127 -0
- package/templates/quiz/ui/theme.css +50 -0
package/es/cli.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { usage as usage$5, run as run$5 } from './commands/build/index.js';
|
|
3
|
+
import { usage as usage$6, run as run$6 } from './commands/check/index.js';
|
|
4
|
+
import { usage as usage$4, run as run$4 } from './commands/create/index.js';
|
|
5
|
+
import { usage as usage$3, run as run$3 } from './commands/dev/index.js';
|
|
6
|
+
import { usage as usage$2, run as run$2 } from './commands/doctor/index.js';
|
|
7
|
+
import { usage as usage$1, run as run$1 } from './commands/guide/index.js';
|
|
8
|
+
import { usage, run } from './commands/skill/index.js';
|
|
9
|
+
import 'fflate';
|
|
10
|
+
import { RULES_VERSION } from './rules/spec.js';
|
|
11
|
+
import { VERSION } from './version.js';
|
|
12
|
+
|
|
13
|
+
const help = `ecdk ${VERSION} · Elice CDK CLI (Custom HTML 콘텐츠 도구)
|
|
14
|
+
|
|
15
|
+
명령:
|
|
16
|
+
create <폴더> 새 프로젝트 (--template quiz|blank, --theme light|dark)
|
|
17
|
+
check [경로] 업로드 전 검사 (서버와 같은 규칙)
|
|
18
|
+
build [폴더] 정답·비밀 제외 → 검사 → content.zip
|
|
19
|
+
dev [폴더] 운영과 같은 조건의 로컬 서버 (--port)
|
|
20
|
+
doctor [폴더] 환경·프로젝트 점검 (--fix)
|
|
21
|
+
guide [주제] 에이전트용 개발 가이드 (주제 목록 · 한 절 · all)
|
|
22
|
+
skill install Claude Code 스킬 설치 (--project, --force)
|
|
23
|
+
|
|
24
|
+
공통 옵션: --json, --help, --version`;
|
|
25
|
+
const usageError = (message, usage) => ({
|
|
26
|
+
exitCode: 2,
|
|
27
|
+
output: `${message}\n\n${usage}`
|
|
28
|
+
});
|
|
29
|
+
/** 프로세스와 분리된 진입점 (테스트에서 그대로 호출). */
|
|
30
|
+
async function main(argv) {
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = parseArgs({
|
|
34
|
+
args: argv,
|
|
35
|
+
allowPositionals: true,
|
|
36
|
+
options: {
|
|
37
|
+
json: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
fix: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
project: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
force: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
template: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
short: 't'
|
|
56
|
+
},
|
|
57
|
+
theme: {
|
|
58
|
+
type: 'string'
|
|
59
|
+
},
|
|
60
|
+
port: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
short: 'p'
|
|
63
|
+
},
|
|
64
|
+
help: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
short: 'h',
|
|
67
|
+
default: false
|
|
68
|
+
},
|
|
69
|
+
version: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
short: 'v',
|
|
72
|
+
default: false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} catch (e) {
|
|
77
|
+
return usageError(e.message, help);
|
|
78
|
+
}
|
|
79
|
+
const {
|
|
80
|
+
values,
|
|
81
|
+
positionals
|
|
82
|
+
} = parsed;
|
|
83
|
+
const [cmd, ...rest] = positionals;
|
|
84
|
+
if (values.version) return {
|
|
85
|
+
exitCode: 0,
|
|
86
|
+
output: `ecdk ${VERSION} (rules ${RULES_VERSION})`
|
|
87
|
+
};
|
|
88
|
+
if (!cmd) return {
|
|
89
|
+
exitCode: values.help ? 0 : 2,
|
|
90
|
+
output: help
|
|
91
|
+
};
|
|
92
|
+
switch (cmd) {
|
|
93
|
+
case 'check':
|
|
94
|
+
{
|
|
95
|
+
if (values.help) return {
|
|
96
|
+
exitCode: 0,
|
|
97
|
+
output: usage$6
|
|
98
|
+
};
|
|
99
|
+
if (rest.length > 1) return usageError('경로는 하나만 줄 수 있습니다.', usage$6);
|
|
100
|
+
try {
|
|
101
|
+
return await run$6({
|
|
102
|
+
target: rest[0] ?? '.',
|
|
103
|
+
json: values.json
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
const message = e.code === 'ENOENT' ? `경로가 없습니다: ${rest[0] ?? '.'}` : e.message;
|
|
107
|
+
return usageError(message, usage$6);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
case 'build':
|
|
111
|
+
{
|
|
112
|
+
if (values.help) return {
|
|
113
|
+
exitCode: 0,
|
|
114
|
+
output: usage$5
|
|
115
|
+
};
|
|
116
|
+
if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$5);
|
|
117
|
+
try {
|
|
118
|
+
return await run$5({
|
|
119
|
+
target: rest[0] ?? '.',
|
|
120
|
+
json: values.json
|
|
121
|
+
});
|
|
122
|
+
} catch (e) {
|
|
123
|
+
const message = e.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : e.message;
|
|
124
|
+
return usageError(message, usage$5);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
case 'create':
|
|
128
|
+
{
|
|
129
|
+
if (values.help) return {
|
|
130
|
+
exitCode: 0,
|
|
131
|
+
output: usage$4
|
|
132
|
+
};
|
|
133
|
+
if (rest.length !== 1) return usageError('만들 폴더를 하나 적어 주세요.', usage$4);
|
|
134
|
+
try {
|
|
135
|
+
return await run$4({
|
|
136
|
+
target: rest[0] ?? '',
|
|
137
|
+
template: values.template ?? 'quiz',
|
|
138
|
+
theme: values.theme ?? 'light',
|
|
139
|
+
json: values.json
|
|
140
|
+
});
|
|
141
|
+
} catch (e) {
|
|
142
|
+
return usageError(e.message, usage$4);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
case 'dev':
|
|
146
|
+
{
|
|
147
|
+
if (values.help) return {
|
|
148
|
+
exitCode: 0,
|
|
149
|
+
output: usage$3
|
|
150
|
+
};
|
|
151
|
+
if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$3);
|
|
152
|
+
try {
|
|
153
|
+
return await run$3({
|
|
154
|
+
target: rest[0] ?? '.',
|
|
155
|
+
...(values.port === undefined ? {} : {
|
|
156
|
+
port: values.port
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
} catch (e) {
|
|
160
|
+
const err = e;
|
|
161
|
+
const message = err.code === 'EADDRINUSE' ? `포트가 이미 쓰이고 있습니다. --port로 다른 포트를 주세요.` : err.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : err.message;
|
|
162
|
+
return usageError(message, usage$3);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
case 'doctor':
|
|
166
|
+
{
|
|
167
|
+
if (values.help) return {
|
|
168
|
+
exitCode: 0,
|
|
169
|
+
output: usage$2
|
|
170
|
+
};
|
|
171
|
+
if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$2);
|
|
172
|
+
return run$2({
|
|
173
|
+
target: rest[0] ?? '.',
|
|
174
|
+
json: values.json,
|
|
175
|
+
fix: values.fix
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
case 'guide':
|
|
179
|
+
{
|
|
180
|
+
if (values.help) return {
|
|
181
|
+
exitCode: 0,
|
|
182
|
+
output: usage$1
|
|
183
|
+
};
|
|
184
|
+
if (rest.length > 1) return usageError('주제는 하나만 줄 수 있습니다.', usage$1);
|
|
185
|
+
return run$1({
|
|
186
|
+
topic: rest[0],
|
|
187
|
+
json: values.json
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
case 'skill':
|
|
191
|
+
{
|
|
192
|
+
if (values.help) return {
|
|
193
|
+
exitCode: 0,
|
|
194
|
+
output: usage
|
|
195
|
+
};
|
|
196
|
+
if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: install', usage);
|
|
197
|
+
return run({
|
|
198
|
+
sub: rest[0],
|
|
199
|
+
project: values.project,
|
|
200
|
+
force: values.force,
|
|
201
|
+
json: values.json
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
return usageError(`알 수 없는 명령: ${cmd}`, help);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { VERSION, main };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MinifyReport } from '../../core/minify.js';
|
|
2
|
+
import { type SandboxReport } from '../../core/sandbox.js';
|
|
3
|
+
import { type CheckResult } from '../../rules/index.js';
|
|
4
|
+
import type { Excluded } from '../../core/collect.js';
|
|
5
|
+
import type { CommandResult } from '../../types.js';
|
|
6
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk build [\uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354] [--json]\n\n elice.config.json\uC758 root(\uAE30\uBCF8 .)\uB97C \uBAA8\uC544 \uC815\uB2F5\u00B7\uBE44\uBC00\u00B7\uD504\uB85C\uC81D\uD2B8 \uD30C\uC77C\uC744 \uBE7C\uACE0,\n screens \uC124\uC815\uC73C\uB85C metadata.json\uC744 \uB9CC\uB4E0 \uB4A4, \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uBA74 <outDir>/content.zip\uC744 \uB9CC\uB4E0\uB2E4\n (outDir \uAE30\uBCF8 dist). \uC9C0\uC6D0 \uCC44\uC810 \uC720\uD615(gradingTypes)\uB9CC metadata.json\uC5D0 \uC801\uACE0 \uC815\uB2F5\uC740 \uB123\uC9C0 \uC54A\uB294\uB2E4.\n \uC6D0\uBCF8 \uCD5C\uC0C1\uC704 commentary.txt(\uD559\uC2B5 \uCC38\uACE0 \uB0B4\uC6A9)\uAC00 \uC788\uC73C\uBA74 zip\uC5D0 \uB123\uACE0 metadata.json commentary\uC5D0 \uC801\uB294\uB2E4.\n \uC124\uC815\uC5D0 \"minify\": true\uBA74 JS \u00B7 CSS \u00B7 JSON\uC744 \uC904\uC5EC\uC11C \uB123\uB294\uB2E4 (\uAC80\uC0AC\uB294 \uC904\uC774\uAE30 \uC804 \uC6D0\uBCF8\uC73C\uB85C),\n \"sourcemap\": true\uBA74 \uC904\uC778 \uD30C\uC77C\uC758 .map\uB3C4 \uB123\uB294\uB2E4. metadata.json build\uC5D0 \uBC84\uC804\uACFC \uB0B4\uC6A9 \uC9C0\uBB38(digest)\uC744 \uC801\uB294\uB2E4.\n LXP\uB294 \uC790\uB8CC\uB97C sandbox(origin null)\uC5D0\uC11C \uC5F4\uC5B4 \uBAA8\uB4C8 \uC2A4\uD06C\uB9BD\uD2B8 \uD30C\uC77C \u00B7 fetch\uAC00 \uB9C9\uD788\uBBC0\uB85C,\n HTML\uC758 <script type=\"module\" src>\uB97C \uBB36\uC5B4 HTML \uC548\uC5D0 \uB123\uACE0 zip \uC548 JSON\uB3C4 \uD398\uC774\uC9C0\uC5D0 \uB123\uB294\uB2E4.\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC131\uACF5 \u00B7 1 \uAC80\uC0AC \uC624\uB958 (zip \uB9CC\uB4E4\uC9C0 \uC54A\uC74C) \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
|
|
7
|
+
export interface BuildResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
engine: string;
|
|
10
|
+
outDir: string;
|
|
11
|
+
zip: string | null;
|
|
12
|
+
zipBytes: number;
|
|
13
|
+
files: string[];
|
|
14
|
+
excluded: Excluded[];
|
|
15
|
+
/** minify를 켰을 때만 */
|
|
16
|
+
minify?: MinifyReport | undefined;
|
|
17
|
+
/** 모듈 스크립트를 묶어 넣은 HTML */
|
|
18
|
+
sandbox: SandboxReport;
|
|
19
|
+
/** 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보, 참고용) */
|
|
20
|
+
unreferenced: string[];
|
|
21
|
+
/** metadata.json build.digest와 같음 */
|
|
22
|
+
digest: string;
|
|
23
|
+
check: CheckResult;
|
|
24
|
+
}
|
|
25
|
+
export declare function build(projectDir: string): Promise<BuildResult>;
|
|
26
|
+
export declare function formatText(projectDir: string, r: BuildResult): string;
|
|
27
|
+
export declare function run(args: {
|
|
28
|
+
target: string;
|
|
29
|
+
json: boolean;
|
|
30
|
+
}): Promise<CommandResult>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { rm, mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, dirname, relative } from 'node:path';
|
|
3
|
+
import { loadConfig } from '../../core/config.js';
|
|
4
|
+
import { contentDigest } from '../../core/manifest.js';
|
|
5
|
+
import { minifyFiles } from '../../core/minify.js';
|
|
6
|
+
import { prepareContent } from '../../core/prepare.js';
|
|
7
|
+
import { inlineModuleScripts } from '../../core/sandbox.js';
|
|
8
|
+
import { createZip } from '../../core/zip.js';
|
|
9
|
+
import { checkFiles } from '../../rules/check.js';
|
|
10
|
+
import { rules } from '../../rules/spec.js';
|
|
11
|
+
import { findUnreferenced } from '../../rules/unused.js';
|
|
12
|
+
import 'fflate';
|
|
13
|
+
import { formatIssues } from '../check/index.js';
|
|
14
|
+
|
|
15
|
+
const usage = `사용법: ecdk build [프로젝트 폴더] [--json]
|
|
16
|
+
|
|
17
|
+
elice.config.json의 root(기본 .)를 모아 정답·비밀·프로젝트 파일을 빼고,
|
|
18
|
+
screens 설정으로 metadata.json을 만든 뒤, 검사를 통과하면 <outDir>/content.zip을 만든다
|
|
19
|
+
(outDir 기본 dist). 지원 채점 유형(gradingTypes)만 metadata.json에 적고 정답은 넣지 않는다.
|
|
20
|
+
원본 최상위 commentary.txt(학습 참고 내용)가 있으면 zip에 넣고 metadata.json commentary에 적는다.
|
|
21
|
+
설정에 "minify": true면 JS · CSS · JSON을 줄여서 넣는다 (검사는 줄이기 전 원본으로),
|
|
22
|
+
"sourcemap": true면 줄인 파일의 .map도 넣는다. metadata.json build에 버전과 내용 지문(digest)을 적는다.
|
|
23
|
+
LXP는 자료를 sandbox(origin null)에서 열어 모듈 스크립트 파일 · fetch가 막히므로,
|
|
24
|
+
HTML의 <script type="module" src>를 묶어 HTML 안에 넣고 zip 안 JSON도 페이지에 넣는다.
|
|
25
|
+
|
|
26
|
+
종료 코드: 0 성공 · 1 검사 오류 (zip 만들지 않음) · 2 잘못된 사용`;
|
|
27
|
+
async function build(projectDir) {
|
|
28
|
+
const config = await loadConfig(projectDir);
|
|
29
|
+
const {
|
|
30
|
+
outDir,
|
|
31
|
+
engine,
|
|
32
|
+
files: sources,
|
|
33
|
+
excluded
|
|
34
|
+
} = await prepareContent(projectDir, config);
|
|
35
|
+
// minify는 zip에 넣을 내용만 바꾼다. 검사는 원본으로: 줄이면 ecdk-ignore 주석이 사라지고 줄 번호가 바뀐다.
|
|
36
|
+
// 용량 한도는 실제로 올릴 zip 크기로 본다
|
|
37
|
+
// LXP는 모듈 스크립트 파일 · fetch를 CORS로 막는다: HTML마다 모듈을 묶어 넣고 JSON도 넣는다 (core/sandbox.ts)
|
|
38
|
+
const sandboxed = await inlineModuleScripts(sources, {
|
|
39
|
+
minify: config.minify === true
|
|
40
|
+
});
|
|
41
|
+
const minified = config.minify ? await minifyFiles(sandboxed.files, {
|
|
42
|
+
sourcemap: config.sourcemap === true
|
|
43
|
+
}) : null;
|
|
44
|
+
// metadata.json build에 minify 여부와 최종 내용의 지문을 적는다 (지문은 metadata.json을 뺀 파일로)
|
|
45
|
+
const digest = contentDigest(minified?.files ?? sandboxed.files);
|
|
46
|
+
const files = withBuildStamp(minified?.files ?? sandboxed.files, {
|
|
47
|
+
...(minified ? {
|
|
48
|
+
minify: true
|
|
49
|
+
} : {}),
|
|
50
|
+
digest
|
|
51
|
+
});
|
|
52
|
+
const zip = createZip(files);
|
|
53
|
+
const check = checkFiles(sources, {
|
|
54
|
+
input: 'zip',
|
|
55
|
+
zipBytes: zip.byteLength,
|
|
56
|
+
bundlesModules: true
|
|
57
|
+
});
|
|
58
|
+
// .map을 더했으면 파일 수 한도는 실제 zip으로 다시 본다
|
|
59
|
+
const realCount = files.filter(f => !f.path.endsWith('/')).length;
|
|
60
|
+
if (realCount > rules.limits.maxFiles && !check.issues.some(i => i.id === 'limit.file-count')) {
|
|
61
|
+
check.issues.unshift({
|
|
62
|
+
id: 'limit.file-count',
|
|
63
|
+
level: 'error',
|
|
64
|
+
message: `sourcemap을 더하면 파일이 ${realCount}개라 한도 ${rules.limits.maxFiles}개를 넘습니다. sourcemap을 끄거나 파일을 줄여 주세요.`
|
|
65
|
+
});
|
|
66
|
+
check.ok = false;
|
|
67
|
+
}
|
|
68
|
+
// 산출물은 <outDir>/content/ 와 <outDir>/content.zip만 건드린다
|
|
69
|
+
const contentDir = join(outDir, 'content');
|
|
70
|
+
const zipPath = join(outDir, 'content.zip');
|
|
71
|
+
await rm(contentDir, {
|
|
72
|
+
recursive: true,
|
|
73
|
+
force: true
|
|
74
|
+
});
|
|
75
|
+
await rm(zipPath, {
|
|
76
|
+
force: true
|
|
77
|
+
});
|
|
78
|
+
for (const f of files) {
|
|
79
|
+
const target = join(contentDir, ...f.path.split('/'));
|
|
80
|
+
await mkdir(dirname(target), {
|
|
81
|
+
recursive: true
|
|
82
|
+
});
|
|
83
|
+
await writeFile(target, f.data);
|
|
84
|
+
}
|
|
85
|
+
if (check.ok) await writeFile(zipPath, zip);
|
|
86
|
+
const zipBytes = zip.byteLength;
|
|
87
|
+
return {
|
|
88
|
+
ok: check.ok,
|
|
89
|
+
engine,
|
|
90
|
+
outDir,
|
|
91
|
+
zip: check.ok ? zipPath : null,
|
|
92
|
+
zipBytes,
|
|
93
|
+
files: files.map(f => f.path),
|
|
94
|
+
excluded,
|
|
95
|
+
minify: minified?.report,
|
|
96
|
+
sandbox: sandboxed.report,
|
|
97
|
+
unreferenced: findUnreferenced(sources, check.manifest),
|
|
98
|
+
digest,
|
|
99
|
+
check
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** metadata.json(원본에 직접 쓴 것 포함)의 build에 값을 더한다. 형식이 틀리면 그대로 두고 검사가 알려 준다 */
|
|
103
|
+
function withBuildStamp(files, stamp) {
|
|
104
|
+
return files.map(f => {
|
|
105
|
+
if (f.path !== rules.manifest.file) return f;
|
|
106
|
+
try {
|
|
107
|
+
const raw = JSON.parse(new TextDecoder().decode(f.data));
|
|
108
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return f;
|
|
109
|
+
const next = {
|
|
110
|
+
...raw,
|
|
111
|
+
build: {
|
|
112
|
+
...raw.build,
|
|
113
|
+
...stamp
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
...f,
|
|
118
|
+
data: new TextEncoder().encode(`${JSON.stringify(next, null, 2)}\n`)
|
|
119
|
+
};
|
|
120
|
+
} catch {
|
|
121
|
+
return f;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const REASON = {
|
|
126
|
+
secret: '정답·비밀',
|
|
127
|
+
dev: '개발용',
|
|
128
|
+
junk: 'OS 파일',
|
|
129
|
+
project: '프로젝트 파일',
|
|
130
|
+
link: '심볼릭 링크 · 특수 파일: 따라가지 않음. 실제 파일로 복사해 넣어 주세요',
|
|
131
|
+
config: '설정 exclude'
|
|
132
|
+
};
|
|
133
|
+
function formatText(projectDir, r) {
|
|
134
|
+
const lines = [];
|
|
135
|
+
if (r.excluded.length > 0) {
|
|
136
|
+
lines.push(`zip에서 뺀 파일 ${r.excluded.length}개`);
|
|
137
|
+
for (const e of r.excluded) lines.push(` - ${e.path} (${REASON[e.reason]})`);
|
|
138
|
+
lines.push('');
|
|
139
|
+
}
|
|
140
|
+
const kb = n => `${(n / 1024).toFixed(1)}KB`;
|
|
141
|
+
if (r.minify) {
|
|
142
|
+
lines.push(`minify: 파일 ${r.minify.files}개 ${kb(r.minify.before)} → ${kb(r.minify.after)} (zip에 넣는 내용만, 검사는 원본으로)`);
|
|
143
|
+
if (r.minify.maps) lines.push(`sourcemap: .map ${r.minify.maps.files}개 ${kb(r.minify.maps.bytes)} 추가`);
|
|
144
|
+
lines.push('');
|
|
145
|
+
}
|
|
146
|
+
if (r.unreferenced.length > 0) {
|
|
147
|
+
lines.push(`참고: 어디서도 이름이 나오지 않는 파일 ${r.unreferenced.length}개 (쓰지 않으면 빼서 용량을 줄이세요)`, ...r.unreferenced.map(p => ` - ${p}`), '');
|
|
148
|
+
}
|
|
149
|
+
lines.push(...formatIssues(r.check));
|
|
150
|
+
if (r.check.issues.length > 0) lines.push('');
|
|
151
|
+
const rel = p => relative(projectDir, p) || '.';
|
|
152
|
+
lines.push(r.ok && r.zip ? `[ok] ${rel(r.zip)} · 파일 ${r.files.length}개 · ${(r.zipBytes / 1024).toFixed(1)}KB (엔진 ${r.engine}, 규칙 ${r.check.rulesVersion})` : `[fail] 검사 오류가 있어 zip을 만들지 않았습니다. 결과물 확인: ${rel(join(r.outDir, 'content'))}`);
|
|
153
|
+
return lines.join('\n');
|
|
154
|
+
}
|
|
155
|
+
async function run(args) {
|
|
156
|
+
const result = await build(args.target);
|
|
157
|
+
return {
|
|
158
|
+
exitCode: result.ok ? 0 : 1,
|
|
159
|
+
output: args.json ? JSON.stringify(result, null, 2) : formatText(args.target, result)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { build, formatText, run, usage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CheckResult } from '../../rules/index.js';
|
|
2
|
+
import type { CommandResult } from '../../types.js';
|
|
3
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk check [\uACBD\uB85C] [--json]\n\n \uACBD\uB85C \uD3F4\uB354, .zip, .html (\uAE30\uBCF8\uAC12: \uD604\uC7AC \uD3F4\uB354)\n --json \uAE30\uACC4\uC6A9 \uCD9C\uB825 (Claude \uC2A4\uD0AC\u00B7CI)\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uD1B5\uACFC \u00B7 1 \uC624\uB958 \uC788\uC74C \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
|
|
4
|
+
export declare function formatIssues(r: CheckResult): string[];
|
|
5
|
+
export declare function formatText(target: string, r: CheckResult): string;
|
|
6
|
+
export declare function run(args: {
|
|
7
|
+
target: string;
|
|
8
|
+
json: boolean;
|
|
9
|
+
}): Promise<CommandResult>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { checkPath } from '../../rules/node.js';
|
|
2
|
+
|
|
3
|
+
const usage = `사용법: ecdk check [경로] [--json]
|
|
4
|
+
|
|
5
|
+
경로 폴더, .zip, .html (기본값: 현재 폴더)
|
|
6
|
+
--json 기계용 출력 (Claude 스킬·CI)
|
|
7
|
+
|
|
8
|
+
종료 코드: 0 통과 · 1 오류 있음 · 2 잘못된 사용`;
|
|
9
|
+
function formatIssues(r) {
|
|
10
|
+
return r.issues.map(i => {
|
|
11
|
+
const at = i.path ? ` ${i.path}${i.line ? `:${i.line}` : ''}` : '';
|
|
12
|
+
return `[${i.level}] ${i.id}${at}\n ${i.message}`;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function formatText(target, r) {
|
|
16
|
+
const lines = formatIssues(r);
|
|
17
|
+
const errors = r.issues.filter(i => i.level === 'error').length;
|
|
18
|
+
const warns = r.issues.length - errors;
|
|
19
|
+
const size = r.stats.zipBytes < 1024 * 1024 ? `${(r.stats.zipBytes / 1024).toFixed(1)}KB` : `${(r.stats.zipBytes / 1024 / 1024).toFixed(1)}MB`;
|
|
20
|
+
lines.push('', `${r.ok ? '[ok]' : '[fail]'} ${target} · 파일 ${r.stats.files}개 · zip ${size} · 오류 ${errors} · 경고 ${warns} (규칙 ${r.rulesVersion})`);
|
|
21
|
+
return lines.join('\n');
|
|
22
|
+
}
|
|
23
|
+
async function run(args) {
|
|
24
|
+
const result = await checkPath(args.target);
|
|
25
|
+
return {
|
|
26
|
+
exitCode: result.ok ? 0 : 1,
|
|
27
|
+
output: args.json ? JSON.stringify(result, null, 2) : formatText(args.target, result)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { formatIssues, formatText, run, usage };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TEMPLATES, THEMES, createProject } from './scaffold.js';
|
|
2
|
+
|
|
3
|
+
const usage = `사용법: ecdk create <폴더> [--template ${TEMPLATES.join('|')}] [--theme ${THEMES.join('|')}] [--json]
|
|
4
|
+
|
|
5
|
+
학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면과 SDK 연결 로직(lib/)이 든 프로젝트를 만든다.
|
|
6
|
+
quiz: 객관식·단답 퀴즈 묶음 예제 (기본) · blank: 화면 3개 골격만
|
|
7
|
+
--theme dark: Elice Design System 어두운 화면 (기본 light)
|
|
8
|
+
|
|
9
|
+
종료 코드: 0 성공 · 2 잘못된 사용 (비어 있지 않은 폴더 포함)`;
|
|
10
|
+
async function run(args) {
|
|
11
|
+
const r = await createProject({
|
|
12
|
+
dir: args.target,
|
|
13
|
+
template: args.template,
|
|
14
|
+
theme: args.theme
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
exitCode: 0,
|
|
18
|
+
output: args.json ? JSON.stringify(r, null, 2) : `[ok] ${r.dir} (${r.template} 템플릿${r.theme === 'dark' ? ' · 어두운 테마' : ''}, 파일 ${r.files.length}개)\n\n고칠 파일: screens/learn.js · screens/instructor.js · screens/edit.js · content.json · styles.css\n\n cd ${args.target}\n ecdk doctor\n ecdk build`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { run, usage };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const TEMPLATES: readonly ["quiz", "blank"];
|
|
2
|
+
export type TemplateName = (typeof TEMPLATES)[number];
|
|
3
|
+
/** 화면 테마. dark는 화면 HTML에 data-eds-theme="dark"를 붙여 EDS 어두운 팔레트를 쓴다 */
|
|
4
|
+
export declare const THEMES: readonly ["light", "dark"];
|
|
5
|
+
export type ThemeName = (typeof THEMES)[number];
|
|
6
|
+
export interface CreateOptions {
|
|
7
|
+
dir: string;
|
|
8
|
+
template: TemplateName;
|
|
9
|
+
/** 기본: light */
|
|
10
|
+
theme?: ThemeName;
|
|
11
|
+
/** 기본: 폴더 이름 */
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateResult {
|
|
15
|
+
dir: string;
|
|
16
|
+
template: TemplateName;
|
|
17
|
+
theme: ThemeName;
|
|
18
|
+
files: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 템플릿(화면 3개 + 내용 + 설정)과 공통 lib/(키트, @eliceio/cdk 묶음, 기본 스타일)를 새 폴더에 복사한다.
|
|
22
|
+
* 비어 있지 않은 폴더에는 만들지 않는다 (덮어쓰기 방지).
|
|
23
|
+
*/
|
|
24
|
+
export declare function createProject(options: CreateOptions): Promise<CreateResult>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { readdir, mkdir, cp, rename, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join, basename } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const TEMPLATES = ['quiz', 'blank'];
|
|
7
|
+
/** 화면 테마. dark는 화면 HTML에 data-eds-theme="dark"를 붙여 EDS 어두운 팔레트를 쓴다 */
|
|
8
|
+
const THEMES = ['light', 'dark'];
|
|
9
|
+
/** 패키지 루트의 templates/ (es/commands/create/와 src/commands/create/ 모두 세 단계 위) */
|
|
10
|
+
const TEMPLATE_ROOT = fileURLToPath(new URL('../../../templates', import.meta.url));
|
|
11
|
+
/** 템플릿을 묶어 배포하는 @eliceio/cdk-cli 버전 (패키지 루트의 package.json) */
|
|
12
|
+
const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL('../../../package.json', import.meta.url)), 'utf8')).version;
|
|
13
|
+
async function listFiles(dir, base = '') {
|
|
14
|
+
const out = [];
|
|
15
|
+
for (const e of await readdir(join(dir, base), {
|
|
16
|
+
withFileTypes: true
|
|
17
|
+
})) {
|
|
18
|
+
const rel = base ? `${base}/${e.name}` : e.name;
|
|
19
|
+
if (e.isDirectory()) out.push(...(await listFiles(dir, rel)));else out.push(rel);
|
|
20
|
+
}
|
|
21
|
+
return out.sort();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 템플릿(화면 3개 + 내용 + 설정)과 공통 lib/(키트, @eliceio/cdk 묶음, 기본 스타일)를 새 폴더에 복사한다.
|
|
25
|
+
* 비어 있지 않은 폴더에는 만들지 않는다 (덮어쓰기 방지).
|
|
26
|
+
*/
|
|
27
|
+
async function createProject(options) {
|
|
28
|
+
if (!TEMPLATES.includes(options.template)) throw new Error(`알 수 없는 템플릿: ${options.template} (가능: ${TEMPLATES.join(', ')})`);
|
|
29
|
+
const theme = options.theme ?? 'light';
|
|
30
|
+
if (!THEMES.includes(theme)) throw new Error(`알 수 없는 테마: ${theme} (가능: ${THEMES.join(', ')})`);
|
|
31
|
+
const dir = resolve(options.dir);
|
|
32
|
+
const existing = await readdir(dir).catch(e => {
|
|
33
|
+
if (e.code === 'ENOENT') return [];
|
|
34
|
+
throw e;
|
|
35
|
+
});
|
|
36
|
+
if (existing.length > 0) throw new Error(`비어 있지 않은 폴더입니다: ${dir}`);
|
|
37
|
+
await mkdir(dir, {
|
|
38
|
+
recursive: true
|
|
39
|
+
});
|
|
40
|
+
await cp(join(TEMPLATE_ROOT, '_shared'), dir, {
|
|
41
|
+
recursive: true
|
|
42
|
+
});
|
|
43
|
+
await cp(join(TEMPLATE_ROOT, options.template), dir, {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
// npm은 패키지 안의 .gitignore를 빼고 배포하므로 이름을 바꿔 두었다가 되돌린다
|
|
47
|
+
await rename(join(dir, 'gitignore'), join(dir, '.gitignore'));
|
|
48
|
+
if (theme === 'dark') {
|
|
49
|
+
// 화면 HTML(최상위)의 <html>에 테마를 붙인다. 바꾸려면 이 속성만 지우면 된다
|
|
50
|
+
for (const file of (await readdir(dir)).filter(f => f.endsWith('.html'))) {
|
|
51
|
+
const path = join(dir, file);
|
|
52
|
+
const html = await readFile(path, 'utf8');
|
|
53
|
+
await writeFile(path, html.replace(/<html(?![^>]*data-eds-theme)/, '<html data-eds-theme="dark"'));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// 어떤 템플릿 · 버전으로 만들었는지 (build가 metadata.json build.template에 적음)
|
|
57
|
+
const configPath = join(dir, 'elice.config.json');
|
|
58
|
+
const config = JSON.parse(await readFile(configPath, 'utf8'));
|
|
59
|
+
await writeFile(configPath, `${JSON.stringify({
|
|
60
|
+
template: `${options.template}@${PACKAGE_VERSION}`,
|
|
61
|
+
...config
|
|
62
|
+
}, null, 2)}\n`);
|
|
63
|
+
const name = options.name ?? basename(dir);
|
|
64
|
+
const readme = join(dir, 'README.md');
|
|
65
|
+
await writeFile(readme, (await readFile(readme, 'utf8')).replaceAll('{{name}}', name));
|
|
66
|
+
await writeFile(join(dir, 'package.json'), `${JSON.stringify({
|
|
67
|
+
name: name.toLowerCase().replace(/[^a-z0-9-_.]+/g, '-'),
|
|
68
|
+
private: true,
|
|
69
|
+
scripts: {
|
|
70
|
+
doctor: 'ecdk doctor',
|
|
71
|
+
build: 'ecdk build'
|
|
72
|
+
}
|
|
73
|
+
}, null, 2)}\n`);
|
|
74
|
+
return {
|
|
75
|
+
dir,
|
|
76
|
+
template: options.template,
|
|
77
|
+
theme,
|
|
78
|
+
files: await listFiles(dir)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { TEMPLATES, THEMES, createProject };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandResult } from '../../types.js';
|
|
2
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk dev [\uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354] [--port 4170]\n\n \uB85C\uCEEC\uC5D0\uC11C \uC6B4\uC601\uACFC \uAC19\uC740 \uC870\uAC74\uC73C\uB85C \uCF58\uD150\uCE20\uB97C \uB744\uC6B4\uB2E4.\n - http://localhost:<port> LXP \uD749\uB0B4 \uD654\uBA74: \uD559\uC0DD \u00B7 \uD29C\uD130\uB9C1 \u00B7 \uAD50\uC721\uC790 \uD654\uBA74 \u00B7 \uB0B4\uC6A9 \uD3B8\uC9D1\n - \uCF58\uD150\uCE20\uB294 \uB2E4\uB978 \uCD9C\uCC98(127.0.0.1:<port+1>)\uC5D0\uC11C \uC6B4\uC601 \uD5E4\uB354(CSP sandbox allow-scripts)\uB85C\n - \uC2E4\uC81C @eliceio/cdk\uAC00 elice-material \uD749\uB0B4 API\uC640 \uD1B5\uC2E0, \uCC44\uC810\uC740 grading.json(\uC720\uD615 \u00B7 \uC815\uB2F5, \uC5C6\uC73C\uBA74 gradingTypes \uCCAB \uC720\uD615)\n - \uD30C\uC77C\uC744 \uACE0\uCE58\uBA74 \uB2E4\uC2DC \uAC80\uC0AC\uD558\uACE0 \uD654\uBA74\uC744 \uC0C8\uB85C \uB744\uC6C0, \uCF58\uD150\uCE20\uC758 \uCF58\uC194 \uC624\uB958\uC640 404\uB97C \uC5EC\uAE30\uC5D0 \uD45C\uC2DC\n\n\uB05D\uB0B4\uAE30: Ctrl+C";
|
|
3
|
+
export declare function run(args: {
|
|
4
|
+
target: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
}): Promise<CommandResult>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { startDevServer } from '../../dev/server.js';
|
|
2
|
+
|
|
3
|
+
const usage = `사용법: ecdk dev [프로젝트 폴더] [--port 4170]
|
|
4
|
+
|
|
5
|
+
로컬에서 운영과 같은 조건으로 콘텐츠를 띄운다.
|
|
6
|
+
- http://localhost:<port> LXP 흉내 화면: 학생 · 튜터링 · 교육자 화면 · 내용 편집
|
|
7
|
+
- 콘텐츠는 다른 출처(127.0.0.1:<port+1>)에서 운영 헤더(CSP sandbox allow-scripts)로
|
|
8
|
+
- 실제 @eliceio/cdk가 elice-material 흉내 API와 통신, 채점은 grading.json(유형 · 정답, 없으면 gradingTypes 첫 유형)
|
|
9
|
+
- 파일을 고치면 다시 검사하고 화면을 새로 띄움, 콘텐츠의 콘솔 오류와 404를 여기에 표시
|
|
10
|
+
|
|
11
|
+
끝내기: Ctrl+C`;
|
|
12
|
+
async function run(args) {
|
|
13
|
+
const port = args.port === undefined ? undefined : Number(args.port);
|
|
14
|
+
if (port !== undefined && !(Number.isInteger(port) && port >= 0 && port < 65535)) return {
|
|
15
|
+
exitCode: 2,
|
|
16
|
+
output: `포트가 올바르지 않습니다: ${args.port}\n\n${usage}`
|
|
17
|
+
};
|
|
18
|
+
const server = await startDevServer({
|
|
19
|
+
dir: args.target,
|
|
20
|
+
...(port === undefined ? {} : {
|
|
21
|
+
port
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
process.stdout.write(`\n ecdk dev ${server.hostUrl}\n 콘텐츠 ${server.contentUrl}\n\n 끝내려면 Ctrl+C\n\n`);
|
|
25
|
+
await new Promise(done => {
|
|
26
|
+
const stop = () => {
|
|
27
|
+
process.off('SIGINT', stop);
|
|
28
|
+
process.off('SIGTERM', stop);
|
|
29
|
+
void server.close().then(done);
|
|
30
|
+
};
|
|
31
|
+
process.on('SIGINT', stop);
|
|
32
|
+
process.on('SIGTERM', stop);
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
exitCode: 0,
|
|
36
|
+
output: ''
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { run, usage };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CommandResult } from '../../types.js';
|
|
2
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk doctor [\uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354] [--fix] [--json]\n\n \uD658\uACBD(Node, \uD328\uD0A4\uC9C0 \uB9E4\uB2C8\uC800)\uACFC \uD504\uB85C\uC81D\uD2B8(\uC124\uC815, \uC6D0\uBCF8, \uC815\uB2F5 \uC720\uCD9C, \uAC80\uC0AC)\uB97C \uC810\uAC80\uD55C\uB2E4.\n --fix \uC790\uB3D9\uC73C\uB85C \uACE0\uCE60 \uC218 \uC788\uB294 \uD56D\uBAA9(auto)\uC744 \uACE0\uCE5C\uB2E4\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC2E4\uD328 \uC5C6\uC74C \u00B7 1 \uC2E4\uD328 \uC788\uC74C \u00B7 2 \uC798\uBABB\uB41C \uC0AC\uC6A9";
|
|
3
|
+
export type DoctorLevel = 'ok' | 'warn' | 'fail' | 'skip';
|
|
4
|
+
export interface DoctorCheck {
|
|
5
|
+
id: string;
|
|
6
|
+
level: DoctorLevel;
|
|
7
|
+
message: string;
|
|
8
|
+
fix?: {
|
|
9
|
+
description: string;
|
|
10
|
+
command?: string;
|
|
11
|
+
auto: boolean;
|
|
12
|
+
} | undefined;
|
|
13
|
+
fixed?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface DoctorResult {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
cli: string;
|
|
18
|
+
rules: string;
|
|
19
|
+
checks: DoctorCheck[];
|
|
20
|
+
}
|
|
21
|
+
export declare function checkNode(version: string): DoctorCheck;
|
|
22
|
+
export declare function doctor(target: string, opts: {
|
|
23
|
+
fix: boolean;
|
|
24
|
+
nodeVersion?: string;
|
|
25
|
+
home?: string | undefined;
|
|
26
|
+
}): Promise<DoctorResult>;
|
|
27
|
+
export declare function formatText(r: DoctorResult): string;
|
|
28
|
+
export declare function run(args: {
|
|
29
|
+
target: string;
|
|
30
|
+
json: boolean;
|
|
31
|
+
fix: boolean;
|
|
32
|
+
}): Promise<CommandResult>;
|
|
33
|
+
/** 주석뿐이 아닌 줄에서 정답·설정 파일 이름이 나오는지. 줄 건너뛰기는 금지 API 검사와 같은 규칙(content-rules lineSkipper) */
|
|
34
|
+
export declare function referencesAnswerFile(text: string): boolean;
|