-
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.
Ability to opt-out of offline mirror
Configs are merged with configs in parent directories, so currently if a .yarnrc in a parent directory enables the offline mirror, all projects in child directories would also use the offline mirror. This commit allows a child directory to opt-out of the offline mirror in their own .yarnrc with `yarn-offline-mirror false`. Previously if you specified `false` you'd get an exception as false is parsed as boolean but it expects a string. Also included tests verifying the existing .yarnrc merging behaviour (previously wasn't covered). t14078443
- Loading branch information
Showing
11 changed files
with
61 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ import {run as cache} from '../../../src/cli/commands/cache.js'; | |
import {run as check} from '../../../src/cli/commands/check.js'; | ||
import * as constants from '../../../src/constants.js'; | ||
import * as reporters from '../../../src/reporters/index.js'; | ||
import {parse} from '../../../src/lockfile/wrapper.js'; | ||
import {Install} from '../../../src/cli/commands/install.js'; | ||
import Lockfile from '../../../src/lockfile/wrapper.js'; | ||
import * as fs from '../../../src/util/fs.js'; | ||
|
@@ -809,6 +810,31 @@ test.concurrent('lockfile should be created when missing even if integrity match | |
}); | ||
}); | ||
|
||
test.concurrent('offline mirror can be enabled from parent dir', (): Promise<void> => { | ||
return runInstall({}, 'offline-mirror-configuration/enabled-from-parent', async (config, reporter) => { | ||
const rawLockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
const lockfile = parse(rawLockfile); | ||
expect(lockfile['[email protected]'].resolved).toEqual('mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee'); | ||
}); | ||
}); | ||
|
||
test.concurrent('offline mirror can be enabled from parent dir, with merging of own .yarnrc', (): Promise<void> => { | ||
return runInstall({}, 'offline-mirror-configuration/enabled-from-parent-merge', async (config, reporter) => { | ||
const rawLockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
const lockfile = parse(rawLockfile); | ||
expect(lockfile['[email protected]'].resolved).toEqual('mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee'); | ||
}); | ||
}); | ||
|
||
test.concurrent('offline mirror can be disabled locally', (): Promise<void> => { | ||
return runInstall({}, 'offline-mirror-configuration/disabled-locally', async (config, reporter) => { | ||
const rawLockfile = await fs.readFile(path.join(config.cwd, 'yarn.lock')); | ||
const lockfile = parse(rawLockfile); | ||
expect(lockfile['[email protected]'].resolved) | ||
.toEqual('https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee'); | ||
}); | ||
}); | ||
|
||
test.concurrent('install infers line endings from existing win32 lockfile', async (): Promise<void> => { | ||
await runInstall({}, 'install-infers-line-endings-from-existing-lockfile', | ||
async (config): Promise<void> => { | ||
|
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/install/offline-mirror-configuration/.yarnrc
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 @@ | ||
yarn-offline-mirror "./offline-mirror" |
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/install/offline-mirror-configuration/disabled-locally/.yarnrc
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 @@ | ||
yarn-offline-mirror false |
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/offline-mirror-configuration/disabled-locally/package.json
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"mime-types": "2.1.14" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/install/offline-mirror-configuration/enabled-from-parent-merge/.yarnrc
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 @@ | ||
something else |
5 changes: 5 additions & 0 deletions
5
...ts__/fixtures/install/offline-mirror-configuration/enabled-from-parent-merge/package.json
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"mime-types": "2.1.14" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
__tests__/fixtures/install/offline-mirror-configuration/enabled-from-parent/package.json
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"mime-types": "2.1.14" | ||
} | ||
} |
Binary file added
BIN
+23.5 KB
__tests__/fixtures/install/offline-mirror-configuration/offline-mirror/mime-db-1.27.0.tgz
Binary file not shown.
Binary file added
BIN
+4.41 KB
__tests__/fixtures/install/offline-mirror-configuration/offline-mirror/mime-types-2.1.15.tgz
Binary file not shown.
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