@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/build/core.js
CHANGED
|
@@ -1,2 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { $ } from "bun";
|
|
2
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { dim, italic, log } from "@stacksjs/cli";
|
|
6
|
+
import { feature } from "@stacksjs/config";
|
|
7
|
+
import { corePath } from "@stacksjs/path";
|
|
8
|
+
import { glob } from "@stacksjs/storage";
|
|
9
|
+
import { ExitCode } from "@stacksjs/types";
|
|
10
|
+
log.info("Building core packages");
|
|
11
|
+
const FEATURE_GATED_PACKAGES = {
|
|
12
|
+
cms: "cms",
|
|
13
|
+
commerce: "commerce",
|
|
14
|
+
queue: "queue",
|
|
15
|
+
realtime: "realtime"
|
|
16
|
+
}, allEntries = (await glob([corePath("*")], { onlyFiles: !1 })).sort(), dirs = allEntries.filter((entry) => {
|
|
17
|
+
if (!existsSync(entry) || !statSync(entry).isDirectory())
|
|
18
|
+
return !1;
|
|
19
|
+
const pkgPath = `${entry}/package.json`;
|
|
20
|
+
if (!existsSync(pkgPath))
|
|
21
|
+
return !1;
|
|
22
|
+
const name = basename(entry), gate = FEATURE_GATED_PACKAGES[name];
|
|
23
|
+
if (gate && !feature(gate)) {
|
|
24
|
+
log.info(`Skipping ${italic(dim(entry))} \u2014 feature '${gate}' is disabled`);
|
|
25
|
+
return !1;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return typeof JSON.parse(readFileSync(pkgPath, "utf8")).scripts?.build === "string";
|
|
29
|
+
} catch (error) {
|
|
30
|
+
log.warn(`Skipping ${italic(dim(entry))}: package.json could not be read`);
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (dirs.length === 0) {
|
|
35
|
+
log.info("No core packages found");
|
|
36
|
+
process.exit(ExitCode.FatalError);
|
|
37
|
+
}
|
|
38
|
+
const failed = [];
|
|
39
|
+
for (const folder of dirs) {
|
|
40
|
+
log.info(`\uD83C\uDFD7\uFE0F Building ${italic(dim(folder))}`);
|
|
41
|
+
try {
|
|
42
|
+
$.cwd(folder);
|
|
43
|
+
await $`bun run build`;
|
|
44
|
+
log.success(`${italic(dim(folder))} built`);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
log.warn(`Failed to build ${italic(dim(folder))}, skipping...`);
|
|
47
|
+
failed.push(folder);
|
|
48
|
+
}
|
|
49
|
+
console.log("");
|
|
50
|
+
}
|
|
51
|
+
if (failed.length > 0) {
|
|
52
|
+
log.warn(`${failed.length} package(s) failed to build:`);
|
|
53
|
+
for (const f of failed)
|
|
54
|
+
log.warn(` - ${f}`);
|
|
55
|
+
}
|
package/dist/build/desktop.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommand } from "@stacksjs/cli";
|
|
2
|
+
import { corePath } from "@stacksjs/path";
|
|
3
|
+
await runCommand("bun run build:app", {
|
|
4
|
+
cwd: corePath("desktop")
|
|
5
|
+
});
|
package/dist/build/docs.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommand } from "@stacksjs/cli";
|
|
2
|
+
import { projectPath } from "@stacksjs/path";
|
|
3
|
+
await runCommand("bunpress build", {
|
|
4
|
+
cwd: projectPath()
|
|
5
|
+
});
|
|
@@ -1,9 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { publicPath, resourcesPath, storagePath } from "@stacksjs/path";
|
|
5
|
+
const isVerbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
6
|
+
function debug(...args) {
|
|
7
|
+
if (isVerbose)
|
|
8
|
+
console.log("\uD83D\uDD0D", ...args);
|
|
9
|
+
}
|
|
10
|
+
async function getSignalsRuntime() {
|
|
11
|
+
try {
|
|
12
|
+
const { generateSignalsRuntime } = await import("@stacksjs/stx/signals");
|
|
13
|
+
return `<script>
|
|
14
|
+
${generateSignalsRuntime()}
|
|
15
|
+
</script>`;
|
|
16
|
+
} catch {
|
|
17
|
+
console.warn("Could not load STX signals runtime");
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function copyDir(src, dest) {
|
|
22
|
+
if (!existsSync(dest))
|
|
23
|
+
mkdirSync(dest, { recursive: !0 });
|
|
24
|
+
for (const item of readdirSync(src)) {
|
|
25
|
+
if (item === ".DS_Store")
|
|
26
|
+
continue;
|
|
27
|
+
const srcPath = join(src, item), destPath = join(dest, item);
|
|
28
|
+
if (statSync(srcPath).isDirectory())
|
|
29
|
+
copyDir(srcPath, destPath);
|
|
30
|
+
else
|
|
31
|
+
copyFileSync(srcPath, destPath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export async function buildFrontendStatic(options = {}) {
|
|
35
|
+
const buildDir = options.outDir ?? storagePath("framework/frontend-dist");
|
|
36
|
+
if (existsSync(buildDir))
|
|
37
|
+
rmSync(buildDir, { recursive: !0 });
|
|
38
|
+
mkdirSync(buildDir, { recursive: !0 });
|
|
39
|
+
mkdirSync(join(buildDir, "assets"), { recursive: !0 });
|
|
40
|
+
const indexPath = resourcesPath("views/index.stx");
|
|
41
|
+
if (existsSync(indexPath)) {
|
|
42
|
+
let stxContent = readFileSync(indexPath, "utf-8");
|
|
43
|
+
const serverBlockMatch = stxContent.match(/<script server>([\s\S]*?)<\/script>/);
|
|
44
|
+
let serverVars = {};
|
|
45
|
+
if (serverBlockMatch) {
|
|
46
|
+
const serverCode = serverBlockMatch[1] ?? "";
|
|
47
|
+
try {
|
|
48
|
+
const varNames = [...serverCode.matchAll(/(?:const|let|var)\s+(\w+)\s*=/g)].map((m) => m[1]).filter((name) => Boolean(name));
|
|
49
|
+
serverVars = Function(`${serverCode}
|
|
50
|
+
return { ${varNames.join(", ")} }`)();
|
|
51
|
+
} catch (evalErr) {
|
|
52
|
+
debug(` Server block evaluation failed: ${evalErr}, falling back to regex`);
|
|
53
|
+
const constMatches = serverCode.matchAll(/const\s+(\w+)\s*=\s*(?:'([^']*)'|"([^"]*)"|([\d.]+))/g);
|
|
54
|
+
for (const m of constMatches) {
|
|
55
|
+
const name = m[1];
|
|
56
|
+
if (name)
|
|
57
|
+
serverVars[name] = m[2] ?? m[3] ?? m[4];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
stxContent = stxContent.replace(/<script server>[\s\S]*?<\/script>\s*/, "");
|
|
61
|
+
}
|
|
62
|
+
stxContent = stxContent.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, varName) => {
|
|
63
|
+
const val = serverVars[varName];
|
|
64
|
+
return val !== void 0 && val !== null ? String(val) : "";
|
|
65
|
+
});
|
|
66
|
+
const foreachRegex = /@foreach\s*\((\w+)\s+as\s+(\w+)\)([\s\S]*?)@endforeach/g;
|
|
67
|
+
stxContent = stxContent.replace(foreachRegex, (_, collectionName, itemVar, template) => {
|
|
68
|
+
const collection = serverVars[collectionName];
|
|
69
|
+
if (!Array.isArray(collection) || collection.length === 0)
|
|
70
|
+
return "";
|
|
71
|
+
let rendered = "";
|
|
72
|
+
for (const item of collection) {
|
|
73
|
+
let itemHtml = template;
|
|
74
|
+
itemHtml = itemHtml.replace(new RegExp(`\\{\\{\\s*${itemVar}\\.(\\w+)\\s*\\}\\}`, "g"), (_match, prop) => {
|
|
75
|
+
const val = item[prop];
|
|
76
|
+
return val !== void 0 && val !== null ? String(val) : "";
|
|
77
|
+
});
|
|
78
|
+
itemHtml = itemHtml.replace(new RegExp(`\\{!!\\s*${itemVar}\\.(\\w+)\\s*!!\\}`, "g"), (_match, prop) => {
|
|
79
|
+
const val = item[prop];
|
|
80
|
+
return val !== void 0 && val !== null ? String(val) : "";
|
|
81
|
+
});
|
|
82
|
+
rendered += itemHtml;
|
|
83
|
+
}
|
|
84
|
+
return rendered;
|
|
85
|
+
});
|
|
86
|
+
stxContent = stxContent.replace(/^\s*@extends\([^)]+\)\s*$/gm, "").replace(/^\s*@include\([^)]+\)\s*$/gm, "").replace(/^\s*@section\('title',\s*['"][^'"]*['"]\)\s*$/gm, "").replace(/^\s*@section\('(?:content|footer)'\)\s*$/gm, "").replace(/^\s*@endsection\s*$/gm, "");
|
|
87
|
+
if (/data-stx-scope|@model|@show|@text|@class|@style|@bind:|@if=|@for=/.test(stxContent)) {
|
|
88
|
+
const signalsRuntime = await getSignalsRuntime();
|
|
89
|
+
if (signalsRuntime) {
|
|
90
|
+
const bodyMatch = stxContent.match(/<body[^>]*>/);
|
|
91
|
+
if (bodyMatch) {
|
|
92
|
+
const insertPos = (stxContent.indexOf(bodyMatch[0]) ?? 0) + bodyMatch[0].length;
|
|
93
|
+
stxContent = stxContent.slice(0, insertPos) + `
|
|
94
|
+
` + signalsRuntime + stxContent.slice(insertPos);
|
|
95
|
+
} else
|
|
96
|
+
stxContent = signalsRuntime + `
|
|
97
|
+
` + stxContent;
|
|
98
|
+
debug(" Injected STX signals runtime for client-side reactivity");
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
writeFileSync(join(buildDir, "index.html"), stxContent);
|
|
102
|
+
debug(" Built index.html from STX template");
|
|
103
|
+
} else {
|
|
104
|
+
const defaultIndex = `<!DOCTYPE html>
|
|
8
105
|
<html><head><title>Stacks</title></head>
|
|
9
|
-
<body><h1>Welcome to Stacks</h1></body></html
|
|
106
|
+
<body><h1>Welcome to Stacks</h1></body></html>`;
|
|
107
|
+
writeFileSync(join(buildDir, "index.html"), defaultIndex);
|
|
108
|
+
}
|
|
109
|
+
const assetsPath = resourcesPath("assets");
|
|
110
|
+
if (existsSync(assetsPath)) {
|
|
111
|
+
copyDir(assetsPath, join(buildDir, "assets"));
|
|
112
|
+
debug(" Copied resources/assets directory");
|
|
113
|
+
}
|
|
114
|
+
const projectPublic = publicPath();
|
|
115
|
+
if (existsSync(projectPublic)) {
|
|
116
|
+
copyDir(projectPublic, buildDir);
|
|
117
|
+
debug(" Copied public/ directory");
|
|
118
|
+
}
|
|
119
|
+
return buildDir;
|
|
120
|
+
}
|
|
121
|
+
if (import.meta.main) {
|
|
122
|
+
const outDir = await buildFrontendStatic();
|
|
123
|
+
console.log(`\u2713 Built frontend static site \u2192 ${outDir}`);
|
|
124
|
+
}
|
package/dist/build/server.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { $ } from "bun";
|
|
2
|
+
import { log } from "@stacksjs/cli";
|
|
3
|
+
import { frameworkPath } from "@stacksjs/path";
|
|
4
|
+
log.info("Building Server...");
|
|
5
|
+
$.cwd(frameworkPath("cloud"));
|
|
6
|
+
await $`bun build.ts`;
|
package/dist/build/stacks.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommands } from "@stacksjs/cli";
|
|
2
|
+
import { projectPath } from "@stacksjs/path";
|
|
3
|
+
await runCommands([
|
|
4
|
+
"bun storage/framework/core/actions/src/build/cli.ts"
|
|
5
|
+
], { verbose: !0, cwd: projectPath() });
|
|
6
|
+
await runCommands([
|
|
7
|
+
"bun storage/framework/core/actions/src/build/core.ts"
|
|
8
|
+
], { verbose: !0, cwd: projectPath() });
|
package/dist/build/views.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { runCommand } from "@stacksjs/cli";
|
|
2
|
+
import { frameworkPath, projectPath } from "@stacksjs/path";
|
|
3
|
+
const projectBuild = projectPath("build.ts");
|
|
4
|
+
if (await Bun.file(projectBuild).exists())
|
|
5
|
+
await runCommand("bun build.ts", {
|
|
6
|
+
cwd: projectPath()
|
|
7
|
+
});
|
|
8
|
+
else
|
|
9
|
+
await runCommand("bun run build", {
|
|
10
|
+
cwd: frameworkPath("views/web")
|
|
11
|
+
});
|
package/dist/build.js
CHANGED
|
@@ -1,2 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { NpmScript } from "@stacksjs/enums";
|
|
2
|
+
import { log } from "@stacksjs/logging";
|
|
3
|
+
import { hasComponents, hasFunctions } from "@stacksjs/storage";
|
|
4
|
+
import { runNpmScript } from "@stacksjs/utils";
|
|
5
|
+
import { generateTypes } from "./generate";
|
|
6
|
+
export async function invoke(options) {
|
|
7
|
+
if (options.components)
|
|
8
|
+
await componentLibraries(options);
|
|
9
|
+
else if (options.webComponents || options.elements)
|
|
10
|
+
await webComponentLibrary(options);
|
|
11
|
+
else if (options.functions)
|
|
12
|
+
await functionsLibrary(options);
|
|
13
|
+
else if (options.docs)
|
|
14
|
+
await docs(options);
|
|
15
|
+
else if (options.stacks)
|
|
16
|
+
await stacks(options);
|
|
17
|
+
await generateTypes();
|
|
18
|
+
}
|
|
19
|
+
export async function build(options) {
|
|
20
|
+
return await invoke(options);
|
|
21
|
+
}
|
|
22
|
+
export async function componentLibraries(options) {
|
|
23
|
+
await runNpmScript(NpmScript.GenerateEntries, options);
|
|
24
|
+
await vueComponentLibrary(options);
|
|
25
|
+
await webComponentLibrary(options);
|
|
26
|
+
}
|
|
27
|
+
export async function vueComponentLibrary(options) {
|
|
28
|
+
if (hasComponents()) {
|
|
29
|
+
log.info("Building your component library...");
|
|
30
|
+
await runNpmScript(NpmScript.BuildComponents, options);
|
|
31
|
+
log.success("Your component library was built successfully");
|
|
32
|
+
} else {
|
|
33
|
+
log.warn("No components found.");
|
|
34
|
+
log.info("Before you can build components,");
|
|
35
|
+
log.info("you need to have created some in the ./components folder.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function webComponentLibrary(options) {
|
|
39
|
+
log.info("Building your component library for production use & npm/CDN distribution...");
|
|
40
|
+
if (hasComponents()) {
|
|
41
|
+
await runNpmScript(NpmScript.BuildWebComponents, options);
|
|
42
|
+
log.success("Your Web Component library was built successfully");
|
|
43
|
+
} else
|
|
44
|
+
log.info("No components found.");
|
|
45
|
+
}
|
|
46
|
+
export async function docs(options) {
|
|
47
|
+
log.info("Building the documentation site...");
|
|
48
|
+
await runNpmScript(NpmScript.BuildDocs, options);
|
|
49
|
+
log.success("Docs built successfully");
|
|
50
|
+
}
|
|
51
|
+
export async function stacks(options) {
|
|
52
|
+
log.info("Building the Stacks Framework...");
|
|
53
|
+
await runNpmScript(NpmScript.BuildStacks, options);
|
|
54
|
+
log.success("Stacks built successfully");
|
|
55
|
+
}
|
|
56
|
+
export async function functionsLibrary(options) {
|
|
57
|
+
if (hasFunctions()) {
|
|
58
|
+
log.info("Building your functions library for production usages...");
|
|
59
|
+
log.info("Production usages include: manual npm distribution and/or CDN distribution");
|
|
60
|
+
await runNpmScript(NpmScript.BuildFunctions, options);
|
|
61
|
+
log.success("Functions library built successfully");
|
|
62
|
+
} else
|
|
63
|
+
log.info("No functions found");
|
|
64
|
+
}
|
package/dist/bump.js
CHANGED
|
@@ -1,8 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import{
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { execSync, log, parseOptions } from "@stacksjs/cli";
|
|
2
|
+
import { path as p } from "@stacksjs/path";
|
|
3
|
+
import { versionBump } from "@stacksjs/bumpx";
|
|
4
|
+
import { generateChangelog, loadLogsmithConfig } from "@stacksjs/logsmith";
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { join, relative } from "node:path";
|
|
7
|
+
const options = parseOptions(), allowedBumps = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]), rawBump = options?.bump?.toString(), bumpArg = rawBump ? allowedBumps.has(rawBump) || /^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(rawBump) ? rawBump : null : null;
|
|
8
|
+
if (rawBump && !bumpArg)
|
|
9
|
+
log.warn(`Ignoring invalid --bump "${rawBump}"; expected one of patch|minor|major or x.y.z`);
|
|
10
|
+
const isDryRun = options?.dryRun === !0, isVerbose = options?.verbose === !0;
|
|
11
|
+
async function readPackage(file) {
|
|
12
|
+
if (!existsSync(file))
|
|
13
|
+
return;
|
|
14
|
+
return await Bun.file(file).json();
|
|
15
|
+
}
|
|
16
|
+
const rootManifest = p.projectPath("package.json"), rootPkg = await readPackage(rootManifest), isFrameworkRelease = rootPkg?.name === "stacks" && existsSync(p.frameworkPath("core/package.json")), bumpCwd = isFrameworkRelease ? p.frameworkPath("core") : p.projectPath(), primaryManifest = isFrameworkRelease ? p.frameworkPath("core/package.json") : rootManifest;
|
|
17
|
+
async function resolveBumpArg(bump) {
|
|
18
|
+
if (!bump || /^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(bump))
|
|
19
|
+
return bump;
|
|
20
|
+
if (!["patch", "minor", "major"].includes(bump))
|
|
21
|
+
return bump;
|
|
22
|
+
const match = (await readPackage(primaryManifest))?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
23
|
+
if (!match)
|
|
24
|
+
return bump;
|
|
25
|
+
const major = Number(match[1]), minor = Number(match[2]), patch = Number(match[3]);
|
|
26
|
+
if (bump === "major")
|
|
27
|
+
return `${major + 1}.0.0`;
|
|
28
|
+
if (bump === "minor")
|
|
29
|
+
return `${major}.${minor + 1}.0`;
|
|
30
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
31
|
+
}
|
|
32
|
+
const resolvedBumpArg = await resolveBumpArg(bumpArg);
|
|
33
|
+
async function git(args, cwd = p.projectPath()) {
|
|
34
|
+
return await execSync(["git", ...args], {
|
|
35
|
+
cwd,
|
|
36
|
+
stdin: "inherit"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function readVersion(file) {
|
|
40
|
+
const pkg = await readPackage(file);
|
|
41
|
+
if (!pkg?.version || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(pkg.version))
|
|
42
|
+
throw Error(`Invalid version in ${file}: ${pkg?.version ?? "<missing>"}`);
|
|
43
|
+
return pkg.version;
|
|
44
|
+
}
|
|
45
|
+
async function packageFilesFor(pattern, cwd) {
|
|
46
|
+
const glob = new Bun.Glob(pattern), files = [];
|
|
47
|
+
for await (const file of glob.scan({ cwd, absolute: !0, onlyFiles: !0 })) {
|
|
48
|
+
if (file.includes("/node_modules/") || file.includes("/dist/") || file.includes("/pantry/"))
|
|
49
|
+
continue;
|
|
50
|
+
files.push(`./${relative(bumpCwd, file)}`);
|
|
51
|
+
}
|
|
52
|
+
return files;
|
|
53
|
+
}
|
|
54
|
+
async function existingPackageFiles(files) {
|
|
55
|
+
const existing = [];
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
const absolutePath = join(bumpCwd, file);
|
|
58
|
+
if (await Bun.file(absolutePath).exists())
|
|
59
|
+
existing.push(file);
|
|
60
|
+
}
|
|
61
|
+
return existing;
|
|
62
|
+
}
|
|
63
|
+
async function frameworkBumpFiles() {
|
|
64
|
+
return Array.from(new Set([
|
|
65
|
+
...await packageFilesFor("package.json", bumpCwd),
|
|
66
|
+
...await packageFilesFor("*/package.json", bumpCwd),
|
|
67
|
+
...await packageFilesFor("*/*/package.json", bumpCwd),
|
|
68
|
+
...await existingPackageFiles([
|
|
69
|
+
"../package.json",
|
|
70
|
+
"../defaults/ide/vscode/package.json",
|
|
71
|
+
"../api/package.json",
|
|
72
|
+
"../cloud/package.json",
|
|
73
|
+
"../docs/package.json",
|
|
74
|
+
"../orm/package.json",
|
|
75
|
+
"../server/package.json"
|
|
76
|
+
]),
|
|
77
|
+
...await packageFilesFor("../libs/**/package.json", bumpCwd)
|
|
78
|
+
]));
|
|
79
|
+
}
|
|
80
|
+
const bumpFiles = isFrameworkRelease ? await frameworkBumpFiles() : ["./package.json"];
|
|
81
|
+
log.debug(`Release mode: ${isFrameworkRelease ? "framework monorepo" : "consumer app"} (${rootPkg?.name ?? "unknown"})`);
|
|
82
|
+
log.debug(`Bumping ${bumpFiles.length} package manifest(s) in ${bumpCwd}`);
|
|
83
|
+
await versionBump({
|
|
84
|
+
release: resolvedBumpArg ?? void 0,
|
|
85
|
+
files: bumpFiles,
|
|
86
|
+
cwd: bumpCwd,
|
|
87
|
+
recursive: !1,
|
|
88
|
+
commit: !1,
|
|
89
|
+
tag: !1,
|
|
90
|
+
push: !1,
|
|
91
|
+
changelog: !1,
|
|
92
|
+
noGitCheck: !0,
|
|
93
|
+
dryRun: isDryRun,
|
|
94
|
+
yes: Boolean(resolvedBumpArg),
|
|
95
|
+
verbose: isVerbose
|
|
96
|
+
});
|
|
97
|
+
const nextVersion = isDryRun && resolvedBumpArg && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(resolvedBumpArg) ? resolvedBumpArg : await readVersion(primaryManifest), latestTag = (await git(["describe", "--abbrev=0", "--tags"]).catch(() => "")).trim();
|
|
98
|
+
async function writeChangelog() {
|
|
99
|
+
const config = await loadLogsmithConfig({
|
|
100
|
+
dir: p.projectPath(),
|
|
101
|
+
from: latestTag || void 0,
|
|
102
|
+
to: "HEAD",
|
|
103
|
+
output: isDryRun ? !1 : "CHANGELOG.md",
|
|
104
|
+
theme: "github",
|
|
105
|
+
verbose: isVerbose
|
|
106
|
+
}), result = await generateChangelog(config);
|
|
107
|
+
if (isDryRun) {
|
|
108
|
+
log.info(result.content);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const changelogPath = p.projectPath("CHANGELOG.md");
|
|
112
|
+
if (!existsSync(changelogPath))
|
|
113
|
+
return;
|
|
114
|
+
let content = readFileSync(changelogPath, "utf-8");
|
|
115
|
+
const versionSeen = new RegExp(`\\bv?${nextVersion.replace(/\./g, "\\.")}\\b`);
|
|
116
|
+
if (/\/compare\/[^)\s]+\.\.\.HEAD\)/.test(content))
|
|
117
|
+
content = content.replace(/(\/compare\/[^)\s]+\.\.\.)HEAD(\))/, `$1v${nextVersion}$2`);
|
|
118
|
+
else if (!versionSeen.test(content.split(`
|
|
119
|
+
`).slice(0, 4).join(`
|
|
120
|
+
`)))
|
|
121
|
+
content = content.replace(/^(#\s.*\n+)?/, (match) => `${match ?? ""}## v${nextVersion}
|
|
6
122
|
|
|
7
|
-
`);
|
|
8
|
-
|
|
123
|
+
`);
|
|
124
|
+
writeFileSync(changelogPath, content);
|
|
125
|
+
}
|
|
126
|
+
await writeChangelog();
|
|
127
|
+
if (!isDryRun && isFrameworkRelease)
|
|
128
|
+
pinMetaCoreDeps(nextVersion);
|
|
129
|
+
function pinMetaCoreDeps(version) {
|
|
130
|
+
const metaPath = p.frameworkPath("core/package.json"), meta = JSON.parse(readFileSync(metaPath, "utf-8"));
|
|
131
|
+
let pinned = 0;
|
|
132
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
133
|
+
const deps = meta[field];
|
|
134
|
+
if (!deps)
|
|
135
|
+
continue;
|
|
136
|
+
for (const name of Object.keys(deps)) {
|
|
137
|
+
if (!name.startsWith("@stacksjs/"))
|
|
138
|
+
continue;
|
|
139
|
+
const dir = name.slice(10), localPkgPath = p.frameworkPath(`core/${dir}/package.json`);
|
|
140
|
+
if (!existsSync(localPkgPath))
|
|
141
|
+
continue;
|
|
142
|
+
if (JSON.parse(readFileSync(localPkgPath, "utf-8")).version !== version)
|
|
143
|
+
continue;
|
|
144
|
+
const next = `^${version}`;
|
|
145
|
+
if (deps[name] !== next) {
|
|
146
|
+
deps[name] = next;
|
|
147
|
+
pinned++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (pinned > 0) {
|
|
152
|
+
writeFileSync(metaPath, `${JSON.stringify(meta, null, 2)}
|
|
153
|
+
`);
|
|
154
|
+
log.debug(`Pinned ${pinned} lockstep core dep(s) in the stacks meta to ^${version}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!isDryRun) {
|
|
158
|
+
await git(["add", "--all"]);
|
|
159
|
+
await git(["commit", "-m", `chore: release v${nextVersion}`]);
|
|
160
|
+
await git(["tag", `v${nextVersion}`]);
|
|
161
|
+
await git(["push"]);
|
|
162
|
+
await git(["push", "origin", `v${nextVersion}`]);
|
|
163
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// @bun
|
package/dist/changelog.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import{
|
|
1
|
+
import { execSync, log, parseOptions } from "@stacksjs/cli";
|
|
2
|
+
import { projectPath } from "@stacksjs/path";
|
|
3
|
+
import { generateChangelog, loadLogsmithConfig } from "@stacksjs/logsmith";
|
|
4
|
+
const sanitizeRevision = (revision) => {
|
|
5
|
+
const value = revision.trim();
|
|
6
|
+
if (!/^[A-Za-z0-9._/-]+$/.test(value))
|
|
7
|
+
throw Error(`Invalid git revision: ${value}`);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
log.debug("Generating changelog");
|
|
11
|
+
const options = parseOptions(), fromRevision = sanitizeRevision(options?.from?.toString() ?? await execSync("git describe --abbrev=0 --tags HEAD^").catch(() => ""));
|
|
12
|
+
log.debug("FromRevision", fromRevision);
|
|
13
|
+
const toRevision = sanitizeRevision(options?.to?.toString() ?? "HEAD");
|
|
14
|
+
log.debug("ToRevision", toRevision);
|
|
15
|
+
log.debug("Changelog Options", options);
|
|
16
|
+
if (options?.version ?? options?.r)
|
|
17
|
+
log.debug("Ignoring --version: logsmith headers the section from the from\u2026to range");
|
|
18
|
+
const isDryRun = options?.dryRun === !0, config = await loadLogsmithConfig({
|
|
19
|
+
dir: projectPath(),
|
|
20
|
+
from: fromRevision || void 0,
|
|
21
|
+
to: toRevision,
|
|
22
|
+
output: isDryRun ? !1 : "CHANGELOG.md",
|
|
23
|
+
theme: "github",
|
|
24
|
+
verbose: options?.verbose === !0
|
|
25
|
+
}), result = await generateChangelog(config);
|
|
26
|
+
if (isDryRun && !options?.quiet)
|
|
27
|
+
log.info(result.content);
|
package/dist/check/ports.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { $ } from "bun";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { log } from "@stacksjs/logging";
|
|
4
|
+
import { findStacksProjects } from "@stacksjs/utils";
|
|
5
|
+
const projects = await findStacksProjects(void 0, { quiet: !0 });
|
|
6
|
+
log.debug("Running `buddy ports`");
|
|
7
|
+
log.debug(`Found ${projects.length} projects`);
|
|
8
|
+
log.debug("Projects:", projects);
|
|
9
|
+
for (const project of projects) {
|
|
10
|
+
log.debug("Running `buddy ports`");
|
|
11
|
+
log.debug("Project:", project);
|
|
12
|
+
$.cwd(project);
|
|
13
|
+
const ports = await $`./buddy ports --project ${project} --quiet`.text();
|
|
14
|
+
log.debug("ports", ports);
|
|
15
|
+
}
|
|
16
|
+
process.exit(0);
|
package/dist/clean.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import{
|
|
1
|
+
import { log } from "@stacksjs/logging";
|
|
2
|
+
import { cleanProject } from "@stacksjs/utils";
|
|
3
|
+
log.info("Running clean command...");
|
|
4
|
+
await cleanProject();
|
package/dist/commit.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { NpmScript } from "@stacksjs/enums";
|
|
2
|
+
import { log } from "@stacksjs/logging";
|
|
3
|
+
import { projectPath } from "@stacksjs/path";
|
|
4
|
+
import { runNpmScript } from "@stacksjs/utils";
|
|
5
|
+
export async function invoke(options) {
|
|
6
|
+
log.info("Committing...");
|
|
7
|
+
await runNpmScript(NpmScript.Commit, { cwd: projectPath(), ...options });
|
|
8
|
+
log.success("Committed");
|
|
9
|
+
}
|
|
10
|
+
export async function commit(options) {
|
|
11
|
+
return await invoke(options);
|
|
12
|
+
}
|
package/dist/copy-types.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { frameworkPath } from "@stacksjs/path";
|
|
2
|
+
import { copyFolder } from "@stacksjs/storage";
|
|
3
|
+
const destinations = [
|
|
4
|
+
[frameworkPath("dist/types/components"), frameworkPath("defaults/resources/components/vue/dist/types")],
|
|
5
|
+
[frameworkPath("dist/types/components"), frameworkPath("defaults/resources/components/web/dist/types")],
|
|
6
|
+
[frameworkPath("dist/types/functions"), frameworkPath("defaults/functions/dist/types")]
|
|
7
|
+
];
|
|
8
|
+
destinations.forEach(([src, dest]) => {
|
|
9
|
+
copyFolder(src, dest);
|
|
10
|
+
});
|
package/dist/database/seed.js
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { log } from "@stacksjs/cli";
|
|
3
|
+
import { seed } from "@stacksjs/database";
|
|
4
|
+
const argv = process.argv.slice(2), allowProtected = argv.includes("--allow-protected") || argv.includes("--allowProtected"), fresh = argv.includes("--fresh"), startTime = Date.now();
|
|
5
|
+
try {
|
|
6
|
+
const result = await seed({ verbose: !0, fresh, allowProtected }), duration = Date.now() - startTime;
|
|
7
|
+
if (result.failed > 0) {
|
|
8
|
+
log.warn("");
|
|
9
|
+
log.warn(`Seeding completed with ${result.failed} failure(s):`);
|
|
10
|
+
for (const r of result.results)
|
|
11
|
+
if (!r.success)
|
|
12
|
+
log.error(` - ${r.model}: ${r.error}`);
|
|
13
|
+
log.info("");
|
|
14
|
+
log.info("Note: Failed models may have schema mismatches or invalid factory functions.");
|
|
15
|
+
log.info("Tip: Run `./buddy migrate:fresh` to ensure schema is up to date.");
|
|
16
|
+
}
|
|
17
|
+
log.info("");
|
|
18
|
+
log.success(`Seeding completed in ${duration}ms`);
|
|
19
|
+
log.info(` Total models: ${result.total}`);
|
|
20
|
+
log.info(` Successful: ${result.successful}`);
|
|
21
|
+
log.info(` Failed: ${result.failed}`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
log.error("Seeding failed catastrophically:", err);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|