Skip to content

Commit d94b566

Browse files
committed
refactor: replace yargs-parser with @socketsecurity/registry parseArgs
1 parent 8809f41 commit d94b566

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

scripts/coverage-percent.mjs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { existsSync } from 'node:fs'
22
import path from 'node:path'
33

4-
import yargsParser from 'yargs-parser'
54
import colors from 'yoctocolors-cjs'
65

76
import constants from '@socketsecurity/registry/lib/constants'
87
import { logger } from '@socketsecurity/registry/lib/logger'
8+
import { parseArgs } from '@socketsecurity/registry/lib/parse-args'
99
import { indentString } from '@socketsecurity/registry/lib/strings'
1010

1111
import { getCodeCoverage } from './utils/get-code-coverage.mjs'
@@ -155,14 +155,19 @@ async function logCoveragePercentage(argv) {
155155

156156
// Main entry point - parse command line arguments and display coverage
157157
void (async () => {
158-
const argv = yargsParser(process.argv.slice(2), {
159-
boolean: ['json', 'simple'],
160-
alias: {
161-
// -j for JSON output
162-
j: 'json',
163-
// -s for simple output
164-
s: 'simple',
158+
const { values } = parseArgs({
159+
options: {
160+
json: {
161+
type: 'boolean',
162+
short: 'j',
163+
default: false,
164+
},
165+
simple: {
166+
type: 'boolean',
167+
short: 's',
168+
default: false,
169+
},
165170
},
166171
})
167-
await logCoveragePercentage(argv)
172+
await logCoveragePercentage(values)
168173
})()

scripts/update.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,28 @@ async function main() {
275275
console.log(' --socket Update Socket packages only')
276276
console.log(' --project Run project-specific updates only')
277277
console.log('\nExamples:')
278-
console.log(' pnpm update # Run all updates')
278+
console.log(' pnpm update # Update deps and Socket packages')
279279
console.log(' pnpm update --check # Check for dependency updates')
280280
console.log(' pnpm update --write # Update dependencies in package.json')
281281
console.log(' pnpm update --deps # Update dependencies only')
282282
console.log(' pnpm update --socket # Update Socket packages only')
283+
console.log(' pnpm update --project # Run project-specific updates')
283284
process.exitCode = 0
284285
return
285286
}
286287

287288
printHeader('Update Runner')
288289

289290
let exitCode = 0
290-
const runAll = !values.deps && !values.socket && !values.project
291+
// When no flags are specified, run deps and socket updates but NOT project updates
292+
const noFlagsSpecified = !values.deps && !values.socket && !values.project
293+
const runDeps = noFlagsSpecified || values.deps
294+
const runSocket = noFlagsSpecified || values.socket
295+
// Only run project updates when explicitly requested
296+
const runProject = values.project
291297

292298
// Update dependencies
293-
if (runAll || values.deps) {
299+
if (runDeps) {
294300
log.step('Updating dependencies')
295301
exitCode = await updateDependencies({
296302
check: values.check,
@@ -305,7 +311,7 @@ async function main() {
305311
}
306312

307313
// Update Socket packages
308-
if ((runAll || values.socket) && !values.check) {
314+
if (runSocket && !values.check) {
309315
log.step('Updating Socket packages')
310316
exitCode = await updateSocketPackages()
311317
if (exitCode !== 0) {
@@ -316,7 +322,7 @@ async function main() {
316322
}
317323

318324
// Run project-specific updates
319-
if ((runAll || values.project) && !values.check) {
325+
if (runProject && !values.check) {
320326
exitCode = await runProjectUpdates()
321327
if (exitCode !== 0) {
322328
log.error('Project updates failed')

0 commit comments

Comments
 (0)