mirror of
https://github.com/actions/setup-node.git
synced 2025-12-15 13:02:35 +00:00
Some checks failed
versions / version-file-volta-extends (windows-latest) (push) Has been cancelled
versions / node-dist (17, macos-latest) (push) Has been cancelled
Basic validation / Basic validation (push) Has been cancelled
Check dist / Check dist/ (push) Has been cancelled
CodeQL analysis / CodeQL analysis (push) Has been cancelled
versions / manifest (20.10.0, macos-latest-large) (push) Has been cancelled
versions / manifest (20.10.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (20.10.0, windows-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest-large) (push) Has been cancelled
versions / manifest (22.0.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (22.0.0, windows-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest-large) (push) Has been cancelled
versions / manifest (24.9.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (24.9.0, windows-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions, macos-latest) (push) Has been cancelled
versions / version-file (package.json, windows-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest-large) (push) Has been cancelled
versions / version-file-volta (ubuntu-latest) (push) Has been cancelled
versions / version-file-volta (windows-latest) (push) Has been cancelled
versions / version-file-volta-extends (macos-latest) (push) Has been cancelled
versions / version-file-volta-extends (macos-latest-large) (push) Has been cancelled
versions / version-file-volta-extends (ubuntu-latest) (push) Has been cancelled
versions / node-dist (17, macos-latest-large) (push) Has been cancelled
versions / node-dist (17, ubuntu-latest) (push) Has been cancelled
versions / node-dist (17, windows-latest) (push) Has been cancelled
versions / node-dist (19, macos-latest) (push) Has been cancelled
versions / node-dist (19, macos-latest-large) (push) Has been cancelled
versions / node-dist (19, ubuntu-latest) (push) Has been cancelled
versions / node-dist (19, windows-latest) (push) Has been cancelled
versions / old-versions (macos-latest-large) (push) Has been cancelled
versions / old-versions (ubuntu-latest) (push) Has been cancelled
versions / old-versions (windows-latest) (push) Has been cancelled
versions / arch (push) Has been cancelled
versions / local-cache (22, ubuntu-latest) (push) Has been cancelled
versions / local-cache (22, windows-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest-large) (push) Has been cancelled
versions / local-cache (24, ubuntu-latest) (push) Has been cancelled
versions / local-cache (24, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/*, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, windows-latest) (push) Has been cancelled
versions / version-file (package.json, macos-latest) (push) Has been cancelled
versions / version-file (package.json, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn subprojects-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed-2 (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git-2 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-1 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-2 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-3 (push) Has been cancelled
versions / version-file (package.json, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed-2 (push) Has been cancelled
e2e-cache / Test npm (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects-2 (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-9 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-10 (push) Has been cancelled
versions / local-cache (20, macos-latest) (push) Has been cancelled
versions / local-cache (20, macos-latest-large) (push) Has been cancelled
versions / local-cache (20, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/-1, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-4 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-5 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-6 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-7 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-8 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-11 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-1 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-2 (push) Has been cancelled
versions / local-cache (20, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-3 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-4 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-5 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-6 (push) Has been cancelled
versions / local-cache (22, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-7 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-8 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-9 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-10 (push) Has been cancelled
versions / local-cache (22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-11 (push) Has been cancelled
Licensed / Licensed (push) Has been cancelled
proxy / test-proxy (push) Has been cancelled
proxy / test-bypass-proxy (push) Has been cancelled
versions / lts-syntax (lts/erbium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/erbium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/erbium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, windows-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (25-nightly, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, windows-latest) (push) Has been cancelled
versions / manifest (20.10.0, macos-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest-large) (push) Has been cancelled
versions / check-latest (20, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (node, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (node, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (node, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (node, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/fermium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, windows-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (20-nightly, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, windows-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, windows-latest) (push) Has been cancelled
versions / check-latest (20, windows-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest-large) (push) Has been cancelled
versions / check-latest (22, ubuntu-latest) (push) Has been cancelled
versions / check-latest (22, windows-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest-large) (push) Has been cancelled
versions / check-latest (24, ubuntu-latest) (push) Has been cancelled
versions / check-latest (24, windows-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest-large) (push) Has been cancelled
versions / version-file (.nvmrc, ubuntu-latest) (push) Has been cancelled
versions / version-file (.nvmrc, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions, macos-latest-large) (push) Has been cancelled
versions / version-file (.tool-versions, ubuntu-latest) (push) Has been cancelled
versions / version-file (.tool-versions, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, macos-latest-large) (push) Has been cancelled
versions / version-file (.tool-versions-node, ubuntu-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (current, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (current, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (current, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (current, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (latest, ubuntu-latest) (push) Has been cancelled
* Remove always-auth configuration handling from setup-node * docs: update README to note always-auth removal Update README to mention removal of always-auth input * Clarify removal of 'always-auth' input in README Updated the description of the 'always-auth' input removal for clarity.
200 lines
7.7 KiB
TypeScript
200 lines
7.7 KiB
TypeScript
import os from 'os';
|
|
import fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as core from '@actions/core';
|
|
import * as io from '@actions/io';
|
|
import * as auth from '../src/authutil';
|
|
import * as cacheUtils from '../src/cache-utils';
|
|
|
|
let rcFile: string;
|
|
|
|
describe('authutil tests', () => {
|
|
const _runnerDir = path.join(__dirname, 'runner');
|
|
|
|
let cnSpy: jest.SpyInstance;
|
|
let logSpy: jest.SpyInstance;
|
|
let dbgSpy: jest.SpyInstance;
|
|
|
|
beforeAll(async () => {
|
|
const randPath = path.join(Math.random().toString(36).substring(7));
|
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
|
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
|
const tempDir = path.join(_runnerDir, randPath, 'temp');
|
|
await io.rmRF(tempDir);
|
|
await io.mkdirP(tempDir);
|
|
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
|
process.env['RUNNER_TEMP'] = tempDir;
|
|
rcFile = path.join(tempDir, '.npmrc');
|
|
}, 100000);
|
|
|
|
beforeEach(async () => {
|
|
await io.rmRF(rcFile);
|
|
// if (fs.existsSync(rcFile)) {
|
|
// fs.unlinkSync(rcFile);
|
|
// }
|
|
process.env['INPUT_SCOPE'] = '';
|
|
|
|
// writes
|
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
|
logSpy = jest.spyOn(console, 'log');
|
|
dbgSpy = jest.spyOn(core, 'debug');
|
|
cnSpy.mockImplementation(line => {
|
|
// uncomment to debug
|
|
// process.stderr.write('write:' + line + '\n');
|
|
});
|
|
logSpy.mockImplementation(line => {
|
|
// uncomment to debug
|
|
// process.stderr.write('log:' + line + '\n');
|
|
});
|
|
dbgSpy.mockImplementation(msg => {
|
|
// uncomment to see debug output
|
|
// process.stderr.write(msg + '\n');
|
|
});
|
|
}, 100000);
|
|
|
|
function dbg(message: string) {
|
|
process.stderr.write('dbg::' + message + '::\n');
|
|
}
|
|
|
|
afterAll(async () => {
|
|
if (_runnerDir) {
|
|
await io.rmRF(_runnerDir);
|
|
}
|
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
|
}, 100000);
|
|
|
|
function readRcFile(rcFile: string) {
|
|
const rc = {};
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
for (const line of contents.split(os.EOL)) {
|
|
const parts = line.split('=');
|
|
if (parts.length == 2) {
|
|
rc[parts[0].trim()] = parts[1].trim();
|
|
}
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
it('Sets up npmrc for npmjs', async () => {
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
|
|
expect(fs.statSync(rcFile)).toBeDefined();
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
const rc = readRcFile(rcFile);
|
|
expect(rc['registry']).toBe('https://registry.npmjs.org/');
|
|
});
|
|
|
|
it('Appends trailing slash to registry', async () => {
|
|
await auth.configAuthentication('https://registry.npmjs.org');
|
|
|
|
expect(fs.statSync(rcFile)).toBeDefined();
|
|
const rc = readRcFile(rcFile);
|
|
expect(rc['registry']).toBe('https://registry.npmjs.org/');
|
|
});
|
|
|
|
it('Configures scoped npm registries', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myScope';
|
|
await auth.configAuthentication('https://registry.npmjs.org');
|
|
|
|
expect(fs.statSync(rcFile)).toBeDefined();
|
|
const rc = readRcFile(rcFile);
|
|
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
|
|
});
|
|
|
|
it('Automatically configures GPR scope', async () => {
|
|
await auth.configAuthentication('npm.pkg.github.com');
|
|
|
|
expect(fs.statSync(rcFile)).toBeDefined();
|
|
const rc = readRcFile(rcFile);
|
|
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
|
|
});
|
|
|
|
it('is already set the NODE_AUTH_TOKEN export it', async () => {
|
|
process.env.NODE_AUTH_TOKEN = 'foobar';
|
|
await auth.configAuthentication('npm.pkg.github.com');
|
|
expect(fs.statSync(rcFile)).toBeDefined();
|
|
const rc = readRcFile(rcFile);
|
|
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
|
|
expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar');
|
|
});
|
|
|
|
it('configAuthentication should overwrite non-scoped with non-scoped', async () => {
|
|
fs.writeFileSync(rcFile, 'registry=NNN');
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should overwrite only non-scoped', async () => {
|
|
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should add non-scoped to scoped', async () => {
|
|
fs.writeFileSync(rcFile, '@myscope:registry=NNN');
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should overwrite scoped with scoped', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myscope';
|
|
fs.writeFileSync(rcFile, `@myscope:registry=NNN`);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should overwrite only scoped', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myscope';
|
|
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should add scoped to non-scoped', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myscope';
|
|
fs.writeFileSync(rcFile, `registry=MMM`);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should overwrite only one scoped', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myscope';
|
|
fs.writeFileSync(
|
|
rcFile,
|
|
`@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM`
|
|
);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
|
|
it('configAuthentication should add scoped to another scoped', async () => {
|
|
process.env['INPUT_SCOPE'] = 'myscope';
|
|
fs.writeFileSync(rcFile, `@otherscope:registry=MMM`);
|
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
|
expect(contents).toBe(
|
|
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
|
);
|
|
});
|
|
});
|