@stacksjs/actions 0.58.47 → 0.58.49

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 (90) hide show
  1. package/dist/src/generate/ide-helpers.js +1 -0
  2. package/dist/src/generate/lib-entries.js +4 -2
  3. package/dist/src/generate/vscode-custom-data.js +1 -0
  4. package/dist/src/helpers/lib-entries.js +1 -0
  5. package/dist/src/helpers/package-json.js +1 -0
  6. package/dist/src/helpers/vscode-custom-data.js +1 -0
  7. package/dist/src/upgrade.js +1 -1
  8. package/package.json +18 -17
  9. package/src/action.ts +11 -0
  10. package/src/actions.ts +2 -0
  11. package/src/add.ts +27 -0
  12. package/src/ai/request-model-access.ts +74 -0
  13. package/src/build/cli.ts +7 -0
  14. package/src/build/component-libs.ts +5 -0
  15. package/src/build/core.ts +34 -0
  16. package/src/build/desktop.ts +7 -0
  17. package/src/build/docs.ts +7 -0
  18. package/src/build/stacks.ts +7 -0
  19. package/src/build.ts +89 -0
  20. package/src/bump.ts +11 -0
  21. package/src/cdn/invalidate-cache.ts +27 -0
  22. package/src/changelog.ts +11 -0
  23. package/src/clean.ts +6 -0
  24. package/src/commit.ts +14 -0
  25. package/src/copy-types.ts +22 -0
  26. package/src/database/fields.ts +111 -0
  27. package/src/database/migration-mysql.ts +72 -0
  28. package/src/database/migration-sqlite.ts +67 -0
  29. package/src/database/migration.ts +10 -0
  30. package/src/database/mydb.sqlite +0 -0
  31. package/src/database/seed.ts +4 -0
  32. package/src/database/stacks.sqlite +0 -0
  33. package/src/database/user-migration.ts +20 -0
  34. package/src/deploy/create-receipt-rule.ts +55 -0
  35. package/src/deploy/index.ts +46 -0
  36. package/src/dev/api.ts +19 -0
  37. package/src/dev/components.ts +14 -0
  38. package/src/dev/dashboard.ts +7 -0
  39. package/src/dev/desktop.ts +7 -0
  40. package/src/dev/docs.ts +7 -0
  41. package/src/dev/index.ts +48 -0
  42. package/src/dev/system-tray.ts +6 -0
  43. package/src/dev/views.ts +7 -0
  44. package/src/domains/add.ts +82 -0
  45. package/src/domains/purchase.ts +76 -0
  46. package/src/domains/remove.ts +38 -0
  47. package/src/examples.ts +46 -0
  48. package/src/fresh.ts +20 -0
  49. package/src/generate/caddyfile.ts +1 -0
  50. package/src/generate/component-meta.ts +19 -0
  51. package/src/generate/env-files.ts +89 -0
  52. package/src/generate/ide-helpers.ts +18 -0
  53. package/src/generate/index.ts +132 -0
  54. package/src/generate/lib-entries.ts +18 -0
  55. package/src/generate/model-classes.ts +299 -0
  56. package/src/generate/model-generate.ts +12 -0
  57. package/src/generate/pkgx-file.ts +72 -0
  58. package/src/generate/types.ts +6 -0
  59. package/src/generate/vscode-custom-data.ts +19 -0
  60. package/src/generate/web-types.ts +2 -0
  61. package/src/helpers/component-meta.ts +93 -0
  62. package/src/helpers/index.ts +1 -0
  63. package/src/helpers/lib-entries.ts +139 -0
  64. package/src/helpers/package-json.ts +96 -0
  65. package/src/helpers/utils.ts +82 -0
  66. package/src/helpers/vscode-custom-data.ts +35 -0
  67. package/src/index.ts +29 -0
  68. package/src/key-generate.ts +10 -0
  69. package/src/lint/fix.ts +7 -0
  70. package/src/lint/index.ts +27 -0
  71. package/src/make.ts +322 -0
  72. package/src/migrate/database.ts +1 -0
  73. package/src/migrate/dns.ts +3 -0
  74. package/src/prepublish.ts +17 -0
  75. package/src/release.ts +15 -0
  76. package/src/start-caddy.ts +13 -0
  77. package/src/test/coverage.ts +5 -0
  78. package/src/test/feature.ts +5 -0
  79. package/src/test/ui.ts +5 -0
  80. package/src/test/unit.ts +5 -0
  81. package/src/test.ts +5 -0
  82. package/src/tinker.ts +10 -0
  83. package/src/typecheck.ts +5 -0
  84. package/src/types.ts +20 -0
  85. package/src/upgrade/bun.ts +4 -0
  86. package/src/upgrade/dependencies.ts +0 -0
  87. package/src/upgrade/framework.ts +30 -0
  88. package/src/upgrade/index.ts +21 -0
  89. package/src/upgrade.ts +65 -0
  90. package/src/zip/api.ts +22 -0
