Skip to content

Commit e6ff653

Browse files
committed
Fix constants.ts d.ts generation
1 parent 1d97ed0 commit e6ff653

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/constants.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ import path from 'node:path'
44
import { envAsBoolean } from '@socketsecurity/registry/lib/env'
55
import registryConstants from '@socketsecurity/registry/lib/constants'
66

7+
type RegistryEnv = typeof registryConstants.ENV
8+
9+
type Constants = {
10+
readonly API_V0_URL: 'https://api.socket.dev/v0'
11+
readonly ENV: RegistryEnv & {
12+
UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean
13+
}
14+
readonly DIST_TYPE: 'module-sync' | 'require'
15+
readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org'
16+
readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-cli/issues'
17+
readonly UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'
18+
readonly cdxgenBinPath: string
19+
readonly distPath: string
20+
readonly nmBinPath: string
21+
readonly rootBinPath: string
22+
readonly rootDistPath: string
23+
readonly rootPath: string
24+
readonly rootPkgJsonPath: string
25+
readonly shadowBinPath: string
26+
readonly synpBinPath: string
27+
} & typeof registryConstants
28+
729
const {
830
kInternalsSymbol,
931
PACKAGE_JSON,
@@ -21,7 +43,7 @@ const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues'
2143
const UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE =
2244
'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'
2345

24-
const ENV = Object.freeze({
46+
const ENV: Constants['ENV'] = Object.freeze({
2547
...registryConstants.ENV,
2648
// Flag set by the optimize command to bypass the packagesHaveRiskyIssues check.
2749
[UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: envAsBoolean(
@@ -43,25 +65,7 @@ const LAZY_DIST_TYPE = () =>
4365

4466
const lazyDistPath = () => path.join(rootDistPath, constants.DIST_TYPE)
4567

46-
const constants = <
47-
{
48-
readonly API_V0_URL: 'https://api.socket.dev/v0'
49-
readonly ENV: typeof ENV
50-
readonly DIST_TYPE: 'module-sync' | 'require'
51-
readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org'
52-
readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-cli/issues'
53-
readonly UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'
54-
readonly cdxgenBinPath: string
55-
readonly distPath: string
56-
readonly nmBinPath: string
57-
readonly rootBinPath: string
58-
readonly rootDistPath: string
59-
readonly rootPath: string
60-
readonly rootPkgJsonPath: string
61-
readonly shadowBinPath: string
62-
readonly synpBinPath: string
63-
} & typeof registryConstants
64-
>createConstantsObject(
68+
const constants = <Constants>createConstantsObject(
6569
{
6670
API_V0_URL,
6771
ENV,

0 commit comments

Comments
 (0)