@eliceio/cdk-cli 0.0.0-stage → 0.1.0-alpha.1

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 (128) hide show
  1. package/README.md +511 -2
  2. package/es/bin/index.d.ts +2 -0
  3. package/es/bin/index.js +10 -0
  4. package/es/cli.d.ts +5 -0
  5. package/es/cli.js +171 -0
  6. package/es/commands/build/index.d.ts +27 -0
  7. package/es/commands/build/index.js +154 -0
  8. package/es/commands/check/index.d.ts +9 -0
  9. package/es/commands/check/index.js +31 -0
  10. package/es/commands/create/index.d.ts +8 -0
  11. package/es/commands/create/index.js +22 -0
  12. package/es/commands/create/scaffold.d.ts +24 -0
  13. package/es/commands/create/scaffold.js +82 -0
  14. package/es/commands/dev/index.d.ts +6 -0
  15. package/es/commands/dev/index.js +40 -0
  16. package/es/commands/doctor/index.d.ts +33 -0
  17. package/es/commands/doctor/index.js +230 -0
  18. package/es/core/collect.d.ts +21 -0
  19. package/es/core/collect.js +89 -0
  20. package/es/core/config.d.ts +55 -0
  21. package/es/core/config.js +109 -0
  22. package/es/core/manifest.d.ts +15 -0
  23. package/es/core/manifest.js +43 -0
  24. package/es/core/minify.d.ts +18 -0
  25. package/es/core/minify.js +93 -0
  26. package/es/core/prepare.d.ts +12 -0
  27. package/es/core/prepare.js +86 -0
  28. package/es/core/protocol.d.ts +2 -0
  29. package/es/core/protocol.js +4 -0
  30. package/es/core/zip.d.ts +4 -0
  31. package/es/core/zip.js +17 -0
  32. package/es/dev/grading.d.ts +15 -0
  33. package/es/dev/grading.js +37 -0
  34. package/es/dev/host-page.d.ts +7 -0
  35. package/es/dev/host-page.js +240 -0
  36. package/es/dev/inject.d.ts +8 -0
  37. package/es/dev/inject.js +38 -0
  38. package/es/dev/mock-api.d.ts +65 -0
  39. package/es/dev/mock-api.js +269 -0
  40. package/es/dev/server.d.ts +24 -0
  41. package/es/dev/server.js +294 -0
  42. package/es/engines/static/index.d.ts +3 -0
  43. package/es/engines/static/index.js +11 -0
  44. package/es/engines/types.d.ts +12 -0
  45. package/es/engines/vite/index.d.ts +2 -0
  46. package/es/engines/vite/index.js +4 -0
  47. package/es/index.d.ts +2 -0
  48. package/es/index.js +2 -0
  49. package/es/rules/check.d.ts +2 -0
  50. package/es/rules/check.js +209 -0
  51. package/es/rules/index.d.ts +8 -0
  52. package/es/rules/index.js +7 -0
  53. package/es/rules/manifest.d.ts +39 -0
  54. package/es/rules/manifest.js +168 -0
  55. package/es/rules/node.d.ts +11 -0
  56. package/es/rules/node.js +87 -0
  57. package/es/rules/path.d.ts +7 -0
  58. package/es/rules/path.js +35 -0
  59. package/es/rules/refs.d.ts +19 -0
  60. package/es/rules/refs.js +111 -0
  61. package/es/rules/skip.d.ts +12 -0
  62. package/es/rules/skip.js +55 -0
  63. package/es/rules/spec.d.ts +3 -0
  64. package/es/rules/spec.js +6 -0
  65. package/es/rules/types.d.ts +138 -0
  66. package/es/rules/unused.d.ts +7 -0
  67. package/es/rules/unused.js +21 -0
  68. package/es/rules/zip.d.ts +13 -0
  69. package/es/rules/zip.js +45 -0
  70. package/es/rules.json.js +3 -0
  71. package/es/types.d.ts +4 -0
  72. package/es/version.d.ts +1 -0
  73. package/es/version.js +3 -0
  74. package/package.json +48 -3
  75. package/rules.json +555 -0
  76. package/templates/_shared/lib/cdk-mock.d.ts +94 -0
  77. package/templates/_shared/lib/cdk-mock.js +429 -0
  78. package/templates/_shared/lib/cdk.js +3 -0
  79. package/templates/_shared/lib/elice-content.css +252 -0
  80. package/templates/_shared/lib/elice-content.d.ts +121 -0
  81. package/templates/_shared/lib/elice-content.js +541 -0
  82. package/templates/_shared/lib/elice-tokens.css +446 -0
  83. package/templates/blank/README.md +64 -0
  84. package/templates/blank/content.json +4 -0
  85. package/templates/blank/edit.html +15 -0
  86. package/templates/blank/elice.config.json +12 -0
  87. package/templates/blank/gitignore +3 -0
  88. package/templates/blank/index.html +15 -0
  89. package/templates/blank/instructor.html +15 -0
  90. package/templates/blank/screens/edit.js +21 -0
  91. package/templates/blank/screens/instructor.js +9 -0
  92. package/templates/blank/screens/learn.js +19 -0
  93. package/templates/blank/styles.css +1 -0
  94. package/templates/quiz/README.md +108 -0
  95. package/templates/quiz/content.json +81 -0
  96. package/templates/quiz/core/behaviors.d.ts +59 -0
  97. package/templates/quiz/core/behaviors.js +309 -0
  98. package/templates/quiz/core/dom.d.ts +13 -0
  99. package/templates/quiz/core/dom.js +83 -0
  100. package/templates/quiz/core/editor.d.ts +48 -0
  101. package/templates/quiz/core/editor.js +206 -0
  102. package/templates/quiz/core/markdown.d.ts +2 -0
  103. package/templates/quiz/core/markdown.js +84 -0
  104. package/templates/quiz/core/model.d.ts +20 -0
  105. package/templates/quiz/core/model.js +203 -0
  106. package/templates/quiz/edit.html +17 -0
  107. package/templates/quiz/elice.config.json +14 -0
  108. package/templates/quiz/gitignore +3 -0
  109. package/templates/quiz/grading.json +13 -0
  110. package/templates/quiz/index.html +17 -0
  111. package/templates/quiz/instructor.html +17 -0
  112. package/templates/quiz/screens/edit.js +139 -0
  113. package/templates/quiz/screens/instructor.js +27 -0
  114. package/templates/quiz/screens/learn.js +50 -0
  115. package/templates/quiz/styles.css +510 -0
  116. package/templates/quiz/ui/templates/choice.js +22 -0
  117. package/templates/quiz/ui/templates/edit.d.ts +14 -0
  118. package/templates/quiz/ui/templates/edit.js +187 -0
  119. package/templates/quiz/ui/templates/group.js +47 -0
  120. package/templates/quiz/ui/templates/index.d.ts +5 -0
  121. package/templates/quiz/ui/templates/index.js +17 -0
  122. package/templates/quiz/ui/templates/order.js +35 -0
  123. package/templates/quiz/ui/templates/page.js +29 -0
  124. package/templates/quiz/ui/templates/question.js +28 -0
  125. package/templates/quiz/ui/templates/text.js +16 -0
  126. package/templates/quiz/ui/texts.d.ts +3 -0
  127. package/templates/quiz/ui/texts.js +128 -0
  128. package/templates/quiz/ui/theme.css +50 -0
