@objectstack/cli 4.0.3 → 4.0.5
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/README.md +12 -25
- package/dist/commands/build.d.ts +5 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +6 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/compile.d.ts +3 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +128 -6
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/data/create.js +2 -2
- package/dist/commands/data/create.js.map +1 -1
- package/dist/commands/data/delete.js +2 -2
- package/dist/commands/data/delete.js.map +1 -1
- package/dist/commands/data/get.js +2 -2
- package/dist/commands/data/get.js.map +1 -1
- package/dist/commands/data/query.js +2 -2
- package/dist/commands/data/query.js.map +1 -1
- package/dist/commands/data/update.js +2 -2
- package/dist/commands/data/update.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +48 -19
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/generate.js +9 -9
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/i18n/check.d.ts +18 -0
- package/dist/commands/i18n/check.d.ts.map +1 -0
- package/dist/commands/i18n/check.js +153 -0
- package/dist/commands/i18n/check.js.map +1 -0
- package/dist/commands/init.js +2 -2
- package/dist/commands/lint.d.ts +3 -0
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +24 -0
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/login.d.ts +17 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +313 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/{auth/logout.js → logout.js} +14 -2
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/meta/delete.js +2 -2
- package/dist/commands/meta/delete.js.map +1 -1
- package/dist/commands/meta/get.js +2 -2
- package/dist/commands/meta/get.js.map +1 -1
- package/dist/commands/meta/list.js +2 -2
- package/dist/commands/meta/list.js.map +1 -1
- package/dist/commands/meta/register.js +2 -2
- package/dist/commands/meta/register.js.map +1 -1
- package/dist/commands/projects/bind.d.ts +30 -0
- package/dist/commands/projects/bind.d.ts.map +1 -0
- package/dist/commands/projects/bind.js +132 -0
- package/dist/commands/projects/bind.js.map +1 -0
- package/dist/commands/projects/create.d.ts +28 -0
- package/dist/commands/projects/create.d.ts.map +1 -0
- package/dist/commands/projects/create.js +120 -0
- package/dist/commands/projects/create.js.map +1 -0
- package/dist/commands/projects/list.d.ts +21 -0
- package/dist/commands/projects/list.d.ts.map +1 -0
- package/dist/commands/projects/list.js +79 -0
- package/dist/commands/projects/list.js.map +1 -0
- package/dist/commands/projects/projects.test.d.ts +2 -0
- package/dist/commands/projects/projects.test.d.ts.map +1 -0
- package/dist/commands/projects/projects.test.js +56 -0
- package/dist/commands/projects/projects.test.js.map +1 -0
- package/dist/commands/projects/show.d.ts +21 -0
- package/dist/commands/projects/show.d.ts.map +1 -0
- package/dist/commands/projects/show.js +72 -0
- package/dist/commands/projects/show.js.map +1 -0
- package/dist/commands/projects/switch.d.ts +24 -0
- package/dist/commands/projects/switch.d.ts.map +1 -0
- package/dist/commands/projects/switch.js +64 -0
- package/dist/commands/projects/switch.js.map +1 -0
- package/dist/commands/publish.d.ts +14 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +91 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/{auth/login.d.ts → register.d.ts} +3 -2
- package/dist/commands/register.d.ts.map +1 -0
- package/dist/commands/{auth/login.js → register.js} +44 -61
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +606 -44
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/start.d.ts +11 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +43 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/{auth/whoami.js → whoami.js} +5 -5
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/account.d.ts +31 -0
- package/dist/utils/account.d.ts.map +1 -0
- package/dist/utils/account.js +154 -0
- package/dist/utils/account.js.map +1 -0
- package/dist/utils/api-client.d.ts +10 -4
- package/dist/utils/api-client.d.ts.map +1 -1
- package/dist/utils/api-client.js +13 -7
- package/dist/utils/api-client.js.map +1 -1
- package/dist/utils/auth-config.d.ts +6 -0
- package/dist/utils/auth-config.d.ts.map +1 -1
- package/dist/utils/auth-config.js.map +1 -1
- package/dist/utils/build-runtime.d.ts +45 -0
- package/dist/utils/build-runtime.d.ts.map +1 -0
- package/dist/utils/build-runtime.js +154 -0
- package/dist/utils/build-runtime.js.map +1 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +17 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/console.d.ts +32 -0
- package/dist/utils/console.d.ts.map +1 -0
- package/dist/utils/console.js +169 -0
- package/dist/utils/console.js.map +1 -0
- package/dist/utils/extract-hook-body.d.ts +13 -0
- package/dist/utils/extract-hook-body.d.ts.map +1 -0
- package/dist/utils/extract-hook-body.js +175 -0
- package/dist/utils/extract-hook-body.js.map +1 -0
- package/dist/utils/format.d.ts +8 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +15 -2
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/i18n-coverage.d.ts +61 -0
- package/dist/utils/i18n-coverage.d.ts.map +1 -0
- package/dist/utils/i18n-coverage.js +176 -0
- package/dist/utils/i18n-coverage.js.map +1 -0
- package/dist/utils/lower-callables.d.ts +17 -0
- package/dist/utils/lower-callables.d.ts.map +1 -0
- package/dist/utils/lower-callables.js +181 -0
- package/dist/utils/lower-callables.js.map +1 -0
- package/dist/utils/plugin-detection.d.ts +1 -0
- package/dist/utils/plugin-detection.d.ts.map +1 -1
- package/dist/utils/plugin-detection.js +41 -0
- package/dist/utils/plugin-detection.js.map +1 -1
- package/dist/utils/studio.d.ts +1 -0
- package/dist/utils/studio.d.ts.map +1 -1
- package/dist/utils/studio.js +25 -9
- package/dist/utils/studio.js.map +1 -1
- package/package.json +55 -21
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -805
- package/bin/run-dev.js +0 -5
- package/dist/commands/auth/login.d.ts.map +0 -1
- package/dist/commands/auth/login.js.map +0 -1
- package/dist/commands/auth/logout.d.ts.map +0 -1
- package/dist/commands/auth/logout.js.map +0 -1
- package/dist/commands/auth/whoami.d.ts.map +0 -1
- package/dist/commands/auth/whoami.js.map +0 -1
- package/dist/commands/codemod/v2-to-v3.d.ts +0 -10
- package/dist/commands/codemod/v2-to-v3.d.ts.map +0 -1
- package/dist/commands/codemod/v2-to-v3.js +0 -145
- package/dist/commands/codemod/v2-to-v3.js.map +0 -1
- package/dist/commands/plugin/add.d.ts +0 -22
- package/dist/commands/plugin/add.d.ts.map +0 -1
- package/dist/commands/plugin/add.js +0 -93
- package/dist/commands/plugin/add.js.map +0 -1
- package/dist/commands/plugin/build.d.ts +0 -29
- package/dist/commands/plugin/build.d.ts.map +0 -1
- package/dist/commands/plugin/build.js +0 -170
- package/dist/commands/plugin/build.js.map +0 -1
- package/dist/commands/plugin/info.d.ts +0 -10
- package/dist/commands/plugin/info.d.ts.map +0 -1
- package/dist/commands/plugin/info.js +0 -65
- package/dist/commands/plugin/info.js.map +0 -1
- package/dist/commands/plugin/list.d.ts +0 -13
- package/dist/commands/plugin/list.d.ts.map +0 -1
- package/dist/commands/plugin/list.js +0 -78
- package/dist/commands/plugin/list.js.map +0 -1
- package/dist/commands/plugin/publish.d.ts +0 -27
- package/dist/commands/plugin/publish.d.ts.map +0 -1
- package/dist/commands/plugin/publish.js +0 -152
- package/dist/commands/plugin/publish.js.map +0 -1
- package/dist/commands/plugin/remove.d.ts +0 -20
- package/dist/commands/plugin/remove.d.ts.map +0 -1
- package/dist/commands/plugin/remove.js +0 -79
- package/dist/commands/plugin/remove.js.map +0 -1
- package/dist/commands/plugin/validate.d.ts +0 -23
- package/dist/commands/plugin/validate.d.ts.map +0 -1
- package/dist/commands/plugin/validate.js +0 -251
- package/dist/commands/plugin/validate.js.map +0 -1
- package/src/bin.ts +0 -13
- package/src/commands/auth/login.ts +0 -188
- package/src/commands/auth/logout.ts +0 -51
- package/src/commands/auth/whoami.ts +0 -85
- package/src/commands/codemod/v2-to-v3.ts +0 -171
- package/src/commands/compile.ts +0 -114
- package/src/commands/create.ts +0 -281
- package/src/commands/data/create.ts +0 -110
- package/src/commands/data/delete.ts +0 -84
- package/src/commands/data/get.ts +0 -84
- package/src/commands/data/query.ts +0 -127
- package/src/commands/data/update.ts +0 -114
- package/src/commands/dev.ts +0 -83
- package/src/commands/diff.ts +0 -294
- package/src/commands/doctor.ts +0 -572
- package/src/commands/explain.ts +0 -412
- package/src/commands/generate.ts +0 -924
- package/src/commands/info.ts +0 -124
- package/src/commands/init.ts +0 -327
- package/src/commands/lint.ts +0 -315
- package/src/commands/meta/delete.ts +0 -79
- package/src/commands/meta/get.ts +0 -73
- package/src/commands/meta/list.ts +0 -105
- package/src/commands/meta/register.ts +0 -97
- package/src/commands/plugin/add.ts +0 -112
- package/src/commands/plugin/build.ts +0 -193
- package/src/commands/plugin/info.ts +0 -79
- package/src/commands/plugin/list.ts +0 -93
- package/src/commands/plugin/publish.ts +0 -176
- package/src/commands/plugin/remove.ts +0 -97
- package/src/commands/plugin/validate.ts +0 -268
- package/src/commands/serve.ts +0 -411
- package/src/commands/studio.ts +0 -52
- package/src/commands/test.ts +0 -135
- package/src/commands/validate.ts +0 -143
- package/src/index.ts +0 -22
- package/src/utils/api-client.ts +0 -88
- package/src/utils/auth-config.ts +0 -107
- package/src/utils/config.ts +0 -80
- package/src/utils/format.ts +0 -267
- package/src/utils/output-formatter.ts +0 -91
- package/src/utils/plugin-detection.ts +0 -16
- package/src/utils/plugin-helpers.ts +0 -37
- package/src/utils/studio.ts +0 -350
- package/test/commands.test.ts +0 -128
- package/test/create.test.ts +0 -25
- package/test/plugin-commands.test.ts +0 -44
- package/test/plugin.test.ts +0 -169
- package/test/remote-api-commands.test.ts +0 -188
- package/test/remote-api-utils.test.ts +0 -196
- package/test/serve-host-config.test.ts +0 -77
- package/tsconfig.build.json +0 -20
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -23
- /package/dist/commands/{auth/logout.d.ts → logout.d.ts} +0 -0
- /package/dist/commands/{auth/whoami.d.ts → whoami.d.ts} +0 -0
package/src/utils/format.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import type { ZodError } from 'zod';
|
|
5
|
-
|
|
6
|
-
// ─── Constants ──────────────────────────────────────────────────────
|
|
7
|
-
export const CLI_NAME = 'objectstack';
|
|
8
|
-
export const CLI_ALIAS = 'os';
|
|
9
|
-
|
|
10
|
-
// ─── Banner ─────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export function printBanner(version: string) {
|
|
13
|
-
console.log('');
|
|
14
|
-
console.log(chalk.bold.cyan(' ╔═══════════════════════════════════╗'));
|
|
15
|
-
console.log(chalk.bold.cyan(' ║') + chalk.bold(' ◆ ObjectStack CLI ') + chalk.dim(`v${version}`) + chalk.bold.cyan(' ║'));
|
|
16
|
-
console.log(chalk.bold.cyan(' ╚═══════════════════════════════════╝'));
|
|
17
|
-
console.log('');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ─── Section Header ─────────────────────────────────────────────────
|
|
21
|
-
|
|
22
|
-
export function printHeader(title: string) {
|
|
23
|
-
console.log(chalk.bold(`\n◆ ${title}`));
|
|
24
|
-
console.log(chalk.dim('─'.repeat(40)));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ─── Key-Value Line ─────────────────────────────────────────────────
|
|
28
|
-
|
|
29
|
-
export function printKV(key: string, value: string | number, icon?: string) {
|
|
30
|
-
const prefix = icon ? `${icon} ` : ' ';
|
|
31
|
-
console.log(`${prefix}${chalk.dim(key + ':')} ${chalk.white(String(value))}`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// ─── Status Line ────────────────────────────────────────────────────
|
|
35
|
-
|
|
36
|
-
export function printSuccess(msg: string) {
|
|
37
|
-
console.log(chalk.green(` ✓ ${msg}`));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function printWarning(msg: string) {
|
|
41
|
-
console.log(chalk.yellow(` ⚠ ${msg}`));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function printError(msg: string) {
|
|
45
|
-
console.log(chalk.red(` ✗ ${msg}`));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function printInfo(msg: string) {
|
|
49
|
-
console.log(chalk.blue(` ℹ ${msg}`));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function printStep(msg: string) {
|
|
53
|
-
console.log(chalk.yellow(` → ${msg}`));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ─── Timer ──────────────────────────────────────────────────────────
|
|
57
|
-
|
|
58
|
-
export function createTimer() {
|
|
59
|
-
const start = Date.now();
|
|
60
|
-
return {
|
|
61
|
-
elapsed: () => Date.now() - start,
|
|
62
|
-
display: () => `${Date.now() - start}ms`,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ─── Zod Error Formatting ───────────────────────────────────────────
|
|
67
|
-
|
|
68
|
-
export function formatZodErrors(error: ZodError) {
|
|
69
|
-
const issues = error.issues || (error as any).errors || [];
|
|
70
|
-
|
|
71
|
-
if (issues.length === 0) {
|
|
72
|
-
console.log(chalk.red(' Unknown validation error'));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Group by top-level path
|
|
77
|
-
const grouped = new Map<string, typeof issues>();
|
|
78
|
-
for (const issue of issues) {
|
|
79
|
-
const topPath = (issue as any).path?.[0] || '_root';
|
|
80
|
-
if (!grouped.has(String(topPath))) {
|
|
81
|
-
grouped.set(String(topPath), []);
|
|
82
|
-
}
|
|
83
|
-
grouped.get(String(topPath))!.push(issue);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
for (const [section, sectionIssues] of grouped) {
|
|
87
|
-
console.log(chalk.bold.red(`\n ${section}:`));
|
|
88
|
-
for (const issue of sectionIssues) {
|
|
89
|
-
const path = (issue as any).path?.join('.') || '';
|
|
90
|
-
const code = (issue as any).code || '';
|
|
91
|
-
const msg = (issue as any).message || '';
|
|
92
|
-
|
|
93
|
-
console.log(chalk.red(` ✗ ${path}`));
|
|
94
|
-
console.log(chalk.dim(` ${code}: ${msg}`));
|
|
95
|
-
|
|
96
|
-
// Show expected/received for type errors
|
|
97
|
-
if ((issue as any).expected) {
|
|
98
|
-
console.log(chalk.dim(` expected: ${chalk.green((issue as any).expected)}`));
|
|
99
|
-
}
|
|
100
|
-
if ((issue as any).received) {
|
|
101
|
-
console.log(chalk.dim(` received: ${chalk.red((issue as any).received)}`));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
console.log('');
|
|
107
|
-
console.log(chalk.dim(` ${issues.length} validation error(s) total`));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ─── Metadata Statistics ────────────────────────────────────────────
|
|
111
|
-
|
|
112
|
-
export interface MetadataStats {
|
|
113
|
-
objects: number;
|
|
114
|
-
objectExtensions: number;
|
|
115
|
-
fields: number;
|
|
116
|
-
views: number;
|
|
117
|
-
pages: number;
|
|
118
|
-
apps: number;
|
|
119
|
-
dashboards: number;
|
|
120
|
-
reports: number;
|
|
121
|
-
actions: number;
|
|
122
|
-
flows: number;
|
|
123
|
-
workflows: number;
|
|
124
|
-
approvals: number;
|
|
125
|
-
agents: number;
|
|
126
|
-
apis: number;
|
|
127
|
-
roles: number;
|
|
128
|
-
permissions: number;
|
|
129
|
-
themes: number;
|
|
130
|
-
datasources: number;
|
|
131
|
-
translations: number;
|
|
132
|
-
plugins: number;
|
|
133
|
-
devPlugins: number;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function collectMetadataStats(config: any): MetadataStats {
|
|
137
|
-
const count = (val: any) => {
|
|
138
|
-
if (Array.isArray(val)) return val.length;
|
|
139
|
-
if (val && typeof val === 'object') return Object.keys(val).length;
|
|
140
|
-
return 0;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// Count total fields across all objects
|
|
144
|
-
let fields = 0;
|
|
145
|
-
const objects = Array.isArray(config.objects) ? config.objects :
|
|
146
|
-
(config.objects && typeof config.objects === 'object' ? Object.values(config.objects) : []);
|
|
147
|
-
for (const obj of objects as any[]) {
|
|
148
|
-
if (obj.fields && typeof obj.fields === 'object') {
|
|
149
|
-
fields += Object.keys(obj.fields).length;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
objects: count(config.objects),
|
|
155
|
-
objectExtensions: count(config.objectExtensions),
|
|
156
|
-
fields,
|
|
157
|
-
views: count(config.views),
|
|
158
|
-
pages: count(config.pages),
|
|
159
|
-
apps: count(config.apps),
|
|
160
|
-
dashboards: count(config.dashboards),
|
|
161
|
-
reports: count(config.reports),
|
|
162
|
-
actions: count(config.actions),
|
|
163
|
-
flows: count(config.flows),
|
|
164
|
-
workflows: count(config.workflows),
|
|
165
|
-
approvals: count(config.approvals),
|
|
166
|
-
agents: count(config.agents),
|
|
167
|
-
apis: count(config.apis),
|
|
168
|
-
roles: count(config.roles),
|
|
169
|
-
permissions: count(config.permissions),
|
|
170
|
-
themes: count(config.themes),
|
|
171
|
-
datasources: count(config.datasources),
|
|
172
|
-
translations: count(config.translations),
|
|
173
|
-
plugins: count(config.plugins),
|
|
174
|
-
devPlugins: count(config.devPlugins),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ─── Server Ready Banner ────────────────────────────────────────────
|
|
179
|
-
|
|
180
|
-
export interface ServerReadyOptions {
|
|
181
|
-
port: number;
|
|
182
|
-
configFile: string;
|
|
183
|
-
isDev: boolean;
|
|
184
|
-
pluginCount: number;
|
|
185
|
-
pluginNames?: string[];
|
|
186
|
-
uiEnabled?: boolean;
|
|
187
|
-
studioPath?: string;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function printServerReady(opts: ServerReadyOptions) {
|
|
191
|
-
const base = `http://localhost:${opts.port}`;
|
|
192
|
-
console.log('');
|
|
193
|
-
console.log(chalk.bold.green(' ✓ Server is ready'));
|
|
194
|
-
console.log('');
|
|
195
|
-
console.log(chalk.cyan(' ➜') + chalk.bold(' API: ') + chalk.cyan(base + '/'));
|
|
196
|
-
if (opts.uiEnabled && opts.studioPath) {
|
|
197
|
-
console.log(chalk.cyan(' ➜') + chalk.bold(' Studio: ') + chalk.cyan(base + opts.studioPath + '/'));
|
|
198
|
-
}
|
|
199
|
-
console.log('');
|
|
200
|
-
console.log(chalk.dim(` Config: ${opts.configFile}`));
|
|
201
|
-
console.log(chalk.dim(` Mode: ${opts.isDev ? 'development' : 'production'}`));
|
|
202
|
-
console.log(chalk.dim(` Plugins: ${opts.pluginCount} loaded`));
|
|
203
|
-
if (opts.pluginNames && opts.pluginNames.length > 0) {
|
|
204
|
-
console.log(chalk.dim(` ${opts.pluginNames.join(', ')}`));
|
|
205
|
-
}
|
|
206
|
-
console.log('');
|
|
207
|
-
console.log(chalk.dim(' Press Ctrl+C to stop'));
|
|
208
|
-
console.log('');
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function printMetadataStats(stats: MetadataStats) {
|
|
212
|
-
const sections: Array<{ label: string; items: Array<[string, number]> }> = [
|
|
213
|
-
{
|
|
214
|
-
label: 'Data',
|
|
215
|
-
items: [
|
|
216
|
-
['Objects', stats.objects],
|
|
217
|
-
['Fields', stats.fields],
|
|
218
|
-
['Extensions', stats.objectExtensions],
|
|
219
|
-
['Datasources', stats.datasources],
|
|
220
|
-
],
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
label: 'UI',
|
|
224
|
-
items: [
|
|
225
|
-
['Apps', stats.apps],
|
|
226
|
-
['Views', stats.views],
|
|
227
|
-
['Pages', stats.pages],
|
|
228
|
-
['Dashboards', stats.dashboards],
|
|
229
|
-
['Reports', stats.reports],
|
|
230
|
-
['Actions', stats.actions],
|
|
231
|
-
['Themes', stats.themes],
|
|
232
|
-
],
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
label: 'Logic',
|
|
236
|
-
items: [
|
|
237
|
-
['Flows', stats.flows],
|
|
238
|
-
['Workflows', stats.workflows],
|
|
239
|
-
['Approvals', stats.approvals],
|
|
240
|
-
['Agents', stats.agents],
|
|
241
|
-
['APIs', stats.apis],
|
|
242
|
-
],
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
label: 'Security',
|
|
246
|
-
items: [
|
|
247
|
-
['Roles', stats.roles],
|
|
248
|
-
['Permissions', stats.permissions],
|
|
249
|
-
],
|
|
250
|
-
},
|
|
251
|
-
];
|
|
252
|
-
|
|
253
|
-
for (const section of sections) {
|
|
254
|
-
const nonZero = section.items.filter(([, v]) => v > 0);
|
|
255
|
-
if (nonZero.length === 0) continue;
|
|
256
|
-
|
|
257
|
-
const line = nonZero.map(([k, v]) => `${chalk.white(v)} ${chalk.dim(k)}`).join(' ');
|
|
258
|
-
console.log(` ${chalk.bold(section.label + ':')} ${line}`);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (stats.plugins > 0 || stats.devPlugins > 0) {
|
|
262
|
-
const parts: string[] = [];
|
|
263
|
-
if (stats.plugins > 0) parts.push(`${stats.plugins} plugins`);
|
|
264
|
-
if (stats.devPlugins > 0) parts.push(`${stats.devPlugins} devPlugins`);
|
|
265
|
-
console.log(` ${chalk.bold('Runtime:')} ${chalk.dim(parts.join(', '))}`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import yaml from 'yaml';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Output format options for CLI commands
|
|
8
|
-
*/
|
|
9
|
-
export type OutputFormat = 'json' | 'table' | 'yaml';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Format and output data according to the specified format
|
|
13
|
-
*/
|
|
14
|
-
export function formatOutput(data: any, format: OutputFormat = 'json'): void {
|
|
15
|
-
switch (format) {
|
|
16
|
-
case 'json':
|
|
17
|
-
console.log(JSON.stringify(data, null, 2));
|
|
18
|
-
break;
|
|
19
|
-
|
|
20
|
-
case 'yaml':
|
|
21
|
-
console.log(yaml.stringify(data));
|
|
22
|
-
break;
|
|
23
|
-
|
|
24
|
-
case 'table':
|
|
25
|
-
// For table format, handle different data structures
|
|
26
|
-
if (Array.isArray(data)) {
|
|
27
|
-
printTable(data);
|
|
28
|
-
} else if (data && typeof data === 'object') {
|
|
29
|
-
// For single objects, print as key-value pairs
|
|
30
|
-
printKeyValue(data);
|
|
31
|
-
} else {
|
|
32
|
-
console.log(String(data));
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
|
|
36
|
-
default:
|
|
37
|
-
console.log(JSON.stringify(data, null, 2));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Print data as a table (for arrays of objects)
|
|
43
|
-
*/
|
|
44
|
-
function printTable(data: any[]): void {
|
|
45
|
-
if (data.length === 0) {
|
|
46
|
-
console.log(chalk.dim('(no data)'));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Get all unique keys from all objects
|
|
51
|
-
const keys = Array.from(
|
|
52
|
-
new Set(data.flatMap(item => Object.keys(item)))
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
// Print header
|
|
56
|
-
console.log(chalk.bold(keys.join(' | ')));
|
|
57
|
-
console.log(chalk.dim('─'.repeat(keys.join(' | ').length)));
|
|
58
|
-
|
|
59
|
-
// Print rows
|
|
60
|
-
for (const item of data) {
|
|
61
|
-
const values = keys.map(key => {
|
|
62
|
-
const value = item[key];
|
|
63
|
-
if (value === null || value === undefined) return chalk.dim('-');
|
|
64
|
-
if (typeof value === 'object') return chalk.dim('[object]');
|
|
65
|
-
return String(value);
|
|
66
|
-
});
|
|
67
|
-
console.log(values.join(' | '));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
console.log(chalk.dim(`\n${data.length} row(s)`));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Print object as key-value pairs
|
|
75
|
-
*/
|
|
76
|
-
function printKeyValue(data: Record<string, any>, indent = 0): void {
|
|
77
|
-
const prefix = ' '.repeat(indent);
|
|
78
|
-
|
|
79
|
-
for (const [key, value] of Object.entries(data)) {
|
|
80
|
-
if (value === null || value === undefined) {
|
|
81
|
-
console.log(`${prefix}${chalk.dim(key + ':')} ${chalk.dim('null')}`);
|
|
82
|
-
} else if (typeof value === 'object' && !Array.isArray(value)) {
|
|
83
|
-
console.log(`${prefix}${chalk.bold(key + ':')}`);
|
|
84
|
-
printKeyValue(value, indent + 1);
|
|
85
|
-
} else if (Array.isArray(value)) {
|
|
86
|
-
console.log(`${prefix}${chalk.dim(key + ':')} ${chalk.dim(`[${value.length} items]`)}`);
|
|
87
|
-
} else {
|
|
88
|
-
console.log(`${prefix}${chalk.dim(key + ':')} ${chalk.white(String(value))}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Detect whether a loaded config is a host/aggregator configuration.
|
|
5
|
-
*
|
|
6
|
-
* A host config already contains a `plugins` array with instantiated Plugin
|
|
7
|
-
* objects (i.e. objects that have an `init` method). Such configs must NOT
|
|
8
|
-
* be wrapped again by AppPlugin in the CLI, as that would cause duplicate
|
|
9
|
-
* plugin registration and startup failures.
|
|
10
|
-
*/
|
|
11
|
-
export function isHostConfig(config: any): boolean {
|
|
12
|
-
return (
|
|
13
|
-
Array.isArray(config.plugins) &&
|
|
14
|
-
config.plugins.some((p: any) => typeof p?.init === 'function')
|
|
15
|
-
);
|
|
16
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Resolve plugin display name from a plugin entry.
|
|
5
|
-
* Plugins can be string package names, objects with `.name`, or class instances.
|
|
6
|
-
*/
|
|
7
|
-
export function resolvePluginName(plugin: unknown): string {
|
|
8
|
-
if (typeof plugin === 'string') return plugin;
|
|
9
|
-
if (plugin && typeof plugin === 'object') {
|
|
10
|
-
const p = plugin as Record<string, unknown>;
|
|
11
|
-
if (typeof p.name === 'string') return p.name;
|
|
12
|
-
if (p.constructor && p.constructor.name !== 'Object') return p.constructor.name;
|
|
13
|
-
}
|
|
14
|
-
return 'unknown';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Resolve plugin version from a plugin entry.
|
|
19
|
-
*/
|
|
20
|
-
export function resolvePluginVersion(plugin: unknown): string {
|
|
21
|
-
if (plugin && typeof plugin === 'object') {
|
|
22
|
-
const p = plugin as Record<string, unknown>;
|
|
23
|
-
if (typeof p.version === 'string') return p.version;
|
|
24
|
-
}
|
|
25
|
-
return '-';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Resolve plugin type from a plugin entry.
|
|
30
|
-
*/
|
|
31
|
-
export function resolvePluginType(plugin: unknown): string {
|
|
32
|
-
if (plugin && typeof plugin === 'object') {
|
|
33
|
-
const p = plugin as Record<string, unknown>;
|
|
34
|
-
if (typeof p.type === 'string') return p.type;
|
|
35
|
-
}
|
|
36
|
-
return 'standard';
|
|
37
|
-
}
|