Skip to content

Commit e55b231

Browse files
authored
Merge pull request #11 from thediveo/develop
fix: docsify feature
2 parents ef42564 + 7cebd92 commit e55b231

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

src/docsify/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "docsify",
33
"id": "docsify",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"description": "Automatically serves ./docs workspace directory via 'docsify serve' in the background.",
66
"options": {
77
"port": {

src/docsify/install.sh

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DOCSIFY_SERVE_PATH="/usr/local/bin/docsify-serve"
66
DOCS_PATH=${DOCS_PATH:-docs}
77

88
echo "Activating feature 'docsify-cli'..."
9+
910
npm install -g docsify-cli
1011

1112
# The fallback/default index.html file to use when the documents directory does
@@ -14,23 +15,23 @@ DEFAULT_INDEX_HTML=$(cat <<EOF
1415
<!DOCTYPE html>
1516
<html lang="en">
1617
<head>
17-
<meta charset="UTF-8">
18-
<title>Fake Site</title>
19-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
20-
<meta name="description" content="Description">
21-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
22-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
18+
<meta charset="UTF-8">
19+
<title>Fake Site</title>
20+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
21+
<meta name="description" content="Description">
22+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
23+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
2324
</head>
2425
<body>
25-
<div id="app"></div>
26-
<script>
27-
window.$docsify = {
28-
name: 'fakesite',
29-
repo: 'fakerepo'
30-
}
31-
</script>
32-
<!-- Docsify v4 -->
33-
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
26+
<div id="app"></div>
27+
<script>
28+
window.$docsify = {
29+
name: 'fakesite',
30+
repo: 'fakerepo'
31+
}
32+
</script>
33+
<!-- Docsify v4 -->
34+
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
3435
</body>
3536
</html>
3637
EOF
@@ -48,11 +49,26 @@ EOF
4849
tee "${DOCSIFY_SERVE_PATH}" > /dev/null \
4950
<< EOF
5051
#!/usr/bin/env sh
52+
53+
# we need to explicitly "activate" (the current) node here, as otherwise
54+
# devcontainers using our feature and also setting their remoteEnv PATH will
55+
# cause our script to fail when run as the postStartCommand.
56+
. /usr/local/share/nvm/nvm.sh
57+
nvm use node
58+
5159
mkdir -p "${DOCS_PATH}"
5260
if [ ! -f "${DOCS_PATH}/index.html" ]; then
5361
echo "${DEFAULT_INDEX_HTML}" > "${DOCS_PATH}/index.html"
5462
echo "${DEFAULT_README_MD}" > "${DOCS_PATH}/README.md"
5563
fi
56-
nohup bash -c "docsify serve -p=${PORT} -P=${LIVERELOAD_PORT} --no-open ./${DOCS_PATH} &" >/tmp/nohup.log 2>&1
64+
65+
nohup bash -c "\
66+
docsify serve \
67+
-p=${PORT} \
68+
-P=${LIVERELOAD_PORT} \
69+
--no-open \
70+
${DOCS_PATH} \
71+
&" >/tmp/nohup-docsify.log 2>&1
5772
EOF
73+
5874
chmod 0755 "${DOCSIFY_SERVE_PATH}"

test/docsify/port_5678.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source dev-container-features-test-lib
66
CMD=$(cat <<EOF
77
curl --output /dev/null \
88
--retry-connrefused --retry-delay 1 --retry 3 \
9-
--silent --head --fail \
9+
--head --fail \
1010
http://localhost:5678
1111
EOF
1212
)

test/docsify/test.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66

77
set -e
88

9-
echo "installing puppeteer..."
10-
sudo apt-get update
11-
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
12-
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] https://dl-ssl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
13-
sudo apt-get update
14-
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 dbus dbus-x11 --no-install-recommends
15-
npm install puppeteer --save
16-
179
source dev-container-features-test-lib
1810

1911
CMD=$(cat <<EOF
2012
curl --output /dev/null \
2113
--retry-connrefused --retry-delay 1 --retry 3 \
22-
silent --head --fail \
23-
http://localhost:3300
14+
--head --fail \
15+
http://localhost:3300/
2416
EOF
2517
)
2618
check "serves at default port 3300" bash -c "${CMD}"
2719

20+
echo "installing puppeteer..."
21+
sudo apt-get update
22+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
23+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] https://dl-ssl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
24+
sudo apt-get update
25+
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 dbus dbus-x11 --no-install-recommends
26+
npm install puppeteer --save
27+
2828
SCRIPT=$(cat <<EOF
2929
import puppeteer from 'puppeteer';
3030

0 commit comments

Comments
 (0)