@sealcode/sealgen 0.11.1 → 0.11.3

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 CHANGED
@@ -37,6 +37,7 @@ const find_scss_includes_1 = require("./find-scss-includes");
37
37
  const sleep_1 = require("./utils/sleep");
38
38
  const generate_collections_1 = require("./generate-collections");
39
39
  const generate_routes_1 = require("./generate-routes");
40
+ const generate_components_1 = require("./generate-components");
40
41
  const generate_names = (function* generate_names() {
41
42
  const base_name = "____unique_import_";
42
43
  let count = 0;
@@ -46,7 +47,11 @@ const generate_names = (function* generate_names() {
46
47
  }
47
48
  })();
48
49
  async function build_ts() {
49
- await Promise.all([(0, generate_collections_1.generateCollections)(), (0, generate_routes_1.generateRoutes)()]);
50
+ await Promise.all([
51
+ (0, generate_collections_1.generateCollections)(),
52
+ (0, generate_routes_1.generateRoutes)(),
53
+ (0, generate_components_1.generateComponents)(),
54
+ ]);
50
55
  const entryPoints = (await (0, tiny_glob_1.default)("./src/back/**/*.{ts,tsx}")).filter((path) => !path.includes(".#"));
51
56
  try {
52
57
  await (0, esbuild_1.build)({
@@ -106,6 +111,8 @@ async function build_ts() {
106
111
  }
107
112
  async function complex_build(watch) {
108
113
  let scss_build = null;
114
+ let ongoing_ts = false;
115
+ let ongoing_scss = false;
109
116
  if (watch) {
110
117
  const watcher = chokidar.watch("src", { ignoreInitial: true });
111
118
  watcher.on("all", async (_, path) => {
@@ -114,6 +121,10 @@ async function complex_build(watch) {
114
121
  if (path.includes(".#"))
115
122
  return;
116
123
  if (path.endsWith(".scss") && !path.endsWith("/includes.scss")) {
124
+ if (ongoing_scss) {
125
+ return;
126
+ }
127
+ ongoing_scss = true;
117
128
  // refresh the list of all scss files in includes.scss
118
129
  await (0, find_scss_includes_1.generateScssIncludes)();
119
130
  try {
@@ -129,13 +140,19 @@ async function complex_build(watch) {
129
140
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
130
141
  .catch((e) => console.error(e?.message));
131
142
  }
143
+ ongoing_scss = false;
132
144
  }
133
145
  if ((path.endsWith(".ts") || path.endsWith(".tsx")) &&
134
146
  !path.endsWith("src/back/collections/collections.ts") &&
135
147
  !path.endsWith("src/back/routes/routes.ts") &&
136
148
  !path.endsWith("src/back/routes/urls.ts")) {
149
+ if (ongoing_ts) {
150
+ return;
151
+ }
152
+ ongoing_ts = true;
137
153
  await build_ts();
138
154
  console.log(`Finished TS build [on ${path}]`);
155
+ ongoing_ts = false;
139
156
  }
140
157
  });
141
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
package/src/build.ts CHANGED
@@ -8,6 +8,7 @@ import { generateScssIncludes } from "./find-scss-includes";
8
8
  import { sleep } from "./utils/sleep";
9
9
  import { generateCollections } from "./generate-collections";
10
10
  import { generateRoutes } from "./generate-routes";
11
+ import { generateComponents } from "./generate-components";
11
12
 
12
13
  const generate_names = (function* generate_names() {
13
14
  const base_name = "____unique_import_";
@@ -19,7 +20,11 @@ const generate_names = (function* generate_names() {
19
20
  })();
20
21
 
21
22
  async function build_ts() {
22
- await Promise.all([generateCollections(), generateRoutes()]);
23
+ await Promise.all([
24
+ generateCollections(),
25
+ generateRoutes(),
26
+ generateComponents(),
27
+ ]);
23
28
  const entryPoints = (await glob("./src/back/**/*.{ts,tsx}")).filter(
24
29
  (path) => !path.includes(".#")
25
30
  );
@@ -116,12 +121,18 @@ async function build_ts() {
116
121
 
117
122
  async function complex_build(watch: boolean): Promise<void> {
118
123
  let scss_build: BuildResult | null = null;
124
+ let ongoing_ts = false;
125
+ let ongoing_scss = false;
119
126
  if (watch) {
120
127
  const watcher = chokidar.watch("src", { ignoreInitial: true });
121
128
  watcher.on("all", async (_, path) => {
122
129
  if (!scss_build) return;
123
130
  if (path.includes(".#")) return;
124
131
  if (path.endsWith(".scss") && !path.endsWith("/includes.scss")) {
132
+ if (ongoing_scss) {
133
+ return;
134
+ }
135
+ ongoing_scss = true;
125
136
  // refresh the list of all scss files in includes.scss
126
137
  await generateScssIncludes();
127
138
  try {
@@ -136,6 +147,7 @@ async function complex_build(watch: boolean): Promise<void> {
136
147
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
137
148
  .catch((e) => console.error(e?.message));
138
149
  }
150
+ ongoing_scss = false;
139
151
  }
140
152
  if (
141
153
  (path.endsWith(".ts") || path.endsWith(".tsx")) &&
@@ -143,8 +155,13 @@ async function complex_build(watch: boolean): Promise<void> {
143
155
  !path.endsWith("src/back/routes/routes.ts") &&
144
156
  !path.endsWith("src/back/routes/urls.ts")
145
157
  ) {
158
+ if (ongoing_ts) {
159
+ return;
160
+ }
161
+ ongoing_ts = true;
146
162
  await build_ts();
147
163
  console.log(`Finished TS build [on ${path}]`);
164
+ ongoing_ts = false;
148
165
  }
149
166
  });
150
167
  }