@sealcode/sealgen 0.11.4 → 0.11.5
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/find-css-includes.d.ts +1 -0
- package/lib/add-jdd-component.js +1 -1
- package/lib/build.js +26 -26
- package/lib/cli.js +2 -2
- package/lib/find-css-includes.js +30 -0
- package/lib/find-scss-includes.js +8 -8
- package/package.json +2 -2
- package/src/add-jdd-component.ts +1 -1
- package/src/build.ts +32 -27
- package/src/cli.ts +2 -2
- package/src/{find-scss-includes.ts → find-css-includes.ts} +10 -10
- package/src/forms/{forms.scss → forms.css} +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generate_css_includes(): Promise<void>;
|
package/lib/add-jdd-component.js
CHANGED
|
@@ -22,7 +22,7 @@ async function addJDDComponent() {
|
|
|
22
22
|
}
|
|
23
23
|
await fs_1.promises.mkdir((0, path_1.resolve)(file_path, "../"), { recursive: true });
|
|
24
24
|
await fs_1.promises.writeFile(file_path, (0, jdd_component_1.jddComponentTemplate)(component_name));
|
|
25
|
-
const css_file_path = target_locreq.resolve(`src/back/jdd-components/${(0, js_convert_case_1.toKebabCase)(component_name)}/${(0, js_convert_case_1.toKebabCase)(component_name)}.
|
|
25
|
+
const css_file_path = target_locreq.resolve(`src/back/jdd-components/${(0, js_convert_case_1.toKebabCase)(component_name)}/${(0, js_convert_case_1.toKebabCase)(component_name)}.css`);
|
|
26
26
|
await fs_1.promises.writeFile(css_file_path, `.${(0, js_convert_case_1.toKebabCase)(component_name)} {
|
|
27
27
|
}`);
|
|
28
28
|
// eslint-disable-next-line no-console
|
package/lib/build.js
CHANGED
|
@@ -30,10 +30,9 @@ exports.buildProject = void 0;
|
|
|
30
30
|
const esbuild_1 = require("esbuild");
|
|
31
31
|
const fs_1 = require("fs");
|
|
32
32
|
const path_1 = require("path");
|
|
33
|
-
const esbuild_sass_plugin_1 = require("esbuild-sass-plugin");
|
|
34
33
|
const chokidar = __importStar(require("chokidar"));
|
|
35
34
|
const tiny_glob_1 = __importDefault(require("tiny-glob"));
|
|
36
|
-
const
|
|
35
|
+
const find_css_includes_1 = require("./find-css-includes");
|
|
37
36
|
const sleep_1 = require("./utils/sleep");
|
|
38
37
|
const generate_collections_1 = require("./generate-collections");
|
|
39
38
|
const generate_routes_1 = require("./generate-routes");
|
|
@@ -110,37 +109,47 @@ async function build_ts() {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
async function complex_build(watch) {
|
|
113
|
-
|
|
112
|
+
const loader = Object.fromEntries(["png", "svg", "jpg", "gif", "jpeg", "otf", "ttf"].map((ext) => ["." + ext, "file"]));
|
|
113
|
+
console.log({ loader });
|
|
114
|
+
let css_build = await (0, esbuild_1.context)({
|
|
115
|
+
entryPoints: ["./src/main.css"],
|
|
116
|
+
sourcemap: true,
|
|
117
|
+
bundle: true,
|
|
118
|
+
outdir: "./public/dist",
|
|
119
|
+
logLevel: "info",
|
|
120
|
+
// plugins: [sassPlugin()],
|
|
121
|
+
loader,
|
|
122
|
+
});
|
|
114
123
|
let ongoing_ts = false;
|
|
115
|
-
let
|
|
124
|
+
let ongoing_css = false;
|
|
116
125
|
if (watch) {
|
|
117
126
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
118
127
|
watcher.on("all", async (_, path) => {
|
|
119
|
-
if (!
|
|
128
|
+
if (!css_build)
|
|
120
129
|
return;
|
|
121
130
|
if (path.includes(".#"))
|
|
122
131
|
return;
|
|
123
|
-
if (path.endsWith(".
|
|
124
|
-
if (
|
|
132
|
+
if (path.endsWith(".css") && !path.endsWith("/includes.css")) {
|
|
133
|
+
if (ongoing_css) {
|
|
125
134
|
return;
|
|
126
135
|
}
|
|
127
|
-
|
|
128
|
-
// refresh the list of all
|
|
129
|
-
await (0,
|
|
136
|
+
ongoing_css = true;
|
|
137
|
+
// refresh the list of all css files in includes.css
|
|
138
|
+
await (0, find_css_includes_1.generate_css_includes)();
|
|
130
139
|
try {
|
|
131
|
-
await
|
|
132
|
-
console.log(`Built main.
|
|
140
|
+
await css_build?.rebuild?.();
|
|
141
|
+
console.log(`Built main.css [on ${path}]`);
|
|
133
142
|
}
|
|
134
143
|
catch (e) {
|
|
135
144
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
136
145
|
console.error(e.message);
|
|
137
146
|
await (0, sleep_1.sleep)(200);
|
|
138
|
-
|
|
147
|
+
css_build
|
|
139
148
|
?.rebuild?.()
|
|
140
149
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
141
150
|
.catch((e) => console.error(e?.message));
|
|
142
151
|
}
|
|
143
|
-
|
|
152
|
+
ongoing_css = false;
|
|
144
153
|
}
|
|
145
154
|
if ((path.endsWith(".ts") || path.endsWith(".tsx")) &&
|
|
146
155
|
!path.endsWith("src/back/collections/collections.ts") &&
|
|
@@ -156,17 +165,9 @@ async function complex_build(watch) {
|
|
|
156
165
|
}
|
|
157
166
|
});
|
|
158
167
|
}
|
|
159
|
-
await (0,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
sourcemap: true,
|
|
163
|
-
outfile: "./public/dist/style.css",
|
|
164
|
-
logLevel: "info",
|
|
165
|
-
incremental: watch,
|
|
166
|
-
plugins: [(0, esbuild_sass_plugin_1.sassPlugin)()],
|
|
167
|
-
});
|
|
168
|
-
await build_ts();
|
|
169
|
-
watch && scss_build?.rebuild?.();
|
|
168
|
+
await (0, find_css_includes_1.generate_css_includes)();
|
|
169
|
+
await Promise.all([css_build.rebuild(), build_ts()]);
|
|
170
|
+
watch && css_build?.rebuild?.();
|
|
170
171
|
}
|
|
171
172
|
async function buildProject({ watch, }) {
|
|
172
173
|
try {
|
|
@@ -176,7 +177,6 @@ async function buildProject({ watch, }) {
|
|
|
176
177
|
outfile: "./public/dist/bundle.js",
|
|
177
178
|
logLevel: "info",
|
|
178
179
|
bundle: true,
|
|
179
|
-
watch,
|
|
180
180
|
});
|
|
181
181
|
await complex_build(watch);
|
|
182
182
|
}
|
package/lib/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ const add_collection_1 = require("./add-collection");
|
|
|
5
5
|
const add_jdd_component_1 = require("./add-jdd-component");
|
|
6
6
|
const add_route_1 = require("./add-route");
|
|
7
7
|
const build_1 = require("./build");
|
|
8
|
-
const
|
|
8
|
+
const find_css_includes_1 = require("./find-css-includes");
|
|
9
9
|
const generate_collections_1 = require("./generate-collections");
|
|
10
10
|
const generate_components_1 = require("./generate-components");
|
|
11
11
|
const generate_routes_1 = require("./generate-routes");
|
|
@@ -16,7 +16,7 @@ const actions = {
|
|
|
16
16
|
"generate-collections": generate_collections_1.generateCollections,
|
|
17
17
|
"generate-components": generate_components_1.generateComponents,
|
|
18
18
|
"generate-routes": generate_routes_1.generateRoutes,
|
|
19
|
-
"generate-
|
|
19
|
+
"generate-css-includes": find_css_includes_1.generate_css_includes,
|
|
20
20
|
build: build_1.buildProject,
|
|
21
21
|
default: async function () {
|
|
22
22
|
console.log("Usage: `sealscript <action>`");
|
|
@@ -0,0 +1,30 @@
|
|
|
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.generate_css_includes = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const locreq_1 = __importDefault(require("locreq"));
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const walk_1 = require("./utils/walk");
|
|
11
|
+
const target_locreq = (0, locreq_1.default)(process.cwd());
|
|
12
|
+
async function generate_css_includes() {
|
|
13
|
+
const files = await Promise.all((await (0, walk_1.walkDir)(target_locreq.resolve("src/")))
|
|
14
|
+
.filter((f) => f.endsWith(".css") &&
|
|
15
|
+
!f.endsWith("/main.css") &&
|
|
16
|
+
!f.endsWith("\\main.css") &&
|
|
17
|
+
!f.endsWith("/includes.css") &&
|
|
18
|
+
!f.endsWith("\\includes.css") &&
|
|
19
|
+
!f.includes(".#"))
|
|
20
|
+
.map((fullpath) => (0, path_1.relative)(target_locreq.resolve("src/"), fullpath)));
|
|
21
|
+
await fs_1.promises.writeFile(target_locreq.resolve("src/includes.css"), `/* DO NOT EDIT! This file is generated automaticaly with npx sealgen generate-css-includes */
|
|
22
|
+
|
|
23
|
+
@import "../node_modules/@sealcode/sealgen/src/forms/forms.css";
|
|
24
|
+
${files.map((path) => `@import "${path.replaceAll("\\", "/")}";`).join("\n")}
|
|
25
|
+
`);
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.log("Successfuly generated new src/includes.css file");
|
|
28
|
+
}
|
|
29
|
+
exports.generate_css_includes = generate_css_includes;
|
|
30
|
+
//# sourceMappingURL=find-css-includes.js.map
|
|
@@ -11,20 +11,20 @@ const walk_1 = require("./utils/walk");
|
|
|
11
11
|
const target_locreq = (0, locreq_1.default)(process.cwd());
|
|
12
12
|
async function generateScssIncludes() {
|
|
13
13
|
const files = await Promise.all((await (0, walk_1.walkDir)(target_locreq.resolve("src/")))
|
|
14
|
-
.filter((f) => f.endsWith(".
|
|
15
|
-
!f.endsWith("/main.
|
|
16
|
-
!f.endsWith("\\main.
|
|
17
|
-
!f.endsWith("/includes.
|
|
18
|
-
!f.endsWith("\\includes.
|
|
14
|
+
.filter((f) => f.endsWith(".css") &&
|
|
15
|
+
!f.endsWith("/main.css") &&
|
|
16
|
+
!f.endsWith("\\main.css") &&
|
|
17
|
+
!f.endsWith("/includes.css") &&
|
|
18
|
+
!f.endsWith("\\includes.css") &&
|
|
19
19
|
!f.includes(".#"))
|
|
20
20
|
.map((fullpath) => (0, path_1.relative)(target_locreq.resolve("src/"), fullpath)));
|
|
21
|
-
await fs_1.promises.writeFile(target_locreq.resolve("src/includes.
|
|
21
|
+
await fs_1.promises.writeFile(target_locreq.resolve("src/includes.css"), `/* DO NOT EDIT! This file is generated automaticaly with npx sealgen generate-scss-includes */
|
|
22
22
|
|
|
23
|
-
@import "../node_modules/@sealcode/sealgen/src/forms/forms.
|
|
23
|
+
@import "../node_modules/@sealcode/sealgen/src/forms/forms.css";
|
|
24
24
|
${files.map((path) => `@import "${path.replaceAll("\\", "/")}";`).join("\n")}
|
|
25
25
|
`);
|
|
26
26
|
// eslint-disable-next-line no-console
|
|
27
|
-
console.log("Successfuly generated new src/includes.
|
|
27
|
+
console.log("Successfuly generated new src/includes.css file");
|
|
28
28
|
}
|
|
29
29
|
exports.generateScssIncludes = generateScssIncludes;
|
|
30
30
|
//# sourceMappingURL=find-scss-includes.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.5",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@koa/router": "^12.0.1",
|
|
50
50
|
"@sealcode/ts-predicates": "^0.4.3",
|
|
51
51
|
"deepmerge": "^4.3.1",
|
|
52
|
-
"esbuild": "^0.
|
|
52
|
+
"esbuild": "^0.20.0",
|
|
53
53
|
"esbuild-sass-plugin": "^2.3.1",
|
|
54
54
|
"js-convert-case": "^4.2.0",
|
|
55
55
|
"koa": "^2.13.0",
|
package/src/add-jdd-component.ts
CHANGED
|
@@ -29,7 +29,7 @@ export async function addJDDComponent(): Promise<void> {
|
|
|
29
29
|
const css_file_path = target_locreq.resolve(
|
|
30
30
|
`src/back/jdd-components/${toKebabCase(component_name)}/${toKebabCase(
|
|
31
31
|
component_name
|
|
32
|
-
)}.
|
|
32
|
+
)}.css`
|
|
33
33
|
);
|
|
34
34
|
await fs.writeFile(
|
|
35
35
|
css_file_path,
|
package/src/build.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { build, BuildResult } from "esbuild";
|
|
1
|
+
import { build, BuildContext, BuildResult, context } from "esbuild";
|
|
2
2
|
import { promises as fs } from "fs";
|
|
3
3
|
import { extname } from "path";
|
|
4
|
-
import { sassPlugin } from "esbuild-sass-plugin";
|
|
5
4
|
import * as chokidar from "chokidar";
|
|
6
5
|
import { default as glob } from "tiny-glob";
|
|
7
|
-
import {
|
|
6
|
+
import { generate_css_includes } from "./find-css-includes";
|
|
8
7
|
import { sleep } from "./utils/sleep";
|
|
9
8
|
import { generateCollections } from "./generate-collections";
|
|
10
9
|
import { generateRoutes } from "./generate-routes";
|
|
@@ -120,34 +119,48 @@ async function build_ts() {
|
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
async function complex_build(watch: boolean): Promise<void> {
|
|
123
|
-
|
|
122
|
+
const loader = Object.fromEntries(
|
|
123
|
+
(<const>["png", "svg", "jpg", "gif", "jpeg", "otf", "ttf"]).map(
|
|
124
|
+
(ext) => <const>["." + ext, "file"]
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
console.log({ loader });
|
|
128
|
+
let css_build: BuildContext = await context({
|
|
129
|
+
entryPoints: ["./src/main.css"],
|
|
130
|
+
sourcemap: true,
|
|
131
|
+
bundle: true,
|
|
132
|
+
outdir: "./public/dist",
|
|
133
|
+
logLevel: "info",
|
|
134
|
+
// plugins: [sassPlugin()],
|
|
135
|
+
loader,
|
|
136
|
+
});
|
|
124
137
|
let ongoing_ts = false;
|
|
125
|
-
let
|
|
138
|
+
let ongoing_css = false;
|
|
126
139
|
if (watch) {
|
|
127
140
|
const watcher = chokidar.watch("src", { ignoreInitial: true });
|
|
128
141
|
watcher.on("all", async (_, path) => {
|
|
129
|
-
if (!
|
|
142
|
+
if (!css_build) return;
|
|
130
143
|
if (path.includes(".#")) return;
|
|
131
|
-
if (path.endsWith(".
|
|
132
|
-
if (
|
|
144
|
+
if (path.endsWith(".css") && !path.endsWith("/includes.css")) {
|
|
145
|
+
if (ongoing_css) {
|
|
133
146
|
return;
|
|
134
147
|
}
|
|
135
|
-
|
|
136
|
-
// refresh the list of all
|
|
137
|
-
await
|
|
148
|
+
ongoing_css = true;
|
|
149
|
+
// refresh the list of all css files in includes.css
|
|
150
|
+
await generate_css_includes();
|
|
138
151
|
try {
|
|
139
|
-
await
|
|
140
|
-
console.log(`Built main.
|
|
152
|
+
await css_build?.rebuild?.();
|
|
153
|
+
console.log(`Built main.css [on ${path}]`);
|
|
141
154
|
} catch (e) {
|
|
142
155
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
143
156
|
console.error(e.message);
|
|
144
157
|
await sleep(200);
|
|
145
|
-
|
|
158
|
+
css_build
|
|
146
159
|
?.rebuild?.()
|
|
147
160
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
148
161
|
.catch((e) => console.error(e?.message));
|
|
149
162
|
}
|
|
150
|
-
|
|
163
|
+
ongoing_css = false;
|
|
151
164
|
}
|
|
152
165
|
if (
|
|
153
166
|
(path.endsWith(".ts") || path.endsWith(".tsx")) &&
|
|
@@ -165,17 +178,10 @@ async function complex_build(watch: boolean): Promise<void> {
|
|
|
165
178
|
}
|
|
166
179
|
});
|
|
167
180
|
}
|
|
168
|
-
await
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
outfile: "./public/dist/style.css",
|
|
173
|
-
logLevel: "info",
|
|
174
|
-
incremental: watch,
|
|
175
|
-
plugins: [sassPlugin()],
|
|
176
|
-
});
|
|
177
|
-
await build_ts();
|
|
178
|
-
watch && scss_build?.rebuild?.();
|
|
181
|
+
await generate_css_includes();
|
|
182
|
+
|
|
183
|
+
await Promise.all([css_build.rebuild(), build_ts()]);
|
|
184
|
+
watch && css_build?.rebuild?.();
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
export async function buildProject({
|
|
@@ -190,7 +196,6 @@ export async function buildProject({
|
|
|
190
196
|
outfile: "./public/dist/bundle.js",
|
|
191
197
|
logLevel: "info",
|
|
192
198
|
bundle: true,
|
|
193
|
-
watch,
|
|
194
199
|
});
|
|
195
200
|
await complex_build(watch);
|
|
196
201
|
} catch (e) {
|
package/src/cli.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { addCollection } from "./add-collection";
|
|
|
3
3
|
import { addJDDComponent } from "./add-jdd-component";
|
|
4
4
|
import { addRoute } from "./add-route";
|
|
5
5
|
import { buildProject } from "./build";
|
|
6
|
-
import {
|
|
6
|
+
import { generate_css_includes } from "./find-css-includes";
|
|
7
7
|
import { generateCollections } from "./generate-collections";
|
|
8
8
|
import { generateComponents } from "./generate-components";
|
|
9
9
|
import { generateRoutes } from "./generate-routes";
|
|
@@ -18,7 +18,7 @@ const actions: Record<
|
|
|
18
18
|
"generate-collections": generateCollections,
|
|
19
19
|
"generate-components": generateComponents,
|
|
20
20
|
"generate-routes": generateRoutes,
|
|
21
|
-
"generate-
|
|
21
|
+
"generate-css-includes": generate_css_includes,
|
|
22
22
|
build: buildProject,
|
|
23
23
|
default: async function () {
|
|
24
24
|
console.log("Usage: `sealscript <action>`");
|
|
@@ -5,16 +5,16 @@ import { walkDir } from "./utils/walk";
|
|
|
5
5
|
|
|
6
6
|
const target_locreq = _locreq(process.cwd());
|
|
7
7
|
|
|
8
|
-
export async function
|
|
8
|
+
export async function generate_css_includes(): Promise<void> {
|
|
9
9
|
const files = await Promise.all(
|
|
10
10
|
(await walkDir(target_locreq.resolve("src/")))
|
|
11
11
|
.filter(
|
|
12
12
|
(f) =>
|
|
13
|
-
f.endsWith(".
|
|
14
|
-
!f.endsWith("/main.
|
|
15
|
-
!f.endsWith("\\main.
|
|
16
|
-
!f.endsWith("/includes.
|
|
17
|
-
!f.endsWith("\\includes.
|
|
13
|
+
f.endsWith(".css") &&
|
|
14
|
+
!f.endsWith("/main.css") &&
|
|
15
|
+
!f.endsWith("\\main.css") &&
|
|
16
|
+
!f.endsWith("/includes.css") &&
|
|
17
|
+
!f.endsWith("\\includes.css") &&
|
|
18
18
|
!f.includes(".#")
|
|
19
19
|
)
|
|
20
20
|
.map((fullpath) =>
|
|
@@ -23,13 +23,13 @@ export async function generateScssIncludes(): Promise<void> {
|
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
await fs.writeFile(
|
|
26
|
-
target_locreq.resolve("src/includes.
|
|
27
|
-
|
|
26
|
+
target_locreq.resolve("src/includes.css"),
|
|
27
|
+
`/* DO NOT EDIT! This file is generated automaticaly with npx sealgen generate-css-includes */
|
|
28
28
|
|
|
29
|
-
@import "../node_modules/@sealcode/sealgen/src/forms/forms.
|
|
29
|
+
@import "../node_modules/@sealcode/sealgen/src/forms/forms.css";
|
|
30
30
|
${files.map((path) => `@import "${path.replaceAll("\\", "/")}";`).join("\n")}
|
|
31
31
|
`
|
|
32
32
|
);
|
|
33
33
|
// eslint-disable-next-line no-console
|
|
34
|
-
console.log("Successfuly generated new src/includes.
|
|
34
|
+
console.log("Successfuly generated new src/includes.css file");
|
|
35
35
|
}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
border: 1px solid var(--color);
|
|
4
4
|
border-radius: 5px;
|
|
5
5
|
padding: 10px;
|
|
6
|
+
}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
.form-message--error {
|
|
9
|
+
--color: #ff4136;
|
|
10
|
+
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
12
|
+
.form-message--success {
|
|
13
|
+
--color: #2ecc40;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.form__error {
|