generated from devcontainers-community/features-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-feature.sh
executable file
·86 lines (71 loc) · 1.67 KB
/
generate-feature.sh
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
#!/bin/bash
set -e
read -p 'Name: ' name
read -p 'Description: ' description
read -p 'npm name: ' npm_name
read -p 'ID: ' id
read -p 'Test command: ' test_cmd
mkdir -p src/$id
cat <<EOF > src/$id/README.md
# $name Dev Container Feature
$description
<p align="center">
<a href="<TODO: Add link>">
<img src="<TODO: Add image>">
</a>
</p>
> <TODO: Add quote>
— <TODO: Add source>
## Usage
![Codespaces](https://img.shields.io/static/v1?style=for-the-badge&message=Codespaces&color=181717&logo=GitHub&logoColor=FFFFFF&label=)
![Devcontainers](https://img.shields.io/static/v1?style=for-the-badge&message=Devcontainers&color=2496ED&logo=Docker&logoColor=FFFFFF&label=)
\`\`\`json
// devcontainer.json
"features": {
"ghcr.io/devcontainers-community/features/$id:1": {}
}
\`\`\`
## Options
You can pin a specific version of the npm package like this:
\`\`\`json
// devcontainer.json
"features": {
"ghcr.io/devcontainers-community/features/$id:1": {
"version": "1.2.3"
}
}
\`\`\`
EOF
cat <<EOF > src/$id/devcontainer-feature.json
{
"id": "$id",
"version": "1.0.0",
"name": "$name",
"documentationURL": "http://github.com/devcontainers-community/npm-features/tree/main/src/$id",
"description": "$description",
"options": {
"version": {
"default": "latest",
"description": "Select the version to install.",
"proposals": ["latest"],
"type": "string"
}
},
"dependsOn": {
"ghcr.io/devcontainers/features/node": {}
}
}
EOF
cat <<EOF > src/$id/install.sh
#!/bin/bash
set -ex
npm install -g $npm_name@\$VERSION
EOF
if [[ -n $test_cmd ]]; then
mkdir -p test/$id
cat <<EOF > test/$id/test.sh
#!/bin/bash
set -ex
$test_cmd
EOF
fi