From 92fdb1cb3896ad49477dab079b4b66fb9bef68d6 Mon Sep 17 00:00:00 2001 From: hustcer Date: Fri, 6 Feb 2026 19:53:46 +0800 Subject: [PATCH 1/2] feat: Add nu/build.nu for assets building --- nu/build.nu | 37 +++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 nu/build.nu diff --git a/nu/build.nu b/nu/build.nu new file mode 100644 index 00000000..56e77c2 --- /dev/null +++ b/nu/build.nu @@ -0,0 +1,37 @@ +#!/usr/bin/env nu +# Description: Build the setup-nu action +# This script replaces the complex build command in package.json + +# Get the project root directory +let root = $env.FILE_PWD | path dirname + +# Step 1: Remove dist directory +let dist_dir = $root | path join dist +if ($dist_dir | path exists) { + rm -rf $dist_dir + print $'Removed ($dist_dir)' +} + +# Step 2: Build with ncc +print 'Building with ncc...' +cd $root +^ncc build src/index.ts --minify + +# Step 3: Rename exec-child.js to exec-child.cjs +let exec_child_js = $dist_dir | path join exec-child.js +let exec_child_cjs = $dist_dir | path join exec-child.cjs +if ($exec_child_js | path exists) { + mv $exec_child_js $exec_child_cjs + print $'Renamed exec-child.js to exec-child.cjs' +} + +# Step 4: Replace 'exec-child.js' with 'exec-child.cjs' in index.js +let index_js = $dist_dir | path join index.js +if ($index_js | path exists) { + open --raw $index_js + | str replace -a 'exec-child.js' 'exec-child.cjs' + | save -f $index_js + print $'Updated references in index.js' +} + +print 'Build completed!' diff --git a/package.json b/package.json index 901f074..6952d26 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "fmt": "biome format . --write", "lint": "biome lint **/*.ts", - "build": "rm -rf dist/ && ncc build src/index.ts --minify && mv dist/exec-child.js dist/exec-child.cjs && node -e \"const fs=require('fs');const f='dist/index.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace(/exec-child\\.js/g,'exec-child.cjs'))\"", + "build": "nu nu/build.nu", "run": "pnpm run build && RUNNER_TOOL_CACHE=./runner/cache RUNNER_TEMP=./runner/temp node dist/index.js" }, "repository": { From 920ef794781f60c872ce1ae27db1b3ff4ae8efed Mon Sep 17 00:00:00 2001 From: hustcer Date: Fri, 6 Feb 2026 19:57:45 +0800 Subject: [PATCH 2/2] feat: Add nu/build.nu for assets building --- .github/workflows/build.yaml | 2 ++ .github/workflows/use-nightly.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a2e74d2..01560d3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,6 +19,8 @@ jobs: - uses: actions/setup-node@v6 with: node-version: '24' + - name: Setup nu + uses: hustcer/setup-nu@v3 - name: Build Setup Script run: | npm i -g pnpm diff --git a/.github/workflows/use-nightly.yaml b/.github/workflows/use-nightly.yaml index c6f9c36..3bf34c5 100644 --- a/.github/workflows/use-nightly.yaml +++ b/.github/workflows/use-nightly.yaml @@ -19,6 +19,8 @@ jobs: - uses: actions/setup-node@v6 with: node-version: '24' + - name: Setup nu + uses: hustcer/setup-nu@v3 - name: Build Setup Script run: | npm i -g pnpm