()
| 137 | } |
| 138 | |
| 139 | async function main(): Promise<void> { |
| 140 | try { |
| 141 | if (isGitHubCI()) { |
| 142 | const version = await resolveVersion(); |
| 143 | if (!isValidSemver(version)) { |
| 144 | throw new Error( |
| 145 | `Resolved version "${version}" is not a valid semantic version. ` + |
| 146 | `Please ensure RELEASE_VERSION, GITHUB_REF, or GITHUB_REF_NAME is set correctly, ` + |
| 147 | `or that the git history is fully fetched.` |
| 148 | ); |
| 149 | } |
| 150 | console.log(`Using publish version ${version}`); |
| 151 | await modifyPackageJson({ version }); |
| 152 | } else { |
| 153 | console.log( |
| 154 | 'ℹ️ Not in GitHub CI, skipping version resolution and package.json modification', |
| 155 | ); |
| 156 | if (shouldSkipNativeBuild()) { |
| 157 | console.log( |
| 158 | 'ℹ️ --skip flag detected, skipping native artifacts build', |
| 159 | ); |
| 160 | } else { |
| 161 | await buildNativeArtifacts(); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | console.log('✅ Prepublish script completed successfully'); |
| 166 | } catch (error) { |
| 167 | console.error('❌ Prepublish script failed:', error); |
| 168 | process.exit(1); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | main(); |
no test coverage detected