From 15660a9ba35479123c180ff1edab5764fc6ba2eb Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Thu, 23 May 2024 16:21:20 -0400 Subject: [PATCH] Add build.sh and entrypoint.sh for building and packing packages --- .gitignore | 1 + build.sh | 13 +++++++++++++ docker/entrypoint.sh | 14 ++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 build.sh create mode 100755 docker/entrypoint.sh diff --git a/.gitignore b/.gitignore index d5a0784..9b0ae45 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,4 @@ dist # Finder (MacOS) folder config .DS_Store .turbo +.vscode \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..8d80ab2 --- /dev/null +++ b/build.sh @@ -0,0 +1,13 @@ +for ext in $(ls extensions); do + # Check if ext is a directory and contains package.json + if [ ! -d "extensions/$ext" ] || [ ! -f "extensions/$ext/package.json" ]; then + echo "Skipping $ext" + continue + fi + echo "Building $ext" + docker run -v $(pwd)/entrypoint.sh:/entrypoint.sh \ + -v $(pwd)/extensions/$ext:/workspace \ + -w /workspace --rm \ + --platform=linux/amd64 \ + node:20 /entrypoint.sh +done diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..8cb51f6 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,14 @@ +cd /workspace +rm *.tgz +cp -r /workspace /workspace-copy +cd /workspace-copy +npm i +npm run build +npm pack +# check number of *.tgz file in current directory +# if more than 1, then exit with error +if [ $(ls -1 *.tgz 2>/dev/null | wc -l) -gt 1 ]; then + echo "More than one tgz file found" + exit 1 +fi +cp *.tgz /workspace