fix: add full npmjs scope when migrating npmToken

commit 7e15d3d488c927df2f11f728f35d493e2821477d
Author: Rhys Arkins <rhys@arkins.net>
Date:   Wed Jan 10 14:26:44 2018 +0100

    Revert "refactor: use _auth= when migrating npm tokens"

    This reverts commit 4a2fdd0477.
This commit is contained in:
Rhys Arkins 2018-01-10 14:27:19 +01:00
parent 421adcfedc
commit 72745b6b13
4 changed files with 4 additions and 4 deletions

View file

@ -19,7 +19,7 @@ function decryptConfig(config, privateKey) {
logger.info(`Decrypted ${eKey}`); logger.info(`Decrypted ${eKey}`);
if (eKey === 'npmToken') { if (eKey === 'npmToken') {
logger.info('Migrating npmToken to npmrc'); logger.info('Migrating npmToken to npmrc');
decryptedConfig.npmrc = `_auth=${decryptedStr}\n`; decryptedConfig.npmrc = `//registry.npmjs.org/:_authToken=${decryptedStr}\n`;
} else { } else {
decryptedConfig[eKey] = decryptedStr; decryptedConfig[eKey] = decryptedStr;
} }

View file

@ -22,7 +22,7 @@ function massageConfig(config) {
if (allowedStrings.includes(key) && typeof val === 'string') { if (allowedStrings.includes(key) && typeof val === 'string') {
massagedConfig[key] = [val]; massagedConfig[key] = [val];
} else if (key === 'npmToken' && val && val.length < 30) { } else if (key === 'npmToken' && val && val.length < 30) {
massagedConfig.npmrc = `_auth=${val}\n`; massagedConfig.npmrc = `//registry.npmjs.org/:_authToken=${val}\n`;
delete massagedConfig.npmToken; delete massagedConfig.npmToken;
} else if (isObject(val)) { } else if (isObject(val)) {
massagedConfig[key] = massageConfig(val); massagedConfig[key] = massageConfig(val);

View file

@ -2,7 +2,7 @@
exports[`config/massage massageConfig massages npmToken 1`] = ` exports[`config/massage massageConfig massages npmToken 1`] = `
Object { Object {
"npmrc": "_auth=some-token "npmrc": "//registry.npmjs.org/:_authToken=some-token
", ",
} }
`; `;

View file

@ -57,7 +57,7 @@ describe('config/decrypt', () => {
); );
expect(res.packageFiles[0].devDependencies.npmToken).not.toBeDefined(); expect(res.packageFiles[0].devDependencies.npmToken).not.toBeDefined();
expect(res.packageFiles[0].devDependencies.npmrc).toEqual( expect(res.packageFiles[0].devDependencies.npmrc).toEqual(
'_auth=abcdef-ghijklm-nopqf-stuvwxyz\n' '//registry.npmjs.org/:_authToken=abcdef-ghijklm-nopqf-stuvwxyz\n'
); );
}); });
}); });