@objectstack/cli 3.0.5 → 3.0.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/.turbo/turbo-build.log +2 -26
- package/CHANGELOG.md +27 -0
- package/README.md +98 -54
- package/bin/run-dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/bin.d.ts +11 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +12 -3759
- package/dist/bin.js.map +1 -0
- package/dist/commands/codemod/v2-to-v3.d.ts +10 -0
- package/dist/commands/codemod/v2-to-v3.d.ts.map +1 -0
- package/dist/commands/codemod/v2-to-v3.js +145 -0
- package/dist/commands/codemod/v2-to-v3.js.map +1 -0
- package/dist/commands/compile.d.ts +13 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +91 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/create.d.ts +91 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +259 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +14 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +67 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/diff.d.ts +16 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +239 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/doctor.d.ts +10 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +532 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/explain.d.ts +12 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +368 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/generate.d.ts +17 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +833 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/info.d.ts +12 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +100 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +22 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +295 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lint.d.ts +13 -0
- package/dist/commands/lint.d.ts.map +1 -0
- package/dist/commands/lint.js +255 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/plugin/add.d.ts +22 -0
- package/dist/commands/plugin/add.d.ts.map +1 -0
- package/dist/commands/plugin/add.js +93 -0
- package/dist/commands/plugin/add.js.map +1 -0
- package/dist/commands/plugin/info.d.ts +10 -0
- package/dist/commands/plugin/info.d.ts.map +1 -0
- package/dist/commands/plugin/info.js +65 -0
- package/dist/commands/plugin/info.js.map +1 -0
- package/dist/commands/plugin/list.d.ts +13 -0
- package/dist/commands/plugin/list.d.ts.map +1 -0
- package/dist/commands/plugin/list.js +78 -0
- package/dist/commands/plugin/list.js.map +1 -0
- package/dist/commands/plugin/remove.d.ts +20 -0
- package/dist/commands/plugin/remove.d.ts.map +1 -0
- package/dist/commands/plugin/remove.js +79 -0
- package/dist/commands/plugin/remove.js.map +1 -0
- package/dist/commands/serve.d.ts +15 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +286 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/studio.d.ts +19 -0
- package/dist/commands/studio.d.ts.map +1 -0
- package/dist/commands/studio.js +43 -0
- package/dist/commands/studio.js.map +1 -0
- package/dist/commands/test.d.ts +13 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +120 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/validate.d.ts +13 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +115 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +15 -114
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -2799
- package/dist/index.js.map +1 -0
- package/dist/utils/config.d.ts +21 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +66 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/format.d.ts +52 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +202 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/plugin-helpers.d.ts +14 -0
- package/dist/utils/plugin-helpers.d.ts.map +1 -0
- package/dist/utils/plugin-helpers.js +40 -0
- package/dist/utils/plugin-helpers.js.map +1 -0
- package/dist/utils/studio.d.ts +58 -0
- package/dist/utils/studio.d.ts.map +1 -0
- package/dist/utils/studio.js +288 -0
- package/dist/utils/studio.js.map +1 -0
- package/package.json +33 -15
- package/src/bin.ts +11 -104
- package/src/commands/{codemod.ts → codemod/v2-to-v3.ts} +21 -28
- package/src/commands/compile.ts +35 -25
- package/src/commands/create.ts +29 -19
- package/src/commands/dev.ts +21 -10
- package/src/commands/diff.ts +28 -19
- package/src/commands/doctor.ts +20 -11
- package/src/commands/explain.ts +20 -10
- package/src/commands/generate.ts +81 -90
- package/src/commands/info.ts +22 -11
- package/src/commands/init.ts +32 -20
- package/src/commands/lint.ts +27 -15
- package/src/commands/plugin/add.ts +112 -0
- package/src/commands/plugin/info.ts +79 -0
- package/src/commands/plugin/list.ts +93 -0
- package/src/commands/plugin/remove.ts +97 -0
- package/src/commands/serve.ts +30 -20
- package/src/commands/studio.ts +21 -11
- package/src/commands/test.ts +21 -10
- package/src/commands/validate.ts +36 -25
- package/src/index.ts +20 -12
- package/src/utils/format.ts +10 -6
- package/src/utils/plugin-helpers.ts +37 -0
- package/src/utils/studio.ts +0 -1
- package/test/commands.test.ts +76 -37
- package/test/plugin-commands.test.ts +42 -160
- package/test/plugin.test.ts +19 -23
- package/tsconfig.build.json +18 -0
- package/bin/objectstack.js +0 -2
- package/dist/chunk-CSHQEILI.js +0 -246
- package/dist/chunk-Q74JNWKD.js +0 -248
- package/dist/config-A7BN6UIT.js +0 -11
- package/dist/config-UN34WBHT.js +0 -10
- package/src/commands/plugin.ts +0 -372
- package/src/utils/plugin-commands.ts +0 -163
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"rootDir": "src",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|
package/bin/objectstack.js
DELETED
package/dist/chunk-CSHQEILI.js
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
// src/utils/config.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import chalk2 from "chalk";
|
|
5
|
-
import { bundleRequire } from "bundle-require";
|
|
6
|
-
|
|
7
|
-
// src/utils/format.ts
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
function printHeader(title) {
|
|
10
|
-
console.log(chalk.bold(`
|
|
11
|
-
\u25C6 ${title}`));
|
|
12
|
-
console.log(chalk.dim("\u2500".repeat(40)));
|
|
13
|
-
}
|
|
14
|
-
function printKV(key, value, icon) {
|
|
15
|
-
const prefix = icon ? `${icon} ` : " ";
|
|
16
|
-
console.log(`${prefix}${chalk.dim(key + ":")} ${chalk.white(String(value))}`);
|
|
17
|
-
}
|
|
18
|
-
function printSuccess(msg) {
|
|
19
|
-
console.log(chalk.green(` \u2713 ${msg}`));
|
|
20
|
-
}
|
|
21
|
-
function printWarning(msg) {
|
|
22
|
-
console.log(chalk.yellow(` \u26A0 ${msg}`));
|
|
23
|
-
}
|
|
24
|
-
function printError(msg) {
|
|
25
|
-
console.log(chalk.red(` \u2717 ${msg}`));
|
|
26
|
-
}
|
|
27
|
-
function printInfo(msg) {
|
|
28
|
-
console.log(chalk.blue(` \u2139 ${msg}`));
|
|
29
|
-
}
|
|
30
|
-
function printStep(msg) {
|
|
31
|
-
console.log(chalk.yellow(` \u2192 ${msg}`));
|
|
32
|
-
}
|
|
33
|
-
function createTimer() {
|
|
34
|
-
const start = Date.now();
|
|
35
|
-
return {
|
|
36
|
-
elapsed: () => Date.now() - start,
|
|
37
|
-
display: () => `${Date.now() - start}ms`
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function formatZodErrors(error) {
|
|
41
|
-
const issues = error.issues || error.errors || [];
|
|
42
|
-
if (issues.length === 0) {
|
|
43
|
-
console.log(chalk.red(" Unknown validation error"));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const issue of issues) {
|
|
48
|
-
const topPath = issue.path?.[0] || "_root";
|
|
49
|
-
if (!grouped.has(String(topPath))) {
|
|
50
|
-
grouped.set(String(topPath), []);
|
|
51
|
-
}
|
|
52
|
-
grouped.get(String(topPath)).push(issue);
|
|
53
|
-
}
|
|
54
|
-
for (const [section, sectionIssues] of grouped) {
|
|
55
|
-
console.log(chalk.bold.red(`
|
|
56
|
-
${section}:`));
|
|
57
|
-
for (const issue of sectionIssues) {
|
|
58
|
-
const path2 = issue.path?.join(".") || "";
|
|
59
|
-
const code = issue.code || "";
|
|
60
|
-
const msg = issue.message || "";
|
|
61
|
-
console.log(chalk.red(` \u2717 ${path2}`));
|
|
62
|
-
console.log(chalk.dim(` ${code}: ${msg}`));
|
|
63
|
-
if (issue.expected) {
|
|
64
|
-
console.log(chalk.dim(` expected: ${chalk.green(issue.expected)}`));
|
|
65
|
-
}
|
|
66
|
-
if (issue.received) {
|
|
67
|
-
console.log(chalk.dim(` received: ${chalk.red(issue.received)}`));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
console.log("");
|
|
72
|
-
console.log(chalk.dim(` ${issues.length} validation error(s) total`));
|
|
73
|
-
}
|
|
74
|
-
function collectMetadataStats(config) {
|
|
75
|
-
const count = (arr) => Array.isArray(arr) ? arr.length : 0;
|
|
76
|
-
let fields = 0;
|
|
77
|
-
if (Array.isArray(config.objects)) {
|
|
78
|
-
for (const obj of config.objects) {
|
|
79
|
-
if (obj.fields && typeof obj.fields === "object") {
|
|
80
|
-
fields += Object.keys(obj.fields).length;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
objects: count(config.objects),
|
|
86
|
-
objectExtensions: count(config.objectExtensions),
|
|
87
|
-
fields,
|
|
88
|
-
views: count(config.views),
|
|
89
|
-
pages: count(config.pages),
|
|
90
|
-
apps: count(config.apps),
|
|
91
|
-
dashboards: count(config.dashboards),
|
|
92
|
-
reports: count(config.reports),
|
|
93
|
-
actions: count(config.actions),
|
|
94
|
-
flows: count(config.flows),
|
|
95
|
-
workflows: count(config.workflows),
|
|
96
|
-
approvals: count(config.approvals),
|
|
97
|
-
agents: count(config.agents),
|
|
98
|
-
apis: count(config.apis),
|
|
99
|
-
roles: count(config.roles),
|
|
100
|
-
permissions: count(config.permissions),
|
|
101
|
-
themes: count(config.themes),
|
|
102
|
-
datasources: count(config.datasources),
|
|
103
|
-
translations: count(config.translations),
|
|
104
|
-
plugins: count(config.plugins),
|
|
105
|
-
devPlugins: count(config.devPlugins)
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function printServerReady(opts) {
|
|
109
|
-
const base = `http://localhost:${opts.port}`;
|
|
110
|
-
console.log("");
|
|
111
|
-
console.log(chalk.bold.green(" \u2713 Server is ready"));
|
|
112
|
-
console.log("");
|
|
113
|
-
console.log(chalk.cyan(" \u279C") + chalk.bold(" API: ") + chalk.cyan(base + "/"));
|
|
114
|
-
if (opts.uiEnabled && opts.studioPath) {
|
|
115
|
-
console.log(chalk.cyan(" \u279C") + chalk.bold(" Studio: ") + chalk.cyan(base + opts.studioPath + "/"));
|
|
116
|
-
}
|
|
117
|
-
console.log("");
|
|
118
|
-
console.log(chalk.dim(` Config: ${opts.configFile}`));
|
|
119
|
-
console.log(chalk.dim(` Mode: ${opts.isDev ? "development" : "production"}`));
|
|
120
|
-
console.log(chalk.dim(` Plugins: ${opts.pluginCount} loaded`));
|
|
121
|
-
if (opts.pluginNames && opts.pluginNames.length > 0) {
|
|
122
|
-
console.log(chalk.dim(` ${opts.pluginNames.join(", ")}`));
|
|
123
|
-
}
|
|
124
|
-
console.log("");
|
|
125
|
-
console.log(chalk.dim(" Press Ctrl+C to stop"));
|
|
126
|
-
console.log("");
|
|
127
|
-
}
|
|
128
|
-
function printMetadataStats(stats) {
|
|
129
|
-
const sections = [
|
|
130
|
-
{
|
|
131
|
-
label: "Data",
|
|
132
|
-
items: [
|
|
133
|
-
["Objects", stats.objects],
|
|
134
|
-
["Fields", stats.fields],
|
|
135
|
-
["Extensions", stats.objectExtensions],
|
|
136
|
-
["Datasources", stats.datasources]
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
label: "UI",
|
|
141
|
-
items: [
|
|
142
|
-
["Apps", stats.apps],
|
|
143
|
-
["Views", stats.views],
|
|
144
|
-
["Pages", stats.pages],
|
|
145
|
-
["Dashboards", stats.dashboards],
|
|
146
|
-
["Reports", stats.reports],
|
|
147
|
-
["Actions", stats.actions],
|
|
148
|
-
["Themes", stats.themes]
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
label: "Logic",
|
|
153
|
-
items: [
|
|
154
|
-
["Flows", stats.flows],
|
|
155
|
-
["Workflows", stats.workflows],
|
|
156
|
-
["Approvals", stats.approvals],
|
|
157
|
-
["Agents", stats.agents],
|
|
158
|
-
["APIs", stats.apis]
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: "Security",
|
|
163
|
-
items: [
|
|
164
|
-
["Roles", stats.roles],
|
|
165
|
-
["Permissions", stats.permissions]
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
for (const section of sections) {
|
|
170
|
-
const nonZero = section.items.filter(([, v]) => v > 0);
|
|
171
|
-
if (nonZero.length === 0) continue;
|
|
172
|
-
const line = nonZero.map(([k, v]) => `${chalk.white(v)} ${chalk.dim(k)}`).join(" ");
|
|
173
|
-
console.log(` ${chalk.bold(section.label + ":")} ${line}`);
|
|
174
|
-
}
|
|
175
|
-
if (stats.plugins > 0 || stats.devPlugins > 0) {
|
|
176
|
-
const parts = [];
|
|
177
|
-
if (stats.plugins > 0) parts.push(`${stats.plugins} plugins`);
|
|
178
|
-
if (stats.devPlugins > 0) parts.push(`${stats.devPlugins} devPlugins`);
|
|
179
|
-
console.log(` ${chalk.bold("Runtime:")} ${chalk.dim(parts.join(", "))}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/utils/config.ts
|
|
184
|
-
function resolveConfigPath(source) {
|
|
185
|
-
if (source) {
|
|
186
|
-
const abs = path.resolve(process.cwd(), source);
|
|
187
|
-
if (!fs.existsSync(abs)) {
|
|
188
|
-
printError(`Config file not found: ${chalk2.white(abs)}`);
|
|
189
|
-
console.log("");
|
|
190
|
-
console.log(chalk2.dim(" Hint: Run this command from a directory with objectstack.config.ts"));
|
|
191
|
-
console.log(chalk2.dim(" Or specify the path: objectstack <command> path/to/config.ts"));
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
return abs;
|
|
195
|
-
}
|
|
196
|
-
const candidates = [
|
|
197
|
-
"objectstack.config.ts",
|
|
198
|
-
"objectstack.config.js",
|
|
199
|
-
"objectstack.config.mjs"
|
|
200
|
-
];
|
|
201
|
-
for (const candidate of candidates) {
|
|
202
|
-
const abs = path.resolve(process.cwd(), candidate);
|
|
203
|
-
if (fs.existsSync(abs)) return abs;
|
|
204
|
-
}
|
|
205
|
-
printError("No objectstack.config.{ts,js,mjs} found in current directory");
|
|
206
|
-
console.log("");
|
|
207
|
-
console.log(chalk2.dim(" Hint: Run `objectstack init` to create a new project"));
|
|
208
|
-
process.exit(1);
|
|
209
|
-
}
|
|
210
|
-
async function loadConfig(source) {
|
|
211
|
-
const absolutePath = resolveConfigPath(source);
|
|
212
|
-
const start = Date.now();
|
|
213
|
-
const { mod } = await bundleRequire({
|
|
214
|
-
filepath: absolutePath
|
|
215
|
-
});
|
|
216
|
-
const config = mod.default || mod;
|
|
217
|
-
if (!config) {
|
|
218
|
-
throw new Error(`No default export found in ${path.basename(absolutePath)}`);
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
config,
|
|
222
|
-
absolutePath,
|
|
223
|
-
duration: Date.now() - start
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
function configExists(name = "objectstack.config.ts") {
|
|
227
|
-
return fs.existsSync(path.resolve(process.cwd(), name));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export {
|
|
231
|
-
printHeader,
|
|
232
|
-
printKV,
|
|
233
|
-
printSuccess,
|
|
234
|
-
printWarning,
|
|
235
|
-
printError,
|
|
236
|
-
printInfo,
|
|
237
|
-
printStep,
|
|
238
|
-
createTimer,
|
|
239
|
-
formatZodErrors,
|
|
240
|
-
collectMetadataStats,
|
|
241
|
-
printServerReady,
|
|
242
|
-
printMetadataStats,
|
|
243
|
-
resolveConfigPath,
|
|
244
|
-
loadConfig,
|
|
245
|
-
configExists
|
|
246
|
-
};
|
package/dist/chunk-Q74JNWKD.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/utils/config.ts
|
|
4
|
-
import path from "path";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
import chalk2 from "chalk";
|
|
7
|
-
import { bundleRequire } from "bundle-require";
|
|
8
|
-
|
|
9
|
-
// src/utils/format.ts
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
function printHeader(title) {
|
|
12
|
-
console.log(chalk.bold(`
|
|
13
|
-
\u25C6 ${title}`));
|
|
14
|
-
console.log(chalk.dim("\u2500".repeat(40)));
|
|
15
|
-
}
|
|
16
|
-
function printKV(key, value, icon) {
|
|
17
|
-
const prefix = icon ? `${icon} ` : " ";
|
|
18
|
-
console.log(`${prefix}${chalk.dim(key + ":")} ${chalk.white(String(value))}`);
|
|
19
|
-
}
|
|
20
|
-
function printSuccess(msg) {
|
|
21
|
-
console.log(chalk.green(` \u2713 ${msg}`));
|
|
22
|
-
}
|
|
23
|
-
function printWarning(msg) {
|
|
24
|
-
console.log(chalk.yellow(` \u26A0 ${msg}`));
|
|
25
|
-
}
|
|
26
|
-
function printError(msg) {
|
|
27
|
-
console.log(chalk.red(` \u2717 ${msg}`));
|
|
28
|
-
}
|
|
29
|
-
function printInfo(msg) {
|
|
30
|
-
console.log(chalk.blue(` \u2139 ${msg}`));
|
|
31
|
-
}
|
|
32
|
-
function printStep(msg) {
|
|
33
|
-
console.log(chalk.yellow(` \u2192 ${msg}`));
|
|
34
|
-
}
|
|
35
|
-
function createTimer() {
|
|
36
|
-
const start = Date.now();
|
|
37
|
-
return {
|
|
38
|
-
elapsed: () => Date.now() - start,
|
|
39
|
-
display: () => `${Date.now() - start}ms`
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function formatZodErrors(error) {
|
|
43
|
-
const issues = error.issues || error.errors || [];
|
|
44
|
-
if (issues.length === 0) {
|
|
45
|
-
console.log(chalk.red(" Unknown validation error"));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
49
|
-
for (const issue of issues) {
|
|
50
|
-
const topPath = issue.path?.[0] || "_root";
|
|
51
|
-
if (!grouped.has(String(topPath))) {
|
|
52
|
-
grouped.set(String(topPath), []);
|
|
53
|
-
}
|
|
54
|
-
grouped.get(String(topPath)).push(issue);
|
|
55
|
-
}
|
|
56
|
-
for (const [section, sectionIssues] of grouped) {
|
|
57
|
-
console.log(chalk.bold.red(`
|
|
58
|
-
${section}:`));
|
|
59
|
-
for (const issue of sectionIssues) {
|
|
60
|
-
const path2 = issue.path?.join(".") || "";
|
|
61
|
-
const code = issue.code || "";
|
|
62
|
-
const msg = issue.message || "";
|
|
63
|
-
console.log(chalk.red(` \u2717 ${path2}`));
|
|
64
|
-
console.log(chalk.dim(` ${code}: ${msg}`));
|
|
65
|
-
if (issue.expected) {
|
|
66
|
-
console.log(chalk.dim(` expected: ${chalk.green(issue.expected)}`));
|
|
67
|
-
}
|
|
68
|
-
if (issue.received) {
|
|
69
|
-
console.log(chalk.dim(` received: ${chalk.red(issue.received)}`));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
console.log("");
|
|
74
|
-
console.log(chalk.dim(` ${issues.length} validation error(s) total`));
|
|
75
|
-
}
|
|
76
|
-
function collectMetadataStats(config) {
|
|
77
|
-
const count = (arr) => Array.isArray(arr) ? arr.length : 0;
|
|
78
|
-
let fields = 0;
|
|
79
|
-
if (Array.isArray(config.objects)) {
|
|
80
|
-
for (const obj of config.objects) {
|
|
81
|
-
if (obj.fields && typeof obj.fields === "object") {
|
|
82
|
-
fields += Object.keys(obj.fields).length;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
objects: count(config.objects),
|
|
88
|
-
objectExtensions: count(config.objectExtensions),
|
|
89
|
-
fields,
|
|
90
|
-
views: count(config.views),
|
|
91
|
-
pages: count(config.pages),
|
|
92
|
-
apps: count(config.apps),
|
|
93
|
-
dashboards: count(config.dashboards),
|
|
94
|
-
reports: count(config.reports),
|
|
95
|
-
actions: count(config.actions),
|
|
96
|
-
flows: count(config.flows),
|
|
97
|
-
workflows: count(config.workflows),
|
|
98
|
-
approvals: count(config.approvals),
|
|
99
|
-
agents: count(config.agents),
|
|
100
|
-
apis: count(config.apis),
|
|
101
|
-
roles: count(config.roles),
|
|
102
|
-
permissions: count(config.permissions),
|
|
103
|
-
themes: count(config.themes),
|
|
104
|
-
datasources: count(config.datasources),
|
|
105
|
-
translations: count(config.translations),
|
|
106
|
-
plugins: count(config.plugins),
|
|
107
|
-
devPlugins: count(config.devPlugins)
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function printServerReady(opts) {
|
|
111
|
-
const base = `http://localhost:${opts.port}`;
|
|
112
|
-
console.log("");
|
|
113
|
-
console.log(chalk.bold.green(" \u2713 Server is ready"));
|
|
114
|
-
console.log("");
|
|
115
|
-
console.log(chalk.cyan(" \u279C") + chalk.bold(" API: ") + chalk.cyan(base + "/"));
|
|
116
|
-
if (opts.uiEnabled && opts.studioPath) {
|
|
117
|
-
console.log(chalk.cyan(" \u279C") + chalk.bold(" Studio: ") + chalk.cyan(base + opts.studioPath + "/"));
|
|
118
|
-
}
|
|
119
|
-
console.log("");
|
|
120
|
-
console.log(chalk.dim(` Config: ${opts.configFile}`));
|
|
121
|
-
console.log(chalk.dim(` Mode: ${opts.isDev ? "development" : "production"}`));
|
|
122
|
-
console.log(chalk.dim(` Plugins: ${opts.pluginCount} loaded`));
|
|
123
|
-
if (opts.pluginNames && opts.pluginNames.length > 0) {
|
|
124
|
-
console.log(chalk.dim(` ${opts.pluginNames.join(", ")}`));
|
|
125
|
-
}
|
|
126
|
-
console.log("");
|
|
127
|
-
console.log(chalk.dim(" Press Ctrl+C to stop"));
|
|
128
|
-
console.log("");
|
|
129
|
-
}
|
|
130
|
-
function printMetadataStats(stats) {
|
|
131
|
-
const sections = [
|
|
132
|
-
{
|
|
133
|
-
label: "Data",
|
|
134
|
-
items: [
|
|
135
|
-
["Objects", stats.objects],
|
|
136
|
-
["Fields", stats.fields],
|
|
137
|
-
["Extensions", stats.objectExtensions],
|
|
138
|
-
["Datasources", stats.datasources]
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
label: "UI",
|
|
143
|
-
items: [
|
|
144
|
-
["Apps", stats.apps],
|
|
145
|
-
["Views", stats.views],
|
|
146
|
-
["Pages", stats.pages],
|
|
147
|
-
["Dashboards", stats.dashboards],
|
|
148
|
-
["Reports", stats.reports],
|
|
149
|
-
["Actions", stats.actions],
|
|
150
|
-
["Themes", stats.themes]
|
|
151
|
-
]
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
label: "Logic",
|
|
155
|
-
items: [
|
|
156
|
-
["Flows", stats.flows],
|
|
157
|
-
["Workflows", stats.workflows],
|
|
158
|
-
["Approvals", stats.approvals],
|
|
159
|
-
["Agents", stats.agents],
|
|
160
|
-
["APIs", stats.apis]
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
label: "Security",
|
|
165
|
-
items: [
|
|
166
|
-
["Roles", stats.roles],
|
|
167
|
-
["Permissions", stats.permissions]
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
];
|
|
171
|
-
for (const section of sections) {
|
|
172
|
-
const nonZero = section.items.filter(([, v]) => v > 0);
|
|
173
|
-
if (nonZero.length === 0) continue;
|
|
174
|
-
const line = nonZero.map(([k, v]) => `${chalk.white(v)} ${chalk.dim(k)}`).join(" ");
|
|
175
|
-
console.log(` ${chalk.bold(section.label + ":")} ${line}`);
|
|
176
|
-
}
|
|
177
|
-
if (stats.plugins > 0 || stats.devPlugins > 0) {
|
|
178
|
-
const parts = [];
|
|
179
|
-
if (stats.plugins > 0) parts.push(`${stats.plugins} plugins`);
|
|
180
|
-
if (stats.devPlugins > 0) parts.push(`${stats.devPlugins} devPlugins`);
|
|
181
|
-
console.log(` ${chalk.bold("Runtime:")} ${chalk.dim(parts.join(", "))}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// src/utils/config.ts
|
|
186
|
-
function resolveConfigPath(source) {
|
|
187
|
-
if (source) {
|
|
188
|
-
const abs = path.resolve(process.cwd(), source);
|
|
189
|
-
if (!fs.existsSync(abs)) {
|
|
190
|
-
printError(`Config file not found: ${chalk2.white(abs)}`);
|
|
191
|
-
console.log("");
|
|
192
|
-
console.log(chalk2.dim(" Hint: Run this command from a directory with objectstack.config.ts"));
|
|
193
|
-
console.log(chalk2.dim(" Or specify the path: objectstack <command> path/to/config.ts"));
|
|
194
|
-
process.exit(1);
|
|
195
|
-
}
|
|
196
|
-
return abs;
|
|
197
|
-
}
|
|
198
|
-
const candidates = [
|
|
199
|
-
"objectstack.config.ts",
|
|
200
|
-
"objectstack.config.js",
|
|
201
|
-
"objectstack.config.mjs"
|
|
202
|
-
];
|
|
203
|
-
for (const candidate of candidates) {
|
|
204
|
-
const abs = path.resolve(process.cwd(), candidate);
|
|
205
|
-
if (fs.existsSync(abs)) return abs;
|
|
206
|
-
}
|
|
207
|
-
printError("No objectstack.config.{ts,js,mjs} found in current directory");
|
|
208
|
-
console.log("");
|
|
209
|
-
console.log(chalk2.dim(" Hint: Run `objectstack init` to create a new project"));
|
|
210
|
-
process.exit(1);
|
|
211
|
-
}
|
|
212
|
-
async function loadConfig(source) {
|
|
213
|
-
const absolutePath = resolveConfigPath(source);
|
|
214
|
-
const start = Date.now();
|
|
215
|
-
const { mod } = await bundleRequire({
|
|
216
|
-
filepath: absolutePath
|
|
217
|
-
});
|
|
218
|
-
const config = mod.default || mod;
|
|
219
|
-
if (!config) {
|
|
220
|
-
throw new Error(`No default export found in ${path.basename(absolutePath)}`);
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
config,
|
|
224
|
-
absolutePath,
|
|
225
|
-
duration: Date.now() - start
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function configExists(name = "objectstack.config.ts") {
|
|
229
|
-
return fs.existsSync(path.resolve(process.cwd(), name));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export {
|
|
233
|
-
printHeader,
|
|
234
|
-
printKV,
|
|
235
|
-
printSuccess,
|
|
236
|
-
printWarning,
|
|
237
|
-
printError,
|
|
238
|
-
printInfo,
|
|
239
|
-
printStep,
|
|
240
|
-
createTimer,
|
|
241
|
-
formatZodErrors,
|
|
242
|
-
collectMetadataStats,
|
|
243
|
-
printServerReady,
|
|
244
|
-
printMetadataStats,
|
|
245
|
-
resolveConfigPath,
|
|
246
|
-
loadConfig,
|
|
247
|
-
configExists
|
|
248
|
-
};
|
package/dist/config-A7BN6UIT.js
DELETED