@eliceio/cdk-cli 0.1.0-alpha.2 → 0.1.0-alpha.4

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.
Files changed (103) hide show
  1. package/README.md +263 -191
  2. package/es/cli.js +93 -33
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +21 -12
  5. package/es/commands/check/index.d.ts +11 -2
  6. package/es/commands/check/index.js +51 -5
  7. package/es/commands/create/index.d.ts +6 -0
  8. package/es/commands/create/index.js +56 -8
  9. package/es/commands/create/install.d.ts +17 -0
  10. package/es/commands/create/install.js +53 -0
  11. package/es/commands/create/scaffold.d.ts +6 -1
  12. package/es/commands/create/scaffold.js +27 -17
  13. package/es/commands/dev/index.d.ts +1 -1
  14. package/es/commands/dev/index.js +6 -2
  15. package/es/commands/doctor/index.d.ts +21 -0
  16. package/es/commands/doctor/index.js +255 -38
  17. package/es/commands/mcp/index.d.ts +134 -0
  18. package/es/commands/mcp/index.js +399 -0
  19. package/es/commands/setup/index.d.ts +40 -0
  20. package/es/commands/setup/index.js +157 -0
  21. package/es/commands/skill/index.d.ts +2 -5
  22. package/es/commands/skill/index.js +1 -29
  23. package/es/core/collect.d.ts +5 -2
  24. package/es/core/config.d.ts +141 -31
  25. package/es/core/config.js +341 -59
  26. package/es/core/manifest.d.ts +2 -1
  27. package/es/core/manifest.js +2 -1
  28. package/es/core/minify.js +2 -2
  29. package/es/core/prepare.d.ts +18 -2
  30. package/es/core/prepare.js +47 -18
  31. package/es/core/project-check.d.ts +26 -0
  32. package/es/core/project-check.js +53 -0
  33. package/es/core/sandbox.js +2 -2
  34. package/es/core/sdk.d.ts +39 -0
  35. package/es/core/sdk.js +95 -0
  36. package/es/core/templates.d.ts +25 -0
  37. package/es/core/templates.js +41 -0
  38. package/es/dev/grading.d.ts +14 -7
  39. package/es/dev/grading.js +27 -13
  40. package/es/dev/host-page.d.ts +1 -1
  41. package/es/dev/host-page.js +34 -34
  42. package/es/dev/mock-api.d.ts +19 -4
  43. package/es/dev/mock-api.js +75 -9
  44. package/es/dev/server.d.ts +7 -0
  45. package/es/dev/server.js +112 -32
  46. package/es/rules/check.js +95 -10
  47. package/es/rules/index.d.ts +1 -1
  48. package/es/rules/index.js +1 -1
  49. package/es/rules/manifest.d.ts +23 -9
  50. package/es/rules/manifest.js +60 -35
  51. package/es/rules/node.js +3 -1
  52. package/es/rules/semver.d.ts +5 -0
  53. package/es/rules/semver.js +32 -0
  54. package/es/rules/types.d.ts +38 -7
  55. package/es/rules.json.js +2 -2
  56. package/es/test-packages.d.ts +7 -0
  57. package/guides/content-development.md +150 -55
  58. package/package.json +3 -3
  59. package/rules.json +77 -7
  60. package/skills/_shared/always.md +4 -2
  61. package/skills/elice-content-check/SKILL.md +3 -1
  62. package/skills/elice-content-create/SKILL.md +5 -4
  63. package/skills/elice-content-migrate/SKILL.md +2 -2
  64. package/skills/elice-content-publish/SKILL.md +23 -0
  65. package/templates/_shared/lib/cdk-mock.d.ts +21 -3
  66. package/templates/_shared/lib/cdk-mock.js +241 -82
  67. package/templates/_shared/lib/elice-content.css +204 -0
  68. package/templates/_shared/lib/elice-content.d.ts +115 -6
  69. package/templates/_shared/lib/elice-content.js +656 -43
  70. package/templates/blank/README.md +19 -7
  71. package/templates/blank/completion.html +15 -0
  72. package/templates/blank/gitignore +1 -0
  73. package/templates/blank/metadata.json +11 -0
  74. package/templates/blank/package.json +13 -0
  75. package/templates/blank/screens/completion.js +7 -0
  76. package/templates/blank/screens/edit.js +3 -0
  77. package/templates/blank/screens/instructor.js +12 -5
  78. package/templates/blank/screens/learn.js +16 -11
  79. package/templates/blank/template.json +6 -0
  80. package/templates/quiz/README.md +41 -31
  81. package/templates/quiz/core/behaviors.d.ts +5 -0
  82. package/templates/quiz/core/behaviors.js +12 -0
  83. package/templates/quiz/core/editor.d.ts +12 -1
  84. package/templates/quiz/core/editor.js +28 -5
  85. package/templates/quiz/core/model.d.ts +41 -1
  86. package/templates/quiz/core/model.js +272 -5
  87. package/templates/quiz/gitignore +1 -0
  88. package/templates/quiz/metadata.json +11 -0
  89. package/templates/quiz/package.json +13 -0
  90. package/templates/quiz/screens/edit.js +176 -46
  91. package/templates/quiz/screens/instructor.js +18 -12
  92. package/templates/quiz/screens/learn.js +43 -38
  93. package/templates/quiz/styles.css +47 -0
  94. package/templates/quiz/template.json +6 -0
  95. package/templates/quiz/ui/templates/edit.d.ts +3 -0
  96. package/templates/quiz/ui/templates/edit.js +53 -14
  97. package/templates/quiz/ui/texts.js +56 -29
  98. package/templates/_shared/lib/cdk.js +0 -3
  99. package/templates/blank/content.json +0 -4
  100. package/templates/blank/elice.config.json +0 -12
  101. package/templates/quiz/content.json +0 -81
  102. package/templates/quiz/elice.config.json +0 -14
  103. package/templates/quiz/grading.json +0 -13
