@joe-sh/pj 1.4.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/LICENSE +21 -0
- package/README.md +277 -0
- package/bin/pj +42 -0
- package/dist/index.cjs +1188 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +565 -0
- package/dist/index.d.ts +565 -0
- package/dist/index.js +1124 -0
- package/dist/index.js.map +1 -0
- package/package.json +77 -0
- package/scripts/postinstall.js +62 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { Options } from 'execa';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A discovered project from pj
|
|
5
|
+
*/
|
|
6
|
+
interface Project {
|
|
7
|
+
/** Absolute path to the project directory */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Name of the project (directory name) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The marker file/directory that identified this as a project */
|
|
12
|
+
marker: string;
|
|
13
|
+
/** Optional icon for the marker (Nerd Font) */
|
|
14
|
+
icon: string | undefined;
|
|
15
|
+
/** Priority of the marker (higher = more specific) */
|
|
16
|
+
priority: number | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for project discovery
|
|
20
|
+
*/
|
|
21
|
+
interface DiscoverOptions {
|
|
22
|
+
/** Paths to search for projects */
|
|
23
|
+
paths?: string[];
|
|
24
|
+
/** Project marker files/directories to look for */
|
|
25
|
+
markers?: string[];
|
|
26
|
+
/** Patterns to exclude from search */
|
|
27
|
+
excludes?: string[];
|
|
28
|
+
/** Maximum directory depth to search */
|
|
29
|
+
maxDepth?: number;
|
|
30
|
+
/** Don't respect .gitignore files */
|
|
31
|
+
noIgnore?: boolean;
|
|
32
|
+
/** Allow nested project detection */
|
|
33
|
+
nested?: boolean;
|
|
34
|
+
/** Bypass cache and do fresh discovery */
|
|
35
|
+
noCache?: boolean;
|
|
36
|
+
/** Include icons in output */
|
|
37
|
+
icons?: boolean;
|
|
38
|
+
/** Custom config file path */
|
|
39
|
+
configPath?: string;
|
|
40
|
+
/** Enable verbose/debug output */
|
|
41
|
+
verbose?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration for pj
|
|
45
|
+
*/
|
|
46
|
+
interface PjConfig {
|
|
47
|
+
/** Paths to search for projects */
|
|
48
|
+
paths: string[];
|
|
49
|
+
/** Project marker files/directories */
|
|
50
|
+
markers: string[];
|
|
51
|
+
/** Patterns to exclude */
|
|
52
|
+
exclude: string[];
|
|
53
|
+
/** Maximum search depth */
|
|
54
|
+
maxDepth: number;
|
|
55
|
+
/** Cache time-to-live in seconds */
|
|
56
|
+
cacheTTL: number;
|
|
57
|
+
/** Don't respect .gitignore */
|
|
58
|
+
noIgnore: boolean;
|
|
59
|
+
/** Allow nested projects */
|
|
60
|
+
noNested: boolean;
|
|
61
|
+
/** Icon mappings for markers */
|
|
62
|
+
icons: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Information about the pj cache
|
|
66
|
+
*/
|
|
67
|
+
interface CacheInfo {
|
|
68
|
+
/** Whether the cache exists */
|
|
69
|
+
exists: boolean;
|
|
70
|
+
/** Path to the cache directory */
|
|
71
|
+
path: string;
|
|
72
|
+
/** Number of cache files */
|
|
73
|
+
fileCount: number;
|
|
74
|
+
/** Total size in bytes */
|
|
75
|
+
totalSize: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Binary installation status
|
|
79
|
+
*/
|
|
80
|
+
interface BinaryStatus {
|
|
81
|
+
/** Whether a binary is available */
|
|
82
|
+
available: boolean;
|
|
83
|
+
/** Path to the binary */
|
|
84
|
+
path: string | null;
|
|
85
|
+
/** Version of the binary */
|
|
86
|
+
version: string | null;
|
|
87
|
+
/** Source of the binary: 'global', 'cache', or 'env' */
|
|
88
|
+
source: "global" | "cache" | "env" | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Options for binary management
|
|
92
|
+
*/
|
|
93
|
+
interface BinaryOptions {
|
|
94
|
+
/** Force download even if binary exists */
|
|
95
|
+
force?: boolean;
|
|
96
|
+
/** Specific version to install (defaults to latest) */
|
|
97
|
+
version?: string;
|
|
98
|
+
/** Progress callback for downloads */
|
|
99
|
+
onProgress?: (progress: DownloadProgress) => void;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Download progress information
|
|
103
|
+
*/
|
|
104
|
+
interface DownloadProgress {
|
|
105
|
+
/** Bytes downloaded so far */
|
|
106
|
+
downloaded: number;
|
|
107
|
+
/** Total bytes to download (may be undefined if unknown) */
|
|
108
|
+
total?: number;
|
|
109
|
+
/** Percentage complete (0-100) */
|
|
110
|
+
percent?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* GitHub release information
|
|
114
|
+
*/
|
|
115
|
+
interface GithubRelease {
|
|
116
|
+
/** Release tag name (e.g., "v1.4.1") */
|
|
117
|
+
tagName: string;
|
|
118
|
+
/** Release version without 'v' prefix */
|
|
119
|
+
version: string;
|
|
120
|
+
/** Release name/title */
|
|
121
|
+
name: string;
|
|
122
|
+
/** Whether this is a prerelease */
|
|
123
|
+
prerelease: boolean;
|
|
124
|
+
/** Release assets */
|
|
125
|
+
assets: GithubAsset[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* GitHub release asset
|
|
129
|
+
*/
|
|
130
|
+
interface GithubAsset {
|
|
131
|
+
/** Asset name (e.g., "pj_1.4.1_darwin_arm64.tar.gz") */
|
|
132
|
+
name: string;
|
|
133
|
+
/** Download URL */
|
|
134
|
+
downloadUrl: string;
|
|
135
|
+
/** File size in bytes */
|
|
136
|
+
size: number;
|
|
137
|
+
/** Content type */
|
|
138
|
+
contentType: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Platform information
|
|
142
|
+
*/
|
|
143
|
+
interface Platform {
|
|
144
|
+
/** Operating system: darwin, linux, win32 */
|
|
145
|
+
os: "darwin" | "linux" | "win32";
|
|
146
|
+
/** Architecture: x64, arm64 */
|
|
147
|
+
arch: "x64" | "arm64";
|
|
148
|
+
/** pj asset OS name */
|
|
149
|
+
pjOs: "darwin" | "linux" | "windows";
|
|
150
|
+
/** pj asset architecture name */
|
|
151
|
+
pjArch: "amd64" | "arm64";
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown when binary operations fail
|
|
155
|
+
*/
|
|
156
|
+
declare class PjBinaryError extends Error {
|
|
157
|
+
readonly cause?: Error | undefined;
|
|
158
|
+
constructor(message: string, cause?: Error | undefined);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Error thrown when pj execution fails
|
|
162
|
+
*/
|
|
163
|
+
declare class PjExecutionError extends Error {
|
|
164
|
+
readonly exitCode: number | undefined;
|
|
165
|
+
readonly stderr: string | undefined;
|
|
166
|
+
constructor(message: string, exitCode?: number, stderr?: string);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Error thrown when configuration is invalid
|
|
170
|
+
*/
|
|
171
|
+
declare class PjConfigError extends Error {
|
|
172
|
+
readonly cause?: Error | undefined;
|
|
173
|
+
constructor(message: string, cause?: Error | undefined);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Main class for interacting with pj
|
|
178
|
+
*
|
|
179
|
+
* Provides a high-level API for project discovery, configuration management,
|
|
180
|
+
* and binary management.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const pj = new Pj();
|
|
185
|
+
*
|
|
186
|
+
* // Discover all projects
|
|
187
|
+
* const projects = await pj.discover();
|
|
188
|
+
*
|
|
189
|
+
* // Find a specific project
|
|
190
|
+
* const myProject = await pj.findProject('my-app');
|
|
191
|
+
*
|
|
192
|
+
* // Search for projects
|
|
193
|
+
* const reactProjects = await pj.findProjects(/react/i);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare class Pj {
|
|
197
|
+
private config;
|
|
198
|
+
/**
|
|
199
|
+
* Create a new Pj instance
|
|
200
|
+
*
|
|
201
|
+
* @param config - Optional configuration overrides
|
|
202
|
+
*/
|
|
203
|
+
constructor(config?: Partial<PjConfig>);
|
|
204
|
+
/**
|
|
205
|
+
* Discover all projects
|
|
206
|
+
*
|
|
207
|
+
* @param options - Discovery options
|
|
208
|
+
* @returns Array of discovered projects
|
|
209
|
+
*/
|
|
210
|
+
discover(options?: DiscoverOptions): Promise<Project[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Discover projects from specific paths
|
|
213
|
+
*
|
|
214
|
+
* Bypasses configured paths and searches only the provided paths.
|
|
215
|
+
* Useful for integration with other tools.
|
|
216
|
+
*
|
|
217
|
+
* @param paths - Paths to search
|
|
218
|
+
* @param options - Additional discovery options
|
|
219
|
+
*/
|
|
220
|
+
discoverFromPaths(paths: string[], options?: Omit<DiscoverOptions, "paths">): Promise<Project[]>;
|
|
221
|
+
/**
|
|
222
|
+
* Find a project by name
|
|
223
|
+
*
|
|
224
|
+
* @param name - Project name to find
|
|
225
|
+
* @param options - Discovery options
|
|
226
|
+
*/
|
|
227
|
+
findProject(name: string, options?: DiscoverOptions): Promise<Project | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Find projects matching a pattern
|
|
230
|
+
*
|
|
231
|
+
* @param pattern - String or regex pattern to match
|
|
232
|
+
* @param options - Discovery options
|
|
233
|
+
*/
|
|
234
|
+
findProjects(pattern: string | RegExp, options?: DiscoverOptions): Promise<Project[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Get projects grouped by marker type
|
|
237
|
+
*
|
|
238
|
+
* @param options - Discovery options
|
|
239
|
+
*/
|
|
240
|
+
discoverByMarker(options?: DiscoverOptions): Promise<Map<string, Project[]>>;
|
|
241
|
+
/**
|
|
242
|
+
* Count projects by marker type
|
|
243
|
+
*
|
|
244
|
+
* @param options - Discovery options
|
|
245
|
+
*/
|
|
246
|
+
countByMarker(options?: DiscoverOptions): Promise<Map<string, number>>;
|
|
247
|
+
/**
|
|
248
|
+
* Clear the pj project cache
|
|
249
|
+
*/
|
|
250
|
+
clearCache(): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Get information about the pj cache
|
|
253
|
+
*/
|
|
254
|
+
getCacheInfo(): Promise<CacheInfo>;
|
|
255
|
+
/**
|
|
256
|
+
* Load configuration from file
|
|
257
|
+
*
|
|
258
|
+
* @param configPath - Optional path to config file
|
|
259
|
+
*/
|
|
260
|
+
loadConfig(configPath?: string): Promise<PjConfig>;
|
|
261
|
+
/**
|
|
262
|
+
* Save configuration to file
|
|
263
|
+
*
|
|
264
|
+
* @param config - Configuration to save (uses current config if not provided)
|
|
265
|
+
* @param configPath - Optional path to config file
|
|
266
|
+
*/
|
|
267
|
+
saveConfig(config?: Partial<PjConfig>, configPath?: string): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Get current configuration
|
|
270
|
+
*/
|
|
271
|
+
getConfig(): PjConfig;
|
|
272
|
+
/**
|
|
273
|
+
* Update configuration
|
|
274
|
+
*
|
|
275
|
+
* @param config - Partial configuration to merge
|
|
276
|
+
*/
|
|
277
|
+
setConfig(config: Partial<PjConfig>): void;
|
|
278
|
+
/**
|
|
279
|
+
* Ensure the pj binary is available
|
|
280
|
+
*
|
|
281
|
+
* Downloads the binary if not already installed.
|
|
282
|
+
*
|
|
283
|
+
* @param options - Binary options
|
|
284
|
+
* @returns Path to the binary
|
|
285
|
+
*/
|
|
286
|
+
ensureBinary(options?: BinaryOptions): Promise<string>;
|
|
287
|
+
/**
|
|
288
|
+
* Get the status of the pj binary
|
|
289
|
+
*/
|
|
290
|
+
getBinaryStatus(): Promise<BinaryStatus>;
|
|
291
|
+
/**
|
|
292
|
+
* Update the pj binary to the latest version
|
|
293
|
+
*
|
|
294
|
+
* @param options - Binary options
|
|
295
|
+
* @returns Path to the updated binary
|
|
296
|
+
*/
|
|
297
|
+
updateBinary(options?: BinaryOptions): Promise<string>;
|
|
298
|
+
/**
|
|
299
|
+
* Get the version of the pj binary
|
|
300
|
+
*/
|
|
301
|
+
getBinaryVersion(): Promise<string | null>;
|
|
302
|
+
/**
|
|
303
|
+
* Merge instance config with provided options
|
|
304
|
+
*/
|
|
305
|
+
private mergeOptions;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Discover projects using pj
|
|
310
|
+
*/
|
|
311
|
+
declare function discover(options?: DiscoverOptions): Promise<Project[]>;
|
|
312
|
+
/**
|
|
313
|
+
* Discover projects from specific paths provided via stdin
|
|
314
|
+
*
|
|
315
|
+
* This bypasses the configured paths and discovers projects only in the
|
|
316
|
+
* provided paths. Useful for integrating with other tools that provide
|
|
317
|
+
* a list of directories to search.
|
|
318
|
+
*/
|
|
319
|
+
declare function discoverFromPaths(paths: string[], options?: Omit<DiscoverOptions, "paths">): Promise<Project[]>;
|
|
320
|
+
/**
|
|
321
|
+
* Find a project by name
|
|
322
|
+
*/
|
|
323
|
+
declare function findProject(name: string, options?: DiscoverOptions): Promise<Project | undefined>;
|
|
324
|
+
/**
|
|
325
|
+
* Find projects matching a pattern
|
|
326
|
+
*/
|
|
327
|
+
declare function findProjects(pattern: string | RegExp, options?: DiscoverOptions): Promise<Project[]>;
|
|
328
|
+
/**
|
|
329
|
+
* Get projects grouped by marker type
|
|
330
|
+
*/
|
|
331
|
+
declare function discoverByMarker(options?: DiscoverOptions): Promise<Map<string, Project[]>>;
|
|
332
|
+
/**
|
|
333
|
+
* Count projects by marker type
|
|
334
|
+
*/
|
|
335
|
+
declare function countByMarker(options?: DiscoverOptions): Promise<Map<string, number>>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Default configuration values
|
|
339
|
+
*/
|
|
340
|
+
declare const DEFAULT_CONFIG: PjConfig;
|
|
341
|
+
/**
|
|
342
|
+
* Load pj configuration from file
|
|
343
|
+
*/
|
|
344
|
+
declare function loadConfig(configPath?: string): Promise<PjConfig>;
|
|
345
|
+
/**
|
|
346
|
+
* Save configuration to file
|
|
347
|
+
*/
|
|
348
|
+
declare function saveConfig(config: Partial<PjConfig>, configPath?: string): Promise<void>;
|
|
349
|
+
/**
|
|
350
|
+
* Check if a config file exists
|
|
351
|
+
*/
|
|
352
|
+
declare function configExists(configPath?: string): Promise<boolean>;
|
|
353
|
+
/**
|
|
354
|
+
* Get the default config path
|
|
355
|
+
*/
|
|
356
|
+
declare function getConfigPath(): string;
|
|
357
|
+
/**
|
|
358
|
+
* Expand ~ in paths to home directory
|
|
359
|
+
*/
|
|
360
|
+
declare function expandPath(p: string): string;
|
|
361
|
+
/**
|
|
362
|
+
* Expand all paths in config
|
|
363
|
+
*/
|
|
364
|
+
declare function expandConfigPaths(config: PjConfig): PjConfig;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Clear the pj project cache
|
|
368
|
+
*/
|
|
369
|
+
declare function clearCache(): Promise<void>;
|
|
370
|
+
/**
|
|
371
|
+
* Get information about the pj cache
|
|
372
|
+
*/
|
|
373
|
+
declare function getCacheInfo(): Promise<CacheInfo>;
|
|
374
|
+
/**
|
|
375
|
+
* Get the cache directory path
|
|
376
|
+
*/
|
|
377
|
+
declare function getCachePath(): string;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Manages the pj binary installation and updates
|
|
381
|
+
*
|
|
382
|
+
* Note: This module uses `execa` for process execution which does NOT use shell
|
|
383
|
+
* by default, preventing command injection vulnerabilities.
|
|
384
|
+
*/
|
|
385
|
+
declare class BinaryManager {
|
|
386
|
+
private cachedBinaryPath;
|
|
387
|
+
/**
|
|
388
|
+
* Get the path to the pj binary, downloading if necessary
|
|
389
|
+
*/
|
|
390
|
+
getBinaryPath(options?: BinaryOptions): Promise<string>;
|
|
391
|
+
/**
|
|
392
|
+
* Get the current binary status
|
|
393
|
+
*/
|
|
394
|
+
getStatus(): Promise<BinaryStatus>;
|
|
395
|
+
/**
|
|
396
|
+
* Download and install the pj binary.
|
|
397
|
+
* If no specific version is requested, downloads the highest compatible version
|
|
398
|
+
* within the target major.minor range.
|
|
399
|
+
*/
|
|
400
|
+
downloadBinary(options?: BinaryOptions): Promise<string>;
|
|
401
|
+
/**
|
|
402
|
+
* Update the binary to the highest compatible version within the target range.
|
|
403
|
+
*/
|
|
404
|
+
updateBinary(options?: BinaryOptions): Promise<string>;
|
|
405
|
+
/**
|
|
406
|
+
* Get the version of a pj binary
|
|
407
|
+
*/
|
|
408
|
+
getVersion(binaryPath: string): Promise<string | null>;
|
|
409
|
+
/**
|
|
410
|
+
* Check if a binary path is a valid pj binary
|
|
411
|
+
*/
|
|
412
|
+
isValidBinary(binaryPath: string): Promise<boolean>;
|
|
413
|
+
/**
|
|
414
|
+
* Find the globally installed pj binary.
|
|
415
|
+
* Only returns the binary if it's version-compatible with our target.
|
|
416
|
+
*/
|
|
417
|
+
private findGlobalBinary;
|
|
418
|
+
/**
|
|
419
|
+
* Get the path to the cached binary if it exists and is version-compatible.
|
|
420
|
+
*/
|
|
421
|
+
private getCachedBinaryPath;
|
|
422
|
+
/**
|
|
423
|
+
* Check if we should check for updates
|
|
424
|
+
*/
|
|
425
|
+
private shouldCheckForUpdate;
|
|
426
|
+
/**
|
|
427
|
+
* Get cached metadata
|
|
428
|
+
*/
|
|
429
|
+
private getMetadata;
|
|
430
|
+
/**
|
|
431
|
+
* Save metadata to cache
|
|
432
|
+
*/
|
|
433
|
+
private saveMetadata;
|
|
434
|
+
/**
|
|
435
|
+
* Get all releases from GitHub (up to 100 most recent)
|
|
436
|
+
*/
|
|
437
|
+
getAllReleases(): Promise<GithubRelease[]>;
|
|
438
|
+
/**
|
|
439
|
+
* Get the highest compatible release within the target major.minor range.
|
|
440
|
+
*/
|
|
441
|
+
getCompatibleRelease(): Promise<GithubRelease>;
|
|
442
|
+
/**
|
|
443
|
+
* Get the latest release from GitHub
|
|
444
|
+
*/
|
|
445
|
+
getLatestRelease(): Promise<GithubRelease>;
|
|
446
|
+
/**
|
|
447
|
+
* Get a specific release from GitHub
|
|
448
|
+
*/
|
|
449
|
+
private getRelease;
|
|
450
|
+
/**
|
|
451
|
+
* Parse GitHub release response
|
|
452
|
+
*/
|
|
453
|
+
private parseRelease;
|
|
454
|
+
/**
|
|
455
|
+
* Download an asset to a file
|
|
456
|
+
*/
|
|
457
|
+
private downloadAsset;
|
|
458
|
+
/**
|
|
459
|
+
* Clear the binary cache
|
|
460
|
+
*/
|
|
461
|
+
clearCache(): Promise<void>;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Get the singleton BinaryManager instance
|
|
465
|
+
*/
|
|
466
|
+
declare function getBinaryManager(): BinaryManager;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Detect the current platform and return normalized platform info
|
|
470
|
+
*/
|
|
471
|
+
declare function detectPlatform(): Platform;
|
|
472
|
+
/**
|
|
473
|
+
* Get the expected asset filename for the current platform
|
|
474
|
+
*/
|
|
475
|
+
declare function getAssetFilename(version: string, platform?: Platform): string;
|
|
476
|
+
/**
|
|
477
|
+
* Check if the current platform is supported
|
|
478
|
+
*/
|
|
479
|
+
declare function isPlatformSupported(): boolean;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Target pj version (major.minor) that this package is compatible with.
|
|
483
|
+
* The installer will accept any patch version within this range.
|
|
484
|
+
* Example: "1.4" means pj 1.4.0, 1.4.1, 1.4.2, etc. are all compatible.
|
|
485
|
+
*
|
|
486
|
+
* IMPORTANT: When pj releases a new minor version (e.g., 1.5.0),
|
|
487
|
+
* this package must also release a new minor version to match.
|
|
488
|
+
*/
|
|
489
|
+
declare const PJ_TARGET_VERSION = "1.4";
|
|
490
|
+
/** GitHub repository owner */
|
|
491
|
+
declare const GITHUB_OWNER = "josephschmitt";
|
|
492
|
+
/** GitHub repository name */
|
|
493
|
+
declare const GITHUB_REPO = "pj";
|
|
494
|
+
/** Get the appropriate binary name for the current platform */
|
|
495
|
+
declare function getBinaryName(): string;
|
|
496
|
+
/** Cache directory for pj-node */
|
|
497
|
+
declare function getCacheDir(): string;
|
|
498
|
+
/** Binary cache directory */
|
|
499
|
+
declare function getBinaryCacheDir(): string;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Parsed semantic version
|
|
503
|
+
*/
|
|
504
|
+
interface ParsedVersion {
|
|
505
|
+
major: number;
|
|
506
|
+
minor: number;
|
|
507
|
+
patch: number;
|
|
508
|
+
raw: string;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Parse a semantic version string
|
|
512
|
+
*/
|
|
513
|
+
declare function parseVersion(version: string): ParsedVersion | null;
|
|
514
|
+
/**
|
|
515
|
+
* Parse a major.minor version target (e.g., "1.4")
|
|
516
|
+
*/
|
|
517
|
+
declare function parseTargetVersion(target: string): {
|
|
518
|
+
major: number;
|
|
519
|
+
minor: number;
|
|
520
|
+
} | null;
|
|
521
|
+
/**
|
|
522
|
+
* Check if a version is compatible with the target major.minor version.
|
|
523
|
+
* A version is compatible if it has the same major.minor version.
|
|
524
|
+
*
|
|
525
|
+
* Example: target "1.4" is compatible with "1.4.0", "1.4.1", "1.4.99"
|
|
526
|
+
* but NOT with "1.3.0", "1.5.0", or "2.4.0"
|
|
527
|
+
*/
|
|
528
|
+
declare function isVersionCompatible(version: string, target?: string): boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Compare two versions. Returns:
|
|
531
|
+
* - negative if a < b
|
|
532
|
+
* - positive if a > b
|
|
533
|
+
* - 0 if a === b
|
|
534
|
+
*/
|
|
535
|
+
declare function compareVersions(a: string, b: string): number;
|
|
536
|
+
/**
|
|
537
|
+
* Find the highest compatible version from a list of versions
|
|
538
|
+
*/
|
|
539
|
+
declare function findHighestCompatibleVersion(versions: string[], target?: string): string | null;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Result from executing pj
|
|
543
|
+
*/
|
|
544
|
+
interface PjResult {
|
|
545
|
+
stdout: string;
|
|
546
|
+
stderr: string;
|
|
547
|
+
exitCode: number;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Build command-line arguments from DiscoverOptions
|
|
551
|
+
*/
|
|
552
|
+
declare function buildArgs(options?: DiscoverOptions): string[];
|
|
553
|
+
/**
|
|
554
|
+
* Parse JSON output from pj
|
|
555
|
+
*/
|
|
556
|
+
declare function parseJsonOutput(output: string): Project[];
|
|
557
|
+
/**
|
|
558
|
+
* Execute the pj binary with the given arguments
|
|
559
|
+
*
|
|
560
|
+
* Note: This function uses `execa` which does NOT use shell by default,
|
|
561
|
+
* preventing command injection vulnerabilities.
|
|
562
|
+
*/
|
|
563
|
+
declare function executePj(args: string[], execaOptions?: Options): Promise<PjResult>;
|
|
564
|
+
|
|
565
|
+
export { BinaryManager, type BinaryOptions, type BinaryStatus, type CacheInfo, DEFAULT_CONFIG, type DiscoverOptions, type DownloadProgress, GITHUB_OWNER, GITHUB_REPO, type GithubAsset, type GithubRelease, PJ_TARGET_VERSION, type ParsedVersion, Pj, PjBinaryError, type PjConfig, PjConfigError, PjExecutionError, type PjResult, type Platform, type Project, buildArgs, clearCache, compareVersions, configExists, countByMarker, detectPlatform, discover, discoverByMarker, discoverFromPaths, executePj, expandConfigPaths, expandPath, findHighestCompatibleVersion, findProject, findProjects, getAssetFilename, getBinaryCacheDir, getBinaryManager, getBinaryName, getCacheDir, getCacheInfo, getCachePath, getConfigPath, isPlatformSupported, isVersionCompatible, loadConfig, parseJsonOutput, parseTargetVersion, parseVersion, saveConfig };
|