@idlebox/node 1.4.12 → 1.4.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 (45) hide show
  1. package/lib/asyncLoad.d.ts +1 -0
  2. package/lib/asyncLoad.d.ts.map +1 -1
  3. package/lib/asyncLoad.js +3 -2
  4. package/lib/asyncLoad.js.map +1 -1
  5. package/lib/autoindex.d.ts +2 -14
  6. package/lib/autoindex.d.ts.map +1 -1
  7. package/lib/autoindex.js +4 -18
  8. package/lib/autoindex.js.map +1 -1
  9. package/lib/child_process/respawn.d.ts +2 -0
  10. package/lib/child_process/respawn.d.ts.map +1 -1
  11. package/lib/child_process/respawn.js +2 -0
  12. package/lib/child_process/respawn.js.map +1 -1
  13. package/lib/fs/exists.js +1 -1
  14. package/lib/fs/exists.js.map +1 -1
  15. package/lib/lifecycle/register.d.ts +6 -2
  16. package/lib/lifecycle/register.d.ts.map +1 -1
  17. package/lib/lifecycle/register.js +94 -56
  18. package/lib/lifecycle/register.js.map +1 -1
  19. package/lib/lifecycle/workingDirectory.d.ts +11 -0
  20. package/lib/lifecycle/workingDirectory.d.ts.map +1 -0
  21. package/lib/lifecycle/workingDirectory.js +40 -0
  22. package/lib/lifecycle/workingDirectory.js.map +1 -0
  23. package/lib/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +5 -6
  25. package/src/asyncLoad.ts +3 -2
  26. package/src/autoindex.ts +4 -21
  27. package/src/child_process/respawn.ts +2 -0
  28. package/src/fs/exists.ts +1 -1
  29. package/src/lifecycle/register.ts +91 -58
  30. package/src/lifecycle/workingDirectory.ts +45 -0
  31. package/lib/error/linux.d.ts +0 -125
  32. package/lib/error/linux.d.ts.map +0 -1
  33. package/lib/error/linux.js +0 -126
  34. package/lib/error/linux.js.map +0 -1
  35. package/lib/error/types.d.ts +0 -24
  36. package/lib/error/types.d.ts.map +0 -1
  37. package/lib/error/types.js +0 -25
  38. package/lib/error/types.js.map +0 -1
  39. package/lib/lifecycle/internal-errors.d.ts +0 -23
  40. package/lib/lifecycle/internal-errors.d.ts.map +0 -1
  41. package/lib/lifecycle/internal-errors.js +0 -60
  42. package/lib/lifecycle/internal-errors.js.map +0 -1
  43. package/src/error/linux.ts +0 -124
  44. package/src/error/types.ts +0 -39
  45. package/src/lifecycle/internal-errors.ts +0 -66
