opacacms 0.3.2 → 0.3.4

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.
Files changed (58) hide show
  1. package/dist/admin/index.js +1 -1
  2. package/dist/admin/react.js +1 -1
  3. package/dist/admin/vue.js +1 -1
  4. package/dist/admin/webcomponent.js +35 -37
  5. package/dist/{chunk-g9bxb6h0.js → chunk-2fm4kv2q.js} +1 -1
  6. package/dist/chunk-2vbfc4q8.js +6 -0
  7. package/dist/{chunk-adq2b75c.js → chunk-40tky6qh.js} +2 -2
  8. package/dist/{chunk-e0g6gn7n.js → chunk-49e16hjg.js} +3 -3
  9. package/dist/{chunk-fnsf1dfm.js → chunk-526a3gqx.js} +1 -1
  10. package/dist/{chunk-sqsfk9p4.js → chunk-6m1jhxmd.js} +1 -1
  11. package/dist/{chunk-6bywt602.js → chunk-8sqjbsgt.js} +1 -26
  12. package/dist/{chunk-n1twhqmf.js → chunk-acghejk8.js} +1 -1
  13. package/dist/{chunk-m24yqkeq.js → chunk-b1g8jmth.js} +3 -3
  14. package/dist/{chunk-5422w4eq.js → chunk-cm5rvcnn.js} +5 -5
  15. package/dist/{chunk-941zxavt.js → chunk-h2y2t07h.js} +4 -4
  16. package/dist/{chunk-6qs0g65f.js → chunk-h8v093av.js} +1 -1
  17. package/dist/{chunk-m5ems3hh.js → chunk-hthm9srb.js} +1 -1
  18. package/dist/{chunk-2k3ysje3.js → chunk-nch158fe.js} +1 -1
  19. package/dist/{chunk-naqcqj8n.js → chunk-pj31j6j0.js} +4 -4
  20. package/dist/{chunk-qsh2nqz3.js → chunk-pw2a9war.js} +3 -3
  21. package/dist/{chunk-j8js1y0h.js → chunk-r5k7jw66.js} +1 -1
  22. package/dist/{chunk-48ywpd0a.js → chunk-vmz9ncf1.js} +1 -1
  23. package/dist/{chunk-qhdsjek6.js → chunk-wry3rqh0.js} +3 -3
  24. package/dist/cli/index.js +6793 -6
  25. package/dist/client.js +3 -3
  26. package/dist/db/better-sqlite.js +4 -4
  27. package/dist/db/bun-sqlite.js +4 -4
  28. package/dist/db/d1.js +4 -4
  29. package/dist/db/index.js +8 -8
  30. package/dist/db/postgres.js +4 -4
  31. package/dist/db/sqlite.js +4 -4
  32. package/dist/index.js +7 -7
  33. package/dist/runtimes/bun.js +6 -6
  34. package/dist/runtimes/cloudflare-workers.js +6 -6
  35. package/dist/runtimes/next.js +6 -6
  36. package/dist/runtimes/node.js +6 -6
  37. package/dist/schema/index.js +3 -3
  38. package/dist/server.js +6 -6
  39. package/dist/storage/index.js +1 -1
  40. package/package.json +12 -11
  41. package/dist/chunk-0hxz770x.js +0 -10
  42. package/dist/chunk-2gdsy99f.js +0 -581
  43. package/dist/chunk-3j9zjfmn.js +0 -376
  44. package/dist/chunk-5b8r0v8c.js +0 -47
  45. package/dist/chunk-71wwx9vj.js +0 -413
  46. package/dist/chunk-9by912e9.js +0 -318
  47. package/dist/chunk-f3dg5dq4.js +0 -75
  48. package/dist/chunk-g17v7yfr.js +0 -237
  49. package/dist/chunk-gzdfc1ct.js +0 -1137
  50. package/dist/chunk-h6dhexzr.js +0 -94
  51. package/dist/chunk-jvv72110.js +0 -98
  52. package/dist/chunk-rg3jrfgg.js +0 -93
  53. package/dist/chunk-rjvcp6ph.js +0 -95
  54. package/dist/chunk-v0nazhmk.js +0 -263
  55. package/dist/chunk-wqvdwck9.js +0 -326
  56. package/dist/chunk-x7bnzswh.js +0 -174
  57. package/dist/chunk-y4e9twg2.js +0 -76
  58. package/src/cli/index.ts +0 -117
