Skip to content

Commit

Permalink
feat: move create-electron-app into forge (#2988)
Browse files Browse the repository at this point in the history
* 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 8d63243.

* Revert "debug: pre-install cli"

This reverts commit dcb2a66.

* Revert "debug: bump windows bolt 0.21.2 -> 0.24.10"

This reverts commit 2458c60.

* Revert "debug: remove windows-latest run"

This reverts commit 37847a2.

* Revert "build: bust ci cache"

This reverts commit 4b35ffe.

* 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 <sam@electronjs.org>

Co-authored-by: Samuel Attard <sattard@salesforce.com>
Co-authored-by: Samuel Attard <sam@electronjs.org>
  • Loading branch information
3 people authored Nov 1, 2022
1 parent 524e3cd commit a2eadbc
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"bolt": {
"workspaces": [
"packages/api/*",
"packages/external/*",
"packages/maker/*",
"packages/publisher/*",
"packages/utils/*",
Expand All @@ -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"
},
Expand Down
27 changes: 27 additions & 0 deletions packages/external/create-electron-app/README.md
Original file line number Diff line number Diff line change
@@ -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
```
15 changes: 15 additions & 0 deletions packages/external/create-electron-app/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
4 changes: 4 additions & 0 deletions packages/external/create-electron-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

/* eslint-disable */
import '@electron-forge/cli/dist/electron-forge-init';
27 changes: 27 additions & 0 deletions tools/maybe-shim-windows.js
Original file line number Diff line number Diff line change
@@ -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);
});
}

0 comments on commit a2eadbc

Please sign in to comment.