-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager/npm): support buildpack
- Loading branch information
Showing
8 changed files
with
155 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { envMock, mockExecAll } from '../../../../../test/exec-util'; | ||
import { env, partial } from '../../../../../test/util'; | ||
import { env, logger, mockedFunction, partial } from '../../../../../test/util'; | ||
import { GlobalConfig } from '../../../../config/global'; | ||
import type { RepoGlobalConfig } from '../../../../config/types'; | ||
import type { PackageFile, PostUpdateConfig } from '../../types'; | ||
import * as lernaHelper from './lerna'; | ||
import { getNodeToolConstraint } from './node-version'; | ||
|
||
jest.mock('../../../../util/exec/env'); | ||
jest.mock('../../npm/post-update/node-version'); | ||
|
||
process.env.BUILDPACK = 'true'; | ||
|
||
function lernaPkgFile(lernaClient: string): Partial<PackageFile> { | ||
return { | ||
lernaClient, | ||
|
@@ -23,17 +26,29 @@ function lernaPkgFileWithoutLernaDep( | |
}; | ||
} | ||
|
||
mockedFunction(logger.logger.debug).mockImplementation((...args) => | ||
// eslint-disable-next-line no-console | ||
console.log(...args) | ||
); | ||
|
||
const config = partial<PostUpdateConfig>({}); | ||
|
||
describe('modules/manager/npm/post-update/lerna', () => { | ||
const globalConfig: RepoGlobalConfig = { localDir: '' }; | ||
const globalConfig: RepoGlobalConfig = { | ||
localDir: '', | ||
cacheDir: '/tmp/cache', | ||
}; | ||
|
||
describe('generateLockFiles()', () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
jest.resetModules(); | ||
env.getChildProcessEnv.mockReturnValue(envMock.basic); | ||
GlobalConfig.set(globalConfig); | ||
mockedFunction(getNodeToolConstraint).mockResolvedValueOnce({ | ||
toolName: 'node', | ||
constraint: '16.16.0', | ||
}); | ||
}); | ||
|
||
it('returns if no lernaClient', async () => { | ||
|
@@ -120,6 +135,87 @@ describe('modules/manager/npm/post-update/lerna', () => { | |
expect(res.error).toBeFalse(); | ||
expect(execSnapshots).toMatchSnapshot(); | ||
}); | ||
|
||
it('suppports docker', async () => { | ||
const execSnapshots = mockExecAll(); | ||
GlobalConfig.set({ ...globalConfig, binarySource: 'docker' }); | ||
const res = await lernaHelper.generateLockFiles( | ||
lernaPkgFile('npm'), | ||
'some-dir', | ||
{ ...config, constraints: { npm: '^6.0.0' } }, | ||
{} | ||
); | ||
expect(execSnapshots).toMatchObject([ | ||
{ | ||
cmd: 'docker pull renovate/sidecar', | ||
}, | ||
{ | ||
cmd: 'docker ps --filter name=renovate_sidecar -aq', | ||
}, | ||
{ | ||
cmd: | ||
'docker run --rm --name=renovate_sidecar --label=renovate_child ' + | ||
'-v "/tmp/cache":"/tmp/cache" ' + | ||
'-e BUILDPACK_CACHE_DIR ' + | ||
'-w "some-dir" renovate/sidecar ' + | ||
'bash -l -c "' + | ||
'install-tool node 16.16.0 ' + | ||
'&& ' + | ||
"npm i -g npm@'^6.0.0' || true " + | ||
'&& ' + | ||
'hash -d npm 2>/dev/null || true ' + | ||
'&& npm i -g [email protected] ' + | ||
'&& lerna info || echo \\"Ignoring lerna info failure\\" ' + | ||
'&& ' + | ||
'npm install --ignore-scripts --no-audit --package-lock-only ' + | ||
'&& ' + | ||
'lerna bootstrap --no-ci --ignore-scripts -- --ignore-scripts --no-audit --package-lock-only' + | ||
'"', | ||
options: { | ||
cwd: 'some-dir', | ||
}, | ||
}, | ||
]); | ||
expect(res.error).toBeFalse(); | ||
}); | ||
|
||
it('suppports binarySource=install', async () => { | ||
const execSnapshots = mockExecAll(); | ||
GlobalConfig.set({ ...globalConfig, binarySource: 'install' }); | ||
const res = await lernaHelper.generateLockFiles( | ||
lernaPkgFile('npm'), | ||
'some-dir', | ||
{ ...config, constraints: { npm: '^6.0.0' } }, | ||
{} | ||
); | ||
expect(res.error).toBeFalse(); | ||
expect(execSnapshots).toMatchObject([ | ||
{ | ||
cmd: 'install-tool node 16.16.0', | ||
options: { | ||
cwd: 'some-dir', | ||
}, | ||
}, | ||
{ | ||
cmd: 'lerna info || echo "Ignoring lerna info failure"', | ||
options: { | ||
cwd: 'some-dir', | ||
}, | ||
}, | ||
{ | ||
cmd: 'npm install --ignore-scripts --no-audit --package-lock-only', | ||
options: { | ||
cwd: 'some-dir', | ||
}, | ||
}, | ||
{ | ||
cmd: 'lerna bootstrap --no-ci --ignore-scripts -- --ignore-scripts --no-audit --package-lock-only', | ||
options: { | ||
cwd: 'some-dir', | ||
}, | ||
}, | ||
]); | ||
}); | ||
}); | ||
|
||
describe('getLernaVersion()', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.