mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-26 17:03:46 +03:00
refactor: lazy download macos maker (#3564)
This commit is contained in:
parent
0882d47dc9
commit
4bb874756d
14
.github/actions/setup-maker/action.yml
vendored
14
.github/actions/setup-maker/action.yml
vendored
@ -1,12 +1,16 @@
|
||||
name: Setup maker
|
||||
description: 'Setup maker dmg for electron'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Install create-dmg from brew'
|
||||
- name: 'Install @electron-forge/maker-dmg'
|
||||
if: runner.os == 'macos'
|
||||
shell: bash
|
||||
run: brew install create-dmg
|
||||
- name: 'Build @affine/makder-dmg'
|
||||
shell: bash
|
||||
run: yarn nx build @affine/maker-dmg
|
||||
working-directory: ./apps/electron
|
||||
run: yarn add @electron-forge/maker-dmg --dev
|
||||
env:
|
||||
HUSKY: '0'
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||
SENTRYCLI_SKIP_DOWNLOAD: '1'
|
||||
|
6
.github/actions/setup-node/action.yml
vendored
6
.github/actions/setup-node/action.yml
vendored
@ -17,10 +17,6 @@ inputs:
|
||||
description: 'Download the Electron binary'
|
||||
required: false
|
||||
default: 'true'
|
||||
npm-token:
|
||||
description: 'The NPM token to use for private packages.'
|
||||
required: false
|
||||
default: ''
|
||||
hard-link-nm:
|
||||
description: 'set nmMode to hardlinks-local in .yarnrc.yml'
|
||||
required: false
|
||||
@ -48,7 +44,6 @@ runs:
|
||||
shell: bash
|
||||
run: yarn install ${{ inputs.extra-flags }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
||||
HUSKY: '0'
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||
@ -59,7 +54,6 @@ runs:
|
||||
shell: bash
|
||||
run: yarn install ${{ inputs.extra-flags }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
||||
HUSKY: '0'
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||
|
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -415,8 +415,6 @@ jobs:
|
||||
with:
|
||||
playwright-install: true
|
||||
hard-link-nm: false
|
||||
- name: Setup Maker
|
||||
uses: ./.github/actions/setup-maker
|
||||
- name: Build AFFiNE native
|
||||
uses: ./.github/actions/build-rust
|
||||
with:
|
||||
|
2
.github/workflows/nightly-build.yml
vendored
2
.github/workflows/nightly-build.yml
vendored
@ -112,8 +112,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Node.js
|
||||
timeout-minutes: 10
|
||||
uses: ./.github/actions/setup-node
|
||||
- name: Setup Maker
|
||||
timeout-minutes: 10
|
||||
uses: ./.github/actions/setup-maker
|
||||
- name: Build AFFiNE native
|
||||
uses: ./.github/actions/build-rust
|
||||
|
2
.github/workflows/release-desktop-app.yml
vendored
2
.github/workflows/release-desktop-app.yml
vendored
@ -114,8 +114,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Node.js
|
||||
timeout-minutes: 10
|
||||
uses: ./.github/actions/setup-node
|
||||
- name: Setup Maker
|
||||
timeout-minutes: 10
|
||||
uses: ./.github/actions/setup-maker
|
||||
- name: Build AFFiNE native
|
||||
uses: ./.github/actions/build-rust
|
||||
|
@ -30,7 +30,7 @@ const windowsIconUrl = `https://cdn.affine.pro/app-icons/icon_${buildType}.ico`;
|
||||
|
||||
const makers = [
|
||||
!process.env.SKIP_BUNDLE && {
|
||||
name: '@affine/maker-dmg',
|
||||
name: '@electron-forge/maker-dmg',
|
||||
config: {
|
||||
format: 'ULFO',
|
||||
icon: icnsPath,
|
||||
@ -40,6 +40,21 @@ const makers = [
|
||||
__dirname,
|
||||
'./resources/icons/dmg-background.png'
|
||||
),
|
||||
contents: [
|
||||
{
|
||||
x: 176,
|
||||
y: 192,
|
||||
type: 'file',
|
||||
path: path.resolve(
|
||||
__dirname,
|
||||
'out',
|
||||
buildType,
|
||||
`${productName}-darwin-${arch}`,
|
||||
`${productName}.app`
|
||||
),
|
||||
},
|
||||
{ x: 432, y: 192, type: 'link', path: '/Applications' },
|
||||
],
|
||||
file: path.resolve(
|
||||
__dirname,
|
||||
'out',
|
||||
|
@ -26,7 +26,6 @@
|
||||
"devDependencies": {
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@affine/env": "workspace:*",
|
||||
"@affine/maker-dmg": "workspace:*",
|
||||
"@affine/native": "workspace:*",
|
||||
"@affine/sdk": "workspace:*",
|
||||
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
|
||||
|
@ -1,7 +0,0 @@
|
||||
# @affine/maker-dmg
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
```shell
|
||||
brew install create-dmg
|
||||
```
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "@affine/maker-dmg",
|
||||
"version": "0.8.0-canary.9",
|
||||
"main": "dist/maker.js",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite build --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron-forge/maker-base": "^6.2.1",
|
||||
"@electron-forge/shared-types": "^6.2.1",
|
||||
"fs-extra": "^11.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "^4.4.7"
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "@affine/maker-dmg",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "library",
|
||||
"sourceRoot": "packages/maker-dmg/src",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "@nx/vite:build",
|
||||
"options": {
|
||||
"outputPath": "packages/maker-dmg/dist"
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"executor": "@nx/vite:build",
|
||||
"options": {
|
||||
"outputPath": "packages/maker-dmg/dist",
|
||||
"watch": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
export interface CodeSignOptions {
|
||||
'signing-identity': string;
|
||||
identifier?: string;
|
||||
}
|
||||
|
||||
export interface DMGContents {
|
||||
x: number;
|
||||
y: number;
|
||||
type: 'link' | 'file' | 'position';
|
||||
path: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface WindowPositionOptions {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface WindowSizeOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface WindowOptions {
|
||||
position?: WindowPositionOptions;
|
||||
size?: WindowSizeOptions;
|
||||
}
|
||||
|
||||
export interface AdditionalDMGOptions {
|
||||
'background-color'?: string;
|
||||
'icon-size'?: number;
|
||||
window?: WindowOptions;
|
||||
'code-sign'?: CodeSignOptions;
|
||||
}
|
||||
|
||||
export interface MakerDMGConfig {
|
||||
/**
|
||||
* The application name
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Path to the background for the DMG window
|
||||
*/
|
||||
background: string;
|
||||
/**
|
||||
* Path to the icon to use for the app in the DMG window
|
||||
*/
|
||||
icon: string;
|
||||
/**
|
||||
* Overwrite an existing DMG file if if already exists
|
||||
*/
|
||||
overwrite?: boolean;
|
||||
/**
|
||||
* Enable debug message output
|
||||
*/
|
||||
debug?: boolean;
|
||||
/**
|
||||
* How big to make the icon for the app in the DMG
|
||||
*/
|
||||
iconSize?: number;
|
||||
/**
|
||||
* Disk image format
|
||||
*
|
||||
* Default: UDZO
|
||||
*/
|
||||
format?: 'UDRW' | 'UDRO' | 'UDCO' | 'UDZO' | 'UDBZ' | 'ULFO';
|
||||
file: string;
|
||||
/**
|
||||
* Additional options to pass through to node-appdmng
|
||||
*
|
||||
* All available options are available in the [`appdmg` docs](https://github.com/LinusU/node-appdmg)
|
||||
*/
|
||||
additionalDMGOptions?: AdditionalDMGOptions;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { cp, mkdtemp } from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import { join, resolve } from 'node:path';
|
||||
|
||||
import type { MakerOptions } from '@electron-forge/maker-base';
|
||||
import { MakerBase } from '@electron-forge/maker-base';
|
||||
import type { ForgePlatform } from '@electron-forge/shared-types';
|
||||
|
||||
import type { MakerDMGConfig } from './config';
|
||||
|
||||
export default class MakerDMG extends MakerBase<MakerDMGConfig> {
|
||||
name = 'dmg';
|
||||
|
||||
defaultPlatforms: ForgePlatform[] = ['darwin', 'mas'];
|
||||
|
||||
override isSupportedOnCurrentPlatform(): boolean {
|
||||
return process.platform === 'darwin';
|
||||
}
|
||||
|
||||
override async make({
|
||||
dir,
|
||||
makeDir,
|
||||
appName,
|
||||
packageJSON,
|
||||
targetArch,
|
||||
}: MakerOptions): Promise<string[]> {
|
||||
const outPath = resolve(makeDir, `${this.config.name || appName}.dmg`);
|
||||
const forgeDefaultOutPath = resolve(
|
||||
makeDir,
|
||||
`${appName}-${packageJSON.version}-${targetArch}.dmg`
|
||||
);
|
||||
|
||||
await this.ensureFile(outPath);
|
||||
|
||||
const args = [
|
||||
'--volname',
|
||||
appName,
|
||||
'--window-size',
|
||||
'610',
|
||||
'365',
|
||||
'--background',
|
||||
this.config.background,
|
||||
'--icon-size',
|
||||
'128',
|
||||
'--icon',
|
||||
`${appName}.app`,
|
||||
'176',
|
||||
'192',
|
||||
'--hide-extension',
|
||||
`${appName}.app`,
|
||||
'--app-drop-link',
|
||||
'423',
|
||||
'192',
|
||||
];
|
||||
|
||||
const tempDir = await mkdtemp(join(os.tmpdir(), 'electron-forge-dmg-'));
|
||||
const filePath = join(tempDir, `${appName}.app`);
|
||||
try {
|
||||
await cp(this.config.file, filePath, {
|
||||
recursive: true,
|
||||
});
|
||||
args.push(outPath, filePath);
|
||||
|
||||
execFileSync('create-dmg', args, {
|
||||
cwd: dir,
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
} finally {
|
||||
// await rm(filePath, { force: true });
|
||||
}
|
||||
|
||||
return [forgeDefaultOutPath];
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"include": ["./src"],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"noEmit": false,
|
||||
"outDir": "lib"
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { fileURLToPath } from 'url';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
const root = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
emptyOutDir: true,
|
||||
minify: false,
|
||||
lib: {
|
||||
entry: {
|
||||
maker: resolve(root, 'src/maker.ts'),
|
||||
},
|
||||
formats: ['cjs'],
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
exports: 'named',
|
||||
},
|
||||
external: [
|
||||
'@electron-forge/maker-base',
|
||||
'@electron-forge/shared-types',
|
||||
/^node:/,
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
@ -151,9 +151,6 @@
|
||||
{
|
||||
"path": "./packages/y-indexeddb"
|
||||
},
|
||||
{
|
||||
"path": "./packages/maker-dmg"
|
||||
},
|
||||
// Tests
|
||||
{
|
||||
"path": "./tests/kit"
|
||||
|
15
yarn.lock
15
yarn.lock
@ -319,7 +319,6 @@ __metadata:
|
||||
dependencies:
|
||||
"@affine-test/kit": "workspace:*"
|
||||
"@affine/env": "workspace:*"
|
||||
"@affine/maker-dmg": "workspace:*"
|
||||
"@affine/native": "workspace:*"
|
||||
"@affine/sdk": "workspace:*"
|
||||
"@blocksuite/blocks": 0.0.0-20230802200139-381599c0-nightly
|
||||
@ -459,18 +458,6 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@affine/maker-dmg@workspace:*, @affine/maker-dmg@workspace:packages/maker-dmg":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@affine/maker-dmg@workspace:packages/maker-dmg"
|
||||
dependencies:
|
||||
"@electron-forge/maker-base": ^6.2.1
|
||||
"@electron-forge/shared-types": ^6.2.1
|
||||
fs-extra: ^11.1.1
|
||||
typescript: ^5.1.6
|
||||
vite: ^4.4.7
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@affine/monorepo@workspace:.":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@affine/monorepo@workspace:."
|
||||
@ -3914,7 +3901,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@electron-forge/maker-base@npm:6.2.1, @electron-forge/maker-base@npm:^6.0.4, @electron-forge/maker-base@npm:^6.2.1":
|
||||
"@electron-forge/maker-base@npm:6.2.1, @electron-forge/maker-base@npm:^6.0.4":
|
||||
version: 6.2.1
|
||||
resolution: "@electron-forge/maker-base@npm:6.2.1"
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user