@stacksjs/actions 0.59.11 → 0.61.1

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 (163) hide show
  1. package/dist/add.js +29 -0
  2. package/dist/build/component-libs.js +9 -0
  3. package/dist/build/core.js +21 -0
  4. package/dist/build/stacks.js +8 -0
  5. package/dist/build.js +317 -0
  6. package/dist/bump.js +16 -0
  7. package/dist/changelog.js +17 -0
  8. package/dist/clean.js +6 -0
  9. package/dist/commit.js +17 -0
  10. package/dist/copy-types.js +14 -0
  11. package/dist/database/seed.js +8 -0
  12. package/dist/deploy/index.js +31 -0
  13. package/dist/dev/components.js +11 -0
  14. package/dist/dev/docs.js +7 -0
  15. package/dist/dev/index.js +112 -0
  16. package/dist/examples.js +43 -0
  17. package/dist/fresh.js +19 -0
  18. package/dist/generate/component-meta.js +59 -0
  19. package/dist/generate/ide-helpers.js +96 -0
  20. package/dist/generate/index.js +251 -0
  21. package/dist/generate/lib-entries.js +175 -0
  22. package/dist/generate/vscode-custom-data.js +96 -0
  23. package/dist/helpers/component-meta.js +50 -0
  24. package/dist/helpers/lib-entries.js +166 -0
  25. package/dist/helpers/package-json.js +146 -0
  26. package/dist/helpers/utils.js +67 -0
  27. package/dist/helpers/vscode-custom-data.js +88 -0
  28. package/dist/index.js +676 -0
  29. package/dist/key-generate.js +10 -0
  30. package/dist/lint/fix.js +12 -0
  31. package/dist/lint/index.js +16 -0
  32. package/dist/make.js +319 -0
  33. package/dist/prepublish.js +17 -0
  34. package/dist/release.js +646 -0
  35. package/dist/test/coverage.js +9 -0
  36. package/dist/test/feature.js +9 -0
  37. package/dist/test/ui.js +6 -0
  38. package/dist/test/unit.js +6 -0
  39. package/dist/test.js +6 -0
  40. package/dist/typecheck.js +6 -0
  41. package/dist/types.js +21 -0
  42. package/dist/upgrade/dependencies.js +6 -0
  43. package/dist/upgrade/framework.js +1 -0
  44. package/dist/upgrade/index.js +78 -0
  45. package/dist/upgrade.js +46 -0
  46. package/package.json +5 -5
  47. package/src/action.ts +1 -0
  48. package/src/actions.ts +2 -2
  49. package/src/add.ts +3 -6
  50. package/src/ai/request-model-access.ts +10 -7
  51. package/src/build/component-libs.ts +5 -2
  52. package/src/build/core.ts +1 -2
  53. package/src/build/stacks.ts +8 -5
  54. package/src/build.ts +11 -25
  55. package/src/bump.ts +0 -2
  56. package/src/check/ports.ts +2 -3
  57. package/src/commit.ts +2 -2
  58. package/src/copy-types.ts +1 -1
  59. package/src/database/seed.ts +8 -4
  60. package/src/deploy/create-receipt-rule.ts +3 -7
  61. package/src/deploy/index.ts +2 -1
  62. package/src/dev/api.ts +4 -4
  63. package/src/dev/components.ts +3 -5
  64. package/src/dev/index.ts +2 -2
  65. package/src/domains/add.ts +8 -6
  66. package/src/domains/purchase.ts +26 -24
  67. package/src/domains/remove.ts +5 -7
  68. package/src/examples.ts +9 -13
  69. package/src/find-projects.ts +4 -6
  70. package/src/fresh.ts +2 -1
  71. package/src/generate/action-types.ts +5 -7
  72. package/src/generate/component-meta.ts +2 -5
  73. package/src/generate/custom-cli-file.ts +4 -3
  74. package/src/generate/env-files.ts +38 -43
  75. package/src/generate/ide-helpers.ts +1 -2
  76. package/src/generate/index.ts +16 -40
  77. package/src/generate/lib-entries.ts +4 -7
  78. package/src/generate/pkgx-file.ts +6 -11
  79. package/src/generate/vscode-custom-data.ts +1 -3
  80. package/src/helpers/component-meta.ts +6 -11
  81. package/src/helpers/index.ts +5 -0
  82. package/src/helpers/lib-entries.ts +30 -25
  83. package/src/helpers/package-json.ts +13 -16
  84. package/src/helpers/utils.ts +56 -13
  85. package/src/helpers/vscode-custom-data.ts +1 -2
  86. package/src/index.ts +2 -1
  87. package/src/key-generate.ts +3 -4
  88. package/src/lint/fix.ts +10 -2
  89. package/src/lint/index.ts +6 -8
  90. package/src/make.ts +79 -77
  91. package/src/migrate/database.ts +22 -1
  92. package/src/migrate/fresh.ts +20 -0
  93. package/src/orm/base.ts +0 -0
  94. package/src/orm/generate-model.ts +1177 -0
  95. package/src/{generate/model-classes.ts → orm/user.ts} +33 -48
  96. package/src/prepublish.ts +5 -2
  97. package/src/release.ts +15 -11
  98. package/src/test/coverage.ts +5 -2
  99. package/src/test/feature.ts +5 -2
  100. package/src/test/ui.ts +1 -1
  101. package/src/test/unit.ts +1 -1
  102. package/src/test.ts +1 -1
  103. package/src/typecheck.ts +1 -1
  104. package/src/types.ts +2 -2
  105. package/src/upgrade/binary.ts +3 -5
  106. package/src/upgrade/index.ts +4 -8
  107. package/src/upgrade/shell.ts +10 -10
  108. package/src/upgrade.ts +28 -25
  109. package/dist/action.d.ts +0 -36
  110. package/dist/add.d.ts +0 -6
  111. package/dist/build/component-libs.d.ts +0 -1
  112. package/dist/build/core.d.ts +0 -1
  113. package/dist/build/stacks.d.ts +0 -1
  114. package/dist/build.d.ts +0 -9
  115. package/dist/bump.d.ts +0 -1
  116. package/dist/changelog.d.ts +0 -1
  117. package/dist/clean.d.ts +0 -1
  118. package/dist/commit.d.ts +0 -3
  119. package/dist/copy-types.d.ts +0 -5
  120. package/dist/database/seed.d.ts +0 -1
  121. package/dist/deploy/index.d.ts +0 -1
  122. package/dist/dev/components.d.ts +0 -1
  123. package/dist/dev/docs.d.ts +0 -1
  124. package/dist/dev/index.d.ts +0 -10
  125. package/dist/examples.d.ts +0 -5
  126. package/dist/fresh.d.ts +0 -1
  127. package/dist/generate/component-meta.d.ts +0 -5
  128. package/dist/generate/ide-helpers.d.ts +0 -6
  129. package/dist/generate/index.d.ts +0 -13
  130. package/dist/generate/lib-entries.d.ts +0 -2
  131. package/dist/generate/vscode-custom-data.d.ts +0 -6
  132. package/dist/helpers/component-meta.d.ts +0 -22
  133. package/dist/helpers/lib-entries.d.ts +0 -13
  134. package/dist/helpers/package-json.d.ts +0 -3
  135. package/dist/helpers/utils.d.ts +0 -18
  136. package/dist/helpers/vscode-custom-data.d.ts +0 -2
  137. package/dist/index.d.ts +0 -7
  138. package/dist/key-generate.d.ts +0 -1
  139. package/dist/lint/fix.d.ts +0 -1
  140. package/dist/lint/index.d.ts +0 -1
  141. package/dist/make.d.ts +0 -20
  142. package/dist/prepublish.d.ts +0 -1
  143. package/dist/release.d.ts +0 -2
  144. package/dist/test/coverage.d.ts +0 -1
  145. package/dist/test/feature.d.ts +0 -1
  146. package/dist/test/ui.d.ts +0 -1
  147. package/dist/test/unit.d.ts +0 -1
  148. package/dist/test.d.ts +0 -1
  149. package/dist/tinker.d.ts +0 -1
  150. package/dist/typecheck.d.ts +0 -1
  151. package/dist/types.d.ts +0 -3
  152. package/dist/upgrade/dependencies.d.ts +0 -1
  153. package/dist/upgrade/framework.d.ts +0 -1
  154. package/dist/upgrade/index.d.ts +0 -1
  155. package/dist/upgrade.d.ts +0 -4
  156. package/src/database/fields.ts +0 -111
  157. package/src/database/migration-mysql.ts +0 -72
  158. package/src/database/migration-sqlite.ts +0 -67
  159. package/src/database/migration.ts +0 -10
  160. package/src/database/user-migration.ts +0 -20
  161. package/src/generate/model-generate.ts +0 -12
  162. package/src/migrate/dns.ts +0 -3
  163. package/src/tinker.ts +0 -10
