Skip to content

Commit

Permalink
Support NPM Enterprise URLs in offline mirror filename calculation. (#…
Browse files Browse the repository at this point in the history
…7200)

* Support NPM Enterprise URLs in offline mirror filename calculation.

* Update CHANGELOG.md

* Update CHANGELOG.md
  • Loading branch information
jmillikin-stripe authored and arcanis committed Apr 16, 2019
1 parent 8a671f1 commit 4ad8816
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#7127](https://github.com/yarnpkg/yarn/pull/7127) - [**Eli Perelman**](https://github.com/eliperelman)

- Adds support for the npm enterprise URLs when computing the offline mirror filenames.

[#7200](https://github.com/yarnpkg/yarn/pull/7200) - [**John Millikin**](https://john-millikin.com)

## 1.15.2

The 1.15.1 doesn't exist due to a release hiccup.
Expand Down
21 changes: 21 additions & 0 deletions __tests__/fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,27 @@ test('TarballFetcher.fetch properly stores tarball for scoped package resolved f
expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
});

test('TarballFetcher.fetch properly stores tarball for scoped package resolved from npm enterprise registry', async () => {
const dir = await mkdir('tarball-fetcher');
const offlineMirrorDir = await mkdir('offline-mirror');

const config = await Config.create();
config.registries.npm.config['yarn-offline-mirror'] = offlineMirrorDir;

const fetcher = new TarballFetcher(
dir,
{
type: 'tarball',
hash: '6f0ab73cdd7b82d8e81e80838b49e9e4c7fbcc44',
reference: 'https://npm.internal.site:443/@/@exponent/configurator/_attachments/configurator-1.0.2.tgz',
registry: 'npm',
},
config,
);

expect(fetcher.getTarballMirrorPath()).toBe(path.join(offlineMirrorDir, '@exponent-configurator-1.0.2.tgz'));
});

test('TarballFetcher.fetch throws on truncated tar data', async () => {
const dir = await mkdir('tarball-fetcher');
const reporter = new Reporter();
Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const gunzip = require('gunzip-maybe');
const invariant = require('invariant');
const ssri = require('ssri');

const RE_URL_NAME_MATCH = /\/(?:(@[^/]+)\/)?[^/]+\/-\/(?:@[^/]+\/)?([^/]+)$/;
const RE_URL_NAME_MATCH = /\/(?:(@[^/]+)\/)?[^/]+\/(?:-|_attachments)\/(?:@[^/]+\/)?([^/]+)$/;

const isHashAlgorithmSupported = name => {
const cachedResult = isHashAlgorithmSupported.__cache[name];
Expand Down

0 comments on commit 4ad8816

Please sign in to comment.