@lunora/vite 0.0.0 → 1.0.0-alpha.1
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.md +105 -0
- package/README.md +117 -9
- package/__assets__/package-og.svg +14 -0
- package/dist/index.d.mts +374 -0
- package/dist/index.d.ts +374 -0
- package/dist/index.mjs +153 -0
- package/dist/packem_shared/augmentWorkerStartupError-DhsXUW8k.mjs +81 -0
- package/dist/packem_shared/buildStudioUrl-5ppCdBHa.mjs +210 -0
- package/dist/packem_shared/codegenPlugin-BAyt6iWS.mjs +210 -0
- package/dist/packem_shared/createCommandProbe-Coo6bgVz.mjs +36 -0
- package/dist/packem_shared/devVariablesPlugin-BRWbWHhq.mjs +20 -0
- package/dist/packem_shared/frameworkComposePlugin-Cja0SF6x.mjs +96 -0
- package/dist/packem_shared/logStreamPlugin-CqvZ17kd.mjs +61 -0
- package/dist/packem_shared/planViteRemoteBindings-QN5ncUS1.mjs +50 -0
- package/dist/packem_shared/reconcileWranglerCrons-PxGwfCp_.mjs +29 -0
- package/dist/packem_shared/wranglerValidatorPlugin-Cf0nLP7-.mjs +63 -0
- package/package.json +53 -17
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { findWranglerFile, readWranglerJsonc } from '@lunora/config';
|
|
3
|
+
import { modify, applyEdits } from 'jsonc-parser';
|
|
4
|
+
|
|
5
|
+
const sameTriggers = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
6
|
+
const reconcileWranglerCrons = (projectRoot, cronTriggers) => {
|
|
7
|
+
const wranglerPath = findWranglerFile(projectRoot);
|
|
8
|
+
if (!wranglerPath) {
|
|
9
|
+
return { changed: false, reason: "wrangler.jsonc not found" };
|
|
10
|
+
}
|
|
11
|
+
const { parsed, text } = readWranglerJsonc(wranglerPath);
|
|
12
|
+
if (parsed === void 0) {
|
|
13
|
+
return { changed: false, reason: `failed to parse ${wranglerPath} as JSONC`, wranglerPath };
|
|
14
|
+
}
|
|
15
|
+
const existing = Array.isArray(parsed.triggers?.crons) ? parsed.triggers.crons.filter((value) => typeof value === "string") : [];
|
|
16
|
+
if (sameTriggers(existing, cronTriggers)) {
|
|
17
|
+
return { changed: false, reason: "triggers.crons already in sync", wranglerPath };
|
|
18
|
+
}
|
|
19
|
+
const edits = modify(text, ["triggers", "crons"], [...cronTriggers], {
|
|
20
|
+
formattingOptions: { insertSpaces: true, tabSize: 4 }
|
|
21
|
+
});
|
|
22
|
+
if (edits.length === 0) {
|
|
23
|
+
return { changed: false, reason: "no structural edit produced", wranglerPath };
|
|
24
|
+
}
|
|
25
|
+
writeFileSync(wranglerPath, applyEdits(text, edits), "utf8");
|
|
26
|
+
return { changed: true, wranglerPath };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { reconcileWranglerCrons };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { validateWranglerProject, readWranglerJsonc } from '@lunora/config';
|
|
3
|
+
|
|
4
|
+
const isLocalImagePath = (image) => image.startsWith("./") || image.startsWith("../") || image.startsWith("/") || image.includes("Dockerfile");
|
|
5
|
+
const probeDocker = () => {
|
|
6
|
+
try {
|
|
7
|
+
return spawnSync("docker", ["info"], { stdio: "ignore" }).status === 0;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const warnWhenDockerMissing = (wranglerPath, dockerAvailable = probeDocker) => {
|
|
13
|
+
const { parsed } = readWranglerJsonc(wranglerPath);
|
|
14
|
+
const needsDocker = (parsed?.containers ?? []).some((entry) => typeof entry?.image === "string" && isLocalImagePath(entry.image));
|
|
15
|
+
if (!needsDocker || dockerAvailable()) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.warn(
|
|
19
|
+
"[lunora] wrangler.jsonc declares containers built from a local Dockerfile, but no Docker-compatible engine is running. Start Docker (or Colima) before `vite dev`, or the container instances will fail to start."
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
const formatError = (wranglerPath, problems) => {
|
|
23
|
+
const lines = [
|
|
24
|
+
"[lunora] wrangler configuration is missing bindings required by your schema.",
|
|
25
|
+
` file: ${wranglerPath}`,
|
|
26
|
+
"",
|
|
27
|
+
...problems.map((problem) => ` - ${problem}`),
|
|
28
|
+
"",
|
|
29
|
+
" Update your wrangler.jsonc and restart the dev server."
|
|
30
|
+
];
|
|
31
|
+
return new Error(lines.join("\n"));
|
|
32
|
+
};
|
|
33
|
+
const wranglerValidatorPlugin = (options) => {
|
|
34
|
+
return {
|
|
35
|
+
configResolved() {
|
|
36
|
+
const result = validateWranglerProject({
|
|
37
|
+
projectRoot: options.projectRoot,
|
|
38
|
+
schemaDir: options.schemaDir
|
|
39
|
+
});
|
|
40
|
+
if (!result.wranglerPath) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
[
|
|
43
|
+
"[lunora] wrangler.jsonc not found.",
|
|
44
|
+
` searched in: ${options.projectRoot}`,
|
|
45
|
+
" create a wrangler.jsonc declaring at least the SHARD durable object binding."
|
|
46
|
+
].join("\n")
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (result.report.warnings.length > 0) {
|
|
50
|
+
for (const warning of result.report.warnings) {
|
|
51
|
+
console.warn(`[lunora] wrangler validator: ${warning}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (result.problems.length > 0) {
|
|
55
|
+
throw formatError(result.wranglerPath, result.problems);
|
|
56
|
+
}
|
|
57
|
+
warnWhenDockerMissing(result.wranglerPath);
|
|
58
|
+
},
|
|
59
|
+
name: "lunora:wrangler-validator"
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { warnWhenDockerMissing, wranglerValidatorPlugin };
|
package/package.json
CHANGED
|
@@ -1,31 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "The Lunora Vite plugin: codegen, type sync, wrangler validation, and an error overlay over @cloudflare/vite-plugin",
|
|
5
|
-
"license": "FSL-1.1-Apache-2.0",
|
|
6
|
-
"homepage": "https://lunora.sh",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/anolilab/lunora.git",
|
|
10
|
-
"directory": "packages/vite"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/anolilab/lunora/issues"
|
|
14
|
-
},
|
|
15
5
|
"keywords": [
|
|
16
|
-
"lunora",
|
|
17
6
|
"cloudflare",
|
|
18
|
-
"
|
|
7
|
+
"codegen",
|
|
19
8
|
"durable-objects",
|
|
9
|
+
"lunora",
|
|
20
10
|
"vite",
|
|
21
11
|
"vite-plugin",
|
|
22
|
-
"
|
|
12
|
+
"workers",
|
|
23
13
|
"wrangler"
|
|
24
14
|
],
|
|
15
|
+
"homepage": "https://lunora.sh",
|
|
16
|
+
"bugs": "https://github.com/anolilab/lunora/issues",
|
|
17
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Daniel Bannert",
|
|
20
|
+
"email": "d.bannert@anolilab.de"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/anolilab/lunora.git",
|
|
25
|
+
"directory": "packages/vite"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"__assets__",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE.md"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"module": "./dist/index.mjs",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
25
44
|
"publishConfig": {
|
|
26
45
|
"access": "public"
|
|
27
46
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@cloudflare/vite-plugin": "1.42.0",
|
|
49
|
+
"@lunora/codegen": "1.0.0-alpha.1",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.1",
|
|
51
|
+
"@visulima/vite-overlay": "2.0.0-alpha.35",
|
|
52
|
+
"jsonc-parser": "^3.3.1",
|
|
53
|
+
"ts-morph": "^28.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@lunora/studio": "1.0.0-alpha.1",
|
|
57
|
+
"vite": "^8.0.16"
|
|
58
|
+
},
|
|
59
|
+
"peerDependenciesMeta": {
|
|
60
|
+
"@lunora/studio": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": "^22.15.0 || >=24.11.0"
|
|
66
|
+
}
|
|
31
67
|
}
|