@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.
Files changed (241) hide show
  1. package/README.md +12 -25
  2. package/dist/commands/build.d.ts +5 -0
  3. package/dist/commands/build.d.ts.map +1 -0
  4. package/dist/commands/build.js +6 -0
  5. package/dist/commands/build.js.map +1 -0
  6. package/dist/commands/compile.d.ts +3 -0
  7. package/dist/commands/compile.d.ts.map +1 -1
  8. package/dist/commands/compile.js +128 -6
  9. package/dist/commands/compile.js.map +1 -1
  10. package/dist/commands/create.js +1 -1
  11. package/dist/commands/data/create.js +2 -2
  12. package/dist/commands/data/create.js.map +1 -1
  13. package/dist/commands/data/delete.js +2 -2
  14. package/dist/commands/data/delete.js.map +1 -1
  15. package/dist/commands/data/get.js +2 -2
  16. package/dist/commands/data/get.js.map +1 -1
  17. package/dist/commands/data/query.js +2 -2
  18. package/dist/commands/data/query.js.map +1 -1
  19. package/dist/commands/data/update.js +2 -2
  20. package/dist/commands/data/update.js.map +1 -1
  21. package/dist/commands/dev.d.ts +3 -0
  22. package/dist/commands/dev.d.ts.map +1 -1
  23. package/dist/commands/dev.js +48 -19
  24. package/dist/commands/dev.js.map +1 -1
  25. package/dist/commands/generate.js +9 -9
  26. package/dist/commands/generate.js.map +1 -1
  27. package/dist/commands/i18n/check.d.ts +18 -0
  28. package/dist/commands/i18n/check.d.ts.map +1 -0
  29. package/dist/commands/i18n/check.js +153 -0
  30. package/dist/commands/i18n/check.js.map +1 -0
  31. package/dist/commands/init.js +2 -2
  32. package/dist/commands/lint.d.ts +3 -0
  33. package/dist/commands/lint.d.ts.map +1 -1
  34. package/dist/commands/lint.js +24 -0
  35. package/dist/commands/lint.js.map +1 -1
  36. package/dist/commands/login.d.ts +17 -0
  37. package/dist/commands/login.d.ts.map +1 -0
  38. package/dist/commands/login.js +313 -0
  39. package/dist/commands/login.js.map +1 -0
  40. package/dist/commands/logout.d.ts.map +1 -0
  41. package/dist/commands/{auth/logout.js → logout.js} +14 -2
  42. package/dist/commands/logout.js.map +1 -0
  43. package/dist/commands/meta/delete.js +2 -2
  44. package/dist/commands/meta/delete.js.map +1 -1
  45. package/dist/commands/meta/get.js +2 -2
  46. package/dist/commands/meta/get.js.map +1 -1
  47. package/dist/commands/meta/list.js +2 -2
  48. package/dist/commands/meta/list.js.map +1 -1
  49. package/dist/commands/meta/register.js +2 -2
  50. package/dist/commands/meta/register.js.map +1 -1
  51. package/dist/commands/projects/bind.d.ts +30 -0
  52. package/dist/commands/projects/bind.d.ts.map +1 -0
  53. package/dist/commands/projects/bind.js +132 -0
  54. package/dist/commands/projects/bind.js.map +1 -0
  55. package/dist/commands/projects/create.d.ts +28 -0
  56. package/dist/commands/projects/create.d.ts.map +1 -0
  57. package/dist/commands/projects/create.js +120 -0
  58. package/dist/commands/projects/create.js.map +1 -0
  59. package/dist/commands/projects/list.d.ts +21 -0
  60. package/dist/commands/projects/list.d.ts.map +1 -0
  61. package/dist/commands/projects/list.js +79 -0
  62. package/dist/commands/projects/list.js.map +1 -0
  63. package/dist/commands/projects/projects.test.d.ts +2 -0
  64. package/dist/commands/projects/projects.test.d.ts.map +1 -0
  65. package/dist/commands/projects/projects.test.js +56 -0
  66. package/dist/commands/projects/projects.test.js.map +1 -0
  67. package/dist/commands/projects/show.d.ts +21 -0
  68. package/dist/commands/projects/show.d.ts.map +1 -0
  69. package/dist/commands/projects/show.js +72 -0
  70. package/dist/commands/projects/show.js.map +1 -0
  71. package/dist/commands/projects/switch.d.ts +24 -0
  72. package/dist/commands/projects/switch.d.ts.map +1 -0
  73. package/dist/commands/projects/switch.js +64 -0
  74. package/dist/commands/projects/switch.js.map +1 -0
  75. package/dist/commands/publish.d.ts +14 -0
  76. package/dist/commands/publish.d.ts.map +1 -0
  77. package/dist/commands/publish.js +91 -0
  78. package/dist/commands/publish.js.map +1 -0
  79. package/dist/commands/{auth/login.d.ts → register.d.ts} +3 -2
  80. package/dist/commands/register.d.ts.map +1 -0
  81. package/dist/commands/{auth/login.js → register.js} +44 -61
  82. package/dist/commands/register.js.map +1 -0
  83. package/dist/commands/serve.d.ts +8 -0
  84. package/dist/commands/serve.d.ts.map +1 -1
  85. package/dist/commands/serve.js +606 -44
  86. package/dist/commands/serve.js.map +1 -1
  87. package/dist/commands/start.d.ts +11 -0
  88. package/dist/commands/start.d.ts.map +1 -0
  89. package/dist/commands/start.js +43 -0
  90. package/dist/commands/start.js.map +1 -0
  91. package/dist/commands/whoami.d.ts.map +1 -0
  92. package/dist/commands/{auth/whoami.js → whoami.js} +5 -5
  93. package/dist/commands/whoami.js.map +1 -0
  94. package/dist/index.d.ts +7 -4
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +8 -5
  97. package/dist/index.js.map +1 -1
  98. package/dist/utils/account.d.ts +31 -0
  99. package/dist/utils/account.d.ts.map +1 -0
  100. package/dist/utils/account.js +154 -0
  101. package/dist/utils/account.js.map +1 -0
  102. package/dist/utils/api-client.d.ts +10 -4
  103. package/dist/utils/api-client.d.ts.map +1 -1
  104. package/dist/utils/api-client.js +13 -7
  105. package/dist/utils/api-client.js.map +1 -1
  106. package/dist/utils/auth-config.d.ts +6 -0
  107. package/dist/utils/auth-config.d.ts.map +1 -1
  108. package/dist/utils/auth-config.js.map +1 -1
  109. package/dist/utils/build-runtime.d.ts +45 -0
  110. package/dist/utils/build-runtime.d.ts.map +1 -0
  111. package/dist/utils/build-runtime.js +154 -0
  112. package/dist/utils/build-runtime.js.map +1 -0
  113. package/dist/utils/config.d.ts.map +1 -1
  114. package/dist/utils/config.js +17 -2
  115. package/dist/utils/config.js.map +1 -1
  116. package/dist/utils/console.d.ts +32 -0
  117. package/dist/utils/console.d.ts.map +1 -0
  118. package/dist/utils/console.js +169 -0
  119. package/dist/utils/console.js.map +1 -0
  120. package/dist/utils/extract-hook-body.d.ts +13 -0
  121. package/dist/utils/extract-hook-body.d.ts.map +1 -0
  122. package/dist/utils/extract-hook-body.js +175 -0
  123. package/dist/utils/extract-hook-body.js.map +1 -0
  124. package/dist/utils/format.d.ts +8 -0
  125. package/dist/utils/format.d.ts.map +1 -1
  126. package/dist/utils/format.js +15 -2
  127. package/dist/utils/format.js.map +1 -1
  128. package/dist/utils/i18n-coverage.d.ts +61 -0
  129. package/dist/utils/i18n-coverage.d.ts.map +1 -0
  130. package/dist/utils/i18n-coverage.js +176 -0
  131. package/dist/utils/i18n-coverage.js.map +1 -0
  132. package/dist/utils/lower-callables.d.ts +17 -0
  133. package/dist/utils/lower-callables.d.ts.map +1 -0
  134. package/dist/utils/lower-callables.js +181 -0
  135. package/dist/utils/lower-callables.js.map +1 -0
  136. package/dist/utils/plugin-detection.d.ts +1 -0
  137. package/dist/utils/plugin-detection.d.ts.map +1 -1
  138. package/dist/utils/plugin-detection.js +41 -0
  139. package/dist/utils/plugin-detection.js.map +1 -1
  140. package/dist/utils/studio.d.ts +1 -0
  141. package/dist/utils/studio.d.ts.map +1 -1
  142. package/dist/utils/studio.js +25 -9
  143. package/dist/utils/studio.js.map +1 -1
  144. package/package.json +55 -21
  145. package/.turbo/turbo-build.log +0 -4
  146. package/CHANGELOG.md +0 -805
  147. package/bin/run-dev.js +0 -5
  148. package/dist/commands/auth/login.d.ts.map +0 -1
  149. package/dist/commands/auth/login.js.map +0 -1
  150. package/dist/commands/auth/logout.d.ts.map +0 -1
  151. package/dist/commands/auth/logout.js.map +0 -1
  152. package/dist/commands/auth/whoami.d.ts.map +0 -1
  153. package/dist/commands/auth/whoami.js.map +0 -1
  154. package/dist/commands/codemod/v2-to-v3.d.ts +0 -10
  155. package/dist/commands/codemod/v2-to-v3.d.ts.map +0 -1
  156. package/dist/commands/codemod/v2-to-v3.js +0 -145
  157. package/dist/commands/codemod/v2-to-v3.js.map +0 -1
  158. package/dist/commands/plugin/add.d.ts +0 -22
  159. package/dist/commands/plugin/add.d.ts.map +0 -1
  160. package/dist/commands/plugin/add.js +0 -93
  161. package/dist/commands/plugin/add.js.map +0 -1
  162. package/dist/commands/plugin/build.d.ts +0 -29
  163. package/dist/commands/plugin/build.d.ts.map +0 -1
  164. package/dist/commands/plugin/build.js +0 -170
  165. package/dist/commands/plugin/build.js.map +0 -1
  166. package/dist/commands/plugin/info.d.ts +0 -10
  167. package/dist/commands/plugin/info.d.ts.map +0 -1
  168. package/dist/commands/plugin/info.js +0 -65
  169. package/dist/commands/plugin/info.js.map +0 -1
  170. package/dist/commands/plugin/list.d.ts +0 -13
  171. package/dist/commands/plugin/list.d.ts.map +0 -1
  172. package/dist/commands/plugin/list.js +0 -78
  173. package/dist/commands/plugin/list.js.map +0 -1
  174. package/dist/commands/plugin/publish.d.ts +0 -27
  175. package/dist/commands/plugin/publish.d.ts.map +0 -1
  176. package/dist/commands/plugin/publish.js +0 -152
  177. package/dist/commands/plugin/publish.js.map +0 -1
  178. package/dist/commands/plugin/remove.d.ts +0 -20
  179. package/dist/commands/plugin/remove.d.ts.map +0 -1
  180. package/dist/commands/plugin/remove.js +0 -79
  181. package/dist/commands/plugin/remove.js.map +0 -1
  182. package/dist/commands/plugin/validate.d.ts +0 -23
  183. package/dist/commands/plugin/validate.d.ts.map +0 -1
  184. package/dist/commands/plugin/validate.js +0 -251
  185. package/dist/commands/plugin/validate.js.map +0 -1
  186. package/src/bin.ts +0 -13
  187. package/src/commands/auth/login.ts +0 -188
  188. package/src/commands/auth/logout.ts +0 -51
  189. package/src/commands/auth/whoami.ts +0 -85
  190. package/src/commands/codemod/v2-to-v3.ts +0 -171
  191. package/src/commands/compile.ts +0 -114
  192. package/src/commands/create.ts +0 -281
  193. package/src/commands/data/create.ts +0 -110
  194. package/src/commands/data/delete.ts +0 -84
  195. package/src/commands/data/get.ts +0 -84
  196. package/src/commands/data/query.ts +0 -127
  197. package/src/commands/data/update.ts +0 -114
  198. package/src/commands/dev.ts +0 -83
  199. package/src/commands/diff.ts +0 -294
  200. package/src/commands/doctor.ts +0 -572
  201. package/src/commands/explain.ts +0 -412
  202. package/src/commands/generate.ts +0 -924
  203. package/src/commands/info.ts +0 -124
  204. package/src/commands/init.ts +0 -327
  205. package/src/commands/lint.ts +0 -315
  206. package/src/commands/meta/delete.ts +0 -79
  207. package/src/commands/meta/get.ts +0 -73
  208. package/src/commands/meta/list.ts +0 -105
  209. package/src/commands/meta/register.ts +0 -97
  210. package/src/commands/plugin/add.ts +0 -112
  211. package/src/commands/plugin/build.ts +0 -193
  212. package/src/commands/plugin/info.ts +0 -79
  213. package/src/commands/plugin/list.ts +0 -93
  214. package/src/commands/plugin/publish.ts +0 -176
  215. package/src/commands/plugin/remove.ts +0 -97
  216. package/src/commands/plugin/validate.ts +0 -268
  217. package/src/commands/serve.ts +0 -411
  218. package/src/commands/studio.ts +0 -52
  219. package/src/commands/test.ts +0 -135
  220. package/src/commands/validate.ts +0 -143
  221. package/src/index.ts +0 -22
  222. package/src/utils/api-client.ts +0 -88
  223. package/src/utils/auth-config.ts +0 -107
  224. package/src/utils/config.ts +0 -80
  225. package/src/utils/format.ts +0 -267
  226. package/src/utils/output-formatter.ts +0 -91
  227. package/src/utils/plugin-detection.ts +0 -16
  228. package/src/utils/plugin-helpers.ts +0 -37
  229. package/src/utils/studio.ts +0 -350
  230. package/test/commands.test.ts +0 -128
  231. package/test/create.test.ts +0 -25
  232. package/test/plugin-commands.test.ts +0 -44
  233. package/test/plugin.test.ts +0 -169
  234. package/test/remote-api-commands.test.ts +0 -188
  235. package/test/remote-api-utils.test.ts +0 -196
  236. package/test/serve-host-config.test.ts +0 -77
  237. package/tsconfig.build.json +0 -20
  238. package/tsconfig.json +0 -25
  239. package/tsup.config.ts +0 -23
  240. /package/dist/commands/{auth/logout.d.ts → logout.d.ts} +0 -0
  241. /package/dist/commands/{auth/whoami.d.ts → whoami.d.ts} +0 -0
