itty-packager 1.6.13 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/commands/release.js +65 -3
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
package/lib/commands/release.js
CHANGED
|
@@ -209,6 +209,54 @@ async function getCommitMessage(newVersion, silent = false) {
|
|
|
209
209
|
})
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
+
async function promptOtp() {
|
|
213
|
+
return new Promise((resolve, reject) => {
|
|
214
|
+
process.stdout.write('🔑 Enter OTP code: ')
|
|
215
|
+
let code = ''
|
|
216
|
+
|
|
217
|
+
process.stdin.setRawMode(true)
|
|
218
|
+
process.stdin.resume()
|
|
219
|
+
|
|
220
|
+
const handleInput = (chunk) => {
|
|
221
|
+
const key = chunk.toString()
|
|
222
|
+
|
|
223
|
+
if (key === '\x03') {
|
|
224
|
+
cleanup()
|
|
225
|
+
reject(new Error('User cancelled with Ctrl+C'))
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (key === '\r' || key === '\n') {
|
|
230
|
+
process.stdout.write('\n')
|
|
231
|
+
cleanup()
|
|
232
|
+
resolve(code.trim())
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (key === '\x7f' || key === '\x08') {
|
|
237
|
+
if (code.length > 0) {
|
|
238
|
+
code = code.slice(0, -1)
|
|
239
|
+
process.stdout.write('\b \b')
|
|
240
|
+
}
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (key >= '0' && key <= '9') {
|
|
245
|
+
code += key
|
|
246
|
+
process.stdout.write(key)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const cleanup = () => {
|
|
251
|
+
process.stdin.setRawMode(false)
|
|
252
|
+
process.stdin.pause()
|
|
253
|
+
process.stdin.removeListener('data', handleInput)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
process.stdin.on('data', handleInput)
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
212
260
|
async function runCommand(command, cwd = process.cwd(), verbose = false) {
|
|
213
261
|
return new Promise((resolve, reject) => {
|
|
214
262
|
const [cmd, ...args] = command.split(' ')
|
|
@@ -318,6 +366,10 @@ export async function releaseCommand(args) {
|
|
|
318
366
|
type: 'boolean',
|
|
319
367
|
description: 'Skip interactive prompts (use default commit message)'
|
|
320
368
|
},
|
|
369
|
+
otp: {
|
|
370
|
+
type: 'boolean',
|
|
371
|
+
description: 'Prompt for a one-time password (OTP) for npm publish'
|
|
372
|
+
},
|
|
321
373
|
verbose: {
|
|
322
374
|
type: 'boolean',
|
|
323
375
|
short: 'v',
|
|
@@ -354,6 +406,7 @@ Publish Options:
|
|
|
354
406
|
--prepare Run prepare (lint, test, build) before publishing
|
|
355
407
|
--silent Skip interactive prompts (use default commit message)
|
|
356
408
|
--no-license Do not copy LICENSE file to published package
|
|
409
|
+
--otp Prompt for a one-time password (OTP) for npm publish
|
|
357
410
|
-v, --verbose Show detailed output including npm and git command details
|
|
358
411
|
|
|
359
412
|
Git Options:
|
|
@@ -408,6 +461,7 @@ This creates a clean, flat package structure in node_modules.
|
|
|
408
461
|
const noLicense = releaseArgs['no-license']
|
|
409
462
|
const shouldPrepare = releaseArgs.prepare
|
|
410
463
|
const silent = releaseArgs.silent
|
|
464
|
+
const useOtp = releaseArgs.otp
|
|
411
465
|
const verbose = releaseArgs.verbose
|
|
412
466
|
|
|
413
467
|
// Read package.json and store original version for potential revert
|
|
@@ -539,18 +593,26 @@ This creates a clean, flat package structure in node_modules.
|
|
|
539
593
|
if (dryRun) {
|
|
540
594
|
console.log('🍸 Dry run - skipping publish')
|
|
541
595
|
} else {
|
|
542
|
-
//
|
|
596
|
+
// Prompt for OTP if requested
|
|
597
|
+
let otpCode
|
|
598
|
+
if (useOtp) {
|
|
599
|
+
otpCode = await promptOtp()
|
|
600
|
+
if (!otpCode) throw new Error('No OTP code provided')
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// Publish from temp directory (always inherit stdio for interactive npm auth)
|
|
543
604
|
console.log(`🚀 Publishing to npm...`)
|
|
544
605
|
|
|
545
606
|
const publishCmd = [
|
|
546
607
|
'npm publish',
|
|
547
608
|
'--registry=https://registry.npmjs.org',
|
|
548
609
|
publicAccess ? '--access=public' : '',
|
|
549
|
-
SEMVER_TYPES.includes(releaseType) ? '' : `--tag=${releaseType}
|
|
610
|
+
SEMVER_TYPES.includes(releaseType) ? '' : `--tag=${releaseType}`,
|
|
611
|
+
otpCode ? `--otp=${otpCode}` : ''
|
|
550
612
|
].filter(Boolean).join(' ')
|
|
551
613
|
|
|
552
614
|
if (verbose) console.log(`Running: ${publishCmd}`)
|
|
553
|
-
await runCommand(publishCmd, tempDir,
|
|
615
|
+
await runCommand(publishCmd, tempDir, true)
|
|
554
616
|
}
|
|
555
617
|
|
|
556
618
|
// Cleanup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itty-packager",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Universal build tool for itty libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"lint": "bun bin/itty.js lint",
|
|
11
11
|
"dev": "bun test --coverage --watch",
|
|
12
|
-
"release": "bun bin/itty.js release --patch --tag --push --root"
|
|
12
|
+
"release": "bun bin/itty.js release --patch --tag --push --root --otp"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"build",
|