@eggjs/watcher 4.0.4 → 4.0.5-beta.2
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 +1 -5
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +7 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.js +7 -0
- package/dist/config/config.default.d.ts +13 -0
- package/dist/config/config.default.js +14 -0
- package/dist/config/config.local.d.ts +8 -0
- package/dist/config/config.local.js +5 -0
- package/dist/config/config.unittest.d.ts +8 -0
- package/dist/config/config.unittest.js +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/dist/lib/boot.d.ts +10 -0
- package/dist/lib/boot.js +19 -0
- package/dist/lib/event-sources/base.d.ts +9 -0
- package/dist/lib/event-sources/base.js +7 -0
- package/dist/lib/event-sources/default.d.ts +10 -0
- package/dist/lib/event-sources/default.js +19 -0
- package/dist/lib/event-sources/development.d.ts +11 -0
- package/dist/lib/event-sources/development.js +66 -0
- package/dist/lib/event-sources/index.d.ts +4 -0
- package/dist/lib/event-sources/index.js +5 -0
- package/{src/lib/types.ts → dist/lib/types.d.ts} +10 -12
- package/dist/lib/types.js +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +15 -0
- package/dist/lib/watcher.d.ts +14 -0
- package/dist/lib/watcher.js +59 -0
- package/package.json +49 -59
- package/dist/commonjs/agent.d.ts +0 -2
- package/dist/commonjs/agent.js +0 -5
- package/dist/commonjs/app.d.ts +0 -2
- package/dist/commonjs/app.js +0 -5
- package/dist/commonjs/config/config.default.d.ts +0 -10
- package/dist/commonjs/config/config.default.js +0 -22
- package/dist/commonjs/config/config.local.d.ts +0 -5
- package/dist/commonjs/config/config.local.js +0 -8
- package/dist/commonjs/config/config.unittest.d.ts +0 -5
- package/dist/commonjs/config/config.unittest.js +0 -8
- package/dist/commonjs/index.d.ts +0 -3
- package/dist/commonjs/index.js +0 -20
- package/dist/commonjs/lib/boot.d.ts +0 -6
- package/dist/commonjs/lib/boot.js +0 -23
- package/dist/commonjs/lib/event-sources/base.d.ts +0 -5
- package/dist/commonjs/lib/event-sources/base.js +0 -8
- package/dist/commonjs/lib/event-sources/default.d.ts +0 -6
- package/dist/commonjs/lib/event-sources/default.js +0 -19
- package/dist/commonjs/lib/event-sources/development.d.ts +0 -7
- package/dist/commonjs/lib/event-sources/development.js +0 -103
- package/dist/commonjs/lib/event-sources/index.d.ts +0 -4
- package/dist/commonjs/lib/event-sources/index.js +0 -13
- package/dist/commonjs/lib/types.d.ts +0 -31
- package/dist/commonjs/lib/types.js +0 -3
- package/dist/commonjs/lib/utils.d.ts +0 -2
- package/dist/commonjs/lib/utils.js +0 -25
- package/dist/commonjs/lib/watcher.d.ts +0 -10
- package/dist/commonjs/lib/watcher.js +0 -113
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/agent.d.ts +0 -2
- package/dist/esm/agent.js +0 -3
- package/dist/esm/app.d.ts +0 -2
- package/dist/esm/app.js +0 -3
- package/dist/esm/config/config.default.d.ts +0 -10
- package/dist/esm/config/config.default.js +0 -17
- package/dist/esm/config/config.local.d.ts +0 -5
- package/dist/esm/config/config.local.js +0 -6
- package/dist/esm/config/config.unittest.d.ts +0 -5
- package/dist/esm/config/config.unittest.js +0 -6
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.js +0 -4
- package/dist/esm/lib/boot.d.ts +0 -6
- package/dist/esm/lib/boot.js +0 -19
- package/dist/esm/lib/event-sources/base.d.ts +0 -5
- package/dist/esm/lib/event-sources/base.js +0 -4
- package/dist/esm/lib/event-sources/default.d.ts +0 -6
- package/dist/esm/lib/event-sources/default.js +0 -16
- package/dist/esm/lib/event-sources/development.d.ts +0 -7
- package/dist/esm/lib/event-sources/development.js +0 -97
- package/dist/esm/lib/event-sources/index.d.ts +0 -4
- package/dist/esm/lib/event-sources/index.js +0 -5
- package/dist/esm/lib/types.d.ts +0 -31
- package/dist/esm/lib/types.js +0 -2
- package/dist/esm/lib/utils.d.ts +0 -2
- package/dist/esm/lib/utils.js +0 -18
- package/dist/esm/lib/watcher.d.ts +0 -10
- package/dist/esm/lib/watcher.js +0 -106
- package/dist/esm/package.json +0 -3
- package/dist/package.json +0 -4
- package/src/agent.ts +0 -3
- package/src/app.ts +0 -3
- package/src/config/config.default.ts +0 -18
- package/src/config/config.local.ts +0 -7
- package/src/config/config.unittest.ts +0 -7
- package/src/index.ts +0 -3
- package/src/lib/boot.ts +0 -22
- package/src/lib/event-sources/base.ts +0 -6
- package/src/lib/event-sources/default.ts +0 -18
- package/src/lib/event-sources/development.ts +0 -101
- package/src/lib/event-sources/index.ts +0 -9
- package/src/lib/utils.ts +0 -20
- package/src/lib/watcher.ts +0 -120
package/README.md
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
# @eggjs/watcher
|
|
2
2
|
|
|
3
3
|
[![NPM version][npm-image]][npm-url]
|
|
4
|
-
[](https://github.com/eggjs/watcher/actions/workflows/nodejs.yml)
|
|
5
|
-
[![Test coverage][codecov-image]][codecov-url]
|
|
6
4
|
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
|
7
5
|
[![npm download][download-image]][download-url]
|
|
8
6
|
[](https://nodejs.org/en/download/)
|
|
9
7
|
|
|
10
8
|
[npm-image]: https://img.shields.io/npm/v/@eggjs/watcher.svg?style=flat-square
|
|
11
9
|
[npm-url]: https://npmjs.org/package/@eggjs/watcher
|
|
12
|
-
[codecov-image]: https://codecov.io/github/eggjs/watcher/coverage.svg?branch=master
|
|
13
|
-
[codecov-url]: https://codecov.io/github/eggjs/watcher?branch=master
|
|
14
10
|
[snyk-image]: https://snyk.io/test/npm/@eggjs/watcher/badge.svg?style=flat-square
|
|
15
11
|
[snyk-url]: https://snyk.io/test/npm/@eggjs/watcher
|
|
16
12
|
[download-image]: https://img.shields.io/npm/dm/@eggjs/watcher.svg?style=flat-square
|
|
@@ -142,6 +138,6 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
|
|
|
142
138
|
|
|
143
139
|
## Contributors
|
|
144
140
|
|
|
145
|
-
[](https://github.com/eggjs/egg/graphs/contributors)
|
|
146
142
|
|
|
147
143
|
Made with [contributors-img](https://contrib.rocks).
|
package/dist/agent.d.ts
ADDED
package/dist/agent.js
ADDED
package/dist/app.d.ts
ADDED
package/dist/app.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WatcherConfig } from "../lib/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/config/config.default.d.ts
|
|
4
|
+
declare const _default: {
|
|
5
|
+
/**
|
|
6
|
+
* watcher options
|
|
7
|
+
* @member Config#watcher
|
|
8
|
+
* @property {string} type - event source type
|
|
9
|
+
*/
|
|
10
|
+
watcher: WatcherConfig;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { _default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getSourceDirname } from "../lib/utils.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/config/config.default.ts
|
|
5
|
+
var config_default_default = { watcher: {
|
|
6
|
+
type: "default",
|
|
7
|
+
eventSources: {
|
|
8
|
+
default: path.join(getSourceDirname(), "lib", "event-sources", "default"),
|
|
9
|
+
development: path.join(getSourceDirname(), "lib", "event-sources", "development")
|
|
10
|
+
}
|
|
11
|
+
} };
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { config_default_default as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WatchListener, Watcher } from "./lib/watcher.js";
|
|
2
|
+
import { ChangeInfo, WatcherConfig } from "./lib/types.js";
|
|
3
|
+
import { BaseEventSource } from "./lib/event-sources/base.js";
|
|
4
|
+
import DefaultEventSource from "./lib/event-sources/default.js";
|
|
5
|
+
import DevelopmentEventSource from "./lib/event-sources/development.js";
|
|
6
|
+
export { BaseEventSource, ChangeInfo, DefaultEventSource, DevelopmentEventSource, WatchListener, Watcher, WatcherConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseEventSource } from "./lib/event-sources/base.js";
|
|
2
|
+
import { Watcher } from "./lib/watcher.js";
|
|
3
|
+
import DefaultEventSource from "./lib/event-sources/default.js";
|
|
4
|
+
import DevelopmentEventSource from "./lib/event-sources/development.js";
|
|
5
|
+
import "./lib/event-sources/index.js";
|
|
6
|
+
|
|
7
|
+
export { BaseEventSource, DefaultEventSource, DevelopmentEventSource, Watcher };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EggApplicationCore, ILifecycleBoot } from "egg";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/boot.d.ts
|
|
4
|
+
declare class Boot implements ILifecycleBoot {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(appOrAgent: EggApplicationCore);
|
|
7
|
+
didLoad(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Boot };
|
package/dist/lib/boot.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Watcher } from "./watcher.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/boot.ts
|
|
4
|
+
var Boot = class {
|
|
5
|
+
#app;
|
|
6
|
+
#watcher;
|
|
7
|
+
constructor(appOrAgent) {
|
|
8
|
+
this.#app = appOrAgent;
|
|
9
|
+
this.#watcher = this.#app.watcher = this.#app.cluster(Watcher, {}).delegate("watch", "subscribe").create(appOrAgent.config);
|
|
10
|
+
this.#watcher.on("info", (msg, ...args) => this.#app.coreLogger.info(msg, ...args)).on("warn", (msg, ...args) => this.#app.coreLogger.warn(msg, ...args)).on("error", (msg, ...args) => this.#app.coreLogger.error(msg, ...args));
|
|
11
|
+
}
|
|
12
|
+
async didLoad() {
|
|
13
|
+
await this.#watcher.ready();
|
|
14
|
+
this.#app.coreLogger.info("[@eggjs/watcher:%s] watcher start success", this.#app.type);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Boot };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseEventSource } from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/event-sources/default.d.ts
|
|
4
|
+
declare class DefaultEventSource extends BaseEventSource {
|
|
5
|
+
constructor();
|
|
6
|
+
watch(): void;
|
|
7
|
+
unwatch(): void;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DefaultEventSource as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseEventSource } from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/event-sources/default.ts
|
|
4
|
+
var DefaultEventSource = class extends BaseEventSource {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
setImmediate(() => this.emit("info", "[@eggjs/watcher] defaultEventSource watcher will NOT take effect"));
|
|
8
|
+
this.ready(true);
|
|
9
|
+
}
|
|
10
|
+
watch() {
|
|
11
|
+
this.emit("info", "[@eggjs/watcher] using defaultEventSource watcher.watch() does NOTHING");
|
|
12
|
+
}
|
|
13
|
+
unwatch() {
|
|
14
|
+
this.emit("info", "[@eggjs/watcher] using defaultEventSource watcher.unwatch() does NOTHING");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { DefaultEventSource as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEventSource } from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/event-sources/development.d.ts
|
|
4
|
+
declare class DevelopmentEventSource extends BaseEventSource {
|
|
5
|
+
#private;
|
|
6
|
+
constructor();
|
|
7
|
+
watch(file: string): void;
|
|
8
|
+
unwatch(file: string): void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DevelopmentEventSource as default };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BaseEventSource } from "./base.js";
|
|
2
|
+
import { debuglog } from "node:util";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
|
|
6
|
+
//#region src/lib/event-sources/development.ts
|
|
7
|
+
const debug = debuglog("egg-watcher/lib/event-sources/development");
|
|
8
|
+
var DevelopmentEventSource = class extends BaseEventSource {
|
|
9
|
+
#fileWatching = /* @__PURE__ */ new Map();
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.ready(true);
|
|
13
|
+
}
|
|
14
|
+
watch(file) {
|
|
15
|
+
try {
|
|
16
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
17
|
+
if (!stat) {
|
|
18
|
+
debug("watch %o ignore, file not exists", file);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
debug("watch %o, isFile: %o", file, stat.isFile());
|
|
22
|
+
let recursive = true;
|
|
23
|
+
if (process.platform === "linux" && process.version.startsWith("v18.")) recursive = false;
|
|
24
|
+
const handler = fs.watch(file, {
|
|
25
|
+
persistent: true,
|
|
26
|
+
recursive
|
|
27
|
+
}, (event, filename) => {
|
|
28
|
+
debug("watch %o => event: %o, filename: %o", file, event, filename);
|
|
29
|
+
let changePath = file;
|
|
30
|
+
if (stat.isFile()) this.#onFsWatchChange(event, changePath);
|
|
31
|
+
else {
|
|
32
|
+
if (filename) changePath = path.join(file, filename);
|
|
33
|
+
this.#onFsWatchChange(event, changePath);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
this.#fileWatching.set(file, handler);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
this.emit("warn", "[@eggjs/watcher:DevelopmentEventSource] watch %o error: %s", file, e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
unwatch(file) {
|
|
42
|
+
if (!file) return;
|
|
43
|
+
const h = this.#fileWatching.get(file);
|
|
44
|
+
if (!h) return;
|
|
45
|
+
h.removeAllListeners();
|
|
46
|
+
h.close();
|
|
47
|
+
this.#fileWatching.delete(file);
|
|
48
|
+
}
|
|
49
|
+
#onFsWatchChange(event, file) {
|
|
50
|
+
if (!file) {
|
|
51
|
+
this.emit("warn", "[@eggjs/watcher:DevelopmentEventSource] event: %o", event);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
55
|
+
const info = {
|
|
56
|
+
path: file,
|
|
57
|
+
event,
|
|
58
|
+
stat,
|
|
59
|
+
isDirectory: stat?.isDirectory()
|
|
60
|
+
};
|
|
61
|
+
this.emit("change", info);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { DevelopmentEventSource as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Watcher } from "./watcher.js";
|
|
2
|
+
import { Stats, WatchEventType } from "node:fs";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
//#region src/lib/types.d.ts
|
|
5
|
+
interface WatcherConfig {
|
|
5
6
|
/**
|
|
6
7
|
* event source type, default is `default`
|
|
7
8
|
* can be `default` or `development`
|
|
@@ -13,8 +14,7 @@ export interface WatcherConfig {
|
|
|
13
14
|
*/
|
|
14
15
|
eventSources: Record<string, string>;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
export interface ChangeInfo extends Record<string, any> {
|
|
17
|
+
interface ChangeInfo extends Record<string, any> {
|
|
18
18
|
event: WatchEventType;
|
|
19
19
|
/**
|
|
20
20
|
* file stat if path exists
|
|
@@ -23,15 +23,13 @@ export interface ChangeInfo extends Record<string, any> {
|
|
|
23
23
|
path: string;
|
|
24
24
|
isDirectory?: boolean;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
interface EggCore {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
-
// @ts-ignore
|
|
26
|
+
declare module 'egg' {
|
|
27
|
+
interface EggApplicationCore {
|
|
31
28
|
watcher: Watcher;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
interface EggAppConfig {
|
|
35
|
-
watcher
|
|
31
|
+
watcher?: WatcherConfig;
|
|
36
32
|
}
|
|
37
33
|
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ChangeInfo, WatcherConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/utils.ts
|
|
5
|
+
function isEqualOrParentPath(parent, child) {
|
|
6
|
+
return !path.relative(parent, child).startsWith("..");
|
|
7
|
+
}
|
|
8
|
+
function getSourceDirname() {
|
|
9
|
+
if (typeof __dirname === "string") return path.dirname(__dirname);
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
return path.dirname(path.dirname(__filename));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { getSourceDirname, isEqualOrParentPath };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChangeInfo } from "./types.js";
|
|
2
|
+
import { Base } from "sdk-base";
|
|
3
|
+
import { EggAppConfig } from "egg";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/watcher.d.ts
|
|
6
|
+
type WatchListener = (info: ChangeInfo) => void;
|
|
7
|
+
declare class Watcher extends Base {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(config: EggAppConfig);
|
|
10
|
+
protected _init(): Promise<void>;
|
|
11
|
+
watch(path: string | string[], listener: WatchListener): void;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { WatchListener, Watcher };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "./event-sources/base.js";
|
|
2
|
+
import { isEqualOrParentPath } from "./utils.js";
|
|
3
|
+
import { debuglog } from "node:util";
|
|
4
|
+
import { Base } from "sdk-base";
|
|
5
|
+
import camelcase from "camelcase";
|
|
6
|
+
import { importModule } from "@eggjs/utils";
|
|
7
|
+
|
|
8
|
+
//#region src/lib/watcher.ts
|
|
9
|
+
const debug = debuglog("egg-watcher/lib/watcher");
|
|
10
|
+
var Watcher = class extends Base {
|
|
11
|
+
#config;
|
|
12
|
+
#eventSource;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super({ initMethod: "_init" });
|
|
15
|
+
this.#config = config;
|
|
16
|
+
}
|
|
17
|
+
async _init() {
|
|
18
|
+
const watcherType = this.#config.watcher?.type;
|
|
19
|
+
if (!watcherType) return;
|
|
20
|
+
let EventSource = this.#config.watcher?.eventSources[watcherType];
|
|
21
|
+
if (typeof EventSource === "string") EventSource = await importModule(EventSource, { importDefaultOnly: true });
|
|
22
|
+
const key = camelcase(["watcher", watcherType]);
|
|
23
|
+
const eventSourceOptions = this.#config[key] ?? {};
|
|
24
|
+
this.#eventSource = Reflect.construct(EventSource, [eventSourceOptions]);
|
|
25
|
+
this.#eventSource.on("change", this.#onChange.bind(this)).on("fuzzy-change", this.#onFuzzyChange.bind(this)).on("info", (...args) => this.emit("info", ...args)).on("warn", (...args) => this.emit("warn", ...args)).on("error", (...args) => this.emit("error", ...args));
|
|
26
|
+
await this.#eventSource.ready();
|
|
27
|
+
}
|
|
28
|
+
watch(path, listener) {
|
|
29
|
+
this.emit("info", "[@eggjs/watcher] Start watching: %j", path);
|
|
30
|
+
if (!path) return;
|
|
31
|
+
if (Array.isArray(path)) {
|
|
32
|
+
path.forEach((p) => this.watch(p, listener));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!this.listenerCount(path)) this.#eventSource.watch(path);
|
|
36
|
+
this.on(path, listener);
|
|
37
|
+
}
|
|
38
|
+
#onChange(info) {
|
|
39
|
+
debug("onChange %o", info);
|
|
40
|
+
this.emit("info", "[@eggjs/watcher] Received a change event from eventSource: %j", info);
|
|
41
|
+
const path = info.path;
|
|
42
|
+
for (const p of this.eventNames()) {
|
|
43
|
+
if (typeof p !== "string") continue;
|
|
44
|
+
if (isEqualOrParentPath(p, path)) this.emit(p, info);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
#onFuzzyChange(info) {
|
|
48
|
+
debug("onFuzzyChange %o", info);
|
|
49
|
+
this.emit("info", "[@eggjs/watcher] Received a fuzzy-change event from eventSource: %j", info);
|
|
50
|
+
const path = info.path;
|
|
51
|
+
for (const p of this.eventNames()) {
|
|
52
|
+
if (typeof p !== "string") continue;
|
|
53
|
+
if (isEqualOrParentPath(path, p)) this.emit(p, info);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Watcher };
|
package/package.json
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/watcher",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5-beta.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "file watcher plugin for egg",
|
|
8
8
|
"eggPlugin": {
|
|
9
|
-
"name": "watcher"
|
|
10
|
-
"exports": {
|
|
11
|
-
"import": "./dist/esm",
|
|
12
|
-
"require": "./dist/commonjs",
|
|
13
|
-
"typescript": "./src"
|
|
14
|
-
}
|
|
9
|
+
"name": "watcher"
|
|
15
10
|
},
|
|
16
|
-
"
|
|
17
|
-
"lint": "eslint --cache src test --ext .ts",
|
|
18
|
-
"pretest": "npm run clean && npm run lint -- --fix",
|
|
19
|
-
"test": "egg-bin test",
|
|
20
|
-
"preci": "npm run clean && npm run lint",
|
|
21
|
-
"ci": "egg-bin cov",
|
|
22
|
-
"postci": "npm run prepublishOnly && attw --pack && npm run clean",
|
|
23
|
-
"prepublishOnly": "tshy && tshy-after",
|
|
24
|
-
"clean": "rimraf dist"
|
|
25
|
-
},
|
|
26
|
-
"homepage": "https://github.com/eggjs/watcher",
|
|
11
|
+
"homepage": "https://github.com/eggjs/egg/tree/master/plugins/watcher#readme",
|
|
27
12
|
"repository": {
|
|
28
13
|
"type": "git",
|
|
29
|
-
"url": "git
|
|
14
|
+
"url": "git://github.com/eggjs/egg.git",
|
|
15
|
+
"directory": "plugins/watcher"
|
|
30
16
|
},
|
|
31
17
|
"keywords": [
|
|
32
18
|
"egg-watcher",
|
|
@@ -35,54 +21,58 @@
|
|
|
35
21
|
"watch"
|
|
36
22
|
],
|
|
37
23
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
24
|
+
"node": ">= 20.19.0"
|
|
39
25
|
},
|
|
40
26
|
"dependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
27
|
+
"camelcase": "^8.0.0",
|
|
28
|
+
"sdk-base": "^5.0.1",
|
|
29
|
+
"@eggjs/utils": "4.5.0-beta.8"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"egg": "4.1.0-beta.8"
|
|
45
33
|
},
|
|
46
34
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"@eggjs/
|
|
53
|
-
"@eggjs/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"tshy": "3",
|
|
58
|
-
"tshy-after": "1",
|
|
59
|
-
"typescript": "5"
|
|
35
|
+
"@types/node": "24",
|
|
36
|
+
"rimraf": "^6.0.1",
|
|
37
|
+
"tsdown": "^0.15.0",
|
|
38
|
+
"typescript": "5.9.2",
|
|
39
|
+
"vitest": "4.0.0-beta.11",
|
|
40
|
+
"@eggjs/mock": "6.1.0-beta.8",
|
|
41
|
+
"@eggjs/bin": "7.3.1-beta.6",
|
|
42
|
+
"@eggjs/supertest": "8.3.0-beta.8",
|
|
43
|
+
"@eggjs/utils": "4.5.0-beta.8",
|
|
44
|
+
"@eggjs/tsconfig": "3.1.0-beta.8"
|
|
60
45
|
},
|
|
61
46
|
"type": "module",
|
|
62
|
-
"tshy": {
|
|
63
|
-
"exports": {
|
|
64
|
-
".": "./src/index.ts",
|
|
65
|
-
"./package.json": "./package.json"
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
47
|
"exports": {
|
|
69
|
-
".":
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
48
|
+
".": "./dist/index.js",
|
|
49
|
+
"./agent": "./dist/agent.js",
|
|
50
|
+
"./app": "./dist/app.js",
|
|
51
|
+
"./config/config.default": "./dist/config/config.default.js",
|
|
52
|
+
"./config/config.local": "./dist/config/config.local.js",
|
|
53
|
+
"./config/config.unittest": "./dist/config/config.unittest.js",
|
|
54
|
+
"./lib/boot": "./dist/lib/boot.js",
|
|
55
|
+
"./lib/event-sources": "./dist/lib/event-sources/index.js",
|
|
56
|
+
"./lib/event-sources/base": "./dist/lib/event-sources/base.js",
|
|
57
|
+
"./lib/event-sources/default": "./dist/lib/event-sources/default.js",
|
|
58
|
+
"./lib/event-sources/development": "./dist/lib/event-sources/development.js",
|
|
59
|
+
"./lib/types": "./dist/lib/types.js",
|
|
60
|
+
"./lib/utils": "./dist/lib/utils.js",
|
|
61
|
+
"./lib/watcher": "./dist/lib/watcher.js",
|
|
79
62
|
"./package.json": "./package.json"
|
|
80
63
|
},
|
|
81
64
|
"files": [
|
|
82
|
-
"dist"
|
|
83
|
-
"src"
|
|
65
|
+
"dist"
|
|
84
66
|
],
|
|
85
|
-
"types": "./dist/
|
|
86
|
-
"main": "./dist/
|
|
87
|
-
"module": "./dist/
|
|
88
|
-
|
|
67
|
+
"types": "./dist/index.d.ts",
|
|
68
|
+
"main": "./dist/index.js",
|
|
69
|
+
"module": "./dist/index.js",
|
|
70
|
+
"scripts": {
|
|
71
|
+
"lint": "oxlint --type-aware",
|
|
72
|
+
"typecheck": "tsc --noEmit",
|
|
73
|
+
"pretest": "pnpm run clean",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"clean": "rimraf dist",
|
|
76
|
+
"build": "tsdown"
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/commonjs/agent.d.ts
DELETED
package/dist/commonjs/agent.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const boot_js_1 = require("./lib/boot.js");
|
|
4
|
-
exports.default = boot_js_1.Boot;
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYWdlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwyQ0FBcUM7QUFFckMsa0JBQWUsY0FBSSxDQUFDIn0=
|
package/dist/commonjs/app.d.ts
DELETED
package/dist/commonjs/app.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const boot_js_1 = require("./lib/boot.js");
|
|
4
|
-
exports.default = boot_js_1.Boot;
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2FwcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDJDQUFxQztBQUVyQyxrQkFBZSxjQUFJLENBQUMifQ==
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
-
const utils_js_1 = require("../lib/utils.js");
|
|
8
|
-
exports.default = {
|
|
9
|
-
/**
|
|
10
|
-
* watcher options
|
|
11
|
-
* @member Config#watcher
|
|
12
|
-
* @property {string} type - event source type
|
|
13
|
-
*/
|
|
14
|
-
watcher: {
|
|
15
|
-
type: 'default', // default event source
|
|
16
|
-
eventSources: {
|
|
17
|
-
default: node_path_1.default.join((0, utils_js_1.getSourceDirname)(), 'lib', 'event-sources', 'default'),
|
|
18
|
-
development: node_path_1.default.join((0, utils_js_1.getSourceDirname)(), 'lib', 'event-sources', 'development'),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmRlZmF1bHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29uZmlnL2NvbmZpZy5kZWZhdWx0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsMERBQTZCO0FBQzdCLDhDQUFtRDtBQUduRCxrQkFBZTtJQUNiOzs7O09BSUc7SUFDSCxPQUFPLEVBQUU7UUFDUCxJQUFJLEVBQUUsU0FBUyxFQUFFLHVCQUF1QjtRQUN4QyxZQUFZLEVBQUU7WUFDWixPQUFPLEVBQUUsbUJBQUksQ0FBQyxJQUFJLENBQUMsSUFBQSwyQkFBZ0IsR0FBRSxFQUFFLEtBQUssRUFBRSxlQUFlLEVBQUUsU0FBUyxDQUFDO1lBQ3pFLFdBQVcsRUFBRSxtQkFBSSxDQUFDLElBQUksQ0FBQyxJQUFBLDJCQUFnQixHQUFFLEVBQUUsS0FBSyxFQUFFLGVBQWUsRUFBRSxhQUFhLENBQUM7U0FDbEY7S0FDZTtDQUNuQixDQUFDIn0=
|