-
Notifications
You must be signed in to change notification settings - Fork 5
feat: enforces that only pinned dependencies should be pinned @W-21064297@ #1606
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d2f1066
1f38c83
2c39146
075da5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,8 +214,10 @@ export class Package extends AsyncOptionalCreatable { | |
| // find dependency in package.json (could be an npm alias) | ||
| const depInfo = this.getDependencyInfo(name, { ...dependencies, ...resolutions, ...jitPlugins }); | ||
|
|
||
| const isPinned: boolean = (this.packageJson.pinnedDependencies ?? []).includes(depInfo.packageName); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I forgot that Example in the sf |
||
|
|
||
| // if a version is not provided, we'll look up the "latest" version | ||
| depInfo.finalVersion = version ?? this.getDistTags(depInfo.packageName).latest; | ||
| depInfo.finalVersion = `${isPinned ? '' : '^'}${version ?? this.getDistTags(depInfo.packageName).latest}`; | ||
|
|
||
| // return if version did not change | ||
| if (depInfo.currentVersion === depInfo.finalVersion) return; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,6 +130,7 @@ describe('Package', () => { | |
| '@salesforce/plugin-config': '1.2.3', | ||
| 'left-pad': '1.1.1', | ||
| }, | ||
| pinnedDependencies: ['left-pad'], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For |
||
| resolutions: { | ||
| '@salesforce/source-deploy-retrieve': '1.0.0', | ||
| }, | ||
|
|
@@ -149,51 +150,66 @@ describe('Package', () => { | |
| }); | ||
| it('should look up latest version if not provided', async () => { | ||
| const pkg = await Package.create(); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config', '@salesforce/jit-me']); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config', '@salesforce/jit-me', 'left-pad']); | ||
|
|
||
| expect(results).to.deep.equal([ | ||
| { | ||
| packageName: '@salesforce/plugin-config', | ||
| currentVersion: '1.2.3', | ||
| finalVersion: '9.9.9', | ||
| // Dependency should be unpinned because it is not listed in `pinnedDependencies` | ||
| finalVersion: '^9.9.9', | ||
| }, | ||
| { | ||
| packageName: '@salesforce/jit-me', | ||
| currentVersion: '1.0.0', | ||
| // Dependency should be unpinned because it is not listed in `pinnedDependencies` | ||
| finalVersion: '^9.9.9', | ||
| }, | ||
| { | ||
| packageName: 'left-pad', | ||
| currentVersion: '1.1.1', | ||
| // Dependency should be pinned because it is listed in `pinnedDependencies` | ||
| finalVersion: '9.9.9', | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should used passed in version', async () => { | ||
| const pkg = await Package.create(); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config@11.0.0']); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config@11.0.0', 'left-pad@11.0.0']); | ||
|
|
||
| expect(results).to.deep.equal([ | ||
| { | ||
| packageName: '@salesforce/plugin-config', | ||
| currentVersion: '1.2.3', | ||
| // Dependency should be unpinned because it's not in `pinnedDependencies` | ||
| finalVersion: '^11.0.0', | ||
| }, | ||
| { | ||
| packageName: 'left-pad', | ||
| currentVersion: '1.1.1', | ||
| // Dependency should be pinned because it's in `pinnedDependencies` | ||
| finalVersion: '11.0.0', | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should work with non-namespaced package', async () => { | ||
| it('should unpin a pinned version even if it is already up-to-date', async () => { | ||
| const pkg = await Package.create(); | ||
| const results = pkg.bumpDependencyVersions(['left-pad']); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config@1.2.3']); | ||
|
|
||
| expect(results).to.deep.equal([ | ||
| { | ||
| packageName: 'left-pad', | ||
| currentVersion: '1.1.1', | ||
| finalVersion: '9.9.9', | ||
| packageName: '@salesforce/plugin-config', | ||
| currentVersion: '1.2.3', | ||
| finalVersion: '^1.2.3', | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should return an empty array if all versions are already up to date', async () => { | ||
| it('should return an empty array if all bumped versions are already up to date', async () => { | ||
| const pkg = await Package.create(); | ||
| const results = pkg.bumpDependencyVersions(['@salesforce/plugin-config@1.2.3']); | ||
| const results = pkg.bumpDependencyVersions(['left-pad@1.1.1']); | ||
|
|
||
| expect(results).to.deep.equal([]); | ||
| }); | ||
|
|
@@ -202,21 +218,21 @@ describe('Package', () => { | |
| const pkg = await Package.create(); | ||
| pkg.bumpDependencyVersions(['@salesforce/plugin-config@3.3.3']); | ||
|
|
||
| expect(pkg.packageJson.dependencies['@salesforce/plugin-config']).to.equal('3.3.3'); | ||
| expect(pkg.packageJson.dependencies['@salesforce/plugin-config']).to.equal('^3.3.3'); | ||
| }); | ||
|
|
||
| it('should update resolutions in package.json', async () => { | ||
| const pkg = await Package.create(); | ||
| pkg.bumpDependencyVersions(['@salesforce/source-deploy-retrieve@1.0.1']); | ||
| assert(pkg.packageJson.resolutions); | ||
| expect(pkg.packageJson.resolutions['@salesforce/source-deploy-retrieve']).to.equal('1.0.1'); | ||
| expect(pkg.packageJson.resolutions['@salesforce/source-deploy-retrieve']).to.equal('^1.0.1'); | ||
| }); | ||
|
|
||
| it('should update jit in package.json', async () => { | ||
| const pkg = await Package.create(); | ||
| pkg.bumpDependencyVersions(['@salesforce/jit-me@1.0.1']); | ||
| assert(pkg.packageJson.oclif?.jitPlugins); | ||
| expect(pkg.packageJson.oclif.jitPlugins['@salesforce/jit-me']).to.equal('1.0.1'); | ||
| expect(pkg.packageJson.oclif.jitPlugins['@salesforce/jit-me']).to.equal('^1.0.1'); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.