@acryldev/blends 1.7.12 → 1.7.14
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/index.d.ts +4 -4
- package/dist/index.js +61 -17
- package/dist/index.js.map +1 -1
- package/pack/lib/create-source.mjs +13 -1
- package/pack/pack-blank-mac.mjs +6 -1
- package/package.json +1 -1
- package/plugins/desktop-shell/frame.ts +7 -2
- package/plugins/desktop-shell/inherited.ts +26 -0
- package/plugins/desktop-shell/main.ts +19 -1
- package/plugins/desktop-shell/menu.ts +32 -0
- package/plugins/desktop-shell/package.json +1 -1
- package/plugins/plugin-share/package.json +1 -1
- package/plugins/plugin-share/plugin.json +1 -1
- package/plugins/save/package.json +1 -1
- package/plugins/save/plugin.json +1 -1
- package/plugins/save/share.ts +31 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
|
-
import { resolve } from 'node:path'
|
|
2
|
+
import { join, resolve } from 'node:path'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The `--from` a packer hands to create: an existing folder as an absolute path, anything else (a registry id such as acrylblends.small-crm) as given.
|
|
@@ -10,3 +10,15 @@ export function createSource(from, cwd = process.cwd()) {
|
|
|
10
10
|
const folder = resolve(cwd, from)
|
|
11
11
|
return existsSync(folder) ? folder : from
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What a Blend's repository carries for itself, not for the app made from it: `.github/` (its release workflow). create copies a folder source whole,
|
|
16
|
+
* so the packer takes these out of the product's app and its first commit; left in, a fresh install showed the bundle's missing workflow as an unsaved
|
|
17
|
+
* deletion ("v2 · 1 unsaved").
|
|
18
|
+
*/
|
|
19
|
+
export const REPOSITORY_ONLY = ['.github']
|
|
20
|
+
|
|
21
|
+
/** The repository-only paths present in an app folder. */
|
|
22
|
+
export function repositoryOnlyIn(app) {
|
|
23
|
+
return REPOSITORY_ONLY.filter((path) => existsSync(join(app, path)))
|
|
24
|
+
}
|
package/pack/pack-blank-mac.mjs
CHANGED
|
@@ -31,7 +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 { createSource } from './lib/create-source.mjs'
|
|
34
|
+
import { createSource, repositoryOnlyIn } from './lib/create-source.mjs'
|
|
35
35
|
|
|
36
36
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
37
37
|
/**
|
|
@@ -623,6 +623,7 @@ execFileSync(
|
|
|
623
623
|
'--ignore-unmatch',
|
|
624
624
|
'--',
|
|
625
625
|
...program.map((path) => path.replace(/\/$/u, '')),
|
|
626
|
+
...repositoryOnlyIn(app),
|
|
626
627
|
],
|
|
627
628
|
{ cwd: app, stdio: 'inherit' },
|
|
628
629
|
)
|
|
@@ -645,6 +646,10 @@ execFileSync(
|
|
|
645
646
|
],
|
|
646
647
|
{ cwd: app, stdio: 'inherit' },
|
|
647
648
|
)
|
|
649
|
+
// The Blend repository's own files (its release workflow) are not the person's app: out of the folder and out of the first commit's tree.
|
|
650
|
+
const repositoryOnly = repositoryOnlyIn(app)
|
|
651
|
+
for (const path of repositoryOnly) rmSync(join(app, path), { recursive: true, force: true })
|
|
652
|
+
if (repositoryOnly.length > 0) log(`left out the repository's own ${repositoryOnly.join(', ')}`)
|
|
648
653
|
// The scaffold's repository travels as `template-git` (the packager drops `.git`), with that commit in it.
|
|
649
654
|
if (existsSync(join(app, '.git')))
|
|
650
655
|
rmSync(join(app, 'template-git'), { recursive: true, force: true })
|
package/package.json
CHANGED
|
@@ -7,8 +7,9 @@ import { type ChildProcess, spawn, spawnSync } from 'node:child_process'
|
|
|
7
7
|
import { existsSync, readFileSync } from 'node:fs'
|
|
8
8
|
import { connect } from 'node:net'
|
|
9
9
|
import { join, resolve } from 'node:path'
|
|
10
|
-
import { fileURLToPath
|
|
10
|
+
import { fileURLToPath } from 'node:url'
|
|
11
11
|
import { appDataHome, PROGRAM_ENV } from '@acryldev/instance'
|
|
12
|
+
import { withoutInheritedDescriptors } from './inherited.ts'
|
|
12
13
|
|
|
13
14
|
/** The launcher every frame app has; without it the app runs on its own server (made before the frame). */
|
|
14
15
|
export const HOST_SCRIPT = join('scripts', 'ide-host.mjs')
|
|
@@ -234,8 +235,12 @@ export function startFrameHost(
|
|
|
234
235
|
launch.runtime === undefined
|
|
235
236
|
? hostCommand(env, platform)
|
|
236
237
|
: { file: launch.runtime, args: packagedHostArgs(program, root), shell: false }
|
|
238
|
+
// Nothing of Electron's own descriptors (its DevTools port) goes on to the host (inherited.ts); a command that needs the Windows shell is left as it is.
|
|
239
|
+
const start = command.shell
|
|
240
|
+
? { program: command.file, args: command.args }
|
|
241
|
+
: withoutInheritedDescriptors(command.file, command.args, platform)
|
|
237
242
|
// The host leads its own process group on macOS and Linux, so a stop reaches npm, the host and every terminal it runs; Windows stops the tree with taskkill.
|
|
238
|
-
const child: ChildProcess = spawn(
|
|
243
|
+
const child: ChildProcess = spawn(start.program, [...start.args], {
|
|
239
244
|
cwd: root,
|
|
240
245
|
env: {
|
|
241
246
|
...env,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a child of the Electron main process inherits. On Linux Chromium opens its DevTools port (`--remote-debugging-port`), its sockets and its files without
|
|
3
|
+
* close-on-exec, and Node's spawn passes every such descriptor on: a started app's host kept the port bound after the app that was started with it had quit
|
|
4
|
+
* (found on Linux: a `sleep` started from Electron main held 20 descriptors, among them Chromium's sockets). macOS closes everything but the standard streams
|
|
5
|
+
* when it starts a process, and a Windows socket is not inherited, so only Linux needs this. The same text is in plugins/launcher-desktop/src/runner.ts (the
|
|
6
|
+
* two packages share no code); keep them equal.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync } from 'node:fs'
|
|
9
|
+
|
|
10
|
+
/** bash's `exec 12>&-` closes a descriptor of any number (dash accepts one digit only); the command then replaces bash, so the process id and group stay the child's own. */
|
|
11
|
+
const CLOSE_AND_RUN =
|
|
12
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: shell parameter expansion, not a JavaScript template
|
|
13
|
+
'for f in /proc/self/fd/*; do n=${f##*/}; if [ "$n" -gt 2 ]; then eval "exec $n>&-"; fi; done; exec "$@"'
|
|
14
|
+
|
|
15
|
+
export const BASH = '/bin/bash'
|
|
16
|
+
|
|
17
|
+
/** The program and arguments to spawn so the child holds no descriptor above 2: the command itself where that is already so, or where bash is not there. */
|
|
18
|
+
export function withoutInheritedDescriptors(
|
|
19
|
+
program: string,
|
|
20
|
+
args: readonly string[],
|
|
21
|
+
platform: NodeJS.Platform = process.platform,
|
|
22
|
+
hasBash: boolean = existsSync(BASH),
|
|
23
|
+
): { readonly program: string; readonly args: readonly string[] } {
|
|
24
|
+
if (platform !== 'linux' || !hasBash) return { program, args }
|
|
25
|
+
return { program: BASH, args: ['-c', CLOSE_AND_RUN, 'acryl-spawn', program, ...args] }
|
|
26
|
+
}
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
} from './frame.ts'
|
|
40
40
|
import { productGit, withGitFirst } from './git.ts'
|
|
41
41
|
import { appendHostLog, hostCrashed, hostRestarting, nextRestart } from './host-supervisor.ts'
|
|
42
|
-
import { hasSettings, settingsPlacement } from './menu.ts'
|
|
42
|
+
import { aboutPlacement, aboutText, hasSettings, settingsPlacement } from './menu.ts'
|
|
43
43
|
import { openProductApp, seedSource } from './product.ts'
|
|
44
44
|
import { createDesktopShutdown, installShutdownRequests } from './shutdown.ts'
|
|
45
45
|
import { offerUpdates } from './update-menu.ts'
|
|
@@ -472,6 +472,24 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
472
472
|
}
|
|
473
473
|
if (product?.releases !== undefined)
|
|
474
474
|
offerUpdates(product.releases, () => live()[0], join(userData, 'updates'))
|
|
475
|
+
// Windows and Linux: Help > About <name> shows the version (macOS has the About panel).
|
|
476
|
+
const helpMenu = Menu.getApplicationMenu()
|
|
477
|
+
const aboutAt = helpMenu === null ? undefined : aboutPlacement(helpMenu.items, process.platform)
|
|
478
|
+
if (helpMenu !== null && aboutAt !== undefined) {
|
|
479
|
+
helpMenu.items[aboutAt]?.submenu?.append(
|
|
480
|
+
new MenuItem({
|
|
481
|
+
label: `About ${app.getName()}`,
|
|
482
|
+
click: () => {
|
|
483
|
+
const about = aboutText(app.getName(), app.getVersion(), process.versions)
|
|
484
|
+
const owner = BrowserWindow.getFocusedWindow() ?? live()[0]
|
|
485
|
+
const options = { type: 'info' as const, buttons: ['OK'], ...about }
|
|
486
|
+
if (owner === undefined) void dialog.showMessageBox(options)
|
|
487
|
+
else void dialog.showMessageBox(owner, options)
|
|
488
|
+
},
|
|
489
|
+
}),
|
|
490
|
+
)
|
|
491
|
+
Menu.setApplicationMenu(helpMenu)
|
|
492
|
+
}
|
|
475
493
|
stopDoorShell = startDoorShell(chosen.root, { desktop, log: console.log })
|
|
476
494
|
|
|
477
495
|
if (appPage && storage !== undefined && product !== undefined) {
|
|
@@ -58,3 +58,35 @@ export function hasSettings(items: readonly MenuNode[]): boolean {
|
|
|
58
58
|
(item.submenu?.items !== undefined && hasSettings(item.submenu.items)),
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Windows and Linux have no application menu, so nothing there says which version runs (macOS has the About panel). Returns the index of the Help menu, where
|
|
64
|
+
* "About <name>" goes last, or nothing on macOS, in a menu with no Help, or in one that already has an About item.
|
|
65
|
+
*/
|
|
66
|
+
export function aboutPlacement(
|
|
67
|
+
items: readonly MenuNode[],
|
|
68
|
+
platform: NodeJS.Platform,
|
|
69
|
+
): number | undefined {
|
|
70
|
+
if (platform === 'darwin') return undefined
|
|
71
|
+
const help = items.findIndex((item) => item.role === 'help' || /^&?help$/iu.test(item.label))
|
|
72
|
+
if (help === -1 || items[help]?.submenu == null) return undefined
|
|
73
|
+
const entries = items[help].submenu.items
|
|
74
|
+
return entries.some((item) => item.role === 'about' || /^about\b/iu.test(item.label))
|
|
75
|
+
? undefined
|
|
76
|
+
: help
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** What the About dialog says: the product and its version first, then the runtime it runs on (what a bug report needs). */
|
|
80
|
+
export function aboutText(
|
|
81
|
+
name: string,
|
|
82
|
+
version: string,
|
|
83
|
+
versions: Readonly<Record<string, string | undefined>>,
|
|
84
|
+
): { readonly message: string; readonly detail: string } {
|
|
85
|
+
const runtime = (['electron', 'chrome', 'node'] as const)
|
|
86
|
+
.filter((key) => versions[key] !== undefined)
|
|
87
|
+
.map(
|
|
88
|
+
(key) =>
|
|
89
|
+
`${key === 'chrome' ? 'Chromium' : key === 'node' ? 'Node.js' : 'Electron'} ${versions[key]}`,
|
|
90
|
+
)
|
|
91
|
+
return { message: name, detail: [`Version ${version}`, ...runtime].join('\n') }
|
|
92
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acryldev/desktop-shell",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Run the app as a desktop app: an Electron window on the app's own server. `npm run desktop`; the app's code never imports electron.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acryldev/plugin-share",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Share plugins between people. Pull one someone released into the running app: fetched without running anything, checked by digest and for every OS, then installed live. Publish one, only as a plan a person confirmed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acryldev/save",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Save the app to its own git repository, and share it: a repository of its own on GitHub, created and pushed only after a person confirms the plan. Refuses a file that holds a secret, and a private app going to a public remote.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/plugins/save/plugin.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"provides": [],
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@deepseek-ai/cordis": "4.0.4",
|
|
9
|
-
"@acryldev/app-persistence": "0.1.
|
|
9
|
+
"@acryldev/app-persistence": "0.1.6"
|
|
10
10
|
},
|
|
11
11
|
"mount": "mount the plugin to give the agent a save_app tool; its scripts (npm run save, npm run share) are added to package.json with it",
|
|
12
12
|
"entries": {
|
package/plugins/save/share.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
type Visibility,
|
|
28
28
|
withId,
|
|
29
29
|
withLicense,
|
|
30
|
+
withVersion,
|
|
30
31
|
withPlacement,
|
|
31
32
|
withVisibility,
|
|
32
33
|
} from '@acryldev/app-persistence'
|
|
@@ -101,6 +102,8 @@ export interface SharePorts {
|
|
|
101
102
|
pending(): number
|
|
102
103
|
/** Label `owner/repo` for the Blends store and push the tag; false when the tag already existed (it is never moved). */
|
|
103
104
|
list(repository: string, tag: string): boolean
|
|
105
|
+
/** Whether release `tag` exists here: `none`, `current` (it is this commit), or `older` (versions were saved since). */
|
|
106
|
+
released(tag: string): 'none' | 'current' | 'older'
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
/** The person's own git and gh, in the app's folder. */
|
|
@@ -120,6 +123,12 @@ export function sharePorts(appRoot: string): SharePorts {
|
|
|
120
123
|
const result = run('git', ['status', '--porcelain'])
|
|
121
124
|
return result.status === 0 ? result.stdout.split('\n').filter(Boolean).length : 0
|
|
122
125
|
},
|
|
126
|
+
released: (tag) => {
|
|
127
|
+
const tagged = run('git', ['rev-parse', '-q', '--verify', `refs/tags/${tag}^{commit}`])
|
|
128
|
+
if (tagged.status !== 0) return 'none'
|
|
129
|
+
const head = run('git', ['rev-parse', '-q', '--verify', 'HEAD'])
|
|
130
|
+
return head.status === 0 && head.stdout.trim() === tagged.stdout.trim() ? 'current' : 'older'
|
|
131
|
+
},
|
|
123
132
|
list: (repository, tag) => {
|
|
124
133
|
const must = (command: string, args: readonly string[], what: string) => {
|
|
125
134
|
const result = run(command, args)
|
|
@@ -183,6 +192,12 @@ const packageOf = (appRoot: string): PackageJson | undefined => {
|
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
194
|
|
|
195
|
+
/** `1.2.0` -> `1.2.1`; a version that is not three numbers gets `.1` added, so it still moves on. */
|
|
196
|
+
export const nextPatch = (version: string): string => {
|
|
197
|
+
const parts = /^(\d+)\.(\d+)\.(\d+)$/u.exec(version)
|
|
198
|
+
return parts === null ? `${version}.1` : `${parts[1]}.${parts[2]}.${Number(parts[3]) + 1}`
|
|
199
|
+
}
|
|
200
|
+
|
|
186
201
|
/** The store listing a share asked for, as the person will read it, or why it cannot be listed. */
|
|
187
202
|
function planListing(
|
|
188
203
|
appRoot: string,
|
|
@@ -190,6 +205,7 @@ function planListing(
|
|
|
190
205
|
visibility: Visibility,
|
|
191
206
|
repository: string | undefined,
|
|
192
207
|
options: ShareOptions,
|
|
208
|
+
ports: SharePorts,
|
|
193
209
|
): StoreListing | ShareRefused | undefined {
|
|
194
210
|
const asked = options.list
|
|
195
211
|
if (asked === undefined) return undefined
|
|
@@ -225,7 +241,13 @@ function planListing(
|
|
|
225
241
|
const license = asked.license ?? identity.license ?? 'MIT'
|
|
226
242
|
if (!LICENSE_ID.test(license))
|
|
227
243
|
return refused(`"${license}" is not a licence id (such as MIT or Apache-2.0)`)
|
|
228
|
-
|
|
244
|
+
// A release is never moved: when this version is already tagged and the app changed since, the share releases the next patch version.
|
|
245
|
+
let version = typeof pkg.version === 'string' ? pkg.version : (identity.version ?? '0.1.0')
|
|
246
|
+
for (let guard = 0; guard < 100; guard += 1) {
|
|
247
|
+
const released = ports.released(`v${version}`)
|
|
248
|
+
if (released === 'none' || (released === 'current' && ports.pending() === 0)) break
|
|
249
|
+
version = nextPatch(version)
|
|
250
|
+
}
|
|
229
251
|
const name = (identity.id ?? '').split('.').slice(1).join('.') || repository.split('/')[1] || ''
|
|
230
252
|
const id = `${(repository.split('/')[0] ?? '').toLowerCase()}.${name.toLowerCase()}`
|
|
231
253
|
return { id, placement, license, tag: `v${version}` }
|
|
@@ -268,8 +290,12 @@ function writeListing(
|
|
|
268
290
|
let text = manifestText
|
|
269
291
|
if (identity.id !== listing.id) text = withId(text, listing.id)
|
|
270
292
|
if (identity.license !== listing.license) text = withLicense(text, listing.license)
|
|
271
|
-
if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
|
|
272
293
|
const pkg = packageOf(appRoot) ?? {}
|
|
294
|
+
// The release this share tags: when planListing moved past an existing tag, the app carries the new version in both files.
|
|
295
|
+
const version = listing.tag.replace(/^v/u, '')
|
|
296
|
+
const bumped = typeof pkg.version === 'string' && pkg.version !== version
|
|
297
|
+
if (bumped || (pkg.version === undefined && identity.version !== version)) text = withVersion(text, version)
|
|
298
|
+
if (text !== manifestText) writeFileSync(join(appRoot, 'blend.yaml'), text)
|
|
273
299
|
const before = Array.isArray(pkg.keywords)
|
|
274
300
|
? pkg.keywords.filter((word): word is string => typeof word === 'string')
|
|
275
301
|
: []
|
|
@@ -277,10 +303,10 @@ function writeListing(
|
|
|
277
303
|
before.includes(BLEND_TOPIC) ? before : [...before, BLEND_TOPIC],
|
|
278
304
|
listing.placement,
|
|
279
305
|
)
|
|
280
|
-
if (JSON.stringify(keywords) !== JSON.stringify(pkg.keywords))
|
|
306
|
+
if (bumped || JSON.stringify(keywords) !== JSON.stringify(pkg.keywords))
|
|
281
307
|
writeFileSync(
|
|
282
308
|
join(appRoot, 'package.json'),
|
|
283
|
-
`${JSON.stringify({ ...pkg, keywords }, null, 2)}\n`,
|
|
309
|
+
`${JSON.stringify({ ...pkg, ...(bumped ? { version } : {}), keywords }, null, 2)}\n`,
|
|
284
310
|
)
|
|
285
311
|
const template = join(appRoot, 'acryl.template.json')
|
|
286
312
|
if (!existsSync(template))
|
|
@@ -313,6 +339,7 @@ export function planShare(
|
|
|
313
339
|
plan.visibility,
|
|
314
340
|
plan.create ? plan.repository : githubRepository(plan.repository),
|
|
315
341
|
options,
|
|
342
|
+
ports,
|
|
316
343
|
)
|
|
317
344
|
if (listing !== undefined && 'ok' in listing) return listing
|
|
318
345
|
return listing === undefined ? plan : { ...plan, listing }
|