forked from projen/projen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-env.ts
97 lines (84 loc) · 2.29 KB
/
dev-env.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Task } from './tasks';
/**
* Base options for configuring a container-based development environemnt.
*/
export interface DevEnvironmentOptions {
/**
* A Docker image or Dockerfile for the container.
*/
readonly dockerImage?: DevEnvironmentDockerImage;
/**
* An array of tasks that should be run when the container starts.
*/
readonly tasks?: Task[];
/**
* An array of ports that should be exposed from the container.
*/
readonly ports?: string[];
/**
* An array of extension IDs that specify the extensions that should be
* installed inside the container when it is created.
*/
readonly vscodeExtensions?: string[];
}
/**
* Options for specifying the Docker image of the container.
*/
export class DevEnvironmentDockerImage {
/**
* A publicly available Docker image.
* @example 'ubuntu:latest'
* @param image a Docker image
*/
public static fromImage(image: string): DevEnvironmentDockerImage {
return { image };
}
/**
* The relative path of a Dockerfile that defines the container contents.
* @example '.gitpod.Docker'
* @param dockerFile a relative path
*/
public static fromFile(dockerFile: string): DevEnvironmentDockerImage {
return { dockerFile };
}
/**
* A publicly available Docker image.
*/
public readonly image?: string;
/**
* The relative path of a Dockerfile that defines the container contents.
*/
public readonly dockerFile?: string;
private constructor() { }
}
/**
* Abstract interface for container-based development environments, such as
* Gitpod and GitHub Codespaces.
*/
export interface IDevEnvironment {
/**
* Add a custom Docker image or Dockerfile for the container.
*
* @param image The Docker image
*/
addDockerImage(image: DevEnvironmentDockerImage): void;
/**
* Adds tasks to run when the container starts.
*
* @param tasks The new tasks
*/
addTasks(...tasks: Task[]): void;
/**
* Adds ports that should be exposed (forwarded) from the container.
*
* @param ports The new ports
*/
addPorts(...ports: string[]): void;
/**
* Adds a list of VSCode extensions that should be automatically installed
* in the container.
*
* @param extensions The extension IDs
*/
addVscodeExtensions(...extensions: string[]): void;
}