File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,9 +67,6 @@ remote-client/build
6767# Temporary backup during publish
6868.publish-backup
6969
70- # NPM publish flag file
71- .npm-publish-in-progress
72-
7370# Build artifacts
7471* .tgz
7572
Original file line number Diff line number Diff line change @@ -60,8 +60,9 @@ release:
6060 - export NEW_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^cli-release-v//')
6161 # 更新版本号
6262 - npm version "$NEW_VERSION" --no-git-tag-version --force
63- # 发布到 npm(prepublishOnly 钩子会自动执行 prepare-publish.js 和 bundle:prod )
63+ # 发布到 npm(设置 SKIP_PREPARE=1 让 prepare 钩子也跳过 )
6464 - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
65+ - export SKIP_PREPARE=1
6566 - npm publish
6667 after_script :
6768 - rm -f .npmrc || true
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ const rootDir = path.dirname(__dirname);
1414
1515function preparePublish ( ) {
1616 const readmePath = path . join ( rootDir , 'README.md' ) ;
17- const publishFlagFile = path . join ( rootDir , '.npm-publish-in-progress' ) ;
1817
1918 console . log ( chalk . cyan ( '\n📦 Preparing publication package...\n' ) ) ;
2019
@@ -26,14 +25,6 @@ function preparePublish() {
2625
2726 console . log ( chalk . green ( '✅ README.md check passed' ) ) ;
2827 console . log ( chalk . dim ( ' (No README replacement needed)\n' ) ) ;
29-
30- // Create a flag file to signal that we're in publish mode
31- // This prevents the prepare hook from running redundant builds
32- try {
33- fs . writeFileSync ( publishFlagFile , Date . now ( ) . toString ( ) ) ;
34- } catch ( err ) {
35- console . warn ( chalk . yellow ( '⚠️ Failed to create publish flag file:' , err . message ) ) ;
36- }
3728}
3829
3930preparePublish ( ) ;
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
33import { execSync } from 'child_process' ;
4- import { existsSync , unlinkSync } from 'fs' ;
5- import { join , dirname } from 'path' ;
6- import { fileURLToPath } from 'url' ;
7-
8- const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
9- const root = join ( __dirname , '..' ) ;
10- const publishFlagFile = join ( root , '.npm-publish-in-progress' ) ;
114
125const buildEnv = process . env . BUILD_ENV ;
136
147// Skip build during npm publish (prepublishOnly will handle it)
15- if ( process . env . SKIP_PREPARE === '1' || existsSync ( publishFlagFile ) ) {
8+ if ( process . env . SKIP_PREPARE === '1' ) {
169 console . log ( '⏭️ Skipping prepare build (handled by prepublishOnly or explicitly disabled)' ) ;
17-
18- // Clean up the flag file if it exists (prepare is the last hook in publish flow)
19- if ( existsSync ( publishFlagFile ) ) {
20- try {
21- unlinkSync ( publishFlagFile ) ;
22- } catch ( err ) {
23- // Ignore errors in cleanup
24- }
25- }
26-
2710 process . exit ( 0 ) ;
2811}
2912
@@ -34,4 +17,4 @@ if (buildEnv === 'development') {
3417} else {
3518 console . log ( 'Running production bundle...' ) ;
3619 execSync ( 'npm run bundle:prod' , { stdio : 'inherit' } ) ;
37- }
20+ }
You can’t perform that action at this time.
0 commit comments