From 5235c5b955a940b513d0aefc12c8b8e0ed9d2cfe Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 00:08:44 +0900 Subject: [PATCH 01/16] Fix 'An indexer property is missing in null' error --- src/util/parse-package-name.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/parse-package-name.js b/src/util/parse-package-name.js index 43b1a39020..191b85207e 100644 --- a/src/util/parse-package-name.js +++ b/src/util/parse-package-name.js @@ -8,6 +8,13 @@ type PackageInput = { const PKG_INPUT = /(^\S?[^\s@]+)(?:@(\S+))?$/; export default function parsePackageName(input: string): PackageInput { - const [, name, version] = PKG_INPUT.exec(input); + const pkgInputMatches = PKG_INPUT.exec(input); + let name = ''; + let version = ''; + + if (pkgInputMatches !== null && pkgInputMatches.length >= 3) { + name = pkgInputMatches[1]; + version = pkgInputMatches[2]; + } return {name, version}; } From a996560a287e722c24d1bdb3b939dc89974f4a00 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 01:03:54 +0900 Subject: [PATCH 02/16] upgrade flow --- .flowconfig | 2 +- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.flowconfig b/.flowconfig index c777bb6ddb..ab0b1690ac 100644 --- a/.flowconfig +++ b/.flowconfig @@ -21,4 +21,4 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe include_warnings=true [version] -^0.66.0 +^0.75.0 diff --git a/package.json b/package.json index da8e4e9d80..4471c16617 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "eslint-plugin-yarn-internal": "file:scripts/eslint-rules", "execa": "^0.11.0", "fancy-log": "^1.3.2", - "flow-bin": "^0.66.0", + "flow-bin": "^0.75.0", "git-release-notes": "^3.0.0", "gulp": "^4.0.0", "gulp-babel": "^7.0.0", diff --git a/yarn.lock b/yarn.lock index fe1b1cd3f8..4eab89f5ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3125,10 +3125,10 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flow-bin@^0.66.0: - version "0.66.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26" - integrity sha1-qW3ecBXcM0P9VSp7SWPAK+cFyiY= +flow-bin@^0.75.0: + version "0.75.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.75.0.tgz#b96d1ee99d3b446a3226be66b4013224ce9df260" + integrity sha1-uW0e6Z07RGoyJr5mtAEyJM6d8mA= flush-write-stream@^1.0.2: version "1.0.3" From b954764b2f4fd4e863ba9a9c2600fff2ccaf941f Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 01:52:01 +0900 Subject: [PATCH 03/16] fix indexer property missing on null --- __tests__/commands/global.js | 4 +++- __tests__/commands/install/bin-links.js | 4 +++- src/lockfile/parse.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/__tests__/commands/global.js b/__tests__/commands/global.js index 269351f95c..5ad03b6d44 100644 --- a/__tests__/commands/global.js +++ b/__tests__/commands/global.js @@ -48,7 +48,9 @@ async function linkAt(config, ...relativePath): Promise { return linkPath; } else { const contents = await fs.readFile(joinedPath); - return /node" +"\$basedir\/([^"]*\.js)"/.exec(contents)[1]; + const matchResult = /node" +"\$basedir\/([^"]*\.js)"/.exec(contents); + + return matchResult !== null && matchResult.length >= 1 ? matchResult[1] : ''; } } diff --git a/__tests__/commands/install/bin-links.js b/__tests__/commands/install/bin-links.js index aa6cb8a00f..a5341223ab 100644 --- a/__tests__/commands/install/bin-links.js +++ b/__tests__/commands/install/bin-links.js @@ -17,7 +17,9 @@ async function linkAt(config, ...relativePath): Promise { return linkPath; } else { const contents = await fs.readFile(joinedPath); - return /node" +"\$basedir\/([^"]*\.js)"/.exec(contents)[1]; + const matchResult = /node" +"\$basedir\/([^"]*\.js)"/.exec(contents); + + return matchResult !== null && matchResult.length >= 1 ? matchResult[1] : ''; } } diff --git a/src/lockfile/parse.js b/src/lockfile/parse.js index d5c089c9c6..ce8ef76d77 100644 --- a/src/lockfile/parse.js +++ b/src/lockfile/parse.js @@ -119,7 +119,9 @@ function* tokenise(input: string): Iterator { } } } else if (/^[0-9]/.test(input)) { - const val = /^[0-9]+/.exec(input)[0]; + const matchResult = /^[0-9]+/.exec(input); + const val = matchResult === null ? '' : matchResult[0]; + chop = val.length; yield buildToken(TOKEN_TYPES.number, +val); From 40addc6b74718025909eeb5b298f5cc363da8969 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 09:51:17 +0900 Subject: [PATCH 04/16] add missing types --- src/config.js | 6 ++++++ src/types.js | 1 + 2 files changed, 7 insertions(+) diff --git a/src/config.js b/src/config.js index caf3d247af..0987d846fe 100644 --- a/src/config.js +++ b/src/config.js @@ -70,6 +70,12 @@ export type ConfigOptions = { focus?: boolean, otp?: string, + + cafile?: string, + ca?: string, + cert?: string, + key?: string, + preferredCacheFolder?: string, }; type PackageMetadata = { diff --git a/src/types.js b/src/types.js index f776508c5f..80bd734eb9 100644 --- a/src/types.js +++ b/src/types.js @@ -118,6 +118,7 @@ export type Manifest = { dist?: { tarball: string, shasum: string, + integrity?: string, }, directories?: { From e0ae6d90bd846cbe79361f5d8821c6e2a39771f6 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 09:51:29 +0900 Subject: [PATCH 05/16] remove unused lib --- src/config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.js b/src/config.js index 0987d846fe..309de2564e 100644 --- a/src/config.js +++ b/src/config.js @@ -17,7 +17,6 @@ import {registries, registryNames} from './registries/index.js'; import {NoopReporter} from './reporters/index.js'; import map from './util/map.js'; -const crypto = require('crypto'); const detectIndent = require('detect-indent'); const invariant = require('invariant'); const path = require('path'); From b29ccc435bc15786176b70515a5759007f935d5a Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:34:55 +0900 Subject: [PATCH 06/16] remove flowfixme's --- __tests__/commands/_helpers.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/__tests__/commands/_helpers.js b/__tests__/commands/_helpers.js index a216a477dd..c33509033c 100644 --- a/__tests__/commands/_helpers.js +++ b/__tests__/commands/_helpers.js @@ -17,7 +17,6 @@ const path = require('path'); const installFixturesLoc = path.join(__dirname, '..', 'fixtures', 'install'); -// $FlowFixMe I don't understand the error export const runInstall = run.bind( null, ConsoleReporter, @@ -34,7 +33,6 @@ export const runInstall = run.bind( const linkFixturesLoc = path.join(__dirname, '..', 'fixtures', 'link'); -// $FlowFixMe I don't understand the error export const runLink = run.bind( null, ConsoleReporter, From 2d4e4e103a15a0d3f5a2b3ac20a2b4346d170e96 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:35:31 +0900 Subject: [PATCH 07/16] add hardRefreshRequired to IntegrityCheckResult --- src/integrity-checker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/integrity-checker.js b/src/integrity-checker.js index c1f7500d26..0c02b411f8 100644 --- a/src/integrity-checker.js +++ b/src/integrity-checker.js @@ -30,6 +30,7 @@ export type IntegrityCheckResult = { integrityMatches?: boolean, integrityError?: IntegrityError, missingPatterns: Array, + hardRefreshRequired?: boolean, }; type IntegrityHashLocation = { From a0ba7170aa5af6ef4c7b75d40510bca44c6a218d Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:36:43 +0900 Subject: [PATCH 08/16] add _integrity and PublishConfig to Manifest --- src/types.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types.js b/src/types.js index 80bd734eb9..ff33fb8e71 100644 --- a/src/types.js +++ b/src/types.js @@ -75,6 +75,7 @@ export type WorkspacesConfig = { export type Manifest = { _registry?: ?RegistryNames, _loc?: ?string, + _integrity?: ?string, name: string, version: string, @@ -170,6 +171,12 @@ export type Manifest = { fresh?: boolean, prebuiltVariants?: {[filename: string]: string}, + + publishConfig?: PublishConfig, +}; + +export type PublishConfig = { + registry?: string, }; // From 98b425f52697fda85c51ef6067288f28a73b3e89 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:37:17 +0900 Subject: [PATCH 09/16] add FlowFixMe for process._getActiveHandles --- src/cli/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli/index.js b/src/cli/index.js index f86454a57a..38e7058799 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -395,6 +395,7 @@ export async function main({ // If the process hasn't exited in the next 5s, it has stalled and we abort const timeout = setTimeout(() => { console.error('Process stalled'); + // $FlowFixMe: _getActiveHandles does exist on process if (process._getActiveHandles) { console.error('Active handles:'); // $FlowFixMe: getActiveHandles is undocumented, but it exists From 9c2c1f3d92d72f34c712e97987134b0d0d7ac936 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:38:25 +0900 Subject: [PATCH 10/16] Fix issue where request does not have dependencyTree instance --- src/cli/commands/import.js | 2 +- src/resolvers/base-resolver.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/commands/import.js b/src/cli/commands/import.js index 049e35518d..d15da63f4f 100644 --- a/src/cli/commands/import.js +++ b/src/cli/commands/import.js @@ -209,7 +209,7 @@ class ImportResolver extends BaseResolver { } } -class ImportPackageRequest extends PackageRequest { +export class ImportPackageRequest extends PackageRequest { constructor(req: DependencyRequestPattern, dependencyTree: ?LogicalDependencyTree, resolver: PackageResolver) { super(req, resolver); this.import = this.parentRequest instanceof ImportPackageRequest ? this.parentRequest.import : true; diff --git a/src/resolvers/base-resolver.js b/src/resolvers/base-resolver.js index fb0dd7596d..5ddf0ddcc2 100644 --- a/src/resolvers/base-resolver.js +++ b/src/resolvers/base-resolver.js @@ -6,6 +6,7 @@ import type {Manifest} from '../types.js'; import type {RegistryNames} from '../registries/index.js'; import type {Reporter} from '../reporters/index.js'; import type Config from '../config.js'; +import {ImportPackageRequest} from '../cli/commands/import'; export default class BaseResolver { constructor(request: PackageRequest, fragment: string) { @@ -22,7 +23,7 @@ export default class BaseResolver { resolver: PackageResolver; reporter: Reporter; fragment: string; - request: PackageRequest; + request: PackageRequest | ImportPackageRequest; pattern: string; config: Config; registry: RegistryNames; From dadc4c65e58cda32088425d02c50c4f35447d508 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:38:43 +0900 Subject: [PATCH 11/16] add shadow optional type to Tree --- src/reporters/types.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/reporters/types.js b/src/reporters/types.js index 2e62e79007..1d09ae9b08 100644 --- a/src/reporters/types.js +++ b/src/reporters/types.js @@ -17,6 +17,7 @@ export type Tree = { hint?: ?string, hidden?: boolean, color?: ?string, + shadow?: ?String, }; export type Trees = Array; From 7c1a54bc9b76d1bd34031fabd818877f0614e2c4 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:39:46 +0900 Subject: [PATCH 12/16] set registryNames as Array of registries' keys to avoid indexer issue --- src/registries/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registries/index.js b/src/registries/index.js index b6c63677e2..2d5d221152 100644 --- a/src/registries/index.js +++ b/src/registries/index.js @@ -8,7 +8,7 @@ export const registries = { yarn: YarnRegistry, }; -export const registryNames = Object.keys(registries); +export const registryNames: Array<$Keys> = Object.keys(registries); export type RegistryNames = $Keys; export type ConfigRegistries = { From feb96eaacb0856ddbcb9916ecddfc6e115f245c1 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:40:04 +0900 Subject: [PATCH 13/16] add optional offline type to install flags --- src/cli/commands/install.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli/commands/install.js b/src/cli/commands/install.js index bbe044fc35..881f06958e 100644 --- a/src/cli/commands/install.js +++ b/src/cli/commands/install.js @@ -81,6 +81,8 @@ type Flags = { // add, remove, upgrade workspaceRootIsCwd: boolean, + + offline?: Boolean, }; /** @@ -610,6 +612,7 @@ export class Install { steps.push((curr: number, total: number) => callThroughHook('auditStep', async () => { this.reporter.step(curr, total, this.reporter.lang('auditRunning'), emoji.get('mag')); + if (this.flags.offline) { this.reporter.warn(this.reporter.lang('auditOffline')); return {bailout: false}; From c5d387ec9d93bae38015255e6a917247c7d50b0e Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:40:21 +0900 Subject: [PATCH 14/16] remove unneeded flowfixme --- src/cli/commands/publish.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cli/commands/publish.js b/src/cli/commands/publish.js index b64297b0ef..87c7552ac2 100644 --- a/src/cli/commands/publish.js +++ b/src/cli/commands/publish.js @@ -141,7 +141,6 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg } // validate package fields that are required for publishing - // $FlowFixMe const pkg = await config.readRootManifest(); if (pkg.private) { throw new MessageError(reporter.lang('publishPrivate')); From 1406b8f799422ce22aed6567f54ec4b7bff37934 Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:41:06 +0900 Subject: [PATCH 15/16] remove unused cleanup function --- src/util/request-manager.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/request-manager.js b/src/util/request-manager.js index 8756139f14..4672b7d03c 100644 --- a/src/util/request-manager.js +++ b/src/util/request-manager.js @@ -382,9 +382,7 @@ export default class RequestManager { return false; } params.retryAttempts = attempts + 1; - if (typeof params.cleanup === 'function') { - params.cleanup(); - } + opts.retryReason = reason; this.queueForRetry(opts); return true; From ed2d6401441baa8c74a25fe57202877056b983fe Mon Sep 17 00:00:00 2001 From: Nick Olinger Date: Thu, 30 Jan 2020 11:54:19 +0900 Subject: [PATCH 16/16] yarn prettier --- src/util/request-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/request-manager.js b/src/util/request-manager.js index 4672b7d03c..49ced74377 100644 --- a/src/util/request-manager.js +++ b/src/util/request-manager.js @@ -382,7 +382,7 @@ export default class RequestManager { return false; } params.retryAttempts = attempts + 1; - + opts.retryReason = reason; this.queueForRetry(opts); return true;