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