From e39ff444debe9d4a061c75415c3c16167b85bace Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Thu, 13 Oct 2022 16:11:25 -0700 Subject: [PATCH 1/2] chore: delete `lint` command --- packages/api/cli/src/electron-forge-lint.ts | 24 ----------- packages/api/core/src/api/index.ts | 26 +----------- packages/api/core/src/api/lint.ts | 44 --------------------- 3 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 packages/api/cli/src/electron-forge-lint.ts delete mode 100644 packages/api/core/src/api/lint.ts diff --git a/packages/api/cli/src/electron-forge-lint.ts b/packages/api/cli/src/electron-forge-lint.ts deleted file mode 100644 index 0f64756eb6..0000000000 --- a/packages/api/cli/src/electron-forge-lint.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { api } from '@electron-forge/core'; - -import fs from 'fs-extra'; -import program from 'commander'; -import path from 'path'; - -import './util/terminate'; -import workingDir from './util/working-dir'; - -(async () => { - let dir = process.cwd(); - program - .version((await fs.readJson(path.resolve(__dirname, '../package.json'))).version) - .arguments('[cwd]') - .action((cwd) => { - dir = workingDir(dir, cwd); - }) - .parse(process.argv); - - await api.lint({ - dir, - interactive: true, - }); -})(); diff --git a/packages/api/core/src/api/index.ts b/packages/api/core/src/api/index.ts index 205ce57433..ba2e32273b 100644 --- a/packages/api/core/src/api/index.ts +++ b/packages/api/core/src/api/index.ts @@ -2,7 +2,6 @@ import { ElectronProcess, ForgeMakeResult } from '@electron-forge/shared-types'; import _import, { ImportOptions } from './import'; import init, { InitOptions } from './init'; -import lint, { LintOptions } from './lint'; import make, { MakeOptions } from './make'; import _package, { PackageOptions } from './package'; import publish, { PublishOptions } from './publish'; @@ -28,16 +27,6 @@ export class ForgeAPI { return init(opts); } - /** - * Lint a local Electron application. - * - * The promise will be rejected with the stdout+stderr of the linting process - * if linting fails or will be resolved if it succeeds. - */ - lint(opts: LintOptions): Promise { - return lint(opts); - } - /** * Make distributables for an Electron application */ @@ -72,17 +61,4 @@ export class ForgeAPI { const api = new ForgeAPI(); const utils = new ForgeUtils(); -export { - ForgeMakeResult, - ElectronProcess, - ForgeUtils, - ImportOptions, - InitOptions, - LintOptions, - MakeOptions, - PackageOptions, - PublishOptions, - StartOptions, - api, - utils, -}; +export { ForgeMakeResult, ElectronProcess, ForgeUtils, ImportOptions, InitOptions, MakeOptions, PackageOptions, PublishOptions, StartOptions, api, utils }; diff --git a/packages/api/core/src/api/lint.ts b/packages/api/core/src/api/lint.ts deleted file mode 100644 index 874a11f5fe..0000000000 --- a/packages/api/core/src/api/lint.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { asyncOra } from '@electron-forge/async-ora'; -import debug from 'debug'; -import { yarnOrNpmSpawn } from '../util/yarn-or-npm'; - -import resolveDir from '../util/resolve-dir'; - -const d = debug('electron-forge:lint'); - -export interface LintOptions { - dir?: string; - interactive?: boolean; -} - -export default async ({ dir = process.cwd(), interactive = false }: LintOptions): Promise => { - asyncOra.interactive = interactive; - - let success = true; - let result = null; - - await asyncOra('Linting Application', async (lintSpinner) => { - const resolvedDir = await resolveDir(dir); - if (!resolvedDir) { - throw new Error('Failed to locate lintable Electron application'); - } - - dir = resolvedDir; - - d('executing "run lint" in dir:', dir); - try { - await yarnOrNpmSpawn(['run', 'lint'], { - stdio: process.platform === 'win32' ? 'inherit' : 'pipe', - cwd: dir, - }); - } catch (err) { - lintSpinner.fail(); - success = false; - result = err; - } - }); - - if (!success) { - throw result; - } -}; From d409466444078a7f2bf6e3bac2fa20547bb61c9e Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Thu, 13 Oct 2022 16:36:04 -0700 Subject: [PATCH 2/2] lint with testUtils --- packages/api/core/test/slow/api_spec_slow.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/api/core/test/slow/api_spec_slow.ts b/packages/api/core/test/slow/api_spec_slow.ts index 8e99a59452..17dd6bf01d 100644 --- a/packages/api/core/test/slow/api_spec_slow.ts +++ b/packages/api/core/test/slow/api_spec_slow.ts @@ -1,5 +1,5 @@ import { createDefaultCertificate } from '@electron-forge/maker-appx'; -import { ensureTestDirIsNonexistent, expectProjectPathExists } from '@electron-forge/test-utils'; +import { ensureTestDirIsNonexistent, expectLintToPass, expectProjectPathExists } from '@electron-forge/test-utils'; import { execSync } from 'child_process'; import { expect } from 'chai'; import { ForgeConfig, IForgeResolvableMaker } from '@electron-forge/shared-types'; @@ -78,7 +78,7 @@ for (const nodeInstaller of ['npm', 'yarn']) { }); describe('lint', () => { - it('should initially pass the linting process', () => forge.lint({ dir })); + it('should initially pass the linting process', () => expectLintToPass(dir)); }); after(() => fs.remove(dir)); @@ -116,7 +116,7 @@ for (const nodeInstaller of ['npm', 'yarn']) { }); describe('lint', () => { - it('should initially pass the linting process', () => forge.lint({ dir })); + it('should initially pass the linting process', () => expectLintToPass(dir)); }); after(async () => {