@eliceio/cdk-cli 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +110 -104
- package/es/cli.js +7 -22
- package/es/commands/build/index.d.ts +3 -21
- package/es/commands/build/index.js +17 -140
- package/es/commands/create/scaffold.d.ts +2 -0
- package/es/commands/create/scaffold.js +15 -1
- package/es/commands/doctor/index.d.ts +4 -3
- package/es/commands/doctor/index.js +14 -14
- package/es/commands/setup/index.d.ts +4 -7
- package/es/commands/setup/index.js +41 -70
- package/es/commands/uninstall/index.d.ts +9 -8
- package/es/commands/uninstall/index.js +41 -47
- package/es/commands/update/index.d.ts +4 -2
- package/es/commands/update/index.js +27 -18
- 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 +3 -3
- package/es/core/manifest.d.ts +3 -3
- package/es/core/manifest.js +4 -8
- package/es/{commands/mcp/index.d.ts → core/mcp.d.ts} +11 -18
- package/es/{commands/mcp/index.js → core/mcp.js} +29 -51
- 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 -5
- package/es/core/sandbox.js +30 -8
- package/es/core/sdk.d.ts +7 -18
- package/es/core/sdk.js +8 -38
- package/es/{commands/skill/index.d.ts → core/skills.d.ts} +1 -17
- package/es/{commands/skill/index.js → core/skills.js} +6 -22
- package/es/dev/grading.d.ts +1 -1
- package/es/dev/grading.js +1 -1
- package/es/dev/host-page.js +2 -2
- 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 +10 -12
- package/es/rules/csp.d.ts +1 -1
- package/es/rules/csp.js +1 -1
- package/es/rules/types.d.ts +8 -3
- 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-create/SKILL.md +2 -1
- package/skills/elice-content-guide/topics/01-check-the-environment.md +2 -2
- package/skills/elice-content-guide/topics/02-design-the-material.md +2 -0
- package/skills/elice-content-guide/topics/03-create-the-project.md +3 -3
- package/skills/elice-content-guide/topics/04-rules.md +1 -1
- package/skills/elice-content-guide/topics/05-screen-code.md +44 -13
- 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/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +2 -2
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.js +2 -2
- package/templates/_shared/lib/elice-content-editor.d.ts +80 -0
- package/templates/_shared/lib/elice-content-editor.js +1062 -0
- package/templates/_shared/lib/elice-content.css +332 -0
- package/templates/_shared/lib/elice-content.js +18 -15
- package/templates/blank/README.md +29 -5
- package/templates/blank/commentary.txt +5 -0
- package/templates/blank/screens/edit.js +38 -17
- package/templates/blank/screens/instructor.js +20 -8
- package/templates/blank/screens/learn.js +151 -13
- package/templates/blank/styles.css +171 -0
- package/templates/blank/template.json +2 -2
- package/templates/quiz/README.md +2 -3
- package/templates/quiz/core/model.js +1 -1
- package/templates/quiz/screens/edit.js +14 -2
- package/templates/quiz/styles.css +11 -0
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/texts.js +1 -1
- package/es/core/minify.d.ts +0 -18
- package/es/core/minify.js +0 -93
- 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,286 @@
|
|
|
1
|
+
import { mkdir, writeFile, rm } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve, dirname } from 'node:path';
|
|
3
|
+
import { formatIssues } from '../../commands/validate/index.js';
|
|
4
|
+
import { loadConfig, legacyGradingTypesWarning, CONFIG_FILE, legacyCompletionWarning } from '../../core/config.js';
|
|
5
|
+
import { contentDigest } from '../../core/manifest.js';
|
|
6
|
+
import { prepareContent, PUBLIC_DIR } from '../../core/prepare.js';
|
|
7
|
+
import { projectCheckOptions } from '../../core/project-check.js';
|
|
8
|
+
import { inlineModuleScripts } from '../../core/sandbox.js';
|
|
9
|
+
import { missingSdkMessage } from '../../core/sdk.js';
|
|
10
|
+
import { createZip } from '../../core/zip.js';
|
|
11
|
+
import { injectDevScript } from '../../dev/inject.js';
|
|
12
|
+
import { checkFiles } from '../../rules/check.js';
|
|
13
|
+
import { rules } from '../../rules/spec.js';
|
|
14
|
+
import { stripCompletionPolicy } from '../../rules/manifest.js';
|
|
15
|
+
import { findUnreferenced } from '../../rules/unused.js';
|
|
16
|
+
import 'fflate';
|
|
17
|
+
|
|
18
|
+
/** Plugin name. `ecdk build` / `ecdk dev` add the plugin only when the Vite config has none with this name */
|
|
19
|
+
const ECDK_PLUGIN_NAME = 'ecdk';
|
|
20
|
+
const encoder = new TextEncoder();
|
|
21
|
+
const decoder = new TextDecoder();
|
|
22
|
+
/**
|
|
23
|
+
* Adds values to metadata.json `build` (also an authored one). Legacy completion-policy fields are dropped from the zip
|
|
24
|
+
* (completion policy is an LXP setting, ADR 0012; leftovers are reported by manifest.completion-policies-ignored).
|
|
25
|
+
* Malformed JSON is left as is for the checks to report
|
|
26
|
+
*/
|
|
27
|
+
function withBuildStamp(files, stamp) {
|
|
28
|
+
return files.map(f => {
|
|
29
|
+
if (f.path !== rules.manifest.file) return f;
|
|
30
|
+
try {
|
|
31
|
+
const raw = JSON.parse(decoder.decode(f.data));
|
|
32
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return f;
|
|
33
|
+
const next = {
|
|
34
|
+
...stripCompletionPolicy(raw),
|
|
35
|
+
build: {
|
|
36
|
+
...raw.build,
|
|
37
|
+
...stamp
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
...f,
|
|
42
|
+
data: encoder.encode(`${JSON.stringify(next, null, 2)}\n`)
|
|
43
|
+
};
|
|
44
|
+
} catch {
|
|
45
|
+
return f;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Source checks + limits against the real zip + legacy config warnings */
|
|
50
|
+
async function checkBuild(projectDir, config, prepared, files, zipBytes) {
|
|
51
|
+
// Checks read the sources before bundling: bundling/minifying drops ecdk-ignore comments, shifts line numbers
|
|
52
|
+
// and would scan the bundled SDK. Size limits use the real zip. Project checks also report legacy files and
|
|
53
|
+
// the SDK copy (.ecdk is never read)
|
|
54
|
+
const check = checkFiles(prepared.files, await projectCheckOptions(projectDir, config, {
|
|
55
|
+
publicFiles: prepared.publicFiles,
|
|
56
|
+
zipBytes
|
|
57
|
+
}));
|
|
58
|
+
const realCount = files.length;
|
|
59
|
+
if (realCount > rules.limits.maxFiles && !check.issues.some(i => i.id === 'limit.file-count')) {
|
|
60
|
+
check.issues.unshift({
|
|
61
|
+
id: 'limit.file-count',
|
|
62
|
+
level: 'error',
|
|
63
|
+
message: `결과물 파일이 ${realCount}개라 한도 ${rules.limits.maxFiles}개를 넘습니다. 파일을 줄여 주세요.`
|
|
64
|
+
});
|
|
65
|
+
check.ok = false;
|
|
66
|
+
}
|
|
67
|
+
// Legacy elice.config.json gradingTypes: not migrated, only asked to remove (ADR 0008 · 0009)
|
|
68
|
+
const legacy = legacyGradingTypesWarning(config);
|
|
69
|
+
if (legacy) check.issues.push({
|
|
70
|
+
id: 'manifest.grading-types',
|
|
71
|
+
level: 'warn',
|
|
72
|
+
message: legacy,
|
|
73
|
+
path: CONFIG_FILE
|
|
74
|
+
});
|
|
75
|
+
// Legacy elice.config.json completion policies: not migrated (LXP setting, ADR 0012)
|
|
76
|
+
const legacyCompletion = legacyCompletionWarning(config);
|
|
77
|
+
if (legacyCompletion) check.issues.push({
|
|
78
|
+
id: 'manifest.completion-policies-ignored',
|
|
79
|
+
level: 'warn',
|
|
80
|
+
message: legacyCompletion,
|
|
81
|
+
path: CONFIG_FILE
|
|
82
|
+
});
|
|
83
|
+
return check;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* ecdk Vite plugin. `ecdk build` / `ecdk dev` run Vite with it, and with it in the project's vite.config.*
|
|
87
|
+
* a plain `vite build` produces the same zip (authors can add Vite plugins and options like any Vite project).
|
|
88
|
+
*
|
|
89
|
+
* - config: Vite options from package.json "ecdk" (root, outDir, minify, sourcemap). Every source HTML is an input
|
|
90
|
+
* (multi-page), `base: './'` (relative paths inside the sandbox iframe), output in `<outDir>/content/`
|
|
91
|
+
* - The SDK (@eliceio/cdk) is a package.json dependency bundled like any import; it is never copied as a file (ADR 0010)
|
|
92
|
+
* - generateBundle: copies source files the bundle did not use (metadata.json, commentary, data, images, …),
|
|
93
|
+
* inlines each page's module scripts (core/sandbox.ts) and drops the chunks, stamps metadata.json `build`
|
|
94
|
+
* - Checks (rules) read the sources; size limits read the real zip. On errors no zip is written
|
|
95
|
+
* - writeBundle: `<outDir>/content.zip` (and `this.error` on check errors unless the CLI reports them)
|
|
96
|
+
* - dev (configureServer · transformIndexHtml): files left out of the zip (answers, `.ecdk/`, …) get 404,
|
|
97
|
+
* and under `ecdk dev` the dev script is injected
|
|
98
|
+
*/
|
|
99
|
+
function ecdk(options = {}) {
|
|
100
|
+
const api = {
|
|
101
|
+
throwOnError: true
|
|
102
|
+
};
|
|
103
|
+
let projectDir = '';
|
|
104
|
+
let config;
|
|
105
|
+
let prepared;
|
|
106
|
+
let isBuild = false;
|
|
107
|
+
let pendingZip = null;
|
|
108
|
+
async function prepare() {
|
|
109
|
+
config = await loadConfig(projectDir);
|
|
110
|
+
prepared = await prepareContent(projectDir, config);
|
|
111
|
+
return prepared;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
name: ECDK_PLUGIN_NAME,
|
|
115
|
+
enforce: 'post',
|
|
116
|
+
api,
|
|
117
|
+
async config(user, env) {
|
|
118
|
+
isBuild = env.command === 'build';
|
|
119
|
+
projectDir = resolve(options.projectDir ?? user.root ?? process.cwd());
|
|
120
|
+
const p = await prepare();
|
|
121
|
+
const pages = p.files.filter(f => /\.html?$/i.test(f.path) && !p.publicFiles.has(f.path)).map(f => f.path);
|
|
122
|
+
if (isBuild && p.sdk.missing) throw new Error(missingSdkMessage());
|
|
123
|
+
return {
|
|
124
|
+
root: p.srcDir,
|
|
125
|
+
// Content opens under the material URL in a sandbox iframe, so output uses relative paths
|
|
126
|
+
// (ecdk dev passes its own content base)
|
|
127
|
+
...(isBuild ? {
|
|
128
|
+
base: './'
|
|
129
|
+
} : {}),
|
|
130
|
+
appType: 'mpa',
|
|
131
|
+
cacheDir: join(projectDir, 'node_modules', '.vite'),
|
|
132
|
+
build: {
|
|
133
|
+
outDir: join(p.outDir, 'content'),
|
|
134
|
+
emptyOutDir: true,
|
|
135
|
+
minify: config.minify !== false,
|
|
136
|
+
cssMinify: config.minify !== false,
|
|
137
|
+
// Chunks are inlined into the HTML, so their maps are inline too and chained there (core/sandbox.ts)
|
|
138
|
+
sourcemap: config.sourcemap === true ? 'inline' : false,
|
|
139
|
+
// modulepreload is a CORS request, blocked when the LXP content origin is null; chunks are inlined anyway
|
|
140
|
+
modulePreload: false,
|
|
141
|
+
reportCompressedSize: false,
|
|
142
|
+
// public/ files go into the output from generateBundle, following the zip rules (answers etc. excluded)
|
|
143
|
+
copyPublicDir: false,
|
|
144
|
+
rolldownOptions: {
|
|
145
|
+
input: Object.fromEntries(pages.map(page => [page, join(p.srcDir, page)])),
|
|
146
|
+
// Chunks are inlined and removed, but their names stay in the HTML (data-ecdk-bundle) and the digest:
|
|
147
|
+
// chunk hashes depend on the absolute project path, so chunks get stable names for reproducible zips
|
|
148
|
+
output: {
|
|
149
|
+
entryFileNames: 'assets/[name].js',
|
|
150
|
+
chunkFileNames: 'assets/[name].js'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
async buildStart() {
|
|
157
|
+
if (!isBuild) return;
|
|
158
|
+
pendingZip = null;
|
|
159
|
+
api.result = undefined;
|
|
160
|
+
await rm(join(prepared.outDir, 'content.zip'), {
|
|
161
|
+
force: true
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
generateBundle: {
|
|
165
|
+
order: 'post',
|
|
166
|
+
async handler(_options, bundle) {
|
|
167
|
+
const output = [];
|
|
168
|
+
for (const item of Object.values(bundle)) output.push({
|
|
169
|
+
path: item.fileName,
|
|
170
|
+
data: item.type === 'chunk' ? encoder.encode(item.code) : typeof item.source === 'string' ? encoder.encode(item.source) : item.source
|
|
171
|
+
});
|
|
172
|
+
// Besides the bundle: public/ files as they are, and the files metadata.json names (commentary)
|
|
173
|
+
const manifest = prepared.files.find(f => f.path === rules.manifest.file);
|
|
174
|
+
let commentary;
|
|
175
|
+
try {
|
|
176
|
+
commentary = manifest ? JSON.parse(decoder.decode(manifest.data)).commentary : undefined;
|
|
177
|
+
} catch {
|
|
178
|
+
// Malformed metadata.json is reported by the checks
|
|
179
|
+
}
|
|
180
|
+
const emitted = new Set(output.map(f => f.path));
|
|
181
|
+
for (const f of prepared.files) if (!emitted.has(f.path) && (prepared.publicFiles.has(f.path) || f.path === commentary)) output.push(f);
|
|
182
|
+
// Inline each page's module scripts (chunks) so pages load even when the LXP content origin is null
|
|
183
|
+
const sandboxed = await inlineModuleScripts(output, {
|
|
184
|
+
minify: config.minify !== false,
|
|
185
|
+
sourcemap: config.sourcemap === true
|
|
186
|
+
});
|
|
187
|
+
const chunks = new Set(Object.values(bundle).filter(item => item.type === 'chunk').map(item => item.fileName));
|
|
188
|
+
const content = sandboxed.files.filter(f => !chunks.has(f.path));
|
|
189
|
+
if (manifest) content.push(manifest);
|
|
190
|
+
// metadata.json build gets the minify flag and the digest of the final files (metadata.json excluded)
|
|
191
|
+
const digest = contentDigest(content);
|
|
192
|
+
const files = withBuildStamp(content, {
|
|
193
|
+
...(config.minify !== false ? {
|
|
194
|
+
minify: true
|
|
195
|
+
} : {}),
|
|
196
|
+
digest
|
|
197
|
+
});
|
|
198
|
+
// Replace the Vite bundle with the final output: update emitted assets in place,
|
|
199
|
+
// drop the inlined chunks, and emit the copied source files
|
|
200
|
+
const finalPaths = new Set(files.map(f => f.path));
|
|
201
|
+
for (const name of Object.keys(bundle)) if (!finalPaths.has(name)) delete bundle[name];
|
|
202
|
+
for (const f of files) {
|
|
203
|
+
const item = bundle[f.path];
|
|
204
|
+
if (item?.type === 'asset') item.source = f.data;else this.emitFile({
|
|
205
|
+
type: 'asset',
|
|
206
|
+
fileName: f.path,
|
|
207
|
+
source: f.data
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const zip = createZip(files);
|
|
211
|
+
const check = await checkBuild(projectDir, config, prepared, files, zip.byteLength);
|
|
212
|
+
pendingZip = zip;
|
|
213
|
+
api.result = {
|
|
214
|
+
ok: check.ok,
|
|
215
|
+
outDir: prepared.outDir,
|
|
216
|
+
zip: check.ok ? join(prepared.outDir, 'content.zip') : null,
|
|
217
|
+
zipBytes: zip.byteLength,
|
|
218
|
+
files: files.map(f => f.path),
|
|
219
|
+
excluded: prepared.excluded,
|
|
220
|
+
minify: config.minify !== false,
|
|
221
|
+
sandbox: sandboxed.report,
|
|
222
|
+
unreferenced: findUnreferenced(prepared.files, check.manifest),
|
|
223
|
+
digest,
|
|
224
|
+
check
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
async writeBundle() {
|
|
229
|
+
const result = api.result;
|
|
230
|
+
if (!result || !pendingZip) return;
|
|
231
|
+
if (result.ok && result.zip) {
|
|
232
|
+
await mkdir(dirname(result.zip), {
|
|
233
|
+
recursive: true
|
|
234
|
+
});
|
|
235
|
+
await writeFile(result.zip, pendingZip);
|
|
236
|
+
}
|
|
237
|
+
if (!api.throwOnError) return;
|
|
238
|
+
for (const issue of result.check.issues.filter(i => i.level !== 'error')) this.warn(`${issue.id}${issue.path ? ` ${issue.path}` : ''}: ${issue.message}`);
|
|
239
|
+
if (!result.ok) this.error(['검사 오류가 있어 zip을 만들지 않았습니다.', ...formatIssues(result.check)].join('\n'));
|
|
240
|
+
},
|
|
241
|
+
configureServer(server) {
|
|
242
|
+
// Files left out of the zip (answers, secrets, .ecdk, project files) are not served in dev either
|
|
243
|
+
let current = Promise.resolve(prepared);
|
|
244
|
+
server.watcher.on('all', () => {
|
|
245
|
+
current = prepare().catch(() => prepared);
|
|
246
|
+
});
|
|
247
|
+
const guard = (req, res, next) => {
|
|
248
|
+
const base = server.config.base;
|
|
249
|
+
const url = (req.url ?? '/').replace(/[?#].*$/, '');
|
|
250
|
+
if (!url.startsWith(base)) return next();
|
|
251
|
+
let path;
|
|
252
|
+
try {
|
|
253
|
+
path = decodeURIComponent(url.slice(base.length));
|
|
254
|
+
} catch {
|
|
255
|
+
return next();
|
|
256
|
+
}
|
|
257
|
+
// Vite internals (@vite/client, @fs, node_modules/.vite, …) pass through
|
|
258
|
+
if (path.startsWith('@') || path.startsWith('node_modules/')) return next();
|
|
259
|
+
void current.then(p => {
|
|
260
|
+
const hidden = path.startsWith('.') || [path, PUBLIC_DIR + path].some(at => p.excluded.some(e => at === e.path || at.startsWith(`${e.path}/`)));
|
|
261
|
+
if (!hidden) return next();
|
|
262
|
+
const line = `[404] ${path} (zip에 없는 파일)`;
|
|
263
|
+
if (api.log) api.log(line);else server.config.logger.warn(line);
|
|
264
|
+
res.statusCode = 404;
|
|
265
|
+
res.end('not found');
|
|
266
|
+
}, next);
|
|
267
|
+
};
|
|
268
|
+
server.middlewares.use(guard);
|
|
269
|
+
},
|
|
270
|
+
transformIndexHtml: {
|
|
271
|
+
order: 'post',
|
|
272
|
+
handler(html) {
|
|
273
|
+
// ecdk dev only: mock API address, console forwarding, CSP reports (never in the zip)
|
|
274
|
+
return !isBuild && api.devHost ? injectDevScript(html, api.devHost) : html;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/** Flattens Vite config `plugins` (nested arrays, promises, falsy entries) */
|
|
280
|
+
async function flattenPlugins(plugins) {
|
|
281
|
+
const value = await plugins;
|
|
282
|
+
if (Array.isArray(value)) return (await Promise.all(value.map(flattenPlugins))).flat();
|
|
283
|
+
return value && typeof value === 'object' && 'name' in value ? [value] : [];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { ECDK_PLUGIN_NAME, ecdk, flattenPlugins };
|
|
@@ -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 프로토콜과 맞지 않아 저장 · 제출이 안 될 수 있다 (
|
|
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;
|
|
@@ -231,7 +226,7 @@ function checkFiles(input, opts = {}) {
|
|
|
231
226
|
if (!exact.has(file)) add('manifest.entry-missing', `${spec.manifest.file}에 적은 ${mode} 화면 파일이 없습니다: ${file}`, spec.manifest.file);
|
|
232
227
|
}
|
|
233
228
|
const commentaryFile = manifest.commentary === undefined ? undefined : files.find(f => f.path === manifest.commentary);
|
|
234
|
-
// LXP 업로드는 학습 참고 내용이 없는 자료 본문을 거절한다 (
|
|
229
|
+
// LXP 업로드는 학습 참고 내용이 없는 자료 본문을 거절한다 (실제 업로드로 확인. 스펙은 선택이었음)
|
|
235
230
|
if ((manifest.kind ?? spec.manifest.defaultKind) !== 'description' && manifest.commentary === undefined) add('manifest.commentary-missing', `학습 참고 내용 파일이 없어 LXP 업로드가 거절됩니다. 프로젝트 맨 위에 ${spec.manifest.commentaryFile}(이 자료의 핵심 개념 · 활동 · 문제 의도, 정답 제외)을 만들고 ${spec.manifest.file}에 "commentary": "${spec.manifest.commentaryFile}"를 적어 주세요.`, spec.manifest.file);
|
|
236
231
|
if (manifest.commentary !== undefined && !commentaryFile) add('manifest.entry-missing', `${spec.manifest.file}에 적은 학습 참고 내용 파일이 없습니다: ${manifest.commentary}`, spec.manifest.file);
|
|
237
232
|
// LXP 학습 참고 내용 칸으로 옮길 텍스트라 UTF-8이어야 한다 (메모장 ANSI · EUC-KR 저장이면 깨짐)
|
|
@@ -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/csp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RulesSpec } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* 운영 콘텐츠 응답 CSP 초안 (
|
|
3
|
+
* 운영 콘텐츠 응답 CSP 초안 (서버에 제안한 값).
|
|
4
4
|
* 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
|
|
5
5
|
* (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
|
|
6
6
|
* - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
|
package/es/rules/csp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rules } from './spec.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* 운영 콘텐츠 응답 CSP 초안 (
|
|
4
|
+
* 운영 콘텐츠 응답 CSP 초안 (서버에 제안한 값).
|
|
5
5
|
* 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
|
|
6
6
|
* (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
|
|
7
7
|
* - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
|
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.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>;
|