create-basicjs 0.1.1 → 0.1.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/package.json +1 -1
- package/payload/starter/AGENTS.md +2 -0
- package/payload/starter/_basic/VERSION +1 -1
- package/payload/starter/_basic/tools/check.js +24 -6
- package/payload/templates/panel/module10/greenhouse.htm +8 -2
- package/payload/templates/panel/module11/arduino-projects.htm +5 -0
- package/payload/templates/panel/module6/energy-hub.htm +7 -2
- package/payload/templates/panel/module8/cold-rooms.htm +4 -0
- package/payload/templates/panel/module9/elevator-fleet.htm +9 -1
package/package.json
CHANGED
|
@@ -79,4 +79,6 @@ window.checkViews = {
|
|
|
79
79
|
};
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
It checks every page, also the ones in folders. A page that can not be checked alone can say `<meta name="basic-check" content="skip">`.
|
|
83
|
+
|
|
82
84
|
The tool needs Chrome or Edge. When it can not run, run `node --check` on the files you changed, and tell the user that the page was not opened.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.3
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
// An app with more than one view tells it how to open them (the name of the file is the name of the view):
|
|
11
11
|
// window.checkViews = { orders: function () { App.showPage("orders"); }, settings: function () { App.showPage("settings"); } };
|
|
12
12
|
//
|
|
13
|
+
// Every page is checked, also the ones in folders. A page that can not be checked alone says so, and the report counts
|
|
14
|
+
// it as skipped:
|
|
15
|
+
// <meta name="basic-check" content="skip">
|
|
16
|
+
//
|
|
13
17
|
// Exit code: 0 no problem, 1 problems found, 2 could not run.
|
|
14
18
|
|
|
15
19
|
const fs = require("fs");
|
|
@@ -28,6 +32,7 @@ const SMALLEST_WINDOW = 520; // WHY: headless Chrome does not go under 500 px, s
|
|
|
28
32
|
const WAIT_FOR_PAGE_MS = 6000;
|
|
29
33
|
const STOP_CHROME_MS = 25000;
|
|
30
34
|
const MAX_PROBLEMS_SHOWN = 8;
|
|
35
|
+
const NOT_PAGE_FOLDERS = new Set(["_basic", "dist", "node_modules", ".git", ".check"]);
|
|
31
36
|
const TYPES = { ".htm": "text/html", ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".json": "application/json", ".svg": "image/svg+xml", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp", ".ttf": "font/ttf", ".woff2": "font/woff2" };
|
|
32
37
|
|
|
33
38
|
// *** THE CODE THAT RUNS IN THE PAGE (before the scripts of the page)
|
|
@@ -158,7 +163,7 @@ const PAGE_CHECK = function () {
|
|
|
158
163
|
};
|
|
159
164
|
|
|
160
165
|
const frameOf = function (pageName, width, viewName) {
|
|
161
|
-
const address = "/" + pageName + "?__view=" + encodeURIComponent(viewName);
|
|
166
|
+
const address = "/" + encodeURI(pageName) + "?__view=" + encodeURIComponent(viewName);
|
|
162
167
|
return '<!DOCTYPE html><html><body style="margin:0;background:#fff"><iframe src="' + address + '" style="display:block;width:' + width + "px;height:" + WINDOW_HEIGHT + 'px;border:0"></iframe></body></html>';
|
|
163
168
|
};
|
|
164
169
|
|
|
@@ -254,7 +259,8 @@ const printList = function (title, list) {
|
|
|
254
259
|
const checkOne = async function (browser, profile, port, pageName, width, viewName) {
|
|
255
260
|
lastReport = null;
|
|
256
261
|
missingFiles.clear();
|
|
257
|
-
const
|
|
262
|
+
const pagePart = pageName.replace(/\.html?$/i, "").replace(/[\\/]/g, "-");
|
|
263
|
+
const picture = path.join(PICTURES, pagePart + "-" + width + "-" + (viewName || "start") + ".png");
|
|
258
264
|
const address = "http://127.0.0.1:" + port + "/__frame?page=" + encodeURIComponent(pageName) + "&width=" + width + "&view=" + encodeURIComponent(viewName);
|
|
259
265
|
await openInBrowser(browser, profile, address, picture, width);
|
|
260
266
|
const report = lastReport || { errors: ["The page did not finish: it may have stopped with an error."], offScreen: [], cut: [], views: [] };
|
|
@@ -268,8 +274,17 @@ const checkOne = async function (browser, profile, port, pageName, width, viewNa
|
|
|
268
274
|
return { count: count, views: report.views };
|
|
269
275
|
};
|
|
270
276
|
|
|
271
|
-
|
|
272
|
-
|
|
277
|
+
// Every page of the project, also the ones in folders. The start page comes first.
|
|
278
|
+
const findPages = function (folder = "") {
|
|
279
|
+
const pages = [];
|
|
280
|
+
fs.readdirSync(path.join(SERVED_FOLDER, folder), { withFileTypes: true }).forEach(function (entry) {
|
|
281
|
+
const relativePath = folder ? folder + "/" + entry.name : entry.name;
|
|
282
|
+
if (entry.isDirectory()) {
|
|
283
|
+
if (!NOT_PAGE_FOLDERS.has(entry.name)) pages.push(...findPages(relativePath));
|
|
284
|
+
} else if (/\.html?$/i.test(entry.name)) {
|
|
285
|
+
pages.push(relativePath);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
273
288
|
pages.sort((a, b) => Number(/^index\./i.test(b)) - Number(/^index\./i.test(a)));
|
|
274
289
|
return pages;
|
|
275
290
|
};
|
|
@@ -284,7 +299,9 @@ const run = async function () {
|
|
|
284
299
|
console.log("dist/ does not exist. Run: node _basic/tools/build.js");
|
|
285
300
|
return 2;
|
|
286
301
|
}
|
|
287
|
-
const
|
|
302
|
+
const allPages = findPages();
|
|
303
|
+
const isSkipped = (pageName) => /<meta\s+name=["']basic-check["']\s+content=["']skip["']/i.test(fs.readFileSync(path.join(SERVED_FOLDER, pageName), "utf8"));
|
|
304
|
+
const pages = allPages.filter((pageName) => !isSkipped(pageName));
|
|
288
305
|
if (!pages.length) {
|
|
289
306
|
console.log("There is no .htm page.");
|
|
290
307
|
return 2;
|
|
@@ -297,7 +314,7 @@ const run = async function () {
|
|
|
297
314
|
|
|
298
315
|
let problems = 0;
|
|
299
316
|
for (const pageName of pages) {
|
|
300
|
-
if (pages.length > 1) console.log(pageName);
|
|
317
|
+
if (pages.length > 1) console.log("\n" + pageName);
|
|
301
318
|
for (const width of WIDTHS) {
|
|
302
319
|
const first = await checkOne(browser, profile, port, pageName, width, "");
|
|
303
320
|
problems += first.count;
|
|
@@ -308,6 +325,7 @@ const run = async function () {
|
|
|
308
325
|
}
|
|
309
326
|
server.close();
|
|
310
327
|
fs.rmSync(profile, { recursive: true, force: true, maxRetries: 3 });
|
|
328
|
+
if (allPages.length > pages.length) console.log((allPages.length - pages.length) + " page(s) skipped by their basic-check tag.");
|
|
311
329
|
console.log(problems ? problems + " problem(s). Look at the pictures in .check/ too." : "No problem found. Look at the pictures in .check/ too: this check can not judge the design.");
|
|
312
330
|
return problems ? 1 : 0;
|
|
313
331
|
};
|
|
@@ -598,9 +598,11 @@
|
|
|
598
598
|
that.elem.style.flexWrap = "wrap";
|
|
599
599
|
|
|
600
600
|
HGroup({ width: "auto", height: "auto", align: "left center", gap: 20 });
|
|
601
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
601
602
|
that.elem.style.flexWrap = "wrap";
|
|
602
603
|
|
|
603
604
|
VGroup({ width: "auto", height: "auto", align: "left top", gap: 0 });
|
|
605
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
604
606
|
Label({ text: "Greenhouse", fontSize: 26, textColor: Ink(0.95) });
|
|
605
607
|
that.elem.style.fontFamily = "opensans-bold";
|
|
606
608
|
lblHouse = Label({ text: "", fontSize: 14, textColor: Ink(0.5) });
|
|
@@ -623,15 +625,18 @@
|
|
|
623
625
|
endGroup();
|
|
624
626
|
|
|
625
627
|
HGroup({ width: "auto", height: "auto", align: "right center", gap: 16 });
|
|
628
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
626
629
|
|
|
627
630
|
VGroup({ width: "auto", height: "auto", align: "right center", gap: 0 });
|
|
631
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
628
632
|
lblClock = Label({ text: "", fontSize: 22, textColor: Ink(0.95) });
|
|
629
633
|
that.elem.style.fontVariantNumeric = "tabular-nums";
|
|
630
|
-
lblWeather = Label({ text: "", fontSize: 12, textColor: Ink(0.5) });
|
|
631
|
-
that.
|
|
634
|
+
lblWeather = Label({ text: "", width: "100%", fontSize: 12, textColor: Ink(0.5) });
|
|
635
|
+
that.css = { whiteSpace: "normal", textAlign: "right", width: "max-content", maxWidth: "100%" }; // WHY: On one line when it fits, wraps on a phone
|
|
632
636
|
endGroup();
|
|
633
637
|
|
|
634
638
|
const btnMore = createButton("More", "top-bar/apps.png", function () { });
|
|
639
|
+
btnMore.css = { flexShrink: "0" }; // WHY: The texts wrap on a phone, not this button
|
|
635
640
|
moreMenu = ContextMenu({
|
|
636
641
|
items: [
|
|
637
642
|
{ text: "Test: Heatwave outside", key: "heatwave" },
|
|
@@ -1347,6 +1352,7 @@
|
|
|
1347
1352
|
});
|
|
1348
1353
|
Theme.fillTableWidth(grpEventHost.table);
|
|
1349
1354
|
grpEventHost.table.elem.style.minWidth = "420px";
|
|
1355
|
+
grpEventHost.scrollX = 1; // WHY: a phone is narrower than the table
|
|
1350
1356
|
setDefaultContainerBox(previous);
|
|
1351
1357
|
};
|
|
1352
1358
|
|
|
@@ -377,9 +377,11 @@
|
|
|
377
377
|
that.elem.style.flexWrap = "wrap";
|
|
378
378
|
|
|
379
379
|
HGroup({ width: "auto", height: "auto", align: "left center", gap: 20 });
|
|
380
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
380
381
|
that.elem.style.flexWrap = "wrap";
|
|
381
382
|
|
|
382
383
|
VGroup({ width: "auto", height: "auto", align: "left top", gap: 0 });
|
|
384
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
383
385
|
Label({ text: "Arduino Projects", fontSize: 26, textColor: Ink(0.95) });
|
|
384
386
|
that.elem.style.fontFamily = "opensans-bold";
|
|
385
387
|
lblSubtitle = Label({ text: "", fontSize: 14, textColor: Ink(0.5) });
|
|
@@ -403,8 +405,10 @@
|
|
|
403
405
|
endGroup();
|
|
404
406
|
|
|
405
407
|
HGroup({ width: "auto", height: "auto", align: "right center", gap: 16 });
|
|
408
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
406
409
|
|
|
407
410
|
VGroup({ width: "auto", height: "auto", align: "right center", gap: 0 });
|
|
411
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
408
412
|
lblClock = Label({ text: "", fontSize: 22, textColor: Ink(0.95) });
|
|
409
413
|
that.elem.style.fontVariantNumeric = "tabular-nums";
|
|
410
414
|
lblUptime = Label({ text: "", fontSize: 12, textColor: Ink(0.5) });
|
|
@@ -412,6 +416,7 @@
|
|
|
412
416
|
endGroup();
|
|
413
417
|
|
|
414
418
|
const btnMore = createButton("More", "top-bar/apps.png", function () { });
|
|
419
|
+
btnMore.css = { flexShrink: "0" }; // WHY: The texts wrap on a phone, not this button
|
|
415
420
|
moreMenu = ContextMenu({
|
|
416
421
|
items: [
|
|
417
422
|
{ text: "Send a test line to the serial port", key: "serial" },
|
|
@@ -577,9 +577,11 @@
|
|
|
577
577
|
that.elem.style.paddingRight = "60px"; // WHY: The close button of the full view is on the right top.
|
|
578
578
|
|
|
579
579
|
HGroup({ width: "auto", height: "auto", align: "left center", gap: 20 });
|
|
580
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
580
581
|
that.elem.style.flexWrap = "wrap";
|
|
581
582
|
|
|
582
583
|
VGroup({ width: "auto", height: "auto", align: "left top", gap: 0 });
|
|
584
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
583
585
|
Label({ text: "Energy Hub", fontSize: 26, textColor: Ink(0.95) });
|
|
584
586
|
that.elem.style.fontFamily = "opensans-bold";
|
|
585
587
|
Label({ text: system.site + " · Solar " + system.pv.peakKw + " kWp · Battery " + system.battery.capacity + " kWh · EV charger", fontSize: 14, textColor: Ink(0.5) });
|
|
@@ -591,15 +593,18 @@
|
|
|
591
593
|
endGroup();
|
|
592
594
|
|
|
593
595
|
HGroup({ width: "auto", height: "auto", align: "right center", gap: 16 });
|
|
596
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
594
597
|
|
|
595
598
|
VGroup({ width: "auto", height: "auto", align: "right center", gap: 0 });
|
|
599
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
596
600
|
lblClock = Label({ text: "", fontSize: 22, textColor: Ink(0.95) });
|
|
597
601
|
that.elem.style.fontVariantNumeric = "tabular-nums";
|
|
598
|
-
lblWeather = Label({ text: "", fontSize: 12, textColor: Ink(0.5) });
|
|
599
|
-
that.
|
|
602
|
+
lblWeather = Label({ text: "", width: "100%", fontSize: 12, textColor: Ink(0.5) });
|
|
603
|
+
that.css = { whiteSpace: "normal", textAlign: "right", width: "max-content", maxWidth: "100%" }; // WHY: On one line when it fits, wraps on a phone
|
|
600
604
|
endGroup();
|
|
601
605
|
|
|
602
606
|
const btnMore = createButton("More", "top-bar/apps.png", function () { });
|
|
607
|
+
btnMore.css = { flexShrink: "0" }; // WHY: The texts wrap on a phone, not this button
|
|
603
608
|
|
|
604
609
|
moreMenu = ContextMenu({
|
|
605
610
|
items: [
|
|
@@ -560,9 +560,11 @@
|
|
|
560
560
|
|
|
561
561
|
// Title and device select
|
|
562
562
|
HGroup({ width: "auto", height: "auto", align: "left center", gap: 20 });
|
|
563
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
563
564
|
that.elem.style.flexWrap = "wrap";
|
|
564
565
|
|
|
565
566
|
VGroup({ width: "auto", height: "auto", align: "left top", gap: 0 });
|
|
567
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
566
568
|
|
|
567
569
|
Label({
|
|
568
570
|
text: "Cold Rooms",
|
|
@@ -616,12 +618,14 @@
|
|
|
616
618
|
|
|
617
619
|
// Buttons
|
|
618
620
|
HGroup({ width: "auto", height: "auto", align: "right center", gap: 10 });
|
|
621
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
619
622
|
|
|
620
623
|
createButton("Refresh", "", function () {
|
|
621
624
|
reconnectDevice(device);
|
|
622
625
|
});
|
|
623
626
|
|
|
624
627
|
btnMore = createButton("More", "top-bar/apps.png", function () { });
|
|
628
|
+
btnMore.css = { flexShrink: "0" }; // WHY: The texts wrap on a phone, not this button
|
|
625
629
|
|
|
626
630
|
// MENU: More actions
|
|
627
631
|
moreMenu = ContextMenu({
|
|
@@ -619,9 +619,11 @@
|
|
|
619
619
|
that.elem.style.flexWrap = "wrap";
|
|
620
620
|
|
|
621
621
|
HGroup({ width: "auto", height: "auto", align: "left center", gap: 20 });
|
|
622
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
622
623
|
that.elem.style.flexWrap = "wrap";
|
|
623
624
|
|
|
624
625
|
VGroup({ width: "auto", height: "auto", align: "left top", gap: 0 });
|
|
626
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
625
627
|
Label({ text: "Elevator Fleet", fontSize: 26, textColor: Ink(0.95) });
|
|
626
628
|
that.elem.style.fontFamily = "opensans-bold";
|
|
627
629
|
lblBuilding = Label({ text: "", fontSize: 14, textColor: Ink(0.5) });
|
|
@@ -655,8 +657,10 @@
|
|
|
655
657
|
endGroup();
|
|
656
658
|
|
|
657
659
|
HGroup({ width: "auto", height: "auto", align: "right center", gap: 10 });
|
|
660
|
+
that.css = { maxWidth: "100%", minWidth: "0px", flexShrink: "1" }; // WHY: "auto" grows with its content, out of the screen of a phone
|
|
658
661
|
|
|
659
662
|
const btnMore = createButton("More", "top-bar/apps.png", function () { });
|
|
663
|
+
btnMore.css = { flexShrink: "0" }; // WHY: The texts wrap on a phone, not this button
|
|
660
664
|
|
|
661
665
|
moreMenu = ContextMenu({
|
|
662
666
|
items: [
|
|
@@ -839,12 +843,15 @@
|
|
|
839
843
|
|
|
840
844
|
VGroup({ width: "100%", height: "auto", align: "left top", gap: 10 });
|
|
841
845
|
MODES.forEach(function (mode) {
|
|
842
|
-
RadioButton({
|
|
846
|
+
const radio = RadioButton({
|
|
843
847
|
group: "carMode", value: mode.value,
|
|
844
848
|
labelText: mode.text + "<br><span style='color:" + Ink(0.4) + "; font-size: 12px'>" + mode.desc + "</span>",
|
|
845
849
|
style: DARK_RADIO_STYLE,
|
|
846
850
|
onChange: function (self) { onModeChange(self.value); },
|
|
847
851
|
});
|
|
852
|
+
// WHY: A long description was cut by the card, on a desktop too
|
|
853
|
+
radio.css = { maxWidth: "100%" };
|
|
854
|
+
radio.label.css.whiteSpace = "normal";
|
|
848
855
|
});
|
|
849
856
|
endGroup();
|
|
850
857
|
|
|
@@ -1474,6 +1481,7 @@
|
|
|
1474
1481
|
});
|
|
1475
1482
|
Theme.fillTableWidth(grpEventHost.table);
|
|
1476
1483
|
grpEventHost.table.elem.style.minWidth = "420px";
|
|
1484
|
+
grpEventHost.scrollX = 1; // WHY: a phone is narrower than the table
|
|
1477
1485
|
setDefaultContainerBox(previous);
|
|
1478
1486
|
};
|
|
1479
1487
|
|