Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): upgrade typescript to ~4.4.2 #2485

Merged
merged 7 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ updates:
- dependency-name: find-up
- dependency-name: log-symbols
- dependency-name: ora
- dependency-name: typescript
versions: ['4.1.x', '4.2.x', '4.3.x']
- dependency-name: username
- package-ecosystem: "npm"
directory: "/packages/template/typescript/tmpl"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"sinon-chai": "^3.6.0",
"ts-node": "^10.0.0",
"typedoc": "^0.21.0",
"typescript": "~4.0.2",
"typescript": "~4.4.2",
"xvfb-maybe": "^0.2.1"
},
"optionalDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cli/src/electron-forge-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import workingDir from './util/working-dir';

const spawned = await api.start(opts);

await new Promise((resolve) => {
await new Promise<void>((resolve) => {
const listenForExit = (child: ElectronProcess) => {
let onExit: NodeJS.ExitListener;
let onRestart: (newChild: ElectronProcess) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/init-scripts/find-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async (dir: string, template: string): Promise<ForgeTemplate> =>
foundTemplate = true;
break;
} catch (err) {
d(`Error: ${err.message || err}`);
d(`Error: ${err instanceof Error ? err.message : err}`);
}
}
if (!foundTemplate) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/init-scripts/init-git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const d = debug('electron-forge:init:git');

export default async (dir: string) => {
await asyncOra('Initializing Git Repository', async () => {
await new Promise((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
exec('git rev-parse --show-toplevel', {
cwd: dir,
}, (err) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ export default async ({
arch: targetArch,
});
} catch (err) {
if (err) {
if (err instanceof Error) {
// eslint-disable-next-line no-throw-literal
throw {
message: `An error occured while making for target: ${maker.name}`,
stack: `${err.message}\n${err.stack}`,
};
} else if (err) {
throw err;
} else {
throw new Error(`An unknown error occured while making for target: ${maker.name}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/api/core/src/api/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default async ({
}

const calculatedOutDir = outDir || getCurrentOutDir(dir, forgeConfig);
let packagerSpinner: OraImpl | null = null;
let packagerSpinner: OraImpl | undefined;

const pruneEnabled = !('prune' in forgeConfig.packagerConfig) || forgeConfig.packagerConfig.prune;

Expand Down
7 changes: 6 additions & 1 deletion packages/api/core/src/util/install-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import debug from 'debug';
import { ExitError } from '@malept/cross-spawn-promise';
import { yarnOrNpmSpawn, hasYarn } from './yarn-or-npm';

const d = debug('electron-forge:dependency-installer');
Expand Down Expand Up @@ -41,6 +42,10 @@ export default async (
stdio: 'pipe',
});
} catch (err) {
throw new Error(`Failed to install modules: ${JSON.stringify(deps)}\n\nWith output: ${err.message}\n${err.stderr ? err.stderr.toString() : ''}`);
if (err instanceof ExitError) {
throw new Error(`Failed to install modules: ${JSON.stringify(deps)}\n\nWith output: ${err.message}\n${err.stderr ? err.stderr.toString() : ''}`);
} else {
throw err;
}
}
};
16 changes: 13 additions & 3 deletions packages/api/core/src/util/require-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import path from 'path';

const d = debug('electron-forge:require-search');

// https://github.com/nodejs/node/blob/da0ede1ad55a502a25b4139f58aab3fb1ee3bf3f/lib/internal/modules/cjs/loader.js#L353-L359
type RequireError = Error & {
code: string;
path: string;
requestPath: string | undefined;
}

export function requireSearchRaw<T>(relativeTo: string, paths: string[]): T | null {
const testPaths = paths
.concat(paths.map((mapPath) => path.resolve(relativeTo, mapPath)))
Expand All @@ -14,9 +21,12 @@ export function requireSearchRaw<T>(relativeTo: string, paths: string[]): T | nu
// eslint-disable-next-line global-require, import/no-dynamic-require
return require(testPath);
} catch (err) {
// Ignore require-related errors
if (err.code !== 'MODULE_NOT_FOUND' || ![undefined, testPath].includes(err.requestPath)) {
throw err;
if (err instanceof Error) {
const requireErr = err as RequireError;
// Ignore require-related errors
if (requireErr.code !== 'MODULE_NOT_FOUND' || ![undefined, testPath].includes(requireErr.requestPath)) {
throw err;
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/api/core/src/util/resolve-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default async (dir: string) => {
try {
await getElectronVersion(mDir, packageJSON);
} catch (err) {
lastError = err.message;
if (err instanceof Error) {
lastError = err.message;
}
}

if (packageJSON.config && packageJSON.config.forge) {
Expand Down
6 changes: 3 additions & 3 deletions packages/publisher/github/src/PublisherGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PublisherBase, { PublisherOptions } from '@electron-forge/publisher-base'
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';

import GitHub from './util/github';
import NoReleaseError from './util/no-release-error';
import { PublisherGitHubConfig } from './Config';

interface GitHubRelease {
Expand Down Expand Up @@ -62,11 +63,10 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
per_page: 100,
})).data.find((testRelease: GitHubRelease) => testRelease.tag_name === `v${releaseName}`);
if (!release) {
// eslint-disable-next-line no-throw-literal
throw { code: 404 };
throw new NoReleaseError(404);
}
} catch (err) {
if (err.code === 404) {
if (err instanceof NoReleaseError && err.code === 404) {
// Release does not exist, let's make it
release = (await github.getGitHub().repos.createRelease({
owner: config.repository.owner,
Expand Down
10 changes: 10 additions & 0 deletions packages/publisher/github/src/util/no-release-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class NoReleaseError extends Error {
code: number;

constructor(code: number) {
super('No GitHub Release found');
this.code = code;
}
}

export { NoReleaseError as default };
4 changes: 2 additions & 2 deletions packages/utils/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import fs from 'fs-extra';
import os from 'os';
import path from 'path';
import { spawn } from '@malept/cross-spawn-promise';
import { ExitError, spawn } from '@malept/cross-spawn-promise';

async function runNPM(dir: string, ...args: string[]) {
await spawn('npm', args, { cwd: dir });
Expand Down Expand Up @@ -31,7 +31,7 @@ export async function expectLintToPass(dir: string) {
try {
await runNPM(dir, 'run', 'lint');
} catch (err) {
if (err.stdout) {
if (err instanceof ExitError) {
// eslint-disable-next-line no-console
console.error('STDOUT:', err.stdout.toString());
// eslint-disable-next-line no-console
Expand Down
1 change: 0 additions & 1 deletion tools/update-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const DO_NOT_UPGRADE = [
'find-up', // Requires ESM
'log-symbols', // Requires ESM
'ora', // Requires ESM
'typescript', // Promisify issues, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49699
'username' // Requires ESM
]

Expand Down
15 changes: 15 additions & 0 deletions typings/sudo-prompt/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PromiseWithChild } from 'child_process';

// Copied from https://github.com/jorangreef/sudo-prompt/pull/124
// TODO: Remove this if/when that PR gets merged/released
declare module 'sudo-prompt' {
namespace exec {
function __promisify__(command: string): PromiseWithChild<{ stdout: string; stderr: string }>
function __promisify__<TBuffer = string | Buffer>(
command: string,
options:
| ((error?: Error, stdout?: TBuffer, stderr?: TBuffer) => void)
| { name?: string; icns?: string; env?: Record<string, string> }
): PromiseWithChild<{ stdout: TBuffer; stderr: TBuffer }>
}
}
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6577,10 +6577,10 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"

marked@^2.1.1:
version "2.1.3"
resolved "https://registry.yarnpkg.com/marked/-/marked-2.1.3.tgz#bd017cef6431724fd4b27e0657f5ceb14bff3753"
integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==
marked@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/marked/-/marked-3.0.2.tgz#60ce97d6aec34dd882ab4bb4df82494666854e17"
integrity sha512-TMJQQ79Z0e3rJYazY0tIoMsFzteUGw9fB3FD+gzuIT3zLuG9L9ckIvUfF51apdJkcqc208jJN2KbtPbOvXtbjA==

matcher@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -8690,10 +8690,10 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==

shiki@^0.9.3:
version "0.9.7"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.9.7.tgz#9c760254798a9bbc6df52bbd26f888486f780079"
integrity sha512-rOoAmwRWDiGKjQ1GaSKmbp1J5CamCera+I+DMM3wG/phbwNYQPt1mrjBBZbK66v80Vl1/A9TTLgXVHMbgtOCIQ==
shiki@^0.9.8:
version "0.9.8"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.9.8.tgz#7dcd1af28c9a7804afb9ee3c3a5ee3987c21e86e"
integrity sha512-499zQUTjcNTVwwiaPrWldUTXIV3T9HZWxDwE82bY+9GE7P2uD6hpHUTXNbTof3iOG6WT+/062+OMbl0lDoG8WQ==
dependencies:
json5 "^2.2.0"
onigasm "^2.2.5"
Expand Down Expand Up @@ -9575,29 +9575,29 @@ typedoc-default-themes@^0.12.10:
integrity sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==

typedoc@^0.21.0:
version "0.21.6"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.21.6.tgz#854bfa2d6b3ac818ac70aa4734a4d1ba93695595"
integrity sha512-+4u3PEBjQdaL5/yfus5WJbjIdQHv7E/FpZq3cNki9BBdGmZhqnTF6JLIXDQ2EfVggojOJG9/soB5QVFgXRYnIw==
version "0.21.9"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.21.9.tgz#6fbdc7152024a00f03af53a0ca40f44e91f0f129"
integrity sha512-VRo7aII4bnYaBBM1lhw4bQFmUcDQV8m8tqgjtc7oXl87jc1Slbhfw2X5MccfcR2YnEClHDWgsiQGgNB8KJXocA==
dependencies:
glob "^7.1.7"
handlebars "^4.7.7"
lunr "^2.3.9"
marked "^2.1.1"
marked "^3.0.2"
minimatch "^3.0.0"
progress "^2.0.3"
shiki "^0.9.3"
shiki "^0.9.8"
typedoc-default-themes "^0.12.10"

typescript@~4.0.2:
version "4.0.8"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.8.tgz#5739105541db80a971fdbd0d56511d1a6f17d37f"
integrity sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg==

typescript@~4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==

typescript@~4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==

uglify-js@^3.1.4:
version "3.14.1"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.14.1.tgz#e2cb9fe34db9cb4cf7e35d1d26dfea28e09a7d06"
Expand Down