-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrite the whole thing using Bun
- Loading branch information
1 parent
0edabca
commit f82e819
Showing
10 changed files
with
407 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile.tcli --tag ghcr.io/greentf/tcli:latest | ||
run: docker build . --file Dockerfile.tcli --tag ghcr.io/greentf/tcli:bun | ||
- name: Authenticate with GHCR | ||
if: ${{ github.event_name == 'release' || github.event.inputs.push == 'true' }} | ||
uses: docker/[email protected] | ||
|
@@ -29,4 +29,4 @@ jobs: | |
password: ${{ secrets.GHCR_TOKEN }} | ||
- name: Push container | ||
if: ${{ github.event_name == 'release' || github.event.inputs.push == 'true' }} | ||
run: docker push ghcr.io/greentf/tcli:latest | ||
run: docker push ghcr.io/greentf/tcli:bun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
FROM denoland/deno as cache | ||
ENV DENO_DIR=/var/tmp/deno_cache | ||
COPY ./cfg_edit.js /cfg_edit.js | ||
RUN deno cache /cfg_edit.js | ||
FROM ghcr.io/greentf/tcli | ||
ENV DENO_DIR=/var/tmp/deno_cache | ||
COPY --from=cache ${DENO_DIR} ${DENO_DIR} | ||
FROM ghcr.io/greentf/tcli:bun | ||
COPY ./entrypoint.sh /entrypoint.sh | ||
COPY ./cfg_edit.js /cfg_edit.js | ||
COPY ./index.ts /index.ts | ||
COPY ./package.json /package.json | ||
COPY ./bun.lockb /bun.lockb | ||
RUN ["bun", "install", "--frozen-lockfile"] | ||
RUN ["chmod", "+x", "/entrypoint.sh"] | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,2 @@ | ||
#!/bin/bash | ||
function setup() { | ||
echo "::group::Set up environment" | ||
|
||
# If the TS_PATH var is set and not empty | ||
if [ -n "$TS_PATH" ]; then | ||
echo "::debug::TS_PATH found" | ||
p=$(echo $TS_PATH | sed 's:$/*::') #trim any trailing '/' | ||
else | ||
echo "::debug::TS_PATH not set" | ||
p="." | ||
fi | ||
|
||
mkdir -p "/dist" | ||
|
||
# Move files to the dist directory for the tcli | ||
echo "Move files from $p to /dist" | ||
mv $p/* /dist | ||
|
||
# Move the README if it exists | ||
if [ -e "/dist/README.md" ]; then | ||
echo "Move README" | ||
mv "/dist/README.md" "/" | ||
elif [ -n "$TS_README" ]; then | ||
echo "Download README from $TS_README" | ||
wget -O "/README.md" "$TS_README" | ||
fi | ||
|
||
if [ -e "/dist/icon.png" ]; then | ||
echo "Move icon" | ||
mv "/dist/icon.png" "/" | ||
elif [ -n "$TS_ICON" ]; then | ||
echo "Download icon from $TS_ICON" | ||
wget -O "/icon.png" "$TS_ICON" | ||
fi | ||
|
||
|
||
echo "::endgroup::" | ||
|
||
} | ||
function configure(){ | ||
cd "/" | ||
|
||
echo "::group::Configure tcli" | ||
|
||
#tcli usage based off of https://github.com/R2Northstar/Northstar/blob/d8ad8f12f8bca1e8de96f5d7163f71997d487218/.github/workflows/build.yml#L132-L192 | ||
echo "Init tcli config" | ||
tcli init --package-name ${TS_NAME} --package-namespace ${TS_NAMESPACE} --package-version ${TS_VERSION#v} | ||
|
||
deno run --allow-net --allow-env --allow-read --allow-write cfg_edit.js | ||
|
||
echo "Done config edit" | ||
echo | ||
echo "::debug::$(cat thunderstore.toml)" | ||
echo "::endgroup::" | ||
} | ||
|
||
|
||
function publish() { | ||
if [ -n "$TS_DEV" ]; then | ||
repo="https://thunderstore.dev" | ||
elif [ -n "$TS_REPO" ]; then | ||
repo="https://thunderstore.io" | ||
else | ||
repo="$TS_REPO" | ||
fi | ||
|
||
# skip the build if there is a prebuilt package provided | ||
if [ -n "$TS_FILE" ]; then | ||
echo "::group::Publish package" | ||
echo "Publish to $repo" | ||
file="dist/$TS_FILE" | ||
else | ||
echo "::group::Build and publish" | ||
tcli build | ||
echo "Publish to $repo" | ||
file="build/*.zip" | ||
fi | ||
|
||
out=$(tcli publish --repository ${repo} --file ${file}) #capture the output to get the URL | ||
# A bad response from the server doesn't exit with a non-zero status code | ||
if [[ $? -ne 0 ]]; then | ||
echo "::error::$(echo ${out} | grep -Eo ERROR:.*)" | ||
exit 1 | ||
fi | ||
echo "url=$(echo ${out} | grep -Eo "https.*")" >> $GITHUB_OUTPUT | ||
echo "Done!" | ||
echo "::endgroup::" | ||
} | ||
|
||
set -e | ||
setup | ||
configure | ||
set +e # Turn this off so we can see the output from tcli publish | ||
publish | ||
|
||
|
||
bun run index.ts |
Oops, something went wrong.