11import Module from 'node:module'
2- import path from 'node:path'
32import { fileURLToPath } from 'node:url'
43
54import allThePackageNamesData from 'all-the-package-names/names.json' with {
@@ -12,23 +11,25 @@ import pacote from 'pacote'
1211import semver from 'semver'
1312import validateNpmPackageName from 'validate-npm-package-name'
1413
14+ import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
1515import constants from '@socketsecurity/registry/lib/constants'
1616import { writeJson } from '@socketsecurity/registry/lib/fs'
1717import { logger } from '@socketsecurity/registry/lib/logger'
18+ import { dirname , resolve } from '@socketsecurity/registry/lib/path'
1819import { pFilter } from '@socketsecurity/registry/lib/promises'
1920import { confirm } from '@socketsecurity/registry/lib/prompts'
2021import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
2122
2223const { abortSignal } = constants
2324
2425const __filename = fileURLToPath ( import . meta. url )
25- const __dirname = path . dirname ( __filename )
26+ const __dirname = dirname ( __filename )
2627
27- const rootPath = path . resolve ( __dirname , '..' )
28- const dataPath = path . join ( rootPath , 'data' )
29- const npmDataPath = path . join ( dataPath , 'npm' )
30- const npmBuiltinNamesJsonPath = path . join ( npmDataPath , 'builtin-names.json' )
31- const npmLegacyNamesJsonPath = path . join ( npmDataPath , 'legacy-names.json' )
28+ const rootPath = resolve ( __dirname , '..' )
29+ const dataPath = resolve ( rootPath , 'data' )
30+ const npmDataPath = resolve ( dataPath , 'npm' )
31+ const npmBuiltinNamesJsonPath = resolve ( npmDataPath , 'builtin-names.json' )
32+ const npmLegacyNamesJsonPath = resolve ( npmDataPath , 'legacy-names.json' )
3233
3334void ( async ( ) => {
3435 // Lazily access constants.spinner.
@@ -67,18 +68,16 @@ void (async () => {
6768 spinner . stop ( )
6869 return
6970 }
70- const allThePackageNames = [
71- ...new Set ( [
72- // Load the 43.1MB names.json file of '[email protected] ' 73- // which keeps the json file smaller while still covering the changes from:
74- // https://blog.npmjs.org/post/168978377570/new-package-moniker-rules.html
75- ...allThePackageNamesData ,
76- // Load the 24.7MB names.json from '[email protected] ', 77- // the last v1 release, because it has different names resolved by
78- // npm's replicate.npmjs.com service.
79- ...allThePackageNamesV1Data ,
80- ] ) ,
81- ]
71+ const allThePackageNames = arrayUnique ( [
72+ // Load the 43.1MB names.json file of '[email protected] ' 73+ // which keeps the json file smaller while still covering the changes from:
74+ // https://blog.npmjs.org/post/168978377570/new-package-moniker-rules.html
75+ ...allThePackageNamesData ,
76+ // Load the 24.7MB names.json from '[email protected] ', 77+ // the last v1 release, because it has different names resolved by
78+ // npm's replicate.npmjs.com service.
79+ ...allThePackageNamesV1Data ,
80+ ] )
8281 const rawLegacyNames = allThePackageNames
8382 // Don't simply check validateNpmPackageName(n).validForOldPackages.
8483 // Instead let registry.npmjs.org be our source of truth to whether a
0 commit comments