33/**
44 * Remote publish script
55 * This publishes both mpp-core and mpp-ui to npm registry
6- *
6+ *
77 * Steps:
8- * 1. Build and publish @autodev /mpp-core to npm
8+ * 1. Build and publish @xiuper /mpp-core to npm
99 * 2. Update package.json to use published version
1010 * 3. Build and publish @autodev/cli
1111 * 4. Restore package.json to use local file: dependency
@@ -33,7 +33,7 @@ function askConfirmation(question) {
3333 input : process . stdin ,
3434 output : process . stdout
3535 } ) ;
36-
36+
3737 rl . question ( question + ' (y/N): ' , ( answer ) => {
3838 rl . close ( ) ;
3939 resolve ( answer . toLowerCase ( ) === 'y' || answer . toLowerCase ( ) === 'yes' ) ;
@@ -43,46 +43,46 @@ function askConfirmation(question) {
4343
4444async function main ( ) {
4545 console . log ( '🚀 Remote Publish Script for @xiuper/cli\n' ) ;
46-
46+
4747 // Read current package.json
4848 const packageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf-8' ) ) ;
4949 const currentVersion = packageJson . version ;
50-
50+
5151 console . log ( '📦 Current package info:' ) ;
5252 console . log ( ' Name:' , packageJson . name ) ;
5353 console . log ( ' Version:' , currentVersion ) ;
5454 console . log ( ' mpp-core dependency:' , packageJson . dependencies [ '@xiuper/mpp-core' ] ) ;
5555 console . log ( ) ;
56-
56+
5757 // Confirm publish
5858 const shouldContinue = await askConfirmation ( 'Do you want to continue with remote publish?' ) ;
5959 if ( ! shouldContinue ) {
6060 console . log ( '❌ Publish cancelled' ) ;
6161 process . exit ( 0 ) ;
6262 }
63-
64- // Step 1: Build mpp-core
63+
64+ // Step 1: Build mpp-core (includes automatic package.json fix)
6565 console . log ( '\n1️⃣ Building mpp-core...' ) ;
6666 try {
6767 execSync ( 'npm run build:kotlin' , { cwd : rootDir , stdio : 'inherit' } ) ;
68- console . log ( '✅ mpp-core build complete\n' ) ;
68+ console . log ( '✅ mpp-core build complete (package.json fixed automatically) \n' ) ;
6969 } catch ( error ) {
7070 console . error ( '❌ mpp-core build failed' ) ;
7171 process . exit ( 1 ) ;
7272 }
73-
73+
7474 // Step 2: Check if mpp-core package exists
7575 console . log ( '2️⃣ Checking mpp-core package...' ) ;
7676 const mppCorePackageJsonPath = resolve ( mppCorePackageDir , 'package.json' ) ;
7777 if ( ! existsSync ( mppCorePackageJsonPath ) ) {
7878 console . error ( '❌ mpp-core package.json not found at:' , mppCorePackageJsonPath ) ;
7979 process . exit ( 1 ) ;
8080 }
81-
81+
8282 const mppCorePackageJson = JSON . parse ( readFileSync ( mppCorePackageJsonPath , 'utf-8' ) ) ;
8383 const mppCoreVersion = mppCorePackageJson . version ;
8484 console . log ( '✅ mpp-core package found (v' + mppCoreVersion + ')\n' ) ;
85-
85+
8686 // Step 3: Publish mpp-core to npm
8787 console . log ( '3️⃣ Publishing @xiuper/mpp-core...' ) ;
8888 const shouldPublishCore = await askConfirmation ( 'Publish @xiuper/mpp-core v' + mppCoreVersion + ' to npm?' ) ;
@@ -92,11 +92,11 @@ async function main() {
9292 try {
9393 // Check if user is logged in
9494 execSync ( 'npm whoami' , { cwd : mppCorePackageDir , stdio : 'pipe' } ) ;
95-
95+
9696 // Publish
9797 execSync ( 'npm publish --access public' , { cwd : mppCorePackageDir , stdio : 'inherit' } ) ;
9898 console . log ( '✅ mpp-core published successfully\n' ) ;
99-
99+
100100 // Wait a bit for npm registry to update
101101 console . log ( '⏳ Waiting for npm registry to update (5 seconds)...' ) ;
102102 await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
@@ -107,15 +107,15 @@ async function main() {
107107 process . exit ( 1 ) ;
108108 }
109109 }
110-
110+
111111 // Step 4: Backup and update package.json
112112 console . log ( '4️⃣ Updating package.json for remote dependency...' ) ;
113113 copyFileSync ( packageJsonPath , packageJsonBackupPath ) ;
114-
114+
115115 packageJson . dependencies [ '@xiuper/mpp-core' ] = '^' + mppCoreVersion ;
116116 writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) + '\n' ) ;
117117 console . log ( '✅ Updated to use @xiuper/mpp-core@^' + mppCoreVersion + '\n' ) ;
118-
118+
119119 // Step 5: Install dependencies with remote version
120120 console . log ( '5️⃣ Installing dependencies...' ) ;
121121 try {
@@ -127,7 +127,7 @@ async function main() {
127127 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
128128 process . exit ( 1 ) ;
129129 }
130-
130+
131131 // Step 6: Build TypeScript
132132 console . log ( '6️⃣ Building TypeScript...' ) ;
133133 try {
@@ -139,7 +139,7 @@ async function main() {
139139 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
140140 process . exit ( 1 ) ;
141141 }
142-
142+
143143 // Step 7: Publish @xiuper/cli
144144 console . log ( '7️⃣ Publishing @xiuper/cli...' ) ;
145145 const shouldPublishCli = await askConfirmation ( 'Publish @xiuper/cli v' + currentVersion + ' to npm?' ) ;
@@ -149,7 +149,7 @@ async function main() {
149149 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
150150 process . exit ( 0 ) ;
151151 }
152-
152+
153153 try {
154154 execSync ( 'npm publish --access public' , { cwd : rootDir , stdio : 'inherit' } ) ;
155155 console . log ( '✅ @xiuper/cli published successfully\n' ) ;
@@ -159,12 +159,12 @@ async function main() {
159159 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
160160 process . exit ( 1 ) ;
161161 }
162-
162+
163163 // Step 8: Restore package.json for local development
164164 console . log ( '8️⃣ Restoring package.json for local development...' ) ;
165165 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
166166 console . log ( '✅ package.json restored\n' ) ;
167-
167+
168168 // Step 9: Reinstall with local file: dependency
169169 console . log ( '9️⃣ Reinstalling local dependencies...' ) ;
170170 try {
@@ -173,7 +173,7 @@ async function main() {
173173 } catch ( error ) {
174174 console . warn ( '⚠️ npm install failed, you may need to run it manually\n' ) ;
175175 }
176-
176+
177177 console . log ( '🎉 Remote publish complete!\n' ) ;
178178 console . log ( '📦 Published packages:' ) ;
179179 console . log ( ' @xiuper/mpp-core@' + mppCoreVersion ) ;
@@ -186,12 +186,12 @@ async function main() {
186186
187187main ( ) . catch ( error => {
188188 console . error ( '❌ Unexpected error:' , error ) ;
189-
189+
190190 // Try to restore package.json
191191 if ( existsSync ( packageJsonBackupPath ) ) {
192192 console . log ( '🔄 Restoring package.json...' ) ;
193193 copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
194194 }
195-
195+
196196 process . exit ( 1 ) ;
197197} ) ;
0 commit comments