@idlebox/node 1.2.12 → 1.2.13

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.
Files changed (51) hide show
  1. package/lib/index.generated.cjs.map +1 -1
  2. package/lib/index.generated.js.map +1 -1
  3. package/{dist → lib}/node-alpha.d.ts +0 -0
  4. package/{dist → lib}/node-beta.d.ts +0 -0
  5. package/{dist → lib}/node-public.d.ts +0 -0
  6. package/{dist → lib}/node.d.ts +0 -0
  7. package/lib/preload.cjs +3 -0
  8. package/lib/preload.cjs.map +1 -0
  9. package/lib/preload.js +2 -0
  10. package/lib/preload.js.map +1 -0
  11. package/{dist → lib}/tsdoc-metadata.json +1 -1
  12. package/package.json +17 -17
  13. package/src/asyncLoad.ts +32 -0
  14. package/src/child_process/error.ts +63 -0
  15. package/src/child_process/execa.ts +108 -0
  16. package/src/child_process/lateError.ts +53 -0
  17. package/src/child_process/respawn.ts +132 -0
  18. package/src/cli-io/output.ts +3 -0
  19. package/src/crypto/md5.ts +8 -0
  20. package/src/crypto/sha256.ts +8 -0
  21. package/src/environment/findBinary.ts +13 -0
  22. package/src/environment/getEnvironment.ts +56 -0
  23. package/src/environment/npmConfig.ts +15 -0
  24. package/src/environment/pathEnvironment.ts +45 -0
  25. package/src/error/code.ts +124 -0
  26. package/src/error/pretty.ts +240 -0
  27. package/src/events/dumpEventEmitter.ts +9 -0
  28. package/src/fs/commandExists.ts +48 -0
  29. package/src/fs/exists.ts +17 -0
  30. package/src/fs/tempFolder.ts +54 -0
  31. package/src/fs/weiteChanged.ts +46 -0
  32. package/src/index.generated.ts +133 -0
  33. package/src/log/terminal.ts +41 -0
  34. package/src/path-resolve/findPackageRoot.ts +20 -0
  35. package/src/path-resolve/findUp.ts +34 -0
  36. package/src/path-resolve/getAllUp.ts +15 -0
  37. package/src/path-resolve/lrelative.ts +20 -0
  38. package/src/path-resolve/nodeResolvePathArray.ts +10 -0
  39. package/src/path-resolve/resolvePath.ts +43 -0
  40. package/src/preload.ts +1 -0
  41. package/src/stream/blackHoleStream.ts +7 -0
  42. package/src/stream/collectingStream.ts +85 -0
  43. package/src/stream/disposableStream.ts +24 -0
  44. package/src/stream/drainStream.ts +19 -0
  45. package/src/stream/loggerStream.ts +61 -0
  46. package/src/stream/streamPromise.ts +23 -0
  47. package/src/tsconfig.json +14 -0
  48. package/docs/node.api.json +0 -7222
  49. package/docs/node.api.md +0 -666
  50. package/docs/package-public.d.ts +0 -380
  51. package/docs/tsdoc-metadata.json +0 -11
