-
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.
Bugfix 3752 - Artifacts disappearing when missing integrity file (#4185)
* Add method to update force property * Update install to force script installs when integrity file missing * Update add to force script installs when integrity file missing * Add test case for retaining artifacts after add when missing integrity * Add test case for retaining artifacts after install when missing integrity * Add test fixture data for missing integrity tests * Fix lint errors
- Loading branch information
1 parent
034f461
commit 6bfaac3
Showing
13 changed files
with
107 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -848,6 +848,37 @@ test.concurrent('should only refer to root to satisfy peer dependency', (): Prom | |
); | ||
}); | ||
|
||
test.concurrent('should retain build artifacts after add when missing integrity file', (): Promise<void> => { | ||
return buildRun( | ||
reporters.BufferReporter, | ||
fixturesLoc, | ||
async (args, flags, config, reporter): Promise<void> => { | ||
const lockfile = await createLockfile(config.cwd); | ||
|
||
const addA = new Add(args, flags, config, reporter, lockfile); | ||
await addA.init(); | ||
|
||
const expectedArtifacts = ['foo.txt']; | ||
const integrityLoc = path.join(config.cwd, 'node_modules', constants.INTEGRITY_FILENAME); | ||
|
||
const beforeIntegrity = await fs.readJson(integrityLoc); | ||
expect(beforeIntegrity.artifacts['[email protected]']).toEqual(expectedArtifacts); | ||
|
||
await fs.unlink(integrityLoc); | ||
|
||
const lockfileAfterPreviousAdd = await Lockfile.fromDirectory(config.cwd); | ||
const addB = new Add(['file:b'], flags, config, reporter, lockfileAfterPreviousAdd); | ||
await addB.init(); | ||
|
||
const afterIntegrity = await fs.readJson(integrityLoc); | ||
expect(afterIntegrity.artifacts['[email protected]']).toEqual(expectedArtifacts); | ||
}, | ||
['file:a'], | ||
{}, | ||
'retain-build-artifacts-missing-integrity', | ||
); | ||
}); | ||
|
||
test.concurrent('should retain build artifacts after add', (): Promise<void> => { | ||
return buildRun( | ||
reporters.BufferReporter, | ||
|
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 |
---|---|---|
|
@@ -195,6 +195,24 @@ test.concurrent('install should write and read integrity file based on lockfile | |
}); | ||
}); | ||
|
||
test.concurrent('install should retain artifacts when missing integrity file', (): Promise<void> => { | ||
return runInstall({}, 'install-should-retain-artifacts-when-missing-integrity', async (config, reporter) => { | ||
const expectedArtifacts = ['foo.txt']; | ||
const integrityLoc = path.join(config.cwd, 'node_modules', constants.INTEGRITY_FILENAME); | ||
|
||
const beforeIntegrity = await fs.readJson(integrityLoc); | ||
expect(beforeIntegrity.artifacts['[email protected]']).toEqual(expectedArtifacts); | ||
|
||
await fs.unlink(integrityLoc); | ||
|
||
const reinstall = new Install({}, config, reporter, await Lockfile.fromDirectory(config.cwd)); | ||
await reinstall.init(); | ||
|
||
const afterIntegrity = await fs.readJson(integrityLoc); | ||
expect(afterIntegrity.artifacts['[email protected]']).toEqual(expectedArtifacts); | ||
}); | ||
}); | ||
|
||
test.concurrent('install should not continue if integrity check passes', (): Promise<void> => { | ||
return runInstall({}, 'lockfile-stability', async (config, reporter) => { | ||
await fs.writeFile(path.join(config.cwd, 'node_modules', 'yarn.test'), 'YARN TEST'); | ||
|
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/add/retain-build-artifacts-missing-integrity/a/install.js
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 @@ | ||
require('fs').writeFileSync('foo.txt', 'foobar'); |
7 changes: 7 additions & 0 deletions
7
__tests__/fixtures/add/retain-build-artifacts-missing-integrity/a/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,7 @@ | ||
{ | ||
"name": "a", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"postinstall": "node install.js" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
__tests__/fixtures/add/retain-build-artifacts-missing-integrity/b/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,4 @@ | ||
{ | ||
"name": "b", | ||
"version": "0.0.0" | ||
} |
1 change: 1 addition & 0 deletions
1
__tests__/fixtures/add/retain-build-artifacts-missing-integrity/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 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
...ts__/fixtures/install/install-should-retain-artifacts-when-missing-integrity/a/install.js
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 @@ | ||
require('fs').writeFileSync('foo.txt', 'foobar'); |
7 changes: 7 additions & 0 deletions
7
...__/fixtures/install/install-should-retain-artifacts-when-missing-integrity/a/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,7 @@ | ||
{ | ||
"name": "a", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"postinstall": "node install.js" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...ts__/fixtures/install/install-should-retain-artifacts-when-missing-integrity/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": { | ||
"a": "file:a" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
__tests__/fixtures/install/install-should-retain-artifacts-when-missing-integrity/yarn.lock
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,6 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"a@file:a": | ||
version "0.0.0" |
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
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