Skip to content

Commit d3a1f77

Browse files
authored
Merge pull request #9 from CoderSerio/feat/carbon-dev
Feat/carbon dev
2 parents bfb5d0a + 623d32b commit d3a1f77

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

.github/workflows/Release.yml

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,37 @@ jobs:
133133
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
134134
const v = p.version;
135135
p.optionalDependencies = {
136-
'rush-fs-win32-x64-msvc': v,
137-
'rush-fs-darwin-x64': v,
138-
'rush-fs-linux-x64-gnu': v,
139-
'rush-fs-darwin-arm64': v
136+
'@rush-fs/rush-fs-win32-x64-msvc': v,
137+
'@rush-fs/rush-fs-darwin-x64': v,
138+
'@rush-fs/rush-fs-linux-x64-gnu': v,
139+
'@rush-fs/rush-fs-darwin-arm64': v
140140
};
141141
fs.writeFileSync('package.json', JSON.stringify(p, null, 2));
142142
"
143+
- name: Update platform package names to use scope (@rush-fs/xxx)
144+
run: |
145+
for dir in npm/*/; do
146+
if [ -f "$dir/package.json" ]; then
147+
PKG_PATH="$dir/package.json"
148+
export PKG_PATH
149+
node -e "
150+
const fs = require('fs');
151+
const pkgPath = process.env.PKG_PATH;
152+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
153+
console.log('Updating package name from', pkg.name, 'to @rush-fs/' + pkg.name);
154+
if (!pkg.name.startsWith('@rush-fs/')) {
155+
pkg.name = '@rush-fs/' + pkg.name;
156+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
157+
}
158+
"
159+
fi
160+
done
143161
- name: Publish to npm
144162
run: |
145163
npm config set provenance true
146164
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
147-
# 读取 package.json 版本号,检查对应的 tag 是否已存在
165+
# 先 fetch tags,然后检查对应的 tag 是否已存在
166+
git fetch --tags --force
148167
VERSION=$(node -p "require('./package.json').version")
149168
TAG="v$VERSION"
150169
if git rev-parse "$TAG" >/dev/null 2>&1; then
@@ -154,6 +173,26 @@ jobs:
154173
echo "Tag $TAG does not exist, will create GitHub Release"
155174
pnpm prepublishOnly
156175
fi
176+
# prepublish 之后再次更新包名(因为 prepublish 可能会更新 package.json)
177+
for dir in npm/*/; do
178+
if [ -f "$dir/package.json" ]; then
179+
PKG_PATH="$dir/package.json"
180+
export PKG_PATH
181+
node -e "
182+
const fs = require('fs');
183+
const pkgPath = process.env.PKG_PATH;
184+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
185+
if (!pkg.name.startsWith('@rush-fs/')) {
186+
console.log('Fixing package name:', pkg.name, '-> @rush-fs/' + pkg.name);
187+
pkg.name = '@rush-fs/' + pkg.name;
188+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
189+
}
190+
"
191+
fi
192+
done
193+
# 主包 index.js 里 require 的是 rush-fs-xxx,改为 @rush-fs/rush-fs-xxx 才能找到已发布的平台包
194+
sed -i "s/require('rush-fs-/require('@rush-fs\/rush-fs-/g" index.js
195+
sed -i 's/require(\"rush-fs-/require(\"@rush-fs\/rush-fs-/g' index.js
157196
npm publish --access public
158197
env:
159198
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "rush-fs",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "High-performance drop-in replacement for Node.js fs module, powered by Rust",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
8-
"url": "git+https://github.com/rush-fs/rush-fs.git"
8+
"url": "git+https://github.com/CoderSerio/rush-fs.git"
99
},
1010
"license": "MIT",
1111
"browser": "browser.js",

0 commit comments

Comments
 (0)