@@ -1,94 +0,0 @@
1
- import"./chunk-6bywt602.js";
2
-
3
- // src/cli/core/mocks/d1-mock.ts
4
- import { Database } from "bun:sqlite";
5
- import fs from "node:fs";
6
- import path from "node:path";
7
- function createD1Mock(dbPath = ".opaca/local-d1.db") {
8
- const wranglerD1Dir = path.resolve(process.cwd(), ".wrangler/state/v3/d1/miniflare-D1DatabaseObject");
9
- if (fs.existsSync(wranglerD1Dir)) {
10
- const files = fs.readdirSync(wranglerD1Dir);
11
- const sqliteFile = files.find((f) => f.endsWith(".sqlite"));
12
- if (sqliteFile) {
13
- const wranglerPath = path.join(wranglerD1Dir, sqliteFile);
14
- try {
15
- const sqlite = new Database(wranglerPath);
16
- console.log(`[OpacaCMS] Using Wrangler D1 local state: ${sqliteFile}`);
17
- return wrapSqlite(sqlite);
18
- } catch (e) {
19
- console.warn(`[OpacaCMS] Failed to open Wrangler D1 state at ${wranglerPath}. Falling back...`);
20
- }
21
- }
22
- }
23
- let finalPath = dbPath;
24
- if (!finalPath) {
25
- finalPath = ":memory:";
26
- console.log("[OpacaCMS] Using in-memory D1 mock (no -c/--config provided)");
27
- }
28
- const absolutePath = finalPath === ":memory:" ? finalPath : path.isAbsolute(finalPath) ? finalPath : path.resolve(process.cwd(), finalPath);
29
- try {
30
- if (absolutePath !== ":memory:") {
31
- const dir = path.dirname(absolutePath);
32
- if (!fs.existsSync(dir)) {
33
- fs.mkdirSync(dir, { recursive: true });
34
- }
35
- }
36
- const sqlite = new Database(absolutePath);
37
- if (absolutePath !== ":memory:") {
38
- console.log(`[OpacaCMS] Using local CLI database: ${absolutePath}`);
39
- }
40
- return wrapSqlite(sqlite);
41
- } catch (err) {
42
- console.warn(`[OpacaCMS] Warning: Could not open database at ${absolutePath}. Using memory database.`);
43
- return wrapSqlite(new Database(":memory:"));
44
- }
45
- }
46
- function wrapSqlite(sqlite) {
47
- return {
48
- prepare(query) {
49
- const stmt = sqlite.prepare(query);
50
- const bridge = {
51
- bind(...params) {
52
- bridge._params = params;
53
- return bridge;
54
- },
55
- async first() {
56
- const params = bridge._params || [];
57
- return stmt.get(...params);
58
- },
59
- async all() {
60
- const params = bridge._params || [];
61
- const results = stmt.all(...params);
62
- return { results, success: true, meta: {} };
63
- },
64
- async run() {
65
- const params = bridge._params || [];
66
- const result = stmt.run(...params);
67
- return {
68
- success: true,
69
- meta: { changes: result.changes, last_row_id: result.lastInsertRowid }
70
- };
71
- },
72
- async raw() {
73
- const params = bridge._params || [];
74
- return stmt.all(...params);
75
- }
76
- };
77
- return bridge;
78
- },
79
- async batch(statements) {
80
- const results = [];
81
- for (const stmt of statements) {
82
- results.push(await stmt.all());
83
- }
84
- return results;
85
- },
86
- async exec(query) {
87
- sqlite.exec(query);
88
- return { count: 0, duration: 0 };
89
- }
90
- };
91
- }
92
- export {
93
- createD1Mock
94
- };
@@ -1,98 +0,0 @@
1
- import {
2
- defineCommand,
3
- runMain
4
- } from "./chunk-71wwx9vj.js";
5
- import {
6
- __require
7
- } from "./chunk-6bywt602.js";
8
-
9
- // src/cli/index.ts
10
- import fs from "node:fs";
11
- import { resolve } from "node:path";
12
- import { pathToFileURL } from "node:url";
13
- async function loadConfig(configPath) {
14
- if (!fs.existsSync(configPath)) {
15
- throw new Error(`Config file not found at ${configPath}`);
16
- }
17
- const configUrl = pathToFileURL(configPath).href;
18
- const mod = await import(configUrl);
19
- if (!mod.default) {
20
- throw new Error(`The configuration file at ${configPath} must have a 'default' export.`);
21
- }
22
- const namedExports = Object.keys(mod).filter((k) => k !== "default" && k !== "__esModule");
23
- if (namedExports.length > 0) {
24
- throw new Error(`Named exports are not allowed in the configuration file. Found: ${namedExports.join(", ")}.`);
25
- }
26
- let opaca = mod.default;
27
- if (typeof opaca === "function") {
28
- const { createD1Mock } = await import("./chunk-h6dhexzr.js");
29
- const { createR2Mock } = await import("./chunk-x7bnzswh.js");
30
- const mockDb = createD1Mock();
31
- const mockBucket = createR2Mock();
32
- const mockSecureBucket = createR2Mock();
33
- opaca = await opaca({
34
- DB: mockDb,
35
- BUCKET: mockBucket,
36
- SECURE_BUCKET: mockSecureBucket,
37
- OPACA_SECRET: "cli-secret"
38
- }, { url: "http://localhost:3000" });
39
- }
40
- if (opaca?.fetch) {
41
- throw new Error("Default export is a Hono application. The CLI requires the configuration object.");
42
- }
43
- if (!opaca.db) {
44
- throw new Error("No database adapter found in config");
45
- }
46
- return opaca;
47
- }
48
- function resolveConfigPath(explicitPath) {
49
- let configPath = explicitPath ? resolve(process.cwd(), explicitPath) : "";
50
- if (!configPath) {
51
- const defaults = [
52
- "opaca.config.ts",
53
- "opaca.config.js",
54
- "opacacms.config.ts",
55
- "opacacms.config.js",
56
- "src/opaca.config.ts",
57
- "src/opacacms.config.js"
58
- ];
59
- for (const d of defaults) {
60
- if (fs.existsSync(resolve(process.cwd(), d))) {
61
- configPath = resolve(process.cwd(), d);
62
- break;
63
- }
64
- }
65
- }
66
- if (!configPath || !fs.existsSync(configPath)) {
67
- throw new Error("Config file not found. Use -c or --config to specify path.");
68
- }
69
- return configPath;
70
- }
71
- var mainCommand = defineCommand({
72
- meta: {
73
- name: "opacacms",
74
- version: "0.1.0",
75
- description: "OpacaCMS CLI - The Headless CMS that doesn't get in your way."
76
- },
77
- args: {
78
- config: {
79
- type: "string",
80
- alias: "c",
81
- description: "Path to the OpacaCMS configuration file"
82
- }
83
- },
84
- subCommands: {
85
- init: () => import("./chunk-wqvdwck9.js").then((m) => m.default),
86
- migrate: () => import("./chunk-9by912e9.js").then((m) => m.default),
87
- seed: () => import("./chunk-rg3jrfgg.js").then((m) => m.default),
88
- generate: () => import("./chunk-g17v7yfr.js").then((m) => m.default),
89
- plugin: () => import("./chunk-v0nazhmk.js").then((m) => m.default),
90
- doctor: () => import("./chunk-rjvcp6ph.js").then((m) => m.default),
91
- dev: () => import("./chunk-y4e9twg2.js").then((m) => m.default)
92
- }
93
- });
94
- if (__require.main == __require.module) {
95
- runMain(mainCommand);
96
- }
97
-
98
- export { loadConfig, resolveConfigPath };
@@ -1,93 +0,0 @@
1
- import {
2
- require_picocolors
3
- } from "./chunk-f3dg5dq4.js";
4
- import {
5
- Gt,
6
- R,
7
- Wt,
8
- be
9
- } from "./chunk-gzdfc1ct.js";
10
- import {
11
- loadConfig,
12
- resolveConfigPath
13
- } from "./chunk-jvv72110.js";
14
- import {
15
- defineCommand
16
- } from "./chunk-71wwx9vj.js";
17
- import {
18
- __require,
19
- __toESM
20
- } from "./chunk-6bywt602.js";
21
-
22
- // src/cli/commands/seed.ts
23
- var import_picocolors = __toESM(require_picocolors(), 1);
24
-
25
- // src/cli/core/seeding/seed-logic.ts
26
- async function seedCommand(opaca, count, reset, type, targetTable) {
27
- const { autoSeed } = await import("./chunk-3j9zjfmn.js");
28
- try {
29
- await autoSeed(opaca, count, reset, type);
30
- } catch (error) {
31
- console.error(`[OpacaCMS] Seeding failed: ${error.message}`);
32
- throw error;
33
- }
34
- }
35
-
36
- // src/cli/commands/seed.ts
37
- var seed_default = defineCommand({
38
- meta: {
39
- name: "seed",
40
- description: "Seed the database with mock data"
41
- },
42
- args: {
43
- config: {
44
- type: "string",
45
- alias: "c",
46
- description: "Path to the OpacaCMS configuration file"
47
- },
48
- count: {
49
- type: "string",
50
- description: "Number of documents to seed",
51
- default: "10"
52
- },
53
- reset: {
54
- type: "boolean",
55
- description: "Clear the database before seeding"
56
- },
57
- assets: {
58
- type: "boolean",
59
- description: "Seed only assets"
60
- }
61
- },
62
- async run({ args }) {
63
- console.log();
64
- Wt(import_picocolors.default.bgGreen(import_picocolors.default.white(" OpacaCMS Seeder ")));
65
- const s = be();
66
- s.start("Loading configuration...");
67
- let opaca;
68
- try {
69
- const configPath = resolveConfigPath(args.config);
70
- opaca = await loadConfig(configPath);
71
- s.stop(`Configuration loaded. DB: ${import_picocolors.default.cyan(opaca.db.name)}`);
72
- } catch (err) {
73
- s.stop(import_picocolors.default.red("Failed to load configuration."));
74
- R.error(err.message);
75
- process.exit(1);
76
- }
77
- const type = args.assets ? "assets" : "collections";
78
- const count = parseInt(args.count, 10);
79
- s.start(`Seeding ${count} ${type}...`);
80
- try {
81
- await seedCommand(opaca, count, !!args.reset, type);
82
- s.stop(`Successfully seeded ${import_picocolors.default.green(count)} ${type}!`);
83
- Gt("Database seeded successfully. \uD83C\uDF31");
84
- } catch (error) {
85
- s.stop(import_picocolors.default.red("Seeding failed."));
86
- R.error(error.message);
87
- process.exit(1);
88
- }
89
- }
90
- });
91
- export {
92
- seed_default as default
93
- };
@@ -1,95 +0,0 @@
1
- import {
2
- require_picocolors
3
- } from "./chunk-f3dg5dq4.js";
4
- import {
5
- Gt,
6
- R,
7
- Vt,
8
- Wt,
9
- be
10
- } from "./chunk-gzdfc1ct.js";
11
- import {
12
- loadConfig,
13
- resolveConfigPath
14
- } from "./chunk-jvv72110.js";
15
- import {
16
- defineCommand
17
- } from "./chunk-71wwx9vj.js";
18
- import {
19
- __toESM
20
- } from "./chunk-6bywt602.js";
21
-
22
- // src/cli/commands/doctor.ts
23
- import fs from "node:fs";
24
- var import_picocolors = __toESM(require_picocolors(), 1);
25
- var doctor_default = defineCommand({
26
- meta: {
27
- name: "doctor",
28
- description: "Diagnose your OpacaCMS project configuration and database connection"
29
- },
30
- args: {
31
- config: {
32
- type: "string",
33
- alias: "c",
34
- description: "Path to the OpacaCMS configuration file"
35
- }
36
- },
37
- async run({ args }) {
38
- console.log();
39
- Wt(import_picocolors.default.bgMagenta(import_picocolors.default.white(" OpacaCMS Doctor ")));
40
- const s = be();
41
- s.start("Locating configuration file...");
42
- let configPath;
43
- try {
44
- configPath = resolveConfigPath(args.config);
45
- s.stop(`Config found at ${import_picocolors.default.green(configPath)}`);
46
- } catch (err) {
47
- s.stop(import_picocolors.default.red("Config file not found."));
48
- R.error("Could not find opacacms.config.ts or similar.");
49
- Gt(import_picocolors.default.red("Diagnosis failed."));
50
- process.exit(1);
51
- }
52
- s.start("Loading configuration...");
53
- let opaca;
54
- try {
55
- opaca = await loadConfig(configPath);
56
- s.stop(`Configuration loaded successfully. App Name: ${import_picocolors.default.cyan(opaca.appName || "Unknown")}`);
57
- } catch (err) {
58
- s.stop(import_picocolors.default.red("Failed to load configuration."));
59
- R.error(err.message);
60
- Gt(import_picocolors.default.red("Diagnosis failed."));
61
- process.exit(1);
62
- }
63
- s.start("Verifying database connection...");
64
- try {
65
- if (!opaca.db)
66
- throw new Error("No database configured in config.db");
67
- const tables = await opaca.db.kysely.introspection.getTables();
68
- s.stop(`Database connected successfully. Found ${import_picocolors.default.green(tables.length)} tables.`);
69
- } catch (err) {
70
- s.stop(import_picocolors.default.red("Database connection failed."));
71
- R.error(err.message);
72
- }
73
- s.start("Checking dependencies...");
74
- try {
75
- const pkgPath = `${process.cwd()}/package.json`;
76
- if (fs.existsSync(pkgPath)) {
77
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
78
- const deps = { ...pkg.dependencies, ...pkg.devDependencies };
79
- if (!deps.opacacms) {
80
- R.warn(import_picocolors.default.yellow("opacacms is missing from package.json"));
81
- }
82
- s.stop(`Dependencies checked.`);
83
- } else {
84
- s.stop(import_picocolors.default.yellow("package.json not found."));
85
- }
86
- } catch (err) {
87
- s.stop(import_picocolors.default.red("Error checking dependencies."));
88
- }
89
- Vt(`Everything seems to be in order! Run \`opacacms dev\` to start.`, "Diagnosis Complete");
90
- Gt("Doctor out.");
91
- }
92
- });
93
- export {
94
- doctor_default as default
95
- };
@@ -1,263 +0,0 @@
1
- import {
2
- require_picocolors
3
- } from "./chunk-f3dg5dq4.js";
4
- import {
5
- Ct,
6
- Gt,
7
- Nt,
8
- R,
9
- Wt,
10
- Zt,
11
- be
12
- } from "./chunk-gzdfc1ct.js";
13
- import {
14
- defineCommand
15
- } from "./chunk-71wwx9vj.js";
16
- import {
17
- logger
18
- } from "./chunk-jq1drsen.js";
19
- import {
20
- __require,
21
- __toESM
22
- } from "./chunk-6bywt602.js";
23
-
24
- // src/cli/commands/plugin.ts
25
- var import_picocolors = __toESM(require_picocolors(), 1);
26
-
27
- // src/cli/core/plugins/plugin-build.ts
28
- import fs from "node:fs";
29
- import path from "node:path";
30
- async function pluginBuildCommand(projectRoot) {
31
- const srcDir = path.resolve(projectRoot, "src");
32
- const distDir = path.resolve(projectRoot, "dist");
33
- if (!fs.existsSync(srcDir)) {
34
- logger.error(`No 'src' directory found in ${projectRoot}.`);
35
- process.exit(1);
36
- }
37
- const entryFiles = ["index.tsx", "index.ts", "plugin.tsx", "plugin.ts"];
38
- let mainEntry = "";
39
- for (const file of entryFiles) {
40
- const fullPath = path.join(srcDir, file);
41
- if (fs.existsSync(fullPath)) {
42
- mainEntry = fullPath;
43
- break;
44
- }
45
- }
46
- if (!mainEntry) {
47
- logger.error(`Could not find a main entry file in ${srcDir}`);
48
- process.exit(1);
49
- }
50
- logger.info(`Building plugin entry: ${path.basename(mainEntry)}...`);
51
- if (!fs.existsSync(distDir)) {
52
- fs.mkdirSync(distDir, { recursive: true });
53
- }
54
- const buildResult = await Bun.build({
55
- entrypoints: [mainEntry],
56
- outdir: distDir,
57
- target: "node",
58
- format: "esm",
59
- external: [
60
- "opacacms",
61
- "opacacms/types",
62
- "opacacms/plugins",
63
- "opacacms/schema",
64
- "hono",
65
- "zod",
66
- "react",
67
- "react-dom"
68
- ]
69
- });
70
- if (!buildResult.success) {
71
- logger.error("Plugin build failed.");
72
- for (const msg of buildResult.logs) {
73
- console.error(msg);
74
- }
75
- process.exit(1);
76
- }
77
- try {
78
- logger.info("Generating type declarations...");
79
- const { execSync } = await import("node:child_process");
80
- execSync("bunx tsc --emitDeclarationOnly --outDir dist", {
81
- cwd: projectRoot,
82
- stdio: "ignore"
83
- });
84
- logger.success("Types generated.");
85
- } catch (err) {
86
- logger.warn("Failed to generate types. Make sure typescript is installed.");
87
- }
88
- logger.success(`Plugin built successfully in ${distDir}!`);
89
- }
90
-
91
- // src/cli/core/plugins/plugin-init.ts
92
- import fs2 from "node:fs";
93
- import path2 from "node:path";
94
- async function pluginInitCommand(pluginName) {
95
- if (!pluginName) {
96
- logger.error("Please provide a plugin name. Usage: opacacms plugin:init <plugin_name>");
97
- process.exit(1);
98
- }
99
- const targetDir = path2.resolve(process.cwd(), pluginName);
100
- if (fs2.existsSync(targetDir)) {
101
- logger.error(`Directory ${targetDir} already exists.`);
102
- process.exit(1);
103
- }
104
- logger.info(`Initializing new plugin in ${targetDir}...`);
105
- fs2.mkdirSync(targetDir, { recursive: true });
106
- fs2.mkdirSync(path2.join(targetDir, "src"), { recursive: true });
107
- const packageJson = {
108
- name: pluginName,
109
- version: "1.0.0",
110
- description: "An OpacaCMS plugin",
111
- main: "dist/index.js",
112
- types: "dist/index.d.ts",
113
- scripts: {
114
- build: "opacacms plugin:build",
115
- dev: "bun run build --watch"
116
- },
117
- peerDependencies: {
118
- opacacms: "workspace:*"
119
- },
120
- devDependencies: {
121
- typescript: "^5.0.0",
122
- "@types/node": "^20.0.0"
123
- }
124
- };
125
- fs2.writeFileSync(path2.join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2), "utf-8");
126
- const tsconfig = {
127
- compilerOptions: {
128
- target: "ESNext",
129
- module: "ESNext",
130
- moduleResolution: "bundler",
131
- strict: true,
132
- esModuleInterop: true,
133
- skipLibCheck: true,
134
- forceConsistentCasingInFileNames: true,
135
- outDir: "./dist",
136
- declaration: true,
137
- jsx: "react"
138
- },
139
- include: ["src/**/*"]
140
- };
141
- fs2.writeFileSync(path2.join(targetDir, "tsconfig.json"), JSON.stringify(tsconfig, null, 2), "utf-8");
142
- const indexTsx = `import type { OpacaPlugin, OpacaPluginContext } from 'opacacms/types';
143
- import { definePlugin } from 'opacacms/plugins';
144
-
145
- export const myPlugin = (): OpacaPlugin => definePlugin({
146
- name: '${pluginName}',
147
- label: 'My Custom Plugin',
148
- description: 'A great new plugin for OpacaCMS.',
149
- version: '1.0.0',
150
- icon: 'Box',
151
-
152
- onInit: (ctx: OpacaPluginContext) => {
153
- ctx.logger.info('[${pluginName}] Plugin initialized!');
154
- },
155
-
156
- onRouterInit: (app) => {
157
- app.get('/admin/plugins/${pluginName}/view', (c) => {
158
- return c.html(\`
159
- <!DOCTYPE html>
160
- <html>
161
- <head>
162
- <meta charset="UTF-8">
163
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
164
- <style>
165
- body {
166
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
167
- padding: 2rem;
168
- line-height: 1.5;
169
- color: #334155;
170
- }
171
- .card {
172
- background: white;
173
- border: 1px solid #e2e8f0;
174
- border-radius: 0.5rem;
175
- padding: 1.5rem;
176
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
177
- }
178
- h2 { margin-top: 0; color: #1e293b; }
179
- </style>
180
- </head>
181
- <body>
182
- <div class="card">
183
- <h2>Welcome to ${pluginName} Dashboard!</h2>
184
- <p>This UI is rendered directly from your plugin's backend using <strong>SSR</strong>.</p>
185
- <p>You can use Hono's <code>c.html()</code> or even React SSR with <code>@hono/react-renderer</code>.</p>
186
- </div>
187
- </body>
188
- </html>
189
- \`);
190
- });
191
- },
192
-
193
- adminUI: {
194
- type: 'ssr',
195
- path: '/admin/plugins/${pluginName}/view',
196
- }
197
- });
198
- `;
199
- fs2.writeFileSync(path2.join(targetDir, "src", "index.tsx"), indexTsx, "utf-8");
200
- logger.success(`Plugin ${pluginName} initialized successfully!`);
201
- logger.info(`Next steps:
202
- cd ${pluginName}
203
- bun install
204
- bun run build`);
205
- }
206
-
207
- // src/cli/commands/plugin.ts
208
- var plugin_default = defineCommand({
209
- meta: {
210
- name: "plugin",
211
- description: "Manage OpacaCMS plugins"
212
- },
213
- args: {
214
- action: {
215
- type: "positional",
216
- description: "Action to perform: init, build",
217
- required: true
218
- },
219
- name: {
220
- type: "positional",
221
- description: "Name of the plugin (for init)",
222
- required: false
223
- }
224
- },
225
- async run({ args }) {
226
- if (args.action === "init") {
227
- let name = args.name;
228
- if (!name) {
229
- const response = await Zt({
230
- message: "What is the name of your plugin?",
231
- placeholder: "my-opaca-plugin",
232
- defaultValue: "my-opaca-plugin"
233
- });
234
- if (Ct(response)) {
235
- Nt("Operation cancelled.");
236
- process.exit(0);
237
- }
238
- name = response;
239
- }
240
- Wt(import_picocolors.default.bgBlue(import_picocolors.default.white(" OpacaCMS Plugin Init ")));
241
- const s = be();
242
- s.start(`Scaffolding plugin ${name}...`);
243
- await pluginInitCommand(name);
244
- s.stop(`Plugin ${name} scaffolded!`);
245
- Gt(`Run cd ${name} && bun install to get started.`);
246
- return;
247
- }
248
- if (args.action === "build") {
249
- Wt(import_picocolors.default.bgMagenta(import_picocolors.default.white(" OpacaCMS Plugin Build ")));
250
- const s = be();
251
- s.start(`Building plugin in ${process.cwd()}...`);
252
- await pluginBuildCommand(process.cwd());
253
- s.stop(`Plugin built successfully!`);
254
- Gt(`Ready for distribution.`);
255
- return;
256
- }
257
- R.error(`Unknown plugin action: ${args.action}`);
258
- process.exit(1);
259
- }
260
- });
261
- export {
262
- plugin_default as default
263
- };