From a1d145953c8bc9f5c434e58fc60a19ed97787b45 Mon Sep 17 00:00:00 2001 From: Keeley Hammond Date: Tue, 25 Oct 2022 15:27:18 -0700 Subject: [PATCH] feat: move create-electron-app into forge --- .../create-electron-app/package.json | 15 ++++ .../create-electron-app/src/index.js | 3 + .../create-electron-app/src/index.ts | 3 + tools/publish.js | 74 +++++++++---------- tools/utils.ts | 28 ++++--- 5 files changed, 74 insertions(+), 49 deletions(-) create mode 100644 packages/externals/create-electron-app/package.json create mode 100755 packages/externals/create-electron-app/src/index.js create mode 100644 packages/externals/create-electron-app/src/index.ts diff --git a/packages/externals/create-electron-app/package.json b/packages/externals/create-electron-app/package.json new file mode 100644 index 0000000000..b574a16acb --- /dev/null +++ b/packages/externals/create-electron-app/package.json @@ -0,0 +1,15 @@ +{ + "name": "create-electron-app", + "version": "1.0.0", + "description": "Create Electron App", + "main": "src/index.js", + "typings": "../../api/cli/src/electron-forge-init.ts", + "author": "Samuel Attard", + "license": "MIT", + "dependencies": { + "@electron-forge/cli": "latest" + }, + "bin": { + "create-electron-app": "./src/index" + } +} diff --git a/packages/externals/create-electron-app/src/index.js b/packages/externals/create-electron-app/src/index.js new file mode 100755 index 0000000000..62e9a20ec4 --- /dev/null +++ b/packages/externals/create-electron-app/src/index.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +require('@electron-forge/cli/dist/electron-forge-init.js'); diff --git a/packages/externals/create-electron-app/src/index.ts b/packages/externals/create-electron-app/src/index.ts new file mode 100644 index 0000000000..0a6d58e018 --- /dev/null +++ b/packages/externals/create-electron-app/src/index.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env ts-node + +require('@electron-forge/cli/dist/electron-forge-init.js'); \ No newline at end of file diff --git a/tools/publish.js b/tools/publish.js index 2fd0baa620..a8455a7122 100644 --- a/tools/publish.js +++ b/tools/publish.js @@ -51,46 +51,46 @@ const publisher = new Listr([ } }, }, - { - title: 'Publishing all packages', - task: async (ctx) => { - return new Listr( - await Promise.all( - ctx.dirsToPublish.map(async (dir) => { - const { name, version } = await fs.readJson(path.resolve(dir, 'package.json')); - // TODO: Re-enable this once V6 stable is released - // const isBeta = version.includes('beta'); - const isBeta = false; - return { - title: `Publishing: ${chalk.cyan(`${name}@${version}`)} (beta=${isBeta ? chalk.green('true') : chalk.red('false')})`, - task: async () => { - try { - await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], { - cwd: dir, - }); - } catch (err) { - throw new Error(`Failed to publish ${chalk.cyan(`${name}@${version}`)} \n${err.stderr.toString()}`); - } - }, - }; - }) - ), - { concurrent: 5, exitOnError: false } - ); - }, - }, + // { + // title: 'Publishing all packages', + // task: async (ctx) => { + // return new Listr( + // await Promise.all( + // ctx.dirsToPublish.map(async (dir) => { + // const { name, version } = await fs.readJson(path.resolve(dir, 'package.json')); + // // TODO: Re-enable this once V6 stable is released + // // const isBeta = version.includes('beta'); + // const isBeta = false; + // return { + // title: `Publishing: ${chalk.cyan(`${name}@${version}`)} (beta=${isBeta ? chalk.green('true') : chalk.red('false')})`, + // task: async () => { + // try { + // await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], { + // cwd: dir, + // }); + // } catch (err) { + // throw new Error(`Failed to publish ${chalk.cyan(`${name}@${version}`)} \n${err.stderr.toString()}`); + // } + // }, + // }; + // }) + // ), + // { concurrent: 5, exitOnError: false } + // ); + // }, + // }, ]); const runPublisher = async () => { - const otp = await new Promise((resolve) => { - process.stdin.once('data', (chunk) => { - process.stdin.pause(); - resolve(chunk.toString()); - }); - process.stdout.write('Enter OTP: '); - process.stdin.read(); - }); - publisher.run({ otp }); + // const otp = await new Promise((resolve) => { + // process.stdin.once('data', (chunk) => { + // process.stdin.pause(); + // resolve(chunk.toString()); + // }); + // process.stdout.write('Enter OTP: '); + // process.stdin.read(); + // }); + // publisher.run({ otp }); }; prepare diff --git a/tools/utils.ts b/tools/utils.ts index 5ae7c90439..c911275073 100644 --- a/tools/utils.ts +++ b/tools/utils.ts @@ -16,12 +16,14 @@ export const getPackageInfo = async (): Promise => { for (const subDir of await fs.readdir(PACKAGES_DIR)) { for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) { const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir); - const pkg = await fs.readJson(path.resolve(packagePath, 'package.json')); - packages.push({ - path: packagePath, - name: pkg.name, - manifest: pkg, - }); + if (fs.lstatSync(packagePath).isDirectory() ) { + const pkg = await fs.readJson(path.resolve(packagePath, 'package.json')); + packages.push({ + path: packagePath, + name: pkg.name, + manifest: pkg, + }); + } } } @@ -34,12 +36,14 @@ export const getPackageInfoSync = (): Package[] => { for (const subDir of fs.readdirSync(PACKAGES_DIR)) { for (const packageDir of fs.readdirSync(path.resolve(PACKAGES_DIR, subDir))) { const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir); - const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json')); - packages.push({ - path: packagePath, - name: pkg.name, - manifest: pkg, - }); + if (fs.lstatSync(packagePath).isDirectory() ) { + const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json')); + packages.push({ + path: packagePath, + name: pkg.name, + manifest: pkg, + }); + } } }