@acryldev/blends 1.7.11 → 1.7.13
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 +16 -4
- package/dist/index.js +79 -17
- package/dist/index.js.map +1 -1
- package/pack/lib/create-source.mjs +24 -0
- package/pack/pack-blank-mac.mjs +698 -0
- package/package.json +3 -2
- 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 +2 -4
- package/plugins/save/share.ts +151 -37
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The Blank app as a macOS product (M10 T002): scaffold a Blank app with the desktop shell, install it, make the workspace links real files, mark it as a
|
|
4
|
+
* product, and package it with electron-builder as an unsigned DMG. First run only, for this Mac's CPU.
|
|
5
|
+
*
|
|
6
|
+
* node scripts/pack-blank-mac.mjs [--out <dir>] [--arch arm64|x64]
|
|
7
|
+
* node scripts/pack-blank-mac.mjs --from acrylblends.small-crm [--product "Small CRM"] a registry blueprint as its own product
|
|
8
|
+
* node scripts/pack-blank-mac.mjs --from ../apps/acryl-ade --product "ACRYL ADE" --tag-prefix ade-v a product of a repository that releases several
|
|
9
|
+
* npx @acryldev/blends pack --from . --product "ACRYL ADE" the same from a Blend's own repository, with the published packages
|
|
10
|
+
*
|
|
11
|
+
* The DMG carries the app itself: the frame and the Blank app it builds in, with Electron's own Node, so it needs no Node, npm or git. The bundle is
|
|
12
|
+
* read-only; on the first start the packaged app makes the person's first app from it in the product's own folder of the OS per-user data folder
|
|
13
|
+
* (plugins/desktop-shell/product.ts, plugins/instance/storage.ts).
|
|
14
|
+
*/
|
|
15
|
+
import { execFileSync, spawnSync } from 'node:child_process'
|
|
16
|
+
import { createHash } from 'node:crypto'
|
|
17
|
+
import {
|
|
18
|
+
appendFileSync,
|
|
19
|
+
cpSync,
|
|
20
|
+
existsSync,
|
|
21
|
+
lstatSync,
|
|
22
|
+
mkdirSync,
|
|
23
|
+
readdirSync,
|
|
24
|
+
readFileSync,
|
|
25
|
+
realpathSync,
|
|
26
|
+
renameSync,
|
|
27
|
+
rmSync,
|
|
28
|
+
statSync,
|
|
29
|
+
writeFileSync,
|
|
30
|
+
} from 'node:fs'
|
|
31
|
+
import { tmpdir } from 'node:os'
|
|
32
|
+
import { basename, dirname, join, resolve } from 'node:path'
|
|
33
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
34
|
+
import { createSource, repositoryOnlyIn } from './lib/create-source.mjs'
|
|
35
|
+
|
|
36
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
37
|
+
/**
|
|
38
|
+
* Where this packer runs: ACRYL's checkout (framework/scripts, root = framework), which makes the app with the checkout's own CLI and frame packages, or the
|
|
39
|
+
* published @acryldev/blends (its pack/ folder, root = the package, `acrylblends pack`), which makes it with the published ones: a Blend's own repository
|
|
40
|
+
* releases its product without ACRYL's source.
|
|
41
|
+
*/
|
|
42
|
+
const checkout = existsSync(join(root, 'packages', 'cli', 'bin', 'acrylblends.js'))
|
|
43
|
+
const scratch = checkout ? join(root, 'dist') : join(tmpdir(), 'acryl-pack')
|
|
44
|
+
const args = process.argv.slice(2)
|
|
45
|
+
const option = (name, fallback) => {
|
|
46
|
+
const at = args.indexOf(name)
|
|
47
|
+
return at === -1 ? fallback : args[at + 1]
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The product is built on the OS it is for (each release runner builds its own): a DMG on macOS, an NSIS installer on Windows, a Debian package on
|
|
51
|
+
* Linux. Native packages (node-pty, sharp) are installed for this machine, so building for another OS would ship the wrong ones.
|
|
52
|
+
*/
|
|
53
|
+
const PLATFORMS = { darwin: 'mac', win32: 'win', linux: 'linux' }
|
|
54
|
+
const platform = PLATFORMS[process.platform]
|
|
55
|
+
if (platform === undefined) throw new Error(`pack-blank-mac: no product for ${process.platform}`)
|
|
56
|
+
const win = process.platform === 'win32'
|
|
57
|
+
const arch = option('--arch', process.arch)
|
|
58
|
+
/** npm on Windows is a .cmd, which Node starts only through a shell, and a shell would read a range's `>` as a redirection: run npm's own script. */
|
|
59
|
+
const NPM_CLI = join(dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js')
|
|
60
|
+
const npm = (npmArgs, options) =>
|
|
61
|
+
win
|
|
62
|
+
? spawnSync(process.execPath, [NPM_CLI, ...npmArgs], options)
|
|
63
|
+
: spawnSync('npm', npmArgs, options)
|
|
64
|
+
/**
|
|
65
|
+
* A blueprint from the registry instead of Blank (`--from acrylblends.small-crm`): the product is that app, made as `npm create @acryldev/blends --from` makes it
|
|
66
|
+
* (in the frame), under its own name (`--product`, else the first heading of its README).
|
|
67
|
+
*/
|
|
68
|
+
const from = option('--from', undefined)
|
|
69
|
+
/**
|
|
70
|
+
* Where the product's newer builds are published: the Blend's GitHub repository (its `origin`), whose release workflow uploads this packer's files. A
|
|
71
|
+
* repository that releases several products (acryldev/acryl) passes `--tag-prefix`, so the updater takes this product's newest tag, not the repository's latest.
|
|
72
|
+
*/
|
|
73
|
+
const tagPrefix = option('--tag-prefix', undefined)
|
|
74
|
+
if (tagPrefix !== undefined && !/^[\w.-]+$/u.test(tagPrefix))
|
|
75
|
+
throw new Error(
|
|
76
|
+
`pack-blank-mac: --tag-prefix ${tagPrefix} is not a tag prefix (letters, digits, . _ -)`,
|
|
77
|
+
)
|
|
78
|
+
function releaseSource() {
|
|
79
|
+
try {
|
|
80
|
+
const remote = execFileSync('git', ['-C', from, 'remote', 'get-url', 'origin'], {
|
|
81
|
+
encoding: 'utf8',
|
|
82
|
+
}).trim()
|
|
83
|
+
const repo = /github\.com[:/]([\w.-]+\/[\w.-]+?)(?:\.git)?$/u.exec(remote)?.[1]
|
|
84
|
+
return repo === undefined
|
|
85
|
+
? {}
|
|
86
|
+
: { releases: { repo, file: FILE_NAME, ...(tagPrefix === undefined ? {} : { tagPrefix }) } }
|
|
87
|
+
} catch {
|
|
88
|
+
return {} // not a checkout, or no origin: the product has no update source
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Which build this product is (product.json `build`): the Blend folder's commit when it is a checkout, else the moment of packing. A started app compares it with the build its copy was made from. */
|
|
93
|
+
const productBuild = () => {
|
|
94
|
+
try {
|
|
95
|
+
if (from !== undefined && existsSync(from))
|
|
96
|
+
return execFileSync('git', ['-C', from, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim()
|
|
97
|
+
} catch {}
|
|
98
|
+
return new Date().toISOString()
|
|
99
|
+
}
|
|
100
|
+
// A folder (`--from ./05-acryl-ade`, a Blend's own checkout in its release workflow) is named by its folder, a registry id by its last part.
|
|
101
|
+
const slug =
|
|
102
|
+
from === undefined
|
|
103
|
+
? 'blank'
|
|
104
|
+
: /^[./\\]|^[a-z]:/iu.test(from)
|
|
105
|
+
? basename(resolve(from)).replace(/^\d+-/u, '')
|
|
106
|
+
: from.replace(/^[^.]+\./u, '')
|
|
107
|
+
const out = resolve(
|
|
108
|
+
option('--out', join(checkout ? scratch : join(process.cwd(), 'dist'), `${slug}-${platform}`)),
|
|
109
|
+
)
|
|
110
|
+
const work = join(scratch, `${slug}-${platform}-work`)
|
|
111
|
+
// Every git this script starts (create's first commit, the frame's) runs without git's background maintenance: a detached `git maintenance run --auto`
|
|
112
|
+
// writes into .git (objects/maintenance.lock) while step 6 copies it, and the copy fails with ENOENT (macOS runner, ACRYL ADE v0.1.1).
|
|
113
|
+
const gitConfigAt = Number(process.env.GIT_CONFIG_COUNT ?? 0)
|
|
114
|
+
Object.assign(process.env, {
|
|
115
|
+
GIT_CONFIG_COUNT: String(gitConfigAt + 2),
|
|
116
|
+
[`GIT_CONFIG_KEY_${gitConfigAt}`]: 'maintenance.auto',
|
|
117
|
+
[`GIT_CONFIG_VALUE_${gitConfigAt}`]: 'false',
|
|
118
|
+
[`GIT_CONFIG_KEY_${gitConfigAt + 1}`]: 'gc.auto',
|
|
119
|
+
[`GIT_CONFIG_VALUE_${gitConfigAt + 1}`]: '0',
|
|
120
|
+
})
|
|
121
|
+
const app = join(work, from === undefined ? 'app' : slug)
|
|
122
|
+
const log = (line) => console.log(`pack-blank-mac: ${line}`)
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The git GitHub Desktop ships (desktop/dugite-native), pinned by version and checksum. Downloaded once into dist/git-download (kept between packs),
|
|
126
|
+
* checked, unpacked into the work folder, and made to run from wherever the app is installed.
|
|
127
|
+
*/
|
|
128
|
+
const GIT = {
|
|
129
|
+
version: '2.56.0',
|
|
130
|
+
release: 'v2.56.0-2',
|
|
131
|
+
build: 'a44aeca',
|
|
132
|
+
sha256: {
|
|
133
|
+
arm64: '1110de343de11cc6f469b782b60f36217b9199b5e06875dd65baa26dd60563c7',
|
|
134
|
+
x64: '52cc663281e1ec2f1d76ba781193ca4847e62dbbf767f6c99ec9ec5b978a7659',
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function download(url, file) {
|
|
139
|
+
if (existsSync(file)) return
|
|
140
|
+
const answer = await fetch(url)
|
|
141
|
+
if (!answer.ok) throw new Error(`${url}: ${String(answer.status)}`)
|
|
142
|
+
mkdirSync(dirname(file), { recursive: true })
|
|
143
|
+
writeFileSync(`${file}.part`, Buffer.from(await answer.arrayBuffer()))
|
|
144
|
+
renameSync(`${file}.part`, file)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function productGit(cpu) {
|
|
148
|
+
const name = `dugite-native-v${GIT.version}-${GIT.build}-macOS-${cpu}.tar.gz`
|
|
149
|
+
const cache = join(scratch, 'git-download')
|
|
150
|
+
const archive = join(cache, name)
|
|
151
|
+
await download(
|
|
152
|
+
`https://github.com/desktop/dugite-native/releases/download/${GIT.release}/${name}`,
|
|
153
|
+
archive,
|
|
154
|
+
)
|
|
155
|
+
const sum = createHash('sha256').update(readFileSync(archive)).digest('hex')
|
|
156
|
+
if (sum !== GIT.sha256[cpu]) {
|
|
157
|
+
rmSync(archive, { force: true })
|
|
158
|
+
throw new Error(`${name}: checksum ${sum}, expected ${String(GIT.sha256[cpu])}`)
|
|
159
|
+
}
|
|
160
|
+
const copying = join(cache, `git-v${GIT.version}-COPYING`)
|
|
161
|
+
await download(`https://raw.githubusercontent.com/git/git/v${GIT.version}/COPYING`, copying)
|
|
162
|
+
|
|
163
|
+
const dir = join(work, 'git')
|
|
164
|
+
rmSync(dir, { recursive: true, force: true })
|
|
165
|
+
mkdirSync(dir, { recursive: true })
|
|
166
|
+
execFileSync('tar', ['-xzf', archive, '-C', dir])
|
|
167
|
+
// Git Credential Manager (a .NET program with its own runtime and UI toolkit) is 115 of the 150 MB, so it is left out; git, its helpers and git-lfs
|
|
168
|
+
// stay. A push signs in through the helper the person's own git configuration names (`gh auth setup-git` writes one).
|
|
169
|
+
const core = join(dir, 'libexec', 'git-core')
|
|
170
|
+
for (const file of readdirSync(core))
|
|
171
|
+
if (
|
|
172
|
+
/\.(dll|dylib|json|pdb)$/u.test(file) ||
|
|
173
|
+
file.startsWith('git-credential-manager') ||
|
|
174
|
+
file === 'createdump' ||
|
|
175
|
+
file === 'NOTICE' ||
|
|
176
|
+
(statSync(join(core, file)).isDirectory() &&
|
|
177
|
+
/^(cs|de|es|fr|it|ja|ko|pl|pt-BR|ru|tr|zh-Hans|zh-Hant)$/u.test(file))
|
|
178
|
+
)
|
|
179
|
+
rmSync(join(core, file), { recursive: true, force: true })
|
|
180
|
+
rmSync(join(dir, 'bin', 'scalar'), { force: true })
|
|
181
|
+
// dugite-native's git finds its helpers and templates only through the environment. The wrapper sets them from where it lies, for git's own process
|
|
182
|
+
// tree only: a shell or an agent that runs `git` gets this one with nothing else changed.
|
|
183
|
+
writeFileSync(
|
|
184
|
+
join(dir, 'bin', 'git'),
|
|
185
|
+
[
|
|
186
|
+
'#!/bin/sh',
|
|
187
|
+
`# The git that ships with ACRYL Blends (Git ${GIT.version}, desktop/dugite-native ${GIT.release}, GPL-2.0: see COPYING.txt and SOURCE.txt beside bin/).`,
|
|
188
|
+
'here=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)',
|
|
189
|
+
'GIT_EXEC_PATH="$here/libexec/git-core"',
|
|
190
|
+
'GIT_TEMPLATE_DIR="$here/share/git-core/templates"',
|
|
191
|
+
'export GIT_EXEC_PATH GIT_TEMPLATE_DIR',
|
|
192
|
+
'exec "$here/libexec/git-core/git" "$@"',
|
|
193
|
+
'',
|
|
194
|
+
].join('\n'),
|
|
195
|
+
{ mode: 0o755 },
|
|
196
|
+
)
|
|
197
|
+
cpSync(copying, join(dir, 'COPYING.txt'))
|
|
198
|
+
writeFileSync(join(dir, 'SOURCE.txt'), gitSourceOffer())
|
|
199
|
+
const size = Number(execFileSync('du', ['-sk', dir], { encoding: 'utf8' }).split('\t')[0]) * 1024
|
|
200
|
+
log(
|
|
201
|
+
`git ${GIT.version} for ${cpu}: ${String(Math.round(size / 1024 / 1024))} MB unpacked (Credential Manager left out)`,
|
|
202
|
+
)
|
|
203
|
+
return dir
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function gitSourceOffer() {
|
|
207
|
+
return [
|
|
208
|
+
`Git ${GIT.version}, as included in ACRYL Blends`,
|
|
209
|
+
'',
|
|
210
|
+
'This app includes Git, which is free software under the GNU General Public License, version 2 (the full text is in COPYING.txt beside this',
|
|
211
|
+
'file). It is the build GitHub Desktop ships, unchanged apart from leaving out Git Credential Manager and the scalar command.',
|
|
212
|
+
'',
|
|
213
|
+
'The complete corresponding source code:',
|
|
214
|
+
` Git: https://github.com/git/git/tree/v${GIT.version}`,
|
|
215
|
+
` The build scripts: https://github.com/desktop/dugite-native/tree/${GIT.release}`,
|
|
216
|
+
'',
|
|
217
|
+
'For at least three years from the day you received this app, the publisher of ACRYL Blends will also send a complete machine-readable copy of',
|
|
218
|
+
'that source code, for no more than the cost of making and sending it, to anyone who asks at https://github.com/acryldev/acryl/issues.',
|
|
219
|
+
'',
|
|
220
|
+
].join('\n')
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (
|
|
224
|
+
checkout &&
|
|
225
|
+
(!existsSync(join(root, '..', 'plugins', 'blends-frame', 'lib')) ||
|
|
226
|
+
!existsSync(join(root, 'packages', 'cli', 'dist')))
|
|
227
|
+
)
|
|
228
|
+
throw new Error('the checkout is not built: run `corepack pnpm run build` first')
|
|
229
|
+
|
|
230
|
+
// A build that exists is not a build that is current: a merge or an edit leaves the output of the last build in place, and the bundle would ship it
|
|
231
|
+
// (the frame and the scaffolder run from `lib` and `dist`, not from `src`). The newest source file of each built package must be older than its output.
|
|
232
|
+
const newestFile = (folder) => {
|
|
233
|
+
let newest = 0
|
|
234
|
+
for (const entry of readdirSync(folder, { withFileTypes: true })) {
|
|
235
|
+
if (entry.name === 'node_modules') continue
|
|
236
|
+
const path = join(folder, entry.name)
|
|
237
|
+
newest = Math.max(newest, entry.isDirectory() ? newestFile(path) : statSync(path).mtimeMs)
|
|
238
|
+
}
|
|
239
|
+
return newest
|
|
240
|
+
}
|
|
241
|
+
const stale = []
|
|
242
|
+
for (const [pkg, out] of [
|
|
243
|
+
['../plugins/blends-frame', 'lib'],
|
|
244
|
+
['packages/cli', 'dist'],
|
|
245
|
+
]) {
|
|
246
|
+
const src = join(root, pkg, 'src')
|
|
247
|
+
if (checkout && existsSync(src) && newestFile(src) > newestFile(join(root, pkg, out)))
|
|
248
|
+
stale.push(`${pkg} (${out} is older than src)`)
|
|
249
|
+
}
|
|
250
|
+
if (stale.length > 0)
|
|
251
|
+
throw new Error(
|
|
252
|
+
`the checkout's build is out of date: ${stale.join(', ')}. Run \`corepack pnpm run build\` first`,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
// 1. A Blank app with the desktop shell, made by this checkout's CLI, exactly as a person would make one.
|
|
256
|
+
rmSync(work, { recursive: true, force: true })
|
|
257
|
+
mkdirSync(work, { recursive: true })
|
|
258
|
+
const cliVersion = JSON.parse(
|
|
259
|
+
readFileSync(join(root, checkout ? 'packages/cli/package.json' : 'package.json'), 'utf8'),
|
|
260
|
+
).version
|
|
261
|
+
// The checkout's own frame packages (file: links) for a checkout; the published ones, as create picks them, otherwise.
|
|
262
|
+
const frameEnv = checkout
|
|
263
|
+
? {
|
|
264
|
+
ACRYLBLENDS_FRAME_PACKAGES: (
|
|
265
|
+
await import(pathToFileURL(join(root, 'scripts/lib/ide-specs.mjs')).href)
|
|
266
|
+
).frameSpecsEnv(root, { dshVersion: '0.2.0-rc.2', frameworkVersion: `^${cliVersion}` }),
|
|
267
|
+
}
|
|
268
|
+
: {}
|
|
269
|
+
const initOptions = { stdio: 'inherit', env: { ...process.env, ...frameEnv } }
|
|
270
|
+
const init =
|
|
271
|
+
from === undefined
|
|
272
|
+
? spawnSync(
|
|
273
|
+
process.execPath,
|
|
274
|
+
[
|
|
275
|
+
join(root, checkout ? 'packages/cli/bin/acrylblends.js' : 'bin/acrylblends.js'),
|
|
276
|
+
'init',
|
|
277
|
+
app,
|
|
278
|
+
'--name',
|
|
279
|
+
'acryl-blends-blank',
|
|
280
|
+
'--template',
|
|
281
|
+
'blank',
|
|
282
|
+
'--desktop',
|
|
283
|
+
'--yes',
|
|
284
|
+
'--no-next',
|
|
285
|
+
],
|
|
286
|
+
initOptions,
|
|
287
|
+
)
|
|
288
|
+
: // The registry blueprint, put in the frame by create itself (add desktop, upgrade); installed in step 2 like Blank.
|
|
289
|
+
// A folder goes to create as an absolute path (lib/create-source.mjs says why).
|
|
290
|
+
checkout
|
|
291
|
+
? spawnSync(
|
|
292
|
+
process.execPath,
|
|
293
|
+
[
|
|
294
|
+
join(root, 'packages/create/bin/create-acrylblends.js'),
|
|
295
|
+
app,
|
|
296
|
+
'--from',
|
|
297
|
+
createSource(from),
|
|
298
|
+
'--yes',
|
|
299
|
+
],
|
|
300
|
+
initOptions,
|
|
301
|
+
)
|
|
302
|
+
: // create is its own package, released together with this CLI.
|
|
303
|
+
npm(
|
|
304
|
+
[
|
|
305
|
+
'exec',
|
|
306
|
+
'--yes',
|
|
307
|
+
`--package=@acryldev/create-blends@${cliVersion}`,
|
|
308
|
+
'--',
|
|
309
|
+
'create-blends',
|
|
310
|
+
app,
|
|
311
|
+
'--from',
|
|
312
|
+
createSource(from),
|
|
313
|
+
'--yes',
|
|
314
|
+
],
|
|
315
|
+
initOptions,
|
|
316
|
+
)
|
|
317
|
+
if (init.status !== 0) throw new Error(`init failed (${String(init.status)})`)
|
|
318
|
+
log(`scaffolded ${app}`)
|
|
319
|
+
// The manifest the person's app starts from, before the packaging below declares every installed package in it.
|
|
320
|
+
const scaffoldManifest = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8'))
|
|
321
|
+
|
|
322
|
+
// 2. Its packages, as npm installs them.
|
|
323
|
+
const install = npm(['install', '--no-audit', '--no-fund', '--loglevel=error'], {
|
|
324
|
+
cwd: app,
|
|
325
|
+
stdio: 'inherit',
|
|
326
|
+
})
|
|
327
|
+
if (install.status !== 0) throw new Error(`npm install failed (${String(install.status)})`)
|
|
328
|
+
// The app's own step before its window opens (ACRYL ADE swaps the frame's root row for its workbench there). A product never runs `npm run desktop`,
|
|
329
|
+
// so the step runs here, once, and the bundle ships what it made.
|
|
330
|
+
if (scaffoldManifest.scripts?.predesktop !== undefined) {
|
|
331
|
+
const before = npm(['run', 'predesktop', '--loglevel=error'], { cwd: app, stdio: 'inherit' })
|
|
332
|
+
if (before.status !== 0) throw new Error(`npm run predesktop failed (${String(before.status)})`)
|
|
333
|
+
log("ran the app's predesktop step")
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// 3. npm links the workspace packages (file: specs) instead of copying them, and those links point at this checkout: a bundle must carry the files.
|
|
337
|
+
const materialize = (path) => {
|
|
338
|
+
const target = realpathSync(path)
|
|
339
|
+
rmSync(path, { recursive: true, force: true })
|
|
340
|
+
cpSync(target, path, { recursive: true, dereference: true })
|
|
341
|
+
}
|
|
342
|
+
const modules = join(app, 'node_modules')
|
|
343
|
+
const materialized = []
|
|
344
|
+
for (const entry of readdirSync(modules)) {
|
|
345
|
+
if (entry === '.bin') continue
|
|
346
|
+
const path = join(modules, entry)
|
|
347
|
+
const stat = lstatSync(path)
|
|
348
|
+
if (stat.isSymbolicLink()) {
|
|
349
|
+
materialize(path)
|
|
350
|
+
materialized.push(entry)
|
|
351
|
+
log(`materialized ${entry}`)
|
|
352
|
+
} else if (stat.isDirectory() && entry.startsWith('@')) {
|
|
353
|
+
for (const scoped of readdirSync(path)) {
|
|
354
|
+
const scopedPath = join(path, scoped)
|
|
355
|
+
if (!lstatSync(scopedPath).isSymbolicLink()) continue
|
|
356
|
+
materialize(scopedPath)
|
|
357
|
+
materialized.push(`${entry}/${scoped}`)
|
|
358
|
+
log(`materialized ${entry}/${scoped}`)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// 3b. Packages installed from npm can miss dependencies the monorepo satisfied by hoisting, and a linked package's own dependencies came from the checkout;
|
|
364
|
+
// a bundle carries none of that, and the packager keeps only packages the app declares: install whatever any installed package requires and the app does
|
|
365
|
+
// not have, into package.json, until nothing is missing (optionals are left
|
|
366
|
+
// out: they are platform builds, and npm refuses the ones for another CPU).
|
|
367
|
+
const packagesIn = (dir) => {
|
|
368
|
+
const found = []
|
|
369
|
+
for (const entry of readdirSync(dir)) {
|
|
370
|
+
if (entry.startsWith('.')) continue
|
|
371
|
+
const path = join(dir, entry)
|
|
372
|
+
if (!lstatSync(path).isDirectory()) continue
|
|
373
|
+
if (entry.startsWith('@')) {
|
|
374
|
+
for (const scoped of readdirSync(path)) {
|
|
375
|
+
const scopedPath = join(path, scoped)
|
|
376
|
+
if (lstatSync(scopedPath).isDirectory())
|
|
377
|
+
found.push({ name: `${entry}/${scoped}`, path: scopedPath })
|
|
378
|
+
}
|
|
379
|
+
} else found.push({ name: entry, path })
|
|
380
|
+
}
|
|
381
|
+
return found
|
|
382
|
+
}
|
|
383
|
+
for (let round = 1; round <= 4; round += 1) {
|
|
384
|
+
const missing = new Map()
|
|
385
|
+
for (const pkg of packagesIn(modules)) {
|
|
386
|
+
const manifestPath = join(pkg.path, 'package.json')
|
|
387
|
+
if (!existsSync(manifestPath)) continue
|
|
388
|
+
const own = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
389
|
+
for (const [dependency, range] of Object.entries({
|
|
390
|
+
...own.dependencies,
|
|
391
|
+
...own.peerDependencies,
|
|
392
|
+
})) {
|
|
393
|
+
const wantedRange = String(range)
|
|
394
|
+
if (wantedRange.startsWith('workspace:')) continue
|
|
395
|
+
if (missing.has(dependency)) continue
|
|
396
|
+
if (existsSync(join(modules, dependency))) continue
|
|
397
|
+
missing.set(dependency, wantedRange)
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (missing.size === 0) break
|
|
401
|
+
const specs = [...missing].map(([dependency, range]) => `${dependency}@${range}`)
|
|
402
|
+
log(`round ${String(round)}: installing ${String(specs.length)} dependencies the app was missing`)
|
|
403
|
+
const extra = npm(
|
|
404
|
+
['install', '--save-exact', '--no-audit', '--no-fund', '--loglevel=error', ...specs],
|
|
405
|
+
{ cwd: app, stdio: 'inherit' },
|
|
406
|
+
)
|
|
407
|
+
if (extra.status !== 0)
|
|
408
|
+
throw new Error(`installing missing dependencies failed (${String(extra.status)})`)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 3c. The packager keeps only what the app declares, and a dependency that arrived transitively (an optional one, say) is still needed at run time: every
|
|
412
|
+
// installed package is declared, so the bundle carries exactly the tree that runs here.
|
|
413
|
+
const declared = {}
|
|
414
|
+
// A package the app overrides (frame/packages.json `omit`: the LibreOffice engines as an empty placeholder) is declared with the override's own spec:
|
|
415
|
+
// npm refuses a direct dependency that differs from its override (EOVERRIDE), which stopped every pack of acrylblends 1.5.19 apps.
|
|
416
|
+
const overrides = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8')).overrides ?? {}
|
|
417
|
+
for (const pkg of packagesIn(modules)) {
|
|
418
|
+
const manifestPath = join(pkg.path, 'package.json')
|
|
419
|
+
if (!existsSync(manifestPath)) continue
|
|
420
|
+
const own = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
421
|
+
// electron is the runtime the packager brings, not a package of the app: it stays in devDependencies.
|
|
422
|
+
if (pkg.name === 'electron') continue
|
|
423
|
+
if (typeof overrides[pkg.name] === 'string') declared[pkg.name] = overrides[pkg.name]
|
|
424
|
+
else if (typeof own.version === 'string') declared[pkg.name] = own.version
|
|
425
|
+
}
|
|
426
|
+
const before = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8'))
|
|
427
|
+
const merged = { ...before.dependencies, ...declared }
|
|
428
|
+
JSON.parse(JSON.stringify(before)) // the manifest is rewritten below with the product fields; dependencies travel with it
|
|
429
|
+
writeFileSync(
|
|
430
|
+
join(app, 'package.json'),
|
|
431
|
+
`${JSON.stringify({ ...before, dependencies: merged }, null, 2)}\n`,
|
|
432
|
+
)
|
|
433
|
+
log(`declared ${String(Object.keys(declared).length)} installed packages`)
|
|
434
|
+
|
|
435
|
+
// 4. The product marker, and what Electron needs to find its main process and the packager its identity.
|
|
436
|
+
// The product is ACRYL Blends; Blank is only the starting app a person's first app is made from. The name is the installed app's, the DMG's and the root
|
|
437
|
+
// folder's in the OS data folder, so every app the person makes (AccountingApp, CRMApp, ...) lives beside the others under one product.
|
|
438
|
+
const readmeTitle = () => {
|
|
439
|
+
const readme = join(app, 'README.md')
|
|
440
|
+
const heading = existsSync(readme) ? /^# (.+)$/mu.exec(readFileSync(readme, 'utf8')) : null
|
|
441
|
+
return heading?.[1]?.trim()
|
|
442
|
+
}
|
|
443
|
+
const PRODUCT =
|
|
444
|
+
from === undefined ? 'ACRYL Blends' : (option('--product', undefined) ?? readmeTitle() ?? slug)
|
|
445
|
+
/** The app's own name in the product: Blank for ACRYL Blends, the product itself for a blueprint. */
|
|
446
|
+
const APP_NAME = from === undefined ? 'Blank' : PRODUCT
|
|
447
|
+
const DESCRIPTION =
|
|
448
|
+
from === undefined
|
|
449
|
+
? 'The ACRYL Blends frame around an empty app: make it yours from the chat.'
|
|
450
|
+
: `${PRODUCT}, an ACRYL Blends app (${from}), in the frame: change it from the chat.`
|
|
451
|
+
const FILE_NAME =
|
|
452
|
+
from === undefined ? 'ACRYL-Blends-Blank' : PRODUCT.replace(/[^A-Za-z0-9]+/gu, '-')
|
|
453
|
+
// 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
|
+
// signature (identifier `Electron`, no sealed resources, Info.plist not bound), so the bundle was not sealed and `codesign --verify --deep --strict` failed.
|
|
455
|
+
// 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
|
|
456
|
+
// person's native modules (node-pty, sharp) are not signed by us and a hardened process refuses to load them. A Developer ID signature and notarization
|
|
457
|
+
// replace this seal at release (app-storage.md).
|
|
458
|
+
writeFileSync(
|
|
459
|
+
join(work, 'seal-bundle.cjs'),
|
|
460
|
+
`const { spawnSync } = require('node:child_process')
|
|
461
|
+
const { join } = require('node:path')
|
|
462
|
+
exports.default = async (context) => {
|
|
463
|
+
const bundle = join(context.appOutDir, context.packager.appInfo.productFilename + '.app')
|
|
464
|
+
const sealed = spawnSync('codesign', ['--force', '--deep', '--sign', '-', bundle], { stdio: 'inherit' })
|
|
465
|
+
if (sealed.status !== 0) throw new Error('codesign failed for ' + bundle)
|
|
466
|
+
const checked = spawnSync('codesign', ['--verify', '--deep', '--strict', bundle], { stdio: 'inherit' })
|
|
467
|
+
if (checked.status !== 0) throw new Error('the sealed bundle does not verify: ' + bundle)
|
|
468
|
+
}
|
|
469
|
+
`,
|
|
470
|
+
)
|
|
471
|
+
const manifest = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8'))
|
|
472
|
+
// The installed app's icon (Dock, Finder, About, the installer) is the one its window wears (plugins/desktop-shell/brand.ts iconFile): the app's own
|
|
473
|
+
// assets/icon.png, else the ACRYL Blends logo. Left unset, every product showed Electron's default icon.
|
|
474
|
+
// The app's desktop shell: its own copy in plugins/desktop-shell, or the @acryldev/desktop-shell package it depends on (spec 051 T011).
|
|
475
|
+
const { findDesktopShell } = await import(
|
|
476
|
+
pathToFileURL(join(root, checkout ? 'packages/cli/src/desktop-shell.ts' : 'dist/index.js')).href
|
|
477
|
+
)
|
|
478
|
+
const shell = findDesktopShell(app)
|
|
479
|
+
if (shell === undefined)
|
|
480
|
+
throw new Error(
|
|
481
|
+
`pack-blank-mac: ${app} has no desktop shell (plugins/desktop-shell, or the @acryldev/desktop-shell package)`,
|
|
482
|
+
)
|
|
483
|
+
const appIcon = [
|
|
484
|
+
join(app, 'assets', 'icon.png'),
|
|
485
|
+
join(shell.root, 'assets', 'acrylblends-logo.png'),
|
|
486
|
+
].find((file) => existsSync(file))
|
|
487
|
+
manifest.main = shell.main
|
|
488
|
+
manifest.productName = PRODUCT
|
|
489
|
+
manifest.description = DESCRIPTION
|
|
490
|
+
manifest.build = {
|
|
491
|
+
appId: `dev.acrylblends.${slug}`,
|
|
492
|
+
productName: PRODUCT,
|
|
493
|
+
asar: false,
|
|
494
|
+
npmRebuild: false,
|
|
495
|
+
files: ['**/*', '!dist/**', '!**/.acrylblends/**', '!**/*.map'],
|
|
496
|
+
directories: { output: 'dist' },
|
|
497
|
+
mac: {
|
|
498
|
+
target: [{ target: 'dmg', arch: [arch] }],
|
|
499
|
+
// No signing by the builder (it passes --timestamp, which an ad hoc signature refuses); `afterPack` below seals the bundle instead.
|
|
500
|
+
identity: null,
|
|
501
|
+
category: 'public.app-category.developer-tools',
|
|
502
|
+
icon: appIcon,
|
|
503
|
+
},
|
|
504
|
+
dmg: { title: PRODUCT },
|
|
505
|
+
win: { target: [{ target: 'nsis', arch: [arch] }], icon: appIcon },
|
|
506
|
+
// Per user, no administrator: the installer asks where, and the app's home is the person's own data folder (plugins/instance/storage.ts).
|
|
507
|
+
nsis: {
|
|
508
|
+
oneClick: false,
|
|
509
|
+
perMachine: false,
|
|
510
|
+
allowToChangeInstallationDirectory: true,
|
|
511
|
+
},
|
|
512
|
+
linux: {
|
|
513
|
+
target: [{ target: 'deb', arch: [arch] }],
|
|
514
|
+
category: 'Development',
|
|
515
|
+
icon: appIcon,
|
|
516
|
+
maintainer: 'ACRYL Blends <build@acryldev.dev>',
|
|
517
|
+
},
|
|
518
|
+
...(platform === 'mac' ? { afterPack: join(work, 'seal-bundle.cjs') } : {}),
|
|
519
|
+
}
|
|
520
|
+
// A Debian package names its maintainer and the app's home page; electron-builder reads both from the manifest.
|
|
521
|
+
manifest.author ??= { name: 'ACRYL Blends', email: 'build@acryldev.dev' }
|
|
522
|
+
manifest.homepage ??= 'https://acrylblends.github.io'
|
|
523
|
+
// 4a. The product's own git (app-storage.md, "Git on a clean machine"): a clean Mac has only the shim that asks to install the Command Line Tools, and
|
|
524
|
+
// versions, export, the terminals and the agents all run `git`. It lies beside the app in Resources/git, and the desktop shell puts it first on the
|
|
525
|
+
// frame host's PATH (plugins/desktop-shell/git.ts).
|
|
526
|
+
// shortcut: git ships with the macOS product only; Windows and Linux use the machine's git (dugite-native has builds for both, add them when the desktop
|
|
527
|
+
// shell's git.ts finds a Windows git.exe).
|
|
528
|
+
if (platform === 'mac')
|
|
529
|
+
manifest.build.extraResources = [{ from: await productGit(arch), to: 'git' }]
|
|
530
|
+
else log(`no bundled git on ${platform}: the app uses the git on the machine`)
|
|
531
|
+
writeFileSync(join(app, 'package.json'), `${JSON.stringify(manifest, null, 2)}\n`)
|
|
532
|
+
// The product's root in the OS per-user data folder is named after it; the first app the person gets is called Blank until they name it. The Program is
|
|
533
|
+
// what stays in the bundle and is served from there (plugins/instance/bundle.ts): the packages, the generated host and its composition, and every
|
|
534
|
+
// framework plugin the library copied in (plugins/library.lock.json). A new app's source gets everything else: the person's part.
|
|
535
|
+
const libraryPlugins = Object.keys(
|
|
536
|
+
JSON.parse(readFileSync(join(app, 'plugins', 'library.lock.json'), 'utf8')).plugins ?? {},
|
|
537
|
+
)
|
|
538
|
+
const program = [
|
|
539
|
+
'node_modules/',
|
|
540
|
+
'app/',
|
|
541
|
+
'frame/',
|
|
542
|
+
'scripts/',
|
|
543
|
+
'cordis.yml',
|
|
544
|
+
'cordis.patch.yml',
|
|
545
|
+
...libraryPlugins.map((name) => `plugins/${name}/`),
|
|
546
|
+
]
|
|
547
|
+
writeFileSync(
|
|
548
|
+
join(app, 'product.json'),
|
|
549
|
+
// A product made from a Blend (--from) is that finished app under its own name; only Blank's first app is the person's to name.
|
|
550
|
+
`${JSON.stringify({ product: PRODUCT, appName: APP_NAME, program, ...(from === undefined ? {} : { named: true, build: productBuild(), ...releaseSource() }) }, null, 2)}\n`,
|
|
551
|
+
)
|
|
552
|
+
log(`the Program: ${program.join(', ')}`)
|
|
553
|
+
|
|
554
|
+
// 4b. The packager drops or rewrites files the app owns: `.git` and `.gitignore` never enter a bundle (electron-builder excludes those names), and the
|
|
555
|
+
// manifest it ships is filtered (the scripts go). Each travels under a plain carrier name and a new app's source gets it back as itself
|
|
556
|
+
// (plugins/desktop-shell/product.ts). The product's own build-time files stay out of the repository's status through its local exclude, never the app's tracked
|
|
557
|
+
// .gitignore.
|
|
558
|
+
cpSync(join(app, '.gitignore'), join(app, 'gitignore-product'))
|
|
559
|
+
// `.gitattributes` pins the line endings of the app's files (a plugin written on Windows must digest the same on a Mac): the template commits it, the builder drops it by name.
|
|
560
|
+
if (existsSync(join(app, '.gitattributes')))
|
|
561
|
+
cpSync(join(app, '.gitattributes'), join(app, 'gitattributes-product'))
|
|
562
|
+
// The source's manifest lists no framework package as its own: the bundle provides every package the scaffold declared, so they are peers, at the
|
|
563
|
+
// version installed here (never a build machine's file: path). Its scripts name Program files and a product runs no npm, so they stay with the bundle.
|
|
564
|
+
// What the person installs later is theirs: `dependencies` in their source.
|
|
565
|
+
const installedVersion = (name) =>
|
|
566
|
+
JSON.parse(readFileSync(join(app, 'node_modules', name, 'package.json'), 'utf8')).version
|
|
567
|
+
const {
|
|
568
|
+
scripts: _scripts,
|
|
569
|
+
dependencies: scaffoldDependencies = {},
|
|
570
|
+
devDependencies: _devDependencies,
|
|
571
|
+
...ownFields
|
|
572
|
+
} = scaffoldManifest
|
|
573
|
+
const sourceManifest = {
|
|
574
|
+
...ownFields,
|
|
575
|
+
peerDependencies: Object.fromEntries(
|
|
576
|
+
Object.keys(scaffoldDependencies)
|
|
577
|
+
.sort()
|
|
578
|
+
.map((name) => [name, installedVersion(name)]),
|
|
579
|
+
),
|
|
580
|
+
}
|
|
581
|
+
writeFileSync(join(app, 'package-product.json'), `${JSON.stringify(sourceManifest, null, 2)}\n`)
|
|
582
|
+
const exclude = join(app, '.git', 'info', 'exclude')
|
|
583
|
+
const excluded = existsSync(exclude) ? readFileSync(exclude, 'utf8') : ''
|
|
584
|
+
const productNames = [
|
|
585
|
+
'product.json',
|
|
586
|
+
'gitignore-product',
|
|
587
|
+
'gitattributes-product',
|
|
588
|
+
'package-product.json',
|
|
589
|
+
'template-git/',
|
|
590
|
+
]
|
|
591
|
+
const missingNames = productNames.filter(
|
|
592
|
+
(name) =>
|
|
593
|
+
!excluded
|
|
594
|
+
.split('\n')
|
|
595
|
+
.map((line) => line.trim())
|
|
596
|
+
.includes(name),
|
|
597
|
+
)
|
|
598
|
+
if (missingNames.length > 0) {
|
|
599
|
+
mkdirSync(join(app, '.git', 'info'), { recursive: true })
|
|
600
|
+
appendFileSync(
|
|
601
|
+
exclude,
|
|
602
|
+
`${excluded === '' || excluded.endsWith('\n') ? '' : '\n'}${missingNames.join('\n')}\n`,
|
|
603
|
+
)
|
|
604
|
+
}
|
|
605
|
+
// The repository a new app starts with records the person's part only: the source's manifest, and none of the Program (which a source never holds,
|
|
606
|
+
// so it would show as deleted). The bundle's own files are left as they are; the commit is made in the index. The identity is the product's, not
|
|
607
|
+
// whatever the build machine configures.
|
|
608
|
+
const gitIdentity = [
|
|
609
|
+
'-c',
|
|
610
|
+
'user.name=ACRYL Blends',
|
|
611
|
+
'-c',
|
|
612
|
+
'user.email=build@acryldev.dev',
|
|
613
|
+
'-c',
|
|
614
|
+
'commit.gpgsign=false',
|
|
615
|
+
]
|
|
616
|
+
execFileSync(
|
|
617
|
+
'git',
|
|
618
|
+
[
|
|
619
|
+
'rm',
|
|
620
|
+
'-r',
|
|
621
|
+
'-q',
|
|
622
|
+
'--cached',
|
|
623
|
+
'--ignore-unmatch',
|
|
624
|
+
'--',
|
|
625
|
+
...program.map((path) => path.replace(/\/$/u, '')),
|
|
626
|
+
...repositoryOnlyIn(app),
|
|
627
|
+
],
|
|
628
|
+
{ cwd: app, stdio: 'inherit' },
|
|
629
|
+
)
|
|
630
|
+
const manifestBlob = execFileSync('git', ['hash-object', '-w', 'package-product.json'], {
|
|
631
|
+
cwd: app,
|
|
632
|
+
encoding: 'utf8',
|
|
633
|
+
}).trim()
|
|
634
|
+
execFileSync('git', ['update-index', '--cacheinfo', `100644,${manifestBlob},package.json`], {
|
|
635
|
+
cwd: app,
|
|
636
|
+
stdio: 'inherit',
|
|
637
|
+
})
|
|
638
|
+
execFileSync(
|
|
639
|
+
'git',
|
|
640
|
+
[
|
|
641
|
+
...gitIdentity,
|
|
642
|
+
'commit',
|
|
643
|
+
'-q',
|
|
644
|
+
'-m',
|
|
645
|
+
"product: the person's part of the app; the framework is served from the product's bundle",
|
|
646
|
+
],
|
|
647
|
+
{ cwd: app, stdio: 'inherit' },
|
|
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(', ')}`)
|
|
653
|
+
// The scaffold's repository travels as `template-git` (the packager drops `.git`), with that commit in it.
|
|
654
|
+
if (existsSync(join(app, '.git')))
|
|
655
|
+
rmSync(join(app, 'template-git'), { recursive: true, force: true })
|
|
656
|
+
// shortcut: the filter keeps Node on its JavaScript copy; its native copy (Node 24.22 on macOS runners) fails here with ENOENT on template-git/objects.
|
|
657
|
+
if (existsSync(join(app, '.git')))
|
|
658
|
+
cpSync(join(app, '.git'), join(app, 'template-git'), { recursive: true, filter: () => true })
|
|
659
|
+
|
|
660
|
+
// 5. Package it. The builder is not a dependency of this repo yet; a checkout of ACRYL has one, and npx fetches one otherwise.
|
|
661
|
+
const builder = process.env.ELECTRON_BUILDER
|
|
662
|
+
const KIND = { mac: 'dmg', win: 'nsis', linux: 'deb' }[platform]
|
|
663
|
+
const EXTENSION = { mac: '.dmg', win: '.exe', linux: '.deb' }[platform]
|
|
664
|
+
const targetArgs = [`--${platform}`, KIND, `--${arch}`, '--publish', 'never']
|
|
665
|
+
log(`packaging with ${builder ?? 'npx electron-builder@26.15.7'}`)
|
|
666
|
+
const pack =
|
|
667
|
+
builder !== undefined
|
|
668
|
+
? spawnSync(process.execPath, [builder, ...targetArgs], {
|
|
669
|
+
cwd: app,
|
|
670
|
+
stdio: 'inherit',
|
|
671
|
+
env: { ...process.env, CSC_IDENTITY_AUTO_DISCOVERY: 'false' },
|
|
672
|
+
})
|
|
673
|
+
: npm(
|
|
674
|
+
[
|
|
675
|
+
'exec',
|
|
676
|
+
'--yes',
|
|
677
|
+
'--package=electron-builder@26.15.7',
|
|
678
|
+
'--',
|
|
679
|
+
'electron-builder',
|
|
680
|
+
...targetArgs,
|
|
681
|
+
],
|
|
682
|
+
{
|
|
683
|
+
cwd: app,
|
|
684
|
+
stdio: 'inherit',
|
|
685
|
+
env: { ...process.env, CSC_IDENTITY_AUTO_DISCOVERY: 'false' },
|
|
686
|
+
},
|
|
687
|
+
)
|
|
688
|
+
if (pack.status !== 0) throw new Error(`electron-builder failed (${String(pack.status)})`)
|
|
689
|
+
|
|
690
|
+
// 6. The installer, under the name the person is given.
|
|
691
|
+
const produced = readdirSync(join(app, 'dist')).filter((file) => file.endsWith(EXTENSION))
|
|
692
|
+
if (produced.length === 0) throw new Error(`electron-builder wrote no ${EXTENSION}`)
|
|
693
|
+
mkdirSync(out, { recursive: true })
|
|
694
|
+
for (const file of readdirSync(out))
|
|
695
|
+
if (file.endsWith(EXTENSION)) rmSync(join(out, file), { force: true })
|
|
696
|
+
const target = join(out, `${FILE_NAME}-${platform}-${arch}${EXTENSION}`)
|
|
697
|
+
cpSync(join(app, 'dist', produced[0]), target)
|
|
698
|
+
log(`done: ${target} (${String(Math.round(statSync(target).size / 1024 / 1024))} MB)`)
|