mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-17 08:12:06 +03:00
0b380f94c7
This pr only includes how to bundle the app into an installer after package step. todo (not in this pr) - [ ] make sure updater can work for both nsis & squirrel - [ ] integrate nsis build into github action workflow Advantage over Squirrel: - allowing user to specify the installation location - better uninstaller ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/T2klNLEk0wxLh4NRDzhk/b75f1076-62e7-445c-bbf9-d7be00dbfc59.png) ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/T2klNLEk0wxLh4NRDzhk/c9ddc58c-512e-487e-80c8-7c4bd51482a8.png) ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/T2klNLEk0wxLh4NRDzhk/cfc5c281-e044-4929-a261-b02a4619117b.png)
91 lines
2.1 KiB
TypeScript
91 lines
2.1 KiB
TypeScript
import path from 'node:path';
|
|
|
|
import { buildForge } from 'app-builder-lib';
|
|
import debug from 'debug';
|
|
import fs from 'fs-extra';
|
|
|
|
import {
|
|
appIdMap,
|
|
arch,
|
|
buildType,
|
|
iconPngPath,
|
|
icoPath,
|
|
platform,
|
|
productName,
|
|
REPO_ROOT,
|
|
ROOT,
|
|
} from './make-env.js';
|
|
|
|
const log = debug('electron-forge:make-nsis');
|
|
|
|
async function make() {
|
|
const appName = productName;
|
|
const makeDir = path.resolve(ROOT, 'out', buildType, 'make');
|
|
const outPath = path.resolve(makeDir, `nsis.windows/${arch}`);
|
|
const appDirectory = path.resolve(
|
|
ROOT,
|
|
'out',
|
|
buildType,
|
|
`${appName}-${platform}-${arch}`
|
|
);
|
|
|
|
await fs.ensureDir(outPath);
|
|
await fs.emptyDir(outPath);
|
|
|
|
// create tmp dir
|
|
const tmpPath = await fs.mkdtemp(appName);
|
|
|
|
// copy app to tmp dir
|
|
log(`Copying app to ${tmpPath}`);
|
|
await fs.copy(appDirectory, tmpPath);
|
|
|
|
log(`Calling app-builder-lib's buildForge() with ${tmpPath}`);
|
|
const output = await buildForge(
|
|
{ dir: tmpPath },
|
|
{
|
|
win: [`nsis:${arch}`],
|
|
config: {
|
|
appId: appIdMap[buildType],
|
|
productName,
|
|
executableName: productName,
|
|
icon: iconPngPath,
|
|
extraMetadata: {
|
|
// do not use package.json's name
|
|
name: productName,
|
|
},
|
|
nsis: {
|
|
differentialPackage: false,
|
|
perMachine: false,
|
|
oneClick: false,
|
|
license: path.resolve(REPO_ROOT, 'LICENSE'),
|
|
include: path.resolve(ROOT, 'scripts', 'nsis-installer.nsh'),
|
|
installerIcon: icoPath,
|
|
allowToChangeInstallationDirectory: true,
|
|
installerSidebar: path.resolve(
|
|
ROOT,
|
|
'resources',
|
|
'icons',
|
|
'nsis-sidebar.bmp'
|
|
),
|
|
},
|
|
},
|
|
}
|
|
);
|
|
|
|
// Move the output to the actual output folder, app-builder-lib might get it wrong
|
|
log('Received output files', output);
|
|
|
|
const result: Array<string> = [];
|
|
for (const file of output) {
|
|
const filePath = path.resolve(outPath, path.basename(file));
|
|
result.push(filePath);
|
|
|
|
await fs.move(file, filePath);
|
|
}
|
|
|
|
// cleanup
|
|
await fs.remove(tmpPath);
|
|
}
|
|
|
|
make();
|