@@ -4,6 +4,7 @@ import process from 'node:process'
4
4
5
5
import registryConstants from '@socketsecurity/registry/lib/constants'
6
6
import { envAsBoolean } from '@socketsecurity/registry/lib/env'
7
+ import { isObject } from '@socketsecurity/registry/lib/objects'
7
8
8
9
type RegistryEnv = typeof registryConstants . ENV
9
10
@@ -14,10 +15,12 @@ type Constants = {
14
15
readonly BUN : 'bun'
15
16
readonly ENV : RegistryEnv & {
16
17
SOCKET_CLI_DEBUG : boolean
17
- SOCKET_CLI_FIX_PACKAGE_LOCK_FILE : boolean
18
- SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE : boolean
19
18
}
20
19
readonly DIST_TYPE : 'module-sync' | 'require'
20
+ readonly IPC : ( ) => Promise < {
21
+ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE : boolean
22
+ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE : boolean
23
+ } >
21
24
readonly LOCK_EXT : '.lock'
22
25
readonly MODULE_SYNC : 'module-sync'
23
26
readonly NPM_REGISTRY_URL : 'https://registry.npmjs.org'
@@ -42,6 +45,29 @@ type Constants = {
42
45
readonly synpBinPath : string
43
46
} & typeof registryConstants
44
47
48
+ const { abortSignal } = registryConstants
49
+
50
+ const IPC = ( ( ) => {
51
+ const promise = new Promise ( ( resolve , reject ) => {
52
+ process . once ( 'message' , ipcData => {
53
+ console . log ( 'hi' )
54
+ const {
55
+ [ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE ] : a ,
56
+ [ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE ] : b
57
+ } = < any > { __proto__ : null , ...( isObject ( ipcData ) ? ipcData : { } ) }
58
+ console . log ( 'ok' )
59
+ resolve ( {
60
+ [ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE ] : ! ! a ,
61
+ [ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE ] : ! ! b
62
+ } )
63
+ } )
64
+ abortSignal . addEventListener ( 'abort' , reject , { once : true } )
65
+ } )
66
+ return function IPC ( ) {
67
+ return promise
68
+ }
69
+ } ) ( )
70
+
45
71
const {
46
72
PACKAGE_JSON ,
47
73
kInternalsSymbol,
@@ -77,17 +103,7 @@ const LAZY_ENV = () =>
77
103
// Lazily access registryConstants.ENV.
78
104
...registryConstants . ENV ,
79
105
// Flag set to help debug Socket CLI.
80
- [ SOCKET_CLI_DEBUG ] : envAsBoolean ( process . env [ SOCKET_CLI_DEBUG ] ) ,
81
- // Flag set by the "fix" command to accept the package alerts prompt with
82
- // "Y(es)" in the SafeArborist reify method.
83
- [ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE ] : envAsBoolean (
84
- process . env [ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE ]
85
- ) ,
86
- // Flag set by the "optimize" command to bypass the package alerts check
87
- // in the SafeArborist reify method.
88
- [ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE ] : envAsBoolean (
89
- process . env [ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE ]
90
- )
106
+ [ SOCKET_CLI_DEBUG ] : envAsBoolean ( process . env [ SOCKET_CLI_DEBUG ] )
91
107
} )
92
108
93
109
const lazyCdxgenBinPath = ( ) =>
@@ -136,6 +152,7 @@ const constants = <Constants>createConstantsObject(
136
152
ENV : undefined ,
137
153
// Lazily defined values are initialized as `undefined` to keep their key order.
138
154
DIST_TYPE : undefined ,
155
+ IPC ,
139
156
LOCK_EXT ,
140
157
MODULE_SYNC ,
141
158
NPM_REGISTRY_URL ,
0 commit comments