-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualenv.ts
More file actions
53 lines (44 loc) · 1.62 KB
/
Copy pathvirtualenv.ts
File metadata and controls
53 lines (44 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { CreatePlan, DestroyPlan, ExampleConfig, getPty, Resource, ResourceSettings, Utils } from '@codifycli/plugin-core';
import { OS, ResourceConfig } from '@codifycli/schemas';
import schema from './virtualenv-schema.json';
export interface VirtualenvConfig extends ResourceConfig {}
const exampleWithProject: ExampleConfig = {
title: 'Install virtualenv and set up a project environment',
description: 'Install virtualenv and create an isolated environment for a Python project, automatically installing dependencies from requirements.txt.',
configs: [
{
type: 'virtualenv',
},
{
type: 'virtualenv-project',
dest: '.venv',
cwd: '~/projects/my-python-project',
automaticallyInstallRequirementsTxt: true,
dependsOn: ['virtualenv'],
},
]
}
export class Virtualenv extends Resource<VirtualenvConfig> {
getSettings(): ResourceSettings<VirtualenvConfig> {
return {
id: 'virtualenv',
exampleConfigs: {
example1: exampleWithProject,
},
operatingSystems: [OS.Darwin, OS.Linux],
schema,
dependencies: ['homebrew'],
}
}
async refresh(parameters: Partial<VirtualenvConfig>): Promise<Partial<VirtualenvConfig> | Partial<VirtualenvConfig>[] | null> {
const pty = getPty()
const { status } = await pty.spawnSafe('which virtualenv');
return status === 'error' ? null : parameters;
}
async create(plan: CreatePlan<VirtualenvConfig>): Promise<void> {
await Utils.installViaPkgMgr('virtualenv');
}
async destroy(plan: DestroyPlan<VirtualenvConfig>): Promise<void> {
await Utils.uninstallViaPkgMgr('virtualenv');
}
}