Skip to content

Commit 4d3c5cf

Browse files
committed
refactor(scripts): use @socketsecurity/lib helpers directly
- Remove re-exports from cli-helpers.mjs and helpers.mjs - Import stdio/header, stdio/divider, argv/flags, logger directly from lib - Replace custom print functions with logger methods throughout scripts - Add @socketsecurity/lib to registry devDependencies - Simplifies maintenance by reducing wrapper code Updated files: - scripts/utils/cli-helpers.mjs: Remove all re-exports, keep only getRootPath - scripts/utils/helpers.mjs: Remove re-exports and custom logger - scripts/check.mjs: Use lib imports directly - scripts/cover.mjs: Use lib imports directly - scripts/update.mjs: Replace log.* calls with logger.* calls - registry/scripts/build-js.mjs: Use logger from lib - registry/scripts/build.mjs: Use lib imports directly
1 parent 3c46252 commit 4d3c5cf

File tree

10 files changed

+87
-185
lines changed

10 files changed

+87
-185
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,42 @@ packages:
44
- registry
55
- scripts
66

7-
patchedDependencies:
8-
brace-expansion@2.0.2: patches/brace-expansion@2.0.2.patch
9-
iconv-lite@0.6.3: patches/iconv-lite@0.6.3.patch
10-
minimatch@9.0.5: patches/minimatch@9.0.5.patch
11-
127
catalog:
138
'@babel/core': 7.28.4
149
'@babel/generator': 7.28.3
1510
'@babel/parser': 7.28.4
1611
'@babel/traverse': 7.28.4
1712
'@babel/types': 7.28.4
18-
'esbuild': 0.25.11
19-
'typescript': 5.9.2
2013
'@biomejs/biome': 2.2.4
2114
'@biomejs/wasm-nodejs': 2.2.4
22-
'eslint': 9.35.0
23-
'typescript-eslint': 8.44.1
24-
'eslint-plugin-import-x': 4.16.1
25-
'eslint-plugin-n': 17.23.1
26-
'eslint-plugin-sort-destructure-keys': 2.0.0
27-
'eslint-plugin-unicorn': 56.0.1
28-
'vitest': 4.0.3
29-
'@vitest/coverage-v8': 4.0.3
30-
'@vitest/ui': 4.0.3
31-
'@socketsecurity/lib': 3.1.3
3215
'@socketregistry/packageurl-js': 1.3.5
16+
'@socketsecurity/lib': 3.1.3
3317
'@types/node': 24.9.2
34-
'yoctocolors-cjs': 2.1.3
35-
'semver': 7.7.2
36-
'pacote': 21.0.1
37-
'npm-package-arg': 13.0.0
38-
'normalize-package-data': 8.0.0
39-
'validate-npm-package-name': 6.0.2
40-
'fast-glob': 3.3.3
41-
'magic-string': 0.30.17
42-
'zod': 4.1.12
43-
'del': 8.0.1
44-
'del-cli': 6.0.0
45-
'husky': 9.1.7
18+
'@vitest/coverage-v8': 4.0.3
19+
'@vitest/ui': 4.0.3
20+
del: 8.0.1
21+
del-cli: 6.0.0
22+
esbuild: 0.25.11
23+
eslint: 9.35.0
24+
eslint-plugin-import-x: 4.16.1
25+
eslint-plugin-n: 17.23.1
26+
eslint-plugin-sort-destructure-keys: 2.0.0
27+
eslint-plugin-unicorn: 56.0.1
28+
fast-glob: 3.3.3
29+
husky: 9.1.7
30+
magic-string: 0.30.17
31+
normalize-package-data: 8.0.0
32+
npm-package-arg: 13.0.0
33+
pacote: 21.0.1
34+
semver: 7.7.2
35+
typescript: 5.9.2
36+
typescript-eslint: 8.44.1
37+
validate-npm-package-name: 6.0.2
38+
vitest: 4.0.3
39+
yoctocolors-cjs: 2.1.3
40+
zod: 4.1.12
41+
42+
patchedDependencies:
43+
brace-expansion@2.0.2: patches/brace-expansion@2.0.2.patch
44+
iconv-lite@0.6.3: patches/iconv-lite@0.6.3.patch
45+
minimatch@9.0.5: patches/minimatch@9.0.5.patch