@@ -1,380 +0,0 @@
1
- /// <reference types="node" />
2
-
3
- import { EventEmitter } from 'events';
4
- import { ExecaReturnValue } from 'execa';
5
- import { IDisposable } from '@idlebox/common';
6
- import { Options } from 'execa';
7
- import { PathArray } from '@idlebox/common';
8
- import { Readable } from 'stream';
9
- import { Transform } from 'stream';
10
- import { WrappedConsole } from '@idlebox/common';
11
- import { WrappedConsoleOptions } from '@idlebox/common';
12
- import { Writable } from 'stream';
13
-
14
- export declare interface Async {
15
- sync?: boolean;
16
- }
17
-
18
- export declare type AsyncMainFunction = () => Promise<void | number>;
19
-
20
- export declare class BlackHoleStream extends Writable {
21
- _write(_chunk: Buffer, _encoding: string, callback: (error?: Error | null) => void): void;
22
- }
23
-
24
- /** @throws */
25
- export declare function checkChildProcessResult(result: IChildProcessStatus): void;
26
-
27
- export declare function cleanupEnvironment(name: string, env?: NodeJS.ProcessEnv): void;
28
-
29
- export declare class CollectingStream extends Writable {
30
- private buffer?;
31
- private _promise?;
32
- constructor(sourceStream?: NodeJS.ReadableStream);
33
- _write(chunk: Buffer, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
34
- getOutput(): string;
35
- promise(): Promise<string>;
36
- }
37
-
38
- declare const colorMap: {
39
- info: string;
40
- success: string;
41
- debug: string;
42
- error: string;
43
- trace: string;
44
- warn: string;
45
- assert: string;
46
- };
47
-
48
- export declare function commandInPath(cmd: string, alterExt?: string[]): Promise<string | undefined>;
49
-
50
- export declare function commmandInPathSync(cmd: string, alterExt?: string[]): string | undefined;
51
-
52
- export declare function createTempFolder(path: string): void;
53
-
54
- export declare function deleteEnvironment(name: string, env?: NodeJS.ProcessEnv): void;
55
-
56
- export declare function disposableStream<T extends Writable | Readable>(stream: T): T & IDisposable;
57
-
58
- export declare function drainStream(stream: NodeJS.ReadableStream, size: number, start?: number, extra?: number): Promise<Buffer>;
59
-
60
- export declare function dumpEventEmitterEmit(ev: EventEmitter): void;
61
-
62
- export declare enum ERRNO_LINUX {
63
- EPERM = 1,
64
- ENOENT = 2,
65
- ESRCH = 3,
66
- EINTR = 4,
67
- EIO = 5,
68
- ENXIO = 6,
69
- E2BIG = 7,
70
- ENOEXEC = 8,
71
- EBADF = 9,
72
- ECHILD = 10,
73
- EAGAIN = 11,
74
- ENOMEM = 12,
75
- EACCES = 13,
76
- EFAULT = 14,
77
- ENOTBLK = 15,
78
- EBUSY = 16,
79
- EEXIST = 17,
80
- EXDEV = 18,
81
- ENODEV = 19,
82
- ENOTDIR = 20,
83
- EISDIR = 21,
84
- EINVAL = 22,
85
- ENFILE = 23,
86
- EMFILE = 24,
87
- ENOTTY = 25,
88
- ETXTBSY = 26,
89
- EFBIG = 27,
90
- ENOSPC = 28,
91
- ESPIPE = 29,
92
- EROFS = 30,
93
- EMLINK = 31,
94
- EPIPE = 32,
95
- EDOM = 33,
96
- ERANGE = 34,
97
- ENOMSG = 35,
98
- EIDRM = 36,
99
- ECHRNG = 37,
100
- EL2NSYNC = 38,
101
- EL3HLT = 39,
102
- EL3RST = 40,
103
- ELNRNG = 41,
104
- EUNATCH = 42,
105
- ENOCSI = 43,
106
- EL2HLT = 44,
107
- EDEADLK = 45,
108
- ENOLCK = 46,
109
- EBADE = 50,
110
- EBADR = 51,
111
- EXFULL = 52,
112
- ENOANO = 53,
113
- EBADRQC = 54,
114
- EBADSLT = 55,
115
- EDEADLOCK = 56,
116
- EBFONT = 57,
117
- ENOSTR = 60,
118
- ENODATA = 61,
119
- ETIME = 62,
120
- ENOSR = 63,
121
- ENONET = 64,
122
- ENOPKG = 65,
123
- EREMOTE = 66,
124
- ENOLINK = 67,
125
- EADV = 68,
126
- ESRMNT = 69,
127
- ECOMM = 70,
128
- EPROTO = 71,
129
- EMULTIHOP = 74,
130
- ELBIN = 75,
131
- EDOTDOT = 76,
132
- EBADMSG = 77,
133
- EFTYPE = 79,
134
- ENOTUNIQ = 80,
135
- EBADFD = 81,
136
- EREMCHG = 82,
137
- ELIBACC = 83,
138
- ELIBBAD = 84,
139
- ELIBSCN = 85,
140
- ELIBMAX = 86,
141
- ELIBEXEC = 87,
142
- ENOSYS = 88,
143
- ENMFILE = 89,
144
- ENOTEMPTY = 90,
145
- ENAMETOOLONG = 91,
146
- ELOOP = 92,
147
- EOPNOTSUPP = 95,
148
- EPFNOSUPPORT = 96,
149
- ECONNRESET = 104,
150
- ENOBUFS = 105,
151
- EAFNOSUPPORT = 106,
152
- EPROTOTYPE = 107,
153
- ENOTSOCK = 108,
154
- ENOPROTOOPT = 109,
155
- ESHUTDOWN = 110,
156
- ECONNREFUSED = 111,
157
- EADDRINUSE = 112,
158
- ECONNABORTED = 113,
159
- ENETUNREACH = 114,
160
- ENETDOWN = 115,
161
- ETIMEDOUT = 116,
162
- EHOSTDOWN = 117,
163
- EHOSTUNREACH = 118,
164
- EINPROGRESS = 119,
165
- EALREADY = 120,
166
- EDESTADDRREQ = 121,
167
- EMSGSIZE = 122,
168
- EPROTONOSUPPORT = 123,
169
- ESOCKTNOSUPPORT = 124,
170
- EADDRNOTAVAIL = 125,
171
- ENETRESET = 126,
172
- EISCONN = 127,
173
- ENOTCONN = 128,
174
- ETOOMANYREFS = 129,
175
- EPROCLIM = 130,
176
- EUSERS = 131,
177
- EDQUOT = 132,
178
- ESTALE = 133,
179
- ENOTSUP = 134,
180
- ENOMEDIUM = 135,
181
- ENOSHARE = 136,
182
- ECASECLASH = 137,
183
- EILSEQ = 138,
184
- EOVERFLOW = 139
185
- }
186
-
187
- export declare function execLazyError(cmd: string, args: string[], spawnOptions?: Omit<Options, 'reject' | 'stdio' | 'encoding' | 'all' | 'stderr'> & ISpawnAdditionOptions): Promise<ExecaReturnValue<string>>;
188
-
189
- export declare function exists(path: string): Promise<boolean>;
190
-
191
- export declare function existsSync(path: string): boolean;
192
-
193
- export declare class ExitError extends Error {
194
- readonly code: number;
195
- constructor(message: string, code?: number);
196
- }
197
-
198
- export declare function findBinary(what: string, pathvar?: PathArray, cwd?: string): string;
199
-
200
- export declare function findPackageRoot(packageName: string, require?: NodeRequire): string;
201
-
202
- export declare function findUpUntil(from: string, file: string): Promise<string | null>;
203
-
204
- export declare function findUpUntilSync(from: string, file: string): string | null;
205
-
206
- export declare function getAllPathUpToRoot(from: string, append?: string): string[];
207
-
208
- export declare function getEnvironment(name: string, env?: NodeJS.ProcessEnv): IEnvironmentResult;
209
-
210
- export declare class HexDumpLoggerStream extends Transform {
211
- private readonly logFn;
212
- private readonly prefix;
213
- constructor(logFn: LogFunction, prefix?: string);
214
- _transform(chunk: Buffer, encoding: BufferEncoding, callback: Function): void;
215
- }
216
-
217
- declare interface IChildProcessStatus {
218
- signal?: NodeJS.Signals | string | null;
219
- status?: number | null;
220
- error?: Error;
221
- signalCode?: NodeJS.Signals | string | null;
222
- exitCode?: number | null;
223
- signalDescription?: string;
224
- command?: string;
225
- killed?: boolean;
226
- failed?: boolean;
227
- timedOut?: boolean;
228
- }
229
-
230
- export declare interface ICommand {
231
- exec: string[];
232
- cwd?: string;
233
- sync?: boolean;
234
- }
235
-
236
- export declare interface IEnvironmentResult {
237
- value: string | undefined;
238
- name: string;
239
- }
240
-
241
- export declare interface ISpawnAdditionOptions {
242
- verbose?: boolean;
243
- }
244
-
245
- export declare interface JoinPathFunction {
246
- (from: string, to: string): string;
247
- }
248
-
249
- export declare type LogFunction = (message: string, ...args: any[]) => void;
250
-
251
- export declare class LoggerStream extends Transform {
252
- private readonly logFn;
253
- private readonly prefix;
254
- constructor(logFn: LogFunction, prefix?: string);
255
- _transform(chunk: Buffer, encoding: BufferEncoding, callback: Function): void;
256
- }
257
-
258
- export declare function lrelative(from: string, to: string): string;
259
-
260
- export declare function md5(data: Buffer): string;
261
-
262
- export declare function nodeResolvePathArray(from: string, file?: string): string[];
263
-
264
- export declare const normalizePath: NormalizePathFunction;
265
-
266
- export declare interface NormalizePathFunction {
267
- (path: string): string;
268
- }
269
-
270
- export declare function osTempDir(name?: string): string;
271
-
272
- export declare const PATH_SEPARATOR: string;
273
-
274
- export declare class PathEnvironment extends PathArray {
275
- private readonly name;
276
- private readonly env;
277
- constructor(varName?: string, env?: NodeJS.ProcessEnv);
278
- add(p: string): this;
279
- clear(): void;
280
- delete(p: string): boolean;
281
- save(): void;
282
- }
283
-
284
- export declare function prettyFormatError(e: Error): string;
285
-
286
- export declare function prettyPrintError(type: string, e: Error): void;
287
-
288
- export declare function printLine(char?: string): void;
289
-
290
- export declare class RawCollectingStream extends Writable {
291
- private buffer?;
292
- private _promise?;
293
- constructor(sourceStream?: NodeJS.ReadableStream);
294
- _write(chunk: Buffer, _encoding: string, callback: (error?: Error | null) => void): void;
295
- getOutput(): Buffer;
296
- promise(): Promise<Buffer>;
297
- }
298
-
299
- export declare const relativePath: JoinPathFunction;
300
-
301
- export declare const resolvePath: ResolvePathFunction;
302
-
303
- export declare interface ResolvePathFunction {
304
- (...pathSegments: string[]): string;
305
- }
306
-
307
- /**
308
- * Self restart in a pid/cgroup namespace on linux.
309
- * Your application must inside mainFunc, not before or after it.
310
- *
311
- * ```typescript
312
- * import {respawnInScope} from '@idlebox/node'
313
- * respawnInScope(() => {
314
- * import('./real-application');
315
- * });
316
- * ```
317
- */
318
- export declare function respawnInScope(mainFunc: Function): unknown | never;
319
-
320
- /**
321
- * should do this before:
322
- * ```
323
- * setErrorLogRoot(require('path').dirname(__dirname));
324
- * ```
325
- **/
326
- export declare function runMain(main: AsyncMainFunction): void;
327
-
328
- export declare function setErrorLogRoot(_root: string): void;
329
-
330
- export declare function sha256(data: Buffer): string;
331
-
332
- export declare function spawnGetEverything({ exec, cwd }: ICommand): Promise<string | undefined>;
333
-
334
- export declare function spawnGetOutput(opt: ICommand & Sync): string;
335
-
336
- export declare function spawnGetOutput(opt: ICommand & Async): Promise<string>;
337
-
338
- export declare function spawnRecreateEventHandlers(): void;
339
-
340
- export declare function spawnWithoutOutput(opt: ICommand & Sync): void;
341
-
342
- export declare function spawnWithoutOutput(opt: ICommand & Async): Promise<void>;
343
-
344
- export declare function streamHasEnd(S: NodeJS.ReadableStream | NodeJS.WritableStream): any;
345
-
346
- /**
347
- * wait read/write stream end/close, as promise
348
- * reject when stream emit error
349
- */
350
- export declare function streamPromise(stream: NodeJS.ReadableStream | NodeJS.WritableStream): Promise<void>;
351
-
352
- export declare function streamToBuffer(stream: NodeJS.ReadableStream, raw: false): Promise<string>;
353
-
354
- export declare function streamToBuffer(stream: NodeJS.ReadableStream, raw: true): Promise<Buffer>;
355
-
356
- export declare interface Sync {
357
- sync: true;
358
- }
359
-
360
- declare interface TerminalConsoleOptions {
361
- color?: boolean | Partial<typeof colorMap>;
362
- }
363
-
364
- /**
365
- * Spawn a command, replace current node process
366
- * If can't do that (eg. on Windows), spawn as normal, but quit self after it quit.
367
- */
368
- export declare function trySpawnInScope(cmds: string[]): never;
369
-
370
- export declare class WrappedTerminalConsole extends WrappedConsole {
371
- private readonly colors;
372
- constructor(title: string, { color, ...opt }?: WrappedConsoleOptions & TerminalConsoleOptions);
373
- protected processColorLabel(msg: any[], pos: number, level: string, prefix: string): void;
374
- }
375
-
376
- export declare function writeFileIfChange(file: string, data: string | Buffer): Promise<boolean>;
377
-
378
- export declare function writeFileIfChangeSync(file: string, data: string | Buffer): boolean;
379
-
380
- export { }
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.25.2"
9
- }
10
- ]
11
- }