diff --git a/.github/actions/setup-maker/action.yml b/.github/actions/setup-maker/action.yml index 49c81269d2..6861249b23 100644 --- a/.github/actions/setup-maker/action.yml +++ b/.github/actions/setup-maker/action.yml @@ -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' diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml index ae062ce326..6baa856ce1 100644 --- a/.github/actions/setup-node/action.yml +++ b/.github/actions/setup-node/action.yml @@ -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' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1f4dfe9bf..e5e8c11b0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 216bab5792..89566fd5e0 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -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 diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.yml index 88038cce65..92a52bcbf3 100644 --- a/.github/workflows/release-desktop-app.yml +++ b/.github/workflows/release-desktop-app.yml @@ -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 diff --git a/apps/electron/forge.config.js b/apps/electron/forge.config.js index 8ee2fa6488..0908dd9e6c 100644 --- a/apps/electron/forge.config.js +++ b/apps/electron/forge.config.js @@ -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', diff --git a/apps/electron/package.json b/apps/electron/package.json index 40068549a9..0320b42b74 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -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", diff --git a/packages/maker-dmg/README.md b/packages/maker-dmg/README.md deleted file mode 100644 index 21a4633ca0..0000000000 --- a/packages/maker-dmg/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @affine/maker-dmg - -## Pre-requisites - -```shell -brew install create-dmg -``` diff --git a/packages/maker-dmg/package.json b/packages/maker-dmg/package.json deleted file mode 100644 index ef7f1f22c3..0000000000 --- a/packages/maker-dmg/package.json +++ /dev/null @@ -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" - } -} diff --git a/packages/maker-dmg/project.json b/packages/maker-dmg/project.json deleted file mode 100644 index 44298f5dff..0000000000 --- a/packages/maker-dmg/project.json +++ /dev/null @@ -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 - } - } - } -} diff --git a/packages/maker-dmg/src/config.ts b/packages/maker-dmg/src/config.ts deleted file mode 100644 index 708053d539..0000000000 --- a/packages/maker-dmg/src/config.ts +++ /dev/null @@ -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; -} diff --git a/packages/maker-dmg/src/maker.ts b/packages/maker-dmg/src/maker.ts deleted file mode 100644 index 197e287286..0000000000 --- a/packages/maker-dmg/src/maker.ts +++ /dev/null @@ -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 { - name = 'dmg'; - - defaultPlatforms: ForgePlatform[] = ['darwin', 'mas']; - - override isSupportedOnCurrentPlatform(): boolean { - return process.platform === 'darwin'; - } - - override async make({ - dir, - makeDir, - appName, - packageJSON, - targetArch, - }: MakerOptions): Promise { - 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]; - } -} diff --git a/packages/maker-dmg/tsconfig.json b/packages/maker-dmg/tsconfig.json deleted file mode 100644 index 8034f93ce4..0000000000 --- a/packages/maker-dmg/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./src"], - "compilerOptions": { - "composite": true, - "noEmit": false, - "outDir": "lib" - } -} diff --git a/packages/maker-dmg/vite.config.ts b/packages/maker-dmg/vite.config.ts deleted file mode 100644 index 72208ed283..0000000000 --- a/packages/maker-dmg/vite.config.ts +++ /dev/null @@ -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:/, - ], - }, - }, -}); diff --git a/tsconfig.json b/tsconfig.json index 0cb3c5de95..68a39ef863 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -151,9 +151,6 @@ { "path": "./packages/y-indexeddb" }, - { - "path": "./packages/maker-dmg" - }, // Tests { "path": "./tests/kit" diff --git a/yarn.lock b/yarn.lock index 385a9830e2..60fb09b0a9 100644 --- a/yarn.lock +++ b/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: