@easbot/utils 0.2.9 → 0.2.11

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/dist/index.d.cts CHANGED
@@ -1,13 +1,12 @@
1
1
  import { ChildProcess } from 'node:child_process';
2
2
  import z, { z as z$1 } from 'zod';
3
- export { z } from 'zod';
4
3
  import { statSync } from 'node:fs';
5
4
  import * as stream from 'stream';
6
5
  import { Readable } from 'stream';
7
6
  import * as _hono_node_ws from '@hono/node-ws';
8
7
  export { createNodeWebSocket } from '@hono/node-ws';
9
8
  import * as fs from 'fs';
10
- import { Context as Context$1, Next, Hono } from 'hono';
9
+ import { Hono, Context as Context$1, Next } from 'hono';
11
10
  export { Hono, Next } from 'hono';
12
11
  import { ServerType } from '@hono/node-server';
13
12
  import { cors } from 'hono/cors';
@@ -111,6 +110,20 @@ declare namespace Shell {
111
110
  function platformShells(): string[];
112
111
  function isValid(file: string): boolean;
113
112
  function version(file: string): Promise<string | undefined>;
113
+ interface InstallOptions {
114
+ cwd?: string;
115
+ env?: Record<string, string | undefined>;
116
+ timeout?: number;
117
+ windowsHide?: boolean;
118
+ }
119
+ class InstallFailedError extends Error {
120
+ message: string;
121
+ pkg: string;
122
+ version: string;
123
+ originalError?: string | undefined;
124
+ constructor(message: string, pkg: string, version: string, originalError?: string | undefined);
125
+ }
126
+ function install(pkg: string, version?: string, installPath?: string): Promise<string>;
114
127
  interface RunOptions {
115
128
  cwd?: string;
116
129
  env?: Record<string, string | undefined>;
@@ -124,12 +137,12 @@ declare namespace Shell {
124
137
  stderr?: 'pipe' | 'inherit' | 'null';
125
138
  stdin?: 'pipe' | 'inherit' | 'null';
126
139
  }
127
- function run(shell: string, command: string, options?: RunOptions): Promise<{
140
+ function run(shell: string | undefined, command: string, options?: RunOptions): Promise<{
128
141
  code: number;
129
142
  stdout: string;
130
143
  stderr: string;
131
144
  }>;
132
- function spawn(shell: string, command: string, options?: SpawnOptions): {
145
+ function spawn(shell: string | undefined, command: string, options?: SpawnOptions): {
133
146
  stdout: any;
134
147
  stderr: any;
135
148
  stdin: any;
@@ -137,7 +150,29 @@ declare namespace Shell {
137
150
  exited: Promise<number>;
138
151
  kill: (signal?: string | number) => boolean;
139
152
  };
153
+ interface DollarRunOptions {
154
+ cwd?: string;
155
+ quiet?: boolean;
156
+ nothrow?: boolean;
157
+ env?: Record<string, string | undefined>;
158
+ }
159
+ function $(strings: TemplateStringsArray, ...values: unknown[]): {
160
+ quiet: () => any;
161
+ nothrow: () => any;
162
+ cwd: (dir: string) => any;
163
+ env: (env: Record<string, string | undefined>) => any;
164
+ text: () => Promise<string>;
165
+ lines: () => Promise<string[]>;
166
+ then: (onfulfilled: (result: {
167
+ exitCode: number;
168
+ stdout: Uint8Array;
169
+ stderr: Uint8Array;
170
+ text: () => string;
171
+ lines: () => string[];
172
+ }) => void, onrejected?: (error: Error) => void) => Promise<void>;
173
+ };
140
174
  }
175
+ declare const $: typeof Shell.$;
141
176
 
142
177
  declare function formatLocalISO(date: Date | number, includeMilliseconds?: boolean): string;
143
178
  declare function formatLocalISOCompact(date: Date | number): string;
@@ -875,6 +910,11 @@ interface NodeSpawnResult {
875
910
  exitCode?: number;
876
911
  }
877
912
  declare namespace PKG {
913
+ type PackageManager = 'npm' | 'pnpm' | 'bun';
914
+ function packageManager(preferred?: PackageManager): Promise<{
915
+ name: PackageManager;
916
+ path: string;
917
+ } | undefined>;
878
918
  function which(command?: string, options?: NodeWhichOptions): Promise<string | null>;
879
919
  function whichSync(command?: string, options?: NodeWhichOptions): string | null;
880
920
  function clearWhichCache(): void;
@@ -926,21 +966,6 @@ declare namespace PKG {
926
966
  stdout: string;
927
967
  stderr: string;
928
968
  }>;
929
- function $(strings: TemplateStringsArray, ...values: unknown[]): {
930
- quiet: () => any;
931
- nothrow: () => any;
932
- cwd: (dir: string) => any;
933
- env: (env: Record<string, string | undefined>) => any;
934
- text: () => Promise<string>;
935
- lines: () => Promise<string[]>;
936
- then: (onfulfilled: (result: {
937
- exitCode: number;
938
- stdout: Uint8Array;
939
- stderr: Uint8Array;
940
- text: () => string;
941
- lines: () => string[];
942
- }) => void, onrejected?: (error: Error) => void) => Promise<void>;
943
- };
944
969
  function readableStreamToText(stream: ReadableStream<Uint8Array>): Promise<string>;
945
970
  function nodeReadableStreamToText(stream: NodeJS.ReadableStream): Promise<string>;
946
971
  function xxHash32(str: string, seed?: number): number;
@@ -964,257 +989,6 @@ declare namespace PKG {
964
989
  }): Generator<string>;
965
990
  match(filepath: string): boolean;
966
991
  }
967
- const InstallFailedError: {
968
- new (data: {
969
- message: string;
970
- pkg: string;
971
- version: string;
972
- originalError?: string | undefined;
973
- }, options?: ErrorOptions): {
974
- readonly name: "PKGInstallFailedError";
975
- readonly data: {
976
- message: string;
977
- pkg: string;
978
- version: string;
979
- originalError?: string | undefined;
980
- };
981
- schema(): z.ZodObject<{
982
- name: z.ZodLiteral<"PKGInstallFailedError">;
983
- data: z.ZodObject<{
984
- message: z.ZodString;
985
- pkg: z.ZodString;
986
- version: z.ZodString;
987
- originalError: z.ZodOptional<z.ZodString>;
988
- }, z.core.$strip>;
989
- }, z.core.$strip>;
990
- toObject(): {
991
- name: "PKGInstallFailedError";
992
- data: {
993
- message: string;
994
- pkg: string;
995
- version: string;
996
- originalError?: string | undefined;
997
- };
998
- };
999
- message: string;
1000
- stack?: string;
1001
- cause?: unknown;
1002
- };
1003
- readonly Schema: z.ZodObject<{
1004
- name: z.ZodLiteral<"PKGInstallFailedError">;
1005
- data: z.ZodObject<{
1006
- message: z.ZodString;
1007
- pkg: z.ZodString;
1008
- version: z.ZodString;
1009
- originalError: z.ZodOptional<z.ZodString>;
1010
- }, z.core.$strip>;
1011
- }, z.core.$strip>;
1012
- isInstance(input: any): input is {
1013
- readonly name: "PKGInstallFailedError";
1014
- readonly data: {
1015
- message: string;
1016
- pkg: string;
1017
- version: string;
1018
- originalError?: string | undefined;
1019
- };
1020
- schema(): z.ZodObject<{
1021
- name: z.ZodLiteral<"PKGInstallFailedError">;
1022
- data: z.ZodObject<{
1023
- message: z.ZodString;
1024
- pkg: z.ZodString;
1025
- version: z.ZodString;
1026
- originalError: z.ZodOptional<z.ZodString>;
1027
- }, z.core.$strip>;
1028
- }, z.core.$strip>;
1029
- toObject(): {
1030
- name: "PKGInstallFailedError";
1031
- data: {
1032
- message: string;
1033
- pkg: string;
1034
- version: string;
1035
- originalError?: string | undefined;
1036
- };
1037
- };
1038
- message: string;
1039
- stack?: string;
1040
- cause?: unknown;
1041
- };
1042
- create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data): {
1043
- new (data: z.input<Data>, options?: ErrorOptions): {
1044
- readonly name: Name;
1045
- readonly data: z.core.input<Data>;
1046
- schema(): z.ZodObject<{
1047
- name: z.ZodLiteral<Name>;
1048
- data: Data;
1049
- }, z.core.$strip>;
1050
- toObject(): {
1051
- name: Name;
1052
- data: z.core.input<Data>;
1053
- };
1054
- message: string;
1055
- stack?: string;
1056
- cause?: unknown;
1057
- };
1058
- readonly Schema: z.ZodObject<{
1059
- name: z.ZodLiteral<Name>;
1060
- data: Data;
1061
- }, z.core.$strip>;
1062
- isInstance(input: any): input is InstanceType<any>;
1063
- create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data): any;
1064
- readonly Unknown: {
1065
- new (data: {
1066
- message: string;
1067
- }, options?: ErrorOptions): {
1068
- readonly name: "UnknownError";
1069
- readonly data: {
1070
- message: string;
1071
- };
1072
- schema(): z.ZodObject<{
1073
- name: z.ZodLiteral<"UnknownError">;
1074
- data: z.ZodObject<{
1075
- message: z.ZodString;
1076
- }, z.core.$strip>;
1077
- }, z.core.$strip>;
1078
- toObject(): {
1079
- name: "UnknownError";
1080
- data: {
1081
- message: string;
1082
- };
1083
- };
1084
- message: string;
1085
- stack?: string;
1086
- cause?: unknown;
1087
- };
1088
- readonly Schema: z.ZodObject<{
1089
- name: z.ZodLiteral<"UnknownError">;
1090
- data: z.ZodObject<{
1091
- message: z.ZodString;
1092
- }, z.core.$strip>;
1093
- }, z.core.$strip>;
1094
- isInstance(input: any): input is {
1095
- readonly name: "UnknownError";
1096
- readonly data: {
1097
- message: string;
1098
- };
1099
- schema(): z.ZodObject<{
1100
- name: z.ZodLiteral<"UnknownError">;
1101
- data: z.ZodObject<{
1102
- message: z.ZodString;
1103
- }, z.core.$strip>;
1104
- }, z.core.$strip>;
1105
- toObject(): {
1106
- name: "UnknownError";
1107
- data: {
1108
- message: string;
1109
- };
1110
- };
1111
- message: string;
1112
- stack?: string;
1113
- cause?: unknown;
1114
- };
1115
- create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data): any;
1116
- readonly Unknown: any;
1117
- isError(error: unknown): error is Error;
1118
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1119
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1120
- stackTraceLimit: number;
1121
- };
1122
- isError(error: unknown): error is Error;
1123
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1124
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1125
- stackTraceLimit: number;
1126
- };
1127
- readonly Unknown: {
1128
- new (data: {
1129
- message: string;
1130
- }, options?: ErrorOptions): {
1131
- readonly name: "UnknownError";
1132
- readonly data: {
1133
- message: string;
1134
- };
1135
- schema(): z.ZodObject<{
1136
- name: z.ZodLiteral<"UnknownError">;
1137
- data: z.ZodObject<{
1138
- message: z.ZodString;
1139
- }, z.core.$strip>;
1140
- }, z.core.$strip>;
1141
- toObject(): {
1142
- name: "UnknownError";
1143
- data: {
1144
- message: string;
1145
- };
1146
- };
1147
- message: string;
1148
- stack?: string;
1149
- cause?: unknown;
1150
- };
1151
- readonly Schema: z.ZodObject<{
1152
- name: z.ZodLiteral<"UnknownError">;
1153
- data: z.ZodObject<{
1154
- message: z.ZodString;
1155
- }, z.core.$strip>;
1156
- }, z.core.$strip>;
1157
- isInstance(input: any): input is {
1158
- readonly name: "UnknownError";
1159
- readonly data: {
1160
- message: string;
1161
- };
1162
- schema(): z.ZodObject<{
1163
- name: z.ZodLiteral<"UnknownError">;
1164
- data: z.ZodObject<{
1165
- message: z.ZodString;
1166
- }, z.core.$strip>;
1167
- }, z.core.$strip>;
1168
- toObject(): {
1169
- name: "UnknownError";
1170
- data: {
1171
- message: string;
1172
- };
1173
- };
1174
- message: string;
1175
- stack?: string;
1176
- cause?: unknown;
1177
- };
1178
- create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data): {
1179
- new (data: z.input<Data>, options?: ErrorOptions): {
1180
- readonly name: Name;
1181
- readonly data: z.core.input<Data>;
1182
- schema(): z.ZodObject<{
1183
- name: z.ZodLiteral<Name>;
1184
- data: Data;
1185
- }, z.core.$strip>;
1186
- toObject(): {
1187
- name: Name;
1188
- data: z.core.input<Data>;
1189
- };
1190
- message: string;
1191
- stack?: string;
1192
- cause?: unknown;
1193
- };
1194
- readonly Schema: z.ZodObject<{
1195
- name: z.ZodLiteral<Name>;
1196
- data: Data;
1197
- }, z.core.$strip>;
1198
- isInstance(input: any): input is InstanceType<any>;
1199
- create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data): any;
1200
- readonly Unknown: any;
1201
- isError(error: unknown): error is Error;
1202
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1203
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1204
- stackTraceLimit: number;
1205
- };
1206
- readonly Unknown: any;
1207
- isError(error: unknown): error is Error;
1208
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1209
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1210
- stackTraceLimit: number;
1211
- };
1212
- isError(error: unknown): error is Error;
1213
- captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1214
- prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1215
- stackTraceLimit: number;
1216
- };
1217
- function install(pkg: string, version?: string, installPath?: string): Promise<string>;
1218
992
  const stdin: NodeJS.ReadStream & {
1219
993
  fd: 0;
1220
994
  };
@@ -1237,7 +1011,6 @@ declare namespace PKG {
1237
1011
  const streamingServer: typeof createStreamingServer;
1238
1012
  const webSocketServer: typeof createWebSocketServer;
1239
1013
  }
1240
- declare const $: typeof PKG.$;
1241
1014
  declare const readableStreamToText: typeof PKG.readableStreamToText;
1242
1015
  declare const whichSync: typeof PKG.whichSync;
1243
1016