chore: port publish script to ts
This commit is contained in:
@@ -40,17 +40,22 @@
|
||||
"@swc/register": "0.1.10",
|
||||
"@testing-library/jest-dom": "5.17.0",
|
||||
"@testing-library/react": "13.4.0",
|
||||
"@types/fs-extra": "^11.0.2",
|
||||
"@types/jest": "29.5.4",
|
||||
"@types/minimist": "1.2.2",
|
||||
"@types/node": "20.5.7",
|
||||
"@types/prompts": "^2.4.5",
|
||||
"@types/qs": "6.9.7",
|
||||
"@types/react": "18.2.15",
|
||||
"@types/shelljs": "0.8.12",
|
||||
"@types/testing-library__jest-dom": "5.14.8",
|
||||
"chalk": "^5.3.0",
|
||||
"copyfiles": "2.4.1",
|
||||
"cross-env": "7.0.3",
|
||||
"dotenv": "8.6.0",
|
||||
"express": "4.18.2",
|
||||
"form-data": "3.0.1",
|
||||
"fs-extra": "10.1.0",
|
||||
"get-port": "5.1.1",
|
||||
"glob": "8.1.0",
|
||||
"graphql-request": "6.1.0",
|
||||
@@ -60,10 +65,12 @@
|
||||
"jest-environment-jsdom": "29.6.4",
|
||||
"jwt-decode": "3.1.2",
|
||||
"lint-staged": "^14.0.1",
|
||||
"minimist": "1.2.8",
|
||||
"mongodb-memory-server": "8.12.2",
|
||||
"node-fetch": "2.6.12",
|
||||
"nodemon": "3.0.1",
|
||||
"prettier": "^3.0.3",
|
||||
"prompts": "2.4.2",
|
||||
"qs": "6.11.2",
|
||||
"rimraf": "3.0.2",
|
||||
"shelljs": "0.8.5",
|
||||
|
||||
44
pnpm-lock.yaml
generated
44
pnpm-lock.yaml
generated
@@ -39,12 +39,21 @@ importers:
|
||||
'@testing-library/react':
|
||||
specifier: 13.4.0
|
||||
version: 13.4.0(react-dom@18.2.0)(react@18.2.0)
|
||||
'@types/fs-extra':
|
||||
specifier: ^11.0.2
|
||||
version: 11.0.2
|
||||
'@types/jest':
|
||||
specifier: 29.5.4
|
||||
version: 29.5.4
|
||||
'@types/minimist':
|
||||
specifier: 1.2.2
|
||||
version: 1.2.2
|
||||
'@types/node':
|
||||
specifier: 20.5.7
|
||||
version: 20.5.7
|
||||
'@types/prompts':
|
||||
specifier: ^2.4.5
|
||||
version: 2.4.5
|
||||
'@types/qs':
|
||||
specifier: 6.9.7
|
||||
version: 6.9.7
|
||||
@@ -57,6 +66,9 @@ importers:
|
||||
'@types/testing-library__jest-dom':
|
||||
specifier: 5.14.8
|
||||
version: 5.14.8
|
||||
chalk:
|
||||
specifier: ^5.3.0
|
||||
version: 5.3.0
|
||||
copyfiles:
|
||||
specifier: 2.4.1
|
||||
version: 2.4.1
|
||||
@@ -72,6 +84,9 @@ importers:
|
||||
form-data:
|
||||
specifier: 3.0.1
|
||||
version: 3.0.1
|
||||
fs-extra:
|
||||
specifier: 10.1.0
|
||||
version: 10.1.0
|
||||
get-port:
|
||||
specifier: 5.1.1
|
||||
version: 5.1.1
|
||||
@@ -99,6 +114,9 @@ importers:
|
||||
lint-staged:
|
||||
specifier: ^14.0.1
|
||||
version: 14.0.1
|
||||
minimist:
|
||||
specifier: 1.2.8
|
||||
version: 1.2.8
|
||||
mongodb-memory-server:
|
||||
specifier: 8.12.2
|
||||
version: 8.12.2
|
||||
@@ -111,6 +129,9 @@ importers:
|
||||
prettier:
|
||||
specifier: ^3.0.3
|
||||
version: 3.0.3
|
||||
prompts:
|
||||
specifier: 2.4.2
|
||||
version: 2.4.2
|
||||
qs:
|
||||
specifier: 6.11.2
|
||||
version: 6.11.2
|
||||
@@ -4319,6 +4340,13 @@ packages:
|
||||
'@types/webpack': 4.41.33
|
||||
dev: true
|
||||
|
||||
/@types/fs-extra@11.0.2:
|
||||
resolution: {integrity: sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ==}
|
||||
dependencies:
|
||||
'@types/jsonfile': 6.1.2
|
||||
'@types/node': 20.6.2
|
||||
dev: true
|
||||
|
||||
/@types/glob@7.2.0:
|
||||
resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==}
|
||||
dependencies:
|
||||
@@ -4418,6 +4446,12 @@ packages:
|
||||
resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}
|
||||
dev: false
|
||||
|
||||
/@types/jsonfile@6.1.2:
|
||||
resolution: {integrity: sha512-8t92P+oeW4d/CRQfJaSqEwXujrhH4OEeHRjGU3v1Q8mUS8GPF3yiX26sw4svv6faL2HfBtGTe2xWIoVgN3dy9w==}
|
||||
dependencies:
|
||||
'@types/node': 20.6.2
|
||||
dev: true
|
||||
|
||||
/@types/jsonwebtoken@8.5.9:
|
||||
resolution: {integrity: sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg==}
|
||||
dependencies:
|
||||
@@ -4585,6 +4619,13 @@ packages:
|
||||
'@types/node': 20.6.2
|
||||
dev: true
|
||||
|
||||
/@types/prompts@2.4.5:
|
||||
resolution: {integrity: sha512-TvrzGMCwARi2qqXcD7VmvMvfMP3F7JRQpeEHECK0oufRNZInoBqzd8v/1zksKFE5XW8OOGto/5FsDT8lnpvGRA==}
|
||||
dependencies:
|
||||
'@types/node': 20.6.2
|
||||
kleur: 3.0.3
|
||||
dev: true
|
||||
|
||||
/@types/prop-types@15.7.5:
|
||||
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
|
||||
|
||||
@@ -8493,7 +8534,6 @@ packages:
|
||||
graceful-fs: 4.2.11
|
||||
jsonfile: 6.1.0
|
||||
universalify: 2.0.0
|
||||
dev: false
|
||||
|
||||
/fs-extra@8.1.0:
|
||||
resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==}
|
||||
@@ -10391,7 +10431,6 @@ packages:
|
||||
universalify: 2.0.0
|
||||
optionalDependencies:
|
||||
graceful-fs: 4.2.11
|
||||
dev: false
|
||||
|
||||
/jsonparse@1.3.1:
|
||||
resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==}
|
||||
@@ -14935,7 +14974,6 @@ packages:
|
||||
/universalify@2.0.0:
|
||||
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
|
||||
engines: {node: '>= 10.0.0'}
|
||||
dev: false
|
||||
|
||||
/unpipe@1.0.0:
|
||||
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
|
||||
|
||||
86
scripts/publish-multiple.ts
Executable file
86
scripts/publish-multiple.ts
Executable file
@@ -0,0 +1,86 @@
|
||||
import fse from 'fs-extra'
|
||||
import { ExecSyncOptions, execSync } from 'child_process'
|
||||
import chalk from 'chalk'
|
||||
import prompts from 'prompts'
|
||||
import minimist from 'minimist'
|
||||
|
||||
const execOpts: ExecSyncOptions = { stdio: 'inherit' }
|
||||
|
||||
async function main() {
|
||||
const args = minimist(process.argv.slice(2))
|
||||
const { _: packageNames } = args
|
||||
|
||||
// If packageNames contains a comma, parse
|
||||
if (packageNames[0]?.includes(',')) {
|
||||
packageNames.length = 0
|
||||
const splitNames = process.argv[2].split(',')
|
||||
packageNames.push(...splitNames)
|
||||
}
|
||||
|
||||
if (packageNames.length === 0) {
|
||||
console.error('Please specify a package to publish')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`\n${chalk.bold.green('Publishing packages:')}\n`)
|
||||
console.log(`${packageNames.map((p) => ` ${p}`).join('\n')}`)
|
||||
console.log('\n')
|
||||
|
||||
const { confirm } = await prompts(
|
||||
{
|
||||
name: 'confirm',
|
||||
initial: false,
|
||||
message: `Publish ${packageNames.length} package(s)?`,
|
||||
type: 'confirm',
|
||||
},
|
||||
{
|
||||
onCancel: () => {
|
||||
console.log(chalk.bold.red('\nAborted'))
|
||||
process.exit(0)
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if (!confirm) {
|
||||
console.log(chalk.bold.red('\nAborted\n'))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const results: { name: string; success: boolean }[] = []
|
||||
|
||||
for (const packageName of packageNames) {
|
||||
const packageDir = `packages/${packageName}`
|
||||
try {
|
||||
console.log(chalk.bold(`Publishing ${packageName}...`))
|
||||
execSync(`npm --prefix ${packageDir} version pre --preid beta`, execOpts)
|
||||
execSync(`git add ${packageDir}/package.json`, execOpts)
|
||||
|
||||
const packageObj = await fse.readJson(`${packageDir}/package.json`)
|
||||
const newVersion = packageObj.version
|
||||
|
||||
execSync(`git commit -m "chore(release): ${packageName}@${newVersion}"`, execOpts)
|
||||
execSync(`pnpm publish -C ${packageDir} --tag beta --no-git-checks`, execOpts)
|
||||
results.push({ name: packageName, success: true })
|
||||
} catch (error) {
|
||||
console.error(`ERROR: ${error.message}`)
|
||||
results.push({ name: packageName, success: false })
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n')
|
||||
console.log(`${chalk.bold('Results:')}\n`)
|
||||
console.log(
|
||||
results
|
||||
.map(
|
||||
({ name, success }) =>
|
||||
` ${success ? chalk.bold.green('✔') : chalk.bold.red('✘')} ${name}`,
|
||||
)
|
||||
.join('\n'),
|
||||
)
|
||||
console.log('\n')
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user