@stacksjs/actions 0.70.232 → 0.70.235

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.
@@ -4,7 +4,7 @@ import { basename, join } from "node:path";
4
4
  import process from "node:process";
5
5
  import { log, runCommand } from "@stacksjs/cli";
6
6
  import { corePath, projectPath, storagePath } from "@stacksjs/path";
7
- import { assertDesktopReleaseChannel, resolveCraftBinary, resolveDesktopLauncher } from "@stacksjs/desktop";
7
+ import { assertDesktopReleaseChannel, resolveCraftBinary, resolveDesktopLauncher } from "@stacksjs/desktop-build";
8
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
9
  if (!appUrl)
10
10
  throw Error("Desktop builds require APP_URL or DESKTOP_URL so the native app knows which Stacks application to open");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,84 @@
1
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import process from "node:process";
5
+ import { log, runCommand } from "@stacksjs/cli";
6
+ import { projectPath, publicPath, resourcesPath, storagePath } from "@stacksjs/path";
7
+ if (process.platform !== "darwin")
8
+ throw Error("DMG packaging only runs on macOS");
9
+ const desktopDist = storagePath("framework/desktop-dist"), manifestPath = join(desktopDist, "desktop.json");
10
+ if (!existsSync(manifestPath))
11
+ throw Error("Run `buddy build:desktop` before packaging a DMG");
12
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8")), appName = process.env.DESKTOP_APP_NAME || manifest.title || process.env.APP_NAME || "Stacks", bundleId = process.env.DESKTOP_BUNDLE_ID || `sh.stacks.${appName.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`, version = process.env.DESKTOP_APP_VERSION || "0.0.0", signingIdentity = process.env.DESKTOP_SIGNING_IDENTITY, outputDir = storagePath("framework/desktop-dmg");
13
+ if (existsSync(outputDir))
14
+ rmSync(outputDir, { recursive: !0 });
15
+ mkdirSync(outputDir, { recursive: !0 });
16
+ const staging = mkdtempSync(join(tmpdir(), "stacks-dmg-")), scratch = mkdtempSync(join(tmpdir(), "stacks-dmg-work-")), appDir = join(staging, `${appName}.app`), macosDir = join(appDir, "Contents/MacOS"), resourcesDir = join(appDir, "Contents/Resources");
17
+ mkdirSync(macosDir, { recursive: !0 });
18
+ mkdirSync(resourcesDir, { recursive: !0 });
19
+ const launcherName = "stacks-desktop";
20
+ for (const file of [launcherName, "craft-runtime", "desktop.json"])
21
+ await runCommand(["cp", join(desktopDist, file), join(macosDir, file)], { cwd: projectPath() });
22
+ async function buildIcon() {
23
+ const source = [
24
+ resourcesPath("assets/images/app-icon.png"),
25
+ publicPath("images/app-icon.png"),
26
+ publicPath("apple-touch-icon.png")
27
+ ].find((candidate) => existsSync(candidate));
28
+ if (!source)
29
+ return;
30
+ const iconset = join(scratch, "icon.iconset");
31
+ mkdirSync(iconset, { recursive: !0 });
32
+ for (const size of [16, 32, 128, 256, 512]) {
33
+ await runCommand(["sips", "-z", String(size), String(size), source, "--out", join(iconset, `icon_${size}x${size}.png`)], { cwd: scratch, silent: !0 });
34
+ await runCommand(["sips", "-z", String(size * 2), String(size * 2), source, "--out", join(iconset, `icon_${size}x${size}@2x.png`)], { cwd: scratch, silent: !0 });
35
+ }
36
+ const icns = join(resourcesDir, "AppIcon.icns");
37
+ if ((await runCommand(["iconutil", "-c", "icns", iconset, "-o", icns], { cwd: scratch })).isErr || !existsSync(icns))
38
+ return;
39
+ return "AppIcon";
40
+ }
41
+ const iconFile = await buildIcon();
42
+ writeFileSync(join(appDir, "Contents/Info.plist"), `<?xml version="1.0" encoding="UTF-8"?>
43
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
44
+ <plist version="1.0">
45
+ <dict>
46
+ <key>CFBundleName</key><string>${appName}</string>
47
+ <key>CFBundleDisplayName</key><string>${appName}</string>
48
+ <key>CFBundleIdentifier</key><string>${bundleId}</string>
49
+ <key>CFBundleVersion</key><string>${version}</string>
50
+ <key>CFBundleShortVersionString</key><string>${version}</string>
51
+ <key>CFBundleExecutable</key><string>${launcherName}</string>
52
+ <key>CFBundlePackageType</key><string>APPL</string>
53
+ <key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
54
+ <key>LSMinimumSystemVersion</key><string>11.0</string>
55
+ <key>NSHighResolutionCapable</key><true/>
56
+ <!-- The window loads a remote URL, so the app has to be allowed to reach it. -->
57
+ <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict>${iconFile ? `
58
+ <key>CFBundleIconFile</key><string>${iconFile}</string>` : ""}
59
+ </dict>
60
+ </plist>
61
+ `);
62
+ if (signingIdentity)
63
+ for (const target of [join(macosDir, "craft-runtime"), join(macosDir, launcherName), appDir])
64
+ await runCommand(["codesign", "--force", "--options", "runtime", "--sign", signingIdentity, target], { cwd: staging });
65
+ symlinkSync("/Applications", join(staging, "Applications"));
66
+ const dmgPath = join(outputDir, `${appName}-${version}.dmg`), created = await runCommand([
67
+ "hdiutil",
68
+ "create",
69
+ "-volname",
70
+ appName,
71
+ "-srcfolder",
72
+ staging,
73
+ "-ov",
74
+ "-format",
75
+ "UDZO",
76
+ dmgPath
77
+ ], { cwd: staging });
78
+ if (created.isErr)
79
+ throw Error(`hdiutil failed to create ${dmgPath}`);
80
+ rmSync(staging, { recursive: !0, force: !0 });
81
+ rmSync(scratch, { recursive: !0, force: !0 });
82
+ log.success(`Built ${dmgPath}`);
83
+ if (!signingIdentity)
84
+ log.info("Unsigned build: Gatekeeper blocks the first launch. Right-click the app and choose Open, or set DESKTOP_SIGNING_IDENTITY and notarize before distributing.");
package/dist/build.js CHANGED
@@ -4,6 +4,7 @@ import { hasFunctions } from "@stacksjs/storage";
4
4
  import { runNpmScript } from "@stacksjs/utils";
