Skip to content

Commit c98f9bf

Browse files
committed
fix: Fixes for docker and pnpm. Improved python tests by switching to uv
1 parent db95abf commit c98f9bf

8 files changed

Lines changed: 33 additions & 22 deletions

File tree

src/resources/docker/docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class DockerResource extends Resource<DockerConfig> {
175175
{ requiresRoot: true }
176176
);
177177
await $.spawn(
178-
'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o --batch --yes /etc/apt/keyrings/docker.gpg',
178+
`bash -c 'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --batch --yes --dearmor -o /etc/apt/keyrings/docker.gpg'`,
179179
{ requiresRoot: true }
180180
);
181181
await $.spawn(

src/resources/javascript/pnpm/pnpm.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ export class Pnpm extends Resource<PnpmConfig> {
6969

7070
async destroy(plan: DestroyPlan<PnpmConfig>): Promise<void> {
7171
const $ = getPty();
72+
73+
const expectedPnpmHome = Utils.isMacOS()
74+
? path.join(os.homedir(), 'Library', 'pnpm')
75+
: path.join(os.homedir(), '.local', 'share', 'pnpm');
76+
7277
const { data: pnpmLocation } = await $.spawn('which pnpm', { interactive: true });
73-
if (pnpmLocation.trim().toLowerCase() !== path.join(os.homedir(), 'Library', 'pnpm', 'pnpm').trim().toLowerCase()) {
78+
if (pnpmLocation.trim().toLowerCase() !== path.join(expectedPnpmHome, 'pnpm').trim().toLowerCase()) {
7479
throw new Error('pnpm was installed outside of Codify. Please uninstall manually and re-run Codify');
7580
}
7681

@@ -84,7 +89,7 @@ export class Pnpm extends Resource<PnpmConfig> {
8489

8590
const shellRc = Utils.getPrimaryShellRc();
8691
await FileUtils.removeLineFromStartupFile('# pnpm')
87-
await FileUtils.removeLineFromStartupFile(`export PNPM_HOME="${os.homedir()}/Library/pnpm"`)
92+
await FileUtils.removeLineFromStartupFile(`export PNPM_HOME="${expectedPnpmHome}"`)
8893
await FileUtils.removeFromFile(shellRc,
8994
`case ":$PATH:" in
9095
*":$PNPM_HOME:"*) ;;

test/node/npm/npm.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeAll } from 'vitest';
1+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
22
import { PluginTester, testSpawn } from '@codifycli/plugin-test';
33
import path from 'node:path';
44
import { SpawnStatus } from '@codifycli/plugin-core';
@@ -20,18 +20,15 @@ describe('Npm tests', () => {
2020
await PluginTester.fullTest(pluginPath, [
2121
{
2222
type: 'npm',
23-
globalInstall: ['pnpm'],
23+
globalInstall: ['npm-run-all'],
2424
}
2525
], {
26+
skipUninstall: true,
2627
validateApply: async () => {
27-
expect(await testSpawn('which nvm')).toMatchObject({ status: SpawnStatus.SUCCESS });
28-
expect(await testSpawn('node --version')).toMatchObject({ status: SpawnStatus.SUCCESS });
29-
expect(await testSpawn('nvm list')).toMatchObject({ status: SpawnStatus.SUCCESS });
30-
31-
const { data: installedVersions } = await testSpawn('nvm list')
32-
expect(installedVersions).to.include('20');
33-
expect(installedVersions).to.include('18');
28+
expect(await testSpawn('which npm-run-all')).toMatchObject({ status: SpawnStatus.SUCCESS });
3429
},
3530
});
3631
});
32+
33+
// Don't uninstall nodeJS here. We need it for the test harness
3734
});

test/node/pnpm/pnpm.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Pnpm tests', () => {
1313
], {
1414
validateDestroy: async () => {
1515
const shellRcFile = fs.readFileSync(TestUtils.getPrimaryShellRc(), 'utf8')
16-
expect(shellRcFile.trim()).to.eq('');
16+
expect(shellRcFile).to.not.include('pnpm');
1717
}
1818
})
1919
})
@@ -28,7 +28,7 @@ describe('Pnpm tests', () => {
2828
},
2929
validateDestroy: async () => {
3030
const shellRcFile = fs.readFileSync(TestUtils.getPrimaryShellRc(), 'utf8')
31-
expect(shellRcFile.trim()).to.eq('');
31+
expect(shellRcFile).to.not.include('pnpm');
3232
}
3333
})
3434
})

test/python/pip-sync.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { PluginTester, testSpawn } from '@codifycli/plugin-test';
22
import * as path from 'node:path';
3-
import { describe, expect, it } from 'vitest'
3+
import * as fs from 'node:fs/promises';
4+
import * as os from 'node:os';
5+
import { afterAll, describe, expect, it } from 'vitest'
46

57
describe('Pip-sync resource integration tests', () => {
68
const pluginPath = path.resolve('./src/index.ts');
79

810
it('Installs python', { timeout: 500_000 }, async () => {
911
await PluginTester.fullTest(pluginPath, [
1012
{
11-
type: 'pyenv',
13+
type: 'uv',
1214
pythonVersions: ['3.11'],
13-
global: '3.11'
15+
global: '3.11',
16+
tools: ['pip'],
1417
},
1518
], {
1619
skipUninstall: true,
@@ -25,7 +28,7 @@ describe('Pip-sync resource integration tests', () => {
2528
{
2629
'type': 'git-repository',
2730
'directory': '~/Projects/example-project2',
28-
'repository': 'https://github.com/daniel-dqsdatalabs/python-template.git'
31+
'repository': 'https://github.com/ImperialCollegeLondon/pip-tools-template.git'
2932
},
3033
{
3134
'type': 'venv-project',
@@ -49,4 +52,9 @@ describe('Pip-sync resource integration tests', () => {
4952
validateApply() {},
5053
});
5154
});
55+
56+
afterAll(async () => {
57+
await fs.rm(path.join(os.homedir(), 'Projects', 'example-project2'), { recursive: true, force: true });
58+
await PluginTester.uninstall(pluginPath, [{ type: 'uv' }]);
59+
}, 120_000);
5260
})

test/python/pip.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ describe('Pip resource integration tests', () => {
1010
it('Installs python', { timeout: 500000 }, async () => {
1111
await PluginTester.fullTest(pluginPath, [
1212
{
13-
type: 'pyenv',
13+
type: 'uv',
1414
pythonVersions: ['3.11'],
15-
global: '3.11'
15+
global: '3.11',
16+
tools: ['pip'],
1617
},
1718
], {
1819
skipUninstall: true,

test/python/venv-project.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Virtualenv project tests', () => {
1313
console.log(await fs.readdir('Projects/python-project'));
1414

1515
await PluginTester.fullTest(pluginPath, [
16-
{ type: 'pyenv', pythonVersions: ['3.11'], global: '3.11' },
16+
{ type: 'uv', pythonVersions: ['3.11'], global: '3.11' },
1717
{ type: 'venv-project', envDir: '.venv', cwd: 'Projects/python-project', automaticallyInstallRequirementsTxt: true },
1818
])
1919
})

test/python/virtualenv-project.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Virtualenv project tests', () => {
1515

1616
await PluginTester.fullTest(pluginPath, [
1717
{ type: 'virtualenv' },
18-
{ type: 'pyenv', pythonVersions: ['3.11'], global: '3.11' },
18+
{ type: 'uv', pythonVersions: ['3.11'], global: '3.11' },
1919
{ type: 'virtualenv-project', dest: '.venv', cwd: 'Projects/python-project', automaticallyInstallRequirementsTxt: true },
2020
])
2121
})

0 commit comments

Comments
 (0)