-
Notifications
You must be signed in to change notification settings - Fork 937
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Proposed Changes - `bit install --update` updates all dependencies (direct and indirect). Existing semver ranges are respected. - Newly installed dependency are saved in `workspace.jsonc` with the `^` prefix by default.
- Loading branch information
Showing
11 changed files
with
170 additions
and
16 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
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,5 +1,6 @@ | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import { addDistTag } from '@pnpm/registry-mock'; | ||
import { IssuesClasses } from '@teambit/component-issues'; | ||
import { expect } from 'chai'; | ||
import Helper from '../../src/e2e-helper/e2e-helper'; | ||
|
@@ -65,3 +66,119 @@ describe('install command', function () { | |
}); | ||
}); | ||
}); | ||
|
||
(supportNpmCiRegistryTesting ? describe : describe.skip)('install --update', function () { | ||
this.timeout(0); | ||
let helper: Helper; | ||
describe('using pnpm', () => { | ||
let npmCiRegistry: NpmCiRegistry; | ||
before(async () => { | ||
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } }); | ||
helper.scopeHelper.setNewLocalAndRemoteScopes(); | ||
helper.bitJsonc.setPackageManager(`teambit.dependencies/pnpm`); | ||
npmCiRegistry = new NpmCiRegistry(helper); | ||
await npmCiRegistry.init(); | ||
|
||
helper.command.setConfig('registry', npmCiRegistry.getRegistryUrl()); | ||
await addDistTag({ package: '@pnpm.e2e/pkg-with-1-dep', version: '100.0.0', distTag: 'latest' }); | ||
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' }); | ||
helper.command.install('@pnpm.e2e/dep-of-pkg-with-1-dep @pnpm.e2e/parent-of-pkg-with-1-dep'); | ||
await addDistTag({ package: '@pnpm.e2e/pkg-with-1-dep', version: '100.1.0', distTag: 'latest' }); | ||
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '101.0.0', distTag: 'latest' }); | ||
helper.command.install('--update'); | ||
}); | ||
after(() => { | ||
helper.command.delConfig('registry'); | ||
npmCiRegistry.destroy(); | ||
helper.scopeHelper.destroy(); | ||
}); | ||
it('should update direct dependency inside existing range', async () => { | ||
const manifest = fs.readJSONSync( | ||
path.join(helper.fixtures.scopes.localPath, 'node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep/package.json') | ||
); | ||
expect(manifest.version).to.eq('100.1.0'); | ||
}); | ||
it('should update subdependency inside existing range', async () => { | ||
const dirs = fs.readdirSync(path.join(helper.fixtures.scopes.localPath, 'node_modules/.pnpm')); | ||
expect(dirs).to.include('@[email protected]'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('install new dependencies', function () { | ||
this.timeout(0); | ||
let helper: Helper; | ||
let bitJsonc; | ||
describe('using pnpm', () => { | ||
before(() => { | ||
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } }); | ||
helper.scopeHelper.setNewLocalAndRemoteScopes(); | ||
helper.extensions.bitJsonc.setPackageManager('teambit.dependencies/pnpm'); | ||
helper.command.install('is-positive@~1.0.0 [email protected] is-even@1 is-negative'); | ||
bitJsonc = helper.bitJsonc.read(); | ||
}); | ||
after(() => { | ||
helper.scopeHelper.destroy(); | ||
}); | ||
it('should add new dependency preserving the ~ prefix', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-positive']).to.equal( | ||
'~1.0.0' | ||
); | ||
}); | ||
it('should add new dependency with ^ prefix if the dependency was installed by specifying the exact version', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-odd']).to.equal('^1.0.0'); | ||
}); | ||
it('should add new dependency with ^ prefix if the dependency was installed by specifying a range not using ~', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-even']).to.equal('^1.0.0'); | ||
}); | ||
it('should add new dependency with ^ prefix by default', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-negative'][0]).to.equal('^'); | ||
}); | ||
}); | ||
describe('using yarn', () => { | ||
before(() => { | ||
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } }); | ||
helper.scopeHelper.setNewLocalAndRemoteScopes(); | ||
helper.extensions.bitJsonc.setPackageManager('teambit.dependencies/yarn'); | ||
helper.command.install('is-positive@~1.0.0 [email protected] is-even@1 is-negative'); | ||
bitJsonc = helper.bitJsonc.read(); | ||
}); | ||
after(() => { | ||
helper.scopeHelper.destroy(); | ||
}); | ||
it('should add new dependency preserving the ~ prefix', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-positive']).to.equal( | ||
'~1.0.0' | ||
); | ||
}); | ||
it('should add new dependency with ^ prefix if the dependency was installed by specifying the exact version', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-odd']).to.equal('^1.0.0'); | ||
}); | ||
it('should add new dependency with ^ prefix if the dependency was installed by specifying a range not using ~', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-even']).to.equal('^1.0.0'); | ||
}); | ||
it('should add new dependency with ^ prefix by default', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-negative'][0]).to.equal('^'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('named install', function () { | ||
this.timeout(0); | ||
let helper: Helper; | ||
let bitJsonc; | ||
before(() => { | ||
helper = new Helper({ scopesOptions: { remoteScopeWithDot: true } }); | ||
helper.scopeHelper.setNewLocalAndRemoteScopes(); | ||
helper.extensions.bitJsonc.setPackageManager('teambit.dependencies/pnpm'); | ||
helper.command.install('[email protected]'); | ||
helper.command.install('is-positive'); | ||
bitJsonc = helper.bitJsonc.read(); | ||
}); | ||
after(() => { | ||
helper.scopeHelper.destroy(); | ||
}); | ||
it('should override already existing dependency with the latest version', () => { | ||
expect(bitJsonc['teambit.dependencies/dependency-resolver'].policy.dependencies['is-positive']).to.equal('^3.1.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
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
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