5
5
  import { buildStxComponentLibrary } from "./build/component-library";
6
6
  import { generateTypes } from "./generate";
7
+ import { generateProjectImages } from "./generate/images";
7
8
  export async function invoke(options) {
8
9
  if (options.components)
9
10
  await componentLibraries(options);
@@ -16,6 +17,11 @@ export async function invoke(options) {
16
17
  else if (options.stacks)
17
18
  await stacks(options);
18
19
  await generateTypes();
20
+ try {
21
+ await generateProjectImages({ only: ["social", "app-icons"] });
22
+ } catch (error) {
23
+ log.warn(`[build] image generation skipped: ${error.message}`);
24
+ }
19
25
  }
20
26
  export async function build(options) {
21
27
  return await invoke(options);
package/dist/bump.js CHANGED
@@ -2,7 +2,7 @@ import { execSync, log, parseOptions } from "@stacksjs/cli";
2
2
  import { path as p } from "@stacksjs/path";
3
3
  import { versionBump } from "@stacksjs/bumpx";
4
4
  import { generateChangelog, loadLogsmithConfig } from "@stacksjs/logsmith";
5
- import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
5
+ import { existsSync, readdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { join, relative } from "node:path";
7
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
8
  if (rawBump && !bumpArg)
@@ -127,7 +127,7 @@ async function writeChangelog() {
127
127
  }
128
128
  await writeChangelog();
129
129
  if (!isDryRun && isFrameworkRelease)
130
- pinMetaCoreDeps(nextVersion);
130
+ pinLockstepDeps(nextVersion);
131
131
  if (!isDryRun && existsSync(p.projectPath("bun.lock"))) {
132
132
  const lockPath = p.projectPath("bun.lock"), previousLock = readFileSync(lockPath);
133
133
  unlinkSync(lockPath);
@@ -146,33 +146,47 @@ if (!isDryRun && existsSync(p.projectPath("bun.lock"))) {
146
146
  throw Error(`Release aborted: regenerating bun.lock produced lockfileVersion ${producedVersion ?? "unknown"}, but CI's Bun (1.3.x) requires v${expectedLockfileVersion}. You are releasing with a newer Bun (1.4.x writes v2). Re-run the release with Bun 1.3.x (e.g. via \`bunx bun@1.3.14\`) so CI can parse the lockfile.`);
147
147
  }
148
148
  }
149
- function pinMetaCoreDeps(version) {
150
- const metaPath = p.frameworkPath("core/package.json"), meta = JSON.parse(readFileSync(metaPath, "utf-8"));
151
- let pinned = 0;
152
- for (const field of ["dependencies", "devDependencies"]) {
153
- const deps = meta[field];
154
- if (!deps)
149
+ function lockstepPackages(version) {
150
+ const names = new Set;
151
+ for (const entry of readdirSync(p.frameworkPath("core"), { withFileTypes: !0 })) {
152
+ if (!entry.isDirectory())
155
153
  continue;
156
- for (const name of Object.keys(deps)) {
157
- if (!name.startsWith("@stacksjs/"))
158
- continue;
159
- const dir = name.slice(10), localPkgPath = p.frameworkPath(`core/${dir}/package.json`);
160
- if (!existsSync(localPkgPath))
161
- continue;
162
- if (JSON.parse(readFileSync(localPkgPath, "utf-8")).version !== version)
154
+ const manifest = p.frameworkPath(`core/${entry.name}/package.json`);
155
+ if (!existsSync(manifest))
156
+ continue;
157
+ const pkg = JSON.parse(readFileSync(manifest, "utf-8"));
158
+ if (pkg.name?.startsWith("@stacksjs/") && pkg.version === version)
159
+ names.add(pkg.name);
160
+ }
161
+ return names;
162
+ }
163
+ function pinLockstepDeps(version) {
164
+ const lockstep = lockstepPackages(version), next = `^${version}`, manifests = [
165
+ p.frameworkPath("core/package.json"),
166
+ ...readdirSync(p.frameworkPath("core"), { withFileTypes: !0 }).filter((entry) => entry.isDirectory()).map((entry) => p.frameworkPath(`core/${entry.name}/package.json`)).filter((path) => existsSync(path))
167
+ ];
168
+ let pinned = 0;
169
+ for (const manifestPath of manifests) {
170
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
171
+ let changed = !1;
172
+ for (const field of ["dependencies", "devDependencies"]) {
173
+ const deps = manifest[field];
174
+ if (!deps)
163
175
  continue;
164
- const next = `^${version}`;
165
- if (deps[name] !== next) {
176
+ for (const name of Object.keys(deps)) {
177
+ if (!lockstep.has(name) || deps[name].startsWith("workspace:") || deps[name] === next)
178
+ continue;
166
179
  deps[name] = next;
180
+ changed = !0;
167
181
  pinned++;
168
182
  }
169
183
  }
170
- }
171
- if (pinned > 0) {
172
- writeFileSync(metaPath, `${JSON.stringify(meta, null, 2)}
184
+ if (changed)
185
+ writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
173
186
  `);
174
- log.debug(`Pinned ${pinned} lockstep core dep(s) in the stacks meta to ^${version}`);
175
187
  }
188
+ if (pinned > 0)
189
+ log.debug(`Pinned ${pinned} lockstep core dep(s) to ^${version}`);
176
190
  }
177
191
  if (!isDryRun) {
178
192
  await git(["add", "--all"]);
@@ -2,7 +2,7 @@ import { homedir, networkInterfaces } from "node:os";
2
2
  import { basename, join } from "node:path";
3
3
  import process from "node:process";
4
4
  import { bold, cyan, dim, green } from "@stacksjs/cli";
5
- import { openDevWindow } from "@stacksjs/desktop";
5
+ import { openDevWindow } from "@stacksjs/desktop-build";
6
6
  import { projectPath, storagePath } from "@stacksjs/path";
7
7
  import { findStacksProjects } from "@stacksjs/utils";
8
8
  import { findAvailablePort, waitForServer } from "./dashboard-utils";
@@ -0,0 +1,15 @@
1
+ import type { ImageTarget } from '@stacksjs/image';
2
+ export declare function generateProjectImages(options?: GenerateImagesActionOptions): Promise<void>;
3
+ /**
4
+ * Build the imagery a project declares in `config/images.ts`.
5
+ *
6
+ * Social cards, App Store screenshots and app icons are all downstream of
7
+ * things that change often — a headline, a feature, a logo — and none of them
8
+ * fail loudly when they fall behind. Regenerating them as a build step is the
9
+ * only way they stay true, which is why this is an action and not a snippet in
10
+ * a README.
11
+ */
12
+ export declare interface GenerateImagesActionOptions {
13
+ only?: ImageTarget[]
14
+ verbose?: boolean
15
+ }
@@ -0,0 +1,26 @@
1
+ import { awaitConfig } from "@stacksjs/config";
2
+ import { log } from "@stacksjs/logging";
3
+ import { projectPath } from "@stacksjs/path";
4
+ export async function generateProjectImages(options = {}) {
5
+ const images = (await awaitConfig()).images;
6
+ if (!images || !images.social?.enabled && !images.appStore?.enabled && !images.appIcons?.enabled) {
7
+ log.debug("[generate:images] nothing declared in config/images.ts \u2014 skipping");
8
+ return;
9
+ }
10
+ const { countGeneratedImages, generateImages } = await import("@stacksjs/image"), result = await generateImages(images, { only: options.only, root: projectPath() }), counts = countGeneratedImages(result);
11
+ if (options.verbose) {
12
+ for (const card of result.social)
13
+ log.info(`[generate:images] ${card.path} \u2192 ${Object.values(card.files).join(", ")}`);
14
+ for (const [display, paths] of Object.entries(result.appStore))
15
+ log.info(`[generate:images] ${display} \u2192 ${paths.length} screenshot(s)`);
16
+ }
17
+ const summary = [
18
+ counts.social ? `${counts.social} social card(s)` : "",
19
+ counts.appStore ? `${counts.appStore} App Store screenshot(s)` : "",
20
+ counts.appIcons ? `${counts.appIcons} icon(s)` : ""
21
+ ].filter(Boolean).join(", ");
22
+ if (summary)
23
+ log.success(`Generated ${summary}`);
24
+ else
25
+ log.info("[generate:images] nothing to generate");
26
+ }
@@ -1,4 +1,6 @@
1
+ import { generateProjectImages } from './images';
1
2
  import type { GeneratorOptions } from '@stacksjs/types';
3
+ export type { GenerateImagesActionOptions } from './images';
2
4
  // import { files } from '@stacksjs/storage'
3
5
  export declare function invoke(options?: GeneratorOptions): Promise<void>;
4
6
  export declare function generate(options: GeneratorOptions): Promise<void>;
@@ -42,3 +44,4 @@ export declare function generateSeeder(): Promise<void>;
42
44
  */
43
45
  export declare function generateCoreSymlink(): Promise<void>;
44
46
  export declare function generateOpenApiSpec(): Promise<void>;
47
+ export { generateProjectImages } from './images';
@@ -8,6 +8,8 @@ import { ExitCode } from "@stacksjs/types";
8
8
  import { runNpmScript } from "@stacksjs/utils";
9
9
  import { runAction } from "../helpers";
10
10
  import { generateVsCodeCustomData as genVsCodeCustomData } from "../helpers/vscode-custom-data";
11
+ import { generateProjectImages } from "./images";
12
+ export { generateProjectImages } from "./images";
11
13
  export async function invoke(options) {
12
14
  if (options?.types)
13
15
  await generateTypes(options);
@@ -25,6 +27,8 @@ export async function invoke(options) {
25
27
  await generateCoreSymlink();
26
28
  else if (options?.openApiSpec)
27
29
  await generateOpenApiSpec();
30
+ else if (options?.images)
31
+ await generateProjectImages({ verbose: options?.verbose });
28
32
  }
29
33
  export function generate(options) {
30
34
  return invoke(options);
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.232",
5
+ "version": "0.70.235",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -30,21 +30,18 @@
30
30
  "exports": {
31
31
  ".": {
32
32
  "types": "./dist/index.d.ts",
33
- "development": "./src/index.ts",
34
33
  "bun": "./dist/index.js",
35
34
  "import": "./dist/index.js",
36
35
  "default": "./dist/index.js"
37
36
  },
38
37
  "./run-action": {
39
38
  "types": "./dist/run-action.d.ts",
40
- "development": "./src/run-action.ts",
41
39
  "bun": "./dist/run-action.js",
42
40
  "import": "./dist/run-action.js",
43
41
  "default": "./dist/run-action.js"
44
42
  },
45
43
  "./*": {
46
44
  "types": "./dist/*.d.ts",
47
- "development": "./src/*.ts",
48
45
  "bun": "./dist/*.js",
49
46
  "import": "./dist/*.js",
50
47
  "default": "./dist/*.js"
@@ -62,32 +59,33 @@
62
59
  "prepublishOnly": "bun run build"
63
60
  },
64
61
  "dependencies": {
65
- "@stacksjs/config": "0.70.232",
62
+ "@stacksjs/config": "0.70.235",
66
63
  "@stacksjs/bumpx": "^0.2.6",
67
64
  "@stacksjs/bunpress": "^0.1.18",
68
65
  "@stacksjs/logsmith": "^0.2.3",
69
- "@stacksjs/registry": "0.70.232",
66
+ "@stacksjs/registry": "0.70.235",
70
67
  "@stacksjs/stx": "^0.2.148",
71
68
  "@stacksjs/ts-cloud": "^0.7.92",
72
69
  "@stacksjs/ts-md": "^0.1.1"
73
70
  },
74
71
  "devDependencies": {
75
- "@stacksjs/api": "0.70.232",
76
- "@stacksjs/cli": "0.70.232",
77
- "@stacksjs/database": "0.70.232",
72
+ "@stacksjs/api": "0.70.235",
73
+ "@stacksjs/cli": "0.70.235",
74
+ "@stacksjs/database": "0.70.235",
78
75
  "@stacksjs/tlsx": "^0.13.2",
79
76
  "better-dx": "^0.2.17",
80
- "@stacksjs/dns": "0.70.232",
81
- "@stacksjs/enums": "0.70.232",
82
- "@stacksjs/env": "0.70.232",
83
- "@stacksjs/error-handling": "0.70.232",
84
- "@stacksjs/logging": "0.70.232",
85
- "@stacksjs/path": "0.70.232",
86
- "@stacksjs/security": "0.70.232",
87
- "@stacksjs/storage": "0.70.232",
88
- "@stacksjs/strings": "0.70.232",
89
- "@stacksjs/utils": "0.70.232",
90
- "@stacksjs/validation": "0.70.232"
77
+ "@stacksjs/dns": "0.70.235",
78
+ "@stacksjs/enums": "0.70.235",
79
+ "@stacksjs/env": "0.70.235",
80
+ "@stacksjs/error-handling": "0.70.235",
81
+ "@stacksjs/image": "0.70.235",
82
+ "@stacksjs/logging": "0.70.235",
83
+ "@stacksjs/path": "0.70.235",
84
+ "@stacksjs/security": "0.70.235",
85
+ "@stacksjs/storage": "0.70.235",
86
+ "@stacksjs/strings": "0.70.235",
87
+ "@stacksjs/utils": "0.70.235",
88
+ "@stacksjs/validation": "0.70.235"
91
89
  },
92
90
  "peerDependencies": {
93
91
  "pickier": "^0.1.35"