@eliceio/cdk-cli 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (120) hide show
  1. package/README.md +288 -200
  2. package/es/cli.js +70 -66
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +27 -15
  5. package/es/commands/create/index.d.ts +5 -1
  6. package/es/commands/create/index.js +34 -15
  7. package/es/commands/create/install.d.ts +17 -0
  8. package/es/commands/create/install.js +53 -0
  9. package/es/commands/create/scaffold.d.ts +4 -1
  10. package/es/commands/create/scaffold.js +19 -13
  11. package/es/commands/dev/index.d.ts +1 -1
  12. package/es/commands/dev/index.js +5 -5
  13. package/es/commands/doctor/index.d.ts +29 -2
  14. package/es/commands/doctor/index.js +253 -55
  15. package/es/commands/mcp/index.d.ts +0 -12
  16. package/es/commands/mcp/index.js +6 -57
  17. package/es/commands/setup/index.d.ts +11 -3
  18. package/es/commands/setup/index.js +112 -37
  19. package/es/commands/skill/index.d.ts +46 -8
  20. package/es/commands/skill/index.js +151 -35
  21. package/es/commands/uninstall/index.d.ts +54 -0
  22. package/es/commands/uninstall/index.js +304 -0
  23. package/es/commands/update/index.d.ts +59 -0
  24. package/es/commands/update/index.js +251 -0
  25. package/es/commands/validate/index.d.ts +18 -0
  26. package/es/commands/{check → validate}/index.js +16 -10
  27. package/es/core/collect.d.ts +5 -2
  28. package/es/core/config.d.ts +99 -50
  29. package/es/core/config.js +244 -91
  30. package/es/core/latest.d.ts +21 -0
  31. package/es/core/latest.js +43 -0
  32. package/es/core/manifest.d.ts +2 -1
  33. package/es/core/manifest.js +2 -1
  34. package/es/core/minify.js +2 -2
  35. package/es/core/prepare.d.ts +18 -2
  36. package/es/core/prepare.js +48 -16
  37. package/es/core/project-check.d.ts +19 -8
  38. package/es/core/project-check.js +36 -9
  39. package/es/core/sandbox.js +2 -2
  40. package/es/core/sdk.d.ts +39 -0
  41. package/es/core/sdk.js +95 -0
  42. package/es/core/templates.d.ts +2 -4
  43. package/es/core/templates.js +2 -5
  44. package/es/dev/grading.d.ts +7 -8
  45. package/es/dev/grading.js +6 -16
  46. package/es/dev/host-page.d.ts +1 -1
  47. package/es/dev/host-page.js +12 -10
  48. package/es/dev/mock-api.d.ts +13 -18
  49. package/es/dev/mock-api.js +56 -66
  50. package/es/dev/server.js +52 -52
  51. package/es/rules/check.js +43 -31
  52. package/es/rules/index.d.ts +1 -1
  53. package/es/rules/index.js +1 -1
  54. package/es/rules/manifest.d.ts +28 -20
  55. package/es/rules/manifest.js +58 -55
  56. package/es/rules/types.d.ts +18 -20
  57. package/es/rules.json.js +2 -2
  58. package/es/test-packages.d.ts +7 -0
  59. package/package.json +3 -4
  60. package/rules.json +27 -43
  61. package/skills/_shared/always.md +4 -4
  62. package/skills/elice-content-check/SKILL.md +11 -8
  63. package/skills/elice-content-create/SKILL.md +8 -7
  64. package/skills/elice-content-guide/SKILL.md +42 -0
  65. package/skills/elice-content-guide/topics/00-what-the-person-decides.md +11 -0
  66. package/skills/elice-content-guide/topics/01-check-the-environment.md +10 -0
  67. package/skills/elice-content-guide/topics/02-design-the-material.md +35 -0
  68. package/skills/elice-content-guide/topics/03-create-the-project.md +22 -0
  69. package/skills/elice-content-guide/topics/04-rules.md +12 -0
  70. package/skills/elice-content-guide/topics/05-screen-code.md +101 -0
  71. package/skills/elice-content-guide/topics/06-using-the-quiz-template.md +22 -0
  72. package/skills/elice-content-guide/topics/07-move-existing-html.md +10 -0
  73. package/skills/elice-content-guide/topics/08-fix-check-errors.md +24 -0
  74. package/skills/elice-content-guide/topics/09-check.md +10 -0
  75. package/skills/elice-content-guide/topics/10-build.md +8 -0
  76. package/skills/elice-content-guide/topics/11-more.md +4 -0
  77. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +41 -0
  78. package/skills/elice-content-migrate/SKILL.md +8 -7
  79. package/skills/elice-content-publish/SKILL.md +8 -7
  80. package/templates/_shared/lib/cdk-mock.d.ts +5 -13
  81. package/templates/_shared/lib/cdk-mock.js +49 -144
  82. package/templates/_shared/lib/elice-content.css +68 -1
  83. package/templates/_shared/lib/elice-content.d.ts +11 -38
  84. package/templates/_shared/lib/elice-content.js +43 -248
  85. package/templates/blank/README.md +12 -10
  86. package/templates/blank/metadata.json +9 -0
  87. package/templates/blank/package.json +13 -0
  88. package/templates/blank/screens/edit.js +1 -1
  89. package/templates/blank/screens/instructor.js +12 -5
  90. package/templates/blank/screens/learn.js +16 -11
  91. package/templates/blank/template.json +2 -2
  92. package/templates/quiz/README.md +15 -12
  93. package/templates/quiz/core/behaviors.js +4 -1
  94. package/templates/quiz/core/editor.d.ts +21 -10
  95. package/templates/quiz/core/editor.js +44 -31
  96. package/templates/quiz/core/model.d.ts +14 -0
  97. package/templates/quiz/core/model.js +76 -4
  98. package/templates/quiz/metadata.json +9 -0
  99. package/templates/quiz/package.json +13 -0
  100. package/templates/quiz/screens/edit.js +101 -34
  101. package/templates/quiz/screens/instructor.js +18 -12
  102. package/templates/quiz/screens/learn.js +45 -36
  103. package/templates/quiz/styles.css +65 -22
  104. package/templates/quiz/template.json +2 -2
  105. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  106. package/templates/quiz/ui/templates/edit.js +65 -19
  107. package/templates/quiz/ui/templates/group.js +10 -2
  108. package/templates/quiz/ui/texts.js +11 -11
  109. package/es/commands/check/index.d.ts +0 -15
  110. package/es/commands/guide/index.d.ts +0 -29
  111. package/es/commands/guide/index.js +0 -120
  112. package/guides/content-development.md +0 -294
  113. package/templates/_shared/lib/cdk.js +0 -3
  114. package/templates/blank/completion.html +0 -15
  115. package/templates/blank/content.json +0 -4
  116. package/templates/blank/elice.config.json +0 -10
  117. package/templates/blank/screens/completion.js +0 -7
  118. package/templates/quiz/content.json +0 -35
  119. package/templates/quiz/elice.config.json +0 -9
  120. package/templates/quiz/grading.json +0 -4
