@acryldev/blends 1.7.15 → 1.7.16

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.
@@ -0,0 +1,107 @@
1
+ /**
2
+ * A product on Arch Linux (and Omarchy, which is Arch): a portable tarball beside the .deb, and a PKGBUILD that installs it. The tarball is the
3
+ * app folder electron-builder lays out (`linux-unpacked`) under `lib/`, a launcher, a .desktop file and the icon; the PKGBUILD downloads the tarball
4
+ * of the product's GitHub release and puts it in /opt/<name>, with the launcher on the PATH.
5
+ */
6
+
7
+ /** Arch's names for the CPUs the products are built for. */
8
+ export const ARCH_LINUX_CPU = { x64: 'x86_64', arm64: 'aarch64' }
9
+
10
+ /**
11
+ * What Electron needs on Arch: the libraries electron-builder's .deb depends on (libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils,
12
+ * libatspi2.0-0, libuuid1, libsecret-1-0, libasound2) under their Arch names, and git, which the app runs (it ships its own on macOS only).
13
+ */
14
+ export const ARCH_LINUX_DEPENDS = [
15
+ 'gtk3',
16
+ 'libnotify',
17
+ 'nss',
18
+ 'libxss',
19
+ 'libxtst',
20
+ 'xdg-utils',
21
+ 'at-spi2-core',
22
+ 'util-linux-libs',
23
+ 'libsecret',
24
+ 'alsa-lib',
25
+ 'git',
26
+ ]
27
+
28
+ /**
29
+ * The launcher at the top of the tarball. It finds the app beside itself through any symlink (the PKGBUILD links it into /usr/bin), lets Electron
30
+ * pick Wayland or X11 (Omarchy runs Hyprland on Wayland), and turns Chromium's sandbox off only where it cannot run: a chrome-sandbox that is not
31
+ * setuid root (an unpacked tarball) on a kernel that refuses unprivileged user namespaces (Ubuntu 24.04's AppArmor default). Arch allows them.
32
+ */
33
+ export function launcherScript(exe) {
34
+ return `#!/bin/sh
35
+ # ${exe}: starts the app in lib/ beside this file.
36
+ here=$(dirname -- "$(readlink -f -- "$0")")
37
+ set -- --ozone-platform-hint=auto "$@"
38
+ if [ ! -u "$here/lib/chrome-sandbox" ] && ! unshare -Ur true 2>/dev/null; then set -- --no-sandbox "$@"; fi
39
+ exec "$here/lib/${exe}" "$@"
40
+ `
41
+ }
42
+
43
+ /** The menu entry; Exec and Icon name the launcher and icon the PKGBUILD installs. */
44
+ export function desktopEntry({ exe, product, description }) {
45
+ return `[Desktop Entry]
46
+ Type=Application
47
+ Name=${product}
48
+ Comment=${description}
49
+ Exec=${exe} %U
50
+ Icon=${exe}
51
+ Terminal=false
52
+ Categories=Development;
53
+ StartupWMClass=${product}
54
+ `
55
+ }
56
+
57
+ /** The tarball a release carries for a CPU: `ACRYL-Control-Center-linux-x64.tar.gz`. */
58
+ export const tarballName = (fileName, arch) => `${fileName}-linux-${arch}.tar.gz`
59
+
60
+ /**
61
+ * The PKGBUILD for a release: one package for every CPU whose tarball is given (`tarballs: { x64: sha256, arm64: sha256 }`), each downloaded from
62
+ * the release's own assets. `version` is the release's (0.2.6 for the tag v0.2.6).
63
+ */
64
+ export function pkgbuildText({ exe, product, description, version, repo, fileName, tarballs }) {
65
+ if (!/^\d+\.\d+\.\d+$/u.test(version))
66
+ throw new Error(`pkgbuild: ${version} is not a release version (like 0.2.6)`)
67
+ if (!/^[\w.-]+\/[\w.-]+$/u.test(repo))
68
+ throw new Error(`pkgbuild: ${repo} is not a GitHub repository (owner/name)`)
69
+ const cpus = Object.keys(tarballs).filter((arch) => ARCH_LINUX_CPU[arch] !== undefined)
70
+ if (cpus.length === 0)
71
+ throw new Error('pkgbuild: no Linux tarball (x64 or arm64) to install from')
72
+ const quote = (text) => `'${text.replaceAll("'", '')}'`
73
+ const perCpu = cpus.flatMap((arch) => {
74
+ const cpu = ARCH_LINUX_CPU[arch]
75
+ const url = `https://github.com/${repo}/releases/download/v${version}/${tarballName(fileName, arch)}`
76
+ return [
77
+ `source_${cpu}=("${exe}-${version}-${cpu}.tar.gz::${url}")`,
78
+ `sha256sums_${cpu}=('${tarballs[arch]}')`,
79
+ ]
80
+ })
81
+ return `# ${product} for Arch Linux and Omarchy: makepkg -si installs the release's tarball in /opt/${exe}.
82
+ # Maintainer: ACRYL Blends <build@acryldev.dev>
83
+ pkgname=${exe}-bin
84
+ pkgver=${version}
85
+ pkgrel=1
86
+ pkgdesc=${quote(description)}
87
+ arch=(${cpus.map((arch) => `'${ARCH_LINUX_CPU[arch]}'`).join(' ')})
88
+ url='https://github.com/${repo}'
89
+ license=('MIT')
90
+ depends=(${ARCH_LINUX_DEPENDS.map((name) => `'${name}'`).join(' ')})
91
+ provides=('${exe}')
92
+ conflicts=('${exe}')
93
+ options=('!strip' '!debug')
94
+ ${perCpu.join('\n')}
95
+
96
+ package() {
97
+ install -d "$pkgdir/opt/${exe}" "$pkgdir/usr/bin"
98
+ cp -a "$srcdir/${exe}/." "$pkgdir/opt/${exe}/"
99
+ # Chromium's sandbox helper must be setuid root, as the .deb installs it.
100
+ chmod 4755 "$pkgdir/opt/${exe}/lib/chrome-sandbox"
101
+ ln -s "/opt/${exe}/${exe}" "$pkgdir/usr/bin/${exe}"
102
+ install -Dm644 "$srcdir/${exe}/${exe}.desktop" "$pkgdir/usr/share/applications/${exe}.desktop"
103
+ install -Dm644 "$srcdir/${exe}/${exe}.png" "$pkgdir/usr/share/pixmaps/${exe}.png"
104
+ if [ -f "$srcdir/${exe}/LICENSE" ]; then install -Dm644 "$srcdir/${exe}/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"; fi
105
+ }
106
+ `
107
+ }
@@ -31,6 +31,7 @@ import {
31
31
  import { tmpdir } from 'node:os'
32
32
  import { basename, dirname, join, resolve } from 'node:path'
33
33
  import { fileURLToPath, pathToFileURL } from 'node:url'
34
+ import { desktopEntry, launcherScript, tarballName } from './lib/arch-linux.mjs'
34
35
  import { createSource, repositoryOnlyIn } from './lib/create-source.mjs'
35
36
 
36
37
  const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
@@ -450,6 +451,8 @@ const DESCRIPTION =
450
451
  : `${PRODUCT}, an ACRYL Blends app (${from}), in the frame: change it from the chat.`
451
452
  const FILE_NAME =
452
453
  from === undefined ? 'ACRYL-Blends-Blank' : PRODUCT.replace(/[^A-Za-z0-9]+/gu, '-')
454
+ /** The program's name on Linux: acryl-control-center. */
455
+ const EXE = FILE_NAME.toLowerCase()
453
456
  // Seal the bundle ad hoc, after the builder has laid it out and before the DMG is made. With no signing step the main program keeps Electron's linker
454
457
  // signature (identifier `Electron`, no sealed resources, Info.plist not bound), so the bundle was not sealed and `codesign --verify --deep --strict` failed.
455
458
  // An ad hoc seal makes every file of the bundle part of the signature: an app that writes into its own bundle shows at once. No hardened runtime: the
@@ -514,6 +517,8 @@ manifest.build = {
514
517
  category: 'Development',
515
518
  icon: appIcon,
516
519
  maintainer: 'ACRYL Blends <build@acryldev.dev>',
520
+ // One name for the program on every Linux: the .deb's, the tarball's launcher and the PKGBUILD's (acryl-control-center).
521
+ executableName: EXE,
517
522
  },
518
523
  ...(platform === 'mac' ? { afterPack: join(work, 'seal-bundle.cjs') } : {}),
519
524
  }