@@ -0,0 +1,139 @@
1
+ // 내용 편집 화면(CMS). 기존 퀴즈 편집 폼을 옮김 (docs/quiz-spec.md §3). 저장 버튼 · 변경 표시는 키트(useSave)가 합니다.
2
+ // 정답은 여기서 다루지 않습니다: LXP 편집 화면의 채점 설정에서 정답(문항 id별 답 묶음)을 지정합니다.
3
+ // 저장한 내용은 학생에게도 내려가므로 정답을 넣지 않습니다.
4
+ // 여기서는 어떤 칸을 어떤 순서로 놓을지만 정합니다. 모양은 ui/(templates/edit.js · texts · theme.css), 동작은 core/editor.js.
5
+ import { start } from '../lib/elice-content.js';
6
+ import { createEditor } from '../core/editor.js';
7
+ import { convertType, LIMITS, newQuestion, validateQuiz } from '../core/model.js';
8
+ import * as templates from '../ui/templates/edit.js';
9
+ import { loading } from '../ui/templates/page.js';
10
+ import { texts } from '../ui/texts.js';
11
+
12
+ const t = texts.edit;
13
+ const root = document.getElementById('app');
14
+ document.title = texts.page.edit;
15
+ root.replaceChildren(loading());
16
+ const app = await start({ screen: 'edit' });
17
+ const draft = structuredClone(app.content);
18
+ draft.questions ??= [];
19
+ const form = createEditor({
20
+ rerender: render,
21
+ root,
22
+ templates,
23
+ labels: {
24
+ preview: t.preview,
25
+ previewClose: t.previewClose,
26
+ count: t.count,
27
+ group: texts.defaults.group,
28
+ },
29
+ });
30
+ let save = null;
31
+
32
+ const swap = (list, i, j) => {
33
+ if (j < 0 || j >= list.length) return;
34
+ [list[i], list[j]] = [list[j], list[i]];
35
+ render();
36
+ };
37
+
38
+ /** 문항 카드 안의 칸들. 유형마다 보이는 칸이 다르다 */
39
+ function questionFields(q, i) {
40
+ const body = [
41
+ form.field(t.title, q.title, (v) => (q.title = v), { required: true, max: LIMITS.titleMax }),
42
+ form.markdownField(t.description, q.description, (v) => (q.description = v)),
43
+ ];
44
+ if (q.type === 'select_one' || q.type === 'select_multiple' || q.type === 'order') {
45
+ const options = form.itemList('option', q.options, `${i}o`, {
46
+ onDelete: () => {
47
+ if (q.type === 'order') q.slots = Math.min(q.slots, q.options.length);
48
+ },
49
+ });
50
+ body.push(form.ui.section({ label: t.options, body: options }));
51
+ }
52
+ if (q.type === 'order')
53
+ body.push(
54
+ form.numberField(t.slots, t.slotsHint, q.slots, q.options.length, (v) => (q.slots = v)),
55
+ );
56
+ if (q.type === 'group')
57
+ body.push(
58
+ form.ui.section({ label: t.groups, body: form.itemList('group', q.groups, `${i}g`) }),
59
+ form.ui.section({
60
+ label: t.options,
61
+ hint: t.groupOptionsHint,
62
+ body: form.itemList('option', q.options, `${i}o`),
63
+ }),
64
+ );
65
+ if (q.type === 'text')
66
+ body.push(
67
+ form.field(t.placeholder, q.placeholder, (v) => (q.placeholder = v), {
68
+ max: LIMITS.placeholderMax,
69
+ hint: t.placeholderHint,
70
+ }),
71
+ );
72
+ if (q.type !== 'text') body.push(form.toggle(t.shuffle, q.shuffle, (v) => (q.shuffle = v)));
73
+ body.push(
74
+ form.toggle(t.explanationOn, q.explanation?.enabled, (v) => {
75
+ q.explanation = { ...(q.explanation ?? { text: '' }), enabled: v };
76
+ render();
77
+ }),
78
+ );
79
+ if (q.explanation?.enabled)
80
+ body.push(
81
+ form.markdownField(t.explanation, q.explanation.text, (v) => (q.explanation.text = v)),
82
+ );
83
+ return body;
84
+ }
85
+
86
+ function questionCard(q, i) {
87
+ return form.card(
88
+ {
89
+ q,
90
+ index: i,
91
+ count: draft.questions.length,
92
+ types: Object.entries(texts.types),
93
+ body: questionFields(q, i),
94
+ },
95
+ {
96
+ type: (type) => {
97
+ draft.questions[i] = convertType(q, type, texts.defaults);
98
+ render();
99
+ },
100
+ up: () => swap(draft.questions, i, i - 1),
101
+ down: () => swap(draft.questions, i, i + 1),
102
+ remove: () => {
103
+ draft.questions.splice(i, 1);
104
+ render();
105
+ },
106
+ },
107
+ );
108
+ }
109
+
110
+ function render() {
111
+ root.replaceChildren(
112
+ form.ui.info(),
113
+ form.field(t.quizTitle, draft.title, (v) => (draft.title = v), { required: true }),
114
+ form.markdownField(t.quizDescription, draft.description, (v) => (draft.description = v)),
115
+ ...draft.questions.map(questionCard),
116
+ form.addQuestion(() => {
117
+ draft.questions.push(
118
+ newQuestion(
119
+ 'select_one',
120
+ draft.questions.map((q) => q.id),
121
+ texts.defaults,
122
+ ),
123
+ );
124
+ render();
125
+ }),
126
+ );
127
+ save?.markDirty();
128
+ }
129
+
130
+ render();
131
+ save = app.useSave({
132
+ getContent: () => structuredClone(draft),
133
+ validate: (content) => {
134
+ const problem = validateQuiz(content, texts.validation);
135
+ if (!problem) return true;
136
+ form.cardAt(problem.questionIndex)?.scrollIntoView({ block: 'center' });
137
+ return problem.message;
138
+ },
139
+ });
@@ -0,0 +1,27 @@
1
+ // 교육자 화면. 문항 구성과 해설을 한눈에 봅니다.
2
+ // 정답과 반 전체 결과는 서버가 교육자 모드에 내려주면 표시합니다 (서버 요청 중).
3
+ // 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
4
+ import { start } from '../lib/elice-content.js';
5
+ import { renderQuestion } from '../core/behaviors.js';
6
+ import { labels, templates } from '../ui/templates/index.js';
7
+ import { instructorHeader, loading } from '../ui/templates/page.js';
8
+ import { texts } from '../ui/texts.js';
9
+
10
+ const root = document.getElementById('app');
11
+ document.title = texts.page.instructor;
12
+ root.replaceChildren(loading());
13
+ const app = await start({ screen: 'instructor' });
14
+ const { title, questions = [] } = app.content;
15
+ const counts = questions.reduce((m, q) => ({ ...m, [q.type]: (m[q.type] ?? 0) + 1 }), {});
16
+
17
+ const views = questions.map((q, i) => renderQuestion(q, i, { templates, labels, disabled: true }));
18
+ views.forEach((v) => v.showExplanation());
19
+
20
+ root.replaceChildren(
21
+ instructorHeader({
22
+ title: title ?? '',
23
+ count: questions.length,
24
+ byType: Object.entries(counts).map(([t, n]) => [texts.types[t] ?? t, n]),
25
+ }),
26
+ ...views.map((v) => v.el),
27
+ );
@@ -0,0 +1,50 @@
1
+ // 학생 화면. 화면 머리와 문항을 놓고, 답을 모으고 채우는 방법만 키트에 알려 줍니다.
2
+ // 튜터링 잠금 · 미리보기 안내 · 답 복원 · 점수와 오류 표시는 키트(useSubmit)가 합니다.
3
+ // 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
4
+ import { start } from '../lib/elice-content.js';
5
+ import { renderQuestion } from '../core/behaviors.js';
6
+ import { decodeAnswer, encodeAnswer, isAnswered } from '../core/model.js';
7
+ import { labels, templates } from '../ui/templates/index.js';
8
+ import { learnHeader, loading } from '../ui/templates/page.js';
9
+ import { texts } from '../ui/texts.js';
10
+
11
+ const root = document.getElementById('app');
12
+ document.title = texts.page.learn;
13
+ root.replaceChildren(loading());
14
+ const app = await start({ screen: 'learn' });
15
+ const { title, description, questions = [] } = app.content;
16
+ const views = questions.map((q, i) =>
17
+ renderQuestion(q, i, { templates, labels, seed: app.account?.anonymousId ?? '' }),
18
+ );
19
+
20
+ root.replaceChildren(learnHeader({ title: title ?? '', description }), ...views.map((v) => v.el));
21
+
22
+ app.useSubmit({
23
+ getAnswer: () => ({
24
+ answers: Object.fromEntries(
25
+ questions.map((q, i) => [q.id, encodeAnswer(q, views[i].getValue())]),
26
+ ),
27
+ }),
28
+ setAnswer: (answer) =>
29
+ questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, answer?.answers?.[q.id]))),
30
+ validate: () => {
31
+ const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
32
+ return left < 0 || texts.learn.unanswered(left + 1);
33
+ },
34
+ // 서버 채점 결과는 전체 { isCorrect, score }뿐이라 모두 맞았을 때만 문항마다 정답 표시. 해설은 한 번이라도 제출하면
35
+ onResult: (res) => {
36
+ views.forEach((v) => {
37
+ v.setResult(res.isCorrect === true ? true : null);
38
+ v.showExplanation();
39
+ });
40
+ },
41
+ });
42
+
43
+ // 다시 고치면 그 문항의 결과 색을 지운다 (기존 동작)
44
+ root.addEventListener('input', (e) => clearResult(e.target));
45
+ root.addEventListener('click', (e) => clearResult(e.target));
46
+ function clearResult(target) {
47
+ const card = target instanceof Element ? target.closest('[data-role="question"]') : null;
48
+ const i = card ? questions.findIndex((q) => q.id === card.dataset.id) : -1;
49
+ if (i >= 0 && !app.readOnly) views[i].setResult(null);
50
+ }