package/es/cli.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { parseArgs } from 'node:util';
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';
2
+ import { usage as usage$6, run as run$6 } from './commands/build/index.js';
3
+ import { usage as usage$5, list, run as run$5 } from './commands/create/index.js';
4
+ import { usage as usage$4, run as run$4 } from './commands/dev/index.js';
5
+ import { usage as usage$3, run as run$3 } from './commands/doctor/index.js';
6
+ import { usage as usage$2, run as run$2 } from './commands/setup/index.js';
7
+ import { usage, run } from './commands/uninstall/index.js';
8
+ import { usage as usage$1, run as run$1 } from './commands/update/index.js';
9
+ import { usage as usage$7, run as run$7 } from './commands/validate/index.js';
11
10
  import 'fflate';
12
11
  import { RULES_VERSION } from './rules/spec.js';
13
12
  import { VERSION } from './version.js';
@@ -15,15 +14,15 @@ import { VERSION } from './version.js';
15
14
  const help = `ecdk ${VERSION} · Elice CDK CLI (Custom HTML 콘텐츠 도구)
16
15
 
17
16
  명령:
18
- create <폴더> 새 프로젝트 (--template quiz|blank, --theme light|dark, --list로 템플릿 목록)
19
- check [경로] 업로드 전 검사 (서버와 같은 규칙)
20
- build [폴더] 정답·비밀 제외 → 검사 → content.zip
21
- dev [폴더] 운영과 같은 조건의 로컬 서버 (--port)
22
- doctor [폴더] 환경·프로젝트 점검 (--fix)
23
- guide [주제] 에이전트용 개발 가이드 (주제 목록 · 한 절 · all)
24
- setup 처음 한 번: 스킬 설치 + 학습자료 서버 MCP 등록 + 점검 (--env prod|qa5, --dry-run)
25
- skill install Claude Code 스킬 설치 (--project, --force)
26
- mcp setup 학습자료 서버 MCP 등록 (--target, --env prod|qa5, --url, --dry-run)
17
+ create <폴더> 새 프로젝트 + npm install (--template quiz|blank, --theme light|dark, --no-install, --list로 템플릿 목록)
18
+ validate [경로] 업로드 전 검사 (서버와 같은 규칙)
19
+ build [폴더] 정답·비밀 제외 → 검사 → content.zip
20
+ dev [폴더] 운영과 같은 조건의 로컬 서버 (--port)
21
+ doctor [폴더] 환경·프로젝트 점검 (--fix)
22
+ setup 처음 한 번: 스킬 설치 + 학습자료 서버 MCP 등록 + 점검 (--env prod|qa5, --dry-run)
23
+ --only skills: 스킬만 (--project, --force) · --only mcp: MCP 등록만 (--target, --url)
24
+ update npm latest로 올리기: CLI · 스킬 · 프로젝트 SDK (--check로 확인만, --yes)
25
+ uninstall setup이 설치한 스킬 · MCP 등록 지우기 (--project, --target, --dry-run, --force)
27
26
 
28
27
  공통 옵션: --json, --help, --version`;
