Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: docsify feature #11

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/docsify/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docsify",
"id": "docsify",
"version": "0.1.0",
"version": "0.1.1",
"description": "Automatically serves ./docs workspace directory via 'docsify serve' in the background.",
"options": {
"port": {
Expand Down
48 changes: 32 additions & 16 deletions src/docsify/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DOCSIFY_SERVE_PATH="/usr/local/bin/docsify-serve"
DOCS_PATH=${DOCS_PATH:-docs}

echo "Activating feature 'docsify-cli'..."

npm install -g docsify-cli

# The fallback/default index.html file to use when the documents directory does
Expand All @@ -14,23 +15,23 @@ DEFAULT_INDEX_HTML=$(cat <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fake Site</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
<meta charset="UTF-8">
<title>Fake Site</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'fakesite',
repo: 'fakerepo'
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<div id="app"></div>
<script>
window.$docsify = {
name: 'fakesite',
repo: 'fakerepo'
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</body>
</html>
EOF
Expand All @@ -48,11 +49,26 @@ EOF
tee "${DOCSIFY_SERVE_PATH}" > /dev/null \
<< EOF
#!/usr/bin/env sh

# we need to explicitly "activate" (the current) node here, as otherwise
# devcontainers using our feature and also setting their remoteEnv PATH will
# cause our script to fail when run as the postStartCommand.
. /usr/local/share/nvm/nvm.sh
nvm use node

mkdir -p "${DOCS_PATH}"
if [ ! -f "${DOCS_PATH}/index.html" ]; then
echo "${DEFAULT_INDEX_HTML}" > "${DOCS_PATH}/index.html"
echo "${DEFAULT_README_MD}" > "${DOCS_PATH}/README.md"
fi
nohup bash -c "docsify serve -p=${PORT} -P=${LIVERELOAD_PORT} --no-open ./${DOCS_PATH} &" >/tmp/nohup.log 2>&1

nohup bash -c "\
docsify serve \
-p=${PORT} \
-P=${LIVERELOAD_PORT} \
--no-open \
${DOCS_PATH} \
&" >/tmp/nohup-docsify.log 2>&1
EOF

chmod 0755 "${DOCSIFY_SERVE_PATH}"
2 changes: 1 addition & 1 deletion test/docsify/port_5678.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source dev-container-features-test-lib
CMD=$(cat <<EOF
curl --output /dev/null \
--retry-connrefused --retry-delay 1 --retry 3 \
--silent --head --fail \
--head --fail \
http://localhost:5678
EOF
)
Expand Down
20 changes: 10 additions & 10 deletions test/docsify/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

set -e

echo "installing puppeteer..."
sudo apt-get update
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
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
sudo apt-get update
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
npm install puppeteer --save

source dev-container-features-test-lib

CMD=$(cat <<EOF
curl --output /dev/null \
--retry-connrefused --retry-delay 1 --retry 3 \
silent --head --fail \
http://localhost:3300
--head --fail \
http://localhost:3300/
EOF
)
check "serves at default port 3300" bash -c "${CMD}"

echo "installing puppeteer..."
sudo apt-get update
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg
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
sudo apt-get update
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
npm install puppeteer --save

SCRIPT=$(cat <<EOF
import puppeteer from 'puppeteer';

Expand Down