@stacksjs/actions 0.70.160 → 0.70.161
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/README.md +1 -1
- package/dist/build/desktop.js +34 -4
- package/dist/build/views.js +11 -6
- package/dist/copy-types.js +0 -1
- package/dist/dev/components.js +1 -1
- package/dist/dev/dashboard.js +8 -8
- package/dist/dev/desktop.d.ts +1 -1
- package/dist/dev/desktop.js +1 -5
- package/dist/dev/system-tray.js +171 -4
- package/dist/examples.js +2 -2
- package/dist/helpers/lib-entries.js +3 -3
- package/dist/helpers/vscode-custom-data.d.ts +1 -0
- package/dist/helpers/vscode-custom-data.js +32 -2
- package/dist/make.d.ts +2 -0
- package/dist/make.js +8 -2
- package/dist/upgrade/packages.d.ts +7 -0
- package/dist/upgrade/packages.js +32 -1
- package/package.json +18 -18
package/README.md
CHANGED
package/dist/build/desktop.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { log, runCommand } from "@stacksjs/cli";
|
|
5
|
+
import { corePath, projectPath, storagePath } from "@stacksjs/path";
|
|
6
|
+
import { resolveCraftBinary } from "@stacksjs/desktop";
|
|
7
|
+
const outputDir = storagePath("framework/desktop-dist"), launcherName = process.platform === "win32" ? "stacks-desktop.exe" : "stacks-desktop", runtimeName = process.platform === "win32" ? "craft-runtime.exe" : "craft-runtime", appUrl = process.env.DESKTOP_URL || process.env.APP_URL;
|
|
8
|
+
if (!appUrl)
|
|
9
|
+
throw Error("Desktop builds require APP_URL or DESKTOP_URL so the native app knows which Stacks application to open");
|
|
10
|
+
const url = new URL(/^https?:\/\//.test(appUrl) ? appUrl : `https://${appUrl}`), craftBinary = resolveCraftBinary();
|
|
11
|
+
if (basename(craftBinary) === "craft" && !existsSync(craftBinary))
|
|
12
|
+
throw Error("Build Craft first in ~/Code/Tools/craft, or set CRAFT_BIN to the native Craft binary");
|
|
13
|
+
if (existsSync(outputDir))
|
|
14
|
+
rmSync(outputDir, { recursive: !0 });
|
|
15
|
+
mkdirSync(outputDir, { recursive: !0 });
|
|
16
|
+
await runCommand("bun run build", { cwd: corePath("desktop") });
|
|
17
|
+
await runCommand(`bun build --compile ${JSON.stringify(corePath("desktop/src/launcher.ts"))} --outfile ${JSON.stringify(join(outputDir, launcherName))}`, {
|
|
18
|
+
cwd: projectPath()
|
|
5
19
|
});
|
|
20
|
+
copyFileSync(craftBinary, join(outputDir, runtimeName));
|
|
21
|
+
if (process.platform !== "win32") {
|
|
22
|
+
chmodSync(join(outputDir, launcherName), 493);
|
|
23
|
+
chmodSync(join(outputDir, runtimeName), 493);
|
|
24
|
+
}
|
|
25
|
+
writeFileSync(join(outputDir, "desktop.json"), `${JSON.stringify({
|
|
26
|
+
url: url.toString().replace(/\/$/, ""),
|
|
27
|
+
title: process.env.APP_NAME || "Stacks",
|
|
28
|
+
width: 1400,
|
|
29
|
+
height: 900,
|
|
30
|
+
darkMode: !1,
|
|
31
|
+
systemTray: !0,
|
|
32
|
+
hideDockIcon: !1
|
|
33
|
+
}, null, 2)}
|
|
34
|
+
`);
|
|
35
|
+
log.success(`Built Craft desktop application in ${outputDir}`);
|
package/dist/build/views.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { runCommand } from "@stacksjs/cli";
|
|
2
|
-
import {
|
|
2
|
+
import { projectPath } from "@stacksjs/path";
|
|
3
3
|
const projectBuild = projectPath("build.ts");
|
|
4
|
-
if (await Bun.file(projectBuild).exists())
|
|
5
|
-
await runCommand("bun build.ts", {
|
|
4
|
+
if (await Bun.file(projectBuild).exists()) {
|
|
5
|
+
const result = await runCommand("bun build.ts", {
|
|
6
6
|
cwd: projectPath()
|
|
7
7
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (result.isErr)
|
|
9
|
+
throw result.error;
|
|
10
|
+
} else {
|
|
11
|
+
const result = await runCommand("bunx --bun @stacksjs/stx build --pages resources/views --out dist", {
|
|
12
|
+
cwd: projectPath()
|
|
11
13
|
});
|
|
14
|
+
if (result.isErr)
|
|
15
|
+
throw result.error;
|
|
16
|
+
}
|
package/dist/copy-types.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { frameworkPath } from "@stacksjs/path";
|
|
2
2
|
import { copyFolder } from "@stacksjs/storage";
|
|
3
3
|
const destinations = [
|
|
4
|
-
[frameworkPath("dist/types/components"), frameworkPath("defaults/resources/components/vue/dist/types")],
|
|
5
4
|
[frameworkPath("dist/types/components"), frameworkPath("defaults/resources/components/web/dist/types")],
|
|
6
5
|
[frameworkPath("dist/types/functions"), frameworkPath("defaults/functions/dist/types")]
|
|
7
6
|
];
|
package/dist/dev/components.js
CHANGED
package/dist/dev/dashboard.js
CHANGED
|
@@ -316,14 +316,14 @@ const dashboardToggles = await loadDashboardToggles(), manifestPath = storagePat
|
|
|
316
316
|
writeFileSync(manifestPath, JSON.stringify(manifestPayload, null, 2));
|
|
317
317
|
const serverReady = await waitForServer(dashboardPort);
|
|
318
318
|
restoreConsole();
|
|
319
|
-
let proxyStarted =
|
|
320
|
-
|
|
321
|
-
proxyStarted =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
});
|
|
326
|
-
const dashboardHttpsUrl = dashboardDomain ? `https://${dashboardDomain}` : null, dashboardLocalUrl = `http://localhost:${dashboardPort}`, initialUrl =
|
|
319
|
+
let proxyStarted = Boolean(process.env.STACKS_PROXY_MANAGED);
|
|
320
|
+
if (!proxyStarted)
|
|
321
|
+
proxyStarted = await startReverseProxy().catch((err) => {
|
|
322
|
+
if (verbose)
|
|
323
|
+
console.warn("[Dashboard] Reverse proxy failed:", err);
|
|
324
|
+
return !1;
|
|
325
|
+
});
|
|
326
|
+
const dashboardHttpsUrl = dashboardDomain ? `https://${dashboardDomain}` : null, dashboardLocalUrl = `http://localhost:${dashboardPort}`, initialUrl = dashboardHttpsUrl && proxyStarted ? `${dashboardHttpsUrl}/` : `${dashboardLocalUrl}/`, elapsedMs = (Bun.nanoseconds() - startTime) / 1e6;
|
|
327
327
|
console.log();
|
|
328
328
|
console.log(` ${bold(cyan("stacks dashboard"))}`);
|
|
329
329
|
console.log();
|
package/dist/dev/desktop.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/dev/desktop.js
CHANGED
package/dist/dev/system-tray.js
CHANGED
|
@@ -1,5 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { homedir, networkInterfaces } from "node:os";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { bold, cyan, dim, green } from "@stacksjs/cli";
|
|
5
|
+
import { openDevWindow } from "@stacksjs/desktop";
|
|
6
|
+
import { projectPath, storagePath } from "@stacksjs/path";
|
|
7
|
+
import { findStacksProjects } from "@stacksjs/utils";
|
|
8
|
+
import { findAvailablePort, waitForServer } from "./dashboard-utils";
|
|
9
|
+
const preferredPort = Number(process.env.PORT_SYSTEM_TRAY) || 3009, port = await findAvailablePort(preferredPort), trayViews = storagePath("framework/defaults/views/system-tray"), appUrl = process.env.APP_URL || "stacks.test", domain = appUrl.replace(/^https?:\/\//, "").replace(/\/$/, ""), hasPrettyDomain = !domain.includes("localhost:") && domain !== "localhost", trayDomain = hasPrettyDomain ? `tray.${domain}` : null, localUrl = `http://localhost:${port}`;
|
|
10
|
+
let cachedProjects;
|
|
11
|
+
async function discoverProjects(refresh = !1) {
|
|
12
|
+
if (cachedProjects && !refresh)
|
|
13
|
+
return cachedProjects;
|
|
14
|
+
const discovered = await findStacksProjects(join(homedir(), "Code"), { quiet: !0 }).catch(() => []), candidates = [...new Set([projectPath(), ...discovered])];
|
|
15
|
+
cachedProjects = (await Promise.all(candidates.map(async (project) => ({
|
|
16
|
+
project,
|
|
17
|
+
valid: await Bun.file(join(project, "buddy")).exists()
|
|
18
|
+
})))).filter((check) => check.valid).map((check) => check.project).sort((a, b) => basename(a).localeCompare(basename(b)));
|
|
19
|
+
return cachedProjects;
|
|
20
|
+
}
|
|
21
|
+
async function runBuddy(project, args) {
|
|
22
|
+
const child = Bun.spawn([join(project, "buddy"), ...args, "--no-interaction"], {
|
|
23
|
+
cwd: project,
|
|
24
|
+
stdout: "pipe",
|
|
25
|
+
stderr: "pipe"
|
|
26
|
+
}), [stdout, stderr, exitCode] = await Promise.all([
|
|
27
|
+
new Response(child.stdout).text(),
|
|
28
|
+
new Response(child.stderr).text(),
|
|
29
|
+
child.exited
|
|
30
|
+
]);
|
|
31
|
+
return { output: [stdout, stderr].filter(Boolean).join(`
|
|
32
|
+
`).trim(), exitCode };
|
|
33
|
+
}
|
|
34
|
+
function openPath(path) {
|
|
35
|
+
const command = process.platform === "darwin" ? ["open", path] : process.platform === "win32" ? ["cmd", "/c", "start", "", path] : ["xdg-open", path];
|
|
36
|
+
Bun.spawn(command, { stdout: "ignore", stderr: "ignore" }).unref();
|
|
37
|
+
}
|
|
38
|
+
function openTerminal(project) {
|
|
39
|
+
const command = process.platform === "darwin" ? ["open", "-a", "Terminal", project] : process.platform === "win32" ? ["cmd", "/c", "start", "cmd", "/K", `cd /d ${project}`] : ["x-terminal-emulator", "--working-directory", project];
|
|
40
|
+
Bun.spawn(command, { stdout: "ignore", stderr: "ignore" }).unref();
|
|
41
|
+
}
|
|
42
|
+
function localIpAddress() {
|
|
43
|
+
for (const addresses of Object.values(networkInterfaces()))
|
|
44
|
+
for (const address of addresses || [])
|
|
45
|
+
if (address.family === "IPv4" && !address.internal)
|
|
46
|
+
return address.address;
|
|
47
|
+
return "127.0.0.1";
|
|
48
|
+
}
|
|
49
|
+
function dashboardUrl(path = "") {
|
|
50
|
+
return `${hasPrettyDomain ? `https://dashboard.${domain}` : `http://localhost:${Number(process.env.PORT_ADMIN) || 3002}`}${path}`;
|
|
51
|
+
}
|
|
52
|
+
async function handleAction(input) {
|
|
53
|
+
const projects = await discoverProjects(), project = input.project || projectPath();
|
|
54
|
+
if (!projects.includes(project))
|
|
55
|
+
return Response.json({ ok: !1, error: "Unknown Stacks project" }, { status: 400 });
|
|
56
|
+
switch (input.action) {
|
|
57
|
+
case "refresh":
|
|
58
|
+
return Response.json({ ok: !0, projects: await discoverProjects(!0) });
|
|
59
|
+
case "open-terminal":
|
|
60
|
+
openTerminal(project);
|
|
61
|
+
return Response.json({ ok: !0, message: `Opened Terminal in ${basename(project)}` });
|
|
62
|
+
case "env-check": {
|
|
63
|
+
const result = await runBuddy(project, ["doctor"]);
|
|
64
|
+
return Response.json({ ok: result.exitCode === 0, ...result });
|
|
65
|
+
}
|
|
66
|
+
case "settings":
|
|
67
|
+
openPath(dashboardUrl("/settings"));
|
|
68
|
+
return Response.json({ ok: !0, message: "Opened dashboard settings" });
|
|
69
|
+
case "check-updates": {
|
|
70
|
+
const result = await runBuddy(project, ["outdated"]);
|
|
71
|
+
return Response.json({ ok: result.exitCode === 0, ...result });
|
|
72
|
+
}
|
|
73
|
+
case "copy-ip":
|
|
74
|
+
return Response.json({ ok: !0, value: localIpAddress(), message: "IP address ready to copy" });
|
|
75
|
+
case "open-dashboard":
|
|
76
|
+
openPath(dashboardUrl());
|
|
77
|
+
return Response.json({ ok: !0, message: "Opened dashboard" });
|
|
78
|
+
case "buddy-commands": {
|
|
79
|
+
const result = await runBuddy(project, ["list"]);
|
|
80
|
+
return Response.json({ ok: result.exitCode === 0, ...result });
|
|
81
|
+
}
|
|
82
|
+
case "deploy": {
|
|
83
|
+
if (!input.confirmed)
|
|
84
|
+
return Response.json({ ok: !1, confirmationRequired: !0, error: "Deployment confirmation required" }, { status: 409 });
|
|
85
|
+
Bun.spawn([join(project, "buddy"), "deploy", "--no-interaction"], {
|
|
86
|
+
cwd: project,
|
|
87
|
+
stdout: "inherit",
|
|
88
|
+
stderr: "inherit"
|
|
89
|
+
}).unref();
|
|
90
|
+
return Response.json({ ok: !0, message: `Deployment started for ${basename(project)}` });
|
|
91
|
+
}
|
|
92
|
+
case "deploy-logs":
|
|
93
|
+
openPath(join(project, "storage/logs"));
|
|
94
|
+
return Response.json({ ok: !0, message: "Opened deployment logs" });
|
|
95
|
+
case "site-logs":
|
|
96
|
+
openPath(join(project, "storage/logs"));
|
|
97
|
+
return Response.json({ ok: !0, message: "Opened site logs" });
|
|
98
|
+
case "error-logs":
|
|
99
|
+
openPath(join(project, "storage/logs"));
|
|
100
|
+
return Response.json({ ok: !0, message: "Opened error logs" });
|
|
101
|
+
case "edit-env":
|
|
102
|
+
openPath(join(project, ".env"));
|
|
103
|
+
return Response.json({ ok: !0, message: "Opened .env" });
|
|
104
|
+
case "edit-dns":
|
|
105
|
+
openPath(join(project, "config/dns.ts"));
|
|
106
|
+
return Response.json({ ok: !0, message: "Opened DNS configuration" });
|
|
107
|
+
case "edit-email":
|
|
108
|
+
openPath(join(project, "config/email.ts"));
|
|
109
|
+
return Response.json({ ok: !0, message: "Opened email configuration" });
|
|
110
|
+
case "ask-buddy":
|
|
111
|
+
openPath(dashboardUrl("/buddy"));
|
|
112
|
+
return Response.json({ ok: !0, message: "Opened Ask Buddy" });
|
|
113
|
+
default:
|
|
114
|
+
return Response.json({ ok: !1, error: "Unknown tray action" }, { status: 400 });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const { serve } = await import("bun-plugin-stx/serve"), serverPromise = serve({
|
|
118
|
+
patterns: [trayViews],
|
|
119
|
+
port,
|
|
120
|
+
componentsDir: storagePath("framework/defaults/resources/components"),
|
|
121
|
+
quiet: !0,
|
|
122
|
+
auth: !1,
|
|
123
|
+
routes: {
|
|
124
|
+
"/api/tray/projects": async () => Response.json({ ok: !0, projects: await discoverProjects() }),
|
|
125
|
+
"/api/tray/action": async (request) => {
|
|
126
|
+
if (request.method !== "POST")
|
|
127
|
+
return Response.json({ ok: !1, error: "Method not allowed" }, { status: 405 });
|
|
128
|
+
return handleAction(await request.json());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
5
131
|
});
|
|
132
|
+
serverPromise.catch((error) => {
|
|
133
|
+
console.error(`System tray server failed: ${error.message}`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
});
|
|
136
|
+
let proxyStarted = !1;
|
|
137
|
+
if (trayDomain && !process.env.STACKS_PROXY_MANAGED)
|
|
138
|
+
try {
|
|
139
|
+
const { startProxies } = await import("@stacksjs/rpx");
|
|
140
|
+
await startProxies({
|
|
141
|
+
proxies: [{ from: `localhost:${port}`, to: trayDomain, cleanUrls: !1 }],
|
|
142
|
+
https: { basePath: `${process.env.HOME}/.stacks/ssl`, validityDays: 825 },
|
|
143
|
+
regenerateUntrustedCerts: !1
|
|
144
|
+
});
|
|
145
|
+
proxyStarted = !0;
|
|
146
|
+
} catch {
|
|
147
|
+
proxyStarted = !1;
|
|
148
|
+
}
|
|
149
|
+
await waitForServer(port, 2000);
|
|
150
|
+
const url = trayDomain && proxyStarted ? `https://${trayDomain}` : localUrl;
|
|
151
|
+
console.log();
|
|
152
|
+
console.log(` ${bold(cyan("stacks tray"))}`);
|
|
153
|
+
console.log();
|
|
154
|
+
console.log(` ${green("\u279C")} ${bold("Local")}: ${cyan(url)}`);
|
|
155
|
+
if (trayDomain)
|
|
156
|
+
console.log(` ${dim("\u279C")} ${dim("Origin")}: ${dim(localUrl)}`);
|
|
157
|
+
console.log();
|
|
158
|
+
await openDevWindow(port, {
|
|
159
|
+
url,
|
|
160
|
+
title: "Stacks",
|
|
161
|
+
width: 440,
|
|
162
|
+
height: 680,
|
|
163
|
+
systemTray: !0,
|
|
164
|
+
hideDockIcon: !0,
|
|
165
|
+
hotReload: !0
|
|
166
|
+
});
|
|
167
|
+
const stop = () => {
|
|
168
|
+
process.exit(0);
|
|
169
|
+
};
|
|
170
|
+
process.on("SIGINT", stop);
|
|
171
|
+
process.on("SIGTERM", stop);
|
|
172
|
+
await new Promise(() => {});
|
package/dist/examples.js
CHANGED
|
@@ -5,7 +5,7 @@ import { hasComponents } from "@stacksjs/storage";
|
|
|
5
5
|
import { ExitCode } from "@stacksjs/types";
|
|
6
6
|
import { runNpmScript } from "@stacksjs/utils";
|
|
7
7
|
export async function invoke(options) {
|
|
8
|
-
if (options.components
|
|
8
|
+
if (options.components)
|
|
9
9
|
await componentExample(options);
|
|
10
10
|
else if (options.webComponents || options.elements)
|
|
11
11
|
await webComponentExample(options);
|
|
@@ -17,7 +17,7 @@ export async function examples(options) {
|
|
|
17
17
|
}
|
|
18
18
|
export async function componentExample(options) {
|
|
19
19
|
if (hasComponents()) {
|
|
20
|
-
await runNpmScript(NpmScript.
|
|
20
|
+
await runNpmScript(NpmScript.Example, options);
|
|
21
21
|
log.success("Your component library was built successfully");
|
|
22
22
|
} else
|
|
23
23
|
log.info("No components found.");
|
|
@@ -53,18 +53,18 @@ export function generateEntryPointData(type) {
|
|
|
53
53
|
`);
|
|
54
54
|
}
|
|
55
55
|
arr = determineResetPreset();
|
|
56
|
-
const imports = [...arr, "import { defineCustomElement } from '
|
|
56
|
+
const imports = [...arr, "import { defineCustomElement } from '@stacksjs/stx'"], declarations = [], definitions = [];
|
|
57
57
|
if (!library.webComponents?.tags) {
|
|
58
58
|
log.error(Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
|
|
59
59
|
process.exit(ExitCode.FatalError);
|
|
60
60
|
}
|
|
61
61
|
for (const component of library.webComponents.tags.map((tag) => tag.name))
|
|
62
62
|
if (Array.isArray(component)) {
|
|
63
|
-
imports.push(`import ${component[1]} from '${componentsPath(component[0])}.
|
|
63
|
+
imports.push(`import ${component[1]} from '${componentsPath(component[0])}.stx'`);
|
|
64
64
|
declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
|
|
65
65
|
definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
|
|
66
66
|
} else {
|
|
67
|
-
imports.push(`import ${component} from '${componentsPath(component)}.
|
|
67
|
+
imports.push(`import ${component} from '${componentsPath(component)}.stx'`);
|
|
68
68
|
declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
|
|
69
69
|
definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
|
|
70
70
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { library } from "@stacksjs/config";
|
|
2
2
|
import { err, ok } from "@stacksjs/error-handling";
|
|
3
3
|
import { log } from "@stacksjs/logging";
|
|
4
|
-
import { customElementsDataPath } from "@stacksjs/path";
|
|
4
|
+
import { customElementsDataPath, frameworkPath } from "@stacksjs/path";
|
|
5
5
|
import { writeTextFile } from "@stacksjs/storage";
|
|
6
6
|
function generateComponentInfoData() {
|
|
7
7
|
return `{
|
|
@@ -26,5 +26,35 @@ export async function generateVsCodeCustomData() {
|
|
|
26
26
|
}
|
|
27
27
|
export async function generateWebTypes() {
|
|
28
28
|
log.info("Generating web-types.json...");
|
|
29
|
-
|
|
29
|
+
await writeTextFile({
|
|
30
|
+
path: frameworkPath("core/web-types.json"),
|
|
31
|
+
data: generateWebTypesData()
|
|
32
|
+
});
|
|
33
|
+
log.success("Generated web-types.json for IDEs.");
|
|
34
|
+
}
|
|
35
|
+
export function generateWebTypesData() {
|
|
36
|
+
const tags = (library.webComponents?.tags ?? []).map((tag) => {
|
|
37
|
+
const sourceName = Array.isArray(tag.name) ? tag.name[0] : tag.name;
|
|
38
|
+
return {
|
|
39
|
+
name: Array.isArray(tag.name) ? tag.name[1] : tag.name,
|
|
40
|
+
description: tag.description ?? "",
|
|
41
|
+
attributes: tag.attributes ?? [],
|
|
42
|
+
source: {
|
|
43
|
+
module: `../../defaults/resources/components/${sourceName}.stx`,
|
|
44
|
+
symbol: "default"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return `${JSON.stringify({
|
|
49
|
+
framework: "stx",
|
|
50
|
+
name: library.name,
|
|
51
|
+
contributions: {
|
|
52
|
+
html: {
|
|
53
|
+
"description-markup": "markdown",
|
|
54
|
+
"types-syntax": "typescript",
|
|
55
|
+
tags
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, null, 2)}
|
|
59
|
+
`;
|
|
30
60
|
}
|
package/dist/make.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function makeAction(options: MakeOptions): Promise<void>;
|
|
|
13
13
|
export declare function makeComponent(options: MakeOptions): Promise<void>;
|
|
14
14
|
export declare function createAction(options: MakeOptions): Promise<void>;
|
|
15
15
|
export declare function createComponent(options: MakeOptions): Promise<void>;
|
|
16
|
+
export declare function componentFileName(name: string): string;
|
|
16
17
|
export declare function makeDatabase(options: MakeOptions): void;
|
|
17
18
|
export declare function createDatabase(options: MakeOptions): void;
|
|
18
19
|
export declare function factory(options: MakeOptions): Promise<void>;
|
|
@@ -39,6 +40,7 @@ export declare function createMail(options: MakeOptions & { force?: boolean }):
|
|
|
39
40
|
export declare function makeMail(options: MakeOptions & { force?: boolean }): Promise<void>;
|
|
40
41
|
export declare function makePage(options: MakeOptions): Promise<void>;
|
|
41
42
|
export declare function createPage(options: MakeOptions): Promise<void>;
|
|
43
|
+
export declare function pageFileName(name: string): string;
|
|
42
44
|
export declare function makeFunction(options: MakeOptions): Promise<void>;
|
|
43
45
|
export declare function createFunction(options: MakeOptions): Promise<void>;
|
|
44
46
|
export declare function makeLanguage(options: MakeOptions): Promise<void>;
|
package/dist/make.js
CHANGED
|
@@ -87,7 +87,10 @@ export async function createAction(options) {
|
|
|
87
87
|
}
|
|
88
88
|
export async function createComponent(options) {
|
|
89
89
|
const name = options.name;
|
|
90
|
-
await createFileWithTemplate(p.userComponentsPath(
|
|
90
|
+
await createFileWithTemplate(p.userComponentsPath(componentFileName(name)), "component", name);
|
|
91
|
+
}
|
|
92
|
+
export function componentFileName(name) {
|
|
93
|
+
return `${name}.stx`;
|
|
91
94
|
}
|
|
92
95
|
export function makeDatabase(options) {
|
|
93
96
|
try {
|
|
@@ -211,7 +214,10 @@ export async function makePage(options) {
|
|
|
211
214
|
}
|
|
212
215
|
export async function createPage(options) {
|
|
213
216
|
const name = options.name;
|
|
214
|
-
await createFileWithTemplate(p.userViewsPath(
|
|
217
|
+
await createFileWithTemplate(p.userViewsPath(pageFileName(name)), "page", name);
|
|
218
|
+
}
|
|
219
|
+
export function pageFileName(name) {
|
|
220
|
+
return `${name}.stx`;
|
|
215
221
|
}
|
|
216
222
|
export async function makeFunction(options) {
|
|
217
223
|
try {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function hasStacksDependency(pkg: PkgJson): boolean;
|
|
2
|
+
export declare function standalonePackageUpdateCommand(): string;
|
|
1
3
|
/**
|
|
2
4
|
* Upgrade a node_modules app to a published framework version. Called by the
|
|
3
5
|
* framework upgrade script when no vendored `storage/framework/core` exists.
|
|
@@ -12,3 +14,8 @@ export declare interface PackageUpgradeOptions {
|
|
|
12
14
|
dryRun?: boolean
|
|
13
15
|
noPostinstall?: boolean
|
|
14
16
|
}
|
|
17
|
+
declare interface PkgJson {
|
|
18
|
+
dependencies?: Record<string, string>
|
|
19
|
+
devDependencies?: Record<string, string>
|
|
20
|
+
[key: string]: unknown
|
|
21
|
+
}
|
package/dist/upgrade/packages.js
CHANGED
|
@@ -2,6 +2,34 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { runCommand } from "@stacksjs/cli";
|
|
5
|
+
export function hasStacksDependency(pkg) {
|
|
6
|
+
return Boolean(pkg.dependencies?.stacks || pkg.devDependencies?.stacks);
|
|
7
|
+
}
|
|
8
|
+
export function standalonePackageUpdateCommand() {
|
|
9
|
+
return "bun update";
|
|
10
|
+
}
|
|
11
|
+
async function updateStandalonePackage(projectRoot, options) {
|
|
12
|
+
console.log(`
|
|
13
|
+
Standalone package detected. No Stacks framework source is installed.`);
|
|
14
|
+
if (options.dryRun) {
|
|
15
|
+
console.log(" --dry-run: would refresh the package dependencies with `bun update`. No files were changed.\n");
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
if (options.noPostinstall) {
|
|
19
|
+
console.log(" --no-postinstall: skipping the dependency refresh. Run `bun update` when ready.\n");
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
console.log(` Refreshing declared dependencies...
|
|
23
|
+
`);
|
|
24
|
+
if ((await runCommand(standalonePackageUpdateCommand(), { cwd: projectRoot })).isErr) {
|
|
25
|
+
console.error("\n\u2717 The dependency refresh failed. Resolve the reported error and re-run `buddy update`.\n");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
console.log(`
|
|
29
|
+
\u2714 Standalone package dependencies are up to date.
|
|
30
|
+
`);
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
5
33
|
async function resolveTarget(options) {
|
|
6
34
|
const res = await fetch("https://registry.npmjs.org/stacks").catch(() => null);
|
|
7
35
|
if (!res || !res.ok)
|
|
@@ -45,7 +73,10 @@ export async function upgradeStacksPackages(projectRoot, options) {
|
|
|
45
73
|
console.error("No package.json found \u2014 nothing to upgrade.");
|
|
46
74
|
process.exit(1);
|
|
47
75
|
}
|
|
48
|
-
const raw = readFileSync(pkgPath, "utf-8"), pkg = JSON.parse(raw), current = pkg.dependencies?.stacks ?? pkg.devDependencies?.stacks
|
|
76
|
+
const raw = readFileSync(pkgPath, "utf-8"), pkg = JSON.parse(raw), current = pkg.dependencies?.stacks ?? pkg.devDependencies?.stacks;
|
|
77
|
+
if (!hasStacksDependency(pkg))
|
|
78
|
+
return updateStandalonePackage(projectRoot, options);
|
|
79
|
+
const { version: target, coreDeps } = await resolveTarget(options).catch((err) => {
|
|
49
80
|
console.error(`\u2717 ${err.message}`);
|
|
50
81
|
process.exit(1);
|
|
51
82
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.161",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -62,31 +62,31 @@
|
|
|
62
62
|
"prepublishOnly": "bun run build"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@stacksjs/config": "0.70.
|
|
65
|
+
"@stacksjs/config": "0.70.161",
|
|
66
66
|
"@stacksjs/bumpx": "^0.2.6",
|
|
67
|
-
"@stacksjs/bunpress": "^0.1.
|
|
67
|
+
"@stacksjs/bunpress": "^0.1.18",
|
|
68
68
|
"@stacksjs/logsmith": "^0.2.3",
|
|
69
69
|
"@stacksjs/ts-cloud": "^0.7.49",
|
|
70
70
|
"@stacksjs/ts-md": "^0.1.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@stacksjs/api": "0.70.
|
|
74
|
-
"@stacksjs/cli": "0.70.
|
|
75
|
-
"@stacksjs/config": "0.70.
|
|
76
|
-
"@stacksjs/database": "0.70.
|
|
73
|
+
"@stacksjs/api": "0.70.161",
|
|
74
|
+
"@stacksjs/cli": "0.70.161",
|
|
75
|
+
"@stacksjs/config": "0.70.161",
|
|
76
|
+
"@stacksjs/database": "0.70.161",
|
|
77
77
|
"@stacksjs/tlsx": "^0.13.2",
|
|
78
78
|
"better-dx": "^0.2.17",
|
|
79
|
-
"@stacksjs/dns": "0.70.
|
|
80
|
-
"@stacksjs/enums": "0.70.
|
|
81
|
-
"@stacksjs/env": "0.70.
|
|
82
|
-
"@stacksjs/error-handling": "0.70.
|
|
83
|
-
"@stacksjs/logging": "0.70.
|
|
84
|
-
"@stacksjs/path": "0.70.
|
|
85
|
-
"@stacksjs/security": "0.70.
|
|
86
|
-
"@stacksjs/storage": "0.70.
|
|
87
|
-
"@stacksjs/strings": "0.70.
|
|
88
|
-
"@stacksjs/utils": "0.70.
|
|
89
|
-
"@stacksjs/validation": "0.70.
|
|
79
|
+
"@stacksjs/dns": "0.70.161",
|
|
80
|
+
"@stacksjs/enums": "0.70.161",
|
|
81
|
+
"@stacksjs/env": "0.70.161",
|
|
82
|
+
"@stacksjs/error-handling": "0.70.161",
|
|
83
|
+
"@stacksjs/logging": "0.70.161",
|
|
84
|
+
"@stacksjs/path": "0.70.161",
|
|
85
|
+
"@stacksjs/security": "0.70.161",
|
|
86
|
+
"@stacksjs/storage": "0.70.161",
|
|
87
|
+
"@stacksjs/strings": "0.70.161",
|
|
88
|
+
"@stacksjs/utils": "0.70.161",
|
|
89
|
+
"@stacksjs/validation": "0.70.161"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"pickier": "^0.1.35"
|