@wix/ditto-codegen-public 1.0.472 → 1.0.474
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/opencode-tools/validate.ts +49 -2
- package/dist/out.js +748 -177
- package/package.json +2 -2
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
|
+
import { readdir } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const EDITOR_COMPONENTS_DIR = "src/extensions/site/components";
|
|
6
|
+
|
|
7
|
+
async function containsTypeScriptFile(directory: string): Promise<boolean> {
|
|
8
|
+
let entries;
|
|
9
|
+
try {
|
|
10
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
const path = join(directory, entry.name);
|
|
18
|
+
if (entry.isDirectory() && (await containsTypeScriptFile(path))) return true;
|
|
19
|
+
if (entry.isFile() && /\.tsx?$/.test(entry.name)) return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
2
23
|
|
|
3
24
|
export default tool({
|
|
4
25
|
description:
|
|
5
|
-
"Run project validation: TypeScript check by default, optionally a full build
|
|
26
|
+
"Run project validation: TypeScript check by default, optionally a full build " +
|
|
27
|
+
"and editor-component manifest generation. " +
|
|
6
28
|
"Use this instead of running npm install, tsc, and wix build separately.",
|
|
7
29
|
args: {
|
|
8
30
|
installDeps: tool.schema
|
|
@@ -18,7 +40,8 @@ export default tool({
|
|
|
18
40
|
.boolean()
|
|
19
41
|
.optional()
|
|
20
42
|
.describe(
|
|
21
|
-
"Default false (tsc only). Pass true to also run `wix build
|
|
43
|
+
"Default false (tsc only). Pass true to also run `wix build` and generate " +
|
|
44
|
+
"manifests when editor components exist. validate " +
|
|
22
45
|
"runs tsc FIRST and builds only if tsc passes, so pass runBuild: true on " +
|
|
23
46
|
"the FIRST call to typecheck+build in one pass — it fails fast on type " +
|
|
24
47
|
"errors before the ~20s build, so a separate tsc-only call is redundant. " +
|
|
@@ -67,6 +90,30 @@ export default tool({
|
|
|
67
90
|
}
|
|
68
91
|
steps.push("wix build: OK");
|
|
69
92
|
|
|
93
|
+
const hasEditorComponents = await containsTypeScriptFile(
|
|
94
|
+
join(cwd, EDITOR_COMPONENTS_DIR),
|
|
95
|
+
);
|
|
96
|
+
if (!hasEditorComponents) {
|
|
97
|
+
steps.push(
|
|
98
|
+
"wix generate manifest: skipped (no editor components)",
|
|
99
|
+
);
|
|
100
|
+
return steps.join("\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const manifest = await Bun.$`npx wix generate manifest`
|
|
104
|
+
.cwd(cwd)
|
|
105
|
+
.nothrow()
|
|
106
|
+
.quiet();
|
|
107
|
+
if (manifest.exitCode !== 0) {
|
|
108
|
+
return [
|
|
109
|
+
...steps,
|
|
110
|
+
`FAILED at wix generate manifest (exit ${manifest.exitCode}):`,
|
|
111
|
+
manifest.stdout.toString(),
|
|
112
|
+
manifest.stderr.toString(),
|
|
113
|
+
].join("\n");
|
|
114
|
+
}
|
|
115
|
+
steps.push("wix generate manifest: OK");
|
|
116
|
+
|
|
70
117
|
return steps.join("\n");
|
|
71
118
|
},
|
|
72
119
|
});
|