@@ -1,84 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Args, Command, Flags } from '@oclif/core';
4
- import { printError, printSuccess } from '../../utils/format.js';
5
- import { createApiClient, requireAuth } from '../../utils/api-client.js';
6
- import { formatOutput } from '../../utils/output-formatter.js';
7
-
8
- export default class DataDelete extends Command {
9
- static override description = 'Delete a record';
10
-
11
- static override examples = [
12
- '$ os data delete project_task abc123',
13
- '$ os data delete project_task abc123 --format json',
14
- ];
15
-
16
- static override args = {
17
- object: Args.string({
18
- description: 'Object name (snake_case)',
19
- required: true,
20
- }),
21
- id: Args.string({
22
- description: 'Record ID',
23
- required: true,
24
- }),
25
- };
26
-
27
- static override flags = {
28
- url: Flags.string({
29
- char: 'u',
30
- description: 'Server URL',
31
- env: 'OBJECTSTACK_URL',
32
- }),
33
- token: Flags.string({
34
- char: 't',
35
- description: 'Authentication token',
36
- env: 'OBJECTSTACK_TOKEN',
37
- }),
38
- format: Flags.string({
39
- char: 'f',
40
- description: 'Output format',
41
- options: ['json', 'table', 'yaml'],
42
- default: 'table',
43
- }),
44
- };
45
-
46
- async run(): Promise<void> {
47
- const { args, flags } = await this.parse(DataDelete);
48
-
49
- try {
50
- const { client, token } = await createApiClient({
51
- url: flags.url,
52
- token: flags.token,
53
- });
54
-
55
- requireAuth(token);
56
-
57
- // Delete the record
58
- const result = await client.data.delete(args.object, args.id);
59
-
60
- if (flags.format === 'json') {
61
- console.log(JSON.stringify({
62
- success: true,
63
- object: result.object,
64
- id: result.id,
65
- deleted: result.deleted,
66
- }, null, 2));
67
- } else if (flags.format === 'yaml') {
68
- formatOutput({ success: true, object: result.object, id: result.id, deleted: result.deleted }, 'yaml');
69
- } else {
70
- printSuccess(`Record deleted: ${result.id}`);
71
- }
72
- } catch (error: any) {
73
- if (flags.format === 'json') {
74
- console.log(JSON.stringify({
75
- success: false,
76
- error: error.message,
77
- }, null, 2));
78
- this.exit(1);
79
- }
80
- printError(error.message || String(error));
81
- this.exit(1);
82
- }
83
- }
84
- }
@@ -1,84 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Args, Command, Flags } from '@oclif/core';
4
- import { printError } from '../../utils/format.js';
5
- import { createApiClient, requireAuth } from '../../utils/api-client.js';
6
- import { formatOutput } from '../../utils/output-formatter.js';
7
-
8
- export default class DataGet extends Command {
9
- static override description = 'Get a single record by ID';
10
-
11
- static override examples = [
12
- '$ os data get project_task abc123',
13
- '$ os data get project_task abc123 --format json',
14
- ];
15
-
16
- static override args = {
17
- object: Args.string({
18
- description: 'Object name (snake_case)',
19
- required: true,
20
- }),
21
- id: Args.string({
22
- description: 'Record ID',
23
- required: true,
24
- }),
25
- };
26
-
27
- static override flags = {
28
- url: Flags.string({
29
- char: 'u',
30
- description: 'Server URL',
31
- env: 'OBJECTSTACK_URL',
32
- }),
33
- token: Flags.string({
34
- char: 't',
35
- description: 'Authentication token',
36
- env: 'OBJECTSTACK_TOKEN',
37
- }),
38
- format: Flags.string({
39
- char: 'f',
40
- description: 'Output format',
41
- options: ['json', 'table', 'yaml'],
42
- default: 'table',
43
- }),
44
- };
45
-
46
- async run(): Promise<void> {
47
- const { args, flags } = await this.parse(DataGet);
48
-
49
- try {
50
- const { client, token } = await createApiClient({
51
- url: flags.url,
52
- token: flags.token,
53
- });
54
-
55
- requireAuth(token);
56
-
57
- // Get the record
58
- const result = await client.data.get(args.object, args.id);
59
-
60
- if (flags.format === 'json') {
61
- formatOutput(result, 'json');
62
- } else if (flags.format === 'yaml') {
63
- formatOutput(result, 'yaml');
64
- } else {
65
- // Table format - show the record
66
- if (result.record) {
67
- formatOutput(result.record, 'table');
68
- } else {
69
- console.log('Record not found.');
70
- }
71
- }
72
- } catch (error: any) {
73
- if (flags.format === 'json') {
74
- console.log(JSON.stringify({
75
- success: false,
76
- error: error.message,
77
- }, null, 2));
78
- this.exit(1);
79
- }
80
- printError(error.message || String(error));
81
- this.exit(1);
82
- }
83
- }
84
- }
@@ -1,127 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Args, Command, Flags } from '@oclif/core';
4
- import { printError } from '../../utils/format.js';
5
- import { createApiClient, requireAuth } from '../../utils/api-client.js';
6
- import { formatOutput } from '../../utils/output-formatter.js';
7
-
8
- export default class DataQuery extends Command {
9
- static override description = 'Query records from an object';
10
-
11
- static override examples = [
12
- '$ os data query project_task',
13
- '$ os data query project_task --filter \'{"status":"open"}\'',
14
- '$ os data query project_task --limit 10 --offset 0',
15
- '$ os data query project_task --fields name,status,created_at',
16
- '$ os data query project_task --sort -created_at',
17
- '$ os data query project_task --format json',
18
- ];
19
-
20
- static override args = {
21
- object: Args.string({
22
- description: 'Object name (snake_case)',
23
- required: true,
24
- }),
25
- };
26
-
27
- static override flags = {
28
- url: Flags.string({
29
- char: 'u',
30
- description: 'Server URL',
31
- env: 'OBJECTSTACK_URL',
32
- }),
33
- token: Flags.string({
34
- char: 't',
35
- description: 'Authentication token',
36
- env: 'OBJECTSTACK_TOKEN',
37
- }),
38
- filter: Flags.string({
39
- description: 'Filter criteria as JSON object',
40
- }),
41
- fields: Flags.string({
42
- description: 'Comma-separated list of fields to retrieve',
43
- }),
44
- sort: Flags.string({
45
- description: 'Sort field (prefix with - for descending)',
46
- }),
47
- limit: Flags.integer({
48
- description: 'Maximum number of records to return',
49
- default: 50,
50
- }),
51
- offset: Flags.integer({
52
- description: 'Number of records to skip',
53
- default: 0,
54
- }),
55
- format: Flags.string({
56
- char: 'f',
57
- description: 'Output format',
58
- options: ['json', 'table', 'yaml'],
59
- default: 'table',
60
- }),
61
- };
62
-
63
- async run(): Promise<void> {
64
- const { args, flags } = await this.parse(DataQuery);
65
-
66
- try {
67
- const { client, token } = await createApiClient({
68
- url: flags.url,
69
- token: flags.token,
70
- });
71
-
72
- requireAuth(token);
73
-
74
- // Build query options
75
- const queryOptions: any = {
76
- limit: flags.limit,
77
- offset: flags.offset,
78
- };
79
-
80
- if (flags.filter) {
81
- try {
82
- queryOptions.where = JSON.parse(flags.filter);
83
- } catch (e) {
84
- throw new Error(`Invalid filter JSON: ${(e as Error).message}`);
85
- }
86
- }
87
-
88
- if (flags.fields) {
89
- queryOptions.fields = flags.fields.split(',').map(f => f.trim());
90
- }
91
-
92
- if (flags.sort) {
93
- queryOptions.orderBy = flags.sort;
94
- }
95
-
96
- // Execute query
97
- const result = await client.data.query(args.object, queryOptions);
98
-
99
- if (flags.format === 'json') {
100
- formatOutput(result, 'json');
101
- } else if (flags.format === 'yaml') {
102
- formatOutput(result, 'yaml');
103
- } else {
104
- // Table format
105
- if (result.records && result.records.length > 0) {
106
- formatOutput(result.records, 'table');
107
- } else {
108
- console.log('No records found.');
109
- }
110
-
111
- if (result.total !== undefined) {
112
- console.log(`\nTotal: ${result.total} record(s)`);
113
- }
114
- }
115
- } catch (error: any) {
116
- if (flags.format === 'json') {
117
- console.log(JSON.stringify({
118
- success: false,
119
- error: error.message,
120
- }, null, 2));
121
- this.exit(1);
122
- }
123
- printError(error.message || String(error));
124
- this.exit(1);
125
- }
126
- }
127
- }
@@ -1,114 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Args, Command, Flags } from '@oclif/core';
4
- import { printError, printSuccess } from '../../utils/format.js';
5
- import { createApiClient, requireAuth } from '../../utils/api-client.js';
6
- import { formatOutput } from '../../utils/output-formatter.js';
7
-
8
- export default class DataUpdate extends Command {
9
- static override description = 'Update an existing record';
10
-
11
- static override examples = [
12
- '$ os data update project_task abc123 \'{"status":"completed"}\'',
13
- '$ os data update project_task abc123 --data update-data.json',
14
- '$ os data update project_task abc123 --data update-data.json --format json',
15
- ];
16
-
17
- static override args = {
18
- object: Args.string({
19
- description: 'Object name (snake_case)',
20
- required: true,
21
- }),
22
- id: Args.string({
23
- description: 'Record ID',
24
- required: true,
25
- }),
26
- data: Args.string({
27
- description: 'Update data as JSON string (or use --data flag for file)',
28
- }),
29
- };
30
-
31
- static override flags = {
32
- url: Flags.string({
33
- char: 'u',
34
- description: 'Server URL',
35
- env: 'OBJECTSTACK_URL',
36
- }),
37
- token: Flags.string({
38
- char: 't',
39
- description: 'Authentication token',
40
- env: 'OBJECTSTACK_TOKEN',
41
- }),
42
- data: Flags.string({
43
- char: 'd',
44
- description: 'Path to JSON file containing update data',
45
- }),
46
- format: Flags.string({
47
- char: 'f',
48
- description: 'Output format',
49
- options: ['json', 'table', 'yaml'],
50
- default: 'table',
51
- }),
52
- };
53
-
54
- async run(): Promise<void> {
55
- const { args, flags } = await this.parse(DataUpdate);
56
-
57
- try {
58
- const { client, token } = await createApiClient({
59
- url: flags.url,
60
- token: flags.token,
61
- });
62
-
63
- requireAuth(token);
64
-
65
- // Parse update data
66
- let updateData: any;
67
-
68
- if (flags.data) {
69
- // Read from file
70
- const { readFile } = await import('node:fs/promises');
71
- const fileContent = await readFile(flags.data, 'utf-8');
72
- try {
73
- updateData = JSON.parse(fileContent);
74
- } catch (e) {
75
- throw new Error(`Invalid JSON in file: ${(e as Error).message}`);
76
- }
77
- } else if (args.data) {
78
- // Parse from argument
79
- try {
80
- updateData = JSON.parse(args.data);
81
- } catch (e) {
82
- throw new Error(`Invalid JSON: ${(e as Error).message}`);
83
- }
84
- } else {
85
- throw new Error('Update data is required (provide JSON string or use --data flag)');
86
- }
87
-
88
- // Update the record
89
- const result = await client.data.update(args.object, args.id, updateData);
90
-
91
- if (flags.format === 'json') {
92
- formatOutput(result, 'json');
93
- } else if (flags.format === 'yaml') {
94
- formatOutput(result, 'yaml');
95
- } else {
96
- printSuccess(`Record updated: ${result.id}`);
97
- if (result.record) {
98
- console.log('');
99
- formatOutput(result.record, 'table');
100
- }
101
- }
102
- } catch (error: any) {
103
- if (flags.format === 'json') {
104
- console.log(JSON.stringify({
105
- success: false,
106
- error: error.message,
107
- }, null, 2));
108
- this.exit(1);
109
- }
110
- printError(error.message || String(error));
111
- this.exit(1);
112
- }
113
- }
114
- }
@@ -1,83 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Args, Command, Flags } from '@oclif/core';
4
- import chalk from 'chalk';
5
- import { execSync, spawn } from 'child_process';
6
- import fs from 'fs';
7
- import path from 'path';
8
- import { printHeader, printKV, printStep, printError } from '../utils/format.js';
9
-
10
- export default class Dev extends Command {
11
- static override description = 'Start development mode with hot-reload';
12
-
13
- static override args = {
14
- package: Args.string({ description: 'Package name or filter pattern', default: 'all', required: false }),
15
- };
16
-
17
- static override flags = {
18
- watch: Flags.boolean({ char: 'w', description: 'Enable watch mode (default)', default: true }),
19
- ui: Flags.boolean({ description: 'Enable Studio UI at /_studio/' }),
20
- verbose: Flags.boolean({ char: 'v', description: 'Verbose output' }),
21
- };
22
-
23
- async run(): Promise<void> {
24
- const { args, flags } = await this.parse(Dev);
25
- const packageName = args.package;
26
-
27
- printHeader('Development Mode');
28
-
29
- // Check if we are running inside a package (Single Package Mode)
30
- // If "package" argument is 'all' (default) AND objectstack.config.ts exists in CWD
31
- const configPath = path.resolve(process.cwd(), 'objectstack.config.ts');
32
- if (packageName === 'all' && fs.existsSync(configPath)) {
33
- printKV('Config', configPath, '📂');
34
- printStep('Starting dev server...');
35
-
36
- // Delegate to 'serve --dev'
37
- // We spawn a new process to ensure clean environment and watch capabilities (plugin-loader etc)
38
- // usage: objectstack serve --dev
39
- const binPath = process.argv[1]; // path to objectstack bin
40
-
41
- const child = spawn(process.execPath, [binPath, 'serve', '--dev', ...(flags.ui ? ['--ui'] : []), ...(flags.verbose ? ['--verbose'] : [])], {
42
- stdio: 'inherit',
43
- env: { ...process.env, NODE_ENV: 'development' }
44
- });
45
-
46
- return;
47
- }
48
-
49
- // Monorepo Orchestration Mode
50
- try {
51
- const cwd = process.cwd();
52
-
53
- // Only attempt monorepo orchestration if we are in a workspace root
54
- const workspaceConfigPath = path.resolve(cwd, 'pnpm-workspace.yaml');
55
- const isWorkspaceRoot = fs.existsSync(workspaceConfigPath);
56
-
57
- if (packageName === 'all' && !isWorkspaceRoot) {
58
- printError(`Config file not found in ${cwd}`);
59
- console.error(chalk.yellow(' Run in a directory with objectstack.config.ts, or from the monorepo root.'));
60
- process.exit(1);
61
- }
62
-
63
- const filter = packageName === 'all' ? '' : `--filter ${packageName}`;
64
-
65
- printKV('Package', packageName === 'all' ? 'All packages' : packageName, '📦');
66
- printKV('Watch', 'enabled', '🔄');
67
-
68
- // Start dev mode
69
- const command = `pnpm ${filter} dev`.trim();
70
- console.log(chalk.dim(`$ ${command}`));
71
- console.log('');
72
-
73
- execSync(command, {
74
- stdio: 'inherit',
75
- cwd
76
- });
77
-
78
- } catch (error: any) {
79
- printError(`Development mode failed: ${error.message || error}`);
80
- process.exit(1);
81
- }
82
- }
83
- }