@sealcode/sealgen 0.11.7 → 0.11.8
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/lib/build.js +27 -2
- package/package.json +2 -2
- package/src/build.ts +32 -2
package/lib/build.js
CHANGED
|
@@ -38,6 +38,9 @@ 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
40
|
const notifier_1 = require("./notifier");
|
|
41
|
+
const get_port_1 = __importDefault(require("get-port"));
|
|
42
|
+
const locreq_1 = __importDefault(require("locreq"));
|
|
43
|
+
const target_locreq = (0, locreq_1.default)(process.cwd());
|
|
41
44
|
const generate_names = (function* generate_names() {
|
|
42
45
|
const base_name = "____unique_import_";
|
|
43
46
|
let count = 0;
|
|
@@ -46,6 +49,16 @@ const generate_names = (function* generate_names() {
|
|
|
46
49
|
count++;
|
|
47
50
|
}
|
|
48
51
|
})();
|
|
52
|
+
async function get_notifier_port() {
|
|
53
|
+
return (0, get_port_1.default)({ port: 4000 });
|
|
54
|
+
}
|
|
55
|
+
async function write_notifier_config(watch, port) {
|
|
56
|
+
const config = { watch };
|
|
57
|
+
if (port) {
|
|
58
|
+
config.port = port;
|
|
59
|
+
}
|
|
60
|
+
await fs_1.promises.writeFile(target_locreq.resolve("public/dist/notifier.json"), JSON.stringify(config));
|
|
61
|
+
}
|
|
49
62
|
async function build_ts() {
|
|
50
63
|
await Promise.all([
|
|
51
64
|
(0, generate_collections_1.generateCollections)(),
|
|
@@ -122,9 +135,12 @@ async function complex_build(watch) {
|
|
|
122
135
|
});
|
|
123
136
|
let ongoing_ts = false;
|
|
124
137
|
let ongoing_css = false;
|
|
138
|
+
let ongoing_ts_promise = null;
|
|
125
139
|
if (watch) {
|
|
126
140
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
127
|
-
const
|
|
141
|
+
const port = await get_notifier_port();
|
|
142
|
+
const notifier = (0, notifier_1.make_notifier)(port);
|
|
143
|
+
await write_notifier_config(watch, port);
|
|
128
144
|
watcher.on("all", async (_, path) => {
|
|
129
145
|
if (!css_build)
|
|
130
146
|
return;
|
|
@@ -150,6 +166,9 @@ async function complex_build(watch) {
|
|
|
150
166
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
151
167
|
.catch((e) => console.error(e?.message));
|
|
152
168
|
}
|
|
169
|
+
if (ongoing_ts_promise) {
|
|
170
|
+
await ongoing_ts_promise;
|
|
171
|
+
}
|
|
153
172
|
notifier("css");
|
|
154
173
|
ongoing_css = false;
|
|
155
174
|
}
|
|
@@ -161,12 +180,18 @@ async function complex_build(watch) {
|
|
|
161
180
|
return;
|
|
162
181
|
}
|
|
163
182
|
ongoing_ts = true;
|
|
164
|
-
|
|
183
|
+
ongoing_ts_promise = build_ts();
|
|
184
|
+
await ongoing_ts_promise;
|
|
185
|
+
notifier("ts");
|
|
186
|
+
ongoing_ts_promise = null;
|
|
165
187
|
console.log(`Finished TS build [on ${path}]`);
|
|
166
188
|
ongoing_ts = false;
|
|
167
189
|
}
|
|
168
190
|
});
|
|
169
191
|
}
|
|
192
|
+
else {
|
|
193
|
+
await write_notifier_config(watch);
|
|
194
|
+
}
|
|
170
195
|
await (0, find_css_includes_1.generate_css_includes)();
|
|
171
196
|
await Promise.all([css_build.rebuild(), build_ts()]);
|
|
172
197
|
watch && css_build?.rebuild?.();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint-config-prettier": "^8.3.0",
|
|
35
35
|
"eslint-plugin-prettier": "^3.4.1",
|
|
36
36
|
"eslint-plugin-with-tsc-error": "^0.0.7",
|
|
37
|
-
"get-port": "^5.
|
|
37
|
+
"get-port": "^5.1.1",
|
|
38
38
|
"koa-body": "^5.0.0",
|
|
39
39
|
"mocha": "^9.2.2",
|
|
40
40
|
"mri": "^1.2.0",
|
package/src/build.ts
CHANGED
|
@@ -9,6 +9,10 @@ import { generateCollections } from "./generate-collections";
|
|
|
9
9
|
import { generateRoutes } from "./generate-routes";
|
|
10
10
|
import { generateComponents } from "./generate-components";
|
|
11
11
|
import { make_notifier } from "./notifier";
|
|
12
|
+
import getPort from "get-port";
|
|
13
|
+
|
|
14
|
+
import _locreq from "locreq";
|
|
15
|
+
const target_locreq = _locreq(process.cwd());
|
|
12
16
|
|
|
13
17
|
const generate_names = (function* generate_names() {
|
|
14
18
|
const base_name = "____unique_import_";
|
|
@@ -19,6 +23,21 @@ const generate_names = (function* generate_names() {
|
|
|
19
23
|
}
|
|
20
24
|
})();
|
|
21
25
|
|
|
26
|
+
async function get_notifier_port() {
|
|
27
|
+
return getPort({ port: 4000 });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function write_notifier_config(watch: boolean, port?: number) {
|
|
31
|
+
const config = { watch } as Record<string, boolean | number>;
|
|
32
|
+
if (port) {
|
|
33
|
+
config.port = port;
|
|
34
|
+
}
|
|
35
|
+
await fs.writeFile(
|
|
36
|
+
target_locreq.resolve("public/dist/notifier.json"),
|
|
37
|
+
JSON.stringify(config)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
async function build_ts() {
|
|
23
42
|
await Promise.all([
|
|
24
43
|
generateCollections(),
|
|
@@ -136,9 +155,12 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
136
155
|
});
|
|
137
156
|
let ongoing_ts = false;
|
|
138
157
|
let ongoing_css = false;
|
|
158
|
+
let ongoing_ts_promise: Promise<any> | null = null;
|
|
139
159
|
if (watch) {
|
|
140
160
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
141
|
-
const
|
|
161
|
+
const port = await get_notifier_port();
|
|
162
|
+
const notifier = make_notifier(port);
|
|
163
|
+
await write_notifier_config(watch, port);
|
|
142
164
|
watcher.on("all", async (_, path) => {
|
|
143
165
|
if (!css_build) return;
|
|
144
166
|
if (path.includes(".#")) return;
|
|
@@ -161,6 +183,9 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
161
183
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
162
184
|
.catch((e) => console.error(e?.message));
|
|
163
185
|
}
|
|
186
|
+
if (ongoing_ts_promise) {
|
|
187
|
+
await ongoing_ts_promise;
|
|
188
|
+
}
|
|
164
189
|
notifier("css");
|
|
165
190
|
ongoing_css = false;
|
|
166
191
|
}
|
|
@@ -174,11 +199,16 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
174
199
|
return;
|
|
175
200
|
}
|
|
176
201
|
ongoing_ts = true;
|
|
177
|
-
|
|
202
|
+
ongoing_ts_promise = build_ts();
|
|
203
|
+
await ongoing_ts_promise;
|
|
204
|
+
notifier("ts");
|
|
205
|
+
ongoing_ts_promise = null;
|
|
178
206
|
console.log(`Finished TS build [on ${path}]`);
|
|
179
207
|
ongoing_ts = false;
|
|
180
208
|
}
|
|
181
209
|
});
|
|
210
|
+
} else {
|
|
211
|
+
await write_notifier_config(watch);
|
|
182
212
|
}
|
|
183
213
|
await generate_css_includes();
|
|
184
214
|
|