@sealcode/sealgen 0.11.6 → 0.11.7
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/@types/notifier.d.ts +1 -0
- package/lib/build.js +3 -0
- package/lib/notifier.js +26 -0
- package/package.json +3 -1
- package/src/build.ts +3 -0
- package/src/notifier.ts +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function make_notifier(port: number): (message: string) => void;
|
package/lib/build.js
CHANGED
|
@@ -37,6 +37,7 @@ const sleep_1 = require("./utils/sleep");
|
|
|
37
37
|
const generate_collections_1 = require("./generate-collections");
|
|
38
38
|
const generate_routes_1 = require("./generate-routes");
|
|
39
39
|
const generate_components_1 = require("./generate-components");
|
|
40
|
+
const notifier_1 = require("./notifier");
|
|
40
41
|
const generate_names = (function* generate_names() {
|
|
41
42
|
const base_name = "____unique_import_";
|
|
42
43
|
let count = 0;
|
|
@@ -123,6 +124,7 @@ async function complex_build(watch) {
|
|
|
123
124
|
let ongoing_css = false;
|
|
124
125
|
if (watch) {
|
|
125
126
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
127
|
+
const notifier = (0, notifier_1.make_notifier)(60808);
|
|
126
128
|
watcher.on("all", async (_, path) => {
|
|
127
129
|
if (!css_build)
|
|
128
130
|
return;
|
|
@@ -148,6 +150,7 @@ async function complex_build(watch) {
|
|
|
148
150
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
149
151
|
.catch((e) => console.error(e?.message));
|
|
150
152
|
}
|
|
153
|
+
notifier("css");
|
|
151
154
|
ongoing_css = false;
|
|
152
155
|
}
|
|
153
156
|
if ((path.endsWith(".ts") || path.endsWith(".tsx")) &&
|
package/lib/notifier.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
exports.make_notifier = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
function make_notifier(port) {
|
|
9
|
+
const server = new ws_1.default.Server({
|
|
10
|
+
port,
|
|
11
|
+
});
|
|
12
|
+
let sockets = [];
|
|
13
|
+
server.on("connection", function (socket) {
|
|
14
|
+
sockets.push(socket);
|
|
15
|
+
// When a socket closes, or disconnects, remove it from the array.
|
|
16
|
+
socket.on("close", function () {
|
|
17
|
+
sockets = sockets.filter((s) => s !== socket);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
console.log("build notifier listening on websocket at port " + port);
|
|
21
|
+
return function notify(message) {
|
|
22
|
+
sockets.forEach((s) => s.send(message));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.make_notifier = make_notifier;
|
|
26
|
+
//# sourceMappingURL=notifier.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@types/prettier": "^2.7.0",
|
|
28
28
|
"@types/prompts": "^2.0.14",
|
|
29
29
|
"@types/recursive-readdir": "^2.2.4",
|
|
30
|
+
"@types/ws": "^8.5.10",
|
|
30
31
|
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
|
31
32
|
"@typescript-eslint/parser": "^4.29.3",
|
|
32
33
|
"eslint": "^7.32.0",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"recursive-readdir": "^2.2.3",
|
|
61
62
|
"tempstream": "^0.3.0",
|
|
62
63
|
"tiny-glob": "^0.2.9",
|
|
64
|
+
"ws": "^8.16.0",
|
|
63
65
|
"yargs": "^17.6.2"
|
|
64
66
|
},
|
|
65
67
|
"peerDependencies": {
|
package/src/build.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { sleep } from "./utils/sleep";
|
|
|
8
8
|
import { generateCollections } from "./generate-collections";
|
|
9
9
|
import { generateRoutes } from "./generate-routes";
|
|
10
10
|
import { generateComponents } from "./generate-components";
|
|
11
|
+
import { make_notifier } from "./notifier";
|
|
11
12
|
|
|
12
13
|
const generate_names = (function* generate_names() {
|
|
13
14
|
const base_name = "____unique_import_";
|
|
@@ -137,6 +138,7 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
137
138
|
let ongoing_css = false;
|
|
138
139
|
if (watch) {
|
|
139
140
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
141
|
+
const notifier = make_notifier(60808);
|
|
140
142
|
watcher.on("all", async (_, path) => {
|
|
141
143
|
if (!css_build) return;
|
|
142
144
|
if (path.includes(".#")) return;
|
|
@@ -159,6 +161,7 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
159
161
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
160
162
|
.catch((e) => console.error(e?.message));
|
|
161
163
|
}
|
|
164
|
+
notifier("css");
|
|
162
165
|
ongoing_css = false;
|
|
163
166
|
}
|
|
164
167
|
if (
|
package/src/notifier.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
|
|
3
|
+
export function make_notifier(port: number) {
|
|
4
|
+
const server = new WebSocket.Server({
|
|
5
|
+
port,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
let sockets: WebSocket[] = [];
|
|
9
|
+
server.on("connection", function (socket) {
|
|
10
|
+
sockets.push(socket);
|
|
11
|
+
|
|
12
|
+
// When a socket closes, or disconnects, remove it from the array.
|
|
13
|
+
socket.on("close", function () {
|
|
14
|
+
sockets = sockets.filter((s) => s !== socket);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
console.log("build notifier listening on websocket at port " + port);
|
|
19
|
+
return function notify(message: string) {
|
|
20
|
+
sockets.forEach((s) => s.send(message));
|
|
21
|
+
};
|
|
22
|
+
}
|