registry/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"type-ci": "pnpm run check"
5858
},
5959
"devDependencies": {
60+
"@socketsecurity/lib": "catalog:",
6061
"@types/node": "24.6.2",
6162
"del-cli": "6.0.0",
6263
"esbuild": "0.25.10",

registry/scripts/build-js.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ import { fileURLToPath } from 'node:url'
99
import { build, context } from 'esbuild'
1010
import fg from 'fast-glob'
1111

12-
import { printError, printSuccess } from '../../scripts/utils/cli-helpers.mjs'
12+
import { getDefaultLogger } from '@socketsecurity/lib/logger'
13+
1314
import {
1415
analyzeMetafile,
1516
buildConfig,
1617
watchConfig,
1718
} from '../.config/esbuild.config.mjs'
1819

20+
const logger = getDefaultLogger()
21+
1922
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2023
const rootPath = path.join(__dirname, '..')
2124
const srcPath = path.join(rootPath, 'src')
@@ -112,7 +115,7 @@ async function buildJS() {
112115
return 0
113116
} catch (error) {
114117
if (!isQuiet) {
115-
printError('JavaScript build failed')
118+
logger.error('JavaScript build failed')
116119
console.error(error)
117120
}
118121
return 1
@@ -140,11 +143,11 @@ async function watchJS() {
140143
build.onEnd(result => {
141144
if (result.errors.length > 0) {
142145
if (!isQuiet) {
143-
printError('Rebuild failed')
146+
logger.error('Rebuild failed')
144147
}
145148
} else {
146149
if (!isQuiet) {
147-
printSuccess('Rebuild succeeded')
150+
logger.success('Rebuild succeeded')
148151

149152
if (result?.metafile && isVerbose) {
150153
const analysis = analyzeMetafile(result.metafile)
@@ -173,7 +176,7 @@ async function watchJS() {
173176
await new Promise(() => {})
174177
} catch (error) {
175178
if (!isQuiet) {
176-
printError('Watch mode failed')
179+
logger.error('Watch mode failed')
177180
console.error(error)
178181
}
179182
return 1

registry/scripts/build.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ import { fileURLToPath } from 'node:url'
99
import { build, context } from 'esbuild'
1010
import colors from 'yoctocolors-cjs'
1111
import fg from 'fast-glob'
12+
13+
import { isQuiet } from '@socketsecurity/lib/argv/flags'
14+
import { LOG_SYMBOLS, getDefaultLogger } from '@socketsecurity/lib/logger'
15+
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
16+
1217
import {
1318
analyzeMetafile,
1419
buildConfig,
1520
watchConfig,
1621
} from '../.config/esbuild.config.mjs'
17-
import { isQuiet } from '../../scripts/utils/flags.mjs'
18-
import {
19-
logger,
20-
printCompletedHeader,
21-
printFooter,
22-
printHeader,
23-
} from '../../scripts/utils/helpers.mjs'
2422
import { parseArgs } from '../../scripts/utils/parse-args.mjs'
2523
import { runSequence } from '../../scripts/utils/run-command.mjs'
2624

25+
const logger = getDefaultLogger()
26+
2727
const rootPath = path.resolve(
2828
path.dirname(fileURLToPath(import.meta.url)),
2929
'..',
@@ -432,7 +432,7 @@ async function main() {
432432
}
433433

434434
if (!quiet) {
435-
printCompletedHeader('Build Cleaned')
435+
logger.log(`${LOG_SYMBOLS.success} Build Cleaned`)
436436
}
437437

438438
// Run source and types builds in parallel.

scripts/check.mjs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@ import path from 'node:path'
1313
import { fileURLToPath } from 'node:url'
1414

1515
import { getDefaultLogger } from '@socketsecurity/lib/logger'
16+
import { printFooter, printHeader } from '@socketsecurity/lib/stdio/header'
1617

17-
const logger = getDefaultLogger()
18-
19-
import {
20-
printError,
21-
printFooter,
22-
printHeader,
23-
printSuccess,
24-
} from './utils/cli-helpers.mjs'
2518
import { runCommand, runParallel } from './utils/run-command.mjs'
2619

20+
const logger = getDefaultLogger()
21+
2722
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2823
const rootPath = path.resolve(__dirname, '..')
2924
const registryDistPath = path.join(rootPath, 'registry', 'dist', 'index.js')
@@ -37,7 +32,7 @@ async function main() {
3732
if (!existsSync(registryDistPath)) {
3833
const buildExitCode = await runCommand('pnpm', ['run', 'build'])
3934
if (buildExitCode !== 0) {
40-
printError('Build failed')
35+
logger.error('Build failed')
4136
process.exitCode = buildExitCode
4237
return
4338
}
@@ -120,14 +115,14 @@ async function main() {
120115
const failed = exitCodes.some(code => code !== 0)
121116

122117
if (failed) {
123-
printError('Some checks failed')
118+
logger.error('Some checks failed')
124119
process.exitCode = 1
125120
} else {
126-
printSuccess('All checks passed')
121+
logger.success('All checks passed')
127122
printFooter()
128123
}
129124
} catch (error) {
130-
printError(`Check failed: ${error.message}`)
125+
logger.error(`Check failed: ${error.message}`)
131126
process.exitCode = 1
132127
}
133128
}

scripts/cover.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { fileURLToPath } from 'node:url'
1313

1414
import { parseArgs } from '@socketsecurity/lib/argv/parse'
1515
import { getDefaultLogger } from '@socketsecurity/lib/logger'
16+
import { printHeader } from '@socketsecurity/lib/stdio/header'
1617

17-
const logger = getDefaultLogger()
18-
19-
import { printError, printHeader, printSuccess } from './utils/cli-helpers.mjs'
2018
import { runCommandQuiet } from './utils/run-command.mjs'
2119

20+
const logger = getDefaultLogger()
21+
2222
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2323
const rootPath = path.join(__dirname, '..')
2424

@@ -279,13 +279,13 @@ try {
279279
}
280280

281281
if (exitCode === 0) {
282-
printSuccess('Coverage completed successfully')
282+
logger.success('Coverage completed successfully')
283283
} else {
284-
printError('Coverage failed')
284+
logger.error('Coverage failed')
285285
}
286286

287287
process.exitCode = exitCode
288288
} catch (error) {
289-
printError(`Coverage script failed: ${error.message}`)
289+
logger.error(`Coverage script failed: ${error.message}`)
290290
process.exitCode = 1
291291
}

0 commit comments

Comments
 (0)