@@ -0,0 +1 @@
1
+ // TODO: generate Caddyfile for the core app
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * This action generates the component meta.
5
+ */
6
+
7
+ import { log } from '@stacksjs/logging'
8
+ import { hasComponents } from '@stacksjs/storage'
9
+ import { generateComponentMeta } from '../helpers/component-meta'
10
+
11
+ log.info('Generating component meta...')
12
+
13
+ if (hasComponents())
14
+ generateComponentMeta()
15
+
16
+ else
17
+ log.info('No components found. Skipping component meta generation.')
18
+
19
+ log.success('Generated component meta.')
@@ -0,0 +1,89 @@
1
+ import { path as p } from '@stacksjs/path'
2
+ import { storage } from '@stacksjs/storage'
3
+ import { env as e, enums } from '@stacksjs/env'
4
+ import { logger } from '@stacksjs/logging'
5
+ import { envKeys } from '../../../../env'
6
+
7
+ logger.log('Generating type env files...')
8
+
9
+ // generate ./storage/framework/types/env.d.ts file from .env
10
+ const envTypes = `
11
+ // This file is auto-generated by Stacks. Do not edit this file manually.
12
+ // If you want to change the environment variables, please edit the .env file.
13
+ //
14
+ // For more information, please visit: https://stacksjs.org/docs
15
+
16
+ declare module 'bun' {
17
+ namespace env {
18
+ ${envKeys.map((key) => {
19
+ let type: string | undefined = typeof e[key]
20
+ let value: string | boolean | number | undefined = e[key]
21
+
22
+ if (!value) {
23
+ if (enums[key]) {
24
+ type = enums[key]?.map(item => `'${item}'`).join(' | ')
25
+ value = enums[key]?.[0] // default to the first enum value
26
+ }
27
+ else {
28
+ switch (type) {
29
+ case 'number':
30
+ value = '0'
31
+ break
32
+ case 'boolean':
33
+ value = false
34
+ break
35
+ default:
36
+ value = ''
37
+ }
38
+ }
39
+ }
40
+
41
+ type = 'string'
42
+ if (typeof value === 'string') {
43
+ if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
44
+ type = 'boolean'
45
+ }
46
+ else if (!Number.isNaN(Number.parseFloat(value)) && Number.isFinite(Number(value))) {
47
+ type = 'number'
48
+ }
49
+ else if (enums[key]) {
50
+ // @ts-expect-error enums[key] is defined
51
+ type = enums[key].map(item => `'${item}'`).join(' | ')
52
+ }
53
+ }
54
+
55
+ else if (typeof value === 'number') {
56
+ type = 'number'
57
+ }
58
+
59
+ else if (typeof value === 'boolean') {
60
+ type = 'boolean'
61
+ }
62
+
63
+ return `const ${key}: ${type}`
64
+ }).join('\n ')}
65
+ }
66
+ }
67
+ `
68
+
69
+ await storage.writeFile(p.frameworkPath('types/env.d.ts'), envTypes)
70
+
71
+ logger.log(' - ./storage/framework/env.ts')
72
+
73
+ // generate ./storage/framework/env.ts file based on Bun.env
74
+ const env = `
75
+ // This file is auto-generated by Stacks. Do not edit this file manually.
76
+ // If you want to change the environment variables, please edit the .env file.
77
+ //
78
+ // For more information, please visit: https://stacksjs.org/docs
79
+
80
+ export const envKeys = [
81
+ ${envKeys.map(key => `'${key}'`).join(',\n ')}
82
+ ] as const
83
+
84
+ export type EnvKey = typeof envKeys[number]
85
+ `
86
+
87
+ await storage.writeFile(p.frameworkPath('env.ts'), env)
88
+
89
+ logger.log(' - ./storage/framework/env.d.ts')
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * This action generates the web-types.json & custom-elements.json
5
+ * files for the components.
6
+ */
7
+
8
+ import { log } from '@stacksjs/logging'
9
+ import { hasComponents } from '@stacksjs/storage'
10
+ import { generateVsCodeCustomData, generateWebTypes } from '../helpers/vscode-custom-data'
11
+
12
+ if (hasComponents()) {
13
+ await generateWebTypes()
14
+ await generateVsCodeCustomData()
15
+ }
16
+ else {
17
+ log.info('No components found. Skipping IDE helper generation.')
18
+ }
@@ -0,0 +1,132 @@
1
+ import process from 'node:process'
2
+ import { log } from '@stacksjs/logging'
3
+ import { Action, NpmScript } from '@stacksjs/enums'
4
+ import type { GeneratorOptions } from '@stacksjs/types'
5
+ import { runNpmScript } from '@stacksjs/utils'
6
+ import { frameworkPath, projectPath } from '@stacksjs/path'
7
+ import { runAction } from '../helpers'
8
+
9
+ // import { files } from '@stacksjs/storage'
10
+
11
+ export async function invoke(options?: GeneratorOptions) {
12
+ if (options?.types)
13
+ await generateTypes(options)
14
+
15
+ else if (options?.entries)
16
+ await generateLibEntries(options)
17
+
18
+ else if (options?.webTypes)
19
+ await generateWebTypes(options)
20
+
21
+ else if (options?.customData)
22
+ await generateVsCodeCustomData(options)
23
+
24
+ else if (options?.ideHelpers)
25
+ await generateIdeHelpers(options)
26
+
27
+ else if (options?.componentMeta)
28
+ await generateComponentMeta(options)
29
+ }
30
+
31
+ export function generate(options: GeneratorOptions) {
32
+ return invoke(options)
33
+ }
34
+
35
+ export async function generateLibEntries(options: GeneratorOptions) {
36
+ const result = await runAction(Action.GenerateLibraryEntries, {
37
+ ...options,
38
+ cwd: projectPath(),
39
+ })
40
+
41
+ if (result.isErr()) {
42
+ log.error('There was an error generating your library entry points', result.error)
43
+ process.exit()
44
+ }
45
+
46
+ log.success('Library entry points generated successfully')
47
+ }
48
+
49
+ export async function generateWebTypes(options?: GeneratorOptions) {
50
+ const result = await runNpmScript(NpmScript.GenerateWebTypes, options)
51
+
52
+ if (result.isErr()) {
53
+ log.error('There was an error generating the web-types.json file.', result.error)
54
+ process.exit()
55
+ }
56
+
57
+ log.success('Successfully generated the web-types.json file')
58
+ }
59
+
60
+ export async function generateVsCodeCustomData(options?: GeneratorOptions) {
61
+ const result = await runNpmScript(NpmScript.GenerateVsCodeCustomData, {
62
+ cwd: frameworkPath(),
63
+ ...options,
64
+ })
65
+
66
+ if (result.isErr()) {
67
+ log.error('There was an error generating the custom-elements.json file.', result.error)
68
+ process.exit()
69
+ }
70
+
71
+ await runAction(Action.LintFix, { verbose: true }) // the generated json file needs to be linted
72
+ log.success('Successfully generated the custom-elements.json file')
73
+ }
74
+
75
+ export async function generateIdeHelpers(options?: GeneratorOptions) {
76
+ const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options)
77
+
78
+ if (result.isErr()) {
79
+ log.error('There was an error generating IDE helpers.', result.error)
80
+ process.exit()
81
+ }
82
+
83
+ await runAction(Action.LintFix, { verbose: true }) // the generated json file needs to be linted
84
+ log.success('Successfully generated IDE helpers')
85
+ }
86
+
87
+ export async function generateComponentMeta(options?: GeneratorOptions) {
88
+ const result = await runNpmScript(NpmScript.GenerateComponentMeta, options)
89
+
90
+ if (result.isErr()) {
91
+ log.error('There was an error generating your component meta information.', result.error)
92
+ process.exit()
93
+ }
94
+
95
+ await runAction(Action.LintFix, { verbose: true }) // the generated json file needs to be linted
96
+ log.success('Successfully generated component meta information')
97
+ }
98
+
99
+ export async function generateTypes(options?: GeneratorOptions) {
100
+ const result = await runNpmScript(NpmScript.GenerateTypes, {
101
+ cwd: frameworkPath(),
102
+ ...options,
103
+ })
104
+
105
+ if (result.isErr()) {
106
+ log.error('There was an error generating your types.', result.error)
107
+ process.exit()
108
+ }
109
+
110
+ log.success('Types were generated successfully')
111
+ }
112
+
113
+ export function generateMigrations() {
114
+ // const path = frameworkPath('database/schema.prisma')
115
+
116
+ // await migrate(path, { database: database.driver })
117
+
118
+ // await runCommand(`bunx prisma migrate dev --schema=${path}`)
119
+
120
+ log.success('Successfully updated migrations')
121
+ }
122
+
123
+ export function generatePkgxConfig() {
124
+ // write the yaml string to a file in your project root
125
+ // files.put(projectPath('./pkgx.yaml'), yamlStr)
126
+
127
+ log.success('Successfully generated `./pkgx.yaml` based on your configs')
128
+ }
129
+
130
+ export async function generateSeeder() {
131
+ // await seed()
132
+ }
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bun
2
+ import { log } from '@stacksjs/logging'
3
+ import { library } from '@stacksjs/config'
4
+ import { hasComponents, hasFunctions } from '@stacksjs/storage'
5
+ import { generateLibEntry } from '../helpers/lib-entries'
6
+
7
+ if (library.releaseable && hasComponents()) {
8
+ await generateLibEntry('vue-components')
9
+ await generateLibEntry('web-components')
10
+ }
11
+ else {
12
+ log.info('No components found. Skipping building component entry points.')
13
+ }
14
+
15
+ if (library.releaseable && hasFunctions())
16
+ await generateLibEntry('functions')
17
+ else
18
+ log.info('No functions found. Skipping building function entry point.')
@@ -0,0 +1,299 @@
1
+ import process from 'node:process'
2
+ import { db } from '@stacksjs/database'
3
+ import type { Collection } from '@stacksjs/collections'
4
+ import { collect } from '@stacksjs/collections'
5
+
6
+ export interface User {
7
+ id: number
8
+ name: string
9
+ email: string
10
+ password: string
11
+ created_at: Date
12
+ deleted_at: Date
13
+ }
14
+
15
+ export type UserColumn = keyof User
16
+ export type UserColumns = Array<keyof User>
17
+
18
+ export class UserModel {
19
+ private _data: User | undefined = undefined
20
+
21
+ private _isSelectInvoked = false
22
+ public _id: number | undefined = undefined
23
+ private cols: UserColumns = []
24
+ private useSoftDeletes = true
25
+ private keyName: keyof User = 'id'
26
+
27
+ queryBuilder = db.selectFrom('users')// Initialize queryBuilder
28
+ queryBuilderStore = db.insertInto('users')// Initialize queryBuilder
29
+ queryBuilderUpdate = db.updateTable('users')// Initialize queryBuilder
30
+ queryBuilderDelete = db.deleteFrom('users')// Initialize queryBuilder
31
+
32
+ public async find(id: number | number[]): Promise<User | Collection<User>> {
33
+ if (Array.isArray(id))
34
+ return await this.findMany(id)
35
+
36
+ let query = this.queryBuilder.selectAll()
37
+ .where(this.keyName, '=', id)
38
+
39
+ if (this.useSoftDeletes)
40
+ query = query.where('deleted_at', 'is', null)
41
+
42
+ this._data = await query.executeTakeFirst()
43
+
44
+ if (!this._data)
45
+ throw new Error('User not found!')
46
+
47
+ return this._createProxy()
48
+ }
49
+
50
+ public async findMany(id: number[] | string[]): Promise<User | Collection<User>> {
51
+ return await this.whereIn(this.keyName, id).get()
52
+ }
53
+
54
+ private _createProxy() {
55
+ return new Proxy(this._data || {}, {
56
+ get: (target: User, prop: UserColumn) => {
57
+ // Property lookup in the User data
58
+ if (prop in target)
59
+ return target[prop]
60
+
61
+ // If it's a method on the UserModel, bind it
62
+ const method = this[prop as keyof this]
63
+ if (typeof method === 'function')
64
+ return method.bind(this)
65
+
66
+ return undefined
67
+ },
68
+ })
69
+ }
70
+
71
+ public async update(obj: Partial<User>): Promise<User | undefined | Collection<User>> {
72
+ if (this._data && this._data?.id) {
73
+ await this.queryBuilderUpdate.set(obj)
74
+ .where(this.keyName, '=', this._data?.id)
75
+ .executeTakeFirst()
76
+
77
+ return await this.find(this._data?.id)
78
+ }
79
+
80
+ return undefined
81
+ }
82
+
83
+ public async all() {
84
+ return await this.queryBuilder.selectAll()
85
+ .execute()
86
+ }
87
+
88
+ public async get(): Promise<Collection<User>> {
89
+ if (this.useSoftDeletes)
90
+ return collect(await this.getSoftDeletes())
91
+
92
+ if (this._isSelectInvoked)
93
+ return collect(await this.queryBuilder.select(this.cols).execute())
94
+
95
+ return collect(await this.queryBuilder.selectAll().execute())
96
+ }
97
+
98
+ public async trashed() {
99
+ if (this._isSelectInvoked)
100
+ return await this.queryBuilder.where('deleted_at', 'is not', null).select(this.cols).execute()
101
+
102
+ return await this.queryBuilder.where('deleted_at', 'is not', null).selectAll().execute()
103
+ }
104
+
105
+ private async getSoftDeletes() {
106
+ if (this._isSelectInvoked)
107
+ return await this.queryBuilder.where('deleted_at', 'is', null).select(this.cols).execute()
108
+
109
+ return await this.queryBuilder.where('deleted_at', 'is', null).selectAll().execute()
110
+ }
111
+
112
+ public where(...args: (string | number | boolean)[]): this {
113
+ if (args.length === 2) {
114
+ const [column, value] = args
115
+ this.queryBuilder = this.queryBuilder.where(column as UserColumn, '=', value)
116
+ }
117
+ else { this.queryBuilder = this.queryBuilder.where(...args) }
118
+
119
+ return this
120
+ }
121
+
122
+ public orWhere(...args: (string | number | boolean)[]): this {
123
+ this.queryBuilder = this.queryBuilder.where(eb => eb.or([
124
+ eb(...args),
125
+ ]))
126
+
127
+ return this
128
+ }
129
+
130
+ public whereIn(...args: (string[] | string | number[] | boolean[])[]): this {
131
+ if (args.length === 2) {
132
+ const [column, value] = args
133
+ this.queryBuilder = this.queryBuilder.where(column, 'in', value)
134
+ }
135
+ else { this.queryBuilder = this.queryBuilder.where(...args) }
136
+
137
+ return this
138
+ }
139
+
140
+ public whereNull(col: UserColumn): this {
141
+ this.queryBuilder = this.queryBuilder.where(col, 'is', null)
142
+
143
+ return this
144
+ }
145
+
146
+ public when(condition: boolean, callback: (instance: this) => any): this {
147
+ if (condition)
148
+ callback(this)
149
+
150
+ return this
151
+ }
152
+
153
+ public whereNotNull(col: UserColumn): this {
154
+ this.queryBuilder = this.queryBuilder.where(col, 'is not', null)
155
+
156
+ return this
157
+ }
158
+
159
+ public distinct() {
160
+ this.queryBuilder = this.queryBuilder.distinct()
161
+
162
+ return this
163
+ }
164
+
165
+ public distinctOn(col: UserColumn): this {
166
+ this.queryBuilder = this.queryBuilder.distinctOn(col)
167
+
168
+ return this
169
+ }
170
+
171
+ public limit(limit: number): this {
172
+ this.queryBuilder = this.queryBuilder.limit(limit)
173
+
174
+ return this
175
+ }
176
+
177
+ public orderBy(col: UserColumn) {
178
+ this.queryBuilder = this.queryBuilder.orderBy(col)
179
+
180
+ return this
181
+ }
182
+
183
+ public groupBy(col: UserColumn) {
184
+ this.queryBuilder = this.queryBuilder.groupBy(col)
185
+
186
+ return this
187
+ }
188
+
189
+ public innerJoin(...args: string[]): this {
190
+ this.queryBuilder = this.queryBuilder.innerJoin(...args)
191
+
192
+ return this
193
+ }
194
+
195
+ public join(...args: string[]): this {
196
+ this.queryBuilder = this.queryBuilder.innerJoin(...args)
197
+
198
+ return this
199
+ }
200
+
201
+ public having(...args: string[]): this {
202
+ this.queryBuilder = this.queryBuilder.having(...args)
203
+
204
+ return this
205
+ }
206
+
207
+ public rightJoin(...args: string[]): this {
208
+ this.queryBuilder = this.queryBuilder.rightJoin(...args)
209
+
210
+ return this
211
+ }
212
+
213
+ public leftJoin(...args: string[]): this {
214
+ this.queryBuilder = this.queryBuilder.leftJoin(...args)
215
+
216
+ return this
217
+ }
218
+
219
+ public offset(offset: number): this {
220
+ this.queryBuilder = this.queryBuilder.offset(offset)
221
+
222
+ return this
223
+ }
224
+
225
+ public fullJoin(...args: string[]): this {
226
+ this.queryBuilder = this.queryBuilder.fullJoin(...args)
227
+
228
+ return this
229
+ }
230
+
231
+ public innerJoinLateral(...args: string[]) {
232
+ this.queryBuilder.innerJoinLateral(...args)
233
+
234
+ return this
235
+ }
236
+
237
+ public leftJoinLateral(...args) {
238
+ this.queryBuilder.leftJoinLateral(...args)
239
+
240
+ return this
241
+ }
242
+
243
+ public orderByDesc(col: UserColumn): this {
244
+ this.queryBuilder = this.queryBuilder.orderBy(col, 'desc')
245
+
246
+ return this
247
+ }
248
+
249
+ public select(...args: UserColumns): this {
250
+ this.cols = args
251
+ this._isSelectInvoked = true
252
+
253
+ // TODO: resolve this
254
+ // @ts-expect-error resolve this
255
+ this.queryBuilder = this.queryBuilder.select(...args)
256
+
257
+ return this
258
+ }
259
+
260
+ public async first(): Promise<User> {
261
+ // Execute the query using queryBuilder
262
+ if (this._isSelectInvoked)
263
+ this._data = await this.queryBuilder.select(this.cols).executeTakeFirst()
264
+ else
265
+ this._data = await this.queryBuilder.selectAll().executeTakeFirst()
266
+
267
+ return this._createProxy()
268
+ }
269
+
270
+ public store(obj: any[]): User {
271
+ // Execute the query using queryBuilder
272
+ return this.queryBuilderStore.values(obj)
273
+ .executeTakeFirst()
274
+ }
275
+
276
+ public createMany(obj: any[]): User[] {
277
+ // Execute the query using queryBuilder
278
+ return this.queryBuilderStore.values(obj)
279
+ .executeTakeFirst()
280
+ }
281
+
282
+ public async delete(): Promise<any> {
283
+ if (this._data && this._data?.id) {
284
+ if (this.useSoftDeletes)
285
+ return await this.update({ deleted_at: new Date() })
286
+
287
+ return this.forceDelete()
288
+ }
289
+ }
290
+
291
+ public forceDelete(): any {
292
+ if (this._data && this._data?.id) {
293
+ return this.queryBuilderDelete.where(this.keyName, '=', this._data?.id)
294
+ .executeTakeFirst()
295
+ }
296
+ }
297
+ }
298
+
299
+ process.exit(0)
@@ -0,0 +1,12 @@
1
+ import { path as p } from '@stacksjs/path'
2
+
3
+ const modelGenerate = Bun.file('model-classes.ts') // Assuming Bun is imported properly
4
+ const file = Bun.file(p.projectStoragePath('framework/orm/UserModel.ts'))
5
+
6
+ const code = await modelGenerate.text()
7
+
8
+ const writer = file.writer()
9
+
10
+ writer.write(code)
11
+
12
+ await writer.end()
@@ -0,0 +1,72 @@
1
+ // generates the pkgx file based on the user configuration
2
+ import { config } from '@stacksjs/config'
3
+ import { runCommand } from '@stacksjs/cli'
4
+
5
+ // @ts-expect-error - no types
6
+ import data from '../../../../../pkgx.yaml'
7
+
8
+ if (!data)
9
+ throw new Error('pkgx.yaml file not found')
10
+
11
+ if (data.dependencies['aws.amazon.com/cdk'] === undefined) {
12
+ log.info('aws.amazon.com/cdk dependency not found in pkgx.yaml.')
13
+ // throw an error unless its installed locally
14
+ const result = await runCommand('which cdk')
15
+ if (result.isErr())
16
+ throw new Error('aws.amazon.com/cdk dependency not found in pkgx.yaml. To confirm, run `which cdk`')
17
+ }
18
+
19
+ if (data.dependencies['aws.amazon.com/cli'] === undefined) {
20
+ log.info('aws.amazon.com/cli dependency not found in pkgx.yaml.')
21
+ const result = await runCommand('which aws')
22
+ if (result.isErr())
23
+ throw new Error('aws.amazon.com/cli dependency not found in pkgx.yaml. To confirm, run `which aws`')
24
+ }
25
+
26
+ if (data.dependencies['bun.sh'] === undefined) {
27
+ log.info('bun.sh dependency not found in pkgx.yaml.')
28
+ // throw an error unless its installed locally
29
+ const result = await runCommand('which aws')
30
+ if (result.isErr())
31
+ throw new Error('bun.sh dependency not found in pkgx.yaml. To confirm, run `which bun`')
32
+ }
33
+
34
+ if (data.dependencies['info-zip.org/zip'] === undefined) {
35
+ log.info('info-zip.org/zip dependency not found in pkgx.yaml.')
36
+ // throw an error unless its installed locally
37
+ const result = await runCommand('which zip')
38
+ if (result.isErr())
39
+ throw new Error('info-zip.org/zip dependency not found in pkgx.yaml. To confirm, run `which zip`')
40
+ }
41
+
42
+ if (data.dependencies['info-zip.org/unzip'] === undefined) {
43
+ log.info('info-zip.org/unzip dependency not found in pkgx.yaml.')
44
+ // throw an error unless its installed locally
45
+ const result = await runCommand('which unzip')
46
+ if (result.isErr())
47
+ throw new Error('info-zip.org/unzip dependency not found in pkgx.yaml. To confirm, run `which unzip`')
48
+ }
49
+
50
+ if (data.dependencies['mailpit.axllent.org'] === undefined) {
51
+ log.info('mailpit.axllent.org dependency not found in pkgx.yaml.')
52
+ // throw an error unless its installed locally
53
+ const result = await runCommand('which mailpit')
54
+ if (result.isErr())
55
+ throw new Error('mailpit.axllent.org dependency not found in pkgx.yaml. To confirm, run `which mailpit`')
56
+ }
57
+
58
+ if (data.dependencies['redis.io'] === undefined) {
59
+ log.info('redis.io dependency not found in pkgx.yaml.')
60
+ // throw an error unless its installed locally
61
+ const result = await runCommand('which redis')
62
+ if (result.isErr())
63
+ throw new Error('redis.io dependency not found in pkgx.yaml. To confirm, run `which redis`')
64
+ }
65
+
66
+ if (config.database.default === 'sqlite' && data.dependencies['sqlite.org'] === undefined) {
67
+ log.info('sqlite.org dependency not found in pkgx.yaml.')
68
+ // throw an error unless its installed locally
69
+ const result = await runCommand('which sqlite')
70
+ if (result.isErr())
71
+ throw new Error('sqlite.org dependency not found in pkgx.yaml. To confirm, run `which sqlite`')
72
+ }
@@ -0,0 +1,6 @@
1
+ // generate types for ./resources/components & ./resources/function
2
+ // currently triggered via buddy dev / vite
3
+ import { log } from '@stacksjs/cli'
4
+
5
+ log.info('Generating types for ./resources/components & ./resources/function')
6
+ log.info('Generated types saved in ./storage/framework/types/*')
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * This action generates the web-types.json & custom-elements.json
5
+ * files for the components.
6
+ */
7
+
8
+ import { log } from '@stacksjs/logging'
9
+ import { hasComponents } from '@stacksjs/storage'
10
+ import { generateVsCodeCustomData } from '../helpers/vscode-custom-data'
11
+
12
+ log.info('Generating VS Code custom data...')
13
+
14
+ if (hasComponents())
15
+ await generateVsCodeCustomData()
16
+
17
+ else log.info('No components found. Skipping VS Code custom data generation.')
18
+
19
+ log.success('Generated VS Code custom data.')
@@ -0,0 +1,2 @@
1
+ // generate types for ./resources/components & ./resources/function
2
+ // currently triggered via buddy dev / vite