@zthun/crumbtrail-cli 2.4.6
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 +20 -0
- package/README.md +17 -0
- package/dist/cli.cjs +24 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +22 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/nudge/nudge.d.mts +52 -0
- package/dist/watch/watch.d.mts +101 -0
- package/dist/watch-C-6Gf4uc.cjs +239 -0
- package/dist/watch-C-6Gf4uc.cjs.map +1 -0
- package/dist/watch-DdpcqnOY.js +236 -0
- package/dist/watch-DdpcqnOY.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Anthony Bonta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
|
|
3
|
+
Crumbtrail Watch is a command line debug utility. This utility will watch a
|
|
4
|
+
specific directory and will output the events, add, remove, update, on said
|
|
5
|
+
directory.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i -g @zthun/crumbtrail-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
crumbtrail-cli /path/to/directory
|
|
17
|
+
```
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crumbtrailFs = require('@zthun/crumbtrail-fs');
|
|
4
|
+
const lumberjackyLog = require('@zthun/lumberjacky-log');
|
|
5
|
+
const commander = require('commander');
|
|
6
|
+
const watch = require('./watch-C-6Gf4uc.cjs');
|
|
7
|
+
|
|
8
|
+
const logger = new lumberjackyLog.ZLoggerConsole(console);
|
|
9
|
+
const application = new commander.Command();
|
|
10
|
+
application.name("crumbtrail-cli").description("Crumbtrail utilities for debugging");
|
|
11
|
+
application.command("watch", {
|
|
12
|
+
isDefault: true
|
|
13
|
+
}).description("Watch a directory and log changes").option("-d, --directory <dir>", "The directory to watch", process.cwd()).option("-g, --glob <pattern>", "Glob pattern (repeatable)", (val, prev)=>prev.concat(val), []).action(async (options)=>{
|
|
14
|
+
const command = new watch.ZCrumbtrailWatch(logger);
|
|
15
|
+
const result = await command.run(options);
|
|
16
|
+
process.exitCode = result;
|
|
17
|
+
});
|
|
18
|
+
application.command("nudge").description("Touch directory timestamps to prompt a refresh").option("-d, --directory <path>", "Directory to refresh", process.cwd()).option("--recursive", "Nudge all subdirectories as well", false).option("--silent", "Do not log any output. Nudge silently", false).option("-e, --every <ms>", "Time between nudges in milliseconds", (v)=>Number.parseInt(v, 10), crumbtrailFs.ZWatchDelay).action(async (options)=>{
|
|
19
|
+
const log = options.silent ? new lumberjackyLog.ZLoggerSilent() : logger;
|
|
20
|
+
const command = new watch.ZCrumbtrailNudge(log);
|
|
21
|
+
process.exitCode = await command.run(options);
|
|
22
|
+
});
|
|
23
|
+
application.parse();
|
|
24
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.cjs","sources":["../src/cli.mts"],"sourcesContent":["import { ZWatchDelay } from \"@zthun/crumbtrail-fs\";\nimport { ZLoggerConsole, ZLoggerSilent } from \"@zthun/lumberjacky-log\";\nimport { Command } from \"commander\";\nimport type { IZCrumbtrailNudgeOptions } from \"./nudge/nudge.mjs\";\nimport { ZCrumbtrailNudge } from \"./nudge/nudge.mjs\";\nimport type { IZCrumbtrailWatchOptions } from \"./watch/watch.mjs\";\nimport { ZCrumbtrailWatch } from \"./watch/watch.mjs\";\n\nconst logger = new ZLoggerConsole(console);\nconst application = new Command();\n\napplication\n .name(\"crumbtrail-cli\")\n .description(\"Crumbtrail utilities for debugging\");\n\napplication\n .command(\"watch\", { isDefault: true })\n .description(\"Watch a directory and log changes\")\n .option(\"-d, --directory <dir>\", \"The directory to watch\", process.cwd())\n .option(\n \"-g, --glob <pattern>\",\n \"Glob pattern (repeatable)\",\n (val, prev: string[]) => prev.concat(val),\n [],\n )\n .action(async (options: IZCrumbtrailWatchOptions) => {\n const command = new ZCrumbtrailWatch(logger);\n const result = await command.run(options);\n process.exitCode = result;\n });\n\napplication\n .command(\"nudge\")\n .description(\"Touch directory timestamps to prompt a refresh\")\n .option(\"-d, --directory <path>\", \"Directory to refresh\", process.cwd())\n .option(\"--recursive\", \"Nudge all subdirectories as well\", false)\n .option(\"--silent\", \"Do not log any output. Nudge silently\", false)\n .option(\n \"-e, --every <ms>\",\n \"Time between nudges in milliseconds\",\n (v) => Number.parseInt(v, 10),\n ZWatchDelay,\n )\n .action(async (options: IZCrumbtrailNudgeOptions & { silent: boolean }) => {\n const log = options.silent ? new ZLoggerSilent() : logger;\n const command = new ZCrumbtrailNudge(log);\n process.exitCode = await command.run(options);\n });\n\napplication.parse();\n"],"names":["logger","ZLoggerConsole","console","application","Command","name","description","command","isDefault","option","process","cwd","val","prev","concat","action","options","ZCrumbtrailWatch","result","run","exitCode","v","Number","parseInt","ZWatchDelay","log","silent","ZLoggerSilent","ZCrumbtrailNudge","parse"],"mappings":";;;;;;;AAQA,MAAMA,MAAAA,GAAS,IAAIC,6BAAAA,CAAeC,OAAAA,CAAAA;AAClC,MAAMC,cAAc,IAAIC,iBAAAA,EAAAA;AAExBD,WAAAA,CACGE,IAAI,CAAC,gBAAA,CAAA,CACLC,WAAW,CAAC,oCAAA,CAAA;AAEfH,WAAAA,CACGI,OAAO,CAAC,OAAA,EAAS;IAAEC,SAAAA,EAAW;AAAK,CAAA,CAAA,CACnCF,WAAW,CAAC,mCAAA,CAAA,CACZG,MAAM,CAAC,yBAAyB,wBAAA,EAA0BC,OAAAA,CAAQC,GAAG,EAAA,CAAA,CACrEF,MAAM,CACL,wBACA,2BAAA,EACA,CAACG,GAAAA,EAAKC,IAAAA,GAAmBA,IAAAA,CAAKC,MAAM,CAACF,GAAAA,CAAAA,EACrC,EAAE,CAAA,CAEHG,MAAM,CAAC,OAAOC,OAAAA,GAAAA;IACb,MAAMT,OAAAA,GAAU,IAAIU,sBAAAA,CAAiBjB,MAAAA,CAAAA;AACrC,IAAA,MAAMkB,MAAAA,GAAS,MAAMX,OAAAA,CAAQY,GAAG,CAACH,OAAAA,CAAAA;AACjCN,IAAAA,OAAAA,CAAQU,QAAQ,GAAGF,MAAAA;AACrB,CAAA,CAAA;AAEFf,WAAAA,CACGI,OAAO,CAAC,OAAA,CAAA,CACRD,WAAW,CAAC,kDACZG,MAAM,CAAC,wBAAA,EAA0B,sBAAA,EAAwBC,QAAQC,GAAG,EAAA,CAAA,CACpEF,MAAM,CAAC,eAAe,kCAAA,EAAoC,KAAA,CAAA,CAC1DA,MAAM,CAAC,YAAY,wCAAA,EAA0C,KAAA,CAAA,CAC7DA,MAAM,CACL,oBACA,qCAAA,EACA,CAACY,CAAAA,GAAMC,MAAAA,CAAOC,QAAQ,CAACF,CAAAA,EAAG,KAC1BG,wBAAAA,CAAAA,CAEDT,MAAM,CAAC,OAAOC,OAAAA,GAAAA;AACb,IAAA,MAAMS,GAAAA,GAAMT,OAAAA,CAAQU,MAAM,GAAG,IAAIC,4BAAAA,EAAAA,GAAkB3B,MAAAA;IACnD,MAAMO,OAAAA,GAAU,IAAIqB,sBAAAA,CAAiBH,GAAAA,CAAAA;AACrCf,IAAAA,OAAAA,CAAQU,QAAQ,GAAG,MAAMb,OAAAA,CAAQY,GAAG,CAACH,OAAAA,CAAAA;AACvC,CAAA,CAAA;AAEFb,WAAAA,CAAY0B,KAAK,EAAA;;"}
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ZWatchDelay } from '@zthun/crumbtrail-fs';
|
|
2
|
+
import { ZLoggerConsole, ZLoggerSilent } from '@zthun/lumberjacky-log';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { a as ZCrumbtrailWatch, Z as ZCrumbtrailNudge } from './watch-DdpcqnOY.js';
|
|
5
|
+
|
|
6
|
+
const logger = new ZLoggerConsole(console);
|
|
7
|
+
const application = new Command();
|
|
8
|
+
application.name("crumbtrail-cli").description("Crumbtrail utilities for debugging");
|
|
9
|
+
application.command("watch", {
|
|
10
|
+
isDefault: true
|
|
11
|
+
}).description("Watch a directory and log changes").option("-d, --directory <dir>", "The directory to watch", process.cwd()).option("-g, --glob <pattern>", "Glob pattern (repeatable)", (val, prev)=>prev.concat(val), []).action(async (options)=>{
|
|
12
|
+
const command = new ZCrumbtrailWatch(logger);
|
|
13
|
+
const result = await command.run(options);
|
|
14
|
+
process.exitCode = result;
|
|
15
|
+
});
|
|
16
|
+
application.command("nudge").description("Touch directory timestamps to prompt a refresh").option("-d, --directory <path>", "Directory to refresh", process.cwd()).option("--recursive", "Nudge all subdirectories as well", false).option("--silent", "Do not log any output. Nudge silently", false).option("-e, --every <ms>", "Time between nudges in milliseconds", (v)=>Number.parseInt(v, 10), ZWatchDelay).action(async (options)=>{
|
|
17
|
+
const log = options.silent ? new ZLoggerSilent() : logger;
|
|
18
|
+
const command = new ZCrumbtrailNudge(log);
|
|
19
|
+
process.exitCode = await command.run(options);
|
|
20
|
+
});
|
|
21
|
+
application.parse();
|
|
22
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.mts"],"sourcesContent":["import { ZWatchDelay } from \"@zthun/crumbtrail-fs\";\nimport { ZLoggerConsole, ZLoggerSilent } from \"@zthun/lumberjacky-log\";\nimport { Command } from \"commander\";\nimport type { IZCrumbtrailNudgeOptions } from \"./nudge/nudge.mjs\";\nimport { ZCrumbtrailNudge } from \"./nudge/nudge.mjs\";\nimport type { IZCrumbtrailWatchOptions } from \"./watch/watch.mjs\";\nimport { ZCrumbtrailWatch } from \"./watch/watch.mjs\";\n\nconst logger = new ZLoggerConsole(console);\nconst application = new Command();\n\napplication\n .name(\"crumbtrail-cli\")\n .description(\"Crumbtrail utilities for debugging\");\n\napplication\n .command(\"watch\", { isDefault: true })\n .description(\"Watch a directory and log changes\")\n .option(\"-d, --directory <dir>\", \"The directory to watch\", process.cwd())\n .option(\n \"-g, --glob <pattern>\",\n \"Glob pattern (repeatable)\",\n (val, prev: string[]) => prev.concat(val),\n [],\n )\n .action(async (options: IZCrumbtrailWatchOptions) => {\n const command = new ZCrumbtrailWatch(logger);\n const result = await command.run(options);\n process.exitCode = result;\n });\n\napplication\n .command(\"nudge\")\n .description(\"Touch directory timestamps to prompt a refresh\")\n .option(\"-d, --directory <path>\", \"Directory to refresh\", process.cwd())\n .option(\"--recursive\", \"Nudge all subdirectories as well\", false)\n .option(\"--silent\", \"Do not log any output. Nudge silently\", false)\n .option(\n \"-e, --every <ms>\",\n \"Time between nudges in milliseconds\",\n (v) => Number.parseInt(v, 10),\n ZWatchDelay,\n )\n .action(async (options: IZCrumbtrailNudgeOptions & { silent: boolean }) => {\n const log = options.silent ? new ZLoggerSilent() : logger;\n const command = new ZCrumbtrailNudge(log);\n process.exitCode = await command.run(options);\n });\n\napplication.parse();\n"],"names":["logger","ZLoggerConsole","console","application","Command","name","description","command","isDefault","option","process","cwd","val","prev","concat","action","options","ZCrumbtrailWatch","result","run","exitCode","v","Number","parseInt","ZWatchDelay","log","silent","ZLoggerSilent","ZCrumbtrailNudge","parse"],"mappings":";;;;;AAQA,MAAMA,MAAAA,GAAS,IAAIC,cAAAA,CAAeC,OAAAA,CAAAA;AAClC,MAAMC,cAAc,IAAIC,OAAAA,EAAAA;AAExBD,WAAAA,CACGE,IAAI,CAAC,gBAAA,CAAA,CACLC,WAAW,CAAC,oCAAA,CAAA;AAEfH,WAAAA,CACGI,OAAO,CAAC,OAAA,EAAS;IAAEC,SAAAA,EAAW;AAAK,CAAA,CAAA,CACnCF,WAAW,CAAC,mCAAA,CAAA,CACZG,MAAM,CAAC,yBAAyB,wBAAA,EAA0BC,OAAAA,CAAQC,GAAG,EAAA,CAAA,CACrEF,MAAM,CACL,wBACA,2BAAA,EACA,CAACG,GAAAA,EAAKC,IAAAA,GAAmBA,IAAAA,CAAKC,MAAM,CAACF,GAAAA,CAAAA,EACrC,EAAE,CAAA,CAEHG,MAAM,CAAC,OAAOC,OAAAA,GAAAA;IACb,MAAMT,OAAAA,GAAU,IAAIU,gBAAAA,CAAiBjB,MAAAA,CAAAA;AACrC,IAAA,MAAMkB,MAAAA,GAAS,MAAMX,OAAAA,CAAQY,GAAG,CAACH,OAAAA,CAAAA;AACjCN,IAAAA,OAAAA,CAAQU,QAAQ,GAAGF,MAAAA;AACrB,CAAA,CAAA;AAEFf,WAAAA,CACGI,OAAO,CAAC,OAAA,CAAA,CACRD,WAAW,CAAC,kDACZG,MAAM,CAAC,wBAAA,EAA0B,sBAAA,EAAwBC,QAAQC,GAAG,EAAA,CAAA,CACpEF,MAAM,CAAC,eAAe,kCAAA,EAAoC,KAAA,CAAA,CAC1DA,MAAM,CAAC,YAAY,wCAAA,EAA0C,KAAA,CAAA,CAC7DA,MAAM,CACL,oBACA,qCAAA,EACA,CAACY,CAAAA,GAAMC,MAAAA,CAAOC,QAAQ,CAACF,CAAAA,EAAG,KAC1BG,WAAAA,CAAAA,CAEDT,MAAM,CAAC,OAAOC,OAAAA,GAAAA;AACb,IAAA,MAAMS,GAAAA,GAAMT,OAAAA,CAAQU,MAAM,GAAG,IAAIC,aAAAA,EAAAA,GAAkB3B,MAAAA;IACnD,MAAMO,OAAAA,GAAU,IAAIqB,gBAAAA,CAAiBH,GAAAA,CAAAA;AACrCf,IAAAA,OAAAA,CAAQU,QAAQ,GAAG,MAAMb,OAAAA,CAAQY,GAAG,CAACH,OAAAA,CAAAA;AACvC,CAAA,CAAA;AAEFb,WAAAA,CAAY0B,KAAK,EAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const watch = require('./watch-C-6Gf4uc.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.ZCrumbtrailNudge = watch.ZCrumbtrailNudge;
|
|
10
|
+
exports.ZCrumbtrailWatch = watch.ZCrumbtrailWatch;
|
|
11
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/dist/index.d.mts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IZLogger } from '@zthun/lumberjacky-log';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the nudge command.
|
|
4
|
+
*/
|
|
5
|
+
export interface IZCrumbtrailNudgeOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The directory to nudge.
|
|
8
|
+
*
|
|
9
|
+
* The default if not specified is the current working directory.
|
|
10
|
+
*/
|
|
11
|
+
directory?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to nudge recursively.
|
|
14
|
+
*
|
|
15
|
+
* Warning: This can have severe CPU
|
|
16
|
+
* usage for deep directories.
|
|
17
|
+
*
|
|
18
|
+
* Default is false.
|
|
19
|
+
*/
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The total number of milliseconds to wait
|
|
23
|
+
* between nudges.
|
|
24
|
+
*
|
|
25
|
+
* Default is {@link ZWatchDelay}
|
|
26
|
+
*/
|
|
27
|
+
every?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* An operation to continuously nudge a directory.
|
|
31
|
+
*
|
|
32
|
+
* This is a special operation that lists the contents of a targeted parent directory.
|
|
33
|
+
* The main reason for this is to work around an issue when you are running inside of
|
|
34
|
+
* a container and your host is not linux.
|
|
35
|
+
*
|
|
36
|
+
* A lot of times, you will not receive events in this situation for add and update
|
|
37
|
+
* until the virtual file bridge is refreshed by listing the outer directory contents.
|
|
38
|
+
* This command helps to force the bridge to send file change events. You should
|
|
39
|
+
* only need this if you are running on a non linux host inside a docker container.
|
|
40
|
+
*
|
|
41
|
+
* Run a separate container in the background and just nudge the directory
|
|
42
|
+
* for however long you need.
|
|
43
|
+
*/
|
|
44
|
+
export declare class ZCrumbtrailNudge {
|
|
45
|
+
private _controller?;
|
|
46
|
+
private _resolve?;
|
|
47
|
+
private _promise?;
|
|
48
|
+
private readonly _logger;
|
|
49
|
+
constructor(logger: IZLogger);
|
|
50
|
+
kill(): Promise<void>;
|
|
51
|
+
run(options?: IZCrumbtrailNudgeOptions): Promise<number>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { IZLogEntry, IZLogger } from '@zthun/lumberjacky-log';
|
|
2
|
+
/**
|
|
3
|
+
* Arguments for the crumbtrail app.
|
|
4
|
+
*/
|
|
5
|
+
export interface IZCrumbtrailWatchOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The directory to watch.
|
|
8
|
+
*
|
|
9
|
+
* If this is falsy, then the cwd is used.
|
|
10
|
+
*/
|
|
11
|
+
directory?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The list of file globs to watch.
|
|
14
|
+
*
|
|
15
|
+
* If this is falsy or empty, then '**' is used.
|
|
16
|
+
*/
|
|
17
|
+
globs?: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The root application for the crumbtrail cli.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ZCrumbtrailWatch {
|
|
23
|
+
private _logger;
|
|
24
|
+
private _globs;
|
|
25
|
+
private _watch;
|
|
26
|
+
private _ready;
|
|
27
|
+
private _promise;
|
|
28
|
+
private _resolve;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the entry for a basic information message.
|
|
31
|
+
*
|
|
32
|
+
* @returns
|
|
33
|
+
* The log entry for a basic information message.
|
|
34
|
+
*/
|
|
35
|
+
static msg(msg: string): IZLogEntry;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the message for when a file is added.
|
|
38
|
+
*
|
|
39
|
+
* @returns
|
|
40
|
+
* The message for when a file is added.
|
|
41
|
+
*/
|
|
42
|
+
static add(path: string): IZLogEntry;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the message for when a file/folder is removed.
|
|
45
|
+
*
|
|
46
|
+
* @returns
|
|
47
|
+
* The message for when a file/folder is added.
|
|
48
|
+
*/
|
|
49
|
+
static remove(path: string): IZLogEntry;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the message for when a file is updated.
|
|
52
|
+
*
|
|
53
|
+
* @returns
|
|
54
|
+
* The message for when a file is updated.
|
|
55
|
+
*/
|
|
56
|
+
static update(path: string): IZLogEntry;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the current directory being watched.
|
|
59
|
+
*
|
|
60
|
+
* @returns
|
|
61
|
+
* The directory that is watching for events.
|
|
62
|
+
*/
|
|
63
|
+
watching(): Promise<string | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the list of globs that filter the directory contents.
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
* The list of globs that filter the directory contents.
|
|
69
|
+
*/
|
|
70
|
+
globs(): Promise<string[] | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns a promise that can be awaited on to
|
|
73
|
+
* make sure the watch is initialized.
|
|
74
|
+
*/
|
|
75
|
+
ready(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Initializes a new instance of this object.
|
|
78
|
+
*
|
|
79
|
+
* @param logger -
|
|
80
|
+
* The logger to use to output events.
|
|
81
|
+
*/
|
|
82
|
+
constructor(logger: IZLogger);
|
|
83
|
+
/**
|
|
84
|
+
* Kills the application.
|
|
85
|
+
*/
|
|
86
|
+
kill(): Promise<void>;
|
|
87
|
+
private _handleFsEvent;
|
|
88
|
+
private _handleAdd;
|
|
89
|
+
private _handleRemove;
|
|
90
|
+
private _handleUpdate;
|
|
91
|
+
/**
|
|
92
|
+
* Runs the application.
|
|
93
|
+
*
|
|
94
|
+
* @param args -
|
|
95
|
+
* The application arguments.
|
|
96
|
+
*
|
|
97
|
+
* @returns
|
|
98
|
+
* The process exit code.
|
|
99
|
+
*/
|
|
100
|
+
run(args?: IZCrumbtrailWatchOptions): Promise<number>;
|
|
101
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crumbtrailFs = require('@zthun/crumbtrail-fs');
|
|
4
|
+
const helpfulFn = require('@zthun/helpful-fn');
|
|
5
|
+
const lumberjackyLog = require('@zthun/lumberjacky-log');
|
|
6
|
+
const glob = require('fast-glob');
|
|
7
|
+
const lodashEs = require('lodash-es');
|
|
8
|
+
const promises = require('node:fs/promises');
|
|
9
|
+
const node_path = require('node:path');
|
|
10
|
+
const minimatch = require('minimatch');
|
|
11
|
+
const node_process = require('node:process');
|
|
12
|
+
|
|
13
|
+
function _define_property$1(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* An operation to continuously nudge a directory.
|
|
28
|
+
*
|
|
29
|
+
* This is a special operation that lists the contents of a targeted parent directory.
|
|
30
|
+
* The main reason for this is to work around an issue when you are running inside of
|
|
31
|
+
* a container and your host is not linux.
|
|
32
|
+
*
|
|
33
|
+
* A lot of times, you will not receive events in this situation for add and update
|
|
34
|
+
* until the virtual file bridge is refreshed by listing the outer directory contents.
|
|
35
|
+
* This command helps to force the bridge to send file change events. You should
|
|
36
|
+
* only need this if you are running on a non linux host inside a docker container.
|
|
37
|
+
*
|
|
38
|
+
* Run a separate container in the background and just nudge the directory
|
|
39
|
+
* for however long you need.
|
|
40
|
+
*/ class ZCrumbtrailNudge {
|
|
41
|
+
async kill() {
|
|
42
|
+
this._controller?.abort();
|
|
43
|
+
delete this._controller;
|
|
44
|
+
await this._promise;
|
|
45
|
+
delete this._promise;
|
|
46
|
+
}
|
|
47
|
+
async run(options = {}) {
|
|
48
|
+
await this.kill();
|
|
49
|
+
const controller = new AbortController();
|
|
50
|
+
this._controller = controller;
|
|
51
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
52
|
+
this._promise = promise;
|
|
53
|
+
this._resolve = resolve;
|
|
54
|
+
const { directory = process.cwd(), recursive, every = crumbtrailFs.ZWatchDelay } = options;
|
|
55
|
+
const ms = helpfulFn.firstTruthy(crumbtrailFs.ZWatchDelay, every);
|
|
56
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(`Starting a nudge loop every ${ms} milliseconds`).build());
|
|
57
|
+
if (recursive) {
|
|
58
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().warning().message("Nudging is recursive. Child folders will be nudged too.").build());
|
|
59
|
+
}
|
|
60
|
+
do {
|
|
61
|
+
this._logger.log(new lumberjackyLog.ZLogEntryBuilder().info().message(`Nudging ${directory} to refresh`).build());
|
|
62
|
+
await promises.readdir(node_path.dirname(directory)).catch(lodashEs.noop);
|
|
63
|
+
if (recursive) {
|
|
64
|
+
await glob(`${directory}/**`, {
|
|
65
|
+
onlyDirectories: true
|
|
66
|
+
}).catch(lodashEs.noop);
|
|
67
|
+
}
|
|
68
|
+
await helpfulFn.sleep(ms);
|
|
69
|
+
}while (!controller.signal.aborted)
|
|
70
|
+
resolve(0);
|
|
71
|
+
delete this._resolve;
|
|
72
|
+
return this._promise;
|
|
73
|
+
}
|
|
74
|
+
constructor(logger){
|
|
75
|
+
_define_property$1(this, "_controller", void 0);
|
|
76
|
+
_define_property$1(this, "_resolve", void 0);
|
|
77
|
+
_define_property$1(this, "_promise", void 0);
|
|
78
|
+
_define_property$1(this, "_logger", void 0);
|
|
79
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZCrumbtrailNudge", logger);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _define_property(obj, key, value) {
|
|
84
|
+
if (key in obj) {
|
|
85
|
+
Object.defineProperty(obj, key, {
|
|
86
|
+
value: value,
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
obj[key] = value;
|
|
93
|
+
}
|
|
94
|
+
return obj;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The root application for the crumbtrail cli.
|
|
98
|
+
*/ class ZCrumbtrailWatch {
|
|
99
|
+
/**
|
|
100
|
+
* Gets the entry for a basic information message.
|
|
101
|
+
*
|
|
102
|
+
* @returns
|
|
103
|
+
* The log entry for a basic information message.
|
|
104
|
+
*/ static msg(msg) {
|
|
105
|
+
return new lumberjackyLog.ZLogEntryBuilder().info().message(msg).build();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Gets the message for when a file is added.
|
|
109
|
+
*
|
|
110
|
+
* @returns
|
|
111
|
+
* The message for when a file is added.
|
|
112
|
+
*/ static add(path) {
|
|
113
|
+
return new lumberjackyLog.ZLogEntryBuilder().info().message(`Node added: ${path}`).build();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the message for when a file/folder is removed.
|
|
117
|
+
*
|
|
118
|
+
* @returns
|
|
119
|
+
* The message for when a file/folder is added.
|
|
120
|
+
*/ static remove(path) {
|
|
121
|
+
return new lumberjackyLog.ZLogEntryBuilder().warning().message(`Node removed: ${path}`).build();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gets the message for when a file is updated.
|
|
125
|
+
*
|
|
126
|
+
* @returns
|
|
127
|
+
* The message for when a file is updated.
|
|
128
|
+
*/ static update(path) {
|
|
129
|
+
return new lumberjackyLog.ZLogEntryBuilder().info().message(`Node updated: ${path}`).build();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Gets the current directory being watched.
|
|
133
|
+
*
|
|
134
|
+
* @returns
|
|
135
|
+
* The directory that is watching for events.
|
|
136
|
+
*/ watching() {
|
|
137
|
+
return Promise.resolve(this._watch?.path);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Gets the list of globs that filter the directory contents.
|
|
141
|
+
*
|
|
142
|
+
* @returns
|
|
143
|
+
* The list of globs that filter the directory contents.
|
|
144
|
+
*/ globs() {
|
|
145
|
+
return Promise.resolve(this._globs?.slice());
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns a promise that can be awaited on to
|
|
149
|
+
* make sure the watch is initialized.
|
|
150
|
+
*/ async ready() {
|
|
151
|
+
return this._ready;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Kills the application.
|
|
155
|
+
*/ async kill() {
|
|
156
|
+
await this._watch?.stop();
|
|
157
|
+
delete this._watch;
|
|
158
|
+
delete this._globs;
|
|
159
|
+
this._ready = Promise.resolve();
|
|
160
|
+
this._resolve?.(0);
|
|
161
|
+
await this._promise;
|
|
162
|
+
delete this._promise;
|
|
163
|
+
}
|
|
164
|
+
_handleFsEvent(path, entry) {
|
|
165
|
+
const globs = helpfulFn.firstDefined([
|
|
166
|
+
"**"
|
|
167
|
+
], this._globs);
|
|
168
|
+
const directory = helpfulFn.firstDefined(node_process.cwd(), this._watch?.path);
|
|
169
|
+
if (globs?.some((g)=>minimatch.minimatch(path, node_path.resolve(directory, g)))) {
|
|
170
|
+
this._logger.log(entry);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
_handleAdd(node) {
|
|
174
|
+
const { add } = ZCrumbtrailWatch;
|
|
175
|
+
this._handleFsEvent(node.path, add(node.path));
|
|
176
|
+
}
|
|
177
|
+
_handleRemove(node) {
|
|
178
|
+
const { remove } = ZCrumbtrailWatch;
|
|
179
|
+
this._handleFsEvent(node.path, remove(node.path));
|
|
180
|
+
}
|
|
181
|
+
_handleUpdate(node) {
|
|
182
|
+
const { update } = ZCrumbtrailWatch;
|
|
183
|
+
this._handleFsEvent(node.path, update(node.path));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Runs the application.
|
|
187
|
+
*
|
|
188
|
+
* @param args -
|
|
189
|
+
* The application arguments.
|
|
190
|
+
*
|
|
191
|
+
* @returns
|
|
192
|
+
* The process exit code.
|
|
193
|
+
*/ async run(args = {}) {
|
|
194
|
+
if (this._promise) {
|
|
195
|
+
return this._promise;
|
|
196
|
+
}
|
|
197
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
198
|
+
this._resolve = resolve;
|
|
199
|
+
this._promise = promise;
|
|
200
|
+
const { msg } = ZCrumbtrailWatch;
|
|
201
|
+
const { directory = node_process.cwd(), globs = [
|
|
202
|
+
"**"
|
|
203
|
+
] } = args;
|
|
204
|
+
this._globs = lodashEs.uniq(globs.slice());
|
|
205
|
+
this._globs = this._globs.length ? this._globs : [
|
|
206
|
+
"**"
|
|
207
|
+
];
|
|
208
|
+
this._watch = new crumbtrailFs.ZFileWatch(directory);
|
|
209
|
+
const filter = globs.join(",");
|
|
210
|
+
this._logger.log(msg("Welcome to Crumbtrail CLI"));
|
|
211
|
+
this._logger.log(msg(`You are now watching ${directory}`));
|
|
212
|
+
this._logger.log(msg(`Files that match ${filter} will be logged here.`));
|
|
213
|
+
this._logger.log(msg("Press Ctrl+C to stop watching"));
|
|
214
|
+
this._watch.add().subscribe(this._handleAdd.bind(this));
|
|
215
|
+
this._watch.remove().subscribe(this._handleRemove.bind(this));
|
|
216
|
+
this._watch.update().subscribe(this._handleUpdate.bind(this));
|
|
217
|
+
this._ready = this._watch.start();
|
|
218
|
+
await this._ready;
|
|
219
|
+
return this._promise;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Initializes a new instance of this object.
|
|
223
|
+
*
|
|
224
|
+
* @param logger -
|
|
225
|
+
* The logger to use to output events.
|
|
226
|
+
*/ constructor(logger){
|
|
227
|
+
_define_property(this, "_logger", void 0);
|
|
228
|
+
_define_property(this, "_globs", void 0);
|
|
229
|
+
_define_property(this, "_watch", void 0);
|
|
230
|
+
_define_property(this, "_ready", Promise.resolve());
|
|
231
|
+
_define_property(this, "_promise", void 0);
|
|
232
|
+
_define_property(this, "_resolve", void 0);
|
|
233
|
+
this._logger = new lumberjackyLog.ZLoggerContext("ZCrumbtrailApp", logger);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
exports.ZCrumbtrailNudge = ZCrumbtrailNudge;
|
|
238
|
+
exports.ZCrumbtrailWatch = ZCrumbtrailWatch;
|
|
239
|
+
//# sourceMappingURL=watch-C-6Gf4uc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-C-6Gf4uc.cjs","sources":["../src/nudge/nudge.mts","../src/watch/watch.mts"],"sourcesContent":["import { ZWatchDelay } from \"@zthun/crumbtrail-fs\";\nimport { firstTruthy, sleep } from \"@zthun/helpful-fn\";\nimport type { IZLogger } from \"@zthun/lumberjacky-log\";\nimport { ZLogEntryBuilder, ZLoggerContext } from \"@zthun/lumberjacky-log\";\nimport glob from \"fast-glob\";\nimport { noop } from \"lodash-es\";\nimport { readdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\n/**\n * Options for the nudge command.\n */\nexport interface IZCrumbtrailNudgeOptions {\n /**\n * The directory to nudge.\n *\n * The default if not specified is the current working directory.\n */\n directory?: string;\n\n /**\n * Whether to nudge recursively.\n *\n * Warning: This can have severe CPU\n * usage for deep directories.\n *\n * Default is false.\n */\n recursive?: boolean;\n\n /**\n * The total number of milliseconds to wait\n * between nudges.\n *\n * Default is {@link ZWatchDelay}\n */\n every?: number;\n}\n\n/**\n * An operation to continuously nudge a directory.\n *\n * This is a special operation that lists the contents of a targeted parent directory.\n * The main reason for this is to work around an issue when you are running inside of\n * a container and your host is not linux.\n *\n * A lot of times, you will not receive events in this situation for add and update\n * until the virtual file bridge is refreshed by listing the outer directory contents.\n * This command helps to force the bridge to send file change events. You should\n * only need this if you are running on a non linux host inside a docker container.\n *\n * Run a separate container in the background and just nudge the directory\n * for however long you need.\n */\nexport class ZCrumbtrailNudge {\n private _controller?: AbortController;\n private _resolve?: (val: number) => void;\n private _promise?: Promise<number>;\n private readonly _logger: IZLogger;\n\n public constructor(logger: IZLogger) {\n this._logger = new ZLoggerContext(\"ZCrumbtrailNudge\", logger);\n }\n\n public async kill(): Promise<void> {\n this._controller?.abort();\n delete this._controller;\n\n await this._promise;\n delete this._promise;\n }\n\n public async run(options: IZCrumbtrailNudgeOptions = {}): Promise<number> {\n await this.kill();\n\n const controller = new AbortController();\n this._controller = controller;\n\n const { promise, resolve } = Promise.withResolvers<number>();\n this._promise = promise;\n this._resolve = resolve;\n\n const {\n directory = process.cwd(),\n recursive,\n every = ZWatchDelay,\n } = options;\n\n const ms = firstTruthy(ZWatchDelay, every);\n\n this._logger.log(\n new ZLogEntryBuilder()\n .info()\n .message(`Starting a nudge loop every ${ms} milliseconds`)\n .build(),\n );\n\n if (recursive) {\n this._logger.log(\n new ZLogEntryBuilder()\n .warning()\n .message(\"Nudging is recursive. Child folders will be nudged too.\")\n .build(),\n );\n }\n\n do {\n this._logger.log(\n new ZLogEntryBuilder()\n .info()\n .message(`Nudging ${directory} to refresh`)\n .build(),\n );\n await readdir(dirname(directory)).catch(noop);\n\n if (recursive) {\n await glob(`${directory}/**`, { onlyDirectories: true }).catch(noop);\n }\n\n await sleep(ms);\n } while (!controller.signal.aborted);\n\n resolve(0);\n delete this._resolve;\n\n return this._promise;\n }\n}\n","import type { IZFileSystemNode } from \"@zthun/crumbtrail-fs\";\nimport { ZFileWatch } from \"@zthun/crumbtrail-fs\";\nimport { firstDefined } from \"@zthun/helpful-fn\";\nimport type { IZLogEntry, IZLogger } from \"@zthun/lumberjacky-log\";\nimport { ZLogEntryBuilder, ZLoggerContext } from \"@zthun/lumberjacky-log\";\nimport { uniq } from \"lodash-es\";\nimport { minimatch } from \"minimatch\";\nimport { resolve } from \"node:path\";\nimport { cwd } from \"node:process\";\n\n/**\n * Arguments for the crumbtrail app.\n */\nexport interface IZCrumbtrailWatchOptions {\n /**\n * The directory to watch.\n *\n * If this is falsy, then the cwd is used.\n */\n directory?: string;\n\n /**\n * The list of file globs to watch.\n *\n * If this is falsy or empty, then '**' is used.\n */\n globs?: string[];\n}\n\n/**\n * The root application for the crumbtrail cli.\n */\nexport class ZCrumbtrailWatch {\n private _logger: IZLogger;\n private _globs: string[] | undefined;\n private _watch: ZFileWatch | undefined;\n private _ready: Promise<void> = Promise.resolve();\n private _promise: Promise<number> | undefined;\n private _resolve: ((value: number) => void) | undefined;\n\n /**\n * Gets the entry for a basic information message.\n *\n * @returns\n * The log entry for a basic information message.\n */\n public static msg(msg: string): IZLogEntry {\n return new ZLogEntryBuilder().info().message(msg).build();\n }\n\n /**\n * Gets the message for when a file is added.\n *\n * @returns\n * The message for when a file is added.\n */\n public static add(path: string): IZLogEntry {\n return new ZLogEntryBuilder().info().message(`Node added: ${path}`).build();\n }\n\n /**\n * Gets the message for when a file/folder is removed.\n *\n * @returns\n * The message for when a file/folder is added.\n */\n public static remove(path: string): IZLogEntry {\n return new ZLogEntryBuilder()\n .warning()\n .message(`Node removed: ${path}`)\n .build();\n }\n\n /**\n * Gets the message for when a file is updated.\n *\n * @returns\n * The message for when a file is updated.\n */\n public static update(path: string): IZLogEntry {\n return new ZLogEntryBuilder()\n .info()\n .message(`Node updated: ${path}`)\n .build();\n }\n\n /**\n * Gets the current directory being watched.\n *\n * @returns\n * The directory that is watching for events.\n */\n public watching() {\n return Promise.resolve(this._watch?.path);\n }\n\n /**\n * Gets the list of globs that filter the directory contents.\n *\n * @returns\n * The list of globs that filter the directory contents.\n */\n public globs() {\n return Promise.resolve(this._globs?.slice());\n }\n\n /**\n * Returns a promise that can be awaited on to\n * make sure the watch is initialized.\n */\n public async ready() {\n return this._ready;\n }\n\n /**\n * Initializes a new instance of this object.\n *\n * @param logger -\n * The logger to use to output events.\n */\n public constructor(logger: IZLogger) {\n this._logger = new ZLoggerContext(\"ZCrumbtrailApp\", logger);\n }\n\n /**\n * Kills the application.\n */\n public async kill(): Promise<void> {\n await this._watch?.stop();\n\n delete this._watch;\n delete this._globs;\n this._ready = Promise.resolve();\n\n this._resolve?.(0);\n await this._promise;\n delete this._promise;\n }\n\n private _handleFsEvent(path: string, entry: IZLogEntry) {\n const globs = firstDefined([\"**\"], this._globs);\n const directory = firstDefined(cwd(), this._watch?.path);\n\n if (globs?.some((g) => minimatch(path, resolve(directory, g)))) {\n this._logger.log(entry);\n }\n }\n\n private _handleAdd(node: IZFileSystemNode) {\n const { add } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, add(node.path));\n }\n\n private _handleRemove(node: IZFileSystemNode) {\n const { remove } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, remove(node.path));\n }\n\n private _handleUpdate(node: IZFileSystemNode) {\n const { update } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, update(node.path));\n }\n\n /**\n * Runs the application.\n *\n * @param args -\n * The application arguments.\n *\n * @returns\n * The process exit code.\n */\n public async run(args: IZCrumbtrailWatchOptions = {}): Promise<number> {\n if (this._promise) {\n return this._promise;\n }\n\n const { promise, resolve } = Promise.withResolvers<number>();\n this._resolve = resolve;\n this._promise = promise;\n\n const { msg } = ZCrumbtrailWatch;\n const { directory = cwd(), globs = [\"**\"] } = args;\n\n this._globs = uniq(globs.slice());\n this._globs = this._globs.length ? this._globs : [\"**\"];\n this._watch = new ZFileWatch(directory);\n\n const filter = globs.join(\",\");\n this._logger.log(msg(\"Welcome to Crumbtrail CLI\"));\n this._logger.log(msg(`You are now watching ${directory}`));\n this._logger.log(msg(`Files that match ${filter} will be logged here.`));\n this._logger.log(msg(\"Press Ctrl+C to stop watching\"));\n\n this._watch.add().subscribe(this._handleAdd.bind(this));\n this._watch.remove().subscribe(this._handleRemove.bind(this));\n this._watch.update().subscribe(this._handleUpdate.bind(this));\n\n this._ready = this._watch.start();\n await this._ready;\n\n return this._promise;\n }\n}\n"],"names":["ZCrumbtrailNudge","kill","_controller","abort","_promise","run","options","controller","AbortController","promise","resolve","Promise","withResolvers","_resolve","directory","process","cwd","recursive","every","ZWatchDelay","ms","firstTruthy","_logger","log","ZLogEntryBuilder","info","message","build","warning","readdir","dirname","catch","noop","glob","onlyDirectories","sleep","signal","aborted","logger","_define_property","ZLoggerContext","ZCrumbtrailWatch","msg","add","path","remove","update","watching","_watch","globs","_globs","slice","ready","_ready","stop","_handleFsEvent","entry","firstDefined","some","g","minimatch","_handleAdd","node","_handleRemove","_handleUpdate","args","uniq","length","ZFileWatch","filter","join","subscribe","bind","start"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;AAcC,IACM,MAAMA,gBAAAA,CAAAA;AAUX,IAAA,MAAaC,IAAAA,GAAsB;QACjC,IAAI,CAACC,WAAW,EAAEC,KAAAA,EAAAA;QAClB,OAAO,IAAI,CAACD,WAAW;QAEvB,MAAM,IAAI,CAACE,QAAQ;QACnB,OAAO,IAAI,CAACA,QAAQ;AACtB,IAAA;AAEA,IAAA,MAAaC,GAAAA,CAAIC,OAAAA,GAAoC,EAAE,EAAmB;QACxE,MAAM,IAAI,CAACL,IAAI,EAAA;AAEf,QAAA,MAAMM,aAAa,IAAIC,eAAAA,EAAAA;QACvB,IAAI,CAACN,WAAW,GAAGK,UAAAA;AAEnB,QAAA,MAAM,EAAEE,OAAO,EAAEC,OAAO,EAAE,GAAGC,QAAQC,aAAa,EAAA;QAClD,IAAI,CAACR,QAAQ,GAAGK,OAAAA;QAChB,IAAI,CAACI,QAAQ,GAAGH,OAAAA;QAEhB,MAAM,EACJI,SAAAA,GAAYC,OAAAA,CAAQC,GAAG,EAAE,EACzBC,SAAS,EACTC,KAAAA,GAAQC,wBAAW,EACpB,GAAGb,OAAAA;QAEJ,MAAMc,EAAAA,GAAKC,sBAAYF,wBAAAA,EAAaD,KAAAA,CAAAA;AAEpC,QAAA,IAAI,CAACI,OAAO,CAACC,GA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AAA,CAAA;AAmFE,QAAA,IAAI,CAACS,OAAO,GAAG,IAAIkB,8BAAe,gBAAA,EAAkBF,MAAAA,CAAAA;AACtD,IAAA;AAiFF;;;;;"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ZWatchDelay, ZFileWatch } from '@zthun/crumbtrail-fs';
|
|
2
|
+
import { firstTruthy, sleep, firstDefined } from '@zthun/helpful-fn';
|
|
3
|
+
import { ZLogEntryBuilder, ZLoggerContext } from '@zthun/lumberjacky-log';
|
|
4
|
+
import glob from 'fast-glob';
|
|
5
|
+
import { noop, uniq } from 'lodash-es';
|
|
6
|
+
import { readdir } from 'node:fs/promises';
|
|
7
|
+
import { dirname, resolve } from 'node:path';
|
|
8
|
+
import { minimatch } from 'minimatch';
|
|
9
|
+
import { cwd } from 'node:process';
|
|
10
|
+
|
|
11
|
+
function _define_property$1(obj, key, value) {
|
|
12
|
+
if (key in obj) {
|
|
13
|
+
Object.defineProperty(obj, key, {
|
|
14
|
+
value: value,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
obj[key] = value;
|
|
21
|
+
}
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An operation to continuously nudge a directory.
|
|
26
|
+
*
|
|
27
|
+
* This is a special operation that lists the contents of a targeted parent directory.
|
|
28
|
+
* The main reason for this is to work around an issue when you are running inside of
|
|
29
|
+
* a container and your host is not linux.
|
|
30
|
+
*
|
|
31
|
+
* A lot of times, you will not receive events in this situation for add and update
|
|
32
|
+
* until the virtual file bridge is refreshed by listing the outer directory contents.
|
|
33
|
+
* This command helps to force the bridge to send file change events. You should
|
|
34
|
+
* only need this if you are running on a non linux host inside a docker container.
|
|
35
|
+
*
|
|
36
|
+
* Run a separate container in the background and just nudge the directory
|
|
37
|
+
* for however long you need.
|
|
38
|
+
*/ class ZCrumbtrailNudge {
|
|
39
|
+
async kill() {
|
|
40
|
+
this._controller?.abort();
|
|
41
|
+
delete this._controller;
|
|
42
|
+
await this._promise;
|
|
43
|
+
delete this._promise;
|
|
44
|
+
}
|
|
45
|
+
async run(options = {}) {
|
|
46
|
+
await this.kill();
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
this._controller = controller;
|
|
49
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
50
|
+
this._promise = promise;
|
|
51
|
+
this._resolve = resolve;
|
|
52
|
+
const { directory = process.cwd(), recursive, every = ZWatchDelay } = options;
|
|
53
|
+
const ms = firstTruthy(ZWatchDelay, every);
|
|
54
|
+
this._logger.log(new ZLogEntryBuilder().info().message(`Starting a nudge loop every ${ms} milliseconds`).build());
|
|
55
|
+
if (recursive) {
|
|
56
|
+
this._logger.log(new ZLogEntryBuilder().warning().message("Nudging is recursive. Child folders will be nudged too.").build());
|
|
57
|
+
}
|
|
58
|
+
do {
|
|
59
|
+
this._logger.log(new ZLogEntryBuilder().info().message(`Nudging ${directory} to refresh`).build());
|
|
60
|
+
await readdir(dirname(directory)).catch(noop);
|
|
61
|
+
if (recursive) {
|
|
62
|
+
await glob(`${directory}/**`, {
|
|
63
|
+
onlyDirectories: true
|
|
64
|
+
}).catch(noop);
|
|
65
|
+
}
|
|
66
|
+
await sleep(ms);
|
|
67
|
+
}while (!controller.signal.aborted)
|
|
68
|
+
resolve(0);
|
|
69
|
+
delete this._resolve;
|
|
70
|
+
return this._promise;
|
|
71
|
+
}
|
|
72
|
+
constructor(logger){
|
|
73
|
+
_define_property$1(this, "_controller", void 0);
|
|
74
|
+
_define_property$1(this, "_resolve", void 0);
|
|
75
|
+
_define_property$1(this, "_promise", void 0);
|
|
76
|
+
_define_property$1(this, "_logger", void 0);
|
|
77
|
+
this._logger = new ZLoggerContext("ZCrumbtrailNudge", logger);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _define_property(obj, key, value) {
|
|
82
|
+
if (key in obj) {
|
|
83
|
+
Object.defineProperty(obj, key, {
|
|
84
|
+
value: value,
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
obj[key] = value;
|
|
91
|
+
}
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The root application for the crumbtrail cli.
|
|
96
|
+
*/ class ZCrumbtrailWatch {
|
|
97
|
+
/**
|
|
98
|
+
* Gets the entry for a basic information message.
|
|
99
|
+
*
|
|
100
|
+
* @returns
|
|
101
|
+
* The log entry for a basic information message.
|
|
102
|
+
*/ static msg(msg) {
|
|
103
|
+
return new ZLogEntryBuilder().info().message(msg).build();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Gets the message for when a file is added.
|
|
107
|
+
*
|
|
108
|
+
* @returns
|
|
109
|
+
* The message for when a file is added.
|
|
110
|
+
*/ static add(path) {
|
|
111
|
+
return new ZLogEntryBuilder().info().message(`Node added: ${path}`).build();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets the message for when a file/folder is removed.
|
|
115
|
+
*
|
|
116
|
+
* @returns
|
|
117
|
+
* The message for when a file/folder is added.
|
|
118
|
+
*/ static remove(path) {
|
|
119
|
+
return new ZLogEntryBuilder().warning().message(`Node removed: ${path}`).build();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the message for when a file is updated.
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
* The message for when a file is updated.
|
|
126
|
+
*/ static update(path) {
|
|
127
|
+
return new ZLogEntryBuilder().info().message(`Node updated: ${path}`).build();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the current directory being watched.
|
|
131
|
+
*
|
|
132
|
+
* @returns
|
|
133
|
+
* The directory that is watching for events.
|
|
134
|
+
*/ watching() {
|
|
135
|
+
return Promise.resolve(this._watch?.path);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the list of globs that filter the directory contents.
|
|
139
|
+
*
|
|
140
|
+
* @returns
|
|
141
|
+
* The list of globs that filter the directory contents.
|
|
142
|
+
*/ globs() {
|
|
143
|
+
return Promise.resolve(this._globs?.slice());
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns a promise that can be awaited on to
|
|
147
|
+
* make sure the watch is initialized.
|
|
148
|
+
*/ async ready() {
|
|
149
|
+
return this._ready;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Kills the application.
|
|
153
|
+
*/ async kill() {
|
|
154
|
+
await this._watch?.stop();
|
|
155
|
+
delete this._watch;
|
|
156
|
+
delete this._globs;
|
|
157
|
+
this._ready = Promise.resolve();
|
|
158
|
+
this._resolve?.(0);
|
|
159
|
+
await this._promise;
|
|
160
|
+
delete this._promise;
|
|
161
|
+
}
|
|
162
|
+
_handleFsEvent(path, entry) {
|
|
163
|
+
const globs = firstDefined([
|
|
164
|
+
"**"
|
|
165
|
+
], this._globs);
|
|
166
|
+
const directory = firstDefined(cwd(), this._watch?.path);
|
|
167
|
+
if (globs?.some((g)=>minimatch(path, resolve(directory, g)))) {
|
|
168
|
+
this._logger.log(entry);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
_handleAdd(node) {
|
|
172
|
+
const { add } = ZCrumbtrailWatch;
|
|
173
|
+
this._handleFsEvent(node.path, add(node.path));
|
|
174
|
+
}
|
|
175
|
+
_handleRemove(node) {
|
|
176
|
+
const { remove } = ZCrumbtrailWatch;
|
|
177
|
+
this._handleFsEvent(node.path, remove(node.path));
|
|
178
|
+
}
|
|
179
|
+
_handleUpdate(node) {
|
|
180
|
+
const { update } = ZCrumbtrailWatch;
|
|
181
|
+
this._handleFsEvent(node.path, update(node.path));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Runs the application.
|
|
185
|
+
*
|
|
186
|
+
* @param args -
|
|
187
|
+
* The application arguments.
|
|
188
|
+
*
|
|
189
|
+
* @returns
|
|
190
|
+
* The process exit code.
|
|
191
|
+
*/ async run(args = {}) {
|
|
192
|
+
if (this._promise) {
|
|
193
|
+
return this._promise;
|
|
194
|
+
}
|
|
195
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
196
|
+
this._resolve = resolve;
|
|
197
|
+
this._promise = promise;
|
|
198
|
+
const { msg } = ZCrumbtrailWatch;
|
|
199
|
+
const { directory = cwd(), globs = [
|
|
200
|
+
"**"
|
|
201
|
+
] } = args;
|
|
202
|
+
this._globs = uniq(globs.slice());
|
|
203
|
+
this._globs = this._globs.length ? this._globs : [
|
|
204
|
+
"**"
|
|
205
|
+
];
|
|
206
|
+
this._watch = new ZFileWatch(directory);
|
|
207
|
+
const filter = globs.join(",");
|
|
208
|
+
this._logger.log(msg("Welcome to Crumbtrail CLI"));
|
|
209
|
+
this._logger.log(msg(`You are now watching ${directory}`));
|
|
210
|
+
this._logger.log(msg(`Files that match ${filter} will be logged here.`));
|
|
211
|
+
this._logger.log(msg("Press Ctrl+C to stop watching"));
|
|
212
|
+
this._watch.add().subscribe(this._handleAdd.bind(this));
|
|
213
|
+
this._watch.remove().subscribe(this._handleRemove.bind(this));
|
|
214
|
+
this._watch.update().subscribe(this._handleUpdate.bind(this));
|
|
215
|
+
this._ready = this._watch.start();
|
|
216
|
+
await this._ready;
|
|
217
|
+
return this._promise;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Initializes a new instance of this object.
|
|
221
|
+
*
|
|
222
|
+
* @param logger -
|
|
223
|
+
* The logger to use to output events.
|
|
224
|
+
*/ constructor(logger){
|
|
225
|
+
_define_property(this, "_logger", void 0);
|
|
226
|
+
_define_property(this, "_globs", void 0);
|
|
227
|
+
_define_property(this, "_watch", void 0);
|
|
228
|
+
_define_property(this, "_ready", Promise.resolve());
|
|
229
|
+
_define_property(this, "_promise", void 0);
|
|
230
|
+
_define_property(this, "_resolve", void 0);
|
|
231
|
+
this._logger = new ZLoggerContext("ZCrumbtrailApp", logger);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { ZCrumbtrailNudge as Z, ZCrumbtrailWatch as a };
|
|
236
|
+
//# sourceMappingURL=watch-DdpcqnOY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-DdpcqnOY.js","sources":["../src/nudge/nudge.mts","../src/watch/watch.mts"],"sourcesContent":["import { ZWatchDelay } from \"@zthun/crumbtrail-fs\";\nimport { firstTruthy, sleep } from \"@zthun/helpful-fn\";\nimport type { IZLogger } from \"@zthun/lumberjacky-log\";\nimport { ZLogEntryBuilder, ZLoggerContext } from \"@zthun/lumberjacky-log\";\nimport glob from \"fast-glob\";\nimport { noop } from \"lodash-es\";\nimport { readdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\n/**\n * Options for the nudge command.\n */\nexport interface IZCrumbtrailNudgeOptions {\n /**\n * The directory to nudge.\n *\n * The default if not specified is the current working directory.\n */\n directory?: string;\n\n /**\n * Whether to nudge recursively.\n *\n * Warning: This can have severe CPU\n * usage for deep directories.\n *\n * Default is false.\n */\n recursive?: boolean;\n\n /**\n * The total number of milliseconds to wait\n * between nudges.\n *\n * Default is {@link ZWatchDelay}\n */\n every?: number;\n}\n\n/**\n * An operation to continuously nudge a directory.\n *\n * This is a special operation that lists the contents of a targeted parent directory.\n * The main reason for this is to work around an issue when you are running inside of\n * a container and your host is not linux.\n *\n * A lot of times, you will not receive events in this situation for add and update\n * until the virtual file bridge is refreshed by listing the outer directory contents.\n * This command helps to force the bridge to send file change events. You should\n * only need this if you are running on a non linux host inside a docker container.\n *\n * Run a separate container in the background and just nudge the directory\n * for however long you need.\n */\nexport class ZCrumbtrailNudge {\n private _controller?: AbortController;\n private _resolve?: (val: number) => void;\n private _promise?: Promise<number>;\n private readonly _logger: IZLogger;\n\n public constructor(logger: IZLogger) {\n this._logger = new ZLoggerContext(\"ZCrumbtrailNudge\", logger);\n }\n\n public async kill(): Promise<void> {\n this._controller?.abort();\n delete this._controller;\n\n await this._promise;\n delete this._promise;\n }\n\n public async run(options: IZCrumbtrailNudgeOptions = {}): Promise<number> {\n await this.kill();\n\n const controller = new AbortController();\n this._controller = controller;\n\n const { promise, resolve } = Promise.withResolvers<number>();\n this._promise = promise;\n this._resolve = resolve;\n\n const {\n directory = process.cwd(),\n recursive,\n every = ZWatchDelay,\n } = options;\n\n const ms = firstTruthy(ZWatchDelay, every);\n\n this._logger.log(\n new ZLogEntryBuilder()\n .info()\n .message(`Starting a nudge loop every ${ms} milliseconds`)\n .build(),\n );\n\n if (recursive) {\n this._logger.log(\n new ZLogEntryBuilder()\n .warning()\n .message(\"Nudging is recursive. Child folders will be nudged too.\")\n .build(),\n );\n }\n\n do {\n this._logger.log(\n new ZLogEntryBuilder()\n .info()\n .message(`Nudging ${directory} to refresh`)\n .build(),\n );\n await readdir(dirname(directory)).catch(noop);\n\n if (recursive) {\n await glob(`${directory}/**`, { onlyDirectories: true }).catch(noop);\n }\n\n await sleep(ms);\n } while (!controller.signal.aborted);\n\n resolve(0);\n delete this._resolve;\n\n return this._promise;\n }\n}\n","import type { IZFileSystemNode } from \"@zthun/crumbtrail-fs\";\nimport { ZFileWatch } from \"@zthun/crumbtrail-fs\";\nimport { firstDefined } from \"@zthun/helpful-fn\";\nimport type { IZLogEntry, IZLogger } from \"@zthun/lumberjacky-log\";\nimport { ZLogEntryBuilder, ZLoggerContext } from \"@zthun/lumberjacky-log\";\nimport { uniq } from \"lodash-es\";\nimport { minimatch } from \"minimatch\";\nimport { resolve } from \"node:path\";\nimport { cwd } from \"node:process\";\n\n/**\n * Arguments for the crumbtrail app.\n */\nexport interface IZCrumbtrailWatchOptions {\n /**\n * The directory to watch.\n *\n * If this is falsy, then the cwd is used.\n */\n directory?: string;\n\n /**\n * The list of file globs to watch.\n *\n * If this is falsy or empty, then '**' is used.\n */\n globs?: string[];\n}\n\n/**\n * The root application for the crumbtrail cli.\n */\nexport class ZCrumbtrailWatch {\n private _logger: IZLogger;\n private _globs: string[] | undefined;\n private _watch: ZFileWatch | undefined;\n private _ready: Promise<void> = Promise.resolve();\n private _promise: Promise<number> | undefined;\n private _resolve: ((value: number) => void) | undefined;\n\n /**\n * Gets the entry for a basic information message.\n *\n * @returns\n * The log entry for a basic information message.\n */\n public static msg(msg: string): IZLogEntry {\n return new ZLogEntryBuilder().info().message(msg).build();\n }\n\n /**\n * Gets the message for when a file is added.\n *\n * @returns\n * The message for when a file is added.\n */\n public static add(path: string): IZLogEntry {\n return new ZLogEntryBuilder().info().message(`Node added: ${path}`).build();\n }\n\n /**\n * Gets the message for when a file/folder is removed.\n *\n * @returns\n * The message for when a file/folder is added.\n */\n public static remove(path: string): IZLogEntry {\n return new ZLogEntryBuilder()\n .warning()\n .message(`Node removed: ${path}`)\n .build();\n }\n\n /**\n * Gets the message for when a file is updated.\n *\n * @returns\n * The message for when a file is updated.\n */\n public static update(path: string): IZLogEntry {\n return new ZLogEntryBuilder()\n .info()\n .message(`Node updated: ${path}`)\n .build();\n }\n\n /**\n * Gets the current directory being watched.\n *\n * @returns\n * The directory that is watching for events.\n */\n public watching() {\n return Promise.resolve(this._watch?.path);\n }\n\n /**\n * Gets the list of globs that filter the directory contents.\n *\n * @returns\n * The list of globs that filter the directory contents.\n */\n public globs() {\n return Promise.resolve(this._globs?.slice());\n }\n\n /**\n * Returns a promise that can be awaited on to\n * make sure the watch is initialized.\n */\n public async ready() {\n return this._ready;\n }\n\n /**\n * Initializes a new instance of this object.\n *\n * @param logger -\n * The logger to use to output events.\n */\n public constructor(logger: IZLogger) {\n this._logger = new ZLoggerContext(\"ZCrumbtrailApp\", logger);\n }\n\n /**\n * Kills the application.\n */\n public async kill(): Promise<void> {\n await this._watch?.stop();\n\n delete this._watch;\n delete this._globs;\n this._ready = Promise.resolve();\n\n this._resolve?.(0);\n await this._promise;\n delete this._promise;\n }\n\n private _handleFsEvent(path: string, entry: IZLogEntry) {\n const globs = firstDefined([\"**\"], this._globs);\n const directory = firstDefined(cwd(), this._watch?.path);\n\n if (globs?.some((g) => minimatch(path, resolve(directory, g)))) {\n this._logger.log(entry);\n }\n }\n\n private _handleAdd(node: IZFileSystemNode) {\n const { add } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, add(node.path));\n }\n\n private _handleRemove(node: IZFileSystemNode) {\n const { remove } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, remove(node.path));\n }\n\n private _handleUpdate(node: IZFileSystemNode) {\n const { update } = ZCrumbtrailWatch;\n this._handleFsEvent(node.path, update(node.path));\n }\n\n /**\n * Runs the application.\n *\n * @param args -\n * The application arguments.\n *\n * @returns\n * The process exit code.\n */\n public async run(args: IZCrumbtrailWatchOptions = {}): Promise<number> {\n if (this._promise) {\n return this._promise;\n }\n\n const { promise, resolve } = Promise.withResolvers<number>();\n this._resolve = resolve;\n this._promise = promise;\n\n const { msg } = ZCrumbtrailWatch;\n const { directory = cwd(), globs = [\"**\"] } = args;\n\n this._globs = uniq(globs.slice());\n this._globs = this._globs.length ? this._globs : [\"**\"];\n this._watch = new ZFileWatch(directory);\n\n const filter = globs.join(\",\");\n this._logger.log(msg(\"Welcome to Crumbtrail CLI\"));\n this._logger.log(msg(`You are now watching ${directory}`));\n this._logger.log(msg(`Files that match ${filter} will be logged here.`));\n this._logger.log(msg(\"Press Ctrl+C to stop watching\"));\n\n this._watch.add().subscribe(this._handleAdd.bind(this));\n this._watch.remove().subscribe(this._handleRemove.bind(this));\n this._watch.update().subscribe(this._handleUpdate.bind(this));\n\n this._ready = this._watch.start();\n await this._ready;\n\n return this._promise;\n }\n}\n"],"names":["ZCrumbtrailNudge","kill","_controller","abort","_promise","run","options","controller","AbortController","promise","resolve","Promise","withResolvers","_resolve","directory","process","cwd","recursive","every","ZWatchDelay","ms","firstTruthy","_logger","log","ZLogEntryBuilder","info","message","build","warning","readdir","dirname","catch","noop","glob","onlyDirectories","sleep","signal","aborted","logger","_define_property","ZLoggerContext","ZCrumbtrailWatch","msg","add","path","remove","update","watching","_watch","globs","_globs","slice","ready","_ready","stop","_handleFsEvent","entry","firstDefined","some","g","minimatch","_handleAdd","node","_handleRemove","_handleUpdate","args","uniq","length","ZFileWatch","filter","join","subscribe","bind","start"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;AAcC,IACM,MAAMA,gBAAAA,CAAAA;AAUX,IAAA,MAAaC,IAAAA,GAAsB;QACjC,IAAI,CAACC,WAAW,EAAEC,KAAAA,EAAAA;QAClB,OAAO,IAAI,CAACD,WAAW;QAEvB,MAAM,IAAI,CAACE,QAAQ;QACnB,OAAO,IAAI,CAACA,QAAQ;AACtB,IAAA;AAEA,IAAA,MAAaC,GAAAA,CAAIC,OAAAA,GAAoC,EAAE,EAAmB;QACxE,MAAM,IAAI,CAACL,IAAI,EAAA;AAEf,QAAA,MAAMM,aAAa,IAAIC,eAAAA,EAAAA;QACvB,IAAI,CAACN,WAAW,GAAGK,UAAAA;AAEnB,QAAA,MAAM,EAAEE,OAAO,EAAEC,OAAO,EAAE,GAAGC,QAAQC,aAAa,EAAA;QAClD,IAAI,CAACR,QAAQ,GAAGK,OAAAA;QAChB,IAAI,CAACI,QAAQ,GAAGH,OAAAA;QAEhB,MAAM,EACJI,SAAAA,GAAYC,OAAAA,CAAQC,GAAG,EAAE,EACzBC,SAAS,EACTC,KAAAA,GAAQC,WAAW,EACpB,GAAGb,OAAAA;QAEJ,MAAMc,EAAAA,GAAKC,YAAYF,WAAAA,EAAaD,KAAAA,CAAAA;AAEpC,QAAA,IAAI,CAACI,OAAO,CAACC,GAAG,CACd,IAAIC,mBACDC,IAAI,EAAA,CACJC,OAAO,CAAC,CAAC,4BAA4B,EAAEN,GAAG,aAAa,CAAC,EACxDO,KAAK,EAAA,CAAA;AAGV,QAAA,IAAIV,SAAAA,EAAW;AACb,YAAA,IAAI,CAACK,OAAO,CAACC,GAAG,CACd,IAAIC,gBAAAA,EAAAA,CACDI,OAAO,EAAA,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": "An application for crumbtrail that helps with debugging io issues",
|
|
5
|
+
"author": "Anthony Bonta",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zthun/crumbtrail",
|
|
10
|
+
"directory": "packages/crumbtrail-cli"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"require": "./dist/index.cjs",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"bin": "dist/cli.js",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=24.13.0"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "vite build",
|
|
27
|
+
"start": "node ./dist/cli.js",
|
|
28
|
+
"debug": "tsx src/cli.mts"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@zthun/crumbtrail-fs": "^2.4.6",
|
|
35
|
+
"@zthun/helpful-fn": "^9.11.5",
|
|
36
|
+
"@zthun/lumberjacky-log": "^4.0.4",
|
|
37
|
+
"commander": "^14.0.3",
|
|
38
|
+
"fast-glob": "^3.3.3",
|
|
39
|
+
"lodash-es": "^4.17.23",
|
|
40
|
+
"minimatch": "^10.1.2"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@zthun/janitor-build-config": "^19.5.6",
|
|
44
|
+
"@zthun/janitor-ts-config": "^19.5.3",
|
|
45
|
+
"tsx": "^4.21.0",
|
|
46
|
+
"typescript": "~5.9.3",
|
|
47
|
+
"vite": "^7.3.1",
|
|
48
|
+
"vitest": "^4.0.18",
|
|
49
|
+
"vitest-mock-extended": "^3.1.0"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
"sideEffects": false,
|
|
55
|
+
"gitHead": "b092744640cbefa05311c878cf8e79326347fa01"
|
|
56
|
+
}
|