@eliceio/cdk-cli 0.1.0-alpha.7 → 1.0.0
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 +64 -57
- package/es/commands/build/index.d.ts +3 -23
- package/es/commands/build/index.js +16 -148
- package/es/commands/doctor/index.d.ts +3 -2
- package/es/commands/doctor/index.js +10 -9
- package/es/commands/validate/index.js +3 -1
- package/es/core/collect.d.ts +1 -1
- package/es/core/collect.js +3 -1
- package/es/core/config.d.ts +2 -2
- package/es/core/config.js +1 -1
- package/es/core/manifest.d.ts +3 -3
- package/es/core/manifest.js +4 -8
- package/es/core/mcp.d.ts +1 -1
- package/es/core/prepare.d.ts +15 -10
- package/es/core/prepare.js +35 -35
- package/es/core/project-check.d.ts +6 -5
- package/es/core/project-check.js +9 -9
- package/es/core/sandbox.d.ts +6 -30
- package/es/core/sandbox.js +32 -109
- package/es/core/sdk.d.ts +7 -18
- package/es/core/sdk.js +8 -38
- package/es/dev/server.d.ts +6 -4
- package/es/dev/server.js +47 -77
- package/es/engines/vite/index.d.ts +2 -2
- package/es/engines/vite/index.js +2 -4
- package/es/engines/vite/plugin.d.ts +58 -0
- package/es/engines/vite/plugin.js +286 -0
- package/es/engines/vite/run.d.ts +15 -0
- package/es/engines/vite/run.js +92 -0
- package/es/rules/check.js +9 -11
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/types.d.ts +8 -3
- package/es/rules/unused.d.ts +0 -2
- package/es/rules/unused.js +3 -4
- package/es/rules.json.js +1 -1
- package/es/test-packages.d.ts +3 -1
- package/package.json +8 -3
- package/rules.json +9 -3
- package/skills/_shared/always.md +1 -1
- package/skills/elice-content-guide/topics/03-create-the-project.md +1 -1
- package/skills/elice-content-guide/topics/04-rules.md +1 -1
- package/skills/elice-content-guide/topics/07-move-existing-html.md +2 -2
- package/skills/elice-content-guide/topics/08-fix-check-errors.md +21 -21
- package/skills/elice-content-guide/topics/10-build.md +1 -1
- package/templates/_shared/lib/elice-content.js +8 -12
- package/templates/blank/README.md +2 -3
- package/templates/quiz/README.md +2 -3
- package/es/core/minify.d.ts +0 -18
- package/es/core/minify.js +0 -122
- package/es/engines/static/index.d.ts +0 -3
- package/es/engines/static/index.js +0 -11
- package/es/engines/types.d.ts +0 -12
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ViteDevServer } from 'vite';
|
|
2
|
+
import { type EcdkBuildOutput } from './plugin.js';
|
|
3
|
+
import type { Server } from 'node:http';
|
|
4
|
+
/** `ecdk build`: Vite build with the ecdk plugin. Check errors come back in the result instead of failing Vite */
|
|
5
|
+
export declare function viteBuild(projectDir: string): Promise<EcdkBuildOutput>;
|
|
6
|
+
/**
|
|
7
|
+
* `ecdk dev` content server: Vite dev server in middleware mode (Vite's default HMR, websocket on the content server).
|
|
8
|
+
* `base` mirrors the production content path; `devHost` is the host origin the dev script talks to
|
|
9
|
+
*/
|
|
10
|
+
export declare function viteDevServer(projectDir: string, opts: {
|
|
11
|
+
base: string;
|
|
12
|
+
httpServer: Server;
|
|
13
|
+
devHost: string;
|
|
14
|
+
log: (line: string) => void;
|
|
15
|
+
}): Promise<ViteDevServer>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createServer, build, mergeConfig, loadConfigFromFile } from 'vite';
|
|
2
|
+
import { readProjectSdk, missingSdkMessage } from '../../core/sdk.js';
|
|
3
|
+
import { ecdk, flattenPlugins, ECDK_PLUGIN_NAME } from './plugin.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* How `ecdk build` / `ecdk dev` run Vite: on top of the project's vite.config.* when there is one,
|
|
7
|
+
* adding the ecdk plugin only if that config lacks it (no config file → the ecdk plugin alone).
|
|
8
|
+
*/
|
|
9
|
+
/** The project's vite.config.* (empty when absent) and whether it already has the ecdk plugin */
|
|
10
|
+
async function projectViteConfig(projectDir, env) {
|
|
11
|
+
// vite.config.* imports installed packages (@eliceio/cdk-cli, vite): report a missing install first
|
|
12
|
+
const sdk = await readProjectSdk(projectDir);
|
|
13
|
+
if (sdk && !sdk.installed) throw new Error(missingSdkMessage());
|
|
14
|
+
const loaded = await loadConfigFromFile(env, undefined, projectDir, 'error');
|
|
15
|
+
const config = loaded?.config ?? {};
|
|
16
|
+
const hasEcdk = (await flattenPlugins(config.plugins)).some(p => p.name === ECDK_PLUGIN_NAME);
|
|
17
|
+
return {
|
|
18
|
+
config,
|
|
19
|
+
hasEcdk
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** After Vite resolves the config, hands over the ecdk plugin's api (from the user config or the one we added) */
|
|
23
|
+
function apiBridge(onApi) {
|
|
24
|
+
return {
|
|
25
|
+
name: `${ECDK_PLUGIN_NAME}:cli`,
|
|
26
|
+
configResolved(resolved) {
|
|
27
|
+
const plugin = resolved.plugins.find(p => p.name === ECDK_PLUGIN_NAME);
|
|
28
|
+
if (plugin?.api) onApi(plugin.api);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async function inlineConfig(projectDir, env, extra, onApi) {
|
|
33
|
+
const {
|
|
34
|
+
config,
|
|
35
|
+
hasEcdk
|
|
36
|
+
} = await projectViteConfig(projectDir, env);
|
|
37
|
+
return mergeConfig(config, {
|
|
38
|
+
root: projectDir,
|
|
39
|
+
configFile: false,
|
|
40
|
+
clearScreen: false,
|
|
41
|
+
logLevel: 'warn',
|
|
42
|
+
...extra,
|
|
43
|
+
plugins: [...(hasEcdk ? [] : [ecdk({
|
|
44
|
+
projectDir
|
|
45
|
+
})]), apiBridge(onApi)]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** `ecdk build`: Vite build with the ecdk plugin. Check errors come back in the result instead of failing Vite */
|
|
49
|
+
async function viteBuild(projectDir) {
|
|
50
|
+
let api;
|
|
51
|
+
const env = {
|
|
52
|
+
command: 'build',
|
|
53
|
+
mode: 'production',
|
|
54
|
+
isSsrBuild: false,
|
|
55
|
+
isPreview: false
|
|
56
|
+
};
|
|
57
|
+
await build(await inlineConfig(projectDir, env, {
|
|
58
|
+
mode: 'production'
|
|
59
|
+
}, a => {
|
|
60
|
+
a.throwOnError = false;
|
|
61
|
+
api = a;
|
|
62
|
+
}));
|
|
63
|
+
if (!api?.result) throw new Error('ecdk 플러그인이 결과를 남기지 않았습니다 (Vite 설정의 ecdk 플러그인 확인).');
|
|
64
|
+
return api.result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* `ecdk dev` content server: Vite dev server in middleware mode (Vite's default HMR, websocket on the content server).
|
|
68
|
+
* `base` mirrors the production content path; `devHost` is the host origin the dev script talks to
|
|
69
|
+
*/
|
|
70
|
+
async function viteDevServer(projectDir, opts) {
|
|
71
|
+
const env = {
|
|
72
|
+
command: 'serve',
|
|
73
|
+
mode: 'development',
|
|
74
|
+
isSsrBuild: false,
|
|
75
|
+
isPreview: false
|
|
76
|
+
};
|
|
77
|
+
return createServer(await inlineConfig(projectDir, env, {
|
|
78
|
+
mode: 'development',
|
|
79
|
+
base: opts.base,
|
|
80
|
+
server: {
|
|
81
|
+
middlewareMode: true,
|
|
82
|
+
hmr: {
|
|
83
|
+
server: opts.httpServer
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, a => {
|
|
87
|
+
a.devHost = opts.devHost;
|
|
88
|
+
a.log = opts.log;
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { viteBuild, viteDevServer };
|
package/es/rules/check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { zipSync } from 'fflate';
|
|
2
2
|
import { isAllowedExternal, allowedOrigins } from './csp.js';
|
|
3
3
|
import { parseManifest } from './manifest.js';
|
|
4
|
-
import { isUnsafePath, extname,
|
|
4
|
+
import { isUnsafePath, extname, resolveRef, globToRegExp } from './path.js';
|
|
5
5
|
import { lineAt, parseTags, extractRefs, classifyRef, FRAME_TAGS } from './refs.js';
|
|
6
6
|
import { compareVersions } from './semver.js';
|
|
7
7
|
import { lineSkipper } from './skip.js';
|
|
@@ -106,28 +106,23 @@ function checkLegacyFiles(opts, add) {
|
|
|
106
106
|
const SDK_UPDATE_COMMAND = 'npm update @eliceio/cdk';
|
|
107
107
|
/**
|
|
108
108
|
* SDK 버전 (ADR 0010). metadata.json build.sdk가 rules.json minVersions.sdk보다 낮으면 오류:
|
|
109
|
-
* LXP 프로토콜과 맞지 않아 저장 · 제출이 안 될 수 있다 (alpha.3 이하는 LXP 편집 화면 초안 저장이 422).
|
|
109
|
+
* LXP 프로토콜과 맞지 않아 저장 · 제출이 안 될 수 있다 (alpha.3 이하는 LXP 편집 화면 초안 저장이 422).
|
|
110
|
+
* 원본에 SDK 복사본(옛 lib/cdk.js)이 남아 있으면 sdk.lib-copy 오류: SDK는 package.json 의존성을 build가 번들로 묶고, 복사본은 zip에 넣지 않는다
|
|
110
111
|
*/
|
|
111
112
|
function checkSdk(manifest, spec, opts, add) {
|
|
112
|
-
// 옛 머리말은 "1.0.0 (브랜치@커밋)"일 수 있어 첫 낱말만 비교한다
|
|
113
113
|
const version = manifest?.build?.sdk?.split(' ')[0];
|
|
114
114
|
const min = spec.minVersions.sdk;
|
|
115
115
|
const order = version ? compareVersions(version, min) : undefined;
|
|
116
116
|
const below = order !== undefined && order < 0;
|
|
117
|
-
if (opts.legacySdkCopy) {
|
|
118
|
-
add('sdk.lib-copy', `${opts.legacySdkCopy}는 옛 ecdk create가 복사한 SDK${version ? ` ${version}` : ''}입니다${below ? ` (최소 ${min}보다 낮음)` : ''}. 이제 SDK는 package.json 의존성입니다: ecdk doctor --fix(또는 package.json dependencies에 "@eliceio/cdk": "^${min}")로 넣고 npm install 하면 ecdk build가 node_modules에서 넣습니다. 그다음 ${opts.legacySdkCopy}는 지워도 됩니다.`, opts.legacySdkCopy);
|
|
119
|
-
// 옛 복사본도 최소 미만이면 오류 (zip 검사와 같은 판정, 옛 SDK로 올리는 것을 막음)
|
|
120
|
-
if (below) add('sdk.outdated', `${opts.legacySdkCopy}의 SDK ${version}은 최소 버전 ${min}보다 낮아 LXP 편집 화면 저장(초안 저장, alpha.3 이하는 실패) · 제출 · 교육자 화면이 안 될 수 있습니다. ecdk doctor --fix && npm install 후 다시 빌드해 주세요.`, opts.legacySdkCopy);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
117
|
+
if (opts.legacySdkCopy) add('sdk.lib-copy', `${opts.legacySdkCopy}는 SDK 복사본입니다. SDK는 복사해 넣지 않고 package.json 의존성(@eliceio/cdk)을 ecdk build가 번들로 묶습니다 (복사본은 zip에 넣지 않음). ecdk doctor --fix(또는 package.json dependencies에 "@eliceio/cdk": "^${min}")로 넣고 npm install 한 뒤, 화면 키트를 새 ecdk create의 lib/elice-content.js로 바꾸고(SDK를 import('@eliceio/cdk')로 부름) ${opts.legacySdkCopy}를 지워 주세요.`, opts.legacySdkCopy);
|
|
123
118
|
if (below) add('sdk.outdated', `@eliceio/cdk(SDK) ${version}은 최소 버전 ${min}보다 낮아 LXP 편집 화면에서 저장(초안 저장)이 안 됩니다 (alpha.3 이하). 프로젝트 폴더에서 ${SDK_UPDATE_COMMAND} 후 다시 빌드해 주세요.`, spec.manifest.file);
|
|
124
119
|
}
|
|
125
120
|
/** `<script type="module" data-ecdk-bundle>` 본문을 줄 수만 남기고 비운다 (줄 번호 유지) */
|
|
126
121
|
function blankBundles(html) {
|
|
127
122
|
return html.replace(/(<script\b[^>]*\sdata-ecdk-bundle\b[^>]*>)([\s\S]*?)(<\/script\s*>)/gi, (_, open, body, close) => open + body.replace(/[^\n]/g, '') + close);
|
|
128
123
|
}
|
|
129
|
-
/** ecdk가 넣는 lib/ 파일 (
|
|
130
|
-
const ECDK_LIB_FILES = new Set(['lib/
|
|
124
|
+
/** ecdk가 넣는 lib/ 파일 (키트). 작성자가 넣은 라이브러리가 아니라 ref.vendor-external-url에서 뺀다 */
|
|
125
|
+
const ECDK_LIB_FILES = new Set(['lib/elice-content.js', 'lib/elice-content-editor.js', 'lib/cdk-mock.js']);
|
|
131
126
|
/** 작성자가 내려받아 넣은 라이브러리로 보는 폴더 · 파일 이름 */
|
|
132
127
|
const VENDOR_DIR = /^(?:vendors?|libs?|third[-_]?party|external|plugins?)$/i;
|
|
133
128
|
const VENDOR_FILE = /[.-]min\.m?js$/i;
|
|
@@ -372,6 +367,9 @@ function checkFiles(input, opts = {}) {
|
|
|
372
367
|
// 모듈 스크립트 파일을 받지 못한다
|
|
373
368
|
const src = t.name === 'script' ? t.attrs.get('src')?.trim() : undefined;
|
|
374
369
|
if (src !== undefined && t.attrs.get('type')?.trim().toLowerCase() === 'module' && classifyRef(src) === 'local' && kind !== 'dir' && !opts.bundlesModules) add('sandbox.module-src', `<script type="module" src="${src}">는 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서 막혀(CORS) 화면이 "불러오는 중"에서 멈춥니다. ecdk build로 만들면 HTML 안에 묶어 넣습니다. 직접 묶으려면 본문을 넣은 <script type="module">이나 일반 <script src>로 바꿔 주세요.`, f.path, t.line);
|
|
370
|
+
// build(Vite)는 type="module" 스크립트만 묶고, 그 밖 원본은 public/ 파일만 zip에 넣는다
|
|
371
|
+
const classic = src !== undefined && t.attrs.get('type')?.trim().toLowerCase() !== 'module' && classifyRef(src) === 'local' ? resolveRef(f.path, src.replace(/[?#].*$/, '')) : null;
|
|
372
|
+
if (classic !== null && opts.publicFiles && !opts.publicFiles.includes(classic)) add('ref.script-not-public', `<script src="${src}">(type="module" 없음)는 build가 묶지 않고 zip에도 넣지 않습니다. type="module"을 붙여 묶거나, 파일을 public/으로 옮겨 그대로 넣어 주세요.`, f.path, t.line);
|
|
375
373
|
if (t.name === 'img' && !t.attrs.has('alt')) add('html.img-alt', `대체 텍스트(alt)가 없는 이미지입니다.`, f.path, t.line);
|
|
376
374
|
if (FRAME_TAGS.has(t.name) && framesSomething(t)) add('html.iframe', t.name === 'iframe' || t.name === 'frame' ? `<${t.name} src="${t.attrs.get('src')?.trim()}">: 외부 페이지 · 파일을 iframe으로 띄우면 CSP(frame-src 'none')가 막음 (zip 안 파일도). 영상은 Elice 비디오 자료로 따로 올리고, 다른 내용은 이 HTML 안에 넣어 주세요. 코드 미리보기는 srcdoc 사용 가능.` : `<${t.name}>는 LXP 콘텐츠 CSP(object-src 'none')가 막아 빈 칸으로 보입니다. 영상은 Elice 비디오 자료로 따로 올리고, 다른 문서는 내용을 이 HTML 안에 넣어 주세요.`, f.path, t.line);
|
|
377
375
|
if (t.name === 'form') add('html.form', 'form 제출은 sandbox · 콘텐츠 CSP(form-action)가 막습니다. 버튼 click 처리와 SDK 제출을 써 주세요.', f.path, t.line);
|
package/es/rules/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { COMPLETION_POLICIES_IGNORED, graderTypeError, LEGACY_COMPLETION_FIELDS,
|
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
5
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
6
|
export { rules, RULES_VERSION } from './spec.js';
|
|
7
|
-
export { findUnreferenced
|
|
7
|
+
export { findUnreferenced } from './unused.js';
|
|
8
8
|
export { filesFromHtml, filesFromZip, ZipLimitError } from './zip.js';
|
|
9
9
|
export type * from './types.js';
|
package/es/rules/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { COMPLETION_POLICIES_IGNORED, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETIO
|
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
5
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
6
|
export { RULES_VERSION, rules } from './spec.js';
|
|
7
|
-
export {
|
|
7
|
+
export { findUnreferenced } from './unused.js';
|
|
8
8
|
export { ZipLimitError, filesFromHtml, filesFromZip } from './zip.js';
|
package/es/rules/types.d.ts
CHANGED
|
@@ -112,10 +112,15 @@ export interface CheckOptions {
|
|
|
112
112
|
*/
|
|
113
113
|
legacyFiles?: string[] | undefined;
|
|
114
114
|
/**
|
|
115
|
-
* 프로젝트 검사일 때:
|
|
116
|
-
* 있으면 sdk.lib-copy로 옮기는 법을
|
|
115
|
+
* 프로젝트 검사일 때: 원본에 SDK 복사본(옛 lib/cdk.js)이 있으면 그 경로.
|
|
116
|
+
* 있으면 sdk.lib-copy 오류로 package.json 의존성 · import로 옮기는 법을 알린다 (복사본은 zip에 넣지 않음)
|
|
117
117
|
*/
|
|
118
118
|
legacySdkCopy?: string | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* 프로젝트 검사일 때: public/ 폴더의 파일 (zip 경로). 있으면 type="module" 없는 <script src>가 public/ 밖
|
|
121
|
+
* 파일을 가리킬 때 ref.script-not-public 오류 (build가 묶지 않고 zip에도 넣지 않음)
|
|
122
|
+
*/
|
|
123
|
+
publicFiles?: string[] | undefined;
|
|
119
124
|
/**
|
|
120
125
|
* 이 CLI가 아는 템플릿과 버전 ({ quiz: '1.0.0' }). 있으면 metadata.json build.template을 맞춰 본다
|
|
121
126
|
* (build.template-unknown). 없으면(서버 · 라이브러리 사용) 보지 않는다
|
|
@@ -130,7 +135,7 @@ export interface BuildInfo {
|
|
|
130
135
|
engine: string;
|
|
131
136
|
/** 만든 템플릿과 그 템플릿의 버전 (예: "quiz@1.0.0", 템플릿마다 template.json version). ecdk create가 package.json "ecdk"에 적어 둔 값 */
|
|
132
137
|
template?: string | undefined;
|
|
133
|
-
/**
|
|
138
|
+
/** build가 번들로 묶은 @eliceio/cdk의 설치 버전 (node_modules/@eliceio/cdk/package.json) */
|
|
134
139
|
sdk?: string | undefined;
|
|
135
140
|
/** minify로 줄였는지 */
|
|
136
141
|
minify?: boolean | undefined;
|
package/es/rules/unused.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { ContentFile, Manifest } from './types.js';
|
|
2
|
-
/** 다른 파일 이름을 담을 수 있는 텍스트 파일 */
|
|
3
|
-
export declare const TEXT_FILE: RegExp;
|
|
4
2
|
/**
|
|
5
3
|
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
6
4
|
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
package/es/rules/unused.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const TEXT_FILE = /\.(?:html?|css|m?js|json|svg)$/i;
|
|
1
|
+
const TEXT = /\.(?:html?|css|m?js|json|svg)$/i;
|
|
3
2
|
/**
|
|
4
3
|
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
5
4
|
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
|
@@ -9,7 +8,7 @@ function findUnreferenced(files, manifest) {
|
|
|
9
8
|
const real = files.filter(f => !f.dir);
|
|
10
9
|
const entries = new Set(Object.values(manifest?.entries ?? {}));
|
|
11
10
|
const decoder = new TextDecoder();
|
|
12
|
-
const texts = real.filter(f =>
|
|
11
|
+
const texts = real.filter(f => TEXT.test(f.path)).map(f => ({
|
|
13
12
|
path: f.path,
|
|
14
13
|
text: decoder.decode(f.data)
|
|
15
14
|
}));
|
|
@@ -19,4 +18,4 @@ function findUnreferenced(files, manifest) {
|
|
|
19
18
|
}).map(f => f.path).sort();
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
export {
|
|
21
|
+
export { findUnreferenced };
|
package/es/rules.json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const version="0.11.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"warn",scope:"client",title:"옛 lib/cdk.js 복사본 (package.json에 @eliceio/cdk가 없음, 프로젝트 검사만. SDK를 package.json 의존성으로 옮기기)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
1
|
+
const version="0.12.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"ref.script-not-public",level:"error",scope:"client",title:"type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"error",scope:"client",title:"SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
2
2
|
|
|
3
3
|
export { allowedExtensions, rulesJson as default, excluded, externalAllow, forbiddenApis, imageExtensions, limits, manifest, minVersions, rules, secretPatterns, version };
|
package/es/test-packages.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type CreateOptions, type CreateResult } from './commands/create/scaffold.js';
|
|
2
|
-
|
|
2
|
+
/** 번들에 들어갔는지 확인하는 표시 */
|
|
3
|
+
export declare const SDK_STUB_MARK = "ecdk-test-sdk-stub";
|
|
4
|
+
export declare const SDK_STUB = "export class EliceCDK { constructor() { this.mark = 'ecdk-test-sdk-stub'; } }\nexport const ErrorCode = {};\n";
|
|
3
5
|
/** 워크스페이스 SDK 버전 (packages/eliceio-cdk/package.json) */
|
|
4
6
|
export declare function workspaceSdkVersion(): Promise<string>;
|
|
5
7
|
export declare function installWorkspaceSdk(dir: string, version?: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliceio/cdk-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "교육자용 Custom HTML 콘텐츠 CLI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./es/index.d.ts",
|
|
10
10
|
"import": "./es/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./vite": {
|
|
13
|
+
"types": "./es/engines/vite/index.d.ts",
|
|
14
|
+
"import": "./es/engines/vite/index.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"publishConfig": {
|
|
@@ -30,7 +34,8 @@
|
|
|
30
34
|
],
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"esbuild": "~0.28.2",
|
|
33
|
-
"fflate": "^0.8.3"
|
|
37
|
+
"fflate": "^0.8.3",
|
|
38
|
+
"vite": "^8.3.6"
|
|
34
39
|
},
|
|
35
40
|
"devDependencies": {
|
|
36
41
|
"@elice/rollup-config": "^1.260406.0",
|
|
@@ -40,7 +45,7 @@
|
|
|
40
45
|
"rollup": "^4.0.0",
|
|
41
46
|
"tslib": "^2.6.1",
|
|
42
47
|
"typescript": "~5.9.3",
|
|
43
|
-
"@eliceio/cdk": "^1.0.0
|
|
48
|
+
"@eliceio/cdk": "^1.0.0"
|
|
44
49
|
},
|
|
45
50
|
"scripts": {
|
|
46
51
|
"prebuild": "del-cli \"buildcache/*\" \"es/*\"",
|
package/rules.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.12.0",
|
|
3
3
|
"manifest": {
|
|
4
4
|
"file": "metadata.json",
|
|
5
5
|
"kinds": ["material", "description"],
|
|
@@ -557,6 +557,12 @@
|
|
|
557
557
|
"scope": "client",
|
|
558
558
|
"title": "라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"
|
|
559
559
|
},
|
|
560
|
+
{
|
|
561
|
+
"id": "ref.script-not-public",
|
|
562
|
+
"level": "error",
|
|
563
|
+
"scope": "client",
|
|
564
|
+
"title": "type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"
|
|
565
|
+
},
|
|
560
566
|
{
|
|
561
567
|
"id": "sandbox.module-src",
|
|
562
568
|
"level": "warn",
|
|
@@ -661,9 +667,9 @@
|
|
|
661
667
|
},
|
|
662
668
|
{
|
|
663
669
|
"id": "sdk.lib-copy",
|
|
664
|
-
"level": "
|
|
670
|
+
"level": "error",
|
|
665
671
|
"scope": "client",
|
|
666
|
-
"title": "
|
|
672
|
+
"title": "SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"
|
|
667
673
|
}
|
|
668
674
|
]
|
|
669
675
|
}
|
package/skills/_shared/always.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
|
|
5
5
|
- The content CSP blocks external images, fonts, video, CSS, `<iframe>` and external APIs: put everything in the zip (fonts as files or data URIs). If a library calls outside hosts while running, that is blocked too → check the `ecdk dev` log for "막힌 외부 요청".
|
|
6
6
|
- If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Run each command through their login shell instead: `"$SHELL" -ilc 'ecdk build --json'` (use `zsh -ilc` when `$SHELL` is empty). With `--json`, read only the last JSON block of the output (a login shell may print other text first). If that also fails, ask the person how Node was installed.
|
|
7
|
-
- Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); `ecdk build`
|
|
7
|
+
- Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); the kit imports it and `ecdk build` (Vite) bundles it into the screens. Never copy SDK code into the project.
|
|
8
8
|
- Ask the person before you settle correct answers, install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
|
|
9
9
|
- LXP draws its own 이전 · 다음 bar under the material to move between lecture pages. For steps inside a material use the kit's `app.usePaging` (side chevrons, `n / N`; on the first and last step they become "이전 자료" · "다음 자료" to the previous / next lecture page, `../elice-content-guide/topics/02-design-the-material.md`), never a look-alike bottom 이전 · 다음 bar.
|
|
10
10
|
- Answer the person in their language. The guide is in English.
|
|
@@ -12,7 +12,7 @@ Run `ecdk create --list` first: it prints each template with its own version (`q
|
|
|
12
12
|
|
|
13
13
|
`create` refuses a folder that is not empty. Use a new subfolder. It then runs `npm install` in the project (the SDK `@eliceio/cdk` comes from npm through `package.json`; `--no-install` skips it). When the install fails, the project stays: run `npm install` in it (network or proxy problem; tell the user).
|
|
14
14
|
|
|
15
|
-
The project files: screens, `lib/` (the screen kit, copied as is), `metadata.json` (screens · `commentary`; `ecdk build` copies it and fills only `build`), `package.json` (the SDK version in `dependencies`, build options `minify` · `sourcemap` · `root` · `outDir` · `exclude` · `template` under `"ecdk"`).
|
|
15
|
+
The project files: screens, `lib/` (the screen kit, copied as is), `metadata.json` (screens · `commentary`; `ecdk build` copies it and fills only `build`), `package.json` (the SDK version in `dependencies`, build options `minify` · `sourcemap` · `root` · `outDir` · `exclude` · `template` under `"ecdk"`). `ecdk build` and `ecdk dev` run on Vite (a project `vite.config.*` is used when present). The kit imports the SDK from `node_modules/@eliceio/cdk` and `ecdk build` bundles it into the screens; there is no SDK file in the project or the zip. To update the SDK run `npm update @eliceio/cdk`.
|
|
16
16
|
|
|
17
17
|
Then:
|
|
18
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 4. Rules
|
|
2
2
|
|
|
3
3
|
1. **Never put correct answers in the content**: not in a data JSON file, the screen code, or comments. They reach the student's browser. Answers go only in `settings.grading` through the edit screen (the server never sends it to students; `ecdk dev` keeps it in `.ecdk/settings.json`, left out of the zip).
|
|
4
|
-
2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (
|
|
4
|
+
2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (`@eliceio/cdk`, imported by the kit and bundled by `ecdk build`) directly.
|
|
5
5
|
3. **Do not use blocked features**: `alert`/`confirm`/`prompt` · `window.open` · `<form>` submission · access to `window.parent`/`top` · `fetch`/`WebSocket` to external addresses · external `<script src>`. `localStorage` · `sessionStorage` · `indexedDB` · `document.cookie` work, but they stay only in that browser and device and are not the learner's record: to keep progress, submit it (`useSubmit`); to keep content, save it from the edit screen.
|
|
6
6
|
4. **Libraries and media go inside the zip.** Download libraries for charts, visualization or physics (for example Chart.js, D3, p5.js) into `vendor/` and load them by relative path instead of a CDN. Fonts, images and sounds also go in the zip. Limits: zip 20 MB, 300 files. Upload long videos separately as Elice video materials.
|
|
7
7
|
- The content CSP (same as LXP) blocks every external image, font, video, CSS file, `<iframe src>`/`<object>`/`<embed>` and `fetch` (errors `ref.external-request` · `html.iframe`; an `<iframe>` filled with `srcdoc` for a code preview is fine). Fonts go in the zip as files or data URIs: external fonts (Google Fonts too) are blocked for now; they open once the server allowlist is settled.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# 7. Move existing HTML
|
|
2
2
|
|
|
3
3
|
1. Create a skeleton with `ecdk create <new folder> --template blank`.
|
|
4
|
-
2. Move the original body, styles and scripts to the student screen (`index.html` · `screens/learn.js` · `styles.css`). Copy image, font and library folders as they are and use relative paths.
|
|
4
|
+
2. Move the original body, styles and scripts to the student screen (`index.html` · `screens/learn.js` · `styles.css`). Copy image, font and library folders as they are and use relative paths. The build only keeps what HTML, CSS and `import` reach: files the code loads by a string path at run time (`fetch('data.json')`, `new Worker('w.js')`, a `<script src>` without `type="module"`) go in `public/` (`public/data.json` becomes `data.json` in the zip). A `<script src>` without `type="module"` outside `public/` fails with `ref.script-not-public`: add `type="module"` or move the file to `public/`.
|
|
5
5
|
3. Download external CDN scripts, fonts, images, CSS and videos into the zip (fonts as files or data URIs, long videos as Elice video materials, no `<iframe>`). After `ecdk dev`, check the log for "막힌 외部 요청".
|
|
6
6
|
4. Replace blocked code (storage, `alert`, external sends) as in [4](04-rules.md).
|
|
7
7
|
5. Merge multiple HTML pages into one HTML that switches views.
|
|
8
8
|
6. Decide submission and grading as in [2 ②](02-design-the-material.md). The completion policy is not written in the project: the instructor picks it in the LXP settings tab after the upload (suggest `on_access` when there is no submission).
|
|
9
9
|
7. Turn off the instructor and edit screens in `metadata.json` `screens` (`{ "enabled": false }`) and delete their files when they are not needed.
|
|
10
|
-
8. An old ecdk project with `elice.config.json` or `lib/cdk.js` and no `@eliceio/cdk` in `package.json`: run `ecdk doctor --fix` (moves the settings to `metadata.json` and `package.json` `"ecdk"`, adds the SDK dependency), then `npm install
|
|
10
|
+
8. An old ecdk project with `elice.config.json` or `lib/cdk.js` and no `@eliceio/cdk` in `package.json`: run `ecdk doctor --fix` (moves the settings to `metadata.json` and `package.json` `"ecdk"`, adds the SDK dependency), then `npm install`, replace `lib/elice-content.js` with the one from a new `ecdk create` project (it imports `@eliceio/cdk`) and delete `lib/cdk.js` (the zip never takes an SDK copy: `sdk.lib-copy` error).
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Read `check.issues[]` (`id` · `level` · `path` · `line` · `message`) from `ecdk build --json`. With an `error` no zip is made. Each `message` says how to fix it.
|
|
4
4
|
|
|
5
|
-
| id | Fix
|
|
6
|
-
| --------------------------------------------------------------- |
|
|
7
|
-
| `ref.missing` · `ref.case-mismatch` | Match the path and case to the real file
|
|
8
|
-
| `ref.root-absolute` | Change `/…` to a relative path
|
|
9
|
-
| `ref.external-script` · `ref.external-request` · `ref.insecure` | Put the library, image, font or video in the zip and use a relative path (fonts: files or data URIs)
|
|
10
|
-
| `html.iframe` | Remove the `<iframe src>`/`<object>`/`<embed>` (an `<iframe>` with `srcdoc` for a code preview passes): upload video as an Elice video material, put other content in this HTML
|
|
11
|
-
| `ref.external-font` (warn) | A font from a host in `rules.json` `externalAllow` (empty for now): closed-network schools cannot reach it, so put a font that matters in the zip
|
|
12
|
-
| `ref.vendor-external-url` (warn) | A library file holds outside addresses: run `ecdk dev`, look for "막힌 외부 요청", put what it loads in the zip and set the library to a relative path
|
|
13
|
-
| `api.storage` · `api.cookie` (warn) | Browser storage and cookies stay only in that browser and device and are not the learner's record. Submit results; save content from the edit screen
|
|
14
|
-
| `api.dialog` · `api.window-open` · `html.form` | An in-page message · the same view · a button click + `useSubmit`
|
|
15
|
-
| `api.external-send` | Remove the external send
|
|
16
|
-
| `sec.html-injection` | Use `textContent`. If justified: escape + `ecdk-ignore` + the reason
|
|
17
|
-
| `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**)
|
|
18
|
-
| `manifest.completion-policies-ignored` (warn) | Remove the old `completionPolicies` and `screens.completionPolicy` from `metadata.json` (and the completion policy screen files). The instructor picks the policy in the LXP settings tab
|
|
19
|
-
| `grading.no-submit` (warn) | The edit screen saves the grading but nothing submits: add `useSubmit` to the student screen, or drop the grading block when the material is not graded
|
|
20
|
-
| `project.legacy-file` (warn, project only) | An old `elice.config.json` · `content.json` · `grading.json` is left: `ecdk doctor --fix` moves `elice.config.json`; re-enter the content and answers in the edit screen, then delete the other files
|
|
21
|
-
| `sdk.outdated` (error) | The SDK
|
|
22
|
-
| `sdk.lib-copy` (
|
|
23
|
-
| `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"`
|
|
24
|
-
| `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json`
|
|
25
|
-
| `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere")
|
|
5
|
+
| id | Fix |
|
|
6
|
+
| --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `ref.missing` · `ref.case-mismatch` | Match the path and case to the real file |
|
|
8
|
+
| `ref.root-absolute` | Change `/…` to a relative path |
|
|
9
|
+
| `ref.external-script` · `ref.external-request` · `ref.insecure` | Put the library, image, font or video in the zip and use a relative path (fonts: files or data URIs) |
|
|
10
|
+
| `html.iframe` | Remove the `<iframe src>`/`<object>`/`<embed>` (an `<iframe>` with `srcdoc` for a code preview passes): upload video as an Elice video material, put other content in this HTML |
|
|
11
|
+
| `ref.external-font` (warn) | A font from a host in `rules.json` `externalAllow` (empty for now): closed-network schools cannot reach it, so put a font that matters in the zip |
|
|
12
|
+
| `ref.vendor-external-url` (warn) | A library file holds outside addresses: run `ecdk dev`, look for "막힌 외부 요청", put what it loads in the zip and set the library to a relative path |
|
|
13
|
+
| `api.storage` · `api.cookie` (warn) | Browser storage and cookies stay only in that browser and device and are not the learner's record. Submit results; save content from the edit screen |
|
|
14
|
+
| `api.dialog` · `api.window-open` · `html.form` | An in-page message · the same view · a button click + `useSubmit` |
|
|
15
|
+
| `api.external-send` | Remove the external send |
|
|
16
|
+
| `sec.html-injection` | Use `textContent`. If justified: escape + `ecdk-ignore` + the reason |
|
|
17
|
+
| `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**) |
|
|
18
|
+
| `manifest.completion-policies-ignored` (warn) | Remove the old `completionPolicies` and `screens.completionPolicy` from `metadata.json` (and the completion policy screen files). The instructor picks the policy in the LXP settings tab |
|
|
19
|
+
| `grading.no-submit` (warn) | The edit screen saves the grading but nothing submits: add `useSubmit` to the student screen, or drop the grading block when the material is not graded |
|
|
20
|
+
| `project.legacy-file` (warn, project only) | An old `elice.config.json` · `content.json` · `grading.json` is left: `ecdk doctor --fix` moves `elice.config.json`; re-enter the content and answers in the edit screen, then delete the other files |
|
|
21
|
+
| `sdk.outdated` (error) | The installed SDK bundled into the zip is older than the minimum (1.0.0-alpha.3 or older cannot save in the LXP edit screen - draft save fails): `npm update @eliceio/cdk`, then build again |
|
|
22
|
+
| `sdk.lib-copy` (error, project only) | An SDK copy `lib/cdk.js` in the project (never put in the zip): `ecdk doctor --fix`, `npm install`, replace the kit `lib/elice-content.js` with a new `ecdk create` one, delete `lib/cdk.js` |
|
|
23
|
+
| `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"` |
|
|
24
|
+
| `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json` |
|
|
25
|
+
| `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere") |
|
|
26
26
|
|
|
27
27
|
Use `ecdk-ignore`, which turns a rule off, only for legitimate code a regular expression cannot tell apart, and **always with the reason**. Do not scatter it to silence errors.
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
ecdk build --json
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
- With `ok: true` the zip is `dist/content.zip`. The build minifies by default (comments do not reach learners' browsers, quiz template about
|
|
7
|
+
- With `ok: true` the zip is `dist/content.zip`. The build minifies by default (comments do not reach learners' browsers, quiz template about 149 KB → 107 KB). Screen code, the kit and the SDK go into the HTML as one bundle, not as separate files. Besides the bundle the zip holds only `metadata.json`, the files it names (`commentary`) and the files in `public/` (as they are, at the zip root); a source file nothing bundles is left out, so put files loaded by a string path at run time in `public/`. Turn minifying off only to debug, with `"minify": false` in `package.json` `"ecdk"`.
|
|
8
8
|
- Report to the user: what the material is (what the student does, which screens are on, how it completes), the zip path and size, **what to pick in the LXP settings tab** (the completion policy that fits, which the instructor picks there, the grading type, and where the answers are set), the upload steps (Custom HTML material in LXP → upload the zip → settings tab → save → check the student and instructor screens), and anything left to check. Saving makes the new version visible to learners at once, so the person approves it first (see [0. What the person decides](00-what-the-person-decides.md)).
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* 화면(screens/*.js)은 이 키트만 부릅니다. 키트가 SDK로 인증 · 화면 확인 · 내용 불러오기 ·
|
|
12
12
|
* 제출 · 저장 · 오류 안내를 처리합니다. SDK는 둘 중 하나를 자동으로 고릅니다.
|
|
13
13
|
*
|
|
14
|
-
* real
|
|
14
|
+
* real @eliceio/cdk 1.x (package.json) 플랫폼에서 열 때 (#token=, 편집기 #preview=1 · #edit=1)
|
|
15
|
+
* ecdk build가 이 화면 코드와 함께 번들로 묶음
|
|
15
16
|
* 편집 화면은 edit 토큰으로 열려 '저장'이 자료의 draft에 저장.
|
|
16
17
|
* 학생에게는 LXP 편집 페이지의 '저장'(새 버전)부터 보임
|
|
17
18
|
* mock lib/cdk-mock.js (같은 인터페이스) 그 밖 (로컬): 로컬 채점, 화면 사이 저장 공유
|
|
@@ -168,18 +169,13 @@ function devApi() {
|
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* 실제 SDK는 package.json 의존성 @eliceio/cdk를 import한다. ecdk build(Vite)가 node_modules에서 찾아
|
|
174
|
+
* 이 화면 코드와 함께 번들로 묶는다 (SDK 파일을 따로 두지 않음). mock이면 실행하지 않는다
|
|
175
|
+
*/
|
|
172
176
|
async function loadRealSdk() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const script = document.createElement('script');
|
|
176
|
-
script.src = new URL('./cdk.js', import.meta.url).href;
|
|
177
|
-
script.onload = resolve;
|
|
178
|
-
script.onerror = () =>
|
|
179
|
-
reject(new ContentError('request_failed', 'SDK 파일(lib/cdk.js)을 불러오지 못했습니다.'));
|
|
180
|
-
document.head.append(script);
|
|
181
|
-
});
|
|
182
|
-
return globalThis.elice.EliceCDK;
|
|
177
|
+
const { EliceCDK } = await import('@eliceio/cdk');
|
|
178
|
+
return EliceCDK;
|
|
183
179
|
}
|
|
184
180
|
|
|
185
181
|
/** 로컬에서 열 때 SDK에 넘기는 자료 경로. SDK는 주소의 /materials/{uuid}/에서 자료 id를 읽는다 */
|