@@ -1,60 +0,0 @@
1
- import { AppExit } from '@idlebox/common';
2
- export class Exit extends AppExit {
3
- constructor(code) {
4
- super(`process exit with code ${code}`, code);
5
- }
6
- }
7
- export class InterruptError extends Error {
8
- signal;
9
- constructor(signal) {
10
- super(`interrupt by signal ${signal}`);
11
- this.signal = signal;
12
- }
13
- }
14
- class ProxiedError extends Error {
15
- constructor(prefix, original) {
16
- super(`${prefix}: ${get_message(original)}`, { cause: original });
17
- delete this.stack;
18
- }
19
- get stack() {
20
- const cause = this.cause;
21
- if (cause && 'stack' in cause) {
22
- const stack = cause.stack;
23
- if (typeof stack === 'string') {
24
- return this.message + '\n' + removeFirstLine(cause.stack);
25
- }
26
- }
27
- return `${this.message}\n no stack available`;
28
- }
29
- }
30
- export class UnhandledRejection extends ProxiedError {
31
- promise;
32
- constructor(reason, promise) {
33
- super('unhandled promise rejection', reason);
34
- this.promise = promise;
35
- }
36
- }
37
- export class UncaughtException extends ProxiedError {
38
- error;
39
- constructor(error) {
40
- super('uncaught exception', error);
41
- this.error = error;
42
- }
43
- }
44
- function get_message(reason) {
45
- if (reason instanceof Error) {
46
- return reason.message;
47
- }
48
- if (reason && typeof reason === 'object' && 'message' in reason) {
49
- return reason.message;
50
- }
51
- return String(reason);
52
- }
53
- function removeFirstLine(text) {
54
- const index = text.indexOf('\n');
55
- if (index !== -1) {
56
- return text.slice(index + 1);
57
- }
58
- return text;
59
- }
60
- //# sourceMappingURL=internal-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-errors.js","sourceRoot":"","sources":["../../src/lifecycle/internal-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAA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,EAAE,KAAK,CAAC,CAAC;QADR,UAAK,GAAL,KAAK,CAAS;IAE1C,CAAC;CACD;AAED,SAAS,WAAW,CAAC,MAAW;IAC/B,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;QACjE,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -1,124 +0,0 @@
1
- export enum LinuxError {
2
- EPERM = 'EPERM' /* Not super-user */,
3
- ENOENT = 'ENOENT' /* No such file or directory */,
4
- ESRCH = 'ESRCH' /* No such process */,
5
- EINTR = 'EINTR' /* Interrupted system call */,
6
- EIO = 'EIO' /* I/O error */,
7
- ENXIO = 'ENXIO' /* No such device or address */,
8
- E2BIG = 'E2BIG' /* Arg list too long */,
9
- ENOEXEC = 'ENOEXEC' /* Exec format error */,
10
- EBADF = 'EBADF' /* Bad file number */,
11
- ECHILD = 'ECHILD' /* No children */,
12
- EAGAIN = 'EAGAIN' /* No more processes */,
13
- ENOMEM = 'ENOMEM' /* Not enough core */,
14
- EACCES = 'EACCES' /* Permission denied */,
15
- EFAULT = 'EFAULT' /* Bad address */,
16
- ENOTBLK = 'ENOTBLK' /* Block device required */,
17
- EBUSY = 'EBUSY' /* Mount device busy */,
18
- EEXIST = 'EEXIST' /* File exists */,
19
- EXDEV = 'EXDEV' /* Cross-device link */,
20
- ENODEV = 'ENODEV' /* No such device */,
21
- ENOTDIR = 'ENOTDIR' /* Not a directory */,
22
- EISDIR = 'EISDIR' /* Is a directory */,
23
- EINVAL = 'EINVAL' /* Invalid argument */,
24
- ENFILE = 'ENFILE' /* Too many open files in system */,
25
- EMFILE = 'EMFILE' /* Too many open files */,
26
- ENOTTY = 'ENOTTY' /* Not a typewriter */,
27
- ETXTBSY = 'ETXTBSY' /* Text file busy */,
28
- EFBIG = 'EFBIG' /* File too large */,
29
- ENOSPC = 'ENOSPC' /* No space left on device */,
30
- ESPIPE = 'ESPIPE' /* Illegal seek */,
31
- EROFS = 'EROFS' /* Read only file system */,
32
- EMLINK = 'EMLINK' /* Too many links */,
33
- EPIPE = 'EPIPE' /* Broken pipe */,
34
- EDOM = 'EDOM' /* Math arg out of domain of func */,
35
- ERANGE = 'ERANGE' /* Math result not representable */,
36
- ENOMSG = 'ENOMSG' /* No message of desired type */,
37
- EIDRM = 'EIDRM' /* Identifier removed */,
38
- ECHRNG = 'ECHRNG' /* Channel number out of range */,
39
- EL2NSYNC = 'EL2NSYNC' /* Level 2 not synchronized */,
40
- EL3HLT = 'EL3HLT' /* Level 3 halted */,
41
- EL3RST = 'EL3RST' /* Level 3 reset */,
42
- ELNRNG = 'ELNRNG' /* Link number out of range */,
43
- EUNATCH = 'EUNATCH' /* Protocol driver not attached */,
44
- ENOCSI = 'ENOCSI' /* No CSI structure available */,
45
- EL2HLT = 'EL2HLT' /* Level 2 halted */,
46
- EDEADLK = 'EDEADLK' /* Deadlock condition */,
47
- ENOLCK = 'ENOLCK' /* No record locks available */,
48
- EBADE = 'EBADE' /* Invalid exchange */,
49
- EBADR = 'EBADR' /* Invalid request descriptor */,
50
- EXFULL = 'EXFULL' /* Exchange full */,
51
- ENOANO = 'ENOANO' /* No anode */,
52
- EBADRQC = 'EBADRQC' /* Invalid request code */,
53
- EBADSLT = 'EBADSLT' /* Invalid slot */,
54
- EDEADLOCK = 'EDEADLOCK' /* File locking deadlock error */,
55
- EBFONT = 'EBFONT' /* Bad font file fmt */,
56
- ENOSTR = 'ENOSTR' /* Device not a stream */,
57
- ENODATA = 'ENODATA' /* No data (for no delay io) */,
58
- ETIME = 'ETIME' /* Timer expired */,
59
- ENOSR = 'ENOSR' /* Out of streams resources */,
60
- ENONET = 'ENONET' /* Machine is not on the network */,
61
- ENOPKG = 'ENOPKG' /* Package not installed */,
62
- EREMOTE = 'EREMOTE' /* The object is remote */,
63
- ENOLINK = 'ENOLINK' /* The link has been severed */,
64
- EADV = 'EADV' /* Advertise error */,
65
- ESRMNT = 'ESRMNT' /* Srmount error */,
66
- ECOMM = 'ECOMM' /* Communication error on send */,
67
- EPROTO = 'EPROTO' /* Protocol error */,
68
- EMULTIHOP = 'EMULTIHOP' /* Multihop attempted */,
69
- ELBIN = 'ELBIN' /* Inode is remote (not really error) */,
70
- EDOTDOT = 'EDOTDOT' /* Cross mount point (not really error) */,
71
- EBADMSG = 'EBADMSG' /* Trying to read unreadable message */,
72
- EFTYPE = 'EFTYPE' /* Inappropriate file type or format */,
73
- ENOTUNIQ = 'ENOTUNIQ' /* Given log. name not unique */,
74
- EBADFD = 'EBADFD' /* f.d. invalid for this operation */,
75
- EREMCHG = 'EREMCHG' /* Remote address changed */,
76
- ELIBACC = 'ELIBACC' /* Can't access a needed shared lib */,
77
- ELIBBAD = 'ELIBBAD' /* Accessing a corrupted shared lib */,
78
- ELIBSCN = 'ELIBSCN' /* .lib section in a.out corrupted */,
79
- ELIBMAX = 'ELIBMAX' /* Attempting to link in too many libs */,
80
- ELIBEXEC = 'ELIBEXEC' /* Attempting to exec a shared library */,
81
- ENOSYS = 'ENOSYS' /* Function not implemented */,
82
- ENMFILE = 'ENMFILE' /* No more files */,
83
- ENOTEMPTY = 'ENOTEMPTY' /* Directory not empty */,
84
- ENAMETOOLONG = 'ENAMETOOLONG' /* File or path name too long */,
85
- ELOOP = 'ELOOP' /* Too many symbolic links */,
86
- EOPNOTSUPP = 'EOPNOTSUPP' /* Operation not supported on transport endpoint */,
87
- EPFNOSUPPORT = 'EPFNOSUPPORT' /* Protocol family not supported */,
88
- ECONNRESET = 'ECONNRESET' /* Connection reset by peer */,
89
- ENOBUFS = 'ENOBUFS' /* No buffer space available */,
90
- EAFNOSUPPORT = 'EAFNOSUPPORT' /* Address family not supported by protocol family */,
91
- EPROTOTYPE = 'EPROTOTYPE' /* Protocol wrong type for socket */,
92
- ENOTSOCK = 'ENOTSOCK' /* Socket operation on non-socket */,
93
- ENOPROTOOPT = 'ENOPROTOOPT' /* Protocol not available */,
94
- ESHUTDOWN = 'ESHUTDOWN' /* Can't send after socket shutdown */,
95
- ECONNREFUSED = 'ECONNREFUSED' /* Connection refused */,
96
- EADDRINUSE = 'EADDRINUSE' /* Address already in use */,
97
- ECONNABORTED = 'ECONNABORTED' /* Connection aborted */,
98
- ENETUNREACH = 'ENETUNREACH' /* Network is unreachable */,
99
- ENETDOWN = 'ENETDOWN' /* Network interface is not configured */,
100
- ETIMEDOUT = 'ETIMEDOUT' /* Connection timed out */,
101
- EHOSTDOWN = 'EHOSTDOWN' /* Host is down */,
102
- EHOSTUNREACH = 'EHOSTUNREACH' /* Host is unreachable */,
103
- EINPROGRESS = 'EINPROGRESS' /* Connection already in progress */,
104
- EALREADY = 'EALREADY' /* Socket already connected */,
105
- EDESTADDRREQ = 'EDESTADDRREQ' /* Destination address required */,
106
- EMSGSIZE = 'EMSGSIZE' /* Message too long */,
107
- EPROTONOSUPPORT = 'EPROTONOSUPPORT' /* Unknown protocol */,
108
- ESOCKTNOSUPPORT = 'ESOCKTNOSUPPORT' /* Socket type not supported */,
109
- EADDRNOTAVAIL = 'EADDRNOTAVAIL' /* Address not available */,
110
- ENETRESET = 'ENETRESET',
111
- EISCONN = 'EISCONN' /* Socket is already connected */,
112
- ENOTCONN = 'ENOTCONN' /* Socket is not connected */,
113
- ETOOMANYREFS = 'ETOOMANYREFS',
114
- EPROCLIM = 'EPROCLIM',
115
- EUSERS = 'EUSERS',
116
- EDQUOT = 'EDQUOT',
117
- ESTALE = 'ESTALE',
118
- ENOTSUP = 'ENOTSUP' /* Not supported */,
119
- ENOMEDIUM = 'ENOMEDIUM' /* No medium (in tape drive) */,
120
- ENOSHARE = 'ENOSHARE' /* No such host or network path */,
121
- ECASECLASH = 'ECASECLASH' /* Filename exists with different case */,
122
- EILSEQ = 'EILSEQ',
123
- EOVERFLOW = 'EOVERFLOW' /* Value too large for defined data type */,
124
- }
@@ -1,39 +0,0 @@
1
- import { NodeError } from '@idlebox/node-error-codes';
2
- import { LinuxError } from './linux.js';
3
- export * from '@idlebox/node-error-codes';
4
-
5
- type NodeException<T extends string = any> = NodeJS.ErrnoException & { code: T };
6
-
7
- export interface OpenSSLException extends Error {
8
- opensslErrorStack?: string;
9
- function?: string;
10
- library?: string;
11
- reason?: string;
12
- }
13
-
14
- /**
15
- * MODULE_NOT_FOUND: require() not found
16
- * ERR_MODULE_NOT_FOUND: import() not found
17
- */
18
- export function isModuleResolutionError(ex: unknown): ex is NodeException<NodeError.MODULE_NOT_FOUND | NodeError.ERR_MODULE_NOT_FOUND> {
19
- return isNodeError(ex) && (ex.code === NodeError.MODULE_NOT_FOUND || ex.code === NodeError.ERR_MODULE_NOT_FOUND);
20
- }
21
-
22
- export function isNotExistsError(e: unknown): e is NodeException<LinuxError.ENOENT> {
23
- return isNodeError(e) && e.code === LinuxError.ENOENT;
24
- }
25
-
26
- export function isExistsError(e: unknown): e is NodeException<LinuxError.EEXIST> {
27
- return isNodeError(e) && e.code === LinuxError.EEXIST;
28
- }
29
-
30
- /** @description use isFileTypeError */
31
- export const isTypeError = isFileTypeError;
32
-
33
- export function isFileTypeError(e: unknown): e is NodeException<LinuxError.EISDIR | LinuxError.ENOTDIR> {
34
- return isNodeError(e) && (e.code === LinuxError.EISDIR || e.code === LinuxError.ENOTDIR);
35
- }
36
-
37
- export function isNodeError(e: unknown): e is NodeException {
38
- return e instanceof Error && typeof (e as any).code === 'string';
39
- }
@@ -1,66 +0,0 @@
1
- import { AppExit } from '@idlebox/common';
2
-
3
- export class Exit extends AppExit {
4
- constructor(code: number) {
5
- super(`process exit with code ${code}`, code);
6
- }
7
- }
8
-
9
- export class InterruptError extends Error {
10
- constructor(public readonly signal: NodeJS.Signals) {
11
- super(`interrupt by signal ${signal}`);
12
- }
13
- }
14
-
15
- class ProxiedError extends Error {
16
- declare cause: any;
17
-
18
- constructor(prefix: string, original: unknown) {
19
- super(`${prefix}: ${get_message(original)}`, { cause: original });
20
- delete (this as any).stack;
21
- }
22
-
23
- override get stack(): string {
24
- const cause: any = this.cause;
25
- if (cause && 'stack' in cause) {
26
- const stack = cause.stack;
27
- if (typeof stack === 'string') {
28
- return this.message + '\n' + removeFirstLine(cause.stack);
29
- }
30
- }
31
- return `${this.message}\n no stack available`;
32
- }
33
- }
34
-
35
- export class UnhandledRejection extends ProxiedError {
36
- constructor(
37
- reason: any,
38
- public readonly promise: Promise<unknown>,
39
- ) {
40
- super('unhandled promise rejection', reason);
41
- }
42
- }
43
-
44
- export class UncaughtException extends ProxiedError {
45
- constructor(public readonly error: unknown) {
46
- super('uncaught exception', error);
47
- }
48
- }
49
-
50
- function get_message(reason: any): string {
51
- if (reason instanceof Error) {
52
- return reason.message;
53
- }
54
- if (reason && typeof reason === 'object' && 'message' in reason) {
55
- return reason.message;
56
- }
57
- return String(reason);
58
- }
59
-
60
- function removeFirstLine(text: string) {
61
- const index = text.indexOf('\n');
62
- if (index !== -1) {
63
- return text.slice(index + 1);
64
- }
65
- return text;
66
- }