diff --git a/packages/cli/src/modules/community-packages/__tests__/community-packages.integration.test.ts b/packages/cli/src/modules/community-packages/__tests__/community-packages.integration.test.ts index 07b2cc240fc..1260d797261 100644 --- a/packages/cli/src/modules/community-packages/__tests__/community-packages.integration.test.ts +++ b/packages/cli/src/modules/community-packages/__tests__/community-packages.integration.test.ts @@ -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); }); diff --git a/packages/cli/src/modules/community-packages/__tests__/community-packages.lifecycle.service.test.ts b/packages/cli/src/modules/community-packages/__tests__/community-packages.lifecycle.service.test.ts index e0c9dc05e63..f58f717d51d 100644 --- a/packages/cli/src/modules/community-packages/__tests__/community-packages.lifecycle.service.test.ts +++ b/packages/cli/src/modules/community-packages/__tests__/community-packages.lifecycle.service.test.ts @@ -35,6 +35,8 @@ describe('CommunityPackagesLifecycleService', () => { }); const communityPackagesConfig = mock({ unverifiedEnabled: true, + registry: 'https://registry.npmjs.org', + authToken: '', }); const instanceSettingsLoaderConfig = mock({ 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]); diff --git a/packages/cli/src/modules/community-packages/community-packages.lifecycle.service.ts b/packages/cli/src/modules/community-packages/community-packages.lifecycle.service.ts index f05b360f4b0..e2e051a7c6d 100644 --- a/packages/cli/src/modules/community-packages/community-packages.lifecycle.service.ts +++ b/packages/cli/src/modules/community-packages/community-packages.lifecycle.service.ts @@ -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) {