-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
const nextVersion = process.argv[2]; | ||
|
||
const packageEntry = process.cwd(); | ||
|
||
const packageName = path.basename(packageEntry); | ||
const scrEntry = path.resolve(packageEntry, './src/index.ts'); | ||
|
||
function generateNextVersion() { | ||
const versionCode = `\nexport const version = '${nextVersion}';\n`; | ||
fs.writeFileSync(scrEntry, versionCode, { encoding: 'utf8', flag: 'a+' }); | ||
} | ||
|
||
function build() { | ||
// 直接运行 yarn build 要报错,用一下蠢办法 | ||
execSync(`yarn clean`, { | ||
stdio: 'inherit', | ||
}); | ||
|
||
execSync(`yarn build:umd & yarn build:cjs & yarn build:esm`, { | ||
stdio: 'inherit', | ||
}); | ||
|
||
execSync(`yarn dts:build && yarn dts:extract`, { | ||
stdio: 'inherit', | ||
}); | ||
} | ||
|
||
function restoreVersionChange() { | ||
execSync(`git restore ${scrEntry}`, { stdio: 'inherit' }); | ||
Check warning Code scanning / CodeQL Shell command built from environment values Medium
This shell command depends on an uncontrolled
absolute path Error loading related location Loading This shell command depends on an uncontrolled absolute path Error loading related location Loading |
||
} | ||
|
||
console.log(`🔖 ${packageName} 添加 nextVersion: ${nextVersion}\n`); | ||
|
||
generateNextVersion(); | ||
build(); | ||
restoreVersionChange(); | ||
|
||
console.log(`✅ ${packageName} nextVersion(${nextVersion}) 添加成功 \n`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters