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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] - Upgrade flow to 0.75.0 #7856

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flowconfig
Expand Up @@ -21,4 +21,4 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
include_warnings=true

[version]
^0.66.0
^0.75.0
2 changes: 0 additions & 2 deletions __tests__/commands/_helpers.js
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion __tests__/commands/global.js
Expand Up @@ -48,7 +48,9 @@ async function linkAt(config, ...relativePath): Promise<string> {
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] : '';
}
}

Expand Down
4 changes: 3 additions & 1 deletion __tests__/commands/install/bin-links.js
Expand Up @@ -17,7 +17,9 @@ async function linkAt(config, ...relativePath): Promise<string> {
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] : '';
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/import.js
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/cli/commands/install.js
Expand Up @@ -81,6 +81,8 @@ type Flags = {

// add, remove, upgrade
workspaceRootIsCwd: boolean,

offline?: Boolean,
};

/**
Expand Down Expand Up @@ -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'));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

if (this.flags.offline) {
this.reporter.warn(this.reporter.lang('auditOffline'));
return {bailout: false};
Expand Down
1 change: 0 additions & 1 deletion src/cli/commands/publish.js
Expand Up @@ -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'));
Expand Down
1 change: 1 addition & 0 deletions src/cli/index.js
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/config.js
Expand Up @@ -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');
Expand Down Expand Up @@ -70,6 +69,12 @@ export type ConfigOptions = {
focus?: boolean,

otp?: string,

cafile?: string,
ca?: string,
cert?: string,
key?: string,
preferredCacheFolder?: string,
};

type PackageMetadata = {
Expand Down
1 change: 1 addition & 0 deletions src/integrity-checker.js
Expand Up @@ -30,6 +30,7 @@ export type IntegrityCheckResult = {
integrityMatches?: boolean,
integrityError?: IntegrityError,
missingPatterns: Array<string>,
hardRefreshRequired?: boolean,
};

type IntegrityHashLocation = {
Expand Down
4 changes: 3 additions & 1 deletion src/lockfile/parse.js
Expand Up @@ -119,7 +119,9 @@ function* tokenise(input: string): Iterator<Token> {
}
}
} 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);
Expand Down
2 changes: 1 addition & 1 deletion src/registries/index.js
Expand Up @@ -8,7 +8,7 @@ export const registries = {
yarn: YarnRegistry,
};

export const registryNames = Object.keys(registries);
export const registryNames: Array<$Keys<typeof registries>> = Object.keys(registries);

export type RegistryNames = $Keys<typeof registries>;
export type ConfigRegistries = {
Expand Down
1 change: 1 addition & 0 deletions src/reporters/types.js
Expand Up @@ -17,6 +17,7 @@ export type Tree = {
hint?: ?string,
hidden?: boolean,
color?: ?string,
shadow?: ?String,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String should be string

};

export type Trees = Array<Tree>;
Expand Down
3 changes: 2 additions & 1 deletion src/resolvers/base-resolver.js
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/types.js
Expand Up @@ -75,6 +75,7 @@ export type WorkspacesConfig = {
export type Manifest = {
_registry?: ?RegistryNames,
_loc?: ?string,
_integrity?: ?string,

name: string,
version: string,
Expand Down Expand Up @@ -118,6 +119,7 @@ export type Manifest = {
dist?: {
tarball: string,
shasum: string,
integrity?: string,
},

directories?: {
Expand Down Expand Up @@ -169,6 +171,12 @@ export type Manifest = {
fresh?: boolean,

prebuiltVariants?: {[filename: string]: string},

publishConfig?: PublishConfig,
};

export type PublishConfig = {
registry?: string,
};

//
Expand Down
9 changes: 8 additions & 1 deletion src/util/parse-package-name.js
Expand Up @@ -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};
}
4 changes: 1 addition & 3 deletions src/util/request-manager.js
Expand Up @@ -382,9 +382,7 @@ export default class RequestManager {
return false;
}
params.retryAttempts = attempts + 1;
if (typeof params.cleanup === 'function') {
params.cleanup();
}

opts.retryReason = reason;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear whether this was ever used anywhere. I could not find any traces of request-manager having a cleanup function bound to its options, but I'll do one more pass just make sure.

this.queueForRetry(opts);
return true;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -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"
Expand Down