@@ -695,4 +700,27 @@ for (const file of readdirSync(out))
695
700
  if (file.endsWith(EXTENSION)) rmSync(join(out, file), { force: true })
696
701
  const target = join(out, `${FILE_NAME}-${platform}-${arch}${EXTENSION}`)
697
702
  cpSync(join(app, 'dist', produced[0]), target)
703
+ // 7. On Linux also a portable tarball (Arch Linux, Omarchy, any distribution without dpkg): the app folder the builder laid out for the .deb, under
704
+ // lib/, with a launcher, a menu entry and the icon (lib/arch-linux.mjs). `acrylblends pkgbuild` makes the PKGBUILD that installs it.
705
+ if (platform === 'linux') {
706
+ const unpacked = readdirSync(join(app, 'dist')).find((name) => /^linux.*-unpacked$/u.test(name))
707
+ if (unpacked === undefined)
708
+ throw new Error('electron-builder left no linux-unpacked folder for the tarball')
709
+ const portable = join(work, 'portable', EXE)
710
+ rmSync(join(work, 'portable'), { recursive: true, force: true })
711
+ mkdirSync(portable, { recursive: true })
712
+ execFileSync('cp', ['-a', join(app, 'dist', unpacked), join(portable, 'lib')])
713
+ writeFileSync(join(portable, EXE), launcherScript(EXE), { mode: 0o755 })
714
+ writeFileSync(
715
+ join(portable, `${EXE}.desktop`),
716
+ desktopEntry({ exe: EXE, product: PRODUCT, description: DESCRIPTION }),
717
+ )
718
+ cpSync(appIcon, join(portable, `${EXE}.png`))
719
+ // The app's licence, which the PKGBUILD installs where Arch looks for it (/usr/share/licenses).
720
+ if (existsSync(join(app, 'LICENSE'))) cpSync(join(app, 'LICENSE'), join(portable, 'LICENSE'))
721
+ const tarball = join(out, tarballName(FILE_NAME, arch))
722
+ rmSync(tarball, { force: true })
723
+ execFileSync('tar', ['-czf', tarball, '-C', join(work, 'portable'), EXE])
724
+ log(`portable: ${tarball} (${String(Math.round(statSync(tarball).size / 1024 / 1024))} MB)`)
725
+ }
698
726
  log(`done: ${target} (${String(Math.round(statSync(target).size / 1024 / 1024))} MB)`)
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `acrylblends pkgbuild --dir <release files> --product "Name" --version 0.2.6 --repo owner/name`: the PKGBUILD (Arch Linux, Omarchy) for a release,
4
+ * written into <dir> beside the Linux tarballs `acrylblends pack` made there; it installs from the release's own assets, so it goes up with them.
5
+ */
6
+ import { createHash } from 'node:crypto'
7
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
8
+ import { join, resolve } from 'node:path'
9
+ import { parseArgs } from 'node:util'
10
+ import { pkgbuildText, tarballName } from './lib/arch-linux.mjs'
11
+
12
+ const { values } = parseArgs({
13
+ options: {
14
+ dir: { type: 'string' },
15
+ product: { type: 'string' },
16
+ version: { type: 'string' },
17
+ repo: { type: 'string' },
18
+ },
19
+ })
20
+ for (const name of ['dir', 'product', 'version', 'repo'])
21
+ if (values[name] === undefined) {
22
+ console.error(
23
+ `pkgbuild: --${name} is missing (acrylblends pkgbuild --dir out --product "Name" --version 0.2.6 --repo owner/name)`,
24
+ )
25
+ process.exit(2)
26
+ }
27
+ const dir = resolve(values.dir)
28
+ const product = values.product
29
+ const fileName = product.replace(/[^A-Za-z0-9]+/gu, '-')
30
+ const tarballs = {}
31
+ for (const arch of ['x64', 'arm64']) {
32
+ const file = join(dir, tarballName(fileName, arch))
33
+ if (existsSync(file))
34
+ tarballs[arch] = createHash('sha256').update(readFileSync(file)).digest('hex')
35
+ }
36
+ const text = pkgbuildText({
37
+ exe: fileName.toLowerCase(),
38
+ product,
39
+ description: `${product}, an ACRYL Blends app`,
40
+ version: values.version.replace(/^v/u, ''),
41
+ repo: values.repo,
42
+ fileName,
43
+ tarballs,
44
+ })
45
+ writeFileSync(join(dir, 'PKGBUILD'), text)
46
+ console.log(`pkgbuild: ${join(dir, 'PKGBUILD')} for ${Object.keys(tarballs).join(', ')}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acryldev/blends",
3
- "version": "1.7.15",
3
+ "version": "1.7.16",
4
4
  "description": "The Acryl web framework (import { Acryl } from \"acrylblends\") and the acrylblends command that scaffolds Cordis apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,8 +27,8 @@ import {
27
27
  type Visibility,
28
28
  withId,
29
29
  withLicense,
30
- withVersion,
31
30
  withPlacement,
31
+ withVersion,
32
32
  withVisibility,
33
33
  } from '@acryldev/app-persistence'
34
34
 
@@ -294,7 +294,8 @@ function writeListing(
294
294
  // The release this share tags: when planListing moved past an existing tag, the app carries the new version in both files.
295
295
  const version = listing.tag.replace(/^v/u, '')
296
296
  const bumped = typeof pkg.version === 'string' && pkg.version !== version
297
- if (bumped || (pkg.version === undefined && identity.version !== version)) text = withVersion(text, version)
297
+ if (bumped || (pkg.version === undefined && identity.version !== version))
298
+ text = withVersion(text, version)
298
299
  if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
299
300
  const before = Array.isArray(pkg.keywords)
300
301
  ? pkg.keywords.filter((word): word is string => typeof word === 'string')