mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 05:29:44 +02:00
fix(core): Pass registry and auth token to npm outdated for community packages (#31515)
Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Bernhard Wittmann <bernhard.wittmann@n8n.io>
This commit is contained in:
parent
e0c27dd34f
commit
1998011d90
|
|
@ -135,7 +135,15 @@ describe('GET /community-packages', () => {
|
|||
|
||||
await authAgent.get('/community-packages').expect(200);
|
||||
|
||||
const args = [['outdated', '--json'], { doNotHandleError: true, cwd: expect.any(String) }];
|
||||
const args = [
|
||||
['outdated', '--json'],
|
||||
{
|
||||
doNotHandleError: true,
|
||||
cwd: expect.any(String),
|
||||
registry: 'https://registry.npmjs.org',
|
||||
authToken: undefined,
|
||||
},
|
||||
];
|
||||
|
||||
expect(mockedExecuteNpmCommand).toHaveBeenCalledWith(...args);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ describe('CommunityPackagesLifecycleService', () => {
|
|||
});
|
||||
const communityPackagesConfig = mock<CommunityPackagesConfig>({
|
||||
unverifiedEnabled: true,
|
||||
registry: 'https://registry.npmjs.org',
|
||||
authToken: '',
|
||||
});
|
||||
const instanceSettingsLoaderConfig = mock<InstanceSettingsLoaderConfig>({
|
||||
communityPackagesManagedByEnv: false,
|
||||
|
|
@ -360,9 +362,32 @@ describe('CommunityPackagesLifecycleService', () => {
|
|||
expect(mockedExecuteNpmCommand).toHaveBeenCalledWith(['outdated', '--json'], {
|
||||
doNotHandleError: true,
|
||||
cwd: '/tmp/n8n-nodes-download',
|
||||
registry: communityPackagesConfig.registry,
|
||||
authToken: communityPackagesConfig.authToken || undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass custom registry and auth token to npm outdated', async () => {
|
||||
communityPackagesConfig.unverifiedEnabled = true;
|
||||
communityPackagesConfig.registry = 'http://localhost:4873';
|
||||
communityPackagesConfig.authToken = 'my-secret-token';
|
||||
communityPackagesService.getAllInstalledPackages.mockResolvedValue([installedPackage]);
|
||||
communityPackagesService.matchPackagesWithUpdates.mockReturnValue([installedPackage]);
|
||||
Object.defineProperty(communityPackagesService, 'hasMissingPackages', { value: false });
|
||||
|
||||
await lifecycle.listInstalledPackages();
|
||||
|
||||
expect(mockedExecuteNpmCommand).toHaveBeenCalledWith(['outdated', '--json'], {
|
||||
doNotHandleError: true,
|
||||
cwd: '/tmp/n8n-nodes-download',
|
||||
registry: 'http://localhost:4873',
|
||||
authToken: 'my-secret-token',
|
||||
});
|
||||
|
||||
communityPackagesConfig.registry = 'https://registry.npmjs.org';
|
||||
communityPackagesConfig.authToken = '';
|
||||
});
|
||||
|
||||
it('should not run npm outdated when unverifiedEnabled is false', async () => {
|
||||
communityPackagesConfig.unverifiedEnabled = false;
|
||||
communityPackagesService.getAllInstalledPackages.mockResolvedValue([installedPackage]);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ export class CommunityPackagesLifecycleService {
|
|||
await executeNpmCommand(['outdated', '--json'], {
|
||||
doNotHandleError: true,
|
||||
cwd: this.instanceSettings.nodesDownloadDir,
|
||||
registry: this.communityPackagesConfig.registry,
|
||||
authToken: this.communityPackagesConfig.authToken || undefined,
|
||||
});
|
||||
} catch (error) {
|
||||
if (isNpmExecErrorWithStdout(error) && error.code === 1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user