opacacms 0.3.1 → 0.3.3
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/admin/auth-client.d.ts +41 -41
- package/dist/admin/index.js +1 -1
- package/dist/admin/react.js +1 -1
- package/dist/admin/vue.js +1 -1
- package/dist/auth/index.d.ts +43 -48
- package/dist/{chunk-g9bxb6h0.js → chunk-2fm4kv2q.js} +1 -1
- package/dist/chunk-2vbfc4q8.js +6 -0
- package/dist/{chunk-adq2b75c.js → chunk-40tky6qh.js} +2 -2
- package/dist/{chunk-e0g6gn7n.js → chunk-49e16hjg.js} +3 -3
- package/dist/{chunk-fnsf1dfm.js → chunk-526a3gqx.js} +1 -1
- package/dist/{chunk-sqsfk9p4.js → chunk-6m1jhxmd.js} +1 -1
- package/dist/{chunk-6bywt602.js → chunk-8sqjbsgt.js} +1 -26
- package/dist/{chunk-n1twhqmf.js → chunk-acghejk8.js} +1 -1
- package/dist/{chunk-m24yqkeq.js → chunk-b1g8jmth.js} +3 -3
- package/dist/{chunk-5422w4eq.js → chunk-cm5rvcnn.js} +5 -5
- package/dist/{chunk-941zxavt.js → chunk-h2y2t07h.js} +4 -4
- package/dist/{chunk-6qs0g65f.js → chunk-h8v093av.js} +1 -1
- package/dist/{chunk-m5ems3hh.js → chunk-hthm9srb.js} +1 -1
- package/dist/{chunk-2k3ysje3.js → chunk-nch158fe.js} +1 -1
- package/dist/{chunk-naqcqj8n.js → chunk-pj31j6j0.js} +4 -4
- package/dist/{chunk-qsh2nqz3.js → chunk-pw2a9war.js} +3 -3
- package/dist/{chunk-j8js1y0h.js → chunk-r5k7jw66.js} +1 -1
- package/dist/{chunk-48ywpd0a.js → chunk-vmz9ncf1.js} +1 -1
- package/dist/{chunk-qhdsjek6.js → chunk-wry3rqh0.js} +3 -3
- package/dist/cli/commands/init.d.ts +1 -6
- package/dist/cli/index.js +6793 -6
- package/dist/client.js +3 -3
- package/dist/db/better-sqlite.js +4 -4
- package/dist/db/bun-sqlite.js +4 -4
- package/dist/db/d1.js +4 -4
- package/dist/db/index.js +8 -8
- package/dist/db/postgres.js +4 -4
- package/dist/db/sqlite.js +4 -4
- package/dist/index.js +7 -7
- package/dist/runtimes/bun.js +6 -6
- package/dist/runtimes/cloudflare-workers.js +6 -6
- package/dist/runtimes/next.js +6 -6
- package/dist/runtimes/node.js +6 -6
- package/dist/schema/index.js +3 -3
- package/dist/server.js +6 -6
- package/dist/storage/index.js +1 -1
- package/package.json +4 -2
- package/dist/chunk-1qm0m8r8.js +0 -413
- package/dist/chunk-3j9zjfmn.js +0 -376
- package/dist/chunk-56n342hs.js +0 -95
- package/dist/chunk-5b8r0v8c.js +0 -47
- package/dist/chunk-63yg00vx.js +0 -263
- package/dist/chunk-7rr5p01g.js +0 -581
- package/dist/chunk-d0tb1xjw.js +0 -93
- package/dist/chunk-d7cgd6vn.js +0 -318
- package/dist/chunk-ec4jhybj.js +0 -1137
- package/dist/chunk-fatyf6f7.js +0 -221
- package/dist/chunk-gyaf5kgf.js +0 -10
- package/dist/chunk-h6dhexzr.js +0 -94
- package/dist/chunk-majsbncm.js +0 -98
- package/dist/chunk-mp2gt9yh.js +0 -237
- package/dist/chunk-r0ms5tk1.js +0 -76
- package/dist/chunk-rwqwsanx.js +0 -75
- package/dist/chunk-x7bnzswh.js +0 -174
package/dist/chunk-63yg00vx.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
require_picocolors
|
|
3
|
-
} from "./chunk-rwqwsanx.js";
|
|
4
|
-
import {
|
|
5
|
-
Ct,
|
|
6
|
-
Gt,
|
|
7
|
-
Nt,
|
|
8
|
-
R,
|
|
9
|
-
Wt,
|
|
10
|
-
Zt,
|
|
11
|
-
be
|
|
12
|
-
} from "./chunk-ec4jhybj.js";
|
|
13
|
-
import {
|
|
14
|
-
defineCommand
|
|
15
|
-
} from "./chunk-1qm0m8r8.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
|
-
};
|