From a2eadbcb188b9ac3dc5f478ed003c09cbacf30a0 Mon Sep 17 00:00:00 2001 From: Keeley Hammond Date: Tue, 1 Nov 2022 15:27:00 -0700 Subject: [PATCH] feat: move create-electron-app into forge (#2988) * feat: move create-electron-app into forge * build: do stuff * build: how dare we ignore this file * chore: add README * fix: name bin for cre correctly * fix: disable eslint for CEA * build: bust ci cache * fix: set version to 74 * debug: remove windows-latest run * debug: bump windows bolt 0.21.2 -> 0.24.10 * debug: pre-install cli * debug: bolt to 0.22.4 * build: make stub electron-forge.js file in dist for windows build to work * Revert "debug: bolt to 0.22.4" This reverts commit 8d632438c2cb5386a1d77e0b0d245f4948f1b4e0. * Revert "debug: pre-install cli" This reverts commit dcb2a66b7e92fa951e8f1822aa306fa16ddd85e5. * Revert "debug: bump windows bolt 0.21.2 -> 0.24.10" This reverts commit 2458c6097798732f4c8c8e2c74f08d21a97817fb. * Revert "debug: remove windows-latest run" This reverts commit 37847a28155524c7f5a580433051063d8ea1067d. * Revert "build: bust ci cache" This reverts commit 4b35ffed2c170cc8c8f9c5a57958d81e297e9bd3. * build: move stub folder to preinstall hook * Reland: bump windows bolt 0.21.2 -> 0.24.10 * build: add shim script for windows, remove unneeded deps * build: improve tools/maybe-shim-windows.js Co-authored-by: Samuel Attard Co-authored-by: Samuel Attard Co-authored-by: Samuel Attard --- .eslintrc.json | 2 +- .github/workflows/ci.yml | 4 +-- package.json | 2 ++ .../external/create-electron-app/README.md | 27 +++++++++++++++++++ .../external/create-electron-app/package.json | 15 +++++++++++ .../external/create-electron-app/src/index.ts | 4 +++ tools/maybe-shim-windows.js | 27 +++++++++++++++++++ 7 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 packages/external/create-electron-app/README.md create mode 100644 packages/external/create-electron-app/package.json create mode 100644 packages/external/create-electron-app/src/index.ts create mode 100644 tools/maybe-shim-windows.js diff --git a/.eslintrc.json b/.eslintrc.json index 39a02aebee..4947d302a0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -65,7 +65,7 @@ } }, { - "files": ["packages/api/cli/src/**/*.ts", "tools/*.{js,ts}"], + "files": ["packages/api/cli/src/**/*.ts", "packages/external/create-electron-app/src/**/*.ts", "tools/*.{js,ts}"], "rules": { "no-process-exit": "off", "node/shebang": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62300f507a..66a45e0af3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: shell: bash run: | case "$(uname -s)" in - Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.21.2 ;; + Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.24.10 ;; *) BOLT_VERSION=latest ;; esac npm install -g bolt@$BOLT_VERSION @@ -109,7 +109,7 @@ jobs: shell: bash run: | case "$(uname -s)" in - Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.21.2 ;; + Windows*|CYGWIN*|MINGW*|MSYS*) BOLT_VERSION=0.24.10 ;; *) BOLT_VERSION=latest ;; esac npm install -g bolt@$BOLT_VERSION diff --git a/package.json b/package.json index 0c78b97d25..3fb184a7c5 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "bolt": { "workspaces": [ "packages/api/*", + "packages/external/*", "packages/maker/*", "packages/publisher/*", "packages/utils/*", @@ -31,6 +32,7 @@ "lint:fix": "prettier --write .", "test": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TS_NODE_FILES=1 mocha './tools/test-globber.ts'", "test:fast": "xvfb-maybe cross-env TS_NODE_PROJECT='./tsconfig.test.json' TEST_FAST_ONLY=1 TS_NODE_FILES=1 mocha './tools/test-globber.ts'", + "preinstall": "node ./tools/maybe-shim-windows.js", "postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts", "prepare": "husky install" }, diff --git a/packages/external/create-electron-app/README.md b/packages/external/create-electron-app/README.md new file mode 100644 index 0000000000..b20c86eacc --- /dev/null +++ b/packages/external/create-electron-app/README.md @@ -0,0 +1,27 @@ +## create-electron-app + +Create Electron App allows you to quickly bootstrap a new Electron app, using Electron Forge. + +### Usage + +Initialize a new project by running the following: + +``` +// yarn 1 +yarn create electron-app my-app + +// npm +npx create-electron-app@latest my-app +``` + +You should now have a directory called my-app with an ultra-minimal Electron app boilerplate inside. If you head into that directory and start up the app, you'll be all set to start developing! + +``` +// yarn 1 +cd my-app +yarn start + +// npm +cd my-app +npm start +``` diff --git a/packages/external/create-electron-app/package.json b/packages/external/create-electron-app/package.json new file mode 100644 index 0000000000..32d6be3fe7 --- /dev/null +++ b/packages/external/create-electron-app/package.json @@ -0,0 +1,15 @@ +{ + "name": "create-electron-app", + "version": "6.0.0-beta.74", + "description": "Create Electron App", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "author": "Samuel Attard", + "license": "MIT", + "dependencies": { + "@electron-forge/cli": "6.0.0-beta.74" + }, + "bin": { + "create-electron-app": "dist/index.js" + } +} diff --git a/packages/external/create-electron-app/src/index.ts b/packages/external/create-electron-app/src/index.ts new file mode 100644 index 0000000000..0cb57e085f --- /dev/null +++ b/packages/external/create-electron-app/src/index.ts @@ -0,0 +1,4 @@ +#!/usr/bin/env node + +/* eslint-disable */ +import '@electron-forge/cli/dist/electron-forge-init'; diff --git a/tools/maybe-shim-windows.js b/tools/maybe-shim-windows.js new file mode 100644 index 0000000000..6804b8694d --- /dev/null +++ b/tools/maybe-shim-windows.js @@ -0,0 +1,27 @@ +const fs = require('fs'); +const path = require('path'); + +/* + * Adds a shim to fix Windows symlinking with create-electron-app. + * Should run on Windows only. + * More details: https://github.com/boltpkg/bolt/issues/207 + */ +function createShim(shimPath) { + fs.mkdirSync(path.dirname(shimPath), { recursive: true }); + fs.writeFileSync(shimPath, ''); +} + +async function main() { + const srcRoot = path.resolve(__dirname, '..'); + const cli = path.resolve(srcRoot, 'packages', 'api', 'cli', 'dist', 'electron-forge.js'); + const cea = path.resolve(srcRoot, 'packages', 'external', 'create-electron-app', 'dist', 'index.js'); + createShim(cli); + createShim(cea); +} + +if (process.platform === 'win32') { + main().catch((err) => { + console.error(err); + process.exit(1); + }); +}