@stacksjs/actions 0.58.48 → 0.58.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/generate/ide-helpers.js +1 -0
- package/dist/src/generate/lib-entries.js +4 -2
- package/dist/src/generate/vscode-custom-data.js +1 -0
- package/dist/src/helpers/lib-entries.js +1 -0
- package/dist/src/helpers/package-json.js +1 -0
- package/dist/src/helpers/vscode-custom-data.js +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/release.js +2 -0
- package/dist/src/upgrade.js +1 -1
- package/package.json +3 -2
- package/src/action.ts +13 -0
- package/src/actions.ts +2 -0
- package/src/add.ts +27 -0
- package/src/ai/request-model-access.ts +74 -0
- package/src/build/cli.ts +7 -0
- package/src/build/component-libs.ts +5 -0
- package/src/build/core.ts +34 -0
- package/src/build/desktop.ts +7 -0
- package/src/build/docs.ts +7 -0
- package/src/build/stacks.ts +7 -0
- package/src/build.ts +89 -0
- package/src/bump.ts +11 -0
- package/src/cdn/invalidate-cache.ts +27 -0
- package/src/changelog.ts +11 -0
- package/src/clean.ts +6 -0
- package/src/commit.ts +14 -0
- package/src/copy-types.ts +22 -0
- package/src/database/fields.ts +111 -0
- package/src/database/migration-mysql.ts +72 -0
- package/src/database/migration-sqlite.ts +67 -0
- package/src/database/migration.ts +10 -0
- package/src/database/mydb.sqlite +0 -0
- package/src/database/seed.ts +4 -0
- package/src/database/stacks.sqlite +0 -0
- package/src/database/user-migration.ts +20 -0
- package/src/deploy/create-receipt-rule.ts +55 -0
- package/src/deploy/index.ts +46 -0
- package/src/dev/api.ts +19 -0
- package/src/dev/components.ts +14 -0
- package/src/dev/dashboard.ts +7 -0
- package/src/dev/desktop.ts +7 -0
- package/src/dev/docs.ts +7 -0
- package/src/dev/index.ts +48 -0
- package/src/dev/system-tray.ts +6 -0
- package/src/dev/views.ts +7 -0
- package/src/domains/add.ts +82 -0
- package/src/domains/purchase.ts +76 -0
- package/src/domains/remove.ts +38 -0
- package/src/examples.ts +46 -0
- package/src/fresh.ts +20 -0
- package/src/generate/caddyfile.ts +1 -0
- package/src/generate/component-meta.ts +19 -0
- package/src/generate/custom-cli-file.ts +24 -0
- package/src/generate/env-files.ts +89 -0
- package/src/generate/ide-helpers.ts +18 -0
- package/src/generate/index.ts +132 -0
- package/src/generate/lib-entries.ts +18 -0
- package/src/generate/model-classes.ts +299 -0
- package/src/generate/model-generate.ts +12 -0
- package/src/generate/pkgx-file.ts +72 -0
- package/src/generate/types.ts +6 -0
- package/src/generate/vscode-custom-data.ts +19 -0
- package/src/generate/web-types.ts +2 -0
- package/src/helpers/component-meta.ts +93 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/lib-entries.ts +139 -0
- package/src/helpers/package-json.ts +96 -0
- package/src/helpers/utils.ts +82 -0
- package/src/helpers/vscode-custom-data.ts +35 -0
- package/src/index.ts +29 -0
- package/src/key-generate.ts +10 -0
- package/src/lint/fix.ts +7 -0
- package/src/lint/index.ts +27 -0
- package/src/make.ts +322 -0
- package/src/migrate/database.ts +1 -0
- package/src/migrate/dns.ts +3 -0
- package/src/prepublish.ts +17 -0
- package/src/release.ts +15 -0
- package/src/start-caddy.ts +13 -0
- package/src/test/coverage.ts +5 -0
- package/src/test/feature.ts +5 -0
- package/src/test/ui.ts +5 -0
- package/src/test/unit.ts +5 -0
- package/src/test.ts +5 -0
- package/src/tinker.ts +10 -0
- package/src/typecheck.ts +5 -0
- package/src/types.ts +20 -0
- package/src/upgrade/bun.ts +4 -0
- package/src/upgrade/dependencies.ts +0 -0
- package/src/upgrade/framework.ts +30 -0
- package/src/upgrade/index.ts +21 -0
- package/src/upgrade.ts +65 -0
- package/src/zip/api.ts +22 -0
package/src/make.ts
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { italic } from '@stacksjs/cli'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import { createFolder, doesFolderExist, writeTextFile } from '@stacksjs/storage'
|
|
5
|
+
import { frameworkPath, projectPath, resolve } from '@stacksjs/path'
|
|
6
|
+
import type { MakeOptions } from '@stacksjs/types'
|
|
7
|
+
|
|
8
|
+
export async function invoke(options: MakeOptions) {
|
|
9
|
+
if (options.component)
|
|
10
|
+
await makeComponent(options)
|
|
11
|
+
|
|
12
|
+
if (options.database)
|
|
13
|
+
makeDatabase(options)
|
|
14
|
+
|
|
15
|
+
if (options.function)
|
|
16
|
+
await makeFunction(options)
|
|
17
|
+
|
|
18
|
+
if (options.language)
|
|
19
|
+
await makeLanguage(options)
|
|
20
|
+
|
|
21
|
+
// if (options.migration)
|
|
22
|
+
// await migration(options)
|
|
23
|
+
|
|
24
|
+
if (options.notification)
|
|
25
|
+
await makeNotification(options)
|
|
26
|
+
|
|
27
|
+
if (options.page)
|
|
28
|
+
await makePage(options)
|
|
29
|
+
|
|
30
|
+
if (options.stack)
|
|
31
|
+
makeStack(options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function make(options: MakeOptions) {
|
|
35
|
+
return invoke(options)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function makeComponent(options: MakeOptions) {
|
|
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
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
log.error('There was an error creating your component', error)
|
|
47
|
+
process.exit()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function createComponent(options: MakeOptions) {
|
|
52
|
+
const name = options.name
|
|
53
|
+
await writeTextFile({
|
|
54
|
+
path: `./components/${name}.stx`,
|
|
55
|
+
data: `<script setup lang="ts">
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.log('Hello World component created')
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div>
|
|
62
|
+
Some HTML block
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
`,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function makeDatabase(options: MakeOptions) {
|
|
70
|
+
try {
|
|
71
|
+
const name = options.name
|
|
72
|
+
log.info(`Creating your ${italic(name)} database...`)
|
|
73
|
+
createDatabase(options)
|
|
74
|
+
log.success(`Created ${italic(name)} database`)
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
log.error('There was an error creating your database', error)
|
|
78
|
+
process.exit()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function createDatabase(options: MakeOptions) {
|
|
83
|
+
// eslint-disable-next-line no-console
|
|
84
|
+
console.log('options', options) // wip
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function factory(options: MakeOptions) {
|
|
88
|
+
try {
|
|
89
|
+
const name = options.name
|
|
90
|
+
log.info(`Creating your ${italic(name)} factory...`)
|
|
91
|
+
createDatabase(options)
|
|
92
|
+
log.success(`Created ${italic(name)} factory`)
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
log.error('There was an error creating your factory', error)
|
|
96
|
+
process.exit()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function createFactory(options: MakeOptions) {
|
|
101
|
+
// eslint-disable-next-line no-console
|
|
102
|
+
console.log('options', options) // wip
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function makeNotification(options: MakeOptions) {
|
|
106
|
+
try {
|
|
107
|
+
const name = options.name
|
|
108
|
+
log.info(`Creating your ${italic(name)} notification...`)
|
|
109
|
+
await createNotification(options)
|
|
110
|
+
log.success(`Created ${italic(name)} notification`)
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
log.error('There was an error creating your notification', error)
|
|
114
|
+
process.exit()
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function makePage(options: MakeOptions) {
|
|
119
|
+
try {
|
|
120
|
+
const name = options.name
|
|
121
|
+
log.info('Creating your page...')
|
|
122
|
+
await createPage(options)
|
|
123
|
+
log.success(`Created ${name} page`)
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
log.error('There was an error creating your page', error)
|
|
127
|
+
process.exit()
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function createPage(options: MakeOptions) {
|
|
132
|
+
const name = options.name
|
|
133
|
+
await writeTextFile({
|
|
134
|
+
path: `./pages/${name}.stx`,
|
|
135
|
+
data:
|
|
136
|
+
`<script setup lang="ts">
|
|
137
|
+
// eslint-disable-next-line no-console
|
|
138
|
+
console.log('Hello World page created')
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
<template>
|
|
142
|
+
<div>
|
|
143
|
+
Visit http://127.0.0.1/${name}
|
|
144
|
+
</div>
|
|
145
|
+
</template>
|
|
146
|
+
`,
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function makeFunction(options: MakeOptions) {
|
|
151
|
+
try {
|
|
152
|
+
const name = options.name
|
|
153
|
+
log.info('Creating your function...')
|
|
154
|
+
await createFunction(options)
|
|
155
|
+
log.success(`Created ${name} function`)
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
log.error('There was an error creating your function', error)
|
|
159
|
+
process.exit()
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function createFunction(options: MakeOptions) {
|
|
164
|
+
const name = options.name
|
|
165
|
+
await writeTextFile({
|
|
166
|
+
path: `./functions/${name}.ts`,
|
|
167
|
+
data: `// reactive state
|
|
168
|
+
const ${name} = ref(0)
|
|
169
|
+
|
|
170
|
+
// functions that mutate state and trigger updates
|
|
171
|
+
function increment() {
|
|
172
|
+
${name}.value++
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
${name},
|
|
177
|
+
increment,
|
|
178
|
+
}
|
|
179
|
+
`,
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export async function makeLanguage(options: MakeOptions) {
|
|
184
|
+
try {
|
|
185
|
+
const name = options.name
|
|
186
|
+
log.info('Creating your translation file...')
|
|
187
|
+
await createLanguage(options)
|
|
188
|
+
log.success(`Created ${name} translation file`)
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
log.error('There was an error creating your language.', error)
|
|
192
|
+
process.exit()
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export async function createLanguage(options: MakeOptions) {
|
|
197
|
+
const name = options.name
|
|
198
|
+
await writeTextFile({
|
|
199
|
+
path: `./lang/${name}.yml`,
|
|
200
|
+
data: `button:
|
|
201
|
+
text: Copy
|
|
202
|
+
`,
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function makeStack(options: MakeOptions) {
|
|
207
|
+
try {
|
|
208
|
+
const name = options.name
|
|
209
|
+
log.info(`Creating your ${name} stack...`)
|
|
210
|
+
const path = resolve(process.cwd(), name)
|
|
211
|
+
|
|
212
|
+
// await spawn(`giget stacks ${path}`)
|
|
213
|
+
log.success('Successfully scaffolded your project')
|
|
214
|
+
log.info(`cd ${path} && bun install`)
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
log.error('There was an error creating your stack', error)
|
|
218
|
+
process.exit()
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function createNotification(options: MakeOptions) {
|
|
223
|
+
const name = options.name
|
|
224
|
+
try {
|
|
225
|
+
let importOption = 'EmailOptions'
|
|
226
|
+
|
|
227
|
+
if (!doesFolderExist('notifications'))
|
|
228
|
+
await createFolder('./notifications')
|
|
229
|
+
|
|
230
|
+
if (options.chat)
|
|
231
|
+
importOption = 'ChatOptions'
|
|
232
|
+
|
|
233
|
+
if (options.sms)
|
|
234
|
+
importOption = 'SMSOptions'
|
|
235
|
+
|
|
236
|
+
await writeTextFile({
|
|
237
|
+
path: `./notifications/${name}.ts`,
|
|
238
|
+
data: `import type { ${importOption} } from \'@stacksjs/types\'
|
|
239
|
+
|
|
240
|
+
function content(): string {
|
|
241
|
+
return 'example'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function send(): ${importOption} {
|
|
245
|
+
return {
|
|
246
|
+
content: content(),
|
|
247
|
+
}
|
|
248
|
+
}`,
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
return true
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
return false
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export async function createMigration(options: MakeOptions) {
|
|
259
|
+
const optionName = options.name
|
|
260
|
+
// const table = options.tableName
|
|
261
|
+
const table = 'dummy-name'
|
|
262
|
+
const name = optionName[0].toUpperCase() + optionName.slice(1)
|
|
263
|
+
const path = frameworkPath(`database/migrations/${name}.ts`)
|
|
264
|
+
|
|
265
|
+
try {
|
|
266
|
+
await writeTextFile({
|
|
267
|
+
path: `${path}`,
|
|
268
|
+
data: `import { Kysely } from 'kysely'
|
|
269
|
+
|
|
270
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
271
|
+
await db.schema
|
|
272
|
+
.createTable('${table}')
|
|
273
|
+
.addColumn('id', 'integer', (col) => col.autoIncrement().primaryKey())
|
|
274
|
+
.execute()
|
|
275
|
+
}`,
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
log.success(`Successfully created your migration file at stacks/database/migrations/${name}.ts`)
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
log.error(error)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export async function createModel(options: MakeOptions) {
|
|
286
|
+
const optionName = options.name
|
|
287
|
+
const name = optionName[0].toUpperCase() + optionName.slice(1)
|
|
288
|
+
const path = projectPath(`app/Models/${name}.ts`)
|
|
289
|
+
try {
|
|
290
|
+
await writeTextFile({
|
|
291
|
+
path: `${path}`,
|
|
292
|
+
data: `import { faker } from '@stacksjs/faker'
|
|
293
|
+
import { validate } from '@stacksjs/validation'
|
|
294
|
+
import type { Model } from '@stacksjs/types'
|
|
295
|
+
|
|
296
|
+
export default <Model> {
|
|
297
|
+
name: '${name}',
|
|
298
|
+
|
|
299
|
+
searchable: true, // boolean | IndexSettings,
|
|
300
|
+
authenticatable: true, // boolean | AuthSettings,
|
|
301
|
+
|
|
302
|
+
seeder: {
|
|
303
|
+
count: 10,
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
fields: {
|
|
307
|
+
name: {
|
|
308
|
+
validation: validate.string().min(3).max(255),
|
|
309
|
+
factory: () => faker.person,
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
// more fields here
|
|
313
|
+
},
|
|
314
|
+
}`,
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
log.success(`Successfully created your model at app/Models/${name}.ts`)
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
log.error(error)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// wip
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log } from '@stacksjs/logging'
|
|
3
|
+
import { runtimePath } from '@stacksjs/path'
|
|
4
|
+
import { runNpmScript } from '@stacksjs/utils'
|
|
5
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
6
|
+
|
|
7
|
+
log.info('Running prepublish command...')
|
|
8
|
+
|
|
9
|
+
// right before we publish, we need to build Stacks
|
|
10
|
+
const result = await runNpmScript(NpmScript.BuildStacks, { verbose: true, cwd: runtimePath() })
|
|
11
|
+
|
|
12
|
+
if (result.isErr()) {
|
|
13
|
+
log.error(new Error('There was an error while prepublishing your stack'), result.error)
|
|
14
|
+
process.exit()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
log.success('Prepublishing completed')
|
package/src/release.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { projectPath } from '@stacksjs/path'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
4
|
+
import { log } from '@stacksjs/logging'
|
|
5
|
+
import { app } from '@stacksjs/config'
|
|
6
|
+
import { runActions } from '.'
|
|
7
|
+
|
|
8
|
+
await runActions([
|
|
9
|
+
Action.GenerateLibraryEntries, // generates the package/library entry points
|
|
10
|
+
Action.LintFix, // ensure there are no lint errors
|
|
11
|
+
// Action.Test, // run the tests
|
|
12
|
+
Action.Bump, // bump the versions, create the git tag, generate the changelog, commit & push the changes
|
|
13
|
+
], { cwd: projectPath(), stdin: 'inherit' }) // debug mode needs to be enabled to see the output due to the interactive prompts
|
|
14
|
+
|
|
15
|
+
log.success(`Successfully released ${app.name}`)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
2
|
+
import { runCommand } from '@stacksjs/cli'
|
|
3
|
+
import { path as p } from '@stacksjs/path'
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line no-console
|
|
6
|
+
console.log('Starting Caddy...')
|
|
7
|
+
|
|
8
|
+
const result = await runCommand('caddy run', {
|
|
9
|
+
cwd: p.frameworkPath(),
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
if (result.isErr())
|
|
13
|
+
handleError(result.error)
|
package/src/test/ui.ts
ADDED
package/src/test/unit.ts
ADDED
package/src/test.ts
ADDED
package/src/tinker.ts
ADDED
package/src/typecheck.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log } from '@stacksjs/logging'
|
|
3
|
+
import { runNpmScript } from '@stacksjs/utils'
|
|
4
|
+
import type { TypesOptions } from '@stacksjs/types'
|
|
5
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
6
|
+
|
|
7
|
+
export async function invoke(options?: TypesOptions) {
|
|
8
|
+
const results = await runNpmScript(NpmScript.TypesFix, options)
|
|
9
|
+
|
|
10
|
+
if (results.isErr()) {
|
|
11
|
+
log.error('There was an error fixing your types.', results.error)
|
|
12
|
+
process.exit()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
log.success('Types are set')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function types(options: TypesOptions) {
|
|
19
|
+
return invoke(options)
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// import { outro } from '@stacksjs/cli'
|
|
2
|
+
// import { log } from '@stacksjs/logging'
|
|
3
|
+
// import * as storage from '@stacksjs/storage'
|
|
4
|
+
// import { determineDebugLevel, loop } from '@stacksjs/utils'
|
|
5
|
+
// import { frameworkPath, projectPath } from '@stacksjs/path'
|
|
6
|
+
//
|
|
7
|
+
// // await runCommand(NpmScript.UpgradeFramework, parseArgs())
|
|
8
|
+
//
|
|
9
|
+
// await checkForUncommittedChanges('./stacks', options)
|
|
10
|
+
// await downloadFrameworkUpdate(options)
|
|
11
|
+
//
|
|
12
|
+
// log.info('Updating framework...')
|
|
13
|
+
//
|
|
14
|
+
// const exclude = ['functions/package.json', 'components/vue/package.json', 'components/web/package.json', 'auto-imports.d.ts', 'components.d.ts', 'dist']
|
|
15
|
+
// await storage.deleteFiles(frameworkPath(), exclude)
|
|
16
|
+
//
|
|
17
|
+
// // loop 5 times to make sure all "deep empty" folders are deleted
|
|
18
|
+
// loop(5, async () => {
|
|
19
|
+
// await storage.deleteEmptyFolders(frameworkPath())
|
|
20
|
+
// })
|
|
21
|
+
//
|
|
22
|
+
// await storage.copyFolder(frameworkPath(), projectPath('./updates/stacks'), exclude)
|
|
23
|
+
//
|
|
24
|
+
// if (determineDebugLevel(options))
|
|
25
|
+
// log.info('Cleanup...')
|
|
26
|
+
//
|
|
27
|
+
// await storage.deleteFolder(projectPath('updates'))
|
|
28
|
+
//
|
|
29
|
+
// outro('Framework updated', { startTime: perf, useSeconds: true })
|
|
30
|
+
// process.exit()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode, parseArgs } from '@stacksjs/cli'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
4
|
+
import { runAction } from '../helpers'
|
|
5
|
+
|
|
6
|
+
const options = parseArgs()
|
|
7
|
+
|
|
8
|
+
// run all the upgrade actions
|
|
9
|
+
if (options?.framework || options?.all)
|
|
10
|
+
await updateFramework(options)
|
|
11
|
+
|
|
12
|
+
if (options?.dependencies || options?.all)
|
|
13
|
+
await updateDependencies(options)
|
|
14
|
+
|
|
15
|
+
if (options?.bun || options?.all)
|
|
16
|
+
await runAction(Action.UpgradeBun, options)
|
|
17
|
+
|
|
18
|
+
process.exit(ExitCode.InvalidArgument)
|
|
19
|
+
|
|
20
|
+
// TODO: also update CI files & configurations, and other files, possibly (taze?)
|
|
21
|
+
// we want this to be smart enough to update only if files that have been updated
|
package/src/upgrade.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { intro, outro, runCommand } from '@stacksjs/cli'
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import { projectPath } from '@stacksjs/path'
|
|
5
|
+
import * as storage from '@stacksjs/storage'
|
|
6
|
+
import type { UpgradeOptions } from '@stacksjs/types'
|
|
7
|
+
import { version } from '../package.json'
|
|
8
|
+
|
|
9
|
+
// import { determineDebugLevel } from '@stacksjs/utils'
|
|
10
|
+
|
|
11
|
+
// export async function checkForUncommittedChanges(path = './stacks', options: UpgradeOptions) {
|
|
12
|
+
export function checkForUncommittedChanges(options: UpgradeOptions) {
|
|
13
|
+
try {
|
|
14
|
+
// const stdio = determineDebugLevel(options) ? 'inherit' : 'ignore'
|
|
15
|
+
|
|
16
|
+
// check if the stacks folder has any updates
|
|
17
|
+
// https://carlosbecker.com/posts/git-changed/
|
|
18
|
+
// await spawn(`git diff --quiet HEAD -- ${path}`, { stdio, cwd: projectPath() })
|
|
19
|
+
}
|
|
20
|
+
catch (error: any) {
|
|
21
|
+
if (error.status === 1) {
|
|
22
|
+
// even though the ./stacks folder should not be edited, instead config values should be adjusted,
|
|
23
|
+
// there is a chance that users may apply local core edits, as it's totally acceptable, as long as
|
|
24
|
+
// the user knows what they are doing. There is also a change that simply the deps within stacks
|
|
25
|
+
// folder have been updated and that could produce a diff.
|
|
26
|
+
if (!options?.force) {
|
|
27
|
+
// const confirmed = await log.prompt('We detected there are uncommitted in the ./stacks folder. Do you want to overwrite those?', {
|
|
28
|
+
// type: 'confirm',
|
|
29
|
+
// })
|
|
30
|
+
|
|
31
|
+
// if (!confirmed) {
|
|
32
|
+
// log.info('Aborted. Stacks did not update itself.')
|
|
33
|
+
// log.info('Note: if you commit your changes and replay the update, you can see what changed.')
|
|
34
|
+
// process.exit(ExitCode.Success)
|
|
35
|
+
// }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function downloadFrameworkUpdate(options: UpgradeOptions) {
|
|
42
|
+
const tempFolderName = 'updates'
|
|
43
|
+
const tempUpdatePath = projectPath(tempFolderName)
|
|
44
|
+
|
|
45
|
+
if (storage.doesFolderExist(tempUpdatePath))
|
|
46
|
+
await deleteFolder(tempUpdatePath)
|
|
47
|
+
|
|
48
|
+
log.info('Downloading framework updates...')
|
|
49
|
+
await runCommand(`giget stacks ${tempFolderName}`, options)
|
|
50
|
+
log.success(`Your framework updated correctly to version: v${version}`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// export async function updateDependencies(options: UpgradeOptions) {
|
|
54
|
+
export async function updateDependencies() {
|
|
55
|
+
const perf = await intro('buddy upgrade:dependencies')
|
|
56
|
+
const result = await runCommand(NpmScript.UpgradeDependencies, options)
|
|
57
|
+
|
|
58
|
+
if (result.isErr()) {
|
|
59
|
+
outro('While running the upgrade:dependencies command, there was an issue', { startTime: perf, useSeconds: true }, result.error)
|
|
60
|
+
process.exit()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await outro('Freshly updated your dependencies.', { startTime: perf, useSeconds: true })
|
|
64
|
+
process.exit()
|
|
65
|
+
}
|
package/src/zip/api.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// TODO: we likely won't need this once we use docker images for the runtime
|
|
2
|
+
// zip the api for deployment
|
|
3
|
+
import { log } from '@stacksjs/logging'
|
|
4
|
+
import { path as p } from '@stacksjs/path'
|
|
5
|
+
import { zip } from '@stacksjs/storage'
|
|
6
|
+
|
|
7
|
+
log.info('zipping your API for Lambda usage...')
|
|
8
|
+
|
|
9
|
+
const from = [
|
|
10
|
+
'bootstrap',
|
|
11
|
+
'runtime.ts',
|
|
12
|
+
'server.js',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const to = p.projectStoragePath('framework/cloud/api.zip')
|
|
16
|
+
|
|
17
|
+
// zip all the paths into a single file
|
|
18
|
+
await zip(from, to, {
|
|
19
|
+
cwd: p.cloudPath('src/runtime'),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
log.info('Zipped your API')
|