@stacksjs/actions 0.70.88 → 0.70.91
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.d.ts +149 -0
- package/dist/action.js +78 -0
- package/dist/actions.d.ts +2 -0
- package/dist/actions.js +2 -0
- package/dist/add.d.ts +6 -0
- package/dist/add.js +20 -0
- package/dist/ai/request-model-access.d.ts +1 -0
- package/dist/ai/request-model-access.js +10 -0
- package/dist/auth/client.d.ts +1 -0
- package/dist/auth/client.js +44 -0
- package/dist/auth/prune.d.ts +1 -0
- package/dist/auth/prune.js +35 -0
- package/dist/auth/setup.d.ts +1 -0
- package/dist/auth/setup.js +322 -0
- package/dist/auth/token.d.ts +1 -0
- package/dist/auth/token.js +10 -0
- package/dist/blog-admin.d.ts +55 -0
- package/dist/blog-admin.js +156 -0
- package/dist/blog.d.ts +30 -0
- package/dist/blog.js +398 -0
- package/dist/build/cli.d.ts +1 -0
- package/dist/build/cli.js +6 -0
- package/dist/build/component-libs.d.ts +1 -0
- package/dist/build/component-libs.js +7 -0
- package/dist/build/core.d.ts +1 -0
- package/dist/build/core.js +55 -0
- package/dist/build/desktop.d.ts +1 -0
- package/dist/build/desktop.js +5 -0
- package/dist/build/docs.d.ts +1 -0
- package/dist/build/docs.js +5 -0
- package/dist/build/frontend-static.d.ts +16 -0
- package/dist/build/frontend-static.js +124 -0
- package/dist/build/server.d.ts +1 -0
- package/dist/build/server.js +6 -0
- package/dist/build/stacks.d.ts +1 -0
- package/dist/build/stacks.js +8 -0
- package/dist/build/views.d.ts +1 -0
- package/dist/build/views.js +11 -0
- package/dist/build.d.ts +9 -0
- package/dist/build.js +64 -0
- package/dist/bump.d.ts +1 -0
- package/dist/bump.js +163 -0
- package/dist/cdn/invalidate-cache.d.ts +1 -0
- package/dist/cdn/invalidate-cache.js +0 -0
- package/dist/changelog.d.ts +9 -0
- package/dist/changelog.js +27 -0
- package/dist/check/ports.d.ts +1 -0
- package/dist/check/ports.js +16 -0
- package/dist/clean.d.ts +1 -0
- package/dist/clean.js +4 -0
- package/dist/commit.d.ts +3 -0
- package/dist/commit.js +12 -0
- package/dist/copy-types.d.ts +1 -0
- package/dist/copy-types.js +10 -0
- package/dist/database/seed.d.ts +1 -0
- package/dist/database/seed.js +26 -0
- package/dist/deploy/create-receipt-rule.d.ts +1 -0
- package/dist/deploy/create-receipt-rule.js +36 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +1574 -0
- package/dist/dev/api.d.ts +1 -0
- package/dist/dev/api.js +94 -0
- package/dist/dev/components.d.ts +1 -0
- package/dist/dev/components.js +7 -0
- package/dist/dev/dashboard-globals.d.ts +4 -0
- package/dist/dev/dashboard-globals.js +89 -0
- package/dist/dev/dashboard-utils.d.ts +150 -0
- package/dist/dev/dashboard-utils.js +380 -0
- package/dist/dev/dashboard.d.ts +22 -0
- package/dist/dev/dashboard.js +435 -0
- package/dist/dev/desktop.d.ts +1 -0
- package/dist/dev/desktop.js +5 -0
- package/dist/dev/docs.d.ts +1 -0
- package/dist/dev/docs.js +24 -0
- package/dist/dev/index.d.ts +10 -0
- package/dist/dev/index.js +29 -0
- package/dist/dev/migrate-watcher.d.ts +1 -0
- package/dist/dev/migrate-watcher.js +74 -0
- package/dist/dev/system-tray.d.ts +1 -0
- package/dist/dev/system-tray.js +5 -0
- package/dist/dev/views.d.ts +1 -0
- package/dist/dev/views.js +147 -0
- package/dist/discover-packages.d.ts +18 -0
- package/dist/discover-packages.js +32 -0
- package/dist/domains/add.d.ts +1 -0
- package/dist/domains/add.js +61 -0
- package/dist/domains/purchase.d.ts +1 -0
- package/dist/domains/purchase.js +66 -0
- package/dist/domains/remove.d.ts +1 -0
- package/dist/domains/remove.js +24 -0
- package/dist/examples.d.ts +5 -0
- package/dist/examples.js +34 -0
- package/dist/find-projects.d.ts +1 -0
- package/dist/find-projects.js +16 -0
- package/dist/fresh.d.ts +1 -0
- package/dist/fresh.js +17 -0
- package/dist/generate/action-types.d.ts +1 -0
- package/dist/generate/action-types.js +13 -0
- package/dist/generate/component-meta.d.ts +1 -0
- package/dist/generate/component-meta.js +9 -0
- package/dist/generate/custom-cli-file.d.ts +1 -0
- package/dist/generate/custom-cli-file.js +21 -0
- package/dist/generate/env-files.d.ts +1 -0
- package/dist/generate/env-files.js +66 -0
- package/dist/generate/ide-helpers.d.ts +1 -0
- package/dist/generate/ide-helpers.js +8 -0
- package/dist/generate/index.d.ts +36 -0
- package/dist/generate/index.js +158 -0
- package/dist/generate/lib-entries.d.ts +1 -0
- package/dist/generate/lib-entries.js +16 -0
- package/dist/generate/pantry-file.d.ts +1 -0
- package/dist/generate/pantry-file.js +46 -0
- package/dist/generate/symlink-core.d.ts +1 -0
- package/dist/generate/symlink-core.js +2 -0
- package/dist/generate/types.d.ts +1 -0
- package/dist/generate/types.js +3 -0
- package/dist/generate/vscode-custom-data.d.ts +1 -0
- package/dist/generate/vscode-custom-data.js +9 -0
- package/dist/generate/web-types.d.ts +1 -0
- package/dist/generate/web-types.js +0 -0
- package/dist/helpers/component-meta.d.ts +26 -0
- package/dist/helpers/component-meta.js +295 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/lib-entries.d.ts +12 -0
- package/dist/helpers/lib-entries.js +73 -0
- package/dist/helpers/package-json.d.ts +2 -0
- package/dist/helpers/package-json.js +74 -0
- package/dist/helpers/utils.d.ts +23 -0
- package/dist/helpers/utils.js +105 -0
- package/dist/helpers/vscode-custom-data.d.ts +3 -0
- package/dist/helpers/vscode-custom-data.js +30 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +50 -0
- package/dist/key-generate.d.ts +1 -0
- package/dist/key-generate.js +24 -0
- package/dist/lint/fix.d.ts +1 -0
- package/dist/lint/fix.js +4 -0
- package/dist/lint/index.d.ts +1 -0
- package/dist/lint/index.js +4 -0
- package/dist/lint/lint.d.ts +14 -0
- package/dist/lint/lint.js +34 -0
- package/dist/make-command.d.ts +10 -0
- package/dist/make-command.js +95 -0
- package/dist/make-job.d.ts +5 -0
- package/dist/make-job.js +154 -0
- package/dist/make-policy.d.ts +10 -0
- package/dist/make-policy.js +142 -0
- package/dist/make-resource.d.ts +10 -0
- package/dist/make-resource.js +142 -0
- package/dist/make.d.ts +52 -0
- package/dist/make.js +328 -0
- package/dist/migrate/database.d.ts +1 -0
- package/dist/migrate/database.js +16 -0
- package/dist/migrate/fresh.d.ts +1 -0
- package/dist/migrate/fresh.js +31 -0
- package/dist/orm/base.d.ts +1 -0
- package/dist/orm/base.js +0 -0
- package/dist/orm/test.d.ts +1 -0
- package/dist/orm/test.js +0 -0
- package/dist/prepublish.d.ts +1 -0
- package/dist/prepublish.js +16 -0
- package/dist/queue/clear.d.ts +1 -0
- package/dist/queue/clear.js +42 -0
- package/dist/queue/dlq-purge.d.ts +1 -0
- package/dist/queue/dlq-purge.js +28 -0
- package/dist/queue/dlq-retry.d.ts +1 -0
- package/dist/queue/dlq-retry.js +35 -0
- package/dist/queue/dlq.d.ts +1 -0
- package/dist/queue/dlq.js +55 -0
- package/dist/queue/failed.d.ts +1 -0
- package/dist/queue/failed.js +69 -0
- package/dist/queue/flush.d.ts +1 -0
- package/dist/queue/flush.js +49 -0
- package/dist/queue/inspect.d.ts +1 -0
- package/dist/queue/inspect.js +154 -0
- package/dist/queue/list.d.ts +1 -0
- package/dist/queue/list.js +69 -0
- package/dist/queue/monitor.d.ts +1 -0
- package/dist/queue/monitor.js +95 -0
- package/dist/queue/pause.d.ts +1 -0
- package/dist/queue/pause.js +28 -0
- package/dist/queue/quarantine.d.ts +1 -0
- package/dist/queue/quarantine.js +42 -0
- package/dist/queue/resume.d.ts +1 -0
- package/dist/queue/resume.js +27 -0
- package/dist/queue/retry.d.ts +1 -0
- package/dist/queue/retry.js +41 -0
- package/dist/queue/schedule-list.d.ts +1 -0
- package/dist/queue/schedule-list.js +33 -0
- package/dist/queue/schedule.d.ts +1 -0
- package/dist/queue/schedule.js +12 -0
- package/dist/queue/status.d.ts +1 -0
- package/dist/queue/status.js +68 -0
- package/dist/queue/table.d.ts +1 -0
- package/dist/queue/table.js +10 -0
- package/dist/queue/unquarantine.d.ts +1 -0
- package/dist/queue/unquarantine.js +27 -0
- package/dist/queue/work.d.ts +1 -0
- package/dist/queue/work.js +57 -0
- package/dist/release.d.ts +1 -0
- package/dist/release.js +21 -0
- package/dist/route/list.d.ts +1 -0
- package/dist/route/list.js +78 -0
- package/dist/run-action.d.ts +2 -0
- package/dist/run-action.js +1 -0
- package/dist/saas/setup.d.ts +1 -0
- package/dist/saas/setup.js +9 -0
- package/dist/scaffold-crud.d.ts +25 -0
- package/dist/scaffold-crud.js +211 -0
- package/dist/schedule/run.d.ts +1 -0
- package/dist/schedule/run.js +7 -0
- package/dist/search/flush.d.ts +1 -0
- package/dist/search/flush.js +10 -0
- package/dist/search/import.d.ts +1 -0
- package/dist/search/import.js +10 -0
- package/dist/search/settings-list.d.ts +1 -0
- package/dist/search/settings-list.js +10 -0
- package/dist/search/settings.d.ts +1 -0
- package/dist/search/settings.js +9 -0
- package/dist/serve/api.d.ts +1 -0
- package/dist/serve/api.js +35 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.js +1 -0
- package/dist/setup/ssl.d.ts +38 -0
- package/dist/setup/ssl.js +271 -0
- package/dist/stacks.d.ts +4 -0
- package/dist/stacks.js +265 -0
- package/dist/templates.d.ts +28 -0
- package/dist/templates.js +301 -0
- package/dist/test/feature.d.ts +1 -0
- package/dist/test/feature.js +11 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.js +11 -0
- package/dist/test/ui.d.ts +1 -0
- package/dist/test/ui.js +4 -0
- package/dist/test/unit.d.ts +1 -0
- package/dist/test/unit.js +11 -0
- package/dist/typecheck.d.ts +1 -0
- package/dist/typecheck.js +4 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +16 -0
- package/dist/upgrade/binary.d.ts +1 -0
- package/dist/upgrade/binary.js +29 -0
- package/dist/upgrade/bun.d.ts +1 -0
- package/dist/upgrade/bun.js +0 -0
- package/dist/upgrade/dependencies.d.ts +1 -0
- package/dist/upgrade/dependencies.js +0 -0
- package/dist/upgrade/framework-utils.d.ts +150 -0
- package/dist/upgrade/framework-utils.js +193 -0
- package/dist/upgrade/framework.d.ts +1 -0
- package/dist/upgrade/framework.js +310 -0
- package/dist/upgrade/index.d.ts +1 -0
- package/dist/upgrade/index.js +17 -0
- package/dist/upgrade/packages.d.ts +14 -0
- package/dist/upgrade/packages.js +99 -0
- package/dist/upgrade/shell.d.ts +1 -0
- package/dist/upgrade/shell.js +41 -0
- package/dist/upgrade.d.ts +7 -0
- package/dist/upgrade.js +38 -0
- package/package.json +16 -16
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/test/ui.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the target channel and git ref from CLI options and persisted channel.
|
|
3
|
+
* Priority: --version > --canary > --stable > persisted channel
|
|
4
|
+
*
|
|
5
|
+
* Branch model: `main` is the bleeding-edge "dump everything" branch; `stable`
|
|
6
|
+
* is the vetted branch that PRs are merged into from `main` once main is proven.
|
|
7
|
+
* So the `stable` channel tracks the `stable` branch (vetted) and the `canary`
|
|
8
|
+
* channel tracks the `main` branch (bleeding edge). A pinned `--version` still
|
|
9
|
+
* resolves to the matching `vX` tag.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveUpgradeContext(options: {
|
|
12
|
+
version?: string
|
|
13
|
+
canary?: boolean
|
|
14
|
+
stable?: boolean
|
|
15
|
+
}, currentChannel: 'stable' | 'canary'): UpgradeContext;
|
|
16
|
+
/**
|
|
17
|
+
* Build the gitit template string for a path under the stacks repo.
|
|
18
|
+
* `subPath` is relative to the repo root (e.g. `storage/framework/core`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildTemplateString(ref: string, subPath?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Read a version from a package.json file. Returns null on any error.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readVersion(pkgPath: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Read the persisted channel from the channel file.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readChannel(channelFilePath: string): 'stable' | 'canary';
|
|
29
|
+
/**
|
|
30
|
+
* Persist the channel to the channel file.
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeChannel(channelFilePath: string, ch: 'stable' | 'canary'): void;
|
|
33
|
+
/**
|
|
34
|
+
* Read the last-synced `{ channel, sha }` from `.stacks-version`.
|
|
35
|
+
*
|
|
36
|
+
* Returns null on absence or any malformed content — callers treat null as
|
|
37
|
+
* "no prior sync", which always falls through to a sync (first-run safe). The
|
|
38
|
+
* stored format is a single line: `"<channel> <40-hex-sha>"`. A bare sha
|
|
39
|
+
* (legacy) or unknown channel parses to null so it never wrongly short-circuits.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readSyncedVersion(versionFilePath: string): SyncedVersion | null;
|
|
42
|
+
/**
|
|
43
|
+
* Persist the last-synced channel + sha to `.stacks-version`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeSyncedVersion(versionFilePath: string, ch: 'stable' | 'canary', sha: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Pure decision for the "already up to date" short-circuit. Returns true only
|
|
48
|
+
* when a sync can be safely skipped: no override flags, not a pinned version,
|
|
49
|
+
* a resolved remote sha, a prior sync on the SAME channel, and the synced sha
|
|
50
|
+
* equals the remote sha. Any of:
|
|
51
|
+
* - `force` (explicit re-sync)
|
|
52
|
+
* - `targetVersion` (pinned tag — always install)
|
|
53
|
+
* - `remoteSha === null` (network/git failure → fail open to sync)
|
|
54
|
+
* - `synced === null` (first run → always sync)
|
|
55
|
+
* - channel mismatch (channel switch never short-circuits)
|
|
56
|
+
* - sha mismatch (a newer commit is available)
|
|
57
|
+
* yields false (proceed with the sync).
|
|
58
|
+
*/
|
|
59
|
+
export declare function shouldShortCircuit(args: {
|
|
60
|
+
force: boolean
|
|
61
|
+
targetVersion?: string
|
|
62
|
+
remoteSha: string | null
|
|
63
|
+
synced: SyncedVersion | null
|
|
64
|
+
channel: 'stable' | 'canary'
|
|
65
|
+
}): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Determine the user-facing log message for the upgrade action.
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveUpgradeMessage(ctx: UpgradeContext, currentChannel: 'stable' | 'canary', isStableFlag: boolean): string;
|
|
70
|
+
/**
|
|
71
|
+
* Determine the user-facing success message after an upgrade.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveSuccessMessage(ctx: UpgradeContext, currentVersion: string | null, newVersion: string | null, currentChannel: 'stable' | 'canary', force: boolean): string;
|
|
74
|
+
/**
|
|
75
|
+
* Auto-detect a local stacks checkout the user might be developing against.
|
|
76
|
+
*
|
|
77
|
+
* Order:
|
|
78
|
+
* 1. `STACKS_LOCAL_PATH` env var (explicit)
|
|
79
|
+
* 2. Sibling directory: `<project>/../stacks`
|
|
80
|
+
* 3. `~/Code/stacks` and a few common dev paths
|
|
81
|
+
*
|
|
82
|
+
* Returns null if nothing looks like a stacks checkout. We confirm by checking
|
|
83
|
+
* for `storage/framework/core/buddy/package.json` — the canonical marker.
|
|
84
|
+
*/
|
|
85
|
+
export declare function detectLocalStacks(projectRoot: string): string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Walk a directory recursively and return a Map of relative-path → entry,
|
|
88
|
+
* with each entry's size + content hash captured at the time of the call.
|
|
89
|
+
* Hashing the entire tree at snapshot time (rather than at diff time) means
|
|
90
|
+
* the "before" snapshot stays valid even after `cpSync` overwrites the
|
|
91
|
+
* files in place.
|
|
92
|
+
*
|
|
93
|
+
* Async because we read each file via `Bun.file().arrayBuffer()`. On a
|
|
94
|
+
* 3000-file framework tree this completes in ~50ms — `Bun.hash` is xxh3,
|
|
95
|
+
* not a crypto hash, and the I/O is fully parallelized.
|
|
96
|
+
*/
|
|
97
|
+
export declare function snapshotTree(root: string, skip?: string[]): Promise<Map<string, SnapshotEntry>>;
|
|
98
|
+
/**
|
|
99
|
+
* Diff two snapshots produced by `snapshotTree`. Pure comparison — both
|
|
100
|
+
* inputs already carry their content hash, so this is just bookkeeping.
|
|
101
|
+
*/
|
|
102
|
+
export declare function diffSnapshots(before: Map<string, SnapshotEntry>, after: Map<string, SnapshotEntry>): ChangeSummary;
|
|
103
|
+
export declare const MANAGED_PATHS: ManagedPath[];
|
|
104
|
+
export declare interface UpgradeContext {
|
|
105
|
+
channel: 'stable' | 'canary'
|
|
106
|
+
ref: string
|
|
107
|
+
targetVersion?: string
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The last-synced channel + commit sha, persisted to `.stacks-version` so
|
|
111
|
+
* `buddy update` can short-circuit when the project is already on the latest
|
|
112
|
+
* commit of its channel.
|
|
113
|
+
*/
|
|
114
|
+
export declare interface SyncedVersion {
|
|
115
|
+
channel: 'stable' | 'canary'
|
|
116
|
+
sha: string
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Framework-managed paths, relative to the project root, that `buddy update`
|
|
120
|
+
* keeps in sync with the upstream stacks repo. Each entry can be a directory
|
|
121
|
+
* (synced recursively) or a single file. The `subPath` is the path inside the
|
|
122
|
+
* upstream stacks checkout — almost always the same as `localPath`, except
|
|
123
|
+
* for root scripts that live at the project root in apps but at the repo root
|
|
124
|
+
* in the stacks monorepo.
|
|
125
|
+
*/
|
|
126
|
+
export declare interface ManagedPath {
|
|
127
|
+
localPath: string
|
|
128
|
+
subPath: string
|
|
129
|
+
isFile?: boolean
|
|
130
|
+
skip?: string[]
|
|
131
|
+
label: string
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Snapshot entry. We capture size + content hash at snapshot time so the
|
|
135
|
+
* before/after diff can detect "actually changed" vs "just re-copied with
|
|
136
|
+
* fresh mtimes". `cpSync` and `downloadTemplate` always touch mtimes,
|
|
137
|
+
* even when the destination bytes are identical to the source — using
|
|
138
|
+
* mtime as the change signal turns every no-op upgrade into a "1600
|
|
139
|
+
* changed" report.
|
|
140
|
+
*/
|
|
141
|
+
export declare interface SnapshotEntry {
|
|
142
|
+
size: number
|
|
143
|
+
hash: bigint
|
|
144
|
+
}
|
|
145
|
+
export declare interface ChangeSummary {
|
|
146
|
+
added: number
|
|
147
|
+
changed: number
|
|
148
|
+
removed: number
|
|
149
|
+
unchanged: number
|
|
150
|
+
}
|