mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
refactor: lazy download macos maker (#3564)
This commit is contained in:
14
.github/actions/setup-maker/action.yml
vendored
14
.github/actions/setup-maker/action.yml
vendored
@@ -1,12 +1,16 @@
|
|||||||
name: Setup maker
|
name: Setup maker
|
||||||
description: 'Setup maker dmg for electron'
|
description: 'Setup maker dmg for electron'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- name: 'Install create-dmg from brew'
|
- name: 'Install @electron-forge/maker-dmg'
|
||||||
if: runner.os == 'macos'
|
if: runner.os == 'macos'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: brew install create-dmg
|
working-directory: ./apps/electron
|
||||||
- name: 'Build @affine/makder-dmg'
|
run: yarn add @electron-forge/maker-dmg --dev
|
||||||
shell: bash
|
env:
|
||||||
run: yarn nx build @affine/maker-dmg
|
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'
|
description: 'Download the Electron binary'
|
||||||
required: false
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
npm-token:
|
|
||||||
description: 'The NPM token to use for private packages.'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
hard-link-nm:
|
hard-link-nm:
|
||||||
description: 'set nmMode to hardlinks-local in .yarnrc.yml'
|
description: 'set nmMode to hardlinks-local in .yarnrc.yml'
|
||||||
required: false
|
required: false
|
||||||
@@ -48,7 +44,6 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: yarn install ${{ inputs.extra-flags }}
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
|
||||||
HUSKY: '0'
|
HUSKY: '0'
|
||||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||||
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||||
@@ -59,7 +54,6 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: yarn install ${{ inputs.extra-flags }}
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
|
||||||
HUSKY: '0'
|
HUSKY: '0'
|
||||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||||
ELECTRON_SKIP_BINARY_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:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
hard-link-nm: false
|
hard-link-nm: false
|
||||||
- name: Setup Maker
|
|
||||||
uses: ./.github/actions/setup-maker
|
|
||||||
- name: Build AFFiNE native
|
- name: Build AFFiNE native
|
||||||
uses: ./.github/actions/build-rust
|
uses: ./.github/actions/build-rust
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.github/workflows/nightly-build.yml
vendored
2
.github/workflows/nightly-build.yml
vendored
@@ -112,8 +112,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
|
timeout-minutes: 10
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
- name: Setup Maker
|
- name: Setup Maker
|
||||||
|
timeout-minutes: 10
|
||||||
uses: ./.github/actions/setup-maker
|
uses: ./.github/actions/setup-maker
|
||||||
- name: Build AFFiNE native
|
- name: Build AFFiNE native
|
||||||
uses: ./.github/actions/build-rust
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
|
timeout-minutes: 10
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
- name: Setup Maker
|
- name: Setup Maker
|
||||||
|
timeout-minutes: 10
|
||||||
uses: ./.github/actions/setup-maker
|
uses: ./.github/actions/setup-maker
|
||||||
- name: Build AFFiNE native
|
- name: Build AFFiNE native
|
||||||
uses: ./.github/actions/build-rust
|
uses: ./.github/actions/build-rust
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const windowsIconUrl = `https://cdn.affine.pro/app-icons/icon_${buildType}.ico`;
|
|||||||
|
|
||||||
const makers = [
|
const makers = [
|
||||||
!process.env.SKIP_BUNDLE && {
|
!process.env.SKIP_BUNDLE && {
|
||||||
name: '@affine/maker-dmg',
|
name: '@electron-forge/maker-dmg',
|
||||||
config: {
|
config: {
|
||||||
format: 'ULFO',
|
format: 'ULFO',
|
||||||
icon: icnsPath,
|
icon: icnsPath,
|
||||||
@@ -40,6 +40,21 @@ const makers = [
|
|||||||
__dirname,
|
__dirname,
|
||||||
'./resources/icons/dmg-background.png'
|
'./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(
|
file: path.resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
'out',
|
'out',
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@affine-test/kit": "workspace:*",
|
"@affine-test/kit": "workspace:*",
|
||||||
"@affine/env": "workspace:*",
|
"@affine/env": "workspace:*",
|
||||||
"@affine/maker-dmg": "workspace:*",
|
|
||||||
"@affine/native": "workspace:*",
|
"@affine/native": "workspace:*",
|
||||||
"@affine/sdk": "workspace:*",
|
"@affine/sdk": "workspace:*",
|
||||||
"@blocksuite/blocks": "0.0.0-20230802200139-381599c0-nightly",
|
"@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/y-indexeddb"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "./packages/maker-dmg"
|
|
||||||
},
|
|
||||||
// Tests
|
// Tests
|
||||||
{
|
{
|
||||||
"path": "./tests/kit"
|
"path": "./tests/kit"
|
||||||
|
|||||||
15
yarn.lock
15
yarn.lock
@@ -319,7 +319,6 @@ __metadata:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@affine-test/kit": "workspace:*"
|
"@affine-test/kit": "workspace:*"
|
||||||
"@affine/env": "workspace:*"
|
"@affine/env": "workspace:*"
|
||||||
"@affine/maker-dmg": "workspace:*"
|
|
||||||
"@affine/native": "workspace:*"
|
"@affine/native": "workspace:*"
|
||||||
"@affine/sdk": "workspace:*"
|
"@affine/sdk": "workspace:*"
|
||||||
"@blocksuite/blocks": 0.0.0-20230802200139-381599c0-nightly
|
"@blocksuite/blocks": 0.0.0-20230802200139-381599c0-nightly
|
||||||
@@ -459,18 +458,6 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
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:.":
|
"@affine/monorepo@workspace:.":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@affine/monorepo@workspace:."
|
resolution: "@affine/monorepo@workspace:."
|
||||||
@@ -3914,7 +3901,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
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
|
version: 6.2.1
|
||||||
resolution: "@electron-forge/maker-base@npm:6.2.1"
|
resolution: "@electron-forge/maker-base@npm:6.2.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user