@mikeyt23/node-cli-utils 1.4.1 → 2.0.0-beta.1
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/README.md +45 -87
- package/dist/cjs/NodeCliUtilsConfig.d.ts +21 -0
- package/dist/cjs/NodeCliUtilsConfig.d.ts.map +1 -0
- package/dist/cjs/NodeCliUtilsConfig.js +41 -0
- package/dist/cjs/TarballUtility.d.ts +53 -0
- package/dist/cjs/TarballUtility.d.ts.map +1 -0
- package/dist/cjs/TarballUtility.js +149 -0
- package/dist/cjs/certUtils.d.ts +30 -0
- package/dist/cjs/certUtils.d.ts.map +1 -0
- package/dist/cjs/certUtils.js +219 -0
- package/dist/cjs/dbMigrationUtils.d.ts +39 -0
- package/dist/cjs/dbMigrationUtils.d.ts.map +1 -0
- package/dist/cjs/dbMigrationUtils.js +205 -0
- package/dist/cjs/dotnetUtils.d.ts +25 -0
- package/dist/cjs/dotnetUtils.d.ts.map +1 -0
- package/dist/cjs/dotnetUtils.js +59 -0
- package/dist/cjs/esmSpecific.d.mts +2 -0
- package/dist/cjs/esmSpecific.d.mts.map +1 -0
- package/dist/cjs/esmSpecific.mjs +10 -0
- package/dist/cjs/generalUtils.d.ts +323 -0
- package/dist/cjs/generalUtils.d.ts.map +1 -0
- package/dist/cjs/generalUtils.js +652 -0
- package/dist/cjs/generalUtilsInternal.d.ts +9 -0
- package/dist/cjs/generalUtilsInternal.d.ts.map +1 -0
- package/dist/cjs/generalUtilsInternal.js +217 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/runWhileParentAlive.d.ts +2 -0
- package/dist/cjs/runWhileParentAlive.d.ts.map +1 -0
- package/dist/cjs/runWhileParentAlive.js +161 -0
- package/dist/esm/NodeCliUtilsConfig.d.ts +21 -0
- package/dist/esm/NodeCliUtilsConfig.d.ts.map +1 -0
- package/dist/esm/NodeCliUtilsConfig.js +35 -0
- package/dist/esm/TarballUtility.d.ts +53 -0
- package/dist/esm/TarballUtility.d.ts.map +1 -0
- package/dist/esm/TarballUtility.js +143 -0
- package/dist/esm/certUtils.d.ts +30 -0
- package/dist/esm/certUtils.d.ts.map +1 -0
- package/dist/esm/certUtils.js +185 -0
- package/dist/esm/dbMigrationUtils.d.ts +39 -0
- package/dist/esm/dbMigrationUtils.d.ts.map +1 -0
- package/dist/esm/dbMigrationUtils.js +194 -0
- package/dist/esm/dotnetUtils.d.ts +25 -0
- package/dist/esm/dotnetUtils.d.ts.map +1 -0
- package/dist/esm/dotnetUtils.js +52 -0
- package/dist/esm/esmSpecific.d.mts +2 -0
- package/dist/esm/esmSpecific.d.mts.map +1 -0
- package/dist/esm/esmSpecific.mjs +6 -0
- package/dist/esm/generalUtils.d.ts +323 -0
- package/dist/esm/generalUtils.d.ts.map +1 -0
- package/dist/esm/generalUtils.js +591 -0
- package/dist/esm/generalUtilsInternal.d.ts +9 -0
- package/dist/esm/generalUtilsInternal.d.ts.map +1 -0
- package/dist/esm/generalUtilsInternal.js +185 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/runWhileParentAlive.d.ts +2 -0
- package/dist/esm/runWhileParentAlive.d.ts.map +1 -0
- package/dist/esm/runWhileParentAlive.js +153 -0
- package/package.json +67 -10
- package/index.js +0 -627
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SpawnOptions } from 'node:child_process';
|
|
3
|
+
/**
|
|
4
|
+
* Just a wrapper for console.log() to type less.
|
|
5
|
+
* @param data The data to log
|
|
6
|
+
* @param moreData More data to log
|
|
7
|
+
*/
|
|
8
|
+
export declare function log(data: unknown, ...moreData: unknown[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Wrapper for console.log() that is suppressed if NodeCliUtilsConfig.logEnabled is false.
|
|
11
|
+
* @param data The data to log
|
|
12
|
+
* @param moreData More data to log
|
|
13
|
+
*/
|
|
14
|
+
export declare function trace(data?: unknown, ...moreData: unknown[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard for a string keyed dictionary.
|
|
17
|
+
*/
|
|
18
|
+
export type StringKeyedDictionary = {
|
|
19
|
+
[name: string]: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Options for the {@link spawnAsync} wrapper function for NodeJS spawn.
|
|
23
|
+
*/
|
|
24
|
+
export interface SpawnResult {
|
|
25
|
+
/**
|
|
26
|
+
* The exit code of the spawned process. Rather than allowing null, this will be set to 1 if the process exits with null, or 0 if user cancels with ctrl+c.
|
|
27
|
+
*/
|
|
28
|
+
code: number;
|
|
29
|
+
/**
|
|
30
|
+
* The stdout of the spawned process. **Warning:** this will be empty by default without changing SpawnOptions stdio (see {@link spawnAsync}).
|
|
31
|
+
*/
|
|
32
|
+
stdout: string;
|
|
33
|
+
/**
|
|
34
|
+
* The stderr of the spawned process. **Warning:** this will be empty by default without changing SpawnOptions stdio (see {@link spawnAsync}).
|
|
35
|
+
*/
|
|
36
|
+
stderr: string;
|
|
37
|
+
/**
|
|
38
|
+
* Not an error from the child process stderr, but rather an error thrown when attempting to spawn the child process.
|
|
39
|
+
*/
|
|
40
|
+
error?: Error;
|
|
41
|
+
/**
|
|
42
|
+
* The current working directory of the spawned process. Not changed by method, so just repeating your SpawnOptions.cwd back to you, but helpful for debugging.
|
|
43
|
+
*/
|
|
44
|
+
cwd?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error throw by {@link spawnAsync} when the spawned process exits with a non-zero exit code and options.throwOnNonZero is true.
|
|
48
|
+
*
|
|
49
|
+
* Contains a {@link SpawnResult} with the exit code, stdout, stderr, and error (if any).
|
|
50
|
+
*/
|
|
51
|
+
export declare class SpawnError extends Error {
|
|
52
|
+
result: SpawnResult;
|
|
53
|
+
constructor(message: string, result: SpawnResult);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Spawn result for calls to {@link simpleSpawnSync} and {@link simpleCmdSync}.
|
|
57
|
+
*
|
|
58
|
+
* Contains the same properties as {@link SpawnResult} plus stdoutLines, which is stdout split into lines from stdout that weren't empty.
|
|
59
|
+
*/
|
|
60
|
+
export interface SimpleSpawnResult extends SpawnResult {
|
|
61
|
+
stdoutLines: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error throw by {@link simpleSpawnSync} and {@link simpleCmdSync} when the spawned process exits with a non-zero exit code and throwOnNonZero param is true (the default).
|
|
65
|
+
*
|
|
66
|
+
* Contains a {@link SimpleSpawnResult} with the exit code, stdout, stderr, and error (if any) in addition to stdoutLines, which is stdout split into lines from stdout that weren't empty.
|
|
67
|
+
*/
|
|
68
|
+
export declare class SimpleSpawnError extends Error {
|
|
69
|
+
result: SimpleSpawnResult;
|
|
70
|
+
constructor(message: string, result: SimpleSpawnResult);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The result type for {@link whichSync}. Contains the location of the command, any additional locations, and an error if one occurred.
|
|
74
|
+
*/
|
|
75
|
+
export interface WhichResult {
|
|
76
|
+
location: string | undefined;
|
|
77
|
+
additionalLocations: string[] | undefined;
|
|
78
|
+
error: Error | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Type guard for command passed to {@link spawnDockerCompose}.
|
|
82
|
+
*/
|
|
83
|
+
export type DockerComposeCommand = 'build' | 'config' | 'cp' | 'create' | 'down' | 'events' | 'exec' | 'images' | 'kill' | 'logs' | 'ls' | 'pause' | 'port' | 'ps' | 'pull' | 'push' | 'restart' | 'rm' | 'run' | 'start' | 'stop' | 'top' | 'unpause' | 'up' | 'version';
|
|
84
|
+
/**
|
|
85
|
+
* Sleeps for the specified number of milliseconds.
|
|
86
|
+
* @param ms The number of milliseconds to sleep
|
|
87
|
+
* @returns A Promise that resolves after the specified number of milliseconds
|
|
88
|
+
*/
|
|
89
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* An extension of the built-in SpawnOptions with an extra option to specify whether a non-zero exit code should throw an error.
|
|
92
|
+
*/
|
|
93
|
+
export interface SpawnOptionsWithThrow extends SpawnOptions {
|
|
94
|
+
throwOnNonZero?: boolean;
|
|
95
|
+
simpleErrorMsg?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* This is a wrapper function for NodeJS. Defaults stdio to inherit so that output is visible in the console,
|
|
99
|
+
* but note that this means stdout and stderr will not be available in the returned SpawnResult.
|
|
100
|
+
*
|
|
101
|
+
* When spawning long-running processes, use {@link spawnAsyncLongRunning} instead so that unexpected
|
|
102
|
+
* termination of the parent process will not orphan the child process tree on windows.
|
|
103
|
+
* @param command The command to spawn
|
|
104
|
+
* @param args The arguments to pass to the command
|
|
105
|
+
* @param options The options to pass to the command
|
|
106
|
+
* @returns A Promise that resolves to a {@link SpawnResult}
|
|
107
|
+
*/
|
|
108
|
+
export declare function spawnAsync(command: string, args?: string[], options?: SpawnOptionsWithThrow): Promise<SpawnResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Use this alternate spawn wrapper instead of {@link spawnAsync} when spawning long-running processes to
|
|
111
|
+
* avoid orphaned child process trees on Windows.
|
|
112
|
+
* @param command The command to spawn
|
|
113
|
+
* @param args The arguments to pass to the command
|
|
114
|
+
* @param cwd The current working directory to run the command from - defaults to process.cwd()
|
|
115
|
+
* @returns A Promise that resolves to a {@link SpawnResult}
|
|
116
|
+
*/
|
|
117
|
+
export declare function spawnAsyncLongRunning(command: string, args?: string[], cwd?: string): Promise<SpawnResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Ensure the directory exists. Similar to `mkdir -p` (creates parent directories if they don't exist).
|
|
120
|
+
* @param dir The directory to ensure exists. If it does not exist, it will be created.
|
|
121
|
+
*/
|
|
122
|
+
export declare function ensureDirectory(dir: string): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Create a directory. Will create parent directory structure if it don't exist. Similar to `mkdir -p`.
|
|
125
|
+
* @param dir The directory to create.
|
|
126
|
+
*/
|
|
127
|
+
export declare function mkdirp(dir: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Empties a directory of all files and subdirectories.
|
|
130
|
+
*
|
|
131
|
+
* Optionally skips files and directories at the top level.
|
|
132
|
+
* @param directoryToEmpty The directory to empty.
|
|
133
|
+
* @param fileAndDirectoryNamesToSkip An optional array of file and directory names to skip, but only at the top level of the directoryToEmpty.
|
|
134
|
+
*/
|
|
135
|
+
export declare function emptyDirectory(directoryToEmpty: string, fileAndDirectoryNamesToSkip?: string[]): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Copies the contents of a directory to another directory (not including the top-level directory itself).
|
|
138
|
+
*
|
|
139
|
+
* If the destination directory does not exist, it will be created.
|
|
140
|
+
* @param sourceDirectory Directory to copy from
|
|
141
|
+
* @param destinationDirectory Directory to copy to
|
|
142
|
+
*/
|
|
143
|
+
export declare function copyDirectoryContents(sourceDirectory: string, destinationDirectory: string): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Helper method to validate that a non-falsy value is provided for a parameter that should be a string.
|
|
146
|
+
*
|
|
147
|
+
* **Warning:** this does not validate the type of the parameter, just whether something non-empty was provided.
|
|
148
|
+
* @param paramName The name of the parameter, for logging purposes
|
|
149
|
+
* @param paramValue The value of the parameter
|
|
150
|
+
*/
|
|
151
|
+
export declare function requireString(paramName: string, paramValue: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Helper method to validate that the path actually exists for the provided value.
|
|
154
|
+
* @param paramName The name of the parameter, for logging purposes
|
|
155
|
+
* @param paramValue The value of the parameter
|
|
156
|
+
*/
|
|
157
|
+
export declare function requireValidPath(paramName: string, paramValue: string): void;
|
|
158
|
+
/**
|
|
159
|
+
* Options for the spawnDockerCompose wrapper function for `docker compose`.
|
|
160
|
+
* @param args Additional arguments to pass to the docker-compose command
|
|
161
|
+
* @param projectName Pass the same projectName for each commands for the same project to ensure your containers get unique, descriptive and consistent names.
|
|
162
|
+
* Note that there are other better options such as using the environment variable `COMPOSE_PROJECT_NAME`. See https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name.
|
|
163
|
+
* @param attached Default: false. All commands that support the detached option wil use it unless attached is specified as true (-d support: exec, logs, ps, restart, run, start, stop, up)
|
|
164
|
+
* @param useDockerComposeFileDirectoryAsCwd Default: false. If true, the docker compose command will be run in the directory containing the docker compose file.
|
|
165
|
+
*/
|
|
166
|
+
export interface DockerComposeOptions {
|
|
167
|
+
args?: string[];
|
|
168
|
+
projectName?: string;
|
|
169
|
+
attached?: boolean;
|
|
170
|
+
useDockerComposeFileDirectoryAsCwd?: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* For docker compose commands, see https://docs.docker.com/compose/reference/.
|
|
174
|
+
* @param dockerComposePath Path to docker-compose.yml
|
|
175
|
+
* @param dockerComposeCommand The docker-compose command to run
|
|
176
|
+
* @param options {@link DockerComposeOptions} to use, including additional arguments to pass to the docker compose command and the project name
|
|
177
|
+
*/
|
|
178
|
+
export declare function spawnDockerCompose(dockerComposePath: string, dockerComposeCommand: DockerComposeCommand, options?: DockerComposeOptions): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Splits a string into lines, removing empty lines and carriage return characters.
|
|
181
|
+
* @param str String to split into lines
|
|
182
|
+
* @returns An array of lines from the string, with empty lines removed
|
|
183
|
+
*/
|
|
184
|
+
export declare function stringToNonEmptyLines(str: string): string[];
|
|
185
|
+
/**
|
|
186
|
+
* Runs the requested command using NodeJS spawnSync wrapped in an outer Windows CMD.exe command and returns the result with stdout split into lines.
|
|
187
|
+
*
|
|
188
|
+
* Use this for simple quick commands that don't require a lot of control.
|
|
189
|
+
*
|
|
190
|
+
* For commands that aren't Windows and CMD specific, use {@link simpleSpawnSync}.
|
|
191
|
+
* @param command Command to run
|
|
192
|
+
* @param args Arguments to pass to the command
|
|
193
|
+
* @returns An object with the status code, stdout, stderr, and error (if any)
|
|
194
|
+
* @throws {@link SimpleSpawnError} if the command fails and throwOnNonZero is true
|
|
195
|
+
*/
|
|
196
|
+
export declare function simpleCmdSync(command: string, args?: string[], throwOnNonZero?: boolean): SimpleSpawnResult;
|
|
197
|
+
/**
|
|
198
|
+
* Runs the requested command using NodeJS spawnSync and returns the result with stdout split into lines.
|
|
199
|
+
*
|
|
200
|
+
* Use this for simple quick commands that don't require a lot of control.
|
|
201
|
+
*
|
|
202
|
+
* For commands that are Windows and CMD specific, use {@link simpleCmdSync}.
|
|
203
|
+
* @param command Command to run
|
|
204
|
+
* @param args Arguments to pass to the command
|
|
205
|
+
* @returns An object with the status code, stdout, stderr, and error (if any)
|
|
206
|
+
* @throws {@link SimpleSpawnError} if the command fails and throwOnNonZero is true
|
|
207
|
+
*/
|
|
208
|
+
export declare function simpleSpawnSync(command: string, args?: string[], throwOnNonZero?: boolean): SimpleSpawnResult;
|
|
209
|
+
/**
|
|
210
|
+
* @returns `true` if platform() is 'win32', `false` otherwise
|
|
211
|
+
*/
|
|
212
|
+
export declare function isPlatformWindows(): boolean;
|
|
213
|
+
/**
|
|
214
|
+
*
|
|
215
|
+
* @returns `true` if platform() is 'darwin', `false` otherwise
|
|
216
|
+
*/
|
|
217
|
+
export declare function isPlatformMac(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
* @returns `true` if {@link isPlatformWindows} and {@link isPlatformMac} are both `false, otherwise returns `false`
|
|
221
|
+
*/
|
|
222
|
+
export declare function isPlatformLinux(): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* This is a cross-platform method to get the location of a system command. Useful for checking if software
|
|
225
|
+
* is installed, where it's installed and whether there are multiple locations for a command.
|
|
226
|
+
* @param commandName The name of the command to find
|
|
227
|
+
* @returns The location of the command, any additional locations, and an error if one occurred
|
|
228
|
+
*/
|
|
229
|
+
export declare function whichSync(commandName: string): WhichResult;
|
|
230
|
+
/**
|
|
231
|
+
* First checks if docker is installed and if not immediately returns false.
|
|
232
|
+
*
|
|
233
|
+
* Then runs the `docker info` command and looks for "error during connect" in the output to determine if docker is running.
|
|
234
|
+
* @returns `true` if docker is installed and running, `false` otherwise
|
|
235
|
+
*/
|
|
236
|
+
export declare function isDockerRunning(): Promise<boolean>;
|
|
237
|
+
/**
|
|
238
|
+
* Uses built-in NodeJS readline to ask a question and return the user's answer.
|
|
239
|
+
* @param query The question to ask
|
|
240
|
+
* @returns A Promise that resolves to the user's answer
|
|
241
|
+
*/
|
|
242
|
+
export declare function askQuestion(query: string): Promise<string>;
|
|
243
|
+
/**
|
|
244
|
+
* A simple CLI prompt using the built-in NodeJS readline functionality to ask for confirmation.
|
|
245
|
+
* @param question The question to ask
|
|
246
|
+
* @returns A Promise that resolves to true if the user answers 'y' or 'yes', false otherwise
|
|
247
|
+
*/
|
|
248
|
+
export declare function getConfirmation(question: string): Promise<boolean>;
|
|
249
|
+
/**
|
|
250
|
+
* Example of using {@link getConfirmation}.
|
|
251
|
+
*/
|
|
252
|
+
export declare function getConfirmationExample(): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Copy entries from a source .env file to a destination .env file for which the destination .env file does not already have entries.
|
|
255
|
+
* If the destination .env file does not exist, it will be created and populated with the source .env file's values.
|
|
256
|
+
*
|
|
257
|
+
* This is useful for copying values from a .env.template file to a root .env file.
|
|
258
|
+
*
|
|
259
|
+
* For copying root .env files to other locations, use {@link overwriteEnvFile}.
|
|
260
|
+
* @param sourcePath The path to the source .env file such as a `.env.template` file (use {@link overwriteEnvFile} for copying root .env files to other locations)
|
|
261
|
+
* @param destinationPath The path to the destination .env file, such as the root .env file
|
|
262
|
+
*/
|
|
263
|
+
export declare function copyNewEnvValues(sourcePath: string, destinationPath: string): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Copy entries from a source .env file to a destination .env file, overwriting any existing entries in the destination .env file.
|
|
266
|
+
* If the destination .env file does not exist, it will be created and populated with the source .env file's values.
|
|
267
|
+
*
|
|
268
|
+
* This is useful for copying values from a root .env file to additional locations (server, client, docker-compose directory, etc.)
|
|
269
|
+
* throughout your solution so you only have to manage one .env file.
|
|
270
|
+
*
|
|
271
|
+
* Note that this does not delete any existing entries in the destination .env file, which is useful if you have additional entries in
|
|
272
|
+
* the destination .env file that you don't want to overwrite.
|
|
273
|
+
*
|
|
274
|
+
* For copying .env.template files to root .env files, use {@link copyNewEnvValues}.
|
|
275
|
+
* @param sourcePath The path to the source .env file such as a root .env file (use {@link copyNewEnvValues} for .env.template files)
|
|
276
|
+
* @param destinationPath The path to the destination .env file
|
|
277
|
+
* @param suppressAddKeysMessages If true, messages about adding missing keys will not be logged (useful if you're always calling {@link copyModifiedEnv} after this call)
|
|
278
|
+
*/
|
|
279
|
+
export declare function overwriteEnvFile(sourcePath: string, destinationPath: string, suppressAddKeysMessages?: boolean): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Copy entries from a source .env file to a destination .env file, but only for the keys specified in keepKeys.
|
|
282
|
+
* Will also modify entries in the destination .env file as specified in modifyEntries.
|
|
283
|
+
* @param sourcePath The path to the source .env file
|
|
284
|
+
* @param destinationPath The path to the destination .env file
|
|
285
|
+
* @param keepKeys The keys to keep from the source .env file
|
|
286
|
+
* @param modifyEntries The entries to modify in the destination .env file
|
|
287
|
+
*/
|
|
288
|
+
export declare function copyModifiedEnv(sourcePath: string, destinationPath: string, keepKeys: string[], modifyEntries?: StringKeyedDictionary): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Filters a dictionary by key.
|
|
291
|
+
* @param dict The dictionary to filter
|
|
292
|
+
* @param predicate A function that returns true if the key should be included in the filtered dictionary
|
|
293
|
+
* @returns A new dictionary with only the keys that passed the predicate
|
|
294
|
+
*/
|
|
295
|
+
export declare function filterDictionary(dict: StringKeyedDictionary, predicate: (key: string) => boolean): StringKeyedDictionary;
|
|
296
|
+
/**
|
|
297
|
+
* Sorts a dictionary by key in ascending order.
|
|
298
|
+
* @param dict The dictionary to sort
|
|
299
|
+
* @returns A new dictionary sorted by key in ascending order
|
|
300
|
+
*/
|
|
301
|
+
export declare function sortDictionaryByKeyAsc(dict: StringKeyedDictionary): StringKeyedDictionary;
|
|
302
|
+
/**
|
|
303
|
+
* Helper method to delete a .env file if it exists.
|
|
304
|
+
* @param envPath The path to the .env file to delete
|
|
305
|
+
*/
|
|
306
|
+
export declare function deleteEnvIfExists(envPath: string): Promise<void>;
|
|
307
|
+
export interface FindFilesOptions {
|
|
308
|
+
maxDepth?: number;
|
|
309
|
+
excludeDirectoryNames?: string[];
|
|
310
|
+
returnForwardSlashRelativePaths?: boolean;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Searches a directory recursively for files that match the specified pattern.
|
|
314
|
+
* The filenamePattern is a simple text string with asterisks (*) for wildcards.
|
|
315
|
+
* @param dir The directory to find files in
|
|
316
|
+
* @param filenamePattern The pattern to match files against
|
|
317
|
+
* @param options Specify a max depth to search, defaults to 5
|
|
318
|
+
* @returns A Promise that resolves to an array of file paths that match the pattern
|
|
319
|
+
*/
|
|
320
|
+
export declare function findFilesRecursively(dir: string, filenamePattern: string, options?: FindFilesOptions): Promise<string[]>;
|
|
321
|
+
/** Utility function to escape a string for use within regex */
|
|
322
|
+
export declare function escapeStringForRegex(str: string): string;
|
|
323
|
+
//# sourceMappingURL=generalUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/generalUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAA;AAWlE;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,QAExD;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,QAK3D;AAED;;GAEG;AACH,MAAM,MAAM,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