@stacksjs/actions 0.70.160 → 0.70.162
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/blog.js +1 -1
- package/dist/build/desktop.js +58 -4
- package/dist/build/views.js +11 -6
- package/dist/build.d.ts +1 -1
- package/dist/build.js +2 -2
- 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 +10 -4
- package/dist/stacks.d.ts +1 -1
- package/dist/stacks.js +208 -157
- package/dist/templates.js +11 -8
- package/dist/test/feature.js +2 -11
- package/dist/test/index.js +2 -11
- package/dist/test/runner.d.ts +1 -0
- package/dist/test/runner.js +30 -0
- package/dist/test/unit.js +2 -11
- package/dist/upgrade/packages.d.ts +18 -0
- package/dist/upgrade/packages.js +49 -8
- package/package.json +20 -19
package/README.md
CHANGED
package/dist/blog.js
CHANGED
|
@@ -208,7 +208,7 @@ async function blogConfig(bp, fm) {
|
|
|
208
208
|
title: fm.title || cfg.title,
|
|
209
209
|
description: fm.description || cfg.description,
|
|
210
210
|
docsDir: CONTENT_DIR,
|
|
211
|
-
theme: "
|
|
211
|
+
theme: "bun",
|
|
212
212
|
markdown: { ...bp.defaultConfig.markdown, css: `${baseCss}
|
|
213
213
|
${themeCss}` },
|
|
214
214
|
themeConfig: {
|
package/dist/build/desktop.js
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, join } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { log, runCommand } from "@stacksjs/cli";
|
|
6
|
+
import { corePath, projectPath, storagePath } from "@stacksjs/path";
|
|
7
|
+
import { assertDesktopReleaseChannel, resolveCraftBinary } from "@stacksjs/desktop";
|
|
8
|
+
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, releaseChannel = process.env.DESKTOP_RELEASE_CHANNEL === "stable" ? "stable" : "experimental", support = assertDesktopReleaseChannel(releaseChannel);
|
|
9
|
+
if (!appUrl)
|
|
10
|
+
throw Error("Desktop builds require APP_URL or DESKTOP_URL so the native app knows which Stacks application to open");
|
|
11
|
+
const url = new URL(/^https?:\/\//.test(appUrl) ? appUrl : `https://${appUrl}`), craftBinary = resolveCraftBinary();
|
|
12
|
+
if (basename(craftBinary) === "craft" && !existsSync(craftBinary))
|
|
13
|
+
throw Error("Build Craft first in ~/Code/Tools/craft, or set CRAFT_BIN to the native Craft binary");
|
|
14
|
+
if (existsSync(outputDir))
|
|
15
|
+
rmSync(outputDir, { recursive: !0 });
|
|
16
|
+
mkdirSync(outputDir, { recursive: !0 });
|
|
17
|
+
await runCommand("bun run build", { cwd: corePath("desktop") });
|
|
18
|
+
await runCommand(`bun build --compile ${JSON.stringify(corePath("desktop/src/launcher.ts"))} --outfile ${JSON.stringify(join(outputDir, launcherName))}`, {
|
|
19
|
+
cwd: projectPath()
|
|
5
20
|
});
|
|
21
|
+
copyFileSync(craftBinary, join(outputDir, runtimeName));
|
|
22
|
+
if (process.platform !== "win32") {
|
|
23
|
+
chmodSync(join(outputDir, launcherName), 493);
|
|
24
|
+
chmodSync(join(outputDir, runtimeName), 493);
|
|
25
|
+
}
|
|
26
|
+
writeFileSync(join(outputDir, "desktop.json"), `${JSON.stringify({
|
|
27
|
+
url: url.toString().replace(/\/$/, ""),
|
|
28
|
+
title: process.env.APP_NAME || "Stacks",
|
|
29
|
+
width: 1400,
|
|
30
|
+
height: 900,
|
|
31
|
+
darkMode: !1,
|
|
32
|
+
systemTray: !0,
|
|
33
|
+
hideDockIcon: !1,
|
|
34
|
+
releaseChannel,
|
|
35
|
+
platform: process.platform,
|
|
36
|
+
architecture: process.arch
|
|
37
|
+
}, null, 2)}
|
|
38
|
+
`);
|
|
39
|
+
const gitResult = Bun.spawnSync(["git", "rev-parse", "HEAD"], { cwd: projectPath() });
|
|
40
|
+
if (gitResult.exitCode !== 0)
|
|
41
|
+
throw Error("Desktop builds require an exact Git source revision");
|
|
42
|
+
const sourceRevision = gitResult.stdout.toString().trim(), artifacts = [launcherName, runtimeName, "desktop.json"].map((name) => {
|
|
43
|
+
const contents = readFileSync(join(outputDir, name));
|
|
44
|
+
return { name, bytes: contents.byteLength, sha256: createHash("sha256").update(contents).digest("hex") };
|
|
45
|
+
});
|
|
46
|
+
writeFileSync(join(outputDir, "provenance.json"), `${JSON.stringify({
|
|
47
|
+
schemaVersion: "1.0.0",
|
|
48
|
+
sourceRepository: "https://github.com/stacksjs/stacks",
|
|
49
|
+
sourceRevision,
|
|
50
|
+
builtWith: { bun: Bun.version, craftSha256: artifacts.find((artifact) => artifact.name === runtimeName)?.sha256 },
|
|
51
|
+
target: { platform: process.platform, architecture: process.arch, status: support.status, osVersions: support.osVersions },
|
|
52
|
+
releaseChannel,
|
|
53
|
+
artifacts
|
|
54
|
+
}, null, 2)}
|
|
55
|
+
`);
|
|
56
|
+
writeFileSync(join(outputDir, "checksums.sha256"), `${artifacts.map((artifact) => `${artifact.sha256} ${artifact.name}`).join(`
|
|
57
|
+
`)}
|
|
58
|
+
`);
|
|
59
|
+
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/build.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { BuildOptions } from '@stacksjs/types';
|
|
|
2
2
|
export declare function invoke(options: BuildOptions): Promise<void>;
|
|
3
3
|
export declare function build(options: BuildOptions): Promise<void>;
|
|
4
4
|
export declare function componentLibraries(options: BuildOptions): Promise<void>;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function stxComponentLibrary(options: BuildOptions): Promise<void>;
|
|
6
6
|
export declare function webComponentLibrary(options: BuildOptions): Promise<void>;
|
|
7
7
|
export declare function docs(options: BuildOptions): Promise<void>;
|
|
8
8
|
export declare function stacks(options: BuildOptions): Promise<void>;
|
package/dist/build.js
CHANGED
|
@@ -21,10 +21,10 @@ export async function build(options) {
|
|
|
21
21
|
}
|
|
22
22
|
export async function componentLibraries(options) {
|
|
23
23
|
await runNpmScript(NpmScript.GenerateEntries, options);
|
|
24
|
-
await
|
|
24
|
+
await stxComponentLibrary(options);
|
|
25
25
|
await webComponentLibrary(options);
|
|
26
26
|
}
|
|
27
|
-
export async function
|
|
27
|
+
export async function stxComponentLibrary(options) {
|
|
28
28
|
if (hasComponents()) {
|
|
29
29
|
log.info("Building your component library...");
|
|
30
30
|
await runNpmScript(NpmScript.BuildComponents, options);
|
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 {
|
|
@@ -262,10 +268,10 @@ export async function makeStack(options) {
|
|
|
262
268
|
log.info("");
|
|
263
269
|
log.info(` cd ${name}`);
|
|
264
270
|
log.info(" # Add your models, actions, views, etc.");
|
|
265
|
-
log.info(" #
|
|
271
|
+
log.info(" # Push the repository, then submit its GitHub source to the Stacks registry.");
|
|
266
272
|
log.info("");
|
|
267
273
|
log.info(" Users install it with:");
|
|
268
|
-
log.info(` buddy
|
|
274
|
+
log.info(` buddy add ${shortName}`);
|
|
269
275
|
} catch (error) {
|
|
270
276
|
log.error("There was an error creating your stack", error);
|
|
271
277
|
process.exit(ExitCode.FatalError);
|
package/dist/stacks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { StackInstallOptions, StackListEntry, StackManifestEntry, StackUninstallOptions } from '@stacksjs/types';
|
|
2
2
|
export declare function installStack(options: StackInstallOptions): Promise<StackManifestEntry | null>;
|
|
3
3
|
export declare function uninstallStack(options: StackUninstallOptions): Promise<boolean>;
|
|
4
|
-
export declare function listStacks(): Promise<StackListEntry[]>;
|
|
4
|
+
export declare function listStacks(project?: string): Promise<StackListEntry[]>;
|