@rafters/veneer 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +20 -0
- package/dist/check-DxTxqBre.mjs +156 -0
- package/dist/index.d.mts +82 -0
- package/dist/index.mjs +3 -0
- package/dist/lint-BabXVYQJ.mjs +1024 -0
- package/dist/tokens-CYaadJgI.mjs +16875 -0
- package/dist/worker.d.mts +1 -0
- package/dist/worker.mjs +112 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/worker.mjs
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { o as openProject, s as readConfig, t as lint } from "./lint-BabXVYQJ.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { execFile } from "node:child_process";
|
|
6
|
+
import { createInterface } from "node:readline";
|
|
7
|
+
//#region src/worker.ts
|
|
8
|
+
const SILENCE = "console.log = console.info = console.debug = () => {};";
|
|
9
|
+
console.log = console.info = console.debug = () => {};
|
|
10
|
+
const run = promisify(execFile);
|
|
11
|
+
const write = (message) => {
|
|
12
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
13
|
+
};
|
|
14
|
+
const messages = (errors) => errors.map((e) => e.message).join("; ");
|
|
15
|
+
async function save(root) {
|
|
16
|
+
const index = new URL("./index.mjs", import.meta.url).href;
|
|
17
|
+
const script = `${SILENCE}
|
|
18
|
+
const { check } = await import(${JSON.stringify(index)});
|
|
19
|
+
process.stdout.write(JSON.stringify(await check(${JSON.stringify(root)}, { save: true })));
|
|
20
|
+
`;
|
|
21
|
+
const { stdout } = await run(process.execPath, [
|
|
22
|
+
"--input-type=module",
|
|
23
|
+
"--eval",
|
|
24
|
+
script
|
|
25
|
+
], { maxBuffer: Number.POSITIVE_INFINITY });
|
|
26
|
+
const result = JSON.parse(stdout);
|
|
27
|
+
if (!result.ok) throw new Error(messages(result.errors));
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
async function serve(root) {
|
|
31
|
+
const config = await readConfig(root);
|
|
32
|
+
if (!config.ok) throw new Error(messages(config.errors));
|
|
33
|
+
const { componentFolders } = config;
|
|
34
|
+
let project = await openProject(root);
|
|
35
|
+
const unsaved = /* @__PURE__ */ new Map();
|
|
36
|
+
const outside = /* @__PURE__ */ new Set();
|
|
37
|
+
const isRoot = (file) => project.checker.getRootFileNames().includes(path.join(project.root, file));
|
|
38
|
+
let isOpen = true;
|
|
39
|
+
const reopen = async () => {
|
|
40
|
+
if (isOpen) project.close();
|
|
41
|
+
isOpen = false;
|
|
42
|
+
project = await openProject(root, { unsaved: Object.fromEntries(unsaved) });
|
|
43
|
+
isOpen = true;
|
|
44
|
+
};
|
|
45
|
+
const lintText = async (file, text) => {
|
|
46
|
+
if (outside.has(file)) return [];
|
|
47
|
+
unsaved.set(file, text);
|
|
48
|
+
if (!isOpen) await reopen();
|
|
49
|
+
if (isRoot(file)) project.setUnsaved(file, text);
|
|
50
|
+
else {
|
|
51
|
+
await reopen();
|
|
52
|
+
if (!isRoot(file)) {
|
|
53
|
+
outside.add(file);
|
|
54
|
+
unsaved.delete(file);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return lint(project, {
|
|
59
|
+
componentFolders,
|
|
60
|
+
files: [file]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
write({ ready: true });
|
|
64
|
+
for await (const raw of createInterface({ input: process.stdin })) {
|
|
65
|
+
const line = JSON.parse(raw);
|
|
66
|
+
const { seq } = line;
|
|
67
|
+
try {
|
|
68
|
+
if ("save" in line) {
|
|
69
|
+
const { diagnostics } = await save(root);
|
|
70
|
+
write({
|
|
71
|
+
seq,
|
|
72
|
+
files: Object.groupBy(diagnostics, ({ file }) => file)
|
|
73
|
+
});
|
|
74
|
+
} else if ("close" in line) {
|
|
75
|
+
const file = line.close;
|
|
76
|
+
unsaved.delete(file);
|
|
77
|
+
outside.delete(file);
|
|
78
|
+
if (!isOpen) await reopen();
|
|
79
|
+
if (isRoot(file)) {
|
|
80
|
+
if (existsSync(path.join(project.root, file))) project.clearUnsaved(file);
|
|
81
|
+
else await reopen();
|
|
82
|
+
}
|
|
83
|
+
write({
|
|
84
|
+
seq,
|
|
85
|
+
file,
|
|
86
|
+
diagnostics: []
|
|
87
|
+
});
|
|
88
|
+
} else write({
|
|
89
|
+
seq,
|
|
90
|
+
file: line.file,
|
|
91
|
+
diagnostics: await lintText(line.file, line.text)
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
write({
|
|
95
|
+
seq,
|
|
96
|
+
error: error instanceof Error ? error.message : String(error)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
await serve(path.resolve(process.argv[2] ?? ""));
|
|
103
|
+
process.exit(0);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
write({
|
|
106
|
+
ready: false,
|
|
107
|
+
message: error instanceof Error ? error.message : String(error)
|
|
108
|
+
});
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rafters/veneer",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Docs, rafters check and the composite compile for rafters projects",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/rafters-studio/veneer"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"rafters-check": "./dist/bin.mjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./worker": "./dist/worker.mjs",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@astrojs/language-server": "2.17.3",
|
|
30
|
+
"@volar/kit": "2.4.30",
|
|
31
|
+
"typescript": "6.0.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"apca-w3": "0.1.9",
|
|
35
|
+
"colorjs.io": "0.5.2",
|
|
36
|
+
"comment-parser": "1.4.1",
|
|
37
|
+
"rafters-monorepo": "github:rafters-studio/rafters#e39634e2ad75b3b33fb42cbe958261549e6f0480",
|
|
38
|
+
"vite-plus": "1.0.0",
|
|
39
|
+
"zod": "^4.6.5"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=24.0.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vp pack && node scripts/assert-dist.ts dist",
|
|
46
|
+
"check": "vp check"
|
|
47
|
+
}
|
|
6
48
|
}
|
package/README.md
DELETED