package/es/cli.js CHANGED
@@ -1,11 +1,13 @@
1
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';
2
+ import { usage as usage$7, run as run$7 } from './commands/build/index.js';
3
+ import { usage as usage$8, run as run$8 } from './commands/check/index.js';
4
+ import { usage as usage$6, list, run as run$6 } from './commands/create/index.js';
5
+ import { usage as usage$5, run as run$5 } from './commands/dev/index.js';
6
+ import { usage as usage$4, run as run$4 } from './commands/doctor/index.js';
7
+ import { usage as usage$3, run as run$3 } from './commands/guide/index.js';
8
+ import { usage, run } from './commands/mcp/index.js';
9
+ import { usage as usage$1, run as run$1 } from './commands/setup/index.js';
10
+ import { usage as usage$2, run as run$2 } from './commands/skill/index.js';
9
11
  import 'fflate';
10
12
  import { RULES_VERSION } from './rules/spec.js';
11
13
  import { VERSION } from './version.js';
@@ -13,13 +15,15 @@ import { VERSION } from './version.js';
13
15
  const help = `ecdk ${VERSION} · Elice CDK CLI (Custom HTML 콘텐츠 도구)
14
16
 
15
17
  명령:
16
- create <폴더> 새 프로젝트 (--template quiz|blank, --theme light|dark)
18
+ create <폴더> 새 프로젝트 + npm install (--template quiz|blank, --theme light|dark, --no-install, --list로 템플릿 목록)
17
19
  check [경로] 업로드 전 검사 (서버와 같은 규칙)
18
20
  build [폴더] 정답·비밀 제외 → 검사 → content.zip
19
21
  dev [폴더] 운영과 같은 조건의 로컬 서버 (--port)
20
22
  doctor [폴더] 환경·프로젝트 점검 (--fix)
21
23
  guide [주제] 에이전트용 개발 가이드 (주제 목록 · 한 절 · all)
24
+ setup 처음 한 번: 스킬 설치 + 학습자료 서버 MCP 등록 + 점검 (--env prod|qa5, --dry-run)
22
25
  skill install Claude Code 스킬 설치 (--project, --force)
26
+ mcp setup 학습자료 서버 MCP 등록 (--target, --env prod|qa5, --url, --dry-run)
23
27
 
24
28
  공통 옵션: --json, --help, --version`;
