Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/constants/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,25 @@ export const SOCKET_REGISTRY_REPO_NAME = 'socket-registry'
export const SOCKET_REGISTRY_PACKAGE_NAME = '@socketsecurity/registry'
export const SOCKET_REGISTRY_NPM_ORG = 'socketregistry'

// Socket.dev application names.
export const SOCKET_CLI_APP_NAME = 'socket'
export const SOCKET_DLX_APP_NAME = 'dlx'
export const SOCKET_FIREWALL_APP_NAME = 'sfw'
export const SOCKET_REGISTRY_APP_NAME = 'registry'
export const SOCKET_WHEELHOUSE_APP_NAME = 'wheelhouse'
export const SOCKET_APP_PREFIX = '_'
// The `_` prefix that marks a Socket-managed subdir of ~/.socket/. Applies to
// BOTH app dirs (_socket, _registry) and infra/storage dirs (_cacache, _dlx,
// _state) — so it is a DIR prefix, not an "app" prefix.
export const SOCKET_DIR_PREFIX = '_'

// Full names of the Socket-managed infra/storage DIRS under ~/.socket/ (the `_`
// prefix included — these are dirs, not apps, and the bare form is never used
// on its own). `_cacache` content-addressable cache; `_dlx` name+version binary
// store (node, jre, python, sfw, …); `_state` version-LESS persistent app state
// (= pnpm `state-dir` / XDG_STATE_HOME); `_wheelhouse` cross-fleet shared bin.
export const SOCKET_DIR = {
__proto__: null,
cacache: `${SOCKET_DIR_PREFIX}cacache`,
dlx: `${SOCKET_DIR_PREFIX}dlx`,
state: `${SOCKET_DIR_PREFIX}state`,
wheelhouse: `${SOCKET_DIR_PREFIX}wheelhouse`,
} as unknown as Readonly<
Record<'cacache' | 'dlx' | 'state' | 'wheelhouse', string>
>

// Socket.dev lib.
export const SOCKET_LIB_NAME = '@socketsecurity/lib'
Expand Down
10 changes: 10 additions & 0 deletions src/env/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,16 @@ export function getSocketRepositoryName(): string | undefined {
)
}

/**
* SOCKET_STATE_DIR environment variable getter. Overrides the default Socket
* state directory (~/.socket/_state) location.
*
* @returns The state directory path, or `undefined` if not set
*/
export function getSocketStateDirEnv(): string | undefined {
return getEnvValue('SOCKET_STATE_DIR')
}

/**
* SOCKET_VIEW_ALL_RISKS environment variable getter. Whether to view all Socket
* Security risks.
Expand Down
3 changes: 3 additions & 0 deletions src/paths/dirnames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const DOT_GITHUB = '.github'
export const DOT_SOCKET_DIR = '.socket'
export const CACHE_DIR = 'cache'
export const CACHE_TTL_DIR = 'ttl'
// Runtime subdir of an app's state dir (~/.socket/_state/<app>/run/) — home for
// a daemon's Unix socket + concurrency.lock + <socket>.pid.
export const RUN_DIR = 'run'

// Path patterns.
export const NODE_MODULES_GLOB_RECURSIVE = '**/node_modules'
Expand Down
Loading
Loading