okno 1.0.0-beta.6 → 1.0.0-beta.7
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/init.d.ts.map +1 -1
- package/dist/init.js +124 -90
- package/package.json +1 -1
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAkBA,KAAK,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;AAEpE,UAAU,QAAQ;IACjB,SAAS,EAAE,SAAS,CAAA;IACpB,yEAAyE;IACzE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,oFAAoF;IACpF,SAAS,EAAE,KAAK,GAAG,MAAM,CAAA;CACzB;AAiBD,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CA0B5C;AAED;;;mEAGmE;AACnE,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA8BrD;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,YAAwB,GAAG,OAAO,CAmB7E;AA2FD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWrD;AAED,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAgB/E;AA4CD,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAgH7C"}
|
package/dist/init.js
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import { join as
|
|
3
|
-
import { fileURLToPath as
|
|
4
|
-
|
|
1
|
+
import { existsSync as c, readFileSync as k, writeFileSync as p, mkdirSync as g } from "node:fs";
|
|
2
|
+
import { join as i, dirname as v } from "node:path";
|
|
3
|
+
import { fileURLToPath as y } from "node:url";
|
|
4
|
+
import { spawnSync as S } from "node:child_process";
|
|
5
|
+
const f = {
|
|
5
6
|
astro: ["astro.config.mjs", "astro.config.ts", "astro.config.js"],
|
|
6
7
|
sveltekit: ["vite.config.ts", "vite.config.js"],
|
|
7
8
|
nuxt: ["nuxt.config.ts", "nuxt.config.js"],
|
|
8
9
|
vite: ["vite.config.ts", "vite.config.js", "vite.config.mjs"]
|
|
9
10
|
};
|
|
10
|
-
function
|
|
11
|
-
for (const
|
|
12
|
-
const o =
|
|
13
|
-
if (
|
|
11
|
+
function m(t, e) {
|
|
12
|
+
for (const n of e) {
|
|
13
|
+
const o = i(t, n);
|
|
14
|
+
if (c(o)) return o;
|
|
14
15
|
}
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const e =
|
|
19
|
-
if (
|
|
18
|
+
function x(t) {
|
|
19
|
+
const e = i(t, "package.json"), n = {};
|
|
20
|
+
if (c(e))
|
|
20
21
|
try {
|
|
21
|
-
const
|
|
22
|
-
Object.assign(
|
|
22
|
+
const r = JSON.parse(k(e, "utf-8"));
|
|
23
|
+
Object.assign(n, r.dependencies, r.devDependencies);
|
|
23
24
|
} catch {
|
|
24
25
|
}
|
|
25
|
-
const o = (
|
|
26
|
-
return o("astro") ||
|
|
26
|
+
const o = (r) => r in n;
|
|
27
|
+
return o("astro") || m(t, f.astro) ? { framework: "astro", configPath: m(t, f.astro), pluginsAt: "vite" } : o("nuxt") ? { framework: "nuxt", configPath: m(t, f.nuxt), pluginsAt: "vite" } : o("@sveltejs/kit") ? { framework: "sveltekit", configPath: m(t, f.vite), pluginsAt: "top" } : o("vite") ? { framework: "vite", configPath: m(t, f.vite), pluginsAt: "top" } : { framework: "unknown", configPath: null, pluginsAt: "top" };
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
let e =
|
|
29
|
+
function A(t) {
|
|
30
|
+
let e = k(t, "utf-8");
|
|
30
31
|
if (/from\s*["']okno\/vite["']/.test(e)) return !0;
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
const o =
|
|
34
|
-
let
|
|
35
|
-
const a =
|
|
36
|
-
a ?
|
|
37
|
-
${a[1]}okno(),` :
|
|
38
|
-
const d = 'import { okno } from "okno/vite"',
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
e = e.slice(0,
|
|
42
|
-
` + d + e.slice(
|
|
32
|
+
const n = e.match(/\bplugins\s*:\s*\[/);
|
|
33
|
+
if (!n || n.index === void 0) return !1;
|
|
34
|
+
const o = n.index + n[0].length, r = e.slice(o);
|
|
35
|
+
let l;
|
|
36
|
+
const a = r.match(/^[^\S\n]*\n(\s*)/);
|
|
37
|
+
a ? l = `
|
|
38
|
+
${a[1]}okno(),` : r.trimStart().startsWith("]") ? l = "okno()" : l = "okno(), ", e = e.slice(0, o) + l + e.slice(o);
|
|
39
|
+
const d = 'import { okno } from "okno/vite"', s = [...e.matchAll(/^import .*$/gm)];
|
|
40
|
+
if (s.length) {
|
|
41
|
+
const u = s[s.length - 1], h = u.index + u[0].length;
|
|
42
|
+
e = e.slice(0, h) + `
|
|
43
|
+
` + d + e.slice(h);
|
|
43
44
|
} else
|
|
44
45
|
e = d + `
|
|
45
46
|
` + e;
|
|
46
|
-
return
|
|
47
|
+
return p(t, e), !0;
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
return
|
|
49
|
+
function C(t, e = "starter") {
|
|
50
|
+
const n = i(t, "okno"), o = i(n, "schema.ts");
|
|
51
|
+
return c(o) ? !1 : (g(n, { recursive: !0 }), e === "empty" ? (p(o, j), !0) : (g(i(n, "pages"), { recursive: !0 }), g(i(n, "globals"), { recursive: !0 }), p(o, w), p(i(n, "pages", "home.ts"), E), p(i(n, "globals", "meta.ts"), P), p(i(n, "globals", "navbar.ts"), R), p(i(n, "globals", "footer.ts"), T), !0));
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const j = `import type { Schema } from "okno"
|
|
53
54
|
|
|
54
55
|
export default {} satisfies Schema
|
|
55
|
-
`,
|
|
56
|
+
`, w = `import type { Schema } from "okno"
|
|
56
57
|
|
|
57
58
|
export default {
|
|
58
59
|
pages: {
|
|
@@ -102,13 +103,13 @@ export default {
|
|
|
102
103
|
},
|
|
103
104
|
},
|
|
104
105
|
} satisfies Schema
|
|
105
|
-
`,
|
|
106
|
+
`, E = `export default {
|
|
106
107
|
headline: "Hello from okno",
|
|
107
108
|
subhead: "Edit this on the page — press “e” or visit ?okno.",
|
|
108
109
|
body: "<p>This is your home page. Everything here is content in your repo.</p>",
|
|
109
110
|
image: null,
|
|
110
111
|
}
|
|
111
|
-
`,
|
|
112
|
+
`, P = `export default {
|
|
112
113
|
title: "My okno site",
|
|
113
114
|
description: "Built with okno — a Git-backed CMS with live editing.",
|
|
114
115
|
shareImage: null,
|
|
@@ -127,29 +128,52 @@ export default {
|
|
|
127
128
|
links: [{ link: { text: "Home", url: "/", external: false } }],
|
|
128
129
|
}
|
|
129
130
|
`;
|
|
130
|
-
function
|
|
131
|
-
const e = v(
|
|
132
|
-
if (!
|
|
133
|
-
const o =
|
|
134
|
-
return
|
|
131
|
+
function M(t) {
|
|
132
|
+
const e = v(y(import.meta.url)), n = i(e, "..", "skills", "connect-okno", "SKILL.md");
|
|
133
|
+
if (!c(n)) return null;
|
|
134
|
+
const o = i(".claude", "skills", "connect-okno", "SKILL.md"), r = i(t, o);
|
|
135
|
+
return c(r) ? null : (g(v(r), { recursive: !0 }), p(r, k(n, "utf-8")), o);
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
-
const
|
|
138
|
-
let
|
|
139
|
-
if (
|
|
137
|
+
function O(t, e) {
|
|
138
|
+
const n = e === "claude" ? ".mcp.json" : i(".cursor", "mcp.json"), o = i(t, n);
|
|
139
|
+
let r = { mcpServers: {} };
|
|
140
|
+
if (c(o))
|
|
140
141
|
try {
|
|
141
|
-
|
|
142
|
+
r = JSON.parse(k(o, "utf-8"));
|
|
142
143
|
} catch {
|
|
143
144
|
}
|
|
144
|
-
return
|
|
145
|
-
`),
|
|
145
|
+
return r.mcpServers ??= {}, r.mcpServers.okno = { command: "npx", args: ["okno", "mcp"] }, g(i(o, ".."), { recursive: !0 }), p(o, JSON.stringify(r, null, 2) + `
|
|
146
|
+
`), n;
|
|
147
|
+
}
|
|
148
|
+
function N(t) {
|
|
149
|
+
return c(i(t, "bun.lock")) || c(i(t, "bun.lockb")) ? "bun" : c(i(t, "pnpm-lock.yaml")) ? "pnpm" : c(i(t, "yarn.lock")) ? "yarn" : "npm";
|
|
150
|
+
}
|
|
151
|
+
function $() {
|
|
152
|
+
try {
|
|
153
|
+
const t = v(y(import.meta.url));
|
|
154
|
+
return JSON.parse(k(i(t, "..", "package.json"), "utf-8")).version ?? "";
|
|
155
|
+
} catch {
|
|
156
|
+
return "";
|
|
157
|
+
}
|
|
146
158
|
}
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
function I(t) {
|
|
160
|
+
try {
|
|
161
|
+
const e = JSON.parse(k(i(t, "package.json"), "utf-8"));
|
|
162
|
+
return !!(e.dependencies?.okno || e.devDependencies?.okno);
|
|
163
|
+
} catch {
|
|
164
|
+
return !1;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function H(t, e) {
|
|
168
|
+
const n = $(), o = n ? `okno@${n}` : "okno", r = e === "npm" ? ["install", o] : ["add", o], l = `${e} ${r.join(" ")}`;
|
|
169
|
+
return S(e, r, { cwd: t, stdio: "inherit", shell: process.platform === "win32" }).status === 0 ? l : null;
|
|
170
|
+
}
|
|
171
|
+
async function V() {
|
|
172
|
+
const t = process.cwd(), e = await import("@clack/prompts");
|
|
149
173
|
e.intro("okno init");
|
|
150
|
-
let
|
|
151
|
-
if (
|
|
152
|
-
const
|
|
174
|
+
let n = x(t);
|
|
175
|
+
if (n.framework === "unknown") {
|
|
176
|
+
const s = await e.select({
|
|
153
177
|
message: "Which framework is this project?",
|
|
154
178
|
options: [
|
|
155
179
|
{ value: "astro", label: "Astro" },
|
|
@@ -158,23 +182,13 @@ async function H() {
|
|
|
158
182
|
{ value: "nuxt", label: "Nuxt" }
|
|
159
183
|
]
|
|
160
184
|
});
|
|
161
|
-
if (e.isCancel(
|
|
162
|
-
const
|
|
163
|
-
|
|
185
|
+
if (e.isCancel(s)) return e.cancel("Cancelled.");
|
|
186
|
+
const u = s, h = u === "astro" || u === "nuxt" ? "vite" : "top", b = f[u] ?? f.vite;
|
|
187
|
+
n = { framework: u, configPath: m(t, b), pluginsAt: h };
|
|
164
188
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{ value: "claude", label: "Claude Code", hint: ".mcp.json + connect-okno skill" },
|
|
169
|
-
{ value: "cursor", label: "Cursor", hint: ".cursor/mcp.json" },
|
|
170
|
-
{ value: "skip", label: "Skip", hint: "no AI editor" }
|
|
171
|
-
],
|
|
172
|
-
initialValue: "claude"
|
|
173
|
-
});
|
|
174
|
-
if (e.isCancel(o)) return e.cancel("Cancelled.");
|
|
175
|
-
let i = "starter";
|
|
176
|
-
if (!f(s(n, "okno", "schema.ts"))) {
|
|
177
|
-
const r = await e.select({
|
|
189
|
+
let o = "starter";
|
|
190
|
+
if (!c(i(t, "okno", "schema.ts"))) {
|
|
191
|
+
const s = await e.select({
|
|
178
192
|
message: "Scaffold a Starter, or an empty schema?",
|
|
179
193
|
options: [
|
|
180
194
|
{ value: "starter", label: "Starter", hint: "Home + Meta/Navbar/Footer globals, ready to edit" },
|
|
@@ -182,40 +196,60 @@ async function H() {
|
|
|
182
196
|
],
|
|
183
197
|
initialValue: "starter"
|
|
184
198
|
});
|
|
185
|
-
if (e.isCancel(
|
|
186
|
-
|
|
199
|
+
if (e.isCancel(s)) return e.cancel("Cancelled.");
|
|
200
|
+
o = s;
|
|
187
201
|
}
|
|
202
|
+
const l = await e.select({
|
|
203
|
+
message: "Set up the okno MCP server for your AI editor? (optional)",
|
|
204
|
+
options: [
|
|
205
|
+
{ value: "skip", label: "Skip", hint: "default — add later with `okno mcp`" },
|
|
206
|
+
{ value: "claude", label: "Claude Code", hint: ".mcp.json + connect-okno skill" },
|
|
207
|
+
{ value: "cursor", label: "Cursor", hint: ".cursor/mcp.json" }
|
|
208
|
+
],
|
|
209
|
+
initialValue: "skip"
|
|
210
|
+
});
|
|
211
|
+
if (e.isCancel(l)) return e.cancel("Cancelled.");
|
|
188
212
|
const a = [];
|
|
213
|
+
if (I(t))
|
|
214
|
+
a.push("• okno already a dependency — skipped install");
|
|
215
|
+
else {
|
|
216
|
+
const s = N(t);
|
|
217
|
+
e.log.step(`Installing okno with ${s}…`);
|
|
218
|
+
const u = H(t, s);
|
|
219
|
+
a.push(
|
|
220
|
+
u ? `✓ Installed okno (${u})` : `! Couldn't install okno automatically — run \`${s === "npm" ? "npm install" : `${s} add`} okno\` yourself`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
189
223
|
let d = !1;
|
|
190
|
-
if (
|
|
191
|
-
a.push(`✓ Added okno() to ${
|
|
224
|
+
if (n.configPath && (d = A(n.configPath)), d)
|
|
225
|
+
a.push(`✓ Added okno() to ${n.configPath.replace(t + "/", "")}`);
|
|
192
226
|
else {
|
|
193
|
-
const
|
|
227
|
+
const s = n.pluginsAt === "vite" ? `import { okno } from "okno/vite"
|
|
194
228
|
// inside defineConfig:
|
|
195
229
|
// vite: { plugins: [okno()] }` : `import { okno } from "okno/vite"
|
|
196
230
|
// inside defineConfig:
|
|
197
231
|
// plugins: [okno()]`;
|
|
198
232
|
a.push(`! Couldn't edit your config automatically — add okno() yourself:
|
|
199
|
-
${
|
|
233
|
+
${s}`);
|
|
200
234
|
}
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
) : a.push("• okno/ already exists — left it alone"),
|
|
204
|
-
const
|
|
205
|
-
a.push(`✓ Registered the okno MCP server in ${
|
|
235
|
+
if (C(t, o) ? a.push(
|
|
236
|
+
o === "starter" ? "✓ Scaffolded the okno Starter (Home + Meta/Navbar/Footer globals)" : "✓ Scaffolded an empty okno/ (schema only — nothing else)"
|
|
237
|
+
) : a.push("• okno/ already exists — left it alone"), l !== "skip") {
|
|
238
|
+
const s = O(t, l);
|
|
239
|
+
a.push(`✓ Registered the okno MCP server in ${s}`);
|
|
206
240
|
}
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
|
|
241
|
+
if (l === "claude") {
|
|
242
|
+
const s = M(t);
|
|
243
|
+
s && a.push(`✓ Installed the connect-okno skill in ${s}`);
|
|
210
244
|
}
|
|
211
245
|
e.note(a.join(`
|
|
212
246
|
`), "Done"), e.outro("Run your dev server and press “e” (or visit ?okno) to open the editor.");
|
|
213
247
|
}
|
|
214
248
|
export {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
249
|
+
A as addPlugin,
|
|
250
|
+
x as detect,
|
|
251
|
+
V as runInit,
|
|
252
|
+
C as scaffold,
|
|
253
|
+
O as writeMcpConfig,
|
|
254
|
+
M as writeSkill
|
|
221
255
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "okno",
|
|
3
3
|
"description": "Git-backed CMS with live editing for any Vite framework",
|
|
4
4
|
"author": "Gabriel Uhlíř",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.7",
|
|
6
6
|
"homepage": "https://okno.build",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./dist/index.d.ts",
|