@joplo-app/server 0.2.12 → 0.2.14
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/dist/build.d.ts +2 -2
- package/dist/build.js +5 -5
- package/dist/feature-diff-locales.json +882 -0
- package/dist/feature-diff-runtime.js +427 -0
- package/dist/feature-diff-viewer.d.ts +3 -0
- package/dist/feature-diff-viewer.js +130 -0
- package/dist/feature-diff.d.ts +14 -0
- package/dist/feature-diff.js +56 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { cp, lstat, mkdir, readFile, readdir, realpath, rename, rm, mkdtemp } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve, sep } from 'node:path';
|
|
3
|
+
import { readFeatureDiffBuild, featureDiff, JoploError } from '@joplo-app/core';
|
|
4
|
+
import { writeFile } from 'node:fs/promises';
|
|
5
|
+
import { diffViewerHtml } from "./feature-diff-viewer.js";
|
|
6
|
+
export const publicIRFromHtml = readFeatureDiffBuild;
|
|
7
|
+
/** Copy only a build's public payload; no project files, review attachments or symlinks. */
|
|
8
|
+
async function checkFiles(dir, prefix = '') {
|
|
9
|
+
for (const e of await readdir(dir, { withFileTypes: true })) {
|
|
10
|
+
const relative = prefix + e.name;
|
|
11
|
+
if (e.isSymbolicLink() || /[\\?#%\x00-\x1f\x7f]/.test(e.name) || (!prefix && !['index.html', 'assets', 'fonts', 'voice', '_joplo'].includes(e.name)))
|
|
12
|
+
throw new JoploError('INVALID_SCHEMA', `Not a standalone public build: ${relative}`);
|
|
13
|
+
if (e.isDirectory())
|
|
14
|
+
await checkFiles(join(dir, e.name), relative + '/');
|
|
15
|
+
else if (!e.isFile())
|
|
16
|
+
throw new JoploError('INVALID_SCHEMA', 'Build contains a non-regular file');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function buildFeatureDiff(opts) {
|
|
20
|
+
const before = await realpath(opts.beforeDir), after = await realpath(opts.afterDir);
|
|
21
|
+
// Never clear an existing directory. Validate both builds before creating any output.
|
|
22
|
+
const output = resolve(opts.outDir);
|
|
23
|
+
await mkdir(dirname(output), { recursive: true });
|
|
24
|
+
const outDir = join(await realpath(dirname(output)), output.slice(dirname(output).length + 1));
|
|
25
|
+
if ([before, after].some(p => outDir === p || p.startsWith(outDir + sep) || outDir.startsWith(p + sep)))
|
|
26
|
+
throw new JoploError('USAGE', 'Diff output must be separate from both input sites');
|
|
27
|
+
try {
|
|
28
|
+
await lstat(outDir);
|
|
29
|
+
throw new JoploError('USAGE', 'Diff output already exists; choose a new directory');
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (e.code !== 'ENOENT')
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
await checkFiles(before);
|
|
36
|
+
await checkFiles(after);
|
|
37
|
+
const beforeHtml = await readFile(join(before, 'index.html'), 'utf8'), afterHtml = await readFile(join(after, 'index.html'), 'utf8');
|
|
38
|
+
let m = featureDiff(publicIRFromHtml(beforeHtml), publicIRFromHtml(afterHtml), opts);
|
|
39
|
+
if (![beforeHtml, afterHtml].every(html => html.includes('<meta name="joplo-feature-diff-player" content="1">'))) {
|
|
40
|
+
m = { ...m, status: 'incompatible', reasons: [...m.reasons, 'player-version'], scenarios: [], summary: { added: [], modified: [], removed: [] } };
|
|
41
|
+
}
|
|
42
|
+
const staging = await mkdtemp(join(dirname(outDir), '.joplo-diff-'));
|
|
43
|
+
try {
|
|
44
|
+
if (m.status !== 'incompatible') {
|
|
45
|
+
await cp(before, join(staging, 'before'), { recursive: true, dereference: false });
|
|
46
|
+
await cp(after, join(staging, 'after'), { recursive: true, dereference: false });
|
|
47
|
+
}
|
|
48
|
+
await writeFile(join(staging, 'feature-diff.json'), JSON.stringify(m, null, 2) + '\n');
|
|
49
|
+
await writeFile(join(staging, 'index.html'), diffViewerHtml(m));
|
|
50
|
+
await rename(staging, outDir);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await rm(staging, { recursive: true, force: true });
|
|
54
|
+
}
|
|
55
|
+
return { outDir, manifest: m };
|
|
56
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { startDev } from './dev.js';
|
|
|
11
11
|
export { buildSite } from './build.js';
|
|
12
12
|
export { renderStep } from './render.js';
|
|
13
13
|
export { EXPORT_DOWNLOAD_MB, PLAYWRIGHT_VERSION, SETUP_COMMAND, exportRuntimeStatus, installExportRuntime, uninstallExportRuntime, type ExportRuntimeStatus, type InstallProgress, type InstallResult } from './export-runtime.js';
|
|
14
|
+
export { buildFeatureDiff, publicIRFromHtml, type DiffBuildOptions, type DiffBuildResult } from './feature-diff.js';
|
package/dist/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { startDev } from "./dev.js";
|
|
|
2
2
|
export { buildSite } from "./build.js";
|
|
3
3
|
export { renderStep } from "./render.js";
|
|
4
4
|
export { EXPORT_DOWNLOAD_MB, PLAYWRIGHT_VERSION, SETUP_COMMAND, exportRuntimeStatus, installExportRuntime, uninstallExportRuntime } from "./export-runtime.js";
|
|
5
|
+
export { buildFeatureDiff, publicIRFromHtml } from "./feature-diff.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "Joplo 本地服务:dev 看板、build 发布站、render 截图",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@joplo-app/core": "0.2.
|
|
19
|
-
"@joplo-app/kit": "0.2.
|
|
20
|
-
"@joplo-app/web": "0.2.
|
|
18
|
+
"@joplo-app/core": "0.2.14",
|
|
19
|
+
"@joplo-app/kit": "0.2.14",
|
|
20
|
+
"@joplo-app/web": "0.2.14",
|
|
21
21
|
"@tailwindcss/vite": "4.3.4",
|
|
22
22
|
"tailwindcss": "4.3.4",
|
|
23
23
|
"vite": "8.3.5",
|
|
24
24
|
"zod": "4.6.7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@joplo-app/core-legacy": "npm:@joplo-app/core@0.2.10",
|
|
27
28
|
"@vitejs/plugin-react": "6.2.1",
|
|
28
29
|
"playwright": "1.64.1",
|
|
29
30
|
"playwright-core": "1.64.1"
|