-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into npm4-prepublish
* master: (66 commits) Add --no-bin-links flag - fixes #929 (#1651) Add option to change the prefix of the global bin folder - fixes #630 (#1654) patterns -> filteredPatterns Add helpful nudge to yarnpkg/rfcs on issue template (#1650) Change reporter.log to console.log in generate-lock-entry command - fixes #644 (#1652) Fixed add command flag (#1653) Nested executables fix (#1210) Added short-flags for yarn add (#1618) Add name lookups to ls command - fixes #1599 (#1643) Disable flaky secureUrl test (#1644) Add unit tests for `yarn why`. (#1544) Refine flow type for config.generateHardModulePath (#1642) Use ~/Library/Caches as default cache location on OSX - fixes #1637 (#1638) Update aliases.js (#1635) Update aliases.js (#1634) Add webhook to archive AppVeyor build artifacts (#1631) Attempt to fix failing Circle CI builds (#1629) Adding 'yarn global upgrade'(Issue #776) (#1616) Show error message in stdout. (#1502) Nicer permission errors when trying to write global binaries - fixes #1578 (#1592) ...
- Loading branch information
Showing
146 changed files
with
3,319 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ test/fixtures/**/.fbkpm | |
|
||
# IDE | ||
.idea/ | ||
/__tests__/fixtures/request-cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
exports[`test TarballFetcher.fetch throws on invalid hash 1`] = `"https://github.com/sindresorhus/beeper/archive/master.tar.gz: Bad hash. Expected foo but got a32262ca1e22a3746b970936d3944b4bfd6cb9e9 "`; | ||
exports[`test TarballFetcher.fetch throws on invalid hash 1`] = `"https://github.com/sindresorhus/beeper/archive/master.tar.gz: Bad hash. Expected \"foo\" but got \"a32262ca1e22a3746b970936d3944b4bfd6cb9e9\" "`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* @flow */ | ||
|
||
import {run as uninstall} from '../../src/cli/commands/remove.js'; | ||
import {run as check} from '../../src/cli/commands/check.js'; | ||
import * as reporters from '../../src/reporters/index.js'; | ||
import {Install} from '../../src/cli/commands/install.js'; | ||
|
@@ -114,6 +113,10 @@ test.concurrent('install from offline mirror', (): Promise<void> => { | |
assert(allFiles.findIndex((file): boolean => { | ||
return file.relative === path.join('node_modules', 'fake-dependency', 'package.json'); | ||
}) !== -1); | ||
|
||
assert(allFiles.findIndex((file): boolean => { | ||
return file.relative === path.join('node_modules', '@fakescope', 'fake-dependency', 'package.json'); | ||
}) !== -1); | ||
}); | ||
}); | ||
|
||
|
@@ -385,104 +388,6 @@ test.concurrent( | |
}, | ||
); | ||
|
||
test.concurrent( | ||
'uninstall should remove dependency from package.json, yarn.lock and node_modules', | ||
(): Promise<void> => { | ||
const mirrorPath = 'mirror-for-offline'; | ||
|
||
return runInstall({}, 'uninstall-should-clean', async (config, reporter) => { | ||
assert.equal( | ||
await getPackageVersion(config, 'dep-a'), | ||
'1.0.0', | ||
); | ||
|
||
await fs.copy(path.join(config.cwd, 'yarn.lock'), path.join(config.cwd, 'yarn.lock.orig')); | ||
await fs.copy(path.join(config.cwd, 'package.json'), path.join(config.cwd, 'package.json.orig')); | ||
|
||
try { | ||
await uninstall(config, reporter, {}, ['dep-a']); | ||
|
||
assert(!await fs.exists(path.join(config.cwd, 'node_modules/dep-a'))); | ||
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-a-1.0.0.tgz`))); | ||
|
||
assert.deepEqual( | ||
JSON.parse(await fs.readFile(path.join(config.cwd, 'package.json'))).dependencies, | ||
{}, | ||
); | ||
|
||
const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
const lockFileLines = explodeLockfile(lockFileContent); | ||
assert.equal(lockFileLines.length, 0); | ||
} finally { | ||
await fs.unlink(path.join(config.cwd, 'yarn.lock')); | ||
await fs.unlink(path.join(config.cwd, 'package.json')); | ||
await fs.copy(path.join(config.cwd, 'yarn.lock.orig'), path.join(config.cwd, 'yarn.lock')); | ||
await fs.copy(path.join(config.cwd, 'package.json.orig'), path.join(config.cwd, 'package.json')); | ||
await fs.unlink(path.join(config.cwd, 'yarn.lock.orig')); | ||
await fs.unlink(path.join(config.cwd, 'package.json.orig')); | ||
} | ||
}); | ||
}, | ||
); | ||
|
||
test.concurrent('uninstall should remove subdependencies', (): Promise<void> => { | ||
// A@1 -> B@1 | ||
// C@1 | ||
|
||
// remove A | ||
|
||
// C@1 | ||
|
||
const mirrorPath = 'mirror-for-offline'; | ||
|
||
return runInstall({}, 'uninstall-should-remove-subdependencies', async (config, reporter) => { | ||
try { | ||
assert.equal( | ||
await getPackageVersion(config, 'dep-a'), | ||
'1.0.0', | ||
); | ||
assert.equal( | ||
await getPackageVersion(config, 'dep-b'), | ||
'1.0.0', | ||
); | ||
assert.equal( | ||
await getPackageVersion(config, 'dep-c'), | ||
'1.0.0', | ||
); | ||
|
||
await fs.copy(path.join(config.cwd, 'yarn.lock'), path.join(config.cwd, 'yarn.lock.orig')); | ||
await fs.copy(path.join(config.cwd, 'package.json'), path.join(config.cwd, 'package.json.orig')); | ||
|
||
await uninstall(config, reporter, {}, ['dep-a']); | ||
|
||
assert(!await fs.exists(path.join(config.cwd, 'node_modules/dep-a'))); | ||
assert(!await fs.exists(path.join(config.cwd, 'node_modules/dep-b'))); | ||
assert(await fs.exists(path.join(config.cwd, 'node_modules/dep-c'))); | ||
|
||
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-a-1.0.0.tgz`))); | ||
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-b-1.0.0.tgz`))); | ||
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-c-1.0.0.tgz`))); | ||
|
||
assert.deepEqual( | ||
JSON.parse(await fs.readFile(path.join(config.cwd, 'package.json'))).dependencies, | ||
{'dep-c': '^1.0.0'}, | ||
); | ||
|
||
const lockFileContent = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
const lockFileLines = explodeLockfile(lockFileContent); | ||
assert.equal(lockFileLines.length, 3); | ||
assert.equal(lockFileLines[0], 'dep-c@^1.0.0:'); | ||
} finally { | ||
await fs.unlink(path.join(config.cwd, 'yarn.lock')); | ||
await fs.unlink(path.join(config.cwd, 'package.json')); | ||
await fs.copy(path.join(config.cwd, 'yarn.lock.orig'), path.join(config.cwd, 'yarn.lock')); | ||
await fs.copy(path.join(config.cwd, 'package.json.orig'), path.join(config.cwd, 'package.json')); | ||
await fs.unlink(path.join(config.cwd, 'yarn.lock.orig')); | ||
await fs.unlink(path.join(config.cwd, 'package.json.orig')); | ||
} | ||
}); | ||
}); | ||
|
||
test.concurrent('check should verify that top level dependencies are installed correctly', (): Promise<void> => { | ||
return runInstall({}, 'check-top-correct', async (config, reporter) => { | ||
|
||
|
@@ -614,6 +519,14 @@ test.concurrent( | |
}, | ||
); | ||
|
||
test.concurrent('install should hoist nested bin scripts', (): Promise<void> => { | ||
return runInstall({}, 'install-nested-bin', async (config) => { | ||
const binScripts = await fs.walk(path.join(config.cwd, 'node_modules', '.bin')); | ||
assert.equal(binScripts.length, 10); | ||
assert(binScripts.findIndex((f) => f.basename === 'eslint') > -1); | ||
}); | ||
}); | ||
|
||
|
||
xit('install should update a dependency to yarn and mirror (PR import scenario 2)', (): Promise<void> => { | ||
// [email protected] is saved in local mirror and gets updated to [email protected] via | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* @flow */ | ||
|
||
import {Reporter} from '../../src/reporters/index.js'; | ||
import {run as outdated} from '../../src/cli/commands/outdated.js'; | ||
import * as fs from '../../src/util/fs.js'; | ||
import * as reporters from '../../src/reporters/index.js'; | ||
import Config from '../../src/config.js'; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; | ||
|
||
const stream = require('stream'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'outdated'); | ||
|
||
async function runOutdated( | ||
flags: Object, | ||
args: Array<string>, | ||
name: string, | ||
checkOutdated?: ?(config: Config, reporter: Reporter, out: string) => ?Promise<void>, | ||
): Promise<void> { | ||
const dir = path.join(fixturesLoc, name); | ||
const cwd = path.join( | ||
os.tmpdir(), | ||
`yarn-${path.basename(dir)}-${Math.random()}`, | ||
); | ||
await fs.unlink(cwd); | ||
await fs.copy(dir, cwd); | ||
|
||
for (const {basename, absolute} of await fs.walk(cwd)) { | ||
if (basename.toLowerCase() === '.ds_store') { | ||
await fs.unlink(absolute); | ||
} | ||
} | ||
|
||
let out = ''; | ||
const stdout = new stream.Writable({ | ||
decodeStrings: false, | ||
write(data, encoding, cb) { | ||
out += data; | ||
cb(); | ||
}, | ||
}); | ||
|
||
const reporter = new reporters.JSONReporter({stdout}); | ||
|
||
// create directories | ||
await fs.mkdirp(path.join(cwd, '.yarn')); | ||
await fs.mkdirp(path.join(cwd, 'node_modules')); | ||
|
||
try { | ||
const config = new Config(reporter); | ||
await config.init({ | ||
cwd, | ||
globalFolder: path.join(cwd, '.yarn/.global'), | ||
cacheFolder: path.join(cwd, '.yarn'), | ||
linkFolder: path.join(cwd, '.yarn/.link'), | ||
}); | ||
|
||
await outdated(config, reporter, flags, args); | ||
|
||
if (checkOutdated) { | ||
await checkOutdated(config, reporter, out); | ||
} | ||
|
||
} catch (err) { | ||
throw new Error(`${err && err.stack} \nConsole output:\n ${out}`); | ||
} | ||
} | ||
|
||
test.concurrent('throws if lockfile is out of date', (): Promise<void> => { | ||
const reporter = new reporters.ConsoleReporter({}); | ||
|
||
return new Promise(async (resolve) => { | ||
try { | ||
await runOutdated({}, [], 'lockfile-outdated'); | ||
} catch (err) { | ||
expect(err.message).toContain(reporter.lang('lockfileOutdated')); | ||
} finally { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
test.concurrent('no output when current matches latest', (): Promise<void> => { | ||
return runOutdated({}, [], 'current-is-latest', (config, reporter, out): ?Promise<void> => { | ||
expect(out).toBe(''); | ||
}); | ||
}); | ||
|
||
test.concurrent('works with no arguments', (): Promise<void> => { | ||
return runOutdated({}, [], 'no-args', (config, reporter, out): ?Promise<void> => { | ||
const json: Object = JSON.parse(out); | ||
|
||
expect(json.data.body.length).toBe(1); | ||
}); | ||
}); | ||
|
||
test.concurrent('works with single argument', (): Promise<void> => { | ||
return runOutdated({}, ['max-safe-integer'], 'single-package', (config, reporter, out): ?Promise<void> => { | ||
const json: Object = JSON.parse(out); | ||
|
||
expect(json.data.body.length).toBe(1); | ||
expect(json.data.body[0][0]).toBe('max-safe-integer'); | ||
}); | ||
}); | ||
|
||
test.concurrent('works with multiple arguments', (): Promise<void> => { | ||
return runOutdated({}, ['left-pad', 'max-safe-integer'], 'multiple-packages', | ||
(config, reporter, out): ?Promise<void> => { | ||
const json: Object = JSON.parse(out); | ||
|
||
expect(json.data.body.length).toBe(2); | ||
expect(json.data.body[0][0]).toBe('left-pad'); | ||
expect(json.data.body[1][0]).toBe('max-safe-integer'); | ||
}, | ||
); | ||
}); | ||
|
||
test.concurrent('works with exotic resolvers', (): Promise<void> => { | ||
return runOutdated({}, [], 'exotic-resolvers', | ||
(config, reporter, out): ?Promise<void> => { | ||
const json: Object = JSON.parse(out); | ||
const first = ['max-safe-integer', '1.0.1', 'exotic', 'exotic', null]; | ||
const second = ['yarn', '0.16.2', 'exotic', 'exotic', null]; | ||
|
||
expect(json.data.body.length).toBe(2); | ||
expect(json.data.body[0]).toEqual(first); | ||
expect(json.data.body[1]).toEqual(second); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.