@stacksjs/actions 0.70.257 → 0.70.259
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 +1 -80
- package/dist/actions.js +1 -2
- package/dist/add.js +1 -20
- package/dist/ai/request-model-access.js +1 -10
- package/dist/auth/client.js +2 -44
- package/dist/auth/prune.js +1 -35
- package/dist/auth/setup.js +33 -153
- package/dist/auth/token.js +1 -10
- package/dist/blog-admin.js +3 -151
- package/dist/blog.js +33 -271
- package/dist/build/cli.js +1 -6
- package/dist/build/component-library.js +1 -36
- package/dist/build/component-libs.js +1 -2
- package/dist/build/core.js +1 -55
- package/dist/build/desktop.js +4 -61
- package/dist/build/dmg.js +4 -68
- package/dist/build/docs.js +1 -5
- package/dist/build/frontend-static.js +6 -122
- package/dist/build/server.js +1 -6
- package/dist/build/stacks.js +1 -8
- package/dist/build/views.js +1 -16
- package/dist/build-web-component-lib.js +1 -2
- package/dist/build.js +1 -57
- package/dist/bump.js +9 -210
- package/dist/changelog.js +1 -27
- package/dist/check/ports.js +1 -16
- package/dist/clean.js +1 -4
- package/dist/commit.js +1 -12
- package/dist/copy-types.js +1 -9
- package/dist/database/seed.js +1 -26
- package/dist/deploy/create-receipt-rule.js +1 -36
- package/dist/deploy/index.js +29 -1306
- package/dist/dev/api.js +3 -94
- package/dist/dev/components.js +1 -7
- package/dist/dev/csrf.js +1 -28
- package/dist/dev/dashboard-request-routing.js +1 -10
- package/dist/dev/dashboard-utils.js +1 -380
- package/dist/dev/dashboard.js +7 -422
- package/dist/dev/desktop.js +1 -1
- package/dist/dev/docs.js +1 -24
- package/dist/dev/exit-with-parent.d.ts +6 -0
- package/dist/dev/exit-with-parent.js +1 -0
- package/dist/dev/index.js +1 -29
- package/dist/dev/migrate-watcher.js +1 -74
- package/dist/dev/system-tray.js +2 -172
- package/dist/dev/views.js +1 -169
- package/dist/discover-packages.js +1 -32
- package/dist/domains/add.js +1 -61
- package/dist/domains/purchase.js +1 -66
- package/dist/domains/remove.js +1 -24
- package/dist/examples.js +1 -34
- package/dist/find-projects.js +1 -16
- package/dist/fresh.js +1 -17
- package/dist/generate/action-types.js +3 -9
- package/dist/generate/component-meta.js +1 -9
- package/dist/generate/custom-cli-file.js +2 -20
- package/dist/generate/env-files.js +5 -46
- package/dist/generate/ide-helpers.js +1 -8
- package/dist/generate/images.js +1 -26
- package/dist/generate/index.js +1 -166
- package/dist/generate/lib-entries.js +1 -16
- package/dist/generate/pantry-file.js +1 -46
- package/dist/generate/symlink-core.js +1 -2
- package/dist/generate/types.js +1 -3
- package/dist/generate/vschema.js +2 -47
- package/dist/generate/vscode-custom-data.js +1 -9
- package/dist/helpers/api-host.js +1 -7
- package/dist/helpers/component-meta.js +5 -295
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/lib-entries.js +3 -73
- package/dist/helpers/package-json.js +2 -34
- package/dist/helpers/utils.js +1 -130
- package/dist/helpers/vscode-custom-data.js +3 -57
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -50
- package/dist/key-generate.js +1 -24
- package/dist/lint/fix.js +1 -4
- package/dist/lint/index.js +1 -4
- package/dist/lint/lint.js +1 -34
- package/dist/lint/stx-gate.d.ts +36 -0
- package/dist/lint/stx-gate.js +3 -0
- package/dist/make-command.js +4 -55
- package/dist/make-job.js +3 -29
- package/dist/make-policy.js +4 -53
- package/dist/make-resource.js +3 -33
- package/dist/make.js +7 -323
- package/dist/migrate/database.js +1 -16
- package/dist/migrate/fresh.js +1 -36
- package/dist/prepublish.js +1 -16
- package/dist/queue/clear.js +1 -42
- package/dist/queue/dlq-purge.js +1 -28
- package/dist/queue/dlq-retry.js +1 -35
- package/dist/queue/dlq.js +4 -55
- package/dist/queue/failed.js +4 -69
- package/dist/queue/flush.js +2 -49
- package/dist/queue/inspect.js +7 -154
- package/dist/queue/list.js +4 -69
- package/dist/queue/monitor.js +5 -94
- package/dist/queue/pause.js +1 -28
- package/dist/queue/quarantine.js +2 -42
- package/dist/queue/resume.js +1 -27
- package/dist/queue/retry.js +1 -41
- package/dist/queue/schedule-list.js +4 -33
- package/dist/queue/schedule.js +1 -12
- package/dist/queue/status.js +4 -68
- package/dist/queue/table.js +1 -10
- package/dist/queue/unquarantine.js +1 -27
- package/dist/queue/work.js +1 -57
- package/dist/release-preflight.js +3 -61
- package/dist/release.js +1 -29
- package/dist/route/list.js +2 -78
- package/dist/run-action.js +1 -1
- package/dist/saas/setup.js +1 -9
- package/dist/scaffold-crud.js +12 -137
- package/dist/schedule/run.js +1 -7
- package/dist/search/flush.js +1 -10
- package/dist/search/import.js +1 -10
- package/dist/search/settings-list.js +1 -10
- package/dist/search/settings.js +1 -9
- package/dist/serve/api.js +1 -37
- package/dist/setup/index.js +1 -1
- package/dist/setup/ssl.js +2 -268
- package/dist/stacks.js +1 -316
- package/dist/templates.js +20 -40
- package/dist/test/feature.js +1 -2
- package/dist/test/index.js +1 -2
- package/dist/test/runner.js +1 -38
- package/dist/test/runner.test.js +1 -29
- package/dist/test/ui.js +1 -2
- package/dist/test/unit.js +1 -2
- package/dist/typecheck.js +1 -4
- package/dist/types.js +1 -16
- package/dist/upgrade/binary.js +1 -29
- package/dist/upgrade/framework-hooks.js +1 -40
- package/dist/upgrade/framework-utils.js +2 -259
- package/dist/upgrade/framework.js +11 -484
- package/dist/upgrade/index.js +1 -17
- package/dist/upgrade/package-project.js +1 -150
- package/dist/upgrade/packages.js +17 -243
- package/dist/upgrade/shell.js +3 -40
- package/dist/upgrade.js +1 -38
- package/package.json +19 -19
package/dist/queue/resume.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { resumeQueue } from "@stacksjs/queue";
|
|
4
|
-
const options = parseArgs(), queue = options.queue;
|
|
5
|
-
if (!queue) {
|
|
6
|
-
log.error("Usage: buddy queue:resume --queue=<name>");
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
await resumeQueue(queue);
|
|
11
|
-
log.success(`Resumed queue '${queue}'`);
|
|
12
|
-
process.exit(0);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
log.error("Failed to resume queue", error);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
function parseArgs() {
|
|
18
|
-
const args = {};
|
|
19
|
-
process.argv.forEach((arg) => {
|
|
20
|
-
if (arg.startsWith("--")) {
|
|
21
|
-
const [key, value] = arg.slice(2).split("=");
|
|
22
|
-
if (key && value)
|
|
23
|
-
args[key] = value;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return args;
|
|
27
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{resumeQueue}from"@stacksjs/queue";const options=parseArgs(),queue=options.queue;if(!queue){log.error("Usage: buddy queue:resume --queue=<name>");process.exit(1)}try{await resumeQueue(queue);log.success(`Resumed queue '${queue}'`);process.exit(0)}catch(error){log.error("Failed to resume queue",error);process.exit(1)}function parseArgs(){const args={};process.argv.forEach((arg)=>{if(arg.startsWith("--")){const[key,value]=arg.slice(2).split("=");if(key&&value)args[key]=value}});return args}
|
package/dist/queue/retry.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { executeFailedJobs, retryFailedJob } from "@stacksjs/queue";
|
|
4
|
-
const options = parseArgs(), jobId = options.id, all = options.all === "true";
|
|
5
|
-
try {
|
|
6
|
-
if (all) {
|
|
7
|
-
log.info("Retrying all failed jobs...");
|
|
8
|
-
await executeFailedJobs();
|
|
9
|
-
log.success("All failed jobs have been queued for retry");
|
|
10
|
-
} else if (jobId) {
|
|
11
|
-
const id = Number.parseInt(jobId, 10);
|
|
12
|
-
if (Number.isNaN(id)) {
|
|
13
|
-
log.error("Invalid job ID provided");
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
log.info(`Retrying failed job ${id}...`);
|
|
17
|
-
await retryFailedJob(id);
|
|
18
|
-
log.success(`Failed job ${id} has been queued for retry`);
|
|
19
|
-
} else {
|
|
20
|
-
log.warn("Please provide a job ID or use --all to retry all failed jobs");
|
|
21
|
-
log.info("Usage: buddy queue:retry <id> or buddy queue:retry --all");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
process.exit(0);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
log.error("Failed to retry job(s)", error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
function parseArgs() {
|
|
30
|
-
const args = {};
|
|
31
|
-
process.argv.forEach((arg) => {
|
|
32
|
-
if (arg.startsWith("--")) {
|
|
33
|
-
const [key, value] = arg.slice(2).split("=");
|
|
34
|
-
if (key && value)
|
|
35
|
-
args[key] = value;
|
|
36
|
-
else if (key)
|
|
37
|
-
args[key] = "true";
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return args;
|
|
41
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{executeFailedJobs,retryFailedJob}from"@stacksjs/queue";const options=parseArgs(),jobId=options.id,all=options.all==="true";try{if(all){log.info("Retrying all failed jobs...");await executeFailedJobs();log.success("All failed jobs have been queued for retry")}else if(jobId){const id=Number.parseInt(jobId,10);if(Number.isNaN(id)){log.error("Invalid job ID provided");process.exit(1)}log.info(`Retrying failed job ${id}...`);await retryFailedJob(id);log.success(`Failed job ${id} has been queued for retry`)}else{log.warn("Please provide a job ID or use --all to retry all failed jobs");log.info("Usage: buddy queue:retry <id> or buddy queue:retry --all");process.exit(1)}process.exit(0)}catch(error){log.error("Failed to retry job(s)",error);process.exit(1)}function parseArgs(){const args={};process.argv.forEach((arg)=>{if(arg.startsWith("--")){const[key,value]=arg.slice(2).split("=");if(key&&value)args[key]=value;else if(key)args[key]="true"}});return args}
|
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
log.info(`Discovering scheduled jobs...
|
|
6
|
-
`);
|
|
7
|
-
await discoverJobs();
|
|
8
|
-
const scheduledJobs = getScheduledJobs();
|
|
9
|
-
if (scheduledJobs.length === 0) {
|
|
10
|
-
log.info("No scheduled jobs found.");
|
|
11
|
-
log.info('Tip: Add a "rate" or "schedule" property to your job configuration.');
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
|
|
15
|
-
console.log("\u2502 Job Name \u2502 Schedule \u2502 Queue \u2502 Tries \u2502");
|
|
16
|
-
console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
17
|
-
for (const job of scheduledJobs) {
|
|
18
|
-
const name = job.name.substring(0, 48).padEnd(48), schedule = (job.config.rate || job.config.schedule || "N/A").substring(0, 21).padEnd(21), queue = (job.config.queue || "default").substring(0, 9).padEnd(9), tries = String(job.config.tries || 3).padStart(7);
|
|
19
|
-
console.log(`\u2502 ${name} \u2502 ${schedule} \u2502 ${queue} \u2502${tries} \u2502`);
|
|
20
|
-
}
|
|
21
|
-
console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
22
|
-
console.log(`
|
|
23
|
-
Total: ${scheduledJobs.length} scheduled job(s)`);
|
|
24
|
-
console.log(`
|
|
25
|
-
Schedule Formats:`);
|
|
26
|
-
console.log(' \u2022 Cron: "* * * * *" (minute hour day month dayOfWeek)');
|
|
27
|
-
console.log(" \u2022 Presets: @hourly, @daily, @weekly, @monthly");
|
|
28
|
-
console.log(" \u2022 Every: Every.Minute, Every.Hour, Every.Day");
|
|
29
|
-
process.exit(0);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
log.error("Failed to list scheduled jobs:", error);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{discoverJobs,getScheduledJobs}from"@stacksjs/queue";try{log.info(`Discovering scheduled jobs...
|
|
2
|
+
`);await discoverJobs();const scheduledJobs=getScheduledJobs();if(scheduledJobs.length===0){log.info("No scheduled jobs found.");log.info('Tip: Add a "rate" or "schedule" property to your job configuration.');process.exit(0)}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");console.log("\u2502 Job Name \u2502 Schedule \u2502 Queue \u2502 Tries \u2502");console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");for(const job of scheduledJobs){const name=job.name.substring(0,48).padEnd(48),schedule=(job.config.rate||job.config.schedule||"N/A").substring(0,21).padEnd(21),queue=(job.config.queue||"default").substring(0,9).padEnd(9),tries=String(job.config.tries||3).padStart(7);console.log(`\u2502 ${name} \u2502 ${schedule} \u2502 ${queue} \u2502${tries} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");console.log(`
|
|
3
|
+
Total: ${scheduledJobs.length} scheduled job(s)`);console.log(`
|
|
4
|
+
Schedule Formats:`);console.log(' \u2022 Cron: "* * * * *" (minute hour day month dayOfWeek)');console.log(" \u2022 Presets: @hourly, @daily, @weekly, @monthly");console.log(" \u2022 Every: Every.Minute, Every.Hour, Every.Day");process.exit(0)}catch(error){log.error("Failed to list scheduled jobs:",error);process.exit(1)}
|
package/dist/queue/schedule.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { startScheduler } from "@stacksjs/queue";
|
|
4
|
-
log.info("Starting job scheduler...");
|
|
5
|
-
try {
|
|
6
|
-
await startScheduler();
|
|
7
|
-
log.success("Scheduler is running. Press Ctrl+C to stop.");
|
|
8
|
-
await new Promise(() => {});
|
|
9
|
-
} catch (error) {
|
|
10
|
-
log.error("Failed to start scheduler:", error);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{startScheduler}from"@stacksjs/queue";log.info("Starting job scheduler...");try{await startScheduler();log.success("Scheduler is running. Press Ctrl+C to stop.");await new Promise(()=>{})}catch(error){log.error("Failed to start scheduler:",error);process.exit(1)}
|
package/dist/queue/status.js
CHANGED
|
@@ -1,68 +1,4 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
log.info(`Fetching queue status...
|
|
7
|
-
`);
|
|
8
|
-
const allJobs = queueName ? await Job.where("queue", queueName).get() : await Job.all(), failedJobs = queueName ? await FailedJob.where("queue", queueName).get() : await FailedJob.all(), queueStats = new Map;
|
|
9
|
-
for (const job of allJobs) {
|
|
10
|
-
const queue = job.queue || "default";
|
|
11
|
-
if (!queueStats.has(queue))
|
|
12
|
-
queueStats.set(queue, { pending: 0, processing: 0, delayed: 0 });
|
|
13
|
-
const stats = queueStats.get(queue), now = Math.floor(Date.now() / 1000);
|
|
14
|
-
if (job.reserved_at)
|
|
15
|
-
stats.processing++;
|
|
16
|
-
else if (job.available_at && Number(job.available_at) > now)
|
|
17
|
-
stats.delayed++;
|
|
18
|
-
else
|
|
19
|
-
stats.pending++;
|
|
20
|
-
}
|
|
21
|
-
const failedStats = new Map;
|
|
22
|
-
for (const job of failedJobs) {
|
|
23
|
-
const queue = job.queue || "default";
|
|
24
|
-
failedStats.set(queue, (failedStats.get(queue) || 0) + 1);
|
|
25
|
-
}
|
|
26
|
-
console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
|
|
27
|
-
console.log("\u2502 Queue \u2502 Pending \u2502 Processing \u2502 Delayed \u2502 Failed \u2502");
|
|
28
|
-
console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");
|
|
29
|
-
const allQueues = new Set([...queueStats.keys(), ...failedStats.keys()]);
|
|
30
|
-
if (allQueues.size === 0)
|
|
31
|
-
console.log("\u2502 No queues found \u2502");
|
|
32
|
-
else
|
|
33
|
-
for (const queue of allQueues) {
|
|
34
|
-
const stats = queueStats.get(queue) || { pending: 0, processing: 0, delayed: 0 }, failed = failedStats.get(queue) || 0, queueDisplay = queue.substring(0, 48).padEnd(48), pendingDisplay = String(stats.pending).padStart(8), processingDisplay = String(stats.processing).padStart(10), delayedDisplay = String(stats.delayed).padStart(8), failedDisplay = String(failed).padStart(6);
|
|
35
|
-
console.log(`\u2502 ${queueDisplay} \u2502${pendingDisplay} \u2502${processingDisplay} \u2502${delayedDisplay} \u2502${failedDisplay} \u2502`);
|
|
36
|
-
}
|
|
37
|
-
console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
38
|
-
const totalPending = Array.from(queueStats.values()).reduce((sum, s) => sum + s.pending, 0), totalProcessing = Array.from(queueStats.values()).reduce((sum, s) => sum + s.processing, 0), totalDelayed = Array.from(queueStats.values()).reduce((sum, s) => sum + s.delayed, 0), totalFailed = Array.from(failedStats.values()).reduce((sum, n) => sum + n, 0);
|
|
39
|
-
console.log(`
|
|
40
|
-
Summary:`);
|
|
41
|
-
console.log(` Pending: ${totalPending}`);
|
|
42
|
-
console.log(` Processing: ${totalProcessing}`);
|
|
43
|
-
console.log(` Delayed: ${totalDelayed}`);
|
|
44
|
-
console.log(` Failed: ${totalFailed}`);
|
|
45
|
-
console.log(` Total: ${totalPending + totalProcessing + totalDelayed + totalFailed}`);
|
|
46
|
-
process.exit(0);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
49
|
-
if (/no such table:\s*(?:jobs|failed_jobs)\b/i.test(message)) {
|
|
50
|
-
process.stdout.write(`Queue tables are not set up yet.
|
|
51
|
-
`);
|
|
52
|
-
process.stdout.write("Run `buddy queue:table` to create the migrations, then `buddy migrate` to apply them.\n");
|
|
53
|
-
process.exit(0);
|
|
54
|
-
}
|
|
55
|
-
log.error("Failed to get queue status", error);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
function parseArgs() {
|
|
59
|
-
const args = {};
|
|
60
|
-
process.argv.forEach((arg) => {
|
|
61
|
-
if (arg.startsWith("--")) {
|
|
62
|
-
const [key, value] = arg.slice(2).split("=");
|
|
63
|
-
if (key && value)
|
|
64
|
-
args[key] = value;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return args;
|
|
68
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{Job,FailedJob}from"@stacksjs/orm";const options=parseArgs(),queueName=options.queue;try{log.info(`Fetching queue status...
|
|
2
|
+
`);const allJobs=queueName?await Job.where("queue",queueName).get():await Job.all(),failedJobs=queueName?await FailedJob.where("queue",queueName).get():await FailedJob.all(),queueStats=new Map;for(const job of allJobs){const queue=job.queue||"default";if(!queueStats.has(queue))queueStats.set(queue,{pending:0,processing:0,delayed:0});const stats=queueStats.get(queue),now=Math.floor(Date.now()/1000);if(job.reserved_at)stats.processing++;else if(job.available_at&&Number(job.available_at)>now)stats.delayed++;else stats.pending++}const failedStats=new Map;for(const job of failedJobs){const queue=job.queue||"default";failedStats.set(queue,(failedStats.get(queue)||0)+1)}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");console.log("\u2502 Queue \u2502 Pending \u2502 Processing \u2502 Delayed \u2502 Failed \u2502");console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");const allQueues=new Set([...queueStats.keys(),...failedStats.keys()]);if(allQueues.size===0)console.log("\u2502 No queues found \u2502");else for(const queue of allQueues){const stats=queueStats.get(queue)||{pending:0,processing:0,delayed:0},failed=failedStats.get(queue)||0,queueDisplay=queue.substring(0,48).padEnd(48),pendingDisplay=String(stats.pending).padStart(8),processingDisplay=String(stats.processing).padStart(10),delayedDisplay=String(stats.delayed).padStart(8),failedDisplay=String(failed).padStart(6);console.log(`\u2502 ${queueDisplay} \u2502${pendingDisplay} \u2502${processingDisplay} \u2502${delayedDisplay} \u2502${failedDisplay} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");const totalPending=Array.from(queueStats.values()).reduce((sum,s)=>sum+s.pending,0),totalProcessing=Array.from(queueStats.values()).reduce((sum,s)=>sum+s.processing,0),totalDelayed=Array.from(queueStats.values()).reduce((sum,s)=>sum+s.delayed,0),totalFailed=Array.from(failedStats.values()).reduce((sum,n)=>sum+n,0);console.log(`
|
|
3
|
+
Summary:`);console.log(` Pending: ${totalPending}`);console.log(` Processing: ${totalProcessing}`);console.log(` Delayed: ${totalDelayed}`);console.log(` Failed: ${totalFailed}`);console.log(` Total: ${totalPending+totalProcessing+totalDelayed+totalFailed}`);process.exit(0)}catch(error){const message=error instanceof Error?error.message:String(error);if(/no such table:\s*(?:jobs|failed_jobs)\b/i.test(message)){process.stdout.write(`Queue tables are not set up yet.
|
|
4
|
+
`);process.stdout.write("Run `buddy queue:table` to create the migrations, then `buddy migrate` to apply them.\n");process.exit(0)}log.error("Failed to get queue status",error);process.exit(1)}function parseArgs(){const args={};process.argv.forEach((arg)=>{if(arg.startsWith("--")){const[key,value]=arg.slice(2).split("=");if(key&&value)args[key]=value}});return args}
|
package/dist/queue/table.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { createJobsMigration } from "@stacksjs/database";
|
|
3
|
-
import { log } from "@stacksjs/logging";
|
|
4
|
-
const result = await createJobsMigration();
|
|
5
|
-
if (result?.isErr) {
|
|
6
|
-
console.error(result.error);
|
|
7
|
-
log.error("generateMigrations failed", result.error);
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
process.exit(0);
|
|
1
|
+
import process from"node:process";import{createJobsMigration}from"@stacksjs/database";import{log}from"@stacksjs/logging";const result=await createJobsMigration();if(result?.isErr){console.error(result.error);log.error("generateMigrations failed",result.error);process.exit(1)}process.exit(0);
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { unquarantineJob } from "@stacksjs/queue";
|
|
4
|
-
const options = parseArgs(), jobName = options.name;
|
|
5
|
-
if (!jobName) {
|
|
6
|
-
log.error("Usage: buddy queue:unquarantine --name=<JobName>");
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
await unquarantineJob(jobName);
|
|
11
|
-
log.success(`Lifted quarantine for ${jobName}`);
|
|
12
|
-
process.exit(0);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
log.error("Failed to unquarantine", error);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
function parseArgs() {
|
|
18
|
-
const args = {};
|
|
19
|
-
process.argv.forEach((arg) => {
|
|
20
|
-
if (arg.startsWith("--")) {
|
|
21
|
-
const [key, value] = arg.slice(2).split("=");
|
|
22
|
-
if (key && value)
|
|
23
|
-
args[key] = value;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return args;
|
|
27
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{unquarantineJob}from"@stacksjs/queue";const options=parseArgs(),jobName=options.name;if(!jobName){log.error("Usage: buddy queue:unquarantine --name=<JobName>");process.exit(1)}try{await unquarantineJob(jobName);log.success(`Lifted quarantine for ${jobName}`);process.exit(0)}catch(error){log.error("Failed to unquarantine",error);process.exit(1)}function parseArgs(){const args={};process.argv.forEach((arg)=>{if(arg.startsWith("--")){const[key,value]=arg.slice(2).split("=");if(key&&value)args[key]=value}});return args}
|
package/dist/queue/work.js
CHANGED
|
@@ -1,57 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { startProcessor, stopProcessor } from "@stacksjs/queue";
|
|
4
|
-
process.on("unhandledRejection", (reason) => {
|
|
5
|
-
log.error(`Unhandled Rejection in queue worker: ${reason}`);
|
|
6
|
-
});
|
|
7
|
-
process.on("uncaughtException", (error) => {
|
|
8
|
-
log.error(`Uncaught Exception in queue worker: ${error.message}`);
|
|
9
|
-
});
|
|
10
|
-
const SHUTDOWN_GRACE_MS = Number(process.env.STACKS_QUEUE_SHUTDOWN_GRACE_MS) || 1e4;
|
|
11
|
-
let shuttingDown = !1;
|
|
12
|
-
async function gracefulShutdown(signal) {
|
|
13
|
-
if (shuttingDown)
|
|
14
|
-
return;
|
|
15
|
-
shuttingDown = !0;
|
|
16
|
-
log.info(`[queue] Worker received ${signal}, draining in-flight jobs (max ${SHUTDOWN_GRACE_MS / 1000}s)\u2026`);
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
log.warn("[queue] Drain window exceeded \u2014 forcing worker exit.");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}, SHUTDOWN_GRACE_MS + 2000).unref();
|
|
21
|
-
try {
|
|
22
|
-
await stopProcessor({ graceMs: SHUTDOWN_GRACE_MS });
|
|
23
|
-
} catch (error) {
|
|
24
|
-
log.error("[queue] Error while draining worker on shutdown:", error);
|
|
25
|
-
}
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
process.on("SIGTERM", () => {
|
|
29
|
-
gracefulShutdown("SIGTERM");
|
|
30
|
-
});
|
|
31
|
-
process.on("SIGINT", () => {
|
|
32
|
-
gracefulShutdown("SIGINT");
|
|
33
|
-
});
|
|
34
|
-
const options = parseArgs(), queue = options.queue, concurrency = Number(options.concurrency) || 1;
|
|
35
|
-
log.info(`Starting queue worker with ${concurrency} concurrent worker(s)...`);
|
|
36
|
-
const result = await startProcessor(queue, {
|
|
37
|
-
concurrency
|
|
38
|
-
});
|
|
39
|
-
if (result.isErr) {
|
|
40
|
-
log.error("Failed to start queue worker:", result.error);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
log.success("Queue worker started successfully!");
|
|
44
|
-
await new Promise(() => {});
|
|
45
|
-
function parseArgs() {
|
|
46
|
-
const args = {};
|
|
47
|
-
process.argv.forEach((arg) => {
|
|
48
|
-
if (arg.startsWith("--")) {
|
|
49
|
-
const [key, value] = arg.slice(2).split("=");
|
|
50
|
-
if (key && value)
|
|
51
|
-
args[key] = value;
|
|
52
|
-
else if (key)
|
|
53
|
-
args[key] = "true";
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return args;
|
|
57
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{startProcessor,stopProcessor}from"@stacksjs/queue";process.on("unhandledRejection",(reason)=>{log.error(`Unhandled Rejection in queue worker: ${reason}`)});process.on("uncaughtException",(error)=>{log.error(`Uncaught Exception in queue worker: ${error.message}`)});const SHUTDOWN_GRACE_MS=Number(process.env.STACKS_QUEUE_SHUTDOWN_GRACE_MS)||1e4;let shuttingDown=!1;async function gracefulShutdown(signal){if(shuttingDown)return;shuttingDown=!0;log.info(`[queue] Worker received ${signal}, draining in-flight jobs (max ${SHUTDOWN_GRACE_MS/1000}s)\u2026`);setTimeout(()=>{log.warn("[queue] Drain window exceeded \u2014 forcing worker exit.");process.exit(1)},SHUTDOWN_GRACE_MS+2000).unref();try{await stopProcessor({graceMs:SHUTDOWN_GRACE_MS})}catch(error){log.error("[queue] Error while draining worker on shutdown:",error)}process.exit(0)}process.on("SIGTERM",()=>{gracefulShutdown("SIGTERM")});process.on("SIGINT",()=>{gracefulShutdown("SIGINT")});const options=parseArgs(),queue=options.queue,concurrency=Number(options.concurrency)||1;log.info(`Starting queue worker with ${concurrency} concurrent worker(s)...`);const result=await startProcessor(queue,{concurrency});if(result.isErr){log.error("Failed to start queue worker:",result.error);process.exit(1)}log.success("Queue worker started successfully!");await new Promise(()=>{});function parseArgs(){const args={};process.argv.forEach((arg)=>{if(arg.startsWith("--")){const[key,value]=arg.slice(2).split("=");if(key&&value)args[key]=value;else if(key)args[key]="true"}});return args}
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
import { readFileSync }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function pinnedCheckScripts(scripts) {
|
|
5
|
-
return Object.keys(scripts).filter((name) => /^(?:protocol|docs):(?:[\w:-]+:)?check$/.test(name)).sort();
|
|
6
|
-
}
|
|
7
|
-
export function readPinnedChecks(cwd) {
|
|
8
|
-
try {
|
|
9
|
-
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
10
|
-
return pinnedCheckScripts(pkg.scripts ?? {});
|
|
11
|
-
} catch {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function isBypassed(env) {
|
|
16
|
-
const value = env[BYPASS_ENV];
|
|
17
|
-
return value === "1" || value === "true";
|
|
18
|
-
}
|
|
19
|
-
export async function runPinnedChecks(options = { cwd: process.cwd() }) {
|
|
20
|
-
const env = options.env ?? process.env;
|
|
21
|
-
if (isBypassed(env))
|
|
22
|
-
return { ran: [], failures: [], bypassed: !0 };
|
|
23
|
-
const scripts = options.scripts ?? readPinnedChecks(options.cwd);
|
|
24
|
-
if (scripts.length === 0)
|
|
25
|
-
return { ran: [], failures: [], bypassed: !1 };
|
|
26
|
-
const results = await Promise.all(scripts.map(async (script) => {
|
|
27
|
-
const proc = Bun.spawn(["bun", "run", script], {
|
|
28
|
-
cwd: options.cwd,
|
|
29
|
-
stdout: "pipe",
|
|
30
|
-
stderr: "pipe"
|
|
31
|
-
}), [stdout, stderr, exitCode] = await Promise.all([
|
|
32
|
-
new Response(proc.stdout).text(),
|
|
33
|
-
new Response(proc.stderr).text(),
|
|
34
|
-
proc.exited
|
|
35
|
-
]);
|
|
36
|
-
return { script, exitCode, output: `${stdout}${stderr}`.trim() };
|
|
37
|
-
}));
|
|
38
|
-
return {
|
|
39
|
-
ran: scripts,
|
|
40
|
-
failures: results.filter((r) => r.exitCode !== 0).map((r) => ({ script: r.script, output: r.output })),
|
|
41
|
-
bypassed: !1
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export function formatPreflightFailure(failures) {
|
|
45
|
-
const lines = [
|
|
46
|
-
`Release blocked: ${failures.length} pinned check${failures.length === 1 ? "" : "s"} failed.`,
|
|
47
|
-
""
|
|
48
|
-
];
|
|
49
|
-
for (const failure of failures) {
|
|
50
|
-
lines.push(` ${failure.script}`);
|
|
51
|
-
const informative = failure.output.split(`
|
|
52
|
-
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("[env]") && !line.startsWith("$ ") && !line.startsWith("error: script"));
|
|
53
|
-
for (const line of informative.slice(0, 4))
|
|
54
|
-
lines.push(` ${line}`);
|
|
55
|
-
lines.push("");
|
|
56
|
-
}
|
|
57
|
-
lines.push("Nothing was bumped, committed, or tagged.");
|
|
58
|
-
lines.push(`Regenerate the affected artifacts and retry, or set ${BYPASS_ENV}=1 to release anyway.`);
|
|
59
|
-
return lines.join(`
|
|
60
|
-
`);
|
|
61
|
-
}
|
|
1
|
+
import{readFileSync}from"node:fs";import{join}from"node:path";export const BYPASS_ENV="RELEASE_GATE_BYPASS";export function pinnedCheckScripts(scripts){return Object.keys(scripts).filter((name)=>/^(?:protocol|docs):(?:[\w:-]+:)?check$/.test(name)).sort()}export function readPinnedChecks(cwd){try{const pkg=JSON.parse(readFileSync(join(cwd,"package.json"),"utf8"));return pinnedCheckScripts(pkg.scripts??{})}catch{return[]}}function isBypassed(env){const value=env[BYPASS_ENV];return value==="1"||value==="true"}export async function runPinnedChecks(options={cwd:process.cwd()}){const env=options.env??process.env;if(isBypassed(env))return{ran:[],failures:[],bypassed:!0};const scripts=options.scripts??readPinnedChecks(options.cwd);if(scripts.length===0)return{ran:[],failures:[],bypassed:!1};const results=await Promise.all(scripts.map(async(script)=>{const proc=Bun.spawn(["bun","run",script],{cwd:options.cwd,stdout:"pipe",stderr:"pipe"}),[stdout,stderr,exitCode]=await Promise.all([new Response(proc.stdout).text(),new Response(proc.stderr).text(),proc.exited]);return{script,exitCode,output:`${stdout}${stderr}`.trim()}}));return{ran:scripts,failures:results.filter((r)=>r.exitCode!==0).map((r)=>({script:r.script,output:r.output})),bypassed:!1}}export function formatPreflightFailure(failures){const lines=[`Release blocked: ${failures.length} pinned check${failures.length===1?"":"s"} failed.`,""];for(const failure of failures){lines.push(` ${failure.script}`);const informative=failure.output.split(`
|
|
2
|
+
`).map((line)=>line.trim()).filter((line)=>line&&!line.startsWith("[env]")&&!line.startsWith("$ ")&&!line.startsWith("error: script"));for(const line of informative.slice(0,4))lines.push(` ${line}`);lines.push("")}lines.push("Nothing was bumped, committed, or tagged.");lines.push(`Regenerate the affected artifacts and retry, or set ${BYPASS_ENV}=1 to release anyway.`);return lines.join(`
|
|
3
|
+
`)}
|
package/dist/release.js
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { app } from "@stacksjs/config";
|
|
3
|
-
import { Action } from "@stacksjs/enums";
|
|
4
|
-
import { log } from "@stacksjs/logging";
|
|
5
|
-
import { projectPath } from "@stacksjs/path";
|
|
6
|
-
import { runActions } from ".";
|
|
7
|
-
import { BYPASS_ENV, formatPreflightFailure, runPinnedChecks } from "./release-preflight";
|
|
8
|
-
const raw = parseOptions() ?? {}, passthrough = {};
|
|
9
|
-
for (const [k, v] of Object.entries(raw)) {
|
|
10
|
-
if (k === "--" || k === "_")
|
|
11
|
-
continue;
|
|
12
|
-
passthrough[k] = v;
|
|
13
|
-
}
|
|
14
|
-
const isDryRun = passthrough.dryRun === !0 || passthrough.dryRun === "true", actions = isDryRun ? [Action.GenerateLibraryEntries, Action.Bump] : [Action.GenerateLibraryEntries, Action.LintFix, Action.Bump], preflight = await runPinnedChecks({ cwd: projectPath() });
|
|
15
|
-
if (preflight.bypassed)
|
|
16
|
-
log.warn(`${BYPASS_ENV} is set, so the pinned checks were skipped for this release.`);
|
|
17
|
-
else if (preflight.failures.length > 0) {
|
|
18
|
-
log.error(formatPreflightFailure(preflight.failures));
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
const result = await runActions(actions, {
|
|
22
|
-
cwd: projectPath(),
|
|
23
|
-
...passthrough
|
|
24
|
-
});
|
|
25
|
-
if (result && result.isErr) {
|
|
26
|
-
log.error(`Release failed: ${result.error?.message ?? String(result.error)}`);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
log.success(`Successfully released ${app.name}`);
|
|
1
|
+
import{parseOptions}from"@stacksjs/cli";import{app}from"@stacksjs/config";import{Action}from"@stacksjs/enums";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{runActions}from".";import{BYPASS_ENV,formatPreflightFailure,runPinnedChecks}from"./release-preflight";const raw=parseOptions()??{},passthrough={};for(const[k,v]of Object.entries(raw)){if(k==="--"||k==="_")continue;passthrough[k]=v}const isDryRun=passthrough.dryRun===!0||passthrough.dryRun==="true",actions=isDryRun?[Action.GenerateLibraryEntries,Action.Bump]:[Action.GenerateLibraryEntries,Action.LintFix,Action.Bump],preflight=await runPinnedChecks({cwd:projectPath()});if(preflight.bypassed)log.warn(`${BYPASS_ENV} is set, so the pinned checks were skipped for this release.`);else if(preflight.failures.length>0){log.error(formatPreflightFailure(preflight.failures));process.exit(1)}const result=await runActions(actions,{cwd:projectPath(),...passthrough});if(result&&result.isErr){log.error(`Release failed: ${result.error?.message??String(result.error)}`);process.exit(1)}log.success(`Successfully released ${app.name}`);
|
package/dist/route/list.js
CHANGED
|
@@ -1,78 +1,2 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
|
|
3
|
-
import { route } from "@stacksjs/router";
|
|
4
|
-
const METHOD_ORDER = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
|
|
5
|
-
function formatHandler(handler) {
|
|
6
|
-
if (typeof handler === "string")
|
|
7
|
-
return handler;
|
|
8
|
-
if (typeof handler === "function")
|
|
9
|
-
return handler.name ? `[fn ${handler.name}]` : "[fn]";
|
|
10
|
-
return "[handler]";
|
|
11
|
-
}
|
|
12
|
-
function pad(value, width) {
|
|
13
|
-
if (value.length >= width)
|
|
14
|
-
return value;
|
|
15
|
-
return value + " ".repeat(width - value.length);
|
|
16
|
-
}
|
|
17
|
-
function write(line) {
|
|
18
|
-
process.stdout.write(`${line}
|
|
19
|
-
`);
|
|
20
|
-
}
|
|
21
|
-
async function listRoutes() {
|
|
22
|
-
try {
|
|
23
|
-
await route.importRoutes();
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return { isErr: !0, error };
|
|
26
|
-
}
|
|
27
|
-
const registered = route.routes ?? [];
|
|
28
|
-
if (registered.length === 0) {
|
|
29
|
-
write(italic("No routes registered."));
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
const rows = registered.map((r) => ({
|
|
33
|
-
method: String(r.method || "GET").toUpperCase(),
|
|
34
|
-
uri: String(r.path || r.uri || ""),
|
|
35
|
-
handler: formatHandler(r.handler ?? r.action ?? ""),
|
|
36
|
-
name: String(r.name || ""),
|
|
37
|
-
middleware: Array.isArray(r.middleware) ? r.middleware.join(",") : String(r.middleware || "")
|
|
38
|
-
}));
|
|
39
|
-
rows.sort((a, b) => {
|
|
40
|
-
const ai = METHOD_ORDER.indexOf(a.method), bi = METHOD_ORDER.indexOf(b.method);
|
|
41
|
-
if (ai !== bi)
|
|
42
|
-
return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
|
|
43
|
-
return a.uri.localeCompare(b.uri);
|
|
44
|
-
});
|
|
45
|
-
const widths = {
|
|
46
|
-
method: Math.max(6, ...rows.map((r) => r.method.length)),
|
|
47
|
-
uri: Math.max(3, ...rows.map((r) => r.uri.length)),
|
|
48
|
-
handler: Math.max(7, ...rows.map((r) => r.handler.length)),
|
|
49
|
-
name: Math.max(4, ...rows.map((r) => r.name.length))
|
|
50
|
-
}, header = [
|
|
51
|
-
pad("METHOD", widths.method),
|
|
52
|
-
pad("URI", widths.uri),
|
|
53
|
-
pad("HANDLER", widths.handler),
|
|
54
|
-
pad("NAME", widths.name),
|
|
55
|
-
"MIDDLEWARE"
|
|
56
|
-
].join(" ");
|
|
57
|
-
write("");
|
|
58
|
-
write(header);
|
|
59
|
-
write("-".repeat(header.length));
|
|
60
|
-
for (const r of rows)
|
|
61
|
-
write([
|
|
62
|
-
pad(r.method, widths.method),
|
|
63
|
-
pad(r.uri, widths.uri),
|
|
64
|
-
pad(r.handler, widths.handler),
|
|
65
|
-
pad(r.name || "-", widths.name),
|
|
66
|
-
r.middleware || "-"
|
|
67
|
-
].join(" "));
|
|
68
|
-
write("");
|
|
69
|
-
write(italic(`${rows.length} route${rows.length === 1 ? "" : "s"} registered.`));
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
const result = await listRoutes();
|
|
73
|
-
if (result?.isErr) {
|
|
74
|
-
console.error(result.error);
|
|
75
|
-
log.error("Route lists failed", result.error);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
process.exit(0);
|
|
1
|
+
import process from"node:process";import{italic,log}from"@stacksjs/cli";import{route}from"@stacksjs/router";const METHOD_ORDER=["GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS"];function formatHandler(handler){if(typeof handler==="string")return handler;if(typeof handler==="function")return handler.name?`[fn ${handler.name}]`:"[fn]";return"[handler]"}function pad(value,width){if(value.length>=width)return value;return value+" ".repeat(width-value.length)}function write(line){process.stdout.write(`${line}
|
|
2
|
+
`)}async function listRoutes(){try{await route.importRoutes()}catch(error){return{isErr:!0,error}}const registered=route.routes??[];if(registered.length===0){write(italic("No routes registered."));return{}}const rows=registered.map((r)=>({method:String(r.method||"GET").toUpperCase(),uri:String(r.path||r.uri||""),handler:formatHandler(r.handler??r.action??""),name:String(r.name||""),middleware:Array.isArray(r.middleware)?r.middleware.join(","):String(r.middleware||"")}));rows.sort((a,b)=>{const ai=METHOD_ORDER.indexOf(a.method),bi=METHOD_ORDER.indexOf(b.method);if(ai!==bi)return(ai===-1?99:ai)-(bi===-1?99:bi);return a.uri.localeCompare(b.uri)});const widths={method:Math.max(6,...rows.map((r)=>r.method.length)),uri:Math.max(3,...rows.map((r)=>r.uri.length)),handler:Math.max(7,...rows.map((r)=>r.handler.length)),name:Math.max(4,...rows.map((r)=>r.name.length))},header=[pad("METHOD",widths.method),pad("URI",widths.uri),pad("HANDLER",widths.handler),pad("NAME",widths.name),"MIDDLEWARE"].join(" ");write("");write(header);write("-".repeat(header.length));for(const r of rows)write([pad(r.method,widths.method),pad(r.uri,widths.uri),pad(r.handler,widths.handler),pad(r.name||"-",widths.name),r.middleware||"-"].join(" "));write("");write(italic(`${rows.length} route${rows.length===1?"":"s"} registered.`));return{}}const result=await listRoutes();if(result?.isErr){console.error(result.error);log.error("Route lists failed",result.error);process.exit(1)}process.exit(0);
|
package/dist/run-action.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{runAction}from"./helpers/utils";
|
package/dist/saas/setup.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { createStripeProduct } from "@stacksjs/payments";
|
|
4
|
-
const result = await createStripeProduct();
|
|
5
|
-
if (result?.isErr) {
|
|
6
|
-
console.error(result.error);
|
|
7
|
-
log.error("generateMigrations failed", result.error);
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
1
|
+
import process from"node:process";import{log}from"@stacksjs/logging";import{createStripeProduct}from"@stacksjs/payments";const result=await createStripeProduct();if(result?.isErr){console.error(result.error);log.error("generateMigrations failed",result.error);process.exit(1)}
|