@stacksjs/actions 0.70.87 → 0.70.90
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/action.js +78 -2
- package/dist/actions.js +2 -2
- package/dist/add.js +20 -2
- package/dist/ai/request-model-access.js +10 -2
- package/dist/auth/client.js +44 -3
- package/dist/auth/prune.js +35 -2
- package/dist/auth/setup.js +152 -36
- package/dist/auth/token.js +10 -2
- package/dist/blog-admin.d.ts +55 -0
- package/dist/blog-admin.js +156 -0
- package/dist/blog.d.ts +11 -0
- package/dist/blog.js +306 -56
- package/dist/build/cli.js +6 -2
- package/dist/build/component-libs.js +7 -2
- package/dist/build/core.js +55 -2
- package/dist/build/desktop.js +5 -2
- package/dist/build/docs.js +5 -2
- package/dist/build/frontend-static.js +123 -8
- package/dist/build/server.js +6 -2
- package/dist/build/stacks.js +8 -2
- package/dist/build/views.js +11 -2
- package/dist/build.js +64 -2
- package/dist/bump.js +162 -7
- package/dist/cdn/invalidate-cache.js +0 -1
- package/dist/changelog.js +27 -3
- package/dist/check/ports.js +16 -2
- package/dist/clean.js +4 -2
- package/dist/commit.js +12 -2
- package/dist/copy-types.js +10 -3
- package/dist/database/seed.js +26 -2
- package/dist/deploy/create-receipt-rule.js +36 -2
- package/dist/deploy/index.js +1318 -44
- package/dist/dev/api.js +94 -6
- package/dist/dev/components.js +7 -2
- package/dist/dev/dashboard-globals.js +89 -3
- package/dist/dev/dashboard-utils.js +380 -2
- package/dist/dev/dashboard.js +435 -8
- package/dist/dev/desktop.js +5 -2
- package/dist/dev/docs.js +24 -2
- package/dist/dev/index.js +29 -2
- package/dist/dev/migrate-watcher.js +74 -2
- package/dist/dev/system-tray.js +5 -2
- package/dist/dev/views.js +147 -2
- package/dist/discover-packages.js +32 -2
- package/dist/domains/add.js +61 -2
- package/dist/domains/purchase.js +66 -2
- package/dist/domains/remove.js +24 -2
- package/dist/examples.js +34 -2
- package/dist/find-projects.js +16 -2
- package/dist/fresh.js +17 -2
- package/dist/generate/action-types.js +9 -4
- package/dist/generate/component-meta.js +9 -3
- package/dist/generate/custom-cli-file.js +20 -3
- package/dist/generate/env-files.js +46 -6
- package/dist/generate/ide-helpers.js +8 -3
- package/dist/generate/index.js +158 -2
- package/dist/generate/lib-entries.js +16 -3
- package/dist/generate/pantry-file.js +46 -2
- package/dist/generate/symlink-core.js +2 -2
- package/dist/generate/types.js +3 -2
- package/dist/generate/vscode-custom-data.js +9 -3
- package/dist/generate/web-types.js +0 -1
- package/dist/helpers/component-meta.js +295 -2
- package/dist/helpers/index.js +1 -2
- package/dist/helpers/lib-entries.js +73 -2
- package/dist/helpers/package-json.js +45 -14
- package/dist/helpers/utils.js +105 -2
- package/dist/helpers/vscode-custom-data.js +30 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +50 -2
- package/dist/key-generate.js +24 -2
- package/dist/lint/fix.js +4 -3
- package/dist/lint/index.js +4 -3
- package/dist/lint/lint.js +34 -2
- package/dist/make-command.js +64 -14
- package/dist/make-job.js +41 -16
- package/dist/make-policy.js +74 -26
- package/dist/make-resource.js +50 -21
- package/dist/make.js +328 -2
- package/dist/migrate/database.js +16 -2
- package/dist/migrate/fresh.js +31 -2
- package/dist/orm/base.js +0 -2
- package/dist/orm/test.js +0 -1
- package/dist/prepublish.js +16 -2
- package/dist/queue/clear.js +42 -2
- package/dist/queue/dlq-purge.js +28 -2
- package/dist/queue/dlq-retry.js +35 -2
- package/dist/queue/dlq.js +55 -5
- package/dist/queue/failed.js +69 -5
- package/dist/queue/flush.js +49 -3
- package/dist/queue/inspect.js +154 -8
- package/dist/queue/list.js +69 -5
- package/dist/queue/monitor.js +94 -6
- package/dist/queue/pause.js +28 -2
- package/dist/queue/quarantine.js +42 -3
- package/dist/queue/resume.js +27 -2
- package/dist/queue/retry.js +41 -2
- package/dist/queue/schedule-list.js +33 -5
- package/dist/queue/schedule.js +12 -2
- package/dist/queue/status.js +68 -5
- package/dist/queue/table.js +10 -2
- package/dist/queue/unquarantine.js +27 -2
- package/dist/queue/work.js +57 -2
- package/dist/release.js +21 -3
- package/dist/route/list.js +78 -3
- package/dist/run-action.js +1 -2
- package/dist/saas/setup.js +9 -2
- package/dist/scaffold-crud.js +164 -40
- package/dist/schedule/run.js +7 -2
- package/dist/search/flush.js +10 -2
- package/dist/search/import.js +10 -2
- package/dist/search/settings-list.js +10 -2
- package/dist/search/settings.js +9 -2
- package/dist/serve/api.js +35 -2
- package/dist/setup/index.js +1 -2
- package/dist/setup/ssl.js +271 -2
- package/dist/stacks.js +265 -2
- package/dist/templates.js +301 -2
- package/dist/test/feature.js +11 -2
- package/dist/test/index.js +11 -2
- package/dist/test/ui.js +4 -2
- package/dist/test/unit.js +11 -2
- package/dist/typecheck.js +4 -2
- package/dist/types.js +16 -2
- package/dist/upgrade/binary.js +29 -2
- package/dist/upgrade/bun.js +0 -1
- package/dist/upgrade/dependencies.js +0 -2
- package/dist/upgrade/framework-utils.js +193 -2
- package/dist/upgrade/framework.js +310 -7
- package/dist/upgrade/index.js +17 -2
- package/dist/upgrade/packages.js +99 -12
- package/dist/upgrade/shell.js +40 -4
- package/dist/upgrade.js +38 -2
- package/package.json +16 -16
- package/dist/chunk-0c8sd1t6.js +0 -2
- package/dist/chunk-0g2nzhx9.js +0 -240
- package/dist/chunk-0gadhvn7.js +0 -3
- package/dist/chunk-0h27aa4r.js +0 -93
- package/dist/chunk-3peh8kqs.js +0 -851
- package/dist/chunk-62gdfav8.js +0 -3
- package/dist/chunk-6bk53y02.js +0 -3
- package/dist/chunk-78c5n3s2.js +0 -3
- package/dist/chunk-c74qv38e.js +0 -17
- package/dist/chunk-cdk2r2jd.js +0 -1
- package/dist/chunk-dbz9dp2h.js +0 -3
- package/dist/chunk-e142dheq.js +0 -3
- package/dist/chunk-ec4gky40.js +0 -3
- package/dist/chunk-h3d81wrg.js +0 -3
- package/dist/chunk-m3q0x4h0.js +0 -688
- package/dist/chunk-mqgbyhph.js +0 -5
- package/dist/chunk-n24m8prb.js +0 -3
- package/dist/chunk-n5eqwhck.js +0 -7
- package/dist/chunk-nsvnqv8y.js +0 -5
- package/dist/chunk-nty6mmx4.js +0 -283
- package/dist/chunk-s735m9mg.js +0 -1
- package/dist/chunk-tpb8jgsk.js +0 -7
- package/dist/chunk-tsbk5vne.js +0 -3
- package/dist/chunk-xg9xscqz.js +0 -1
- package/dist/chunk-y6e448he.js +0 -7
package/dist/templates.js
CHANGED
|
@@ -1,2 +1,301 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
export const CODE_TEMPLATES = {
|
|
2
|
+
action: `import { Action } from '@stacksjs/actions'
|
|
3
|
+
|
|
4
|
+
export default new Action({
|
|
5
|
+
name: '{0}',
|
|
6
|
+
description: '{0} action',
|
|
7
|
+
|
|
8
|
+
handle() {
|
|
9
|
+
return 'Hello World action'
|
|
10
|
+
},
|
|
11
|
+
})`,
|
|
12
|
+
actionWithValidation: `import { Action } from '@stacksjs/actions'
|
|
13
|
+
import { schema, validate } from '@stacksjs/validation'
|
|
14
|
+
|
|
15
|
+
export default new Action({
|
|
16
|
+
name: '{0}',
|
|
17
|
+
description: '{0} action',
|
|
18
|
+
|
|
19
|
+
async handle(request) {
|
|
20
|
+
// Replace these rules with whatever this action expects. The
|
|
21
|
+
// returned object is typed to the rule shape; type-narrow further
|
|
22
|
+
// by passing a generic to validate<Payload>().
|
|
23
|
+
const data = await validate(request, {
|
|
24
|
+
// example: title: schema.string().required().min(1),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return { ok: true, data }
|
|
28
|
+
},
|
|
29
|
+
})`,
|
|
30
|
+
actionWithAuth: `import { Action } from '@stacksjs/actions'
|
|
31
|
+
|
|
32
|
+
export default new Action({
|
|
33
|
+
name: '{0}',
|
|
34
|
+
description: '{0} action (authenticated)',
|
|
35
|
+
|
|
36
|
+
async handle(request) {
|
|
37
|
+
const user = await request.user()
|
|
38
|
+
if (!user) {
|
|
39
|
+
return new Response('Unauthorized', { status: 401 })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { ok: true, userId: user.id }
|
|
43
|
+
},
|
|
44
|
+
})`,
|
|
45
|
+
actionWithBoth: `import { Action } from '@stacksjs/actions'
|
|
46
|
+
import { schema, validate } from '@stacksjs/validation'
|
|
47
|
+
|
|
48
|
+
export default new Action({
|
|
49
|
+
name: '{0}',
|
|
50
|
+
description: '{0} action (authenticated + validated)',
|
|
51
|
+
|
|
52
|
+
async handle(request) {
|
|
53
|
+
const user = await request.user()
|
|
54
|
+
if (!user) {
|
|
55
|
+
return new Response('Unauthorized', { status: 401 })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const data = await validate(request, {
|
|
59
|
+
// example: title: schema.string().required().min(1),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return { ok: true, userId: user.id, data }
|
|
63
|
+
},
|
|
64
|
+
})`,
|
|
65
|
+
component: `<script setup lang="ts">
|
|
66
|
+
console.log('Hello World component created')
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<div>
|
|
71
|
+
Some HTML block
|
|
72
|
+
</div>
|
|
73
|
+
</template>`,
|
|
74
|
+
page: `<script setup lang="ts">
|
|
75
|
+
console.log('Hello World page created')
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<div>
|
|
80
|
+
Visit http://127.0.0.1/{0}
|
|
81
|
+
</div>
|
|
82
|
+
</template>`,
|
|
83
|
+
function: `// reactive state
|
|
84
|
+
const {0} = ref(0)
|
|
85
|
+
|
|
86
|
+
// functions that mutate state and trigger updates
|
|
87
|
+
function increment() {
|
|
88
|
+
{0}.value++
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
{0},
|
|
93
|
+
increment,
|
|
94
|
+
}`,
|
|
95
|
+
language: `button:
|
|
96
|
+
text: Copy`,
|
|
97
|
+
notification: `import type { {0} } from '@stacksjs/types'
|
|
98
|
+
|
|
99
|
+
function content(): string {
|
|
100
|
+
return 'example'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function send(): {0} {
|
|
104
|
+
return {
|
|
105
|
+
content: content(),
|
|
106
|
+
}
|
|
107
|
+
}`,
|
|
108
|
+
mail: `import { Mailable } from '@stacksjs/email'
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Props passed into the {0} email. Add the fields your template
|
|
112
|
+
* needs and they'll flow through to the stx template's \`props\` \u2014
|
|
113
|
+
* \`Mailable<{0}Props>\` ensures \`.template()\` and \`this.props\`
|
|
114
|
+
* type-check against this shape (stacksjs/stacks#1903).
|
|
115
|
+
*/
|
|
116
|
+
export interface {0}Props extends Record<string, unknown> {
|
|
117
|
+
/** Recipient email address. */
|
|
118
|
+
to: string
|
|
119
|
+
/** Display name for the greeting (falls back to 'there'). */
|
|
120
|
+
userName?: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* {0} mailable. Subclass of \`Mailable<{0}Props>\` \u2014 \`build()\` wires the
|
|
125
|
+
* recipient / subject / template (props typed against \`{0}Props\`),
|
|
126
|
+
* then \`send()\` (inherited) dispatches via the configured mail driver.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* \`\`\`ts
|
|
130
|
+
* await new {0}({ to: 'user@example.com', userName: 'Ada' }).send()
|
|
131
|
+
* \`\`\`
|
|
132
|
+
*/
|
|
133
|
+
export class {0} extends Mailable<{0}Props> {
|
|
134
|
+
constructor(private readonly props: {0}Props) {
|
|
135
|
+
super()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
build(): this {
|
|
139
|
+
return this
|
|
140
|
+
.to(this.props.to)
|
|
141
|
+
.subject('{0}')
|
|
142
|
+
.template('{1}', {
|
|
143
|
+
to: this.props.to,
|
|
144
|
+
userName: this.props.userName ?? 'there',
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}`,
|
|
148
|
+
mailTemplate: `<script server>
|
|
149
|
+
// Generated by \`buddy make:mail {0}\`. Edit freely \u2014 \`props\` is the
|
|
150
|
+
// object passed by the Mailable's \`build()\`.
|
|
151
|
+
const appName = props.appName || 'Stacks'
|
|
152
|
+
const appUrl = props.appUrl || 'https://stacksjs.com'
|
|
153
|
+
const userName = props.userName || 'there'
|
|
154
|
+
const primaryColor = props.primaryColor || '#3451b2'
|
|
155
|
+
const primaryColorDark = props.primaryColorDark || '#2a4198'
|
|
156
|
+
const subject = props.subject || '{0}'
|
|
157
|
+
const year = props.year || new Date().getFullYear()
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<!DOCTYPE html>
|
|
161
|
+
<html lang="en">
|
|
162
|
+
<head>
|
|
163
|
+
<meta charset="UTF-8">
|
|
164
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
165
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
166
|
+
<title>{{ subject }}</title>
|
|
167
|
+
<style>
|
|
168
|
+
.button { display: inline-block; padding: 14px 32px; background-color: {{ primaryColor }}; color: #ffffff !important; text-decoration: none; border-radius: 6px; font-weight: 600; font-size: 16px; text-align: center; }
|
|
169
|
+
.button:hover { background-color: {{ primaryColorDark }}; }
|
|
170
|
+
@media only screen and (max-width: 600px) {
|
|
171
|
+
.container { width: 100% !important; padding: 20px !important; }
|
|
172
|
+
.content { padding: 24px !important; }
|
|
173
|
+
.button { display: block !important; width: 100% !important; }
|
|
174
|
+
}
|
|
175
|
+
</style>
|
|
176
|
+
</head>
|
|
177
|
+
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f4f4f5; line-height: 1.6;">
|
|
178
|
+
<table role="presentation" cellpadding="0" cellspacing="0" style="width: 100%; border-collapse: collapse;">
|
|
179
|
+
<tr>
|
|
180
|
+
<td style="padding: 40px 20px;">
|
|
181
|
+
<table role="presentation" cellpadding="0" cellspacing="0" class="container" style="max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);">
|
|
182
|
+
<tr>
|
|
183
|
+
<td style="background-color: {{ primaryColor }}; padding: 30px 40px; text-align: center;">
|
|
184
|
+
<h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: 600;">{{ appName }}</h1>
|
|
185
|
+
</td>
|
|
186
|
+
</tr>
|
|
187
|
+
<tr>
|
|
188
|
+
<td class="content" style="padding: 40px;">
|
|
189
|
+
<h2 style="margin: 0 0 20px; color: #111827; font-size: 20px; font-weight: 600;">{0}</h2>
|
|
190
|
+
<p style="margin: 0 0 20px; color: #4b5563; font-size: 16px;">Hi {{ userName }},</p>
|
|
191
|
+
<p style="margin: 0 0 20px; color: #4b5563; font-size: 16px;">Your message body goes here.</p>
|
|
192
|
+
<table role="presentation" cellpadding="0" cellspacing="0" style="margin: 30px 0;">
|
|
193
|
+
<tr><td><a href="{{ appUrl }}" class="button">Open {{ appName }}</a></td></tr>
|
|
194
|
+
</table>
|
|
195
|
+
</td>
|
|
196
|
+
</tr>
|
|
197
|
+
<tr>
|
|
198
|
+
<td style="padding: 20px 40px; background-color: #f9fafb; border-top: 1px solid #e5e7eb;">
|
|
199
|
+
<p style="margin: 0; color: #6b7280; font-size: 12px; text-align: center;">This is an automated message from {{ appName }}.</p>
|
|
200
|
+
<p style="margin: 10px 0 0; color: #9ca3af; font-size: 11px; text-align: center;">© {{ year }} {{ appName }}. All rights reserved.</p>
|
|
201
|
+
</td>
|
|
202
|
+
</tr>
|
|
203
|
+
</table>
|
|
204
|
+
</td>
|
|
205
|
+
</tr>
|
|
206
|
+
</table>
|
|
207
|
+
</body>
|
|
208
|
+
</html>`,
|
|
209
|
+
middleware: `import type { Request } from '@stacksjs/router'
|
|
210
|
+
import { Middleware } from '@stacksjs/router'
|
|
211
|
+
|
|
212
|
+
export default new Middleware({
|
|
213
|
+
name: '{0}',
|
|
214
|
+
priority: 1,
|
|
215
|
+
async handle(request: Request) {
|
|
216
|
+
// Your middleware logic here
|
|
217
|
+
},
|
|
218
|
+
})`,
|
|
219
|
+
model: `import { defineModel } from '@stacksjs/orm'
|
|
220
|
+
import { schema } from '@stacksjs/validation'
|
|
221
|
+
|
|
222
|
+
export default defineModel({
|
|
223
|
+
name: '{0}',
|
|
224
|
+
table: '{1}',
|
|
225
|
+
primaryKey: 'id',
|
|
226
|
+
autoIncrement: true,
|
|
227
|
+
|
|
228
|
+
traits: {
|
|
229
|
+
useTimestamps: true,
|
|
230
|
+
|
|
231
|
+
useSeeder: {
|
|
232
|
+
count: 10,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
attributes: {
|
|
237
|
+
// your attributes here
|
|
238
|
+
},
|
|
239
|
+
} as const)`,
|
|
240
|
+
migration: `import type { Database } from '@stacksjs/database'
|
|
241
|
+
|
|
242
|
+
export async function up(db: Database): Promise<void> {
|
|
243
|
+
await db.schema
|
|
244
|
+
.createTable('{0}')
|
|
245
|
+
.addColumn('id', 'integer', col => col.autoIncrement().primaryKey())
|
|
246
|
+
.execute()
|
|
247
|
+
}`,
|
|
248
|
+
stackPackageJson: `{
|
|
249
|
+
"name": "{0}",
|
|
250
|
+
"version": "0.0.1",
|
|
251
|
+
"type": "module",
|
|
252
|
+
"stacks": {
|
|
253
|
+
"name": "{1}",
|
|
254
|
+
"description": "A Stacks extension"
|
|
255
|
+
}
|
|
256
|
+
}`,
|
|
257
|
+
job: `import { Job } from '@stacksjs/jobs'
|
|
258
|
+
|
|
259
|
+
export default new Job({
|
|
260
|
+
name: '{0}',
|
|
261
|
+
description: '{0} job',
|
|
262
|
+
|
|
263
|
+
async handle() {
|
|
264
|
+
// Your job logic here
|
|
265
|
+
console.log('Job executed')
|
|
266
|
+
},
|
|
267
|
+
})`,
|
|
268
|
+
event: `import { Event } from '@stacksjs/events'
|
|
269
|
+
|
|
270
|
+
export default new Event({
|
|
271
|
+
name: '{0}',
|
|
272
|
+
description: '{0} event',
|
|
273
|
+
|
|
274
|
+
async handle(data: any) {
|
|
275
|
+
// Your event handler logic here
|
|
276
|
+
console.log('Event handled:', data)
|
|
277
|
+
},
|
|
278
|
+
})`,
|
|
279
|
+
listener: `import { Listener } from '@stacksjs/events'
|
|
280
|
+
|
|
281
|
+
export default new Listener({
|
|
282
|
+
name: '{0}',
|
|
283
|
+
description: '{0} listener',
|
|
284
|
+
|
|
285
|
+
async handle(data: any) {
|
|
286
|
+
// Your listener logic here
|
|
287
|
+
console.log('Listener triggered:', data)
|
|
288
|
+
},
|
|
289
|
+
})`,
|
|
290
|
+
command: `import { Command } from '@stacksjs/cli'
|
|
291
|
+
|
|
292
|
+
export default new Command({
|
|
293
|
+
name: '{0}',
|
|
294
|
+
description: '{0} command',
|
|
295
|
+
|
|
296
|
+
async handle() {
|
|
297
|
+
// Your command logic here
|
|
298
|
+
console.log('Command executed')
|
|
299
|
+
},
|
|
300
|
+
})`
|
|
301
|
+
};
|
package/dist/test/feature.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { log } from "@stacksjs/cli";
|
|
3
|
+
import { projectPath } from "@stacksjs/path";
|
|
4
|
+
const proc = Bun.spawn(["sh", "-c", "bun test ./tests/feature/**"], {
|
|
5
|
+
cwd: projectPath(),
|
|
6
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
7
|
+
}), exitCode = await proc.exited;
|
|
8
|
+
if (exitCode !== 0) {
|
|
9
|
+
log.error("Tests failed");
|
|
10
|
+
process.exit(exitCode ?? 1);
|
|
11
|
+
}
|
package/dist/test/index.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { log } from "@stacksjs/cli";
|
|
3
|
+
import { projectPath } from "@stacksjs/path";
|
|
4
|
+
const proc = Bun.spawn(["sh", "-c", "bun test --timeout 30000 ./tests/feature/** ./tests/integration/** ./tests/unit/**"], {
|
|
5
|
+
cwd: projectPath(),
|
|
6
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
7
|
+
}), exitCode = await proc.exited;
|
|
8
|
+
if (exitCode !== 0) {
|
|
9
|
+
log.error("Tests failed");
|
|
10
|
+
process.exit(exitCode ?? 1);
|
|
11
|
+
}
|
package/dist/test/ui.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommand } from "@stacksjs/cli";
|
|
2
|
+
import { NpmScript } from "@stacksjs/enums";
|
|
3
|
+
import { frameworkPath } from "@stacksjs/path";
|
|
4
|
+
await runCommand(NpmScript.TestUi, { verbose: !0, cwd: frameworkPath() });
|
package/dist/test/unit.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { log } from "@stacksjs/cli";
|
|
3
|
+
import { projectPath } from "@stacksjs/path";
|
|
4
|
+
const proc = Bun.spawn(["sh", "-c", "bun test ./tests/unit/**"], {
|
|
5
|
+
cwd: projectPath(),
|
|
6
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
7
|
+
}), exitCode = await proc.exited;
|
|
8
|
+
if (exitCode !== 0) {
|
|
9
|
+
log.error("Tests failed");
|
|
10
|
+
process.exit(exitCode ?? 1);
|
|
11
|
+
}
|
package/dist/typecheck.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommands } from "@stacksjs/cli";
|
|
2
|
+
import { NpmScript } from "@stacksjs/enums";
|
|
3
|
+
import { projectPath } from "@stacksjs/path";
|
|
4
|
+
await runCommands([NpmScript.TestTypes], { cwd: projectPath() });
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { NpmScript } from "@stacksjs/enums";
|
|
3
|
+
import { log } from "@stacksjs/logging";
|
|
4
|
+
import { ExitCode } from "@stacksjs/types";
|
|
5
|
+
import { runNpmScript } from "@stacksjs/utils";
|
|
6
|
+
export async function invoke(options) {
|
|
7
|
+
const results = await runNpmScript(NpmScript.TypesFix, options);
|
|
8
|
+
if (results.isErr) {
|
|
9
|
+
log.error("There was an error fixing your types.", results.error);
|
|
10
|
+
process.exit(ExitCode.FatalError);
|
|
11
|
+
}
|
|
12
|
+
log.success("Types are set");
|
|
13
|
+
}
|
|
14
|
+
export async function types(options) {
|
|
15
|
+
return await invoke(options);
|
|
16
|
+
}
|
package/dist/upgrade/binary.js
CHANGED
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { runCommand } from "@stacksjs/cli";
|
|
3
|
+
import { log } from "@stacksjs/logging";
|
|
4
|
+
import { path } from "@stacksjs/path";
|
|
5
|
+
import { ExitCode } from "@stacksjs/types";
|
|
6
|
+
import { fs, storage } from "@stacksjs/storage";
|
|
7
|
+
const source = path.buddyPath("dist/stacks"), destination = path.homeDir(".stacks/bin/stacks"), destinationDir = path.homeDir(".stacks/bin/");
|
|
8
|
+
log.info("Upgrading `stacks`...");
|
|
9
|
+
const result = await runCommand("bun compile.ts", { cwd: path.buddyPath() });
|
|
10
|
+
if (result.isErr) {
|
|
11
|
+
log.error("There was an error compiling the binary", result.error);
|
|
12
|
+
process.exit(ExitCode.FatalError);
|
|
13
|
+
}
|
|
14
|
+
if (await storage.exists(source))
|
|
15
|
+
try {
|
|
16
|
+
log.info("Updating Binary...");
|
|
17
|
+
log.info(`Source: ${source}`);
|
|
18
|
+
log.info(`Destination: ${destination}`);
|
|
19
|
+
await fs.ensureDir(destinationDir);
|
|
20
|
+
await fs.move(source, destination, { overwrite: !0 });
|
|
21
|
+
log.success("Binary Latest Version Is Used");
|
|
22
|
+
} catch (err) {
|
|
23
|
+
log.error(err);
|
|
24
|
+
process.exit(ExitCode.FatalError);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
log.error(`Binary source not found: ${source}`);
|
|
28
|
+
process.exit(ExitCode.FatalError);
|
|
29
|
+
}
|
package/dist/upgrade/bun.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
@@ -1,2 +1,193 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
export function resolveUpgradeContext(options, currentChannel) {
|
|
6
|
+
const targetVersion = options.version;
|
|
7
|
+
if (targetVersion)
|
|
8
|
+
return { channel: "stable", ref: targetVersion.startsWith("v") ? targetVersion : `v${targetVersion}`, targetVersion };
|
|
9
|
+
if (options.canary)
|
|
10
|
+
return { channel: "canary", ref: "main" };
|
|
11
|
+
if (options.stable)
|
|
12
|
+
return { channel: "stable", ref: "stable" };
|
|
13
|
+
if (currentChannel === "canary")
|
|
14
|
+
return { channel: "canary", ref: "main" };
|
|
15
|
+
return { channel: "stable", ref: "stable" };
|
|
16
|
+
}
|
|
17
|
+
export function buildTemplateString(ref, subPath = "storage/framework/core") {
|
|
18
|
+
return `github:stacksjs/stacks#${ref}/${subPath}`;
|
|
19
|
+
}
|
|
20
|
+
export function readVersion(pkgPath) {
|
|
21
|
+
try {
|
|
22
|
+
if (existsSync(pkgPath))
|
|
23
|
+
return JSON.parse(readFileSync(pkgPath, "utf-8")).version || null;
|
|
24
|
+
} catch {}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
export function readChannel(channelFilePath) {
|
|
28
|
+
try {
|
|
29
|
+
if (existsSync(channelFilePath)) {
|
|
30
|
+
if (readFileSync(channelFilePath, "utf-8").trim() === "canary")
|
|
31
|
+
return "canary";
|
|
32
|
+
}
|
|
33
|
+
} catch {}
|
|
34
|
+
return "stable";
|
|
35
|
+
}
|
|
36
|
+
export function writeChannel(channelFilePath, ch) {
|
|
37
|
+
try {
|
|
38
|
+
writeFileSync(channelFilePath, ch, "utf-8");
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
export function readSyncedVersion(versionFilePath) {
|
|
42
|
+
try {
|
|
43
|
+
if (existsSync(versionFilePath)) {
|
|
44
|
+
const content = readFileSync(versionFilePath, "utf-8").trim(), [ch, sha] = content.split(/\s+/);
|
|
45
|
+
if ((ch === "stable" || ch === "canary") && sha && /^[0-9a-f]{40}$/i.test(sha))
|
|
46
|
+
return { channel: ch, sha: sha.toLowerCase() };
|
|
47
|
+
}
|
|
48
|
+
} catch {}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
export function writeSyncedVersion(versionFilePath, ch, sha) {
|
|
52
|
+
try {
|
|
53
|
+
writeFileSync(versionFilePath, `${ch} ${sha}`, "utf-8");
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
export function shouldShortCircuit(args) {
|
|
57
|
+
const { force, targetVersion, remoteSha, synced, channel } = args;
|
|
58
|
+
if (force || targetVersion)
|
|
59
|
+
return !1;
|
|
60
|
+
if (!remoteSha || !synced)
|
|
61
|
+
return !1;
|
|
62
|
+
return synced.channel === channel && synced.sha === remoteSha.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
export function resolveUpgradeMessage(ctx, currentChannel, isStableFlag) {
|
|
65
|
+
if (ctx.targetVersion)
|
|
66
|
+
return `Installing Stacks v${ctx.targetVersion.replace(/^v/, "")}...`;
|
|
67
|
+
if (ctx.channel === "canary")
|
|
68
|
+
return "Upgrading to the latest canary build...";
|
|
69
|
+
if (isStableFlag && currentChannel === "canary")
|
|
70
|
+
return "Switching back to the latest stable release...";
|
|
71
|
+
return "Upgrading to the latest version...";
|
|
72
|
+
}
|
|
73
|
+
export function resolveSuccessMessage(ctx, currentVersion, newVersion, currentChannel, force) {
|
|
74
|
+
if (ctx.targetVersion) {
|
|
75
|
+
const pinned = ctx.targetVersion.replace(/^v/, "");
|
|
76
|
+
if (currentVersion === pinned && !force)
|
|
77
|
+
return `Stacks is already at v${pinned}`;
|
|
78
|
+
if (currentVersion)
|
|
79
|
+
return `Installed Stacks v${pinned} (was v${currentVersion})`;
|
|
80
|
+
return `Installed Stacks v${pinned}`;
|
|
81
|
+
}
|
|
82
|
+
if (currentVersion && newVersion && currentVersion === newVersion && !force) {
|
|
83
|
+
if (ctx.channel === "canary")
|
|
84
|
+
return `Stacks is already up to date (canary ${currentVersion})`;
|
|
85
|
+
return `Stacks is already up to date (v${currentVersion})`;
|
|
86
|
+
}
|
|
87
|
+
if (currentVersion && newVersion) {
|
|
88
|
+
const from = currentChannel === "canary" ? `canary ${currentVersion}` : `v${currentVersion}`, to = ctx.channel === "canary" ? `canary ${newVersion}` : `v${newVersion}`;
|
|
89
|
+
return `Upgraded Stacks from ${from} to ${to}`;
|
|
90
|
+
}
|
|
91
|
+
if (newVersion)
|
|
92
|
+
return `Upgraded Stacks to ${ctx.channel === "canary" ? `canary ${newVersion}` : `v${newVersion}`}`;
|
|
93
|
+
return `Upgraded Stacks to ${ctx.ref} (latest)`;
|
|
94
|
+
}
|
|
95
|
+
export const MANAGED_PATHS = [
|
|
96
|
+
{
|
|
97
|
+
localPath: "storage/framework/core",
|
|
98
|
+
subPath: "storage/framework/core",
|
|
99
|
+
label: "core",
|
|
100
|
+
skip: ["node_modules", "dist", "bun.lock", ".DS_Store"]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
localPath: "storage/framework/defaults",
|
|
104
|
+
subPath: "storage/framework/defaults",
|
|
105
|
+
label: "defaults",
|
|
106
|
+
skip: ["node_modules", "dist", ".DS_Store", ".discovered-models.json"]
|
|
107
|
+
},
|
|
108
|
+
{ localPath: "buddy", subPath: "buddy", label: "buddy", isFile: !0 },
|
|
109
|
+
{ localPath: "bootstrap", subPath: "bootstrap", label: "bootstrap", isFile: !0 }
|
|
110
|
+
];
|
|
111
|
+
export function detectLocalStacks(projectRoot) {
|
|
112
|
+
const candidates = [
|
|
113
|
+
process.env.STACKS_LOCAL_PATH,
|
|
114
|
+
resolve(projectRoot, "..", "stacks"),
|
|
115
|
+
resolve(projectRoot, "..", "..", "stacks"),
|
|
116
|
+
resolve(homedir(), "Code", "stacks"),
|
|
117
|
+
resolve(homedir(), "code", "stacks"),
|
|
118
|
+
resolve(homedir(), "projects", "stacks"),
|
|
119
|
+
resolve(homedir(), "src", "stacks")
|
|
120
|
+
];
|
|
121
|
+
for (const candidate of candidates) {
|
|
122
|
+
if (!candidate)
|
|
123
|
+
continue;
|
|
124
|
+
const marker = join(candidate, "storage", "framework", "core", "buddy", "package.json");
|
|
125
|
+
try {
|
|
126
|
+
if (existsSync(marker) && resolve(candidate) !== resolve(projectRoot))
|
|
127
|
+
return resolve(candidate);
|
|
128
|
+
} catch {}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
export async function snapshotTree(root, skip = []) {
|
|
133
|
+
const out = new Map;
|
|
134
|
+
if (!existsSync(root))
|
|
135
|
+
return out;
|
|
136
|
+
const skipSet = new Set(skip), stack = [{ abs: root, rel: "" }], hashJobs = [];
|
|
137
|
+
while (stack.length > 0) {
|
|
138
|
+
const { abs, rel } = stack.pop();
|
|
139
|
+
let entries;
|
|
140
|
+
try {
|
|
141
|
+
entries = readdirSync(abs);
|
|
142
|
+
} catch {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
for (const name of entries) {
|
|
146
|
+
if (skipSet.has(name))
|
|
147
|
+
continue;
|
|
148
|
+
const childAbs = join(abs, name), childRel = rel ? `${rel}/${name}` : name;
|
|
149
|
+
let info;
|
|
150
|
+
try {
|
|
151
|
+
info = statSync(childAbs);
|
|
152
|
+
} catch {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (info.isDirectory())
|
|
156
|
+
stack.push({ abs: childAbs, rel: childRel });
|
|
157
|
+
else if (info.isFile()) {
|
|
158
|
+
const size = info.size;
|
|
159
|
+
hashJobs.push((async () => {
|
|
160
|
+
const hash = await hashFile(childAbs);
|
|
161
|
+
out.set(childRel, { size, hash });
|
|
162
|
+
})());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
await Promise.all(hashJobs);
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
export function diffSnapshots(before, after) {
|
|
170
|
+
let added = 0, changed = 0, unchanged = 0;
|
|
171
|
+
for (const [rel, info] of after) {
|
|
172
|
+
const prev = before.get(rel);
|
|
173
|
+
if (!prev)
|
|
174
|
+
added++;
|
|
175
|
+
else if (prev.size !== info.size || prev.hash !== info.hash)
|
|
176
|
+
changed++;
|
|
177
|
+
else
|
|
178
|
+
unchanged++;
|
|
179
|
+
}
|
|
180
|
+
let removed = 0;
|
|
181
|
+
for (const rel of before.keys())
|
|
182
|
+
if (!after.has(rel))
|
|
183
|
+
removed++;
|
|
184
|
+
return { added, changed, removed, unchanged };
|
|
185
|
+
}
|
|
186
|
+
async function hashFile(absPath) {
|
|
187
|
+
try {
|
|
188
|
+
const buf = await Bun.file(absPath).arrayBuffer();
|
|
189
|
+
return Bun.hash(buf);
|
|
190
|
+
} catch {
|
|
191
|
+
return 0n;
|
|
192
|
+
}
|
|
193
|
+
}
|