|
1 | | -'use strict' |
| 1 | +import Module from 'node:module' |
| 2 | +import path from 'node:path' |
| 3 | +import { fileURLToPath } from 'node:url' |
2 | 4 |
|
3 | | -const Module = require('node:module') |
4 | | -const path = require('node:path') |
| 5 | +import pacote from 'pacote' |
| 6 | +import semver from 'semver' |
| 7 | +import validateNpmPackageName from 'validate-npm-package-name' |
5 | 8 |
|
6 | | -const pacote = require('pacote') |
7 | | -const semver = require('semver') |
8 | | -const validateNpmPackageName = require('validate-npm-package-name') |
9 | | - |
10 | | -const constants = require('@socketsecurity/registry/lib/constants') |
11 | | -const { writeJson } = require('@socketsecurity/registry/lib/fs') |
12 | | -const { logger } = require('@socketsecurity/registry/lib/logger') |
13 | | -const { pFilter } = require('@socketsecurity/registry/lib/promises') |
14 | | -const { confirm } = require('@socketsecurity/registry/lib/prompts') |
15 | | -const { naturalCompare } = require('@socketsecurity/registry/lib/sorts') |
| 9 | +import constants from '@socketsecurity/registry/lib/constants' |
| 10 | +import { writeJson } from '@socketsecurity/registry/lib/fs' |
| 11 | +import { logger } from '@socketsecurity/registry/lib/logger' |
| 12 | +import { pFilter } from '@socketsecurity/registry/lib/promises' |
| 13 | +import { confirm } from '@socketsecurity/registry/lib/prompts' |
| 14 | +import { naturalCompare } from '@socketsecurity/registry/lib/sorts' |
16 | 15 |
|
17 | 16 | const { abortSignal } = constants |
18 | 17 |
|
| 18 | +const __filename = fileURLToPath(import.meta.url) |
| 19 | +const __dirname = path.dirname(__filename) |
| 20 | + |
19 | 21 | const rootPath = path.resolve(__dirname, '..') |
20 | 22 | const dataPath = path.join(rootPath, 'data') |
21 | 23 | const npmDataPath = path.join(dataPath, 'npm') |
@@ -59,16 +61,23 @@ void (async () => { |
59 | 61 | spinner.stop() |
60 | 62 | return |
61 | 63 | } |
| 64 | + const allThePackageNamesData = await import('all-the-package-names/names.json', { |
| 65 | + with: { type: 'json' } |
| 66 | + }) |
| 67 | + const allThePackageNamesV1Data = await import('all-the-package-names-v1.3905.0/names.json', { |
| 68 | + with: { type: 'json' } |
| 69 | + }) |
| 70 | + |
62 | 71 | const allThePackageNames = [ |
63 | 72 | ...new Set([ |
64 | 73 | // Load the 43.1MB names.json file of '[email protected]' |
65 | 74 | // which keeps the json file smaller while still covering the changes from: |
66 | 75 | // https://blog.npmjs.org/post/168978377570/new-package-moniker-rules.html |
67 | | - ...require('all-the-package-names/names.json'), |
| 76 | + ...allThePackageNamesData.default, |
68 | 77 | // Load the 24.7MB names.json from '[email protected]', |
69 | 78 | // the last v1 release, because it has different names resolved by |
70 | 79 | // npm's replicate.npmjs.com service. |
71 | | - ...require('all-the-package-names-v1.3905.0/names.json'), |
| 80 | + ...allThePackageNamesV1Data.default, |
72 | 81 | ]), |
73 | 82 | ] |
74 | 83 | const rawLegacyNames = allThePackageNames |
|
0 commit comments