@socketsecurity/lib 2.10.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +231 -40
- package/dist/constants/platform.js +1 -1
- package/dist/constants/platform.js.map +3 -3
- package/dist/cover/code.js +1 -1
- package/dist/cover/code.js.map +3 -3
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +3 -3
- package/dist/dlx-binary.d.ts +29 -6
- package/dist/dlx-binary.js +7 -7
- package/dist/dlx-binary.js.map +3 -3
- package/dist/dlx-package.d.ts +16 -1
- package/dist/dlx-package.js +7 -7
- package/dist/dlx-package.js.map +3 -3
- package/dist/dlx.js +4 -4
- package/dist/dlx.js.map +3 -3
- package/dist/env/rewire.js +1 -1
- package/dist/env/rewire.js.map +3 -3
- package/dist/env/socket-cli.d.ts +7 -0
- package/dist/env/socket-cli.js +1 -1
- package/dist/env/socket-cli.js.map +2 -2
- package/dist/external/yoctocolors-cjs.d.ts +14 -0
- package/dist/fs.d.ts +82 -27
- package/dist/fs.js +7 -7
- package/dist/fs.js.map +3 -3
- package/dist/git.js +1 -1
- package/dist/git.js.map +3 -3
- package/dist/http-request.js +1 -1
- package/dist/http-request.js.map +3 -3
- package/dist/ipc.js +1 -1
- package/dist/ipc.js.map +3 -3
- package/dist/links/index.d.ts +65 -0
- package/dist/links/index.js +3 -0
- package/dist/links/index.js.map +7 -0
- package/dist/logger.d.ts +21 -18
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +3 -3
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/isolation.js.map +3 -3
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +2 -2
- package/dist/process-lock.js +2 -2
- package/dist/process-lock.js.map +3 -3
- package/dist/promises.d.ts +6 -21
- package/dist/promises.js +1 -1
- package/dist/promises.js.map +2 -2
- package/dist/prompts/index.d.ts +115 -0
- package/dist/prompts/index.js +3 -0
- package/dist/prompts/index.js.map +7 -0
- package/dist/spinner.d.ts +33 -23
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +3 -3
- package/dist/stdio/mask.d.ts +2 -2
- package/dist/stdio/mask.js +4 -4
- package/dist/stdio/mask.js.map +3 -3
- package/dist/stdio/stdout.js +1 -1
- package/dist/stdio/stdout.js.map +3 -3
- package/dist/themes/context.d.ts +80 -0
- package/dist/themes/context.js +3 -0
- package/dist/themes/context.js.map +7 -0
- package/dist/themes/index.d.ts +53 -0
- package/dist/themes/index.js +3 -0
- package/dist/themes/index.js.map +7 -0
- package/dist/themes/themes.d.ts +49 -0
- package/dist/themes/themes.js +3 -0
- package/dist/themes/themes.js.map +7 -0
- package/dist/themes/types.d.ts +92 -0
- package/dist/themes/types.js +3 -0
- package/dist/themes/types.js.map +7 -0
- package/dist/themes/utils.d.ts +78 -0
- package/dist/themes/utils.js +3 -0
- package/dist/themes/utils.js.map +7 -0
- package/package.json +40 -8
- package/dist/download-lock.d.ts +0 -49
- package/dist/download-lock.js +0 -10
- package/dist/download-lock.js.map +0 -7
package/dist/dlx.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dlx.ts"],
|
|
4
|
-
"sourcesContent": ["/** @fileoverview DLX (execute package) utilities for Socket ecosystem shared installations. */\n\nimport { createHash } from '
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,sBAAAC,EAAA,iBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,8BAAAC,EAAA,qBAAAC,EAAA,0BAAAC,EAAA,gCAAAC,EAAA,0BAAAC,EAAA,+BAAAC,EAAA,kBAAAC,EAAA,oBAAAC,EAAA,yBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAApB,GAEA,IAAAqB,EAA2B,
|
|
6
|
-
"names": ["dlx_exports", "__export", "clearDlx", "clearDlxSync", "dlxDirExists", "dlxDirExistsAsync", "ensureDlxDir", "ensureDlxDirSync", "generateCacheKey", "getDlxInstalledPackageDir", "getDlxPackageDir", "getDlxPackageJsonPath", "getDlxPackageNodeModulesDir", "isDlxPackageInstalled", "isDlxPackageInstalledAsync", "isInSocketDlx", "listDlxPackages", "listDlxPackagesAsync", "removeDlxPackage", "removeDlxPackageSync", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["/** @fileoverview DLX (execute package) utilities for Socket ecosystem shared installations. */\n\nimport { createHash } from 'crypto'\n\nimport { readDirNamesSync, safeDelete, safeMkdir, safeMkdirSync } from './fs'\nimport { normalizePath } from './path'\nimport { getSocketDlxDir } from './paths'\nimport { pEach } from './promises'\n\nlet _fs: typeof import('fs') | undefined\n/**\n * Lazily load the fs module to avoid Webpack errors.\n * Uses non-'node:' prefixed require to prevent Webpack bundling issues.\n *\n * @returns The Node.js fs module\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getFs() {\n if (_fs === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _fs = /*@__PURE__*/ require('node:fs')\n }\n return _fs as typeof import('fs')\n}\n\n/**\n * Generate a cache directory name using npm/npx approach.\n * Uses first 16 characters of SHA-512 hash (like npm/npx).\n *\n * Rationale for SHA-512 truncated (vs full SHA-256):\n * - Matches npm/npx ecosystem behavior\n * - Shorter paths for Windows MAX_PATH compatibility (260 chars)\n * - 16 hex chars = 64 bits = acceptable collision risk for local cache\n * - Collision probability ~1 in 18 quintillion with 1000 entries\n *\n * Input strategy (aligned with npx):\n * - npx uses package spec strings (e.g., '@scope/pkg@1.0.0', 'prettier@3.0.0')\n * - Caller provides complete spec string with version for accurate cache keying\n * - For package installs: Use PURL-style spec with version\n * Examples: 'npm:prettier@3.0.0', 'pypi:requests@2.31.0', 'gem:rails@7.0.0'\n * Note: Socket uses shorthand format without 'pkg:' prefix\n * (handled by @socketregistry/packageurl-js)\n * - For binary downloads: Use URL:name for uniqueness\n *\n * Reference: npm/cli v11.6.2 libnpmexec/lib/index.js#L233-L244\n * https://github.com/npm/cli/blob/v11.6.2/workspaces/libnpmexec/lib/index.js#L233-L244\n * Implementation: packages.map().sort().join('\\n') \u2192 SHA-512 \u2192 slice(0,16)\n * npx hashes the package spec (name@version), not just name\n */\nexport function generateCacheKey(spec: string): string {\n return createHash('sha512').update(spec).digest('hex').substring(0, 16)\n}\n\nlet _path: typeof import('path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n * @private\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path!\n}\n\n/**\n * Clear all DLX package installations.\n */\nexport async function clearDlx(): Promise<void> {\n const packages = await listDlxPackagesAsync()\n await pEach(packages, pkg => removeDlxPackage(pkg))\n}\n\n/**\n * Clear all DLX package installations synchronously.\n */\nexport function clearDlxSync(): void {\n const packages = listDlxPackages()\n for (const pkg of packages) {\n removeDlxPackageSync(pkg)\n }\n}\n\n/**\n * Check if the DLX directory exists.\n */\nexport function dlxDirExists(): boolean {\n const fs = getFs()\n return fs.existsSync(getSocketDlxDir())\n}\n\n/**\n * Check if the DLX directory exists asynchronously.\n */\nexport async function dlxDirExistsAsync(): Promise<boolean> {\n const fs = getFs()\n try {\n await fs.promises.access(getSocketDlxDir())\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Ensure the DLX directory exists, creating it if necessary.\n */\nexport async function ensureDlxDir(): Promise<void> {\n await safeMkdir(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Ensure the DLX directory exists synchronously, creating it if necessary.\n */\nexport function ensureDlxDirSync(): void {\n safeMkdirSync(getSocketDlxDir(), { recursive: true })\n}\n\n/**\n * Get the installed package directory within DLX node_modules.\n */\nexport function getDlxInstalledPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxPackageNodeModulesDir(packageName), packageName),\n )\n}\n\n/**\n * Get the DLX installation directory for a specific package.\n */\nexport function getDlxPackageDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getSocketDlxDir(), packageName))\n}\n\n/**\n * Get the package.json path for a DLX installed package.\n */\nexport function getDlxPackageJsonPath(packageName: string): string {\n const path = getPath()\n return normalizePath(\n path.join(getDlxInstalledPackageDir(packageName), 'package.json'),\n )\n}\n\n/**\n * Get the node_modules directory for a DLX package installation.\n */\nexport function getDlxPackageNodeModulesDir(packageName: string): string {\n const path = getPath()\n return normalizePath(path.join(getDlxPackageDir(packageName), 'node_modules'))\n}\n\n/**\n * Check if a file path is within the Socket DLX directory.\n * This is useful for determining if a binary or file is managed by Socket's DLX system.\n *\n * @param filePath - Absolute or relative path to check\n * @returns true if the path is within ~/.socket/_dlx/, false otherwise\n *\n * @example\n * ```typescript\n * isInSocketDlx('/home/user/.socket/_dlx/abc123/bin/socket') // true\n * isInSocketDlx('/usr/local/bin/socket') // false\n * isInSocketDlx(process.argv[0]) // Check if current binary is in DLX\n * ```\n */\nexport function isInSocketDlx(filePath: string): boolean {\n if (!filePath) {\n return false\n }\n\n const path = getPath()\n const dlxDir = getSocketDlxDir()\n const absolutePath = path.resolve(filePath)\n\n // Check if the absolute path starts with the DLX directory.\n return absolutePath.startsWith(dlxDir + path.sep)\n}\n\n/**\n * Check if a package is installed in DLX.\n */\nexport function isDlxPackageInstalled(packageName: string): boolean {\n const fs = getFs()\n return fs.existsSync(getDlxInstalledPackageDir(packageName))\n}\n\n/**\n * Check if a package is installed in DLX asynchronously.\n */\nexport async function isDlxPackageInstalledAsync(\n packageName: string,\n): Promise<boolean> {\n const fs = getFs()\n try {\n await fs.promises.access(getDlxInstalledPackageDir(packageName))\n return true\n } catch {\n return false\n }\n}\n\n/**\n * List all packages installed in DLX.\n */\nexport function listDlxPackages(): string[] {\n try {\n return readDirNamesSync(getSocketDlxDir(), { sort: true })\n } catch {\n return []\n }\n}\n\n/**\n * List all packages installed in DLX asynchronously.\n */\nexport async function listDlxPackagesAsync(): Promise<string[]> {\n const fs = getFs()\n try {\n const entries = await fs.promises.readdir(getSocketDlxDir(), {\n withFileTypes: true,\n })\n return entries\n .filter(e => e.isDirectory())\n .map(e => e.name)\n .sort()\n } catch {\n return []\n }\n}\n\n/**\n * Remove a DLX package installation.\n */\nexport async function removeDlxPackage(packageName: string): Promise<void> {\n const packageDir = getDlxPackageDir(packageName)\n try {\n await safeDelete(packageDir, { recursive: true, force: true })\n } catch (e) {\n throw new Error(`Failed to remove DLX package \"${packageName}\"`, {\n cause: e,\n })\n }\n}\n\n/**\n * Remove a DLX package installation synchronously.\n */\nexport function removeDlxPackageSync(packageName: string): void {\n const fs = getFs()\n const packageDir = getDlxPackageDir(packageName)\n try {\n fs.rmSync(packageDir, { recursive: true, force: true })\n } catch (e) {\n const code = (e as NodeJS.ErrnoException).code\n if (code === 'EACCES' || code === 'EPERM') {\n throw new Error(\n `Permission denied removing DLX package \"${packageName}\"\\n` +\n `Directory: ${packageDir}\\n` +\n 'To resolve:\\n' +\n ' 1. Check file/directory permissions\\n' +\n ' 2. Close any programs using files in this directory\\n' +\n ' 3. Try running with elevated privileges if necessary\\n' +\n ` 4. Manually remove: rm -rf \"${packageDir}\"`,\n { cause: e },\n )\n }\n if (code === 'EROFS') {\n throw new Error(\n `Cannot remove DLX package \"${packageName}\" from read-only filesystem\\n` +\n `Directory: ${packageDir}\\n` +\n 'The filesystem is mounted read-only.',\n { cause: e },\n )\n }\n throw new Error(\n `Failed to remove DLX package \"${packageName}\"\\n` +\n `Directory: ${packageDir}\\n` +\n 'Check permissions and ensure no programs are using this directory.',\n { cause: e },\n )\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["dlx_exports", "__export", "clearDlx", "clearDlxSync", "dlxDirExists", "dlxDirExistsAsync", "ensureDlxDir", "ensureDlxDirSync", "generateCacheKey", "getDlxInstalledPackageDir", "getDlxPackageDir", "getDlxPackageJsonPath", "getDlxPackageNodeModulesDir", "isDlxPackageInstalled", "isDlxPackageInstalledAsync", "isInSocketDlx", "listDlxPackages", "listDlxPackagesAsync", "removeDlxPackage", "removeDlxPackageSync", "__toCommonJS", "import_crypto", "import_fs", "import_path", "import_paths", "import_promises", "_fs", "getFs", "spec", "_path", "getPath", "packages", "pkg", "fs", "packageName", "filePath", "path", "dlxDir", "e", "packageDir", "code"]
|
|
7
7
|
}
|
package/dist/env/rewire.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var t in e)o(n,t,{get:e[t],enumerable:!0})},f=(n,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!g.call(n,i)&&i!==t&&o(n,i,{get:()=>e[i],enumerable:!(c=u(e,i))||c.enumerable});return n};var p=n=>f(o({},"__esModule",{value:!0}),n);var m={};v(m,{clearEnv:()=>E,getEnvValue:()=>x,hasOverride:()=>w,resetEnv:()=>h,setEnv:()=>O,withEnv:()=>T,withEnvSync:()=>l});module.exports=p(m);var d=require("
|
|
2
|
+
var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var t in e)o(n,t,{get:e[t],enumerable:!0})},f=(n,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of a(e))!g.call(n,i)&&i!==t&&o(n,i,{get:()=>e[i],enumerable:!(c=u(e,i))||c.enumerable});return n};var p=n=>f(o({},"__esModule",{value:!0}),n);var m={};v(m,{clearEnv:()=>E,getEnvValue:()=>x,hasOverride:()=>w,resetEnv:()=>h,setEnv:()=>O,withEnv:()=>T,withEnvSync:()=>l});module.exports=p(m);var d=require("async_hooks");const s=new d.AsyncLocalStorage,r=new Map;function x(n){const e=s.getStore();return e?.has(n)?e.get(n):r.has(n)?r.get(n):process.env[n]}function O(n,e){r.set(n,e)}function E(n){r.delete(n)}function h(){r.clear()}function w(n){return s.getStore()?.has(n)||r.has(n)}async function T(n,e){const t=new Map(Object.entries(n));return await s.run(t,e)}function l(n,e){const t=new Map(Object.entries(n));return s.run(t,e)}0&&(module.exports={clearEnv,getEnvValue,hasOverride,resetEnv,setEnv,withEnv,withEnvSync});
|
|
3
3
|
//# sourceMappingURL=rewire.js.map
|
package/dist/env/rewire.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/env/rewire.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Environment variable rewiring utilities for testing.\n * Uses AsyncLocalStorage for context-isolated overrides that work with concurrent tests.\n *\n * Features:\n * - Context-isolated overrides via withEnv() for advanced use cases\n * - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach\n * - Compatible with vi.stubEnv() - reads from process.env as final fallback\n * - Thread-safe for concurrent test execution\n */\n\nimport { AsyncLocalStorage } from '
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,aAAAC,EAAA,WAAAC,EAAA,YAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAT,GAWA,IAAAU,EAAkC,
|
|
6
|
-
"names": ["rewire_exports", "__export", "clearEnv", "getEnvValue", "hasOverride", "resetEnv", "setEnv", "withEnv", "withEnvSync", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Environment variable rewiring utilities for testing.\n * Uses AsyncLocalStorage for context-isolated overrides that work with concurrent tests.\n *\n * Features:\n * - Context-isolated overrides via withEnv() for advanced use cases\n * - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach\n * - Compatible with vi.stubEnv() - reads from process.env as final fallback\n * - Thread-safe for concurrent test execution\n */\n\nimport { AsyncLocalStorage } from 'async_hooks'\n\ntype EnvOverrides = Map<string, string | undefined>\n\nconst envStorage = new AsyncLocalStorage<EnvOverrides>()\n\n// Per-test overrides (used by setEnv/clearEnv/resetEnv in test hooks)\n// Each test file gets its own instance due to Vitest's module isolation\nconst testOverrides = new Map<string, string | undefined>()\n\n/**\n * Get an environment variable value, checking overrides first.\n *\n * Resolution order:\n * 1. AsyncLocalStorage context (set via withEnv)\n * 2. Test overrides (set via setEnv in beforeEach)\n * 3. process.env (including vi.stubEnv modifications)\n *\n * @internal Used by env getters to support test rewiring\n */\nexport function getEnvValue(key: string): string | undefined {\n // Check AsyncLocalStorage context first (highest priority)\n const contextOverrides = envStorage.getStore()\n if (contextOverrides?.has(key)) {\n return contextOverrides.get(key)\n }\n\n // Check test overrides (set via setEnv in beforeEach)\n if (testOverrides.has(key)) {\n return testOverrides.get(key)\n }\n\n // Fall back to process.env (works with vi.stubEnv)\n return process.env[key]\n}\n\n/**\n * Set an environment variable override for testing.\n * This does not modify process.env, only affects env getters.\n *\n * Works in test hooks (beforeEach) without needing AsyncLocalStorage context.\n * Vitest's module isolation ensures each test file has independent overrides.\n *\n * @example\n * ```typescript\n * import { setEnv, resetEnv } from '#env/rewire'\n * import { getCI } from '#env/ci'\n *\n * beforeEach(() => {\n * setEnv('CI', '1')\n * })\n *\n * afterEach(() => {\n * resetEnv()\n * })\n *\n * it('should detect CI environment', () => {\n * expect(getCI()).toBe(true)\n * })\n * ```\n */\nexport function setEnv(key: string, value: string | undefined): void {\n testOverrides.set(key, value)\n}\n\n/**\n * Clear a specific environment variable override.\n */\nexport function clearEnv(key: string): void {\n testOverrides.delete(key)\n}\n\n/**\n * Clear all environment variable overrides.\n * Useful in afterEach hooks to ensure clean test state.\n *\n * @example\n * ```typescript\n * import { resetEnv } from '#env/rewire'\n *\n * afterEach(() => {\n * resetEnv()\n * })\n * ```\n */\nexport function resetEnv(): void {\n testOverrides.clear()\n}\n\n/**\n * Check if an environment variable has been overridden.\n */\nexport function hasOverride(key: string): boolean {\n const contextOverrides = envStorage.getStore()\n return contextOverrides?.has(key) || testOverrides.has(key)\n}\n\n/**\n * Run code with environment overrides in an isolated AsyncLocalStorage context.\n * Creates true context isolation - overrides don't leak to concurrent code.\n *\n * Useful for tests that need temporary overrides without affecting other tests\n * or for nested override scenarios.\n *\n * @example\n * ```typescript\n * import { withEnv } from '#env/rewire'\n * import { getCI } from '#env/ci'\n *\n * // Temporary override in isolated context\n * await withEnv({ CI: '1' }, async () => {\n * expect(getCI()).toBe(true)\n * })\n * expect(getCI()).toBe(false) // Override is gone\n * ```\n *\n * @example\n * ```typescript\n * // Nested overrides work correctly\n * setEnv('CI', '1') // Test-level override\n *\n * await withEnv({ CI: '0' }, async () => {\n * expect(getCI()).toBe(false) // Context override takes precedence\n * })\n *\n * expect(getCI()).toBe(true) // Back to test-level override\n * ```\n */\nexport async function withEnv<T>(\n overrides: Record<string, string | undefined>,\n fn: () => T | Promise<T>,\n): Promise<T> {\n const map = new Map(Object.entries(overrides))\n return await envStorage.run(map, fn)\n}\n\n/**\n * Synchronous version of withEnv for non-async code.\n *\n * @example\n * ```typescript\n * import { withEnvSync } from '#env/rewire'\n * import { getCI } from '#env/ci'\n *\n * const result = withEnvSync({ CI: '1' }, () => {\n * return getCI()\n * })\n * expect(result).toBe(true)\n * ```\n */\nexport function withEnvSync<T>(\n overrides: Record<string, string | undefined>,\n fn: () => T,\n): T {\n const map = new Map(Object.entries(overrides))\n return envStorage.run(map, fn)\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,aAAAC,EAAA,WAAAC,EAAA,YAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAT,GAWA,IAAAU,EAAkC,uBAIlC,MAAMC,EAAa,IAAI,oBAIjBC,EAAgB,IAAI,IAYnB,SAAST,EAAYU,EAAiC,CAE3D,MAAMC,EAAmBH,EAAW,SAAS,EAC7C,OAAIG,GAAkB,IAAID,CAAG,EACpBC,EAAiB,IAAID,CAAG,EAI7BD,EAAc,IAAIC,CAAG,EAChBD,EAAc,IAAIC,CAAG,EAIvB,QAAQ,IAAIA,CAAG,CACxB,CA2BO,SAASP,EAAOO,EAAaE,EAAiC,CACnEH,EAAc,IAAIC,EAAKE,CAAK,CAC9B,CAKO,SAASb,EAASW,EAAmB,CAC1CD,EAAc,OAAOC,CAAG,CAC1B,CAeO,SAASR,GAAiB,CAC/BO,EAAc,MAAM,CACtB,CAKO,SAASR,EAAYS,EAAsB,CAEhD,OADyBF,EAAW,SAAS,GACpB,IAAIE,CAAG,GAAKD,EAAc,IAAIC,CAAG,CAC5D,CAiCA,eAAsBN,EACpBS,EACAC,EACY,CACZ,MAAMC,EAAM,IAAI,IAAI,OAAO,QAAQF,CAAS,CAAC,EAC7C,OAAO,MAAML,EAAW,IAAIO,EAAKD,CAAE,CACrC,CAgBO,SAAST,EACdQ,EACAC,EACG,CACH,MAAMC,EAAM,IAAI,IAAI,OAAO,QAAQF,CAAS,CAAC,EAC7C,OAAOL,EAAW,IAAIO,EAAKD,CAAE,CAC/B",
|
|
6
|
+
"names": ["rewire_exports", "__export", "clearEnv", "getEnvValue", "hasOverride", "resetEnv", "setEnv", "withEnv", "withEnvSync", "__toCommonJS", "import_async_hooks", "envStorage", "testOverrides", "key", "contextOverrides", "value", "overrides", "fn", "map"]
|
|
7
7
|
}
|
package/dist/env/socket-cli.d.ts
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
export declare function getSocketCliAcceptRisks(): boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Socket CLI API base URL (alternative name).
|
|
9
|
+
* Checks SOCKET_CLI_API_BASE_URL first, then falls back to legacy SOCKET_SECURITY_API_BASE_URL.
|
|
9
10
|
*
|
|
10
11
|
* @returns API base URL or undefined
|
|
11
12
|
*/
|
|
12
13
|
export declare function getSocketCliApiBaseUrl(): string | undefined;
|
|
13
14
|
/**
|
|
14
15
|
* Proxy URL for Socket CLI API requests (alternative name).
|
|
16
|
+
* Checks SOCKET_CLI_API_PROXY, SOCKET_SECURITY_API_PROXY, then standard proxy env vars.
|
|
17
|
+
* Follows the same precedence as v1.x: HTTPS_PROXY → https_proxy → HTTP_PROXY → http_proxy.
|
|
15
18
|
*
|
|
16
19
|
* @returns API proxy URL or undefined
|
|
17
20
|
*/
|
|
@@ -24,6 +27,8 @@ export declare function getSocketCliApiProxy(): string | undefined;
|
|
|
24
27
|
export declare function getSocketCliApiTimeout(): number;
|
|
25
28
|
/**
|
|
26
29
|
* Socket CLI API authentication token (alternative name).
|
|
30
|
+
* Checks SOCKET_CLI_API_TOKEN, SOCKET_CLI_API_KEY, SOCKET_SECURITY_API_TOKEN, SOCKET_SECURITY_API_KEY.
|
|
31
|
+
* Maintains full v1.x backward compatibility.
|
|
27
32
|
*
|
|
28
33
|
* @returns API token or undefined
|
|
29
34
|
*/
|
|
@@ -54,6 +59,7 @@ export declare function getSocketCliNoApiToken(): boolean;
|
|
|
54
59
|
export declare function getSocketCliOptimize(): boolean;
|
|
55
60
|
/**
|
|
56
61
|
* Socket CLI organization slug identifier (alternative name).
|
|
62
|
+
* Checks SOCKET_CLI_ORG_SLUG first, then falls back to SOCKET_ORG_SLUG.
|
|
57
63
|
*
|
|
58
64
|
* @returns Organization slug or undefined
|
|
59
65
|
*/
|
|
@@ -66,6 +72,7 @@ export declare function getSocketCliOrgSlug(): string | undefined;
|
|
|
66
72
|
export declare function getSocketCliViewAllRisks(): boolean;
|
|
67
73
|
/**
|
|
68
74
|
* Socket CLI GitHub authentication token.
|
|
75
|
+
* Checks SOCKET_CLI_GITHUB_TOKEN, SOCKET_SECURITY_GITHUB_PAT, then falls back to GITHUB_TOKEN.
|
|
69
76
|
*
|
|
70
77
|
* @returns GitHub token or undefined
|
|
71
78
|
*/
|
package/dist/env/socket-cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var r=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var i in t)r(n,i,{get:t[i],enumerable:!0})},u=(n,t,i,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!I.call(n,o)&&o!==i&&r(n,o,{get:()=>t[o],enumerable:!(C=S(t,o))||C.enumerable});return n};var O=n=>u(r({},"__esModule",{value:!0}),n);var s={};E(s,{getSocketCliAcceptRisks:()=>K,getSocketCliApiBaseUrl:()=>c,getSocketCliApiProxy:()=>p,getSocketCliApiTimeout:()=>A,getSocketCliApiToken:()=>g,getSocketCliConfig:()=>f,getSocketCliFix:()=>l,getSocketCliGithubToken:()=>x,getSocketCliNoApiToken:()=>P,getSocketCliOptimize:()=>L,getSocketCliOrgSlug:()=>k,getSocketCliViewAllRisks:()=>R});module.exports=O(s);var _=require("#env/helpers"),e=require("#env/rewire");function K(){return(0,_.envAsBoolean)((0,e.getEnvValue)("SOCKET_CLI_ACCEPT_RISKS"))}function c(){return(0,e.getEnvValue)("SOCKET_CLI_API_BASE_URL")||(0,e.getEnvValue)("SOCKET_SECURITY_API_BASE_URL")}function p(){return(0,e.getEnvValue)("SOCKET_CLI_API_PROXY")||(0,e.getEnvValue)("SOCKET_SECURITY_API_PROXY")||(0,e.getEnvValue)("HTTPS_PROXY")||(0,e.getEnvValue)("https_proxy")||(0,e.getEnvValue)("HTTP_PROXY")||(0,e.getEnvValue)("http_proxy")}function A(){return(0,_.envAsNumber)((0,e.getEnvValue)("SOCKET_CLI_API_TIMEOUT"))}function g(){return(0,e.getEnvValue)("SOCKET_CLI_API_TOKEN")||(0,e.getEnvValue)("SOCKET_CLI_API_KEY")||(0,e.getEnvValue)("SOCKET_SECURITY_API_TOKEN")||(0,e.getEnvValue)("SOCKET_SECURITY_API_KEY")}function f(){return(0,e.getEnvValue)("SOCKET_CLI_CONFIG")}function l(){return(0,e.getEnvValue)("SOCKET_CLI_FIX")}function P(){return(0,_.envAsBoolean)((0,e.getEnvValue)("SOCKET_CLI_NO_API_TOKEN"))}function L(){return(0,_.envAsBoolean)((0,e.getEnvValue)("SOCKET_CLI_OPTIMIZE"))}function k(){return(0,e.getEnvValue)("SOCKET_CLI_ORG_SLUG")||(0,e.getEnvValue)("SOCKET_ORG_SLUG")}function R(){return(0,_.envAsBoolean)((0,e.getEnvValue)("SOCKET_CLI_VIEW_ALL_RISKS"))}function x(){return(0,e.getEnvValue)("SOCKET_CLI_GITHUB_TOKEN")||(0,e.getEnvValue)("SOCKET_SECURITY_GITHUB_PAT")||(0,e.getEnvValue)("GITHUB_TOKEN")}0&&(module.exports={getSocketCliAcceptRisks,getSocketCliApiBaseUrl,getSocketCliApiProxy,getSocketCliApiTimeout,getSocketCliApiToken,getSocketCliConfig,getSocketCliFix,getSocketCliGithubToken,getSocketCliNoApiToken,getSocketCliOptimize,getSocketCliOrgSlug,getSocketCliViewAllRisks});
|
|
3
3
|
//# sourceMappingURL=socket-cli.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/env/socket-cli.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Socket CLI environment variables.\n * Provides typed getters for SOCKET_CLI_* environment variables (excluding shadow).\n */\n\nimport { envAsBoolean, envAsNumber } from '#env/helpers'\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * Whether to accept all Socket CLI risks (alternative name).\n *\n * @returns Whether to accept all risks\n */\nexport function getSocketCliAcceptRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_ACCEPT_RISKS'))\n}\n\n/**\n * Socket CLI API base URL (alternative name).\n *\n * @returns API base URL or undefined\n */\nexport function getSocketCliApiBaseUrl(): string | undefined {\n return getEnvValue('SOCKET_CLI_API_BASE_URL')\n}\n\n/**\n * Proxy URL for Socket CLI API requests (alternative name).\n *\n * @returns API proxy URL or undefined\n */\nexport function getSocketCliApiProxy(): string | undefined {\n return getEnvValue('SOCKET_CLI_API_PROXY')\n}\n\n/**\n * Timeout in milliseconds for Socket CLI API requests (alternative name).\n *\n * @returns API timeout in milliseconds\n */\nexport function getSocketCliApiTimeout(): number {\n return envAsNumber(getEnvValue('SOCKET_CLI_API_TIMEOUT'))\n}\n\n/**\n * Socket CLI API authentication token (alternative name).\n *\n * @returns API token or undefined\n */\nexport function getSocketCliApiToken(): string | undefined {\n return getEnvValue('SOCKET_CLI_API_TOKEN')\n}\n\n/**\n * Socket CLI configuration file path (alternative name).\n *\n * @returns Config file path or undefined\n */\nexport function getSocketCliConfig(): string | undefined {\n return getEnvValue('SOCKET_CLI_CONFIG')\n}\n\n/**\n * Controls Socket CLI fix mode.\n *\n * @returns Fix mode value or undefined\n */\nexport function getSocketCliFix(): string | undefined {\n return getEnvValue('SOCKET_CLI_FIX')\n}\n\n/**\n * Whether to skip Socket CLI API token requirement (alternative name).\n *\n * @returns Whether to skip API token requirement\n */\nexport function getSocketCliNoApiToken(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_NO_API_TOKEN'))\n}\n\n/**\n * Controls Socket CLI optimization mode.\n *\n * @returns Whether optimization mode is enabled\n */\nexport function getSocketCliOptimize(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_OPTIMIZE'))\n}\n\n/**\n * Socket CLI organization slug identifier (alternative name).\n *\n * @returns Organization slug or undefined\n */\nexport function getSocketCliOrgSlug(): string | undefined {\n return getEnvValue('SOCKET_CLI_ORG_SLUG')\n}\n\n/**\n * Whether to view all Socket CLI risks (alternative name).\n *\n * @returns Whether to view all risks\n */\nexport function getSocketCliViewAllRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_VIEW_ALL_RISKS'))\n}\n\n/**\n * Socket CLI GitHub authentication token.\n *\n * @returns GitHub token or undefined\n */\nexport function getSocketCliGithubToken(): string | undefined {\n return getEnvValue('SOCKET_CLI_GITHUB_TOKEN')\n}\n"],
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,4BAAAC,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA0C,wBAC1CC,EAA4B,uBAOrB,SAASd,GAAmC,CACjD,SAAO,mBAAa,eAAY,yBAAyB,CAAC,CAC5D,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Socket CLI environment variables.\n * Provides typed getters for SOCKET_CLI_* environment variables (excluding shadow).\n */\n\nimport { envAsBoolean, envAsNumber } from '#env/helpers'\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * Whether to accept all Socket CLI risks (alternative name).\n *\n * @returns Whether to accept all risks\n */\nexport function getSocketCliAcceptRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_ACCEPT_RISKS'))\n}\n\n/**\n * Socket CLI API base URL (alternative name).\n * Checks SOCKET_CLI_API_BASE_URL first, then falls back to legacy SOCKET_SECURITY_API_BASE_URL.\n *\n * @returns API base URL or undefined\n */\nexport function getSocketCliApiBaseUrl(): string | undefined {\n return (\n getEnvValue('SOCKET_CLI_API_BASE_URL') ||\n getEnvValue('SOCKET_SECURITY_API_BASE_URL')\n )\n}\n\n/**\n * Proxy URL for Socket CLI API requests (alternative name).\n * Checks SOCKET_CLI_API_PROXY, SOCKET_SECURITY_API_PROXY, then standard proxy env vars.\n * Follows the same precedence as v1.x: HTTPS_PROXY \u2192 https_proxy \u2192 HTTP_PROXY \u2192 http_proxy.\n *\n * @returns API proxy URL or undefined\n */\nexport function getSocketCliApiProxy(): string | undefined {\n return (\n getEnvValue('SOCKET_CLI_API_PROXY') ||\n getEnvValue('SOCKET_SECURITY_API_PROXY') ||\n getEnvValue('HTTPS_PROXY') ||\n getEnvValue('https_proxy') ||\n getEnvValue('HTTP_PROXY') ||\n getEnvValue('http_proxy')\n )\n}\n\n/**\n * Timeout in milliseconds for Socket CLI API requests (alternative name).\n *\n * @returns API timeout in milliseconds\n */\nexport function getSocketCliApiTimeout(): number {\n return envAsNumber(getEnvValue('SOCKET_CLI_API_TIMEOUT'))\n}\n\n/**\n * Socket CLI API authentication token (alternative name).\n * Checks SOCKET_CLI_API_TOKEN, SOCKET_CLI_API_KEY, SOCKET_SECURITY_API_TOKEN, SOCKET_SECURITY_API_KEY.\n * Maintains full v1.x backward compatibility.\n *\n * @returns API token or undefined\n */\nexport function getSocketCliApiToken(): string | undefined {\n return (\n getEnvValue('SOCKET_CLI_API_TOKEN') ||\n getEnvValue('SOCKET_CLI_API_KEY') ||\n getEnvValue('SOCKET_SECURITY_API_TOKEN') ||\n getEnvValue('SOCKET_SECURITY_API_KEY')\n )\n}\n\n/**\n * Socket CLI configuration file path (alternative name).\n *\n * @returns Config file path or undefined\n */\nexport function getSocketCliConfig(): string | undefined {\n return getEnvValue('SOCKET_CLI_CONFIG')\n}\n\n/**\n * Controls Socket CLI fix mode.\n *\n * @returns Fix mode value or undefined\n */\nexport function getSocketCliFix(): string | undefined {\n return getEnvValue('SOCKET_CLI_FIX')\n}\n\n/**\n * Whether to skip Socket CLI API token requirement (alternative name).\n *\n * @returns Whether to skip API token requirement\n */\nexport function getSocketCliNoApiToken(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_NO_API_TOKEN'))\n}\n\n/**\n * Controls Socket CLI optimization mode.\n *\n * @returns Whether optimization mode is enabled\n */\nexport function getSocketCliOptimize(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_OPTIMIZE'))\n}\n\n/**\n * Socket CLI organization slug identifier (alternative name).\n * Checks SOCKET_CLI_ORG_SLUG first, then falls back to SOCKET_ORG_SLUG.\n *\n * @returns Organization slug or undefined\n */\nexport function getSocketCliOrgSlug(): string | undefined {\n return getEnvValue('SOCKET_CLI_ORG_SLUG') || getEnvValue('SOCKET_ORG_SLUG')\n}\n\n/**\n * Whether to view all Socket CLI risks (alternative name).\n *\n * @returns Whether to view all risks\n */\nexport function getSocketCliViewAllRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_CLI_VIEW_ALL_RISKS'))\n}\n\n/**\n * Socket CLI GitHub authentication token.\n * Checks SOCKET_CLI_GITHUB_TOKEN, SOCKET_SECURITY_GITHUB_PAT, then falls back to GITHUB_TOKEN.\n *\n * @returns GitHub token or undefined\n */\nexport function getSocketCliGithubToken(): string | undefined {\n return (\n getEnvValue('SOCKET_CLI_GITHUB_TOKEN') ||\n getEnvValue('SOCKET_SECURITY_GITHUB_PAT') ||\n getEnvValue('GITHUB_TOKEN')\n )\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,4BAAAC,EAAA,2BAAAC,EAAA,yBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA0C,wBAC1CC,EAA4B,uBAOrB,SAASd,GAAmC,CACjD,SAAO,mBAAa,eAAY,yBAAyB,CAAC,CAC5D,CAQO,SAASC,GAA6C,CAC3D,SACE,eAAY,yBAAyB,MACrC,eAAY,8BAA8B,CAE9C,CASO,SAASC,GAA2C,CACzD,SACE,eAAY,sBAAsB,MAClC,eAAY,2BAA2B,MACvC,eAAY,aAAa,MACzB,eAAY,aAAa,MACzB,eAAY,YAAY,MACxB,eAAY,YAAY,CAE5B,CAOO,SAASC,GAAiC,CAC/C,SAAO,kBAAY,eAAY,wBAAwB,CAAC,CAC1D,CASO,SAASC,GAA2C,CACzD,SACE,eAAY,sBAAsB,MAClC,eAAY,oBAAoB,MAChC,eAAY,2BAA2B,MACvC,eAAY,yBAAyB,CAEzC,CAOO,SAASC,GAAyC,CACvD,SAAO,eAAY,mBAAmB,CACxC,CAOO,SAASC,GAAsC,CACpD,SAAO,eAAY,gBAAgB,CACrC,CAOO,SAASE,GAAkC,CAChD,SAAO,mBAAa,eAAY,yBAAyB,CAAC,CAC5D,CAOO,SAASC,GAAgC,CAC9C,SAAO,mBAAa,eAAY,qBAAqB,CAAC,CACxD,CAQO,SAASC,GAA0C,CACxD,SAAO,eAAY,qBAAqB,MAAK,eAAY,iBAAiB,CAC5E,CAOO,SAASC,GAAoC,CAClD,SAAO,mBAAa,eAAY,2BAA2B,CAAC,CAC9D,CAQO,SAASJ,GAA8C,CAC5D,SACE,eAAY,yBAAyB,MACrC,eAAY,4BAA4B,MACxC,eAAY,cAAc,CAE9B",
|
|
6
6
|
"names": ["socket_cli_exports", "__export", "getSocketCliAcceptRisks", "getSocketCliApiBaseUrl", "getSocketCliApiProxy", "getSocketCliApiTimeout", "getSocketCliApiToken", "getSocketCliConfig", "getSocketCliFix", "getSocketCliGithubToken", "getSocketCliNoApiToken", "getSocketCliOptimize", "getSocketCliOrgSlug", "getSocketCliViewAllRisks", "__toCommonJS", "import_helpers", "import_rewire"]
|
|
7
7
|
}
|
|
@@ -22,6 +22,16 @@ interface YoctoColors {
|
|
|
22
22
|
gray: (text: string) => string
|
|
23
23
|
grey: (text: string) => string
|
|
24
24
|
|
|
25
|
+
// Bright colors
|
|
26
|
+
blackBright: (text: string) => string
|
|
27
|
+
redBright: (text: string) => string
|
|
28
|
+
greenBright: (text: string) => string
|
|
29
|
+
yellowBright: (text: string) => string
|
|
30
|
+
blueBright: (text: string) => string
|
|
31
|
+
magentaBright: (text: string) => string
|
|
32
|
+
cyanBright: (text: string) => string
|
|
33
|
+
whiteBright: (text: string) => string
|
|
34
|
+
|
|
25
35
|
// Background colors
|
|
26
36
|
bgBlack: (text: string) => string
|
|
27
37
|
bgRed: (text: string) => string
|
|
@@ -31,6 +41,10 @@ interface YoctoColors {
|
|
|
31
41
|
bgMagenta: (text: string) => string
|
|
32
42
|
bgCyan: (text: string) => string
|
|
33
43
|
bgWhite: (text: string) => string
|
|
44
|
+
|
|
45
|
+
// RGB colors
|
|
46
|
+
rgb: (r: number, g: number, b: number) => (text: string) => string
|
|
47
|
+
bgRgb: (r: number, g: number, b: number) => (text: string) => string
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
declare const yoctocolorsCjs: YoctoColors
|
package/dist/fs.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @fileoverview File system utilities with cross-platform path handling.
|
|
3
3
|
* Provides enhanced fs operations, glob matching, and directory traversal functions.
|
|
4
4
|
*/
|
|
5
|
-
import type { Abortable } from '
|
|
6
|
-
import type { ObjectEncodingOptions, OpenMode, PathLike } from '
|
|
5
|
+
import type { Abortable } from 'events';
|
|
6
|
+
import type { MakeDirectoryOptions, ObjectEncodingOptions, OpenMode, PathLike } from 'fs';
|
|
7
7
|
import type { JsonReviver } from './json';
|
|
8
8
|
import { type Remap } from './objects';
|
|
9
9
|
/**
|
|
@@ -463,7 +463,7 @@ export declare function readDirNamesSync(dirname: PathLike, options?: ReadDirOpt
|
|
|
463
463
|
* ```
|
|
464
464
|
*/
|
|
465
465
|
/*@__NO_SIDE_EFFECTS__*/
|
|
466
|
-
export declare function readFileBinary(filepath: PathLike, options?: ReadFileOptions | undefined): Promise<
|
|
466
|
+
export declare function readFileBinary(filepath: PathLike, options?: ReadFileOptions | undefined): Promise<NonSharedBuffer>;
|
|
467
467
|
/**
|
|
468
468
|
* Read a file as UTF-8 text asynchronously.
|
|
469
469
|
* Returns a string with the file contents decoded as UTF-8.
|
|
@@ -644,6 +644,61 @@ export declare function safeDelete(filepath: PathLike | PathLike[], options?: Re
|
|
|
644
644
|
*/
|
|
645
645
|
/*@__NO_SIDE_EFFECTS__*/
|
|
646
646
|
export declare function safeDeleteSync(filepath: PathLike | PathLike[], options?: RemoveOptions | undefined): void;
|
|
647
|
+
/**
|
|
648
|
+
* Safely create a directory asynchronously, ignoring EEXIST errors.
|
|
649
|
+
* This function wraps fs.promises.mkdir and handles the race condition where
|
|
650
|
+
* the directory might already exist, which is common in concurrent code.
|
|
651
|
+
*
|
|
652
|
+
* Unlike fs.promises.mkdir with recursive:true, this function:
|
|
653
|
+
* - Silently ignores EEXIST errors (directory already exists)
|
|
654
|
+
* - Re-throws all other errors (permissions, invalid path, etc.)
|
|
655
|
+
* - Works reliably in multi-process/concurrent scenarios
|
|
656
|
+
*
|
|
657
|
+
* @param path - Directory path to create
|
|
658
|
+
* @param options - Options including recursive and mode settings
|
|
659
|
+
* @returns Promise that resolves when directory is created or already exists
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```ts
|
|
663
|
+
* // Create a directory, no error if it exists
|
|
664
|
+
* await safeMkdir('./config')
|
|
665
|
+
*
|
|
666
|
+
* // Create nested directories
|
|
667
|
+
* await safeMkdir('./data/cache/temp', { recursive: true })
|
|
668
|
+
*
|
|
669
|
+
* // Create with specific permissions
|
|
670
|
+
* await safeMkdir('./secure', { mode: 0o700 })
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
674
|
+
export declare function safeMkdir(path: PathLike, options?: MakeDirectoryOptions | undefined): Promise<void>;
|
|
675
|
+
/**
|
|
676
|
+
* Safely create a directory synchronously, ignoring EEXIST errors.
|
|
677
|
+
* This function wraps fs.mkdirSync and handles the race condition where
|
|
678
|
+
* the directory might already exist, which is common in concurrent code.
|
|
679
|
+
*
|
|
680
|
+
* Unlike fs.mkdirSync with recursive:true, this function:
|
|
681
|
+
* - Silently ignores EEXIST errors (directory already exists)
|
|
682
|
+
* - Re-throws all other errors (permissions, invalid path, etc.)
|
|
683
|
+
* - Works reliably in multi-process/concurrent scenarios
|
|
684
|
+
*
|
|
685
|
+
* @param path - Directory path to create
|
|
686
|
+
* @param options - Options including recursive and mode settings
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* // Create a directory, no error if it exists
|
|
691
|
+
* safeMkdirSync('./config')
|
|
692
|
+
*
|
|
693
|
+
* // Create nested directories
|
|
694
|
+
* safeMkdirSync('./data/cache/temp', { recursive: true })
|
|
695
|
+
*
|
|
696
|
+
* // Create with specific permissions
|
|
697
|
+
* safeMkdirSync('./secure', { mode: 0o700 })
|
|
698
|
+
* ```
|
|
699
|
+
*/
|
|
700
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
701
|
+
export declare function safeMkdirSync(path: PathLike, options?: MakeDirectoryOptions | undefined): void;
|
|
647
702
|
/**
|
|
648
703
|
* Safely read a file asynchronously, returning undefined on error.
|
|
649
704
|
* Useful when you want to attempt reading a file without handling errors explicitly.
|
|
@@ -666,7 +721,30 @@ export declare function safeDeleteSync(filepath: PathLike | PathLike[], options?
|
|
|
666
721
|
* ```
|
|
667
722
|
*/
|
|
668
723
|
/*@__NO_SIDE_EFFECTS__*/
|
|
669
|
-
export declare function safeReadFile(filepath: PathLike, options?: SafeReadOptions | undefined): Promise<
|
|
724
|
+
export declare function safeReadFile(filepath: PathLike, options?: SafeReadOptions | undefined): Promise<NonSharedBuffer>;
|
|
725
|
+
/**
|
|
726
|
+
* Safely read a file synchronously, returning undefined on error.
|
|
727
|
+
* Useful when you want to attempt reading a file without handling errors explicitly.
|
|
728
|
+
* Returns undefined for any error (file not found, permission denied, etc.).
|
|
729
|
+
*
|
|
730
|
+
* @param filepath - Path to file
|
|
731
|
+
* @param options - Read options including encoding and default value
|
|
732
|
+
* @returns File contents, or undefined on error
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* ```ts
|
|
736
|
+
* // Try to read a config file
|
|
737
|
+
* const config = safeReadFileSync('./config.txt')
|
|
738
|
+
* if (config) {
|
|
739
|
+
* console.log('Config loaded successfully')
|
|
740
|
+
* }
|
|
741
|
+
*
|
|
742
|
+
* // Read binary file safely
|
|
743
|
+
* const buffer = safeReadFileSync('./image.png', { encoding: null })
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
747
|
+
export declare function safeReadFileSync(filepath: PathLike, options?: SafeReadOptions | undefined): string | NonSharedBuffer;
|
|
670
748
|
/**
|
|
671
749
|
* Safely get file stats asynchronously, returning undefined on error.
|
|
672
750
|
* Useful for checking file existence and properties without error handling.
|
|
@@ -708,29 +786,6 @@ export declare function safeStats(filepath: PathLike): Promise<import("fs").Stat
|
|
|
708
786
|
*/
|
|
709
787
|
/*@__NO_SIDE_EFFECTS__*/
|
|
710
788
|
export declare function safeStatsSync(filepath: PathLike, options?: ReadFileOptions | undefined): import("fs").BigIntStats | import("fs").Stats;
|
|
711
|
-
/**
|
|
712
|
-
* Safely read a file synchronously, returning undefined on error.
|
|
713
|
-
* Useful when you want to attempt reading a file without handling errors explicitly.
|
|
714
|
-
* Returns undefined for any error (file not found, permission denied, etc.).
|
|
715
|
-
*
|
|
716
|
-
* @param filepath - Path to file
|
|
717
|
-
* @param options - Read options including encoding and default value
|
|
718
|
-
* @returns File contents, or undefined on error
|
|
719
|
-
*
|
|
720
|
-
* @example
|
|
721
|
-
* ```ts
|
|
722
|
-
* // Try to read a config file
|
|
723
|
-
* const config = safeReadFileSync('./config.txt')
|
|
724
|
-
* if (config) {
|
|
725
|
-
* console.log('Config loaded successfully')
|
|
726
|
-
* }
|
|
727
|
-
*
|
|
728
|
-
* // Read binary file safely
|
|
729
|
-
* const buffer = safeReadFileSync('./image.png', { encoding: null })
|
|
730
|
-
* ```
|
|
731
|
-
*/
|
|
732
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
733
|
-
export declare function safeReadFileSync(filepath: PathLike, options?: SafeReadOptions | undefined): string | NonSharedBuffer;
|
|
734
789
|
/**
|
|
735
790
|
* Generate a unique filepath by adding number suffix if the path exists.
|
|
736
791
|
* Appends `-1`, `-2`, etc. before the file extension until a non-existent path is found.
|
package/dist/fs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var F=Object.defineProperty;var
|
|
3
|
-
Ensure the file exists or create it with the expected structure.`,{cause:d}):
|
|
4
|
-
Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}function re(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=
|
|
5
|
-
Ensure the file exists or create it with the expected structure.`,{cause:d}):
|
|
6
|
-
Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}let O;function N(){if(O===void 0){const n=
|
|
7
|
-
`,s!==void 0?s:!0,c,a);await d.promises.writeFile(n,
|
|
8
|
-
`,s!==void 0?s:!0,c,a);d.writeFileSync(n,
|
|
2
|
+
var F=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},B=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of W(e))!M.call(n,o)&&o!==t&&F(n,o,{get:()=>e[o],enumerable:!(i=T(e,o))||i.enumerable});return n};var q=n=>B(F({},"__esModule",{value:!0}),n);var ye={};$(ye,{findUp:()=>V,findUpSync:()=>G,invalidatePathCache:()=>I,isDir:()=>z,isDirEmptySync:()=>j,isDirSync:()=>X,isSymLinkSync:()=>K,readDirNames:()=>Q,readDirNamesSync:()=>Y,readFileBinary:()=>Z,readFileBinarySync:()=>ne,readFileUtf8:()=>ee,readFileUtf8Sync:()=>te,readJson:()=>ie,readJsonSync:()=>re,safeDelete:()=>oe,safeDeleteSync:()=>se,safeMkdir:()=>ae,safeMkdirSync:()=>ce,safeReadFile:()=>de,safeReadFileSync:()=>fe,safeStats:()=>U,safeStatsSync:()=>C,uniqueSync:()=>le,validateFiles:()=>H,writeJson:()=>ue,writeJsonSync:()=>pe});module.exports=q(ye);var v=require("#constants/process"),_=require("./arrays"),S=require("./globs"),b=require("./json"),D=require("./objects"),p=require("./path"),E=require("./paths/rewire"),R=require("./sorts");const w=(0,v.getAbortSignal)(),L=(0,D.objectFreeze)({__proto__:null,force:!0,maxRetries:3,recursive:!0,retryDelay:200});let P;function f(){return P===void 0&&(P=require("node:fs")),P}let k;function m(){return k===void 0&&(k=require("node:path")),k}function J(n,e,t){const{ignore:i,includeEmpty:o=!0,sort:s=!0}={__proto__:null,...t},c=m(),a=n.filter(r=>r.isDirectory()&&(o||!j(c.join(e||r.parentPath,r.name),{ignore:i}))).map(r=>r.name);return s?a.sort(R.naturalCompare):a}function A(n,e,t,i,o=2){const s=t?e:"";return`${JSON.stringify(n,i,o).replace(/\n/g,e)}${s}`}async function V(n,e){const{cwd:t=process.cwd(),signal:i=w}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=f(),a=m();let r=a.resolve(t);const{root:d}=a.parse(r),l=(0,_.isArray)(n)?n:[n];for(;r&&r!==d;){for(const g of l){if(i?.aborted)return;const u=a.join(r,g);try{const y=await c.promises.stat(u);if(!o&&y.isFile())return(0,p.normalizePath)(u);if(!s&&y.isDirectory())return(0,p.normalizePath)(u)}catch{}}r=a.dirname(r)}}function G(n,e){const{cwd:t=process.cwd(),stopAt:i}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=f(),a=m();let r=a.resolve(t);const{root:d}=a.parse(r),l=i?a.resolve(i):void 0,g=(0,_.isArray)(n)?n:[n];for(;r&&r!==d;){if(l&&r===l){for(const u of g){const y=a.join(r,u);try{const h=c.statSync(y);if(!o&&h.isFile())return(0,p.normalizePath)(y);if(!s&&h.isDirectory())return(0,p.normalizePath)(y)}catch{}}return}for(const u of g){const y=a.join(r,u);try{const h=c.statSync(y);if(!o&&h.isFile())return(0,p.normalizePath)(y);if(!s&&h.isDirectory())return(0,p.normalizePath)(y)}catch{}}r=a.dirname(r)}}async function z(n){return!!(await U(n))?.isDirectory()}function X(n){return!!C(n)?.isDirectory()}function j(n,e){const{ignore:t=S.defaultIgnore}={__proto__:null,...e},i=f();try{const o=i.readdirSync(n),{length:s}=o;if(s===0)return!0;const c=(0,S.getGlobMatcher)(t,{cwd:(0,p.pathLikeToString)(n)});let a=0;for(let r=0;r<s;r+=1){const d=o[r];d&&c(d)&&(a+=1)}return a===s}catch{return!1}}function K(n){const e=f();try{return e.lstatSync(n).isSymbolicLink()}catch{}return!1}function H(n){const e=f(),t=[],i=[],{R_OK:o}=e.constants;for(const s of n)try{e.accessSync(s,o),t.push(s)}catch{i.push(s)}return{__proto__:null,validPaths:t,invalidPaths:i}}async function Q(n,e){const t=f();try{return J(await t.promises.readdir(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}function Y(n,e){const t=f();try{return J(t.readdirSync(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}async function Z(n,e){const t=typeof e=="string"?{encoding:e}:e;return await f().promises.readFile(n,{signal:w,...t,encoding:null})}async function ee(n,e){const t=typeof e=="string"?{encoding:e}:e;return await f().promises.readFile(n,{signal:w,...t,encoding:"utf8"})}function ne(n,e){const t=typeof e=="string"?{encoding:e}:e;return f().readFileSync(n,{...t,encoding:null})}function te(n,e){const t=typeof e=="string"?{encoding:e}:e;return f().readFileSync(n,{...t,encoding:"utf8"})}async function ie(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=f();let r="";try{r=await a.promises.readFile(n,{__proto__:null,encoding:"utf8",...s})}catch(d){if(c){const l=d.code;throw l==="ENOENT"?new Error(`JSON file not found: ${n}
|
|
3
|
+
Ensure the file exists or create it with the expected structure.`,{cause:d}):l==="EACCES"||l==="EPERM"?new Error(`Permission denied reading JSON file: ${n}
|
|
4
|
+
Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}function re(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=f();let r="";try{r=a.readFileSync(n,{__proto__:null,encoding:"utf8",...s})}catch(d){if(c){const l=d.code;throw l==="ENOENT"?new Error(`JSON file not found: ${n}
|
|
5
|
+
Ensure the file exists or create it with the expected structure.`,{cause:d}):l==="EACCES"||l==="EPERM"?new Error(`Permission denied reading JSON file: ${n}
|
|
6
|
+
Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}let O;function N(){if(O===void 0){const n=m(),{getOsTmpDir:e,getSocketCacacheDir:t,getSocketUserDir:i}=require("#lib/paths");O=[n.resolve(e()),n.resolve(t()),n.resolve(i())]}return O}function I(){O=void 0}(0,E.registerCacheInvalidation)(I);async function oe(n,e){const t=require("./external/del"),{deleteAsync:i}=t,o={__proto__:null,...e},s=(0,_.isArray)(n)?n.map(p.pathLikeToString):[(0,p.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=m(),r=N();s.every(l=>{const g=a.resolve(l);for(const u of r){const y=g.startsWith(u+a.sep)||g===u,x=a.relative(u,g).startsWith("..");if(y&&!x)return!0}return!1})&&(c=!0)}await i(s,{concurrency:o.maxRetries||L.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}function se(n,e){const t=require("./external/del"),{deleteSync:i}=t,o={__proto__:null,...e},s=(0,_.isArray)(n)?n.map(p.pathLikeToString):[(0,p.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=m(),r=N();s.every(l=>{const g=a.resolve(l);for(const u of r){const y=g.startsWith(u+a.sep)||g===u,x=a.relative(u,g).startsWith("..");if(y&&!x)return!0}return!1})&&(c=!0)}i(s,{concurrency:o.maxRetries||L.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}async function ae(n,e){const t=f();try{await t.promises.mkdir(n,e)}catch(i){if(typeof i=="object"&&i!==null&&"code"in i&&i.code!=="EEXIST")throw i}}function ce(n,e){const t=f();try{t.mkdirSync(n,e)}catch(i){if(typeof i=="object"&&i!==null&&"code"in i&&i.code!=="EEXIST")throw i}}async function de(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return await i.promises.readFile(n,{signal:w,...t})}catch{}}function fe(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return i.readFileSync(n,{__proto__:null,...t})}catch{}}async function U(n){const e=f();try{return await e.promises.stat(n)}catch{}}function C(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return i.statSync(n,{__proto__:null,throwIfNoEntry:!1,...t})}catch{}}function le(n){const e=f(),t=m(),i=String(n);if(!e.existsSync(i))return(0,p.normalizePath)(i);const o=t.dirname(i),s=t.extname(i),c=t.basename(i,s);let a=1,r;do r=t.join(o,`${c}-${a}${s}`),a++;while(e.existsSync(r));return(0,p.normalizePath)(r)}async function ue(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},d=f(),l=A(e,o||`
|
|
7
|
+
`,s!==void 0?s:!0,c,a);await d.promises.writeFile(n,l,{encoding:"utf8",...r,__proto__:null})}function pe(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},d=f(),l=A(e,o||`
|
|
8
|
+
`,s!==void 0?s:!0,c,a);d.writeFileSync(n,l,{encoding:"utf8",...r,__proto__:null})}0&&(module.exports={findUp,findUpSync,invalidatePathCache,isDir,isDirEmptySync,isDirSync,isSymLinkSync,readDirNames,readDirNamesSync,readFileBinary,readFileBinarySync,readFileUtf8,readFileUtf8Sync,readJson,readJsonSync,safeDelete,safeDeleteSync,safeMkdir,safeMkdirSync,safeReadFile,safeReadFileSync,safeStats,safeStatsSync,uniqueSync,validateFiles,writeJson,writeJsonSync});
|
|
9
9
|
//# sourceMappingURL=fs.js.map
|