Skip to content

Commit 0f16449

Browse files
committed
Migrate from socket-registry/registry to @socketsecurity/lib v2.0.0
0 parents  commit 0f16449

File tree

263 files changed

+29865
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+29865
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tsconfig.build.tsbuildinfo.tmp-build/

CHANGELOG.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.5.3] - 2025-10-07
9+
10+
### Added
11+
12+
- Fix bad build and add validation to prevent in future
13+
14+
## [1.5.2] - 2025-10-07
15+
16+
### Added
17+
18+
- Added coverage utilities to parse v8 and type coverage reports
19+
20+
### Fixed
21+
22+
- Fixed `isPath` function to exclude URLs with protocols
23+
- Fixed `isolatePackage` to handle file: URLs and npm-package-arg paths correctly
24+
25+
## [1.5.1] - 2025-10-05
26+
27+
### Added
28+
29+
- Added `isolatePackage` to `lib/packages/isolation` for creating isolated package test environments
30+
31+
### Changed
32+
33+
- Removed `dependencies/index` barrel file to prevent eager loading of all dependency modules
34+
35+
## [1.5.0] - 2025-10-05
36+
37+
### Added
38+
39+
- Added support for testing local development packages in addition to socket-registry packages
40+
- Exposed isolation module as part of public API via `lib/packages`
41+
42+
### Changed
43+
44+
- Renamed `setupPackageTest` to `isolatePackage` for clearer intent
45+
- Refactored `installPackageForTesting` to accept explicit `sourcePath` and `packageName` parameters
46+
- Simplified package installation logic by removing path detection from low-level function
47+
- Consolidated `setupPackageTest` and `setupMultiEntryTest` into single `isolatePackage` function with options
48+
49+
## [1.4.6] - 2025-10-05
50+
51+
### Added
52+
53+
- Added comprehensive package.json exports validation tests
54+
55+
## [1.4.5] - 2025-10-05
56+
57+
### Added
58+
59+
- Added performance monitoring utilities with timer, measurement, and reporting functions
60+
- Added memoization utilities with LRU, TTL, weak references, and promise deduplication support
61+
- Added table formatting utilities (`formatTable`, `formatSimpleTable`) for CLI output
62+
- Added progress tracking to spinner with `updateProgress()` and `incrementProgress()` methods
63+
- Added `isDir` and `safeStats` async helpers to fs module
64+
65+
### Changed
66+
67+
- Removed `platform` and `arch` options from `dlxBinary` function as cross-platform binary execution is not supported
68+
69+
### Fixed
70+
71+
- Fixed Windows shell execution in `dlxBinary` by adding cache directory to PATH
72+
73+
## [1.4.4] - 2025-10-05
74+
75+
### Fixed
76+
77+
- Fixed subpath exports
78+
79+
## [1.4.3] - 2025-10-04
80+
81+
### Added
82+
83+
- Spinner lifecycle utilities (`withSpinner`, `withSpinnerRestore`, `withSpinnerSync`) for automatic spinner cleanup with try/finally blocks
84+
85+
## [1.4.2] - 2025-10-04
86+
87+
### Added
88+
89+
- Added `GITHUB_API_BASE_URL` constant for GitHub API endpoint configuration
90+
- Added `SOCKET_API_BASE_URL` constant for Socket API endpoint configuration
91+
- Added generic TTL cache utility (`createTtlCache`) with in-memory memoization and persistent storage support
92+
93+
### Changed
94+
95+
- Refactored GitHub caching to use the new `cache-with-ttl` utility for better performance and consistency
96+
97+
## [1.4.1] - 2025-10-04
98+
99+
### Changed
100+
101+
- Update maintained Node.js versions of `constants.maintainedNodeVersions`
102+
103+
## [1.4.0] - 2025-10-04
104+
105+
### Added
106+
107+
- Added `PromiseQueue` utility for controlled concurrency operations
108+
- Added lazy dependency loaders and test utilities
109+
- Added HTTP utilities with retry logic and download locking
110+
- Added `.claude` directory for scratch documents
111+
- Added `noUnusedLocals` and `noUnusedParameters` to TypeScript config
112+
113+
### Changed
114+
115+
- Refactored all library functions to use options objects for better API consistency
116+
- `lib/strings.ts` - String manipulation functions
117+
- `lib/url.ts` - URL handling functions
118+
- `lib/words.ts` - Word manipulation functions
119+
- Refactored `lib/packages` module into specialized submodules for improved code organization
120+
- `lib/packages/editable.ts` - Package editing functionality
121+
- `lib/packages/exports.ts` - Export resolution utilities
122+
- `lib/packages/licenses.ts` - License handling and validation
123+
- `lib/packages/manifest.ts` - Manifest data operations
124+
- `lib/packages/normalize.ts` - Path normalization utilities
125+
- `lib/packages/operations.ts` - Package installation and modification operations
126+
- `lib/packages/paths.ts` - Package path utilities
127+
- `lib/packages/provenance.ts` - Package provenance verification
128+
- `lib/packages/specs.ts` - Package spec parsing
129+
- `lib/packages/validation.ts` - Package validation utilities
130+
- Moved configuration files (vitest, eslint, knip, oxlint, taze) to `.config` directory
131+
- Replaced `fetch()` with Node.js native `http`/`https` modules for better reliability
132+
- Replaced `any` types with meaningful types across library utilities
133+
- Improved pnpm security with build script allowlist
134+
- Updated vitest coverage thresholds to 80%
135+
- Consolidated test files to reduce duplication
136+
- Note: Public API remains unchanged; these are internal organizational improvements
137+
138+
### Fixed
139+
140+
- Fixed resource leaks and race conditions in socket-registry
141+
- Fixed `yarn-cache-path` constant to return string type consistently
142+
- Fixed Yarn Windows temp path detection in `shouldSkipShadow`
143+
- Fixed path normalization for Windows compatibility across all path utilities
144+
- Fixed cache path tests for Windows case sensitivity
145+
- Fixed type errors in promises, parse-args, logger, and specs tests
146+
- Fixed GitHub tests to mock `httpRequest` correctly
147+
- Fixed SEA build tests to mock `httpRequest`
148+
- Decoded URL percent-encoding in `pathLikeToString` fallback
149+
150+
## [1.3.10] - 2025-10-03
151+
152+
### Added
153+
154+
- New utility modules for DLX, shadow, SEA, cacache, and versions functionality
155+
- getSocketHomePath alias to paths module
156+
- del dependency and external wrapper for safer file deletion
157+
- @fileoverview tags to lib modules
158+
- camelCase expansion for kebab-case arguments in parseArgs
159+
- Coerce and configuration options to parseArgs
160+
161+
### Changed
162+
163+
- Updated file removal to use del package for safer deletion
164+
- Normalized path returns in fs and Socket directory utilities
165+
- Removed default exports from git and parse-args modules
166+
- Enhanced test coverage across multiple modules (parse-args, prompts, strings, env, spawn, json)
167+
168+
## [1.3.9] - 2025-10-03
169+
170+
### Changed
171+
172+
- Internal build and distribution updates
173+
174+
## [1.3.8] - 2025-10-03
175+
176+
### Added
177+
178+
- Added unified directory structure for Socket ecosystem tools
179+
- New path utilities module for cross-platform directory resolution
180+
- Directory structure constants for Socket CLI, Registry, Firewall, and DLX
181+
182+
## [1.3.7] - 2025-10-02
183+
184+
### Changed
185+
186+
- Updated manifest.json entries
187+
188+
## [1.3.6] - 2025-10-01
189+
190+
### Fixed
191+
192+
- Fixed indent-string interoprability with older v1 and v2 versions
193+
194+
## [1.3.5] - 2025-10-01
195+
196+
### Added
197+
198+
- Added lib/git utilities module
199+
200+
### Fixed
201+
202+
- Fixed invalid manifest entries
203+
- Fixed parseArgs strip-aliased bug
204+
205+
## [1.3.4] - 2025-10-01
206+
207+
### Changed
208+
209+
- Updated various package override versions
210+
211+
## [1.3.3] - 2025-10-01
212+
213+
### Fixed
214+
215+
- Fixed normalizePath collapsing multiple leading `..` segments incorrectly
216+
217+
## [1.3.2] - 2025-10-01
218+
219+
### Added
220+
221+
- Added 'sfw' to isBlessedPackageName method check
222+
- Added ENV.DEBUG normalization for debug package compatibility
223+
- `DEBUG='1'` or `DEBUG='true'` automatically expands to `DEBUG='*'` (enables all namespaces)
224+
- `DEBUG='0'` or `DEBUG='false'` automatically converts to empty string (disables all output)
225+
- Namespace patterns like `DEBUG='app:*'` are preserved unchanged
226+
227+
## [1.3.1] - 2025-09-30
228+
229+
### Changed
230+
231+
- Renamed debug functions from *Complex to *Ns
232+
233+
### Fixed
234+
235+
- Fixed regression with lib/prompts module imports
236+
237+
## [1.3.0] - 2025-09-29
238+
239+
### Changed
240+
241+
- Updated registry subpath exports
242+
243+
### Fixed
244+
245+
- Fixed Node.js built-in module imports in CommonJS output
246+
247+
## [1.2.2] - 2025-09-29
248+
249+
### Changed
250+
251+
- Internal improvements to module structure
252+
253+
## [1.2.1] - 2025-09-29
254+
255+
### Changed
256+
257+
- Restructured constants module with new architecture
258+
- Updated build configuration and package exports

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Socket Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# @socketsecurity/lib
2+
3+
[![Socket Badge](https://socket.dev/api/badge/npm/package/@socketsecurity/lib)](https://socket.dev/npm/package/@socketsecurity/lib)
4+
[![CI - SocketDev/socket-lib](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/SocketDev/socket-lib/actions/workflows/ci.yml)
5+
6+
[![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
7+
[![Follow @socket.dev on Bluesky](https://img.shields.io/badge/Follow-@socket.dev-1DA1F2?style=social&logo=bluesky)](https://bsky.app/profile/socket.dev)
8+
9+
> Core utilities, constants, and helper functions for Socket.dev security tools.
10+
11+
## Installation
12+
13+
```bash
14+
pnpm install @socketsecurity/lib
15+
```
16+
17+
## Features
18+
19+
- **Constants** — Access Node.js, npm, and package manager constants
20+
- **Type Definitions** — Full TypeScript support with comprehensive type exports
21+
- **Helper Utilities** — File system, path, package, and process utilities
22+
- **Environment Variables** — Typed access to environment variables
23+
- **Effects** — Visual effects for CLI applications
24+
25+
## Usage
26+
27+
### Constants
28+
29+
Import Node.js and package manager constants:
30+
31+
```typescript
32+
import {
33+
NODE_MODULES,
34+
PACKAGE_JSON,
35+
PNPM_LOCK_YAML,
36+
NPM_REGISTRY_URL,
37+
} from '@socketsecurity/lib/constants/packages'
38+
```
39+
40+
### Environment Variables
41+
42+
Access typed environment variables:
43+
44+
```typescript
45+
import { getEnv } from '@socketsecurity/lib/env/getters'
46+
import { NODE_ENV } from '@socketsecurity/lib/env/node-env'
47+
48+
const env = getEnv('NODE_ENV')
49+
console.log(NODE_ENV) // 'production' | 'development' | 'test'
50+
```
51+
52+
For a complete list of available modules, see the [package.json exports](./package.json).
53+
54+
## Type Definitions
55+
56+
All types are exported for TypeScript projects:
57+
58+
```typescript
59+
import type {
60+
PackageJson,
61+
TsConfig,
62+
LockFile,
63+
} from '@socketsecurity/lib/types'
64+
```
65+
66+
## Utilities
67+
68+
Access utility modules for common operations:
69+
70+
```typescript
71+
// File system utilities
72+
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/lib/fs'
73+
74+
// Package utilities
75+
import { parsePackageSpec } from '@socketsecurity/lib/lib/packages'
76+
77+
// Path utilities
78+
import { normalizePath } from '@socketsecurity/lib/lib/paths'
79+
80+
// And many more...
81+
```
82+
83+
See the [exports map](./package.json) for all available utility modules.
84+
85+
## License
86+
87+
MIT

0 commit comments

Comments
 (0)