Skip to content

Commit b1efab4

Browse files
committed
Add a way to generate extensions for manual testing
1 parent ec99d03 commit b1efab4

File tree

8 files changed

+207
-0
lines changed

8 files changed

+207
-0
lines changed

Diff for: Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ coverage:
1717
go tool cover -func=coverage
1818
.PHONY: coverage
1919

20+
gen:
21+
bash ./fixtures/generate.bash
22+
.PHONY: gen
23+
24+
upload:
25+
bash ./fixtures/upload.bash
26+
.PHONY: gen
27+
2028
TAG=$(shell git describe --always)
2129

2230
build:

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ the policy in code-server's source.
152152
When you make a change that affects people deploying the marketplace please
153153
update the changelog as part of your PR.
154154

155+
You can use `make gen` to generate a mock `extensions` directory for testing and
156+
`make upload` to upload them to an Artifactory repository.
157+
155158
### Tests
156159

157160
To run the tests:

Diff for: fixtures/generate.bash

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env bash
2+
# Generate a ./extensions directory with names based on text files containing
3+
# randomly generated words.
4+
5+
set -Eeuo pipefail
6+
7+
dir=$(dirname "$0")
8+
9+
# Pretty arbitrary but try to ensure we have a variety of extension kinds.
10+
kinds=("workspace", "ui,web", "workspace,web", "ui")
11+
12+
while read -r publisher ; do
13+
i=0
14+
while read -r name ; do
15+
kind=${kinds[$i]-workspace}
16+
((++i))
17+
while read -r version ; do
18+
dest="./extensions/$publisher/$name/$version"
19+
mkdir -p "$dest/extension/images"
20+
cat<<EOF > "$dest/extension.vsixmanifest"
21+
<?xml version="1.0" encoding="utf-8"?>
22+
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
23+
<Metadata>
24+
<Identity Language="en-US" Id="$name" Version="$version" Publisher="$publisher" />
25+
<DisplayName>$name</DisplayName>
26+
<Description xml:space="preserve">Mock extension for Visual Studio Code</Description>
27+
<Tags>$name,mock,tag1</Tags>
28+
<Categories>category1,category2</Categories>
29+
<GalleryFlags>Public</GalleryFlags>
30+
31+
<Properties>
32+
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.57.0" />
33+
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
34+
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
35+
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="$kind" />
36+
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
37+
38+
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/coder/code-marketplace.git" />
39+
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/coder/code-marketplace.git" />
40+
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/coder/code-marketplace.git" />
41+
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/coder/code-marketplace/issues" />
42+
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/coder/code-marketplace" />
43+
<Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="#e3f4ff" />
44+
<Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="light" />
45+
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
46+
47+
<Property Id="Microsoft.VisualStudio.Services.CustomerQnALink" Value="https://github.com/coder/code-marketplace" />
48+
</Properties>
49+
<License>extension/LICENSE.txt</License>
50+
<Icon>extension/images/icon.png</Icon>
51+
</Metadata>
52+
<Installation>
53+
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
54+
</Installation>
55+
<Dependencies/>
56+
<Assets>
57+
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
58+
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" />
59+
<Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" />
60+
<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" />
61+
<Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/icon.png" Addressable="true" />
62+
</Assets>
63+
</PackageManifest>
64+
EOF
65+
cat<<EOF > "$dest/extension/package.json"
66+
{
67+
"name": "$name",
68+
"displayName": "$name",
69+
"description": "Mock extension for Visual Studio Code",
70+
"version": "$version",
71+
"publisher": "$publisher",
72+
"author": {
73+
"name": "Coder"
74+
},
75+
"license": "MIT",
76+
"homepage": "https://github.com/coder/code-marketplace",
77+
"repository": {
78+
"type": "git",
79+
"url": "https://github.com/coder/code-marketplace"
80+
},
81+
"bugs": {
82+
"url": "https://github.com/coder/code-marketplace/issues"
83+
},
84+
"qna": "https://github.com/coder/code-marketplace",
85+
"icon": "icon.png",
86+
"engines": {
87+
"vscode": "^1.57.0"
88+
},
89+
"keywords": [
90+
"$name",
91+
"mock",
92+
"coder",
93+
],
94+
"categories": [
95+
"Category1",
96+
"Category2"
97+
],
98+
"activationEvents": [
99+
"onStartupFinished"
100+
],
101+
"main": "./extension",
102+
"browser": "./extension.browser.js"
103+
}
104+
EOF
105+
cat<<EOF > "$dest/extension/extension.js"
106+
const vscode = require("vscode");
107+
function activate(context) {
108+
vscode.window.showInformationMessage("mock extension $publisher.$name-$version loaded");
109+
}
110+
exports.activate = activate;
111+
EOF
112+
cp "$dest/extension/extension.js" "$dest/extension/extension.browser.js"
113+
cat<<EOF > "$dest/extension/LICENSE.txt"
114+
mock license
115+
EOF
116+
cat<<EOF > "$dest/extension/README.md"
117+
mock readme
118+
EOF
119+
cat<<EOF > "$dest/extension/CHANGELOG.md"
120+
mock changelog
121+
EOF
122+
cp "$dir/icon.png" "$dest/extension/images/icon.png"
123+
pushd "$dest" >/dev/null
124+
rm "$publisher.$name-$version.vsix"
125+
zip -r "$publisher.$name-$version.vsix" * -q
126+
popd >/dev/null
127+
done < "$dir/versions"
128+
done < "$dir/names"
129+
done < "$dir/publishers"

Diff for: fixtures/icon.png

1.86 KB
Loading

Diff for: fixtures/names

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
needless
2+
lace
3+
healthy
4+
plants
5+
warlike

Diff for: fixtures/publishers

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
brake
2+
frightened
3+
cooing
4+
lyrical
5+
zip
6+
introduce
7+
rail
8+
inexpensive
9+
spurious
10+
dear
11+
gruesome
12+
beginner
13+
shaggy
14+
minute
15+
group
16+
examine
17+
wipe
18+
guiltless
19+
remove
20+
pathetic
21+
structure
22+
spectacular
23+
house
24+
juice
25+
mate
26+
motionless
27+
distinct
28+
resonant
29+
wheel
30+
scene
31+
odd
32+
base
33+
whistle
34+
adhesive
35+
voracious
36+
hope
37+
unnatural
38+
brother
39+
groan
40+
false
41+
puzzling
42+
shop
43+
foamy
44+
better
45+
rest
46+
precious
47+
parallel
48+
stomach
49+
lacking
50+
load

Diff for: fixtures/upload.bash

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# Upload the extensions directory to Artifactory.
3+
4+
set -Eeuo pipefail
5+
6+
cd ./extensions
7+
find . -type f -exec curl -H "X-JFrog-Art-Api:$ARTIFACTORY_TOKEN" -T '{}' "$ARTIFACTORY_URI/$ARTIFACTORY_REPO/"'{}' \;

Diff for: fixtures/versions

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1.0.0
2+
1.1.1
3+
1.3.5
4+
2.1.0
5+
3.0.0

0 commit comments

Comments
 (0)