@autobusal/utilities 1.3.0 → 1.4.0
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/CHANGELOG.md +15 -27
- package/check-backticks.mjs +91 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## 1.3.0
|
|
6
|
-
|
|
7
|
-
`getDayParts` — the same short date as `getFormattedShort`, but in its parts.
|
|
8
|
-
One string cannot be shortened by CSS, and the seven-day strip needs to drop
|
|
9
|
-
the month on a narrow screen so seven days fit without a scroller.
|
|
10
|
-
|
|
11
|
-
## [1.2.0] - 2026-07-25
|
|
12
|
-
|
|
13
|
-
### Added
|
|
14
|
-
|
|
15
|
-
- `GetChannelStatus(t)`: shared disabled/dedicated/main select values for
|
|
16
|
-
the Telegram and WhatsApp admin settings tabs (and any future per-label
|
|
17
|
-
messaging channel).
|
|
18
|
-
|
|
19
|
-
## [1.1.2] - 2026-07-24
|
|
3
|
+
## 1.4.0
|
|
20
4
|
|
|
21
5
|
### Added
|
|
22
6
|
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
## [1.1.1] - 2026-07-19
|
|
26
|
-
|
|
27
|
-
### Added
|
|
7
|
+
- **`check-backticks.mjs`**, moved here from the autobusal repo root so the
|
|
8
|
+
apps can run it too.
|
|
28
9
|
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
A backtick used as quoting inside a styled-components template *terminates
|
|
11
|
+
the template*. The bundler then reports a syntax error somewhere further
|
|
12
|
+
down, pointing at a line that is perfectly fine — so the search starts in
|
|
13
|
+
the wrong place every time. Per the script's own history that cost five
|
|
14
|
+
build failures in one session before anyone connected the two.
|
|
31
15
|
|
|
32
|
-
|
|
16
|
+
It only ever guarded `packages`, and the trap is not confined there: it bit
|
|
17
|
+
`magus/src` the moment a public page grew its own styled-components, with
|
|
18
|
+
nothing watching. Each app's `prebuild` now runs it over its own `src`
|
|
19
|
+
(first, so a broken template stops the build before it spends minutes
|
|
20
|
+
copying files), and `publish.sh` still runs it over `packages`.
|
|
33
21
|
|
|
34
|
-
|
|
22
|
+
One script with three callers, rather than a copy per repo that drifts.
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
Takes the directory to scan as its argument.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Refuse to publish a backtick used as quoting inside a styled-components
|
|
4
|
+
* template literal.
|
|
5
|
+
*
|
|
6
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-03
|
|
7
|
+
*
|
|
8
|
+
* A backtick inside a CSS comment TERMINATES the template string. What the
|
|
9
|
+
* bundler then reports is a syntax error somewhere further down, pointing at
|
|
10
|
+
* a line that is perfectly fine - so the search starts in the wrong place
|
|
11
|
+
* every time. It cost five build failures in a single session before anyone
|
|
12
|
+
* connected the two.
|
|
13
|
+
*
|
|
14
|
+
* TWO THINGS HERE ARE LEGITIMATE and must never be flagged, which is why
|
|
15
|
+
* this is not a plain grep:
|
|
16
|
+
*
|
|
17
|
+
* - nested css`...` interpolations, which this codebase uses everywhere
|
|
18
|
+
* - backticks in the JSDoc ABOVE a styled block, which are idiomatic and
|
|
19
|
+
* sit outside the template entirely
|
|
20
|
+
*
|
|
21
|
+
* The bug is only ever the intersection: a backtick inside a comment that
|
|
22
|
+
* sits BETWEEN styled.x` and its closing `;
|
|
23
|
+
*
|
|
24
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-06
|
|
25
|
+
* Moved into @autobusal/utilities from the repo root, so the APPS can run it
|
|
26
|
+
* too. It only ever guarded `packages`, and the trap is not confined there:
|
|
27
|
+
* it bit magus/src the moment a public page grew its own styled-components,
|
|
28
|
+
* with nothing watching. Each app's prebuild now runs it over its own src,
|
|
29
|
+
* and publish.sh still runs it over packages - one script, three callers,
|
|
30
|
+
* rather than a copy per repo that drifts.
|
|
31
|
+
*
|
|
32
|
+
* Takes the directory to scan as its argument.
|
|
33
|
+
*/
|
|
34
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
35
|
+
import { join } from 'node:path';
|
|
36
|
+
|
|
37
|
+
const OPEN = /styled(?:\.\w+|\([^)]*\))(?:<[^>]*>)?`/g;
|
|
38
|
+
|
|
39
|
+
const walk = (dir) => readdirSync(dir).flatMap((entry) => {
|
|
40
|
+
const path = join(dir, entry);
|
|
41
|
+
|
|
42
|
+
if (entry === 'node_modules' || entry.startsWith('.')) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (statSync(path).isDirectory()) {
|
|
47
|
+
return walk(path);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return /\.tsx?$/.test(entry) ? [path] : [];
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const found = [];
|
|
54
|
+
|
|
55
|
+
for (const path of walk(process.argv[2] ?? 'packages')) {
|
|
56
|
+
const text = readFileSync(path, 'utf8');
|
|
57
|
+
|
|
58
|
+
for (const match of text.matchAll(OPEN)) {
|
|
59
|
+
const start = match.index + match[0].length;
|
|
60
|
+
const end = text.indexOf('`;', start);
|
|
61
|
+
|
|
62
|
+
if (end === -1) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const base = text.slice(0, start).split('\n').length;
|
|
67
|
+
let comment = false;
|
|
68
|
+
|
|
69
|
+
text.slice(start, end).split('\n').forEach((line, n) => {
|
|
70
|
+
if (line.includes('/*')) {
|
|
71
|
+
comment = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (comment && line.includes('`')) {
|
|
75
|
+
found.push(`${ path }:${ base + n }: ${ line.trim().slice(0, 72) }`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (line.includes('*/')) {
|
|
79
|
+
comment = false;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (found.length > 0) {
|
|
86
|
+
console.error('Backtick in a comment inside a styled template - this breaks the build:');
|
|
87
|
+
found.forEach((line) => console.error(` ${ line }`));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log('backticks: clean');
|