opacacms 0.3.3 → 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.
- package/package.json +2 -2
- package/src/cli/index.ts +0 -117
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opacacms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "OpacaCMS: A lightweight, type-safe, and developer-first Headless CMS for the edge and beyond.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"type": "module",
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"bin": {
|
|
51
|
-
"opacacms": "./
|
|
51
|
+
"opacacms": "./dist/cli/index.js"
|
|
52
52
|
},
|
|
53
53
|
"exports": {
|
|
54
54
|
"./styles.css": {
|
package/src/cli/index.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { defineCommand, runMain } from "citty";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Loads and validates the OpacaCMS configuration from a file.
|
|
9
|
-
*/
|
|
10
|
-
export async function loadConfig(configPath: string) {
|
|
11
|
-
if (!fs.existsSync(configPath)) {
|
|
12
|
-
throw new Error(`Config file not found at ${configPath}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const configUrl = pathToFileURL(configPath).href;
|
|
16
|
-
const mod = await import(configUrl);
|
|
17
|
-
|
|
18
|
-
if (!mod.default) {
|
|
19
|
-
throw new Error(`The configuration file at ${configPath} must have a 'default' export.`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const namedExports = Object.keys(mod).filter((k) => k !== "default" && k !== "__esModule");
|
|
23
|
-
if (namedExports.length > 0) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
`Named exports are not allowed in the configuration file. Found: ${namedExports.join(", ")}.`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let opaca = mod.default;
|
|
30
|
-
|
|
31
|
-
if (typeof opaca === "function") {
|
|
32
|
-
const { createD1Mock } = await import("./core/mocks/d1-mock.js");
|
|
33
|
-
const { createR2Mock } = await import("./core/mocks/r2-mock.js");
|
|
34
|
-
|
|
35
|
-
const mockDb = createD1Mock();
|
|
36
|
-
const mockBucket = createR2Mock();
|
|
37
|
-
const mockSecureBucket = createR2Mock();
|
|
38
|
-
|
|
39
|
-
opaca = await opaca(
|
|
40
|
-
{
|
|
41
|
-
DB: mockDb,
|
|
42
|
-
BUCKET: mockBucket,
|
|
43
|
-
SECURE_BUCKET: mockSecureBucket,
|
|
44
|
-
OPACA_SECRET: "cli-secret",
|
|
45
|
-
},
|
|
46
|
-
{ url: "http://localhost:3000" },
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (opaca?.fetch) {
|
|
51
|
-
throw new Error(
|
|
52
|
-
"Default export is a Hono application. The CLI requires the configuration object.",
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!opaca.db) {
|
|
57
|
-
throw new Error("No database adapter found in config");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return opaca;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Tries to find the Opaca config file automatically.
|
|
65
|
-
*/
|
|
66
|
-
export function resolveConfigPath(explicitPath?: string): string {
|
|
67
|
-
let configPath = explicitPath ? resolve(process.cwd(), explicitPath) : "";
|
|
68
|
-
if (!configPath) {
|
|
69
|
-
const defaults = [
|
|
70
|
-
"opaca.config.ts",
|
|
71
|
-
"opaca.config.js",
|
|
72
|
-
"opacacms.config.ts",
|
|
73
|
-
"opacacms.config.js",
|
|
74
|
-
"src/opaca.config.ts",
|
|
75
|
-
"src/opacacms.config.js",
|
|
76
|
-
];
|
|
77
|
-
for (const d of defaults) {
|
|
78
|
-
if (fs.existsSync(resolve(process.cwd(), d))) {
|
|
79
|
-
configPath = resolve(process.cwd(), d);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!configPath || !fs.existsSync(configPath)) {
|
|
86
|
-
throw new Error("Config file not found. Use -c or --config to specify path.");
|
|
87
|
-
}
|
|
88
|
-
return configPath;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const mainCommand = defineCommand({
|
|
92
|
-
meta: {
|
|
93
|
-
name: "opacacms",
|
|
94
|
-
version: "0.1.0",
|
|
95
|
-
description: "OpacaCMS CLI - The Headless CMS that doesn't get in your way.",
|
|
96
|
-
},
|
|
97
|
-
args: {
|
|
98
|
-
config: {
|
|
99
|
-
type: "string",
|
|
100
|
-
alias: "c",
|
|
101
|
-
description: "Path to the OpacaCMS configuration file",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
subCommands: {
|
|
105
|
-
init: () => import("./commands/init.js").then((m) => m.default),
|
|
106
|
-
migrate: () => import("./commands/migrate.js").then((m) => m.default),
|
|
107
|
-
seed: () => import("./commands/seed.js").then((m) => m.default),
|
|
108
|
-
generate: () => import("./commands/generate.js").then((m) => m.default),
|
|
109
|
-
plugin: () => import("./commands/plugin.js").then((m) => m.default),
|
|
110
|
-
doctor: () => import("./commands/doctor.js").then((m) => m.default),
|
|
111
|
-
dev: () => import("./commands/dev.js").then((m) => m.default),
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
if (import.meta.main) {
|
|
116
|
-
runMain(mainCommand);
|
|
117
|
-
}
|