package/dist/make.js ADDED
@@ -0,0 +1,319 @@
1
+ // @bun
2
+ // src/make.ts
3
+ import process from "process";
4
+ import {italic} from "@stacksjs/cli";
5
+ import {log} from "@stacksjs/logging";
6
+ import {frameworkPath, path as p, resolve} from "@stacksjs/path";
7
+ import {createFolder, doesFolderExist, writeTextFile} from "@stacksjs/storage";
8
+ async function invoke(options) {
9
+ if (options.component)
10
+ await makeComponent(options);
11
+ if (options.database)
12
+ makeDatabase(options);
13
+ if (options.function)
14
+ await makeFunction(options);
15
+ if (options.language)
16
+ await makeLanguage(options);
17
+ if (options.notification)
18
+ await makeNotification(options);
19
+ if (options.page)
20
+ await makePage(options);
21
+ if (options.stack)
22
+ makeStack(options);
23
+ }
24
+ async function make(options) {
25
+ return invoke(options);
26
+ }
27
+ async function makeAction(options) {
28
+ try {
29
+ const name = options.name;
30
+ log.info("Creating your action...");
31
+ await createAction(options);
32
+ log.success(`Created ${italic(name)} action`);
33
+ } catch (error) {
34
+ log.error("There was an error creating your action", error);
35
+ process.exit();
36
+ }
37
+ }
38
+ async function makeComponent(options) {
39
+ try {
40
+ const name = options.name;
41
+ log.info("Creating your component...");
42
+ await createComponent(options);
43
+ log.success(`Created ${italic(name)} component`);
44
+ } catch (error) {
45
+ log.error("There was an error creating your component", error);
46
+ process.exit();
47
+ }
48
+ }
49
+ async function createAction(options) {
50
+ const name = options.name;
51
+ await writeTextFile({
52
+ path: p.userActionsPath(`${name}.ts`),
53
+ data: `import { Action } from '@stacksjs/actions'
54
+
55
+ export default new Action({
56
+ name: '${name}',
57
+ description: '${name} action',
58
+
59
+ handle() {
60
+ return 'Hello World action'
61
+ },
62
+ })
63
+ `
64
+ });
65
+ }
66
+ async function createComponent(options) {
67
+ const name = options.name;
68
+ await writeTextFile({
69
+ path: p.userComponentsPath(`${name}.stx`),
70
+ data: `<script setup lang="ts">
71
+ console.log('Hello World component created')
72
+ </script>
73
+
74
+ <template>
75
+ <div>
76
+ Some HTML block
77
+ </div>
78
+ </template>
79
+ `
80
+ });
81
+ }
82
+ function makeDatabase(options) {
83
+ try {
84
+ const name = options.name;
85
+ log.info(`Creating your ${italic(name)} database...`);
86
+ createDatabase(options);
87
+ log.success(`Created ${italic(name)} database`);
88
+ } catch (error) {
89
+ log.error("There was an error creating your database", error);
90
+ process.exit();
91
+ }
92
+ }
93
+ function createDatabase(options) {
94
+ console.log("createDatabase options", options);
95
+ }
96
+ function factory(options) {
97
+ try {
98
+ const name = options.name;
99
+ log.info(`Creating your ${italic(name)} factory...`);
100
+ createDatabase(options);
101
+ log.success(`Created ${italic(name)} factory`);
102
+ } catch (error) {
103
+ log.error("There was an error creating your factory", error);
104
+ process.exit();
105
+ }
106
+ }
107
+ function createFactory(options) {
108
+ console.log("options", options);
109
+ }
110
+ async function makeNotification(options) {
111
+ try {
112
+ const name = options.name;
113
+ log.info(`Creating your ${italic(name)} notification...`);
114
+ await createNotification(options);
115
+ log.success(`Created ${italic(name)} notification`);
116
+ } catch (error) {
117
+ log.error("There was an error creating your notification", error);
118
+ process.exit();
119
+ }
120
+ }
121
+ async function makePage(options) {
122
+ try {
123
+ const name = options.name;
124
+ log.info("Creating your page...");
125
+ await createPage(options);
126
+ log.success(`Created ${name} page`);
127
+ } catch (error) {
128
+ log.error("There was an error creating your page", error);
129
+ process.exit();
130
+ }
131
+ }
132
+ async function createPage(options) {
133
+ const name = options.name;
134
+ await writeTextFile({
135
+ path: p.userViewsPath(`${name}.stx`),
136
+ data: `<script setup lang="ts">
137
+ console.log('Hello World page created')
138
+ </script>
139
+
140
+ <template>
141
+ <div>
142
+ Visit http://127.0.0.1/${name}
143
+ </div>
144
+ </template>
145
+ `
146
+ });
147
+ }
148
+ async function makeFunction(options) {
149
+ try {
150
+ const name = options.name;
151
+ log.info("Creating your function...");
152
+ await createFunction(options);
153
+ log.success(`Created ${name} function`);
154
+ } catch (error) {
155
+ log.error("There was an error creating your function", error);
156
+ process.exit();
157
+ }
158
+ }
159
+ async function createFunction(options) {
160
+ const name = options.name;
161
+ await writeTextFile({
162
+ path: p.userFunctionsPath(`${name}.ts`),
163
+ data: `// reactive state
164
+ const ${name} = ref(0)
165
+
166
+ // functions that mutate state and trigger updates
167
+ function increment() {
168
+ ${name}.value++
169
+ }
170
+
171
+ export {
172
+ ${name},
173
+ increment,
174
+ }
175
+ `
176
+ });
177
+ }
178
+ async function makeLanguage(options) {
179
+ try {
180
+ const name = options.name;
181
+ log.info("Creating your translation file...");
182
+ await createLanguage(options);
183
+ log.success(`Created ${name} translation file`);
184
+ } catch (error) {
185
+ log.error("There was an error creating your language.", error);
186
+ process.exit();
187
+ }
188
+ }
189
+ async function createLanguage(options) {
190
+ const name = options.name;
191
+ await writeTextFile({
192
+ path: p.resourcesPath(`lang/${name}.yml`),
193
+ data: `button:
194
+ text: Copy
195
+ `
196
+ });
197
+ }
198
+ function makeStack(options) {
199
+ try {
200
+ const name = options.name;
201
+ log.info(`Creating your ${name} stack...`);
202
+ const path2 = resolve(process.cwd(), name);
203
+ log.success("Successfully scaffolded your project");
204
+ log.info(`cd ${path2} && bun install`);
205
+ } catch (error) {
206
+ log.error("There was an error creating your stack", error);
207
+ process.exit();
208
+ }
209
+ }
210
+ async function createNotification(options) {
211
+ const name = options.name;
212
+ try {
213
+ let importOption = "EmailOptions";
214
+ if (!doesFolderExist("notifications"))
215
+ await createFolder("./notifications");
216
+ if (options.chat)
217
+ importOption = "ChatOptions";
218
+ if (options.sms)
219
+ importOption = "SMSOptions";
220
+ await writeTextFile({
221
+ path: p.userNotificationsPath(`${name}.ts`),
222
+ data: `import type { ${importOption} } from \'@stacksjs/types\'
223
+
224
+ function content(): string {
225
+ return 'example'
226
+ }
227
+
228
+ function send(): ${importOption} {
229
+ return {
230
+ content: content(),
231
+ }
232
+ }`
233
+ });
234
+ return true;
235
+ } catch (error) {
236
+ return false;
237
+ }
238
+ }
239
+ async function createMigration(options) {
240
+ const optionName = options.name;
241
+ const table = "dummy-name";
242
+ if (!optionName[0])
243
+ throw new Error("options.name is required and cannot be empty");
244
+ const name = optionName[0].toUpperCase() + optionName.slice(1);
245
+ const path2 = frameworkPath(`database/migrations/${name}.ts`);
246
+ try {
247
+ await writeTextFile({
248
+ path: `${path2}`,
249
+ data: `import { Kysely } from 'kysely'
250
+
251
+ export async function up(db: Kysely<any>): Promise<void> {
252
+ await db.schema
253
+ .createTable('${table}')
254
+ .addColumn('id', 'integer', col => col.autoIncrement().primaryKey())
255
+ .execute()
256
+ }`
257
+ });
258
+ log.success(`Successfully created your migration file at stacks/database/migrations/${name}.ts`);
259
+ } catch (error) {
260
+ log.error(error);
261
+ }
262
+ }
263
+ async function createModel(options) {
264
+ const optionName = options.name;
265
+ if (!optionName[0])
266
+ throw new Error("options.name is required and cannot be empty");
267
+ const name = optionName[0].toUpperCase() + optionName.slice(1);
268
+ const path2 = p.userModelsPath(`${name}.ts`);
269
+ try {
270
+ await writeTextFile({
271
+ path: `${path2}`,
272
+ data: `import { faker } from '@stacksjs/faker'
273
+ import { schema } from '@stacksjs/validation'
274
+ import type { Model } from '@stacksjs/types'
275
+
276
+ export default {
277
+ name: '${name}',
278
+
279
+ traits: {
280
+ useTimestamps: true,
281
+
282
+ useSeeder: {
283
+ count: 10,
284
+ },
285
+ },
286
+
287
+ attributes: {
288
+ // your attributes here
289
+ },
290
+ } satisfies Model`
291
+ });
292
+ log.success(`Model created: ${italic(`app/Models/${name}.ts`)}`);
293
+ } catch (error) {
294
+ log.error(error);
295
+ }
296
+ }
297
+ export {
298
+ makeStack,
299
+ makePage,
300
+ makeNotification,
301
+ makeLanguage,
302
+ makeFunction,
303
+ makeDatabase,
304
+ makeComponent,
305
+ makeAction,
306
+ make,
307
+ invoke,
308
+ factory,
309
+ createPage,
310
+ createNotification,
311
+ createModel,
312
+ createMigration,
313
+ createLanguage,
314
+ createFunction,
315
+ createFactory,
316
+ createDatabase,
317
+ createComponent,
318
+ createAction
319
+ };
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ // src/prepublish.ts
3
+ import process from "process";
4
+ import {NpmScript} from "@stacksjs/enums";
5
+ import {log} from "@stacksjs/logging";
6
+ import {runtimePath} from "@stacksjs/path";
7
+ import {runNpmScript} from "@stacksjs/utils";
8
+ log.info("Running prepublish command...");
9
+ var result = await runNpmScript(NpmScript.BuildStacks, {
10
+ verbose: true,
11
+ cwd: runtimePath()
12
+ });
13
+ if (result.isErr()) {
14
+ log.error(new Error("There was an error while prepublishing your stack"), result.error);
15
+ process.exit();
16
+ }
17
+ log.success("Prepublishing completed");