25
29
  const usageError = (message, usage) => ({
@@ -61,6 +65,27 @@ async function main(argv) {
61
65
  type: 'string',
62
66
  short: 'p'
63
67
  },
68
+ target: {
69
+ type: 'string'
70
+ },
71
+ env: {
72
+ type: 'string'
73
+ },
74
+ url: {
75
+ type: 'string'
76
+ },
77
+ 'dry-run': {
78
+ type: 'boolean',
79
+ default: false
80
+ },
81
+ list: {
82
+ type: 'boolean',
83
+ default: false
84
+ },
85
+ 'no-install': {
86
+ type: 'boolean',
87
+ default: false
88
+ },
64
89
  help: {
65
90
  type: 'boolean',
66
91
  short: 'h',
@@ -94,63 +119,65 @@ async function main(argv) {
94
119
  {
95
120
  if (values.help) return {
96
121
  exitCode: 0,
97
- output: usage$6
122
+ output: usage$8
98
123
  };
99
- if (rest.length > 1) return usageError('경로는 하나만 줄 수 있습니다.', usage$6);
124
+ if (rest.length > 1) return usageError('경로는 하나만 줄 수 있습니다.', usage$8);
100
125
  try {
101
- return await run$6({
126
+ return await run$8({
102
127
  target: rest[0] ?? '.',
103
128
  json: values.json
104
129
  });
105
130
  } catch (e) {
106
131
  const message = e.code === 'ENOENT' ? `경로가 없습니다: ${rest[0] ?? '.'}` : e.message;
107
- return usageError(message, usage$6);
132
+ return usageError(message, usage$8);
108
133
  }
109
134
  }
110
135
  case 'build':
111
136
  {
112
137
  if (values.help) return {
113
138
  exitCode: 0,
114
- output: usage$5
139
+ output: usage$7
115
140
  };
116
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$5);
141
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$7);
117
142
  try {
118
- return await run$5({
143
+ return await run$7({
119
144
  target: rest[0] ?? '.',
120
145
  json: values.json
121
146
  });
122
147
  } catch (e) {
123
148
  const message = e.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : e.message;
124
- return usageError(message, usage$5);
149
+ return usageError(message, usage$7);
125
150
  }
126
151
  }
127
152
  case 'create':
128
153
  {
129
154
  if (values.help) return {
130
155
  exitCode: 0,
131
- output: usage$4
156
+ output: usage$6
132
157
  };
133
- if (rest.length !== 1) return usageError('만들 폴더를 하나 적어 주세요.', usage$4);
158
+ if (values.list) return list(values.json);
159
+ if (rest.length !== 1) return usageError('만들 폴더를 하나 적어 주세요.', usage$6);
134
160
  try {
135
- return await run$4({
161
+ return await run$6({
136
162
  target: rest[0] ?? '',
137
163
  template: values.template ?? 'quiz',
138
164
  theme: values.theme ?? 'light',
165
+ install: !values['no-install'],
139
166
  json: values.json
140
167
  });
141
168
  } catch (e) {
142
- return usageError(e.message, usage$4);
169
+ return usageError(e.message, usage$6);
143
170
  }
144
171
  }
145
172
  case 'dev':
146
173
  {
147
174
  if (values.help) return {
148
175
  exitCode: 0,
149
- output: usage$3
176
+ output: usage$5
150
177
  };
151
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$3);
178
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$5);
152
179
  try {
153
- return await run$3({
180
+ return await run$5({
154
181
  target: rest[0] ?? '.',
155
182
  ...(values.port === undefined ? {} : {
156
183
  port: values.port
@@ -158,18 +185,18 @@ async function main(argv) {
158
185
  });
159
186
  } catch (e) {
160
187
  const err = e;
161
- const message = err.code === 'EADDRINUSE' ? `포트가 이미 쓰이고 있습니다. --port로 다른 포트를 주세요.` : err.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : err.message;
162
- return usageError(message, usage$3);
188
+ const message = err.code === 'EADDRINUSE' ? `${err.message.includes('포트') ? err.message : '포트가 이미 쓰이고 있습니다.'} ecdk dev는 화면 포트(N)와 콘텐츠 포트(N+1) 두 개를 씁니다. --port로 다른 값을 주세요 (예: --port 4180).` : err.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : err.message;
189
+ return usageError(message, usage$5);
163
190
  }
164
191
  }
165
192
  case 'doctor':
166
193
  {
167
194
  if (values.help) return {
168
195
  exitCode: 0,
169
- output: usage$2
196
+ output: usage$4
170
197
  };
171
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$2);
172
- return run$2({
198
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$4);
199
+ return run$4({
173
200
  target: rest[0] ?? '.',
174
201
  json: values.json,
175
202
  fix: values.fix
@@ -179,24 +206,57 @@ async function main(argv) {
179
206
  {
180
207
  if (values.help) return {
181
208
  exitCode: 0,
182
- output: usage$1
209
+ output: usage$3
183
210
  };
184
- if (rest.length > 1) return usageError('주제는 하나만 줄 수 있습니다.', usage$1);
185
- return run$1({
211
+ if (rest.length > 1) return usageError('주제는 하나만 줄 수 있습니다.', usage$3);
212
+ return run$3({
186
213
  topic: rest[0],
187
214
  json: values.json
188
215
  });
189
216
  }
190
217
  case 'skill':
218
+ {
219
+ if (values.help) return {
220
+ exitCode: 0,
221
+ output: usage$2
222
+ };
223
+ if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: install', usage$2);
224
+ return run$2({
225
+ sub: rest[0],
226
+ project: values.project,
227
+ force: values.force,
228
+ json: values.json
229
+ });
230
+ }
231
+ case 'setup':
232
+ {
233
+ if (values.help) return {
234
+ exitCode: 0,
235
+ output: usage$1
236
+ };
237
+ if (rest.length > 0) return usageError('setup은 인자를 받지 않습니다.', usage$1);
238
+ return run$1({
239
+ target: values.target,
240
+ envName: values.env,
241
+ url: values.url,
242
+ dryRun: values['dry-run'],
243
+ force: values.force,
244
+ json: values.json
245
+ });
246
+ }
247
+ case 'mcp':
191
248
  {
192
249
  if (values.help) return {
193
250
  exitCode: 0,
194
251
  output: usage
195
252
  };
196
- if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: install', usage);
253
+ if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: setup', usage);
197
254
  return run({
198
255
  sub: rest[0],
199
- project: values.project,
256
+ target: values.target,
257
+ envName: values.env,
258
+ url: values.url,
259
+ dryRun: values['dry-run'],
200
260
  force: values.force,
201
261
  json: values.json
202
262
  });
@@ -3,7 +3,7 @@ import { type SandboxReport } from '../../core/sandbox.js';
3
3
  import { type CheckResult } from '../../rules/index.js';
4
4
  import type { Excluded } from '../../core/collect.js';
5
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";
6
+ export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk build [\uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354] [--json]\n\n package.json \"ecdk\"\uC758 root(\uAE30\uBCF8 .)\uB97C \uBAA8\uC544 \uC815\uB2F5\u00B7\uBE44\uBC00\u00B7\uD504\uB85C\uC81D\uD2B8 \uD30C\uC77C\uC744 \uBE7C\uACE0,\n \uC6D0\uBCF8\uC758 metadata.json(\uD654\uBA74 \u00B7 \uC644\uB8CC \uC815\uCC45 \u00B7 \uD559\uC2B5 \uCC38\uACE0 \uB0B4\uC6A9)\uC5D0 build\uB97C \uCC44\uC6B4 \uB4A4, \uAC80\uC0AC\uB97C \uD1B5\uACFC\uD558\uBA74 <outDir>/content.zip\uC744 \uB9CC\uB4E0\uB2E4\n (outDir \uAE30\uBCF8 dist). \uC815\uB2F5\uC740 \uD3B8\uC9D1 \uD654\uBA74\uC774 \uC815\uD558\uBBC0\uB85C zip\uC5D0 \uC5C6\uACE0, ecdk dev\uAC00 \uC800\uC7A5\uD55C .ecdk/(settings \u00B7 \uC644\uB8CC \uC815\uCC45)\uB3C4 \uBE60\uC9C4\uB2E4.\n \uC61B elice.config.json\uC774 \uB0A8\uC544 \uC788\uC73C\uBA74 \uC9C0\uAE08\uCC98\uB7FC \uBE4C\uB4DC\uD558\uACE0 \uC62E\uAE30\uB294 \uBC95\uC744 \uACBD\uACE0\uD55C\uB2E4 (ecdk doctor --fix).\n package.json \"ecdk\"\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
7
  export interface BuildResult {
8
8
  ok: boolean;
9
9
  engine: string;
@@ -1,9 +1,10 @@
1
1
  import { rm, mkdir, writeFile } from 'node:fs/promises';
2
2
  import { join, dirname, relative } from 'node:path';
3
- import { loadConfig } from '../../core/config.js';
3
+ import { loadConfig, legacyGradingTypesWarning, CONFIG_FILE } from '../../core/config.js';
4
4
  import { contentDigest } from '../../core/manifest.js';
5
5
  import { minifyFiles } from '../../core/minify.js';
6
6
  import { prepareContent } from '../../core/prepare.js';
7
+ import { projectCheckOptions } from '../../core/project-check.js';
7
8
  import { inlineModuleScripts } from '../../core/sandbox.js';
8
9
  import { createZip } from '../../core/zip.js';
9
10
  import { checkFiles } from '../../rules/check.js';
@@ -14,11 +15,11 @@ import { formatIssues } from '../check/index.js';
14
15
 
15
16
  const usage = `사용법: ecdk build [프로젝트 폴더] [--json]
16
17
 
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을 줄여서 넣는다 (검사는 줄이기 전 원본으로),
18
+ package.json "ecdk"의 root(기본 .)를 모아 정답·비밀·프로젝트 파일을 빼고,
19
+ 원본의 metadata.json(화면 · 완료 정책 · 학습 참고 내용)에 build를 채운 뒤, 검사를 통과하면 <outDir>/content.zip을 만든다
20
+ (outDir 기본 dist). 정답은 편집 화면이 정하므로 zip에 없고, ecdk dev가 저장한 .ecdk/(settings · 완료 정책)도 빠진다.
21
+ 옛 elice.config.json이 남아 있으면 지금처럼 빌드하고 옮기는 법을 경고한다 (ecdk doctor --fix).
22
+ package.json "ecdk"에 "minify": true면 JS · CSS · JSON을 줄여서 넣는다 (검사는 줄이기 전 원본으로),
22
23
  "sourcemap": true면 줄인 파일의 .map도 넣는다. metadata.json build에 버전과 내용 지문(digest)을 적는다.
23
24
  LXP는 자료를 sandbox(origin null)에서 열어 모듈 스크립트 파일 · fetch가 막히므로,
24
25
  HTML의 <script type="module" src>를 묶어 HTML 안에 넣고 zip 안 JSON도 페이지에 넣는다.
@@ -50,11 +51,10 @@ async function build(projectDir) {
50
51
  digest
51
52
  });
52
53
  const zip = createZip(files);
53
- const check = checkFiles(sources, {
54
- input: 'zip',
55
- zipBytes: zip.byteLength,
56
- bundlesModules: true
57
- });
54
+ // 프로젝트 검사: 남은 옛 파일(content.json · grading.json)도 알린다. ecdk dev 상태(.ecdk)는 보지 않는다
55
+ const check = checkFiles(sources, await projectCheckOptions(projectDir, config, {
56
+ zipBytes: zip.byteLength
57
+ }));
58
58
  // .map을 더했으면 파일 수 한도는 실제 zip으로 다시 본다
59
59
  const realCount = files.filter(f => !f.path.endsWith('/')).length;
60
60
  if (realCount > rules.limits.maxFiles && !check.issues.some(i => i.id === 'limit.file-count')) {
@@ -65,6 +65,14 @@ async function build(projectDir) {
65
65
  });
66
66
  check.ok = false;
67
67
  }
68
+ // 옛 elice.config.json gradingTypes: 옮기지 않고 지워 달라고만 알린다 (ADR 0008 · 0009)
69
+ const legacy = legacyGradingTypesWarning(config);
70
+ if (legacy) check.issues.push({
71
+ id: 'manifest.grading-types',
72
+ level: 'warn',
73
+ message: legacy,
74
+ path: CONFIG_FILE
75
+ });
68
76
  // 산출물은 <outDir>/content/ 와 <outDir>/content.zip만 건드린다
69
77
  const contentDir = join(outDir, 'content');
70
78
  const zipPath = join(outDir, 'content.zip');
@@ -128,7 +136,8 @@ const REASON = {
128
136
  junk: 'OS 파일',
129
137
  project: '프로젝트 파일',
130
138
  link: '심볼릭 링크 · 특수 파일: 따라가지 않음. 실제 파일로 복사해 넣어 주세요',
131
- config: '설정 exclude'
139
+ config: '설정 exclude',
140
+ sdk: '옛 lib/cdk.js 복사본: 설치된 @eliceio/cdk를 대신 넣음. 지워도 됩니다'
132
141
  };
133
142
  function formatText(projectDir, r) {
134
143
  const lines = [];
@@ -1,8 +1,17 @@
1
1
  import type { CheckResult } from '../../rules/index.js';
2
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";
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 ecdk \uD504\uB85C\uC81D\uD2B8 \uD3F4\uB354(package.json\uC5D0 \"ecdk\" \uD0A4\uB098 @eliceio/cdk \uC758\uC874\uC131, \uC61B elice.config.json)\uB294\n ecdk build\uAC00 \uB9CC\uB4E4 zip \uAE30\uC900\uC73C\uB85C \uAC80\uC0AC\uD55C\uB2E4\n (\uC815\uB2F5 \u00B7 \uC124\uC815 \u00B7 \uAC1C\uBC1C\uC6A9 \uD30C\uC77C\uC744 \uBE7C\uACE0 metadata.json\uC744 \uB9CC\uB4E0 \uB4A4). \uADF8 \uBC16\uC758 \uD3F4\uB354\uB294 \uADF8\uB300\uB85C \uC62C\uB9B4 zip\uC73C\uB85C \uBCF8\uB2E4\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
+ /** 검사 방식: project = build가 만들 zip 기준, path = 주어진 폴더 · zip · html을 그대로 */
5
+ export type CheckMode = 'project' | 'path';
6
+ /**
7
+ * ecdk 프로젝트 폴더인지 (ADR 0011): package.json에 "ecdk" 키가 있거나 @eliceio/cdk(SDK) · @eliceio/cdk-cli를 쓴다.
8
+ * 옛 elice.config.json이 있는 폴더도 프로젝트로 본다 (옮기라는 경고를 보이려고)
9
+ */
10
+ export declare function isProjectDir(dir: string): Promise<boolean>;
11
+ /** build와 같은 준비(제외 · metadata.json)를 거친 파일로 검사한다. 모듈 묶기는 build가 하므로 module-src는 보지 않는다 */
12
+ export declare function checkProject(dir: string): Promise<CheckResult>;
4
13
  export declare function formatIssues(r: CheckResult): string[];
5
- export declare function formatText(target: string, r: CheckResult): string;
14
+ export declare function formatText(target: string, r: CheckResult, mode?: CheckMode): string;
6
15
  export declare function run(args: {
7
16
  target: string;
8
17
  json: boolean;
@@ -1,19 +1,61 @@
1
+ import { stat, readFile, access } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { CONFIG_FILE, PACKAGE_FILE, PACKAGE_CONFIG_KEY, loadConfig } from '../../core/config.js';
4
+ import { prepareContent } from '../../core/prepare.js';
5
+ import { projectCheckOptions } from '../../core/project-check.js';
6
+ import { SDK_PACKAGE } from '../../core/sdk.js';
7
+ import { createZip } from '../../core/zip.js';
8
+ import { checkFiles } from '../../rules/check.js';
9
+ import '../../rules/spec.js';
10
+ import 'fflate';
1
11
  import { checkPath } from '../../rules/node.js';
2
12
 
3
13
  const usage = `사용법: ecdk check [경로] [--json]
4
14
 
5
15
  경로 폴더, .zip, .html (기본값: 현재 폴더)
16
+ ecdk 프로젝트 폴더(package.json에 "ecdk" 키나 @eliceio/cdk 의존성, 옛 elice.config.json)는
17
+ ecdk build가 만들 zip 기준으로 검사한다
18
+ (정답 · 설정 · 개발용 파일을 빼고 metadata.json을 만든 뒤). 그 밖의 폴더는 그대로 올릴 zip으로 본다
6
19
  --json 기계용 출력 (Claude 스킬·CI)
7
20
 
8
21
  종료 코드: 0 통과 · 1 오류 있음 · 2 잘못된 사용`;
22
+ const exists = p => access(p).then(() => true, () => false);
23
+ /**
24
+ * ecdk 프로젝트 폴더인지 (ADR 0011): package.json에 "ecdk" 키가 있거나 @eliceio/cdk(SDK) · @eliceio/cdk-cli를 쓴다.
25
+ * 옛 elice.config.json이 있는 폴더도 프로젝트로 본다 (옮기라는 경고를 보이려고)
26
+ */
27
+ async function isProjectDir(dir) {
28
+ if (!(await stat(dir)).isDirectory()) return false;
29
+ if (await exists(join(dir, CONFIG_FILE))) return true;
30
+ try {
31
+ const pkg = JSON.parse(await readFile(join(dir, PACKAGE_FILE), 'utf8'));
32
+ if (pkg[PACKAGE_CONFIG_KEY] !== undefined) return true;
33
+ return ['dependencies', 'devDependencies'].some(k => PROJECT_PACKAGES.some(name => pkg[k]?.[name] !== undefined));
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+ /** 이 의존성이 있으면 ecdk 프로젝트 */
39
+ const PROJECT_PACKAGES = [SDK_PACKAGE, '@eliceio/cdk-cli'];
40
+ /** build와 같은 준비(제외 · metadata.json)를 거친 파일로 검사한다. 모듈 묶기는 build가 하므로 module-src는 보지 않는다 */
41
+ async function checkProject(dir) {
42
+ const config = await loadConfig(dir);
43
+ const {
44
+ files
45
+ } = await prepareContent(dir, config);
46
+ return checkFiles(files, await projectCheckOptions(dir, config, {
47
+ zipBytes: createZip(files).byteLength
48
+ }));
49
+ }
9
50
  function formatIssues(r) {
10
51
  return r.issues.map(i => {
11
52
  const at = i.path ? ` ${i.path}${i.line ? `:${i.line}` : ''}` : '';
12
53
  return `[${i.level}] ${i.id}${at}\n ${i.message}`;
13
54
  });
14
55
  }
15
- function formatText(target, r) {
16
- const lines = formatIssues(r);
56
+ function formatText(target, r, mode = 'path') {
57
+ const lines = mode === 'project' ? ['프로젝트로 검사: ecdk build가 만들 zip 기준', ''] : [];
58
+ lines.push(...formatIssues(r));
17
59
  const errors = r.issues.filter(i => i.level === 'error').length;
18
60
  const warns = r.issues.length - errors;
19
61
  const size = r.stats.zipBytes < 1024 * 1024 ? `${(r.stats.zipBytes / 1024).toFixed(1)}KB` : `${(r.stats.zipBytes / 1024 / 1024).toFixed(1)}MB`;
@@ -21,11 +63,15 @@ function formatText(target, r) {
21
63
  return lines.join('\n');
22
64
  }
23
65
  async function run(args) {
24
- const result = await checkPath(args.target);
66
+ const mode = (await isProjectDir(args.target)) ? 'project' : 'path';
67
+ const result = mode === 'project' ? await checkProject(args.target) : await checkPath(args.target);
25
68
  return {
26
69
  exitCode: result.ok ? 0 : 1,
27
- output: args.json ? JSON.stringify(result, null, 2) : formatText(args.target, result)
70
+ output: args.json ? JSON.stringify({
71
+ mode,
72
+ ...result
73
+ }, null, 2) : formatText(args.target, result, mode)
28
74
  };
29
75
  }
30
76
 
31
- export { formatIssues, formatText, run, usage };
77
+ export { checkProject, formatIssues, formatText, isProjectDir, run, usage };
@@ -1,8 +1,14 @@
1
+ import { type InstallResult } from './install.js';
1
2
  import type { CommandResult } from '../../types.js';
2
3
  export declare const usage: string;
4
+ /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 · 완료 정책 */
5
+ export declare function list(json: boolean): CommandResult;
3
6
  export declare function run(args: {
4
7
  target: string;
5
8
  template: string;
6
9
  theme: string;
10
+ install?: boolean;
7
11
  json: boolean;
12
+ }, deps?: {
13
+ install?: (dir: string) => Promise<InstallResult>;
8
14
  }): Promise<CommandResult>;
@@ -1,22 +1,70 @@
1
+ import { INSTALL_COMMAND } from '../../core/sdk.js';
2
+ import { listTemplates } from '../../core/templates.js';
3
+ import { LOCAL_PACKAGES_ENV, npmInstall } from './install.js';
1
4
  import { TEMPLATES, THEMES, createProject } from './scaffold.js';
2
5
 
3
- const usage = `사용법: ecdk create <폴더> [--template ${TEMPLATES.join('|')}] [--theme ${THEMES.join('|')}] [--json]
6
+ const usage = `사용법: ecdk create <폴더> [--template ${TEMPLATES.join('|')}] [--theme ${THEMES.join('|')}] [--no-install] [--json]
7
+ ecdk create --list [--json]
4
8
 
5
- 학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면과 SDK 연결 로직(lib/)이 든 프로젝트를 만든다.
6
- quiz: 객관식·단답 퀴즈 묶음 예제 (기본) · blank: 화면 3개 골격만
9
+ 학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면, 화면 키트(lib/), metadata.json, package.json이 든 프로젝트를 만들고
10
+ npm install을 실행한다. SDK(@eliceio/cdk)는 package.json 의존성이다 (node_modules에 설치, 네트워크 필요).
11
+ quiz: 한 문항 퀴즈(여러 문항은 페이지를 여러 개로, 선택 · 순서 · 주관식 · 그룹 분류, 편집 화면 포함, 기본)
12
+ blank: 퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 화면 3개 골격
13
+ --list: 템플릿 목록과 버전 · 설명 (템플릿마다 버전이 따로 있음)
7
14
  --theme dark: Elice Design System 어두운 화면 (기본 light)
15
+ --no-install: npm install을 하지 않는다 (나중에 프로젝트 폴더에서 npm install)
8
16
 
9
- 종료 코드: 0 성공 · 2 잘못된 사용 (비어 있지 않은 폴더 포함)`;
10
- async function run(args) {
17
+ 종료 코드: 0 성공 · 1 npm install 실패 (프로젝트는 만들어 둠) · 2 잘못된 사용 (비어 있지 않은 폴더 포함)`;
18
+ /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 · 완료 정책 */
19
+ function list(json) {
20
+ const templates = listTemplates();
21
+ if (json) return {
22
+ exitCode: 0,
23
+ output: JSON.stringify({
24
+ templates
25
+ }, null, 2)
26
+ };
27
+ const lines = templates.map(t => {
28
+ const p = t.completionPolicies ?? [];
29
+ const completion = p.length === 0 ? '-' : p.length === 1 ? `${p[0]} 고정` : `${p.join(' · ')} (기본 ${p[0]}, 완료 정책 화면에서 고름)`;
30
+ return `${t.name}@${t.version} ${t.title}\n ${t.description}\n 화면: ${t.screens.join(' · ')} · 완료 정책: ${completion}`;
31
+ });
32
+ return {
33
+ exitCode: 0,
34
+ output: `${lines.join('\n\n')}\n\n만들기: ecdk create <폴더> --template <이름>`
35
+ };
36
+ }
37
+ async function run(args, deps = {}) {
11
38
  const r = await createProject({
12
39
  dir: args.target,
13
40
  template: args.template,
14
- theme: args.theme
41
+ theme: args.theme,
42
+ localPackages: process.env[LOCAL_PACKAGES_ENV] || undefined
15
43
  });
44
+ const installed = args.install === false ? null : await (deps.install ?? npmInstall)(r.dir);
45
+ const failed = installed !== null && !installed.ok;
46
+ const cd = `cd ${args.target}`;
47
+ if (args.json) return {
48
+ exitCode: failed ? 1 : 0,
49
+ output: JSON.stringify({
50
+ ...r,
51
+ install: installed ?? 'skipped',
52
+ ...(installed?.ok === true ? {} : {
53
+ next: `${cd} && ${INSTALL_COMMAND}`
54
+ })
55
+ }, null, 2)
56
+ };
57
+ const head = `[ok] ${r.dir} (${r.template}@${r.version} 템플릿${r.theme === 'dark' ? ' · 어두운 테마' : ''}, 파일 ${r.files.length}개)`;
58
+ if (failed) return {
59
+ exitCode: 1,
60
+ output: `${head}\n\n[fail] ${INSTALL_COMMAND} 실패 (${installed.error ?? '-'}). 프로젝트는 그대로 두었습니다.\n위 npm 출력과 네트워크 · 사내 프록시를 확인한 뒤 다시 실행해 주세요:\n\n ${cd}\n ${INSTALL_COMMAND}\n ecdk build`
61
+ };
62
+ // 고칠 화면 코드: 템플릿에 있는 screens/*.js (blank는 완료 정책 화면 screens/completion.js까지)
63
+ const screens = ['learn', 'instructor', 'edit', 'completion'].map(s => `screens/${s}.js`).filter(f => r.files.includes(f));
16
64
  return {
17
65
  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`
66
+ output: `${head}\n\n고칠 파일: ${[...screens, 'styles.css'].join(' · ')}\n내용 · 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다 (기본 내용 없음, ecdk dev 내용 편집은 로컬 견본).\n\n ${cd}\n${installed ? '' : ` ${INSTALL_COMMAND}\n`} ecdk doctor\n ecdk build`
19
67
  };
20
68
  }
21
69
 
22
- export { run, usage };
70
+ export { list, run, usage };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 저장소에서 시험할 때: 배포 전 SDK를 npm 레지스트리 대신 이 폴더의 패키지 파일(.tgz)에서 설치한다.
3
+ * 저장소 루트에서 `pnpm build && pnpm pack:local`로 만든 `.local-packages/`를 가리킨다.
4
+ */
5
+ export declare const LOCAL_PACKAGES_ENV = "ECDK_LOCAL_PACKAGES";
6
+ /** 폴더의 SDK .tgz로 package.json 값(file:)을 만든다. 여럿이면 가장 높은 버전. 폴더를 주지 않으면 undefined */
7
+ export declare function localSdkSpec(dir: string | undefined): Promise<string | undefined>;
8
+ export interface InstallResult {
9
+ ok: boolean;
10
+ /** 실패 이유 (종료 코드 · 실행 못 함) */
11
+ error?: string | undefined;
12
+ }
13
+ /**
14
+ * 프로젝트 폴더에서 npm install. npm 출력은 stderr로 보낸다 (--json 출력에 섞이지 않게).
15
+ * Windows의 npm은 npm.cmd라 셸로 실행한다
16
+ */
17
+ export declare function npmInstall(dir: string): Promise<InstallResult>;
@@ -0,0 +1,53 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { readdir } from 'node:fs/promises';
3
+ import { resolve, join } from 'node:path';
4
+ import { INSTALL_COMMAND, SDK_PACKAGE } from '../../core/sdk.js';
5
+ import { compareVersions } from '../../rules/semver.js';
6
+
7
+ /**
8
+ * 저장소에서 시험할 때: 배포 전 SDK를 npm 레지스트리 대신 이 폴더의 패키지 파일(.tgz)에서 설치한다.
9
+ * 저장소 루트에서 `pnpm build && pnpm pack:local`로 만든 `.local-packages/`를 가리킨다.
10
+ */
11
+ const LOCAL_PACKAGES_ENV = 'ECDK_LOCAL_PACKAGES';
12
+ /** pnpm pack이 만드는 이름: @eliceio/cdk → eliceio-cdk-1.0.0.tgz */
13
+ const SDK_TARBALL = /^eliceio-cdk-(\d[^/]*)\.tgz$/;
14
+ /** 폴더의 SDK .tgz로 package.json 값(file:)을 만든다. 여럿이면 가장 높은 버전. 폴더를 주지 않으면 undefined */
15
+ async function localSdkSpec(dir) {
16
+ if (!dir) return undefined;
17
+ const abs = resolve(dir);
18
+ const names = await readdir(abs).catch(() => {
19
+ throw new Error(`${LOCAL_PACKAGES_ENV} 폴더가 없습니다: ${abs}`);
20
+ });
21
+ const found = names.map(n => ({
22
+ n,
23
+ v: SDK_TARBALL.exec(n)?.[1]
24
+ })).filter(x => x.v !== undefined).sort((a, b) => compareVersions(b.v, a.v) ?? 0)[0];
25
+ if (!found) throw new Error(`${LOCAL_PACKAGES_ENV} 폴더에 ${SDK_PACKAGE} 패키지 파일(.tgz)이 없습니다: ${abs}. 저장소 루트에서 pnpm build && pnpm pack:local로 만들어 주세요.`);
26
+ return `file:${join(abs, found.n)}`;
27
+ }
28
+ /**
29
+ * 프로젝트 폴더에서 npm install. npm 출력은 stderr로 보낸다 (--json 출력에 섞이지 않게).
30
+ * Windows의 npm은 npm.cmd라 셸로 실행한다
31
+ */
32
+ function npmInstall(dir) {
33
+ return new Promise(done => {
34
+ const [cmd = 'npm', ...args] = INSTALL_COMMAND.split(' ');
35
+ const child = spawn(cmd, args, {
36
+ cwd: dir,
37
+ stdio: ['ignore', process.stderr, process.stderr],
38
+ shell: process.platform === 'win32'
39
+ });
40
+ child.on('error', e => done({
41
+ ok: false,
42
+ error: e.message
43
+ }));
44
+ child.on('close', code => done(code === 0 ? {
45
+ ok: true
46
+ } : {
47
+ ok: false,
48
+ error: `종료 코드 ${code ?? '-'}`
49
+ }));
50
+ });
51
+ }
52
+
53
+ export { LOCAL_PACKAGES_ENV, localSdkSpec, npmInstall };
@@ -10,15 +10,20 @@ export interface CreateOptions {
10
10
  theme?: ThemeName;
11
11
  /** 기본: 폴더 이름 */
12
12
  name?: string;
13
+ /** SDK 패키지 파일(.tgz) 폴더 (저장소 시험용, create 명령은 환경 변수 ECDK_LOCAL_PACKAGES). 없으면 npm 레지스트리 */
14
+ localPackages?: string | undefined;
13
15
  }
14
16
  export interface CreateResult {
15
17
  dir: string;
16
18
  template: TemplateName;
19
+ /** 만든 템플릿의 버전 (templates/<이름>/template.json) */
20
+ version: string;
17
21
  theme: ThemeName;
18
22
  files: string[];
19
23
  }
20
24
  /**
21
- * 템플릿(화면 3개 + 내용 + 설정)과 공통 lib/(키트, @eliceio/cdk 묶음, 기본 스타일)를 새 폴더에 복사한다.
25
+ * 템플릿(화면 · metadata.json · package.json)과 공통 lib/(화면 키트 · 기본 스타일 · 로컬 mock)를 새 폴더에 복사한다.
26
+ * SDK(@eliceio/cdk)는 package.json 의존성이라 복사하지 않는다 (설치는 create 명령이 npm install로, build가 zip lib/cdk.js로 넣음).
22
27
  * 비어 있지 않은 폴더에는 만들지 않는다 (덮어쓰기 방지).
23
28
  */
24
29
  export declare function createProject(options: CreateOptions): Promise<CreateResult>;