29
28
  const usageError = (message, usage) => ({
@@ -74,6 +73,9 @@ async function main(argv) {
74
73
  url: {
75
74
  type: 'string'
76
75
  },
76
+ only: {
77
+ type: 'string'
78
+ },
77
79
  'dry-run': {
78
80
  type: 'boolean',
79
81
  default: false
@@ -82,6 +84,19 @@ async function main(argv) {
82
84
  type: 'boolean',
83
85
  default: false
84
86
  },
87
+ 'no-install': {
88
+ type: 'boolean',
89
+ default: false
90
+ },
91
+ check: {
92
+ type: 'boolean',
93
+ default: false
94
+ },
95
+ yes: {
96
+ type: 'boolean',
97
+ short: 'y',
98
+ default: false
99
+ },
85
100
  help: {
86
101
  type: 'boolean',
87
102
  short: 'h',
@@ -111,68 +126,69 @@ async function main(argv) {
111
126
  output: help
112
127
  };
113
128
  switch (cmd) {
114
- case 'check':
129
+ case 'validate':
115
130
  {
116
131
  if (values.help) return {
117
132
  exitCode: 0,
118
- output: usage$8
133
+ output: usage$7
119
134
  };
120
- if (rest.length > 1) return usageError('경로는 하나만 줄 수 있습니다.', usage$8);
135
+ if (rest.length > 1) return usageError('경로는 하나만 줄 수 있습니다.', usage$7);
121
136
  try {
122
- return await run$8({
137
+ return await run$7({
123
138
  target: rest[0] ?? '.',
124
139
  json: values.json
125
140
  });
126
141
  } catch (e) {
127
142
  const message = e.code === 'ENOENT' ? `경로가 없습니다: ${rest[0] ?? '.'}` : e.message;
128
- return usageError(message, usage$8);
143
+ return usageError(message, usage$7);
129
144
  }
130
145
  }
131
146
  case 'build':
132
147
  {
133
148
  if (values.help) return {
134
149
  exitCode: 0,
135
- output: usage$7
150
+ output: usage$6
136
151
  };
137
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$7);
152
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$6);
138
153
  try {
139
- return await run$7({
154
+ return await run$6({
140
155
  target: rest[0] ?? '.',
141
156
  json: values.json
142
157
  });
143
158
  } catch (e) {
144
159
  const message = e.code === 'ENOENT' ? `폴더가 없습니다: ${rest[0] ?? '.'}` : e.message;
145
- return usageError(message, usage$7);
160
+ return usageError(message, usage$6);
146
161
  }
147
162
  }
148
163
  case 'create':
149
164
  {
150
165
  if (values.help) return {
151
166
  exitCode: 0,
152
- output: usage$6
167
+ output: usage$5
153
168
  };
154
169
  if (values.list) return list(values.json);
155
- if (rest.length !== 1) return usageError('만들 폴더를 하나 적어 주세요.', usage$6);
170
+ if (rest.length !== 1) return usageError('만들 폴더를 하나 적어 주세요.', usage$5);
156
171
  try {
157
- return await run$6({
172
+ return await run$5({
158
173
  target: rest[0] ?? '',
159
174
  template: values.template ?? 'quiz',
160
175
  theme: values.theme ?? 'light',
176
+ install: !values['no-install'],
161
177
  json: values.json
162
178
  });
163
179
  } catch (e) {
164
- return usageError(e.message, usage$6);
180
+ return usageError(e.message, usage$5);
165
181
  }
166
182
  }
167
183
  case 'dev':
168
184
  {
169
185
  if (values.help) return {
170
186
  exitCode: 0,
171
- output: usage$5
187
+ output: usage$4
172
188
  };
173
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$5);
189
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$4);
174
190
  try {
175
- return await run$5({
191
+ return await run$4({
176
192
  target: rest[0] ?? '.',
177
193
  ...(values.port === undefined ? {} : {
178
194
  port: values.port
@@ -181,83 +197,71 @@ async function main(argv) {
181
197
  } catch (e) {
182
198
  const err = e;
183
199
  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;
184
- return usageError(message, usage$5);
200
+ return usageError(message, usage$4);
185
201
  }
186
202
  }
187
203
  case 'doctor':
188
204
  {
189
205
  if (values.help) return {
190
206
  exitCode: 0,
191
- output: usage$4
207
+ output: usage$3
192
208
  };
193
- if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$4);
194
- return run$4({
209
+ if (rest.length > 1) return usageError('프로젝트 폴더는 하나만 줄 수 있습니다.', usage$3);
210
+ return run$3({
195
211
  target: rest[0] ?? '.',
196
212
  json: values.json,
197
213
  fix: values.fix
198
214
  });
199
215
  }
200
- case 'guide':
201
- {
202
- if (values.help) return {
203
- exitCode: 0,
204
- output: usage$3
205
- };
206
- if (rest.length > 1) return usageError('주제는 하나만 줄 수 있습니다.', usage$3);
207
- return run$3({
208
- topic: rest[0],
209
- json: values.json
210
- });
211
- }
212
- case 'skill':
216
+ case 'setup':
213
217
  {
214
218
  if (values.help) return {
215
219
  exitCode: 0,
216
220
  output: usage$2
217
221
  };
218
- if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: install', usage$2);
222
+ if (rest.length > 0) return usageError('setup은 인자를 받지 않습니다.', usage$2);
219
223
  return run$2({
220
- sub: rest[0],
224
+ only: values.only,
221
225
  project: values.project,
226
+ target: values.target,
227
+ envName: values.env,
228
+ url: values.url,
229
+ dryRun: values['dry-run'],
222
230
  force: values.force,
223
231
  json: values.json
224
232
  });
225
233
  }
226
- case 'setup':
234
+ case 'update':
227
235
  {
228
236
  if (values.help) return {
229
237
  exitCode: 0,
230
238
  output: usage$1
231
239
  };
232
- if (rest.length > 0) return usageError('setup은 인자를 받지 않습니다.', usage$1);
240
+ if (rest.length > 0) return usageError('update는 인자를 받지 않습니다.', usage$1);
241
+ // --yes: 지금은 묻는 단계가 없어 늘 그대로 실행한다 (스크립트가 미리 붙여 둘 수 있게 받기만 함)
233
242
  return run$1({
234
- target: values.target,
235
- envName: values.env,
236
- url: values.url,
237
- dryRun: values['dry-run'],
238
- force: values.force,
243
+ check: values.check,
239
244
  json: values.json
240
245
  });
241
246
  }
242
- case 'mcp':
247
+ case 'uninstall':
243
248
  {
244
249
  if (values.help) return {
245
250
  exitCode: 0,
246
251
  output: usage
247
252
  };
248
- if (rest.length !== 1) return usageError('하위 명령을 하나 적어 주세요: setup', usage);
253
+ if (rest.length > 0) return usageError('uninstall은 인자를 받지 않습니다.', usage);
249
254
  return run({
250
- sub: rest[0],
255
+ project: values.project,
251
256
  target: values.target,
252
- envName: values.env,
253
- url: values.url,
254
257
  dryRun: values['dry-run'],
255
258
  force: values.force,
256
259
  json: values.json
257
260
  });
258
261
  }
259
262
  default:
260
- return usageError(`알 수 없는 명령: ${cmd}`, help);
263
+ // 옛 템플릿의 npm run check가 부르는 이름: 별칭은 두지 않고 고치는 길만 알린다 (G162)
264
+ return usageError(cmd === 'check' ? '알 수 없는 명령: check (ecdk validate로 바뀌었습니다. package.json scripts는 ecdk doctor --fix가 고칩니다)' : `알 수 없는 명령: ${cmd}`, help);
261
265
  }
262
266
  }
263
267
 
@@ -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). \uCC44\uC810 \uBC29\uC2DD \u00B7 \uC815\uB2F5(grading.json)\uC740 \uB123\uC9C0 \uC54A\uB294\uB2E4 (\uC6B4\uC601\uC740 \uD3B8\uC9D1 \uD654\uBA74\uC774 \uC815\uD568), \uB85C\uCEEC \uC644\uB8CC \uC815\uCC45(.ecdk/completion.json)\uB3C4 \uBE60\uC9C4\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,6 +1,6 @@
1
1
  import { rm, mkdir, writeFile } from 'node:fs/promises';
2
2
  import { join, dirname, relative } from 'node:path';
3
- import { loadConfig, loadGradingFile, legacyGradingTypesWarning, CONFIG_FILE } from '../../core/config.js';
3
+ import { loadConfig, legacyGradingTypesWarning, CONFIG_FILE, legacyCompletionWarning } 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';
@@ -8,18 +8,19 @@ import { projectCheckOptions } from '../../core/project-check.js';
8
8
  import { inlineModuleScripts } from '../../core/sandbox.js';
9
9
  import { createZip } from '../../core/zip.js';
10
10
  import { checkFiles } from '../../rules/check.js';
11
+ import { stripCompletionPolicy } from '../../rules/manifest.js';
11
12
  import { rules } from '../../rules/spec.js';
12
13
  import { findUnreferenced } from '../../rules/unused.js';
13
14
  import 'fflate';
14
- import { formatIssues } from '../check/index.js';
15
+ import { formatIssues } from '../validate/index.js';
15
16
 
16
17
  const usage = `사용법: ecdk build [프로젝트 폴더] [--json]
17
18
 
18
- elice.config.json의 root(기본 .)를 모아 정답·비밀·프로젝트 파일을 빼고,
19
- screens 설정으로 metadata.json을 만든 뒤, 검사를 통과하면 <outDir>/content.zip을 만든다
20
- (outDir 기본 dist). 채점 방식 · 정답(grading.json)은 넣지 않는다 (운영은 편집 화면이 정함), 로컬 완료 정책(.ecdk/completion.json)도 빠진다.
21
- 원본 최상위 commentary.txt(학습 참고 내용)가 있으면 zip에 넣고 metadata.json commentary에 적는다.
22
- 설정에 "minify": true면 JS · CSS · JSON을 줄여서 넣는다 (검사는 줄이기 전 원본으로),
19
+ package.json "ecdk"의 root(기본 .)를 모아 정답·비밀·프로젝트 파일을 빼고,
20
+ 원본의 metadata.json(화면 · 완료 정책 · 학습 참고 내용)에 build를 채운 뒤, 검사를 통과하면 <outDir>/content.zip을 만든다
21
+ (outDir 기본 dist). 정답은 편집 화면이 정하므로 zip에 없고, ecdk dev가 저장한 .ecdk/(settings · 완료 정책)도 빠진다.
22
+ 옛 elice.config.json이 남아 있으면 지금처럼 빌드하고 옮기는 법을 경고한다 (ecdk doctor --fix).
23
+ package.json "ecdk"에 "minify": true면 JS · CSS · JSON을 줄여서 넣는다 (검사는 줄이기 전 원본으로),
23
24
  "sourcemap": true면 줄인 파일의 .map도 넣는다. metadata.json build에 버전과 내용 지문(digest)을 적는다.
24
25
  LXP는 자료를 sandbox(origin null)에서 열어 모듈 스크립트 파일 · fetch가 막히므로,
25
26
  HTML의 <script type="module" src>를 묶어 HTML 안에 넣고 zip 안 JSON도 페이지에 넣는다.
@@ -51,11 +52,9 @@ async function build(projectDir) {
51
52
  digest
52
53
  });
53
54
  const zip = createZip(files);
54
- // 프로젝트 검사: grading.json(로컬 채점 설정, zip에는 없음)도 완료 정책과 맞춰 본다. 형식이 틀리면 사용 오류
55
- const grading = config.kind === 'description' ? undefined : await loadGradingFile(projectDir);
56
- const check = checkFiles(sources, projectCheckOptions(config, {
57
- zipBytes: zip.byteLength,
58
- grading
55
+ // 프로젝트 검사: 남은 옛 파일(content.json · grading.json)도 알린다. ecdk dev 상태(.ecdk)는 보지 않는다
56
+ const check = checkFiles(sources, await projectCheckOptions(projectDir, config, {
57
+ zipBytes: zip.byteLength
59
58
  }));
60
59
  // .map을 더했으면 파일 수 한도는 실제 zip으로 다시 본다
61
60
  const realCount = files.filter(f => !f.path.endsWith('/')).length;
@@ -75,6 +74,14 @@ async function build(projectDir) {
75
74
  message: legacy,
76
75
  path: CONFIG_FILE
77
76
  });
77
+ // 옛 elice.config.json 완료 정책: 옮기지 않는다 (완료 정책은 LXP 설정, ADR 0012)
78
+ const legacyCompletion = legacyCompletionWarning(config);
79
+ if (legacyCompletion) check.issues.push({
80
+ id: 'manifest.completion-policies-ignored',
81
+ level: 'warn',
82
+ message: legacyCompletion,
83
+ path: CONFIG_FILE
84
+ });
78
85
  // 산출물은 <outDir>/content/ 와 <outDir>/content.zip만 건드린다
79
86
  const contentDir = join(outDir, 'content');
80
87
  const zipPath = join(outDir, 'content.zip');
@@ -109,7 +116,11 @@ async function build(projectDir) {
109
116
  check
110
117
  };
111
118
  }
112
- /** metadata.json(원본에 직접 쓴 것 포함)의 build에 값을 더한다. 형식이 틀리면 그대로 두고 검사가 알려 준다 */
119
+ /**
120
+ * metadata.json(원본에 직접 쓴 것 포함)의 build에 값을 더한다. 옛 완료 정책 필드 · 화면은 zip에서 뺀다 (완료 정책은
121
+ * LXP 설정, ADR 0012. 원본에 남은 것은 검사가 manifest.completion-policies-ignored로 알림). 형식이 틀리면 그대로 두고
122
+ * 검사가 알려 준다
123
+ */
113
124
  function withBuildStamp(files, stamp) {
114
125
  return files.map(f => {
115
126
  if (f.path !== rules.manifest.file) return f;
@@ -117,7 +128,7 @@ function withBuildStamp(files, stamp) {
117
128
  const raw = JSON.parse(new TextDecoder().decode(f.data));
118
129
  if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return f;
119
130
  const next = {
120
- ...raw,
131
+ ...stripCompletionPolicy(raw),
121
132
  build: {
122
133
  ...raw.build,
123
134
  ...stamp
@@ -138,7 +149,8 @@ const REASON = {
138
149
  junk: 'OS 파일',
139
150
  project: '프로젝트 파일',
140
151
  link: '심볼릭 링크 · 특수 파일: 따라가지 않음. 실제 파일로 복사해 넣어 주세요',
141
- config: '설정 exclude'
152
+ config: '설정 exclude',
153
+ sdk: '옛 lib/cdk.js 복사본: 설치된 @eliceio/cdk를 대신 넣음. 지워도 됩니다'
142
154
  };
143
155
  function formatText(projectDir, r) {
144
156
  const lines = [];
@@ -1,10 +1,14 @@
1
+ import { type InstallResult } from './install.js';
1
2
  import type { CommandResult } from '../../types.js';
2
3
  export declare const usage: string;
3
- /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 · 완료 정책 */
4
+ /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 (완료 정책은 LXP 설정이라 없음, ADR 0012) */
4
5
  export declare function list(json: boolean): CommandResult;
5
6
  export declare function run(args: {
6
7
  target: string;
7
8
  template: string;
8
9
  theme: string;
10
+ install?: boolean;
9
11
  json: boolean;
12
+ }, deps?: {
13
+ install?: (dir: string) => Promise<InstallResult>;
10
14
  }): Promise<CommandResult>;
@@ -1,17 +1,21 @@
1
+ import { INSTALL_COMMAND } from '../../core/sdk.js';
1
2
  import { listTemplates } from '../../core/templates.js';
3
+ import { LOCAL_PACKAGES_ENV, npmInstall } from './install.js';
2
4
  import { TEMPLATES, THEMES, createProject } from './scaffold.js';
3
5
 
4
- 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]
5
7
  ecdk create --list [--json]
6
8
 
7
- 학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면과 SDK 연결 로직(lib/)이 든 프로젝트를 만든다.
8
- quiz: 여러 문항 퀴즈(선택 · 순서 · 주관식 · 그룹 분류, 편집 화면 포함, 기본)
9
+ 학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면, 화면 키트(lib/), metadata.json, package.json이 든 프로젝트를 만들고
10
+ npm install을 실행한다. SDK(@eliceio/cdk)는 package.json 의존성이다 (node_modules에 설치, 네트워크 필요).
11
+ quiz: 한 문항 퀴즈(여러 문항은 페이지를 여러 개로, 선택 · 순서 · 주관식 · 그룹 분류, 편집 화면 포함, 기본)
9
12
  blank: 퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 화면 3개 골격
10
13
  --list: 템플릿 목록과 버전 · 설명 (템플릿마다 버전이 따로 있음)
11
14
  --theme dark: Elice Design System 어두운 화면 (기본 light)
15
+ --no-install: npm install을 하지 않는다 (나중에 프로젝트 폴더에서 npm install)
12
16
 
13
- 종료 코드: 0 성공 · 2 잘못된 사용 (비어 있지 않은 폴더 포함)`;
14
- /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 · 완료 정책 */
17
+ 종료 코드: 0 성공 · 1 npm install 실패 (프로젝트는 만들어 둠) · 2 잘못된 사용 (비어 있지 않은 폴더 포함)`;
18
+ /** ecdk create --list: 템플릿 이름 · 버전 · 설명 · 화면 (완료 정책은 LXP 설정이라 없음, ADR 0012) */
15
19
  function list(json) {
16
20
  const templates = listTemplates();
17
21
  if (json) return {
@@ -20,27 +24,42 @@ function list(json) {
20
24
  templates
21
25
  }, null, 2)
22
26
  };
23
- const lines = templates.map(t => {
24
- const p = t.completionPolicies ?? [];
25
- const completion = p.length === 0 ? '-' : p.length === 1 ? `${p[0]} 고정` : `${p.join(' · ')} (기본 ${p[0]}, 완료 정책 화면에서 고름)`;
26
- return `${t.name}@${t.version} ${t.title}\n ${t.description}\n 화면: ${t.screens.join(' · ')} · 완료 정책: ${completion}`;
27
- });
27
+ const lines = templates.map(t => `${t.name}@${t.version} ${t.title}\n ${t.description}\n 화면: ${t.screens.join(' · ')}`);
28
28
  return {
29
29
  exitCode: 0,
30
30
  output: `${lines.join('\n\n')}\n\n만들기: ecdk create <폴더> --template <이름>`
31
31
  };
32
32
  }
33
- async function run(args) {
33
+ async function run(args, deps = {}) {
34
34
  const r = await createProject({
35
35
  dir: args.target,
36
36
  template: args.template,
37
- theme: args.theme
37
+ theme: args.theme,
38
+ localPackages: process.env[LOCAL_PACKAGES_ENV] || undefined
38
39
  });
39
- // 고칠 화면 코드: 템플릿에 있는 screens/*.js (blank는 완료 정책 화면 screens/completion.js까지)
40
- const screens = ['learn', 'instructor', 'edit', 'completion'].map(s => `screens/${s}.js`).filter(f => r.files.includes(f));
40
+ const installed = args.install === false ? null : await (deps.install ?? npmInstall)(r.dir);
41
+ const failed = installed !== null && !installed.ok;
42
+ const cd = `cd ${args.target}`;
43
+ if (args.json) return {
44
+ exitCode: failed ? 1 : 0,
45
+ output: JSON.stringify({
46
+ ...r,
47
+ install: installed ?? 'skipped',
48
+ ...(installed?.ok === true ? {} : {
49
+ next: `${cd} && ${INSTALL_COMMAND}`
50
+ })
51
+ }, null, 2)
52
+ };
53
+ const head = `[ok] ${r.dir} (${r.template}@${r.version} 템플릿${r.theme === 'dark' ? ' · 어두운 테마' : ''}, 파일 ${r.files.length}개)`;
54
+ if (failed) return {
55
+ exitCode: 1,
56
+ output: `${head}\n\n[fail] ${INSTALL_COMMAND} 실패 (${installed.error ?? '-'}). 프로젝트는 그대로 두었습니다.\n위 npm 출력과 네트워크 · 사내 프록시를 확인한 뒤 다시 실행해 주세요:\n\n ${cd}\n ${INSTALL_COMMAND}\n ecdk build`
57
+ };
58
+ // 고칠 화면 코드: 템플릿에 있는 screens/*.js
59
+ const screens = ['learn', 'instructor', 'edit'].map(s => `screens/${s}.js`).filter(f => r.files.includes(f));
41
60
  return {
42
61
  exitCode: 0,
43
- output: args.json ? JSON.stringify(r, null, 2) : `[ok] ${r.dir} (${r.template}@${r.version} 템플릿${r.theme === 'dark' ? ' · 어두운 테마' : ''}, 파일 ${r.files.length}개)\n\n고칠 파일: ${[...screens, 'content.json', 'styles.css'].join(' · ')}\n\n cd ${args.target}\n ecdk doctor\n ecdk build`
62
+ output: `${head}\n\n고칠 파일: ${[...screens, 'styles.css'].join(' · ')}\n내용 · 정답은 LXP에 올린 뒤 편집 화면에서 입력하고, 완료 정책은 LXP 설정 탭에서 교육자가 고릅니다 (기본 내용 없음, ecdk dev 내용 편집은 로컬 견본).\n\n ${cd}\n${installed ? '' : ` ${INSTALL_COMMAND}\n`} ecdk doctor\n ecdk build`
44
63
  };
45
64
  }
46
65
 
@@ -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,6 +10,8 @@ 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;
@@ -20,7 +22,8 @@ export interface CreateResult {
20
22
  files: string[];
21
23
  }
22
24
  /**
23
- * 템플릿(화면 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로 넣음).
24
27
  * 비어 있지 않은 폴더에는 만들지 않는다 (덮어쓰기 방지).
25
28
  */
26
29
  export declare function createProject(options: CreateOptions): Promise<CreateResult>;
@@ -1,7 +1,9 @@
1
1
  import { readdir, mkdir, cp, rm, rename, readFile, writeFile } from 'node:fs/promises';
2
2
  import { resolve, join, basename } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ import { SDK_PACKAGE } from '../../core/sdk.js';
4
5
  import { listTemplates } from '../../core/templates.js';
6
+ import { localSdkSpec } from './install.js';
5
7
 
6
8
  const TEMPLATES = ['quiz', 'blank'];
7
9
  /** 화면 테마. dark는 화면 HTML에 data-eds-theme="dark"를 붙여 EDS 어두운 팔레트를 쓴다 */
@@ -19,7 +21,8 @@ async function listFiles(dir, base = '') {
19
21
  return out.sort();
20
22
  }
21
23
  /**
22
- * 템플릿(화면 3개 + 내용 + 설정)과 공통 lib/(키트, @eliceio/cdk 묶음, 기본 스타일)를 새 폴더에 복사한다.
24
+ * 템플릿(화면 · metadata.json · package.json)과 공통 lib/(화면 키트 · 기본 스타일 · 로컬 mock)를 새 폴더에 복사한다.
25
+ * SDK(@eliceio/cdk)는 package.json 의존성이라 복사하지 않는다 (설치는 create 명령이 npm install로, build가 zip lib/cdk.js로 넣음).
23
26
  * 비어 있지 않은 폴더에는 만들지 않는다 (덮어쓰기 방지).
24
27
  */
25
28
  async function createProject(options) {
@@ -55,23 +58,26 @@ async function createProject(options) {
55
58
  await writeFile(path, html.replace(/<html(?![^>]*data-eds-theme)/, '<html data-eds-theme="dark"'));
56
59
  }
57
60
  }
58
- // 어떤 템플릿 · 버전으로 만들었는지 (템플릿마다 따로 올리는 template.json version. build가 metadata.json build.template에 적음)
61
+ // 어떤 템플릿 · 버전으로 만들었는지 (템플릿마다 따로 올리는 template.json version). package.json "ecdk".template에 적고
62
+ // build가 metadata.json build.template으로 옮긴다 (ADR 0011)
59
63
  const version = listTemplates().find(t => t.name === options.template)?.version ?? '0.0.0';
60
- const configPath = join(dir, 'elice.config.json');
61
- const config = JSON.parse(await readFile(configPath, 'utf8'));
62
- await writeFile(configPath, `${JSON.stringify({
63
- template: `${options.template}@${version}`,
64
- ...config
65
- }, null, 2)}\n`);
66
64
  const name = options.name ?? basename(dir);
67
65
  const readme = join(dir, 'README.md');
68
66
  await writeFile(readme, (await readFile(readme, 'utf8')).replaceAll('{{name}}', name));
69
- await writeFile(join(dir, 'package.json'), `${JSON.stringify({
67
+ // package.json: 템플릿 것(스크립트 · SDK 범위 · "ecdk" 빌드 옵션)에 이름과 템플릿 버전("ecdk".template)을 붙인다.
68
+ // 템플릿의 SDK 범위는 저장소 워크스페이스 표기(workspace:^X)라 npm이 아는 범위(^X)로 바꾼다.
69
+ // ECDK_LOCAL_PACKAGES(저장소 시험용)면 SDK를 그 폴더의 패키지 파일(.tgz)로 (배포 전 SDK는 레지스트리에 없음)
70
+ const pkgPath = join(dir, 'package.json');
71
+ const pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
72
+ const localSdk = await localSdkSpec(options.localPackages);
73
+ const dependencies = Object.fromEntries(Object.entries(pkg.dependencies ?? {}).map(([n, range]) => [n, n === SDK_PACKAGE && localSdk ? localSdk : range.replace(/^workspace:/, '')]));
74
+ await writeFile(pkgPath, `${JSON.stringify({
70
75
  name: name.toLowerCase().replace(/[^a-z0-9-_.]+/g, '-'),
71
- private: true,
72
- scripts: {
73
- doctor: 'ecdk doctor',
74
- build: 'ecdk build'
76
+ ...pkg,
77
+ dependencies,
78
+ ecdk: {
79
+ template: `${options.template}@${version}`,
80
+ ...pkg.ecdk
75
81
  }
76
82
  }, null, 2)}\n`);
77
83
  return {