stay-gold 1.0.3 → 1.0.4
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/dist/bang.js +5 -22
- package/dist/css-named-colors.d.ts +1 -0
- package/dist/css-named-colors.js +8 -9
- package/dist/css-vars.d.ts +1 -0
- package/dist/css-vars.js +10 -15
- package/dist/todos.d.ts +1 -0
- package/dist/todos.js +9 -25
- package/dist/walk.d.ts +2 -0
- package/dist/walk.js +18 -0
- package/package.json +1 -1
package/dist/bang.js
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// check-for-bang.js
|
|
3
3
|
// Script to check for the string "// !" in project files and exit with error if found
|
|
4
|
-
import {
|
|
5
|
-
import { resolve
|
|
6
|
-
import {
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = dirname(__filename);
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { walk } from "./walk.js";
|
|
9
7
|
const exts = [".js", ".ts", ".astro", ".css", ".tsx"];
|
|
10
8
|
const rootDir = resolve(process.cwd(), "src");
|
|
11
9
|
const publicDir = resolve(process.cwd(), "public");
|
|
12
|
-
function walk(dir) {
|
|
13
|
-
let results = [];
|
|
14
|
-
const list = readdirSync(dir);
|
|
15
|
-
list.forEach((file) => {
|
|
16
|
-
const filePath = join(dir, file);
|
|
17
|
-
const stat = statSync(filePath);
|
|
18
|
-
if (stat === null || stat === void 0 ? void 0 : stat.isDirectory()) {
|
|
19
|
-
results = results.concat(walk(filePath));
|
|
20
|
-
}
|
|
21
|
-
else if (exts.includes(extname(file))) {
|
|
22
|
-
results.push(filePath);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return results;
|
|
26
|
-
}
|
|
27
10
|
function checkFiles(files) {
|
|
28
11
|
let found = false;
|
|
29
12
|
files.forEach((file) => {
|
|
@@ -37,8 +20,8 @@ function checkFiles(files) {
|
|
|
37
20
|
});
|
|
38
21
|
return found;
|
|
39
22
|
}
|
|
40
|
-
const srcFiles = walk(rootDir);
|
|
41
|
-
const publicFiles = walk(publicDir);
|
|
23
|
+
const srcFiles = walk(rootDir, exts);
|
|
24
|
+
const publicFiles = walk(publicDir, exts);
|
|
42
25
|
const allFiles = srcFiles.concat(publicFiles);
|
|
43
26
|
if (checkFiles(allFiles)) {
|
|
44
27
|
process.exit(1);
|
package/dist/css-named-colors.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// check-css-named-colors.ts
|
|
2
3
|
// Script to check for usage of named CSS colors in styles folder
|
|
3
|
-
import
|
|
4
|
-
import
|
|
4
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
5
|
+
import { resolve, join, extname } from "node:path";
|
|
5
6
|
import { namedColors } from "./named-colors.js";
|
|
6
|
-
const
|
|
7
|
-
const stylesDir = path.resolve(__dirname, "src/styles");
|
|
7
|
+
const stylesDir = resolve(process.cwd(), "src/styles");
|
|
8
8
|
const exts = [".css"];
|
|
9
|
-
// List of named CSS colors (partial, can be expanded)
|
|
10
9
|
function walkCssFiles(dir) {
|
|
11
|
-
return
|
|
12
|
-
.filter((f) => exts.includes(
|
|
13
|
-
.map((f) =>
|
|
10
|
+
return readdirSync(dir)
|
|
11
|
+
.filter((f) => exts.includes(extname(f)))
|
|
12
|
+
.map((f) => join(dir, f));
|
|
14
13
|
}
|
|
15
14
|
function checkNamedColors(files) {
|
|
16
15
|
let totalCount = 0;
|
|
17
16
|
files.forEach((file) => {
|
|
18
|
-
const content =
|
|
17
|
+
const content = readFileSync(file, "utf8");
|
|
19
18
|
namedColors.forEach((color) => {
|
|
20
19
|
const regex = new RegExp(`\\b${color}\\b`, "gi");
|
|
21
20
|
const matches = content.match(regex);
|
package/dist/css-vars.d.ts
CHANGED
package/dist/css-vars.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// check-css-vars.ts
|
|
2
3
|
// Script to check for usage of undefined CSS variables in styles folder
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
throw new Error("Cannot determine __dirname: require.main or require.main.filename is undefined.");
|
|
8
|
-
}
|
|
9
|
-
const __dirname = path.dirname(require.main.filename);
|
|
10
|
-
const stylesDir = path.resolve(__dirname, "src/styles");
|
|
11
|
-
const variablesFile = path.join(stylesDir, "variables.css");
|
|
4
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
5
|
+
import { resolve, join, basename } from "node:path";
|
|
6
|
+
const stylesDir = resolve(process.cwd(), "src/styles");
|
|
7
|
+
const variablesFile = join(stylesDir, "variables.css");
|
|
12
8
|
function getDefinedVars(file) {
|
|
13
|
-
const content =
|
|
9
|
+
const content = readFileSync(file, "utf8");
|
|
14
10
|
const varRegex = /--([\w-]+):/g;
|
|
15
11
|
const vars = new Set();
|
|
16
12
|
let match = varRegex.exec(content);
|
|
@@ -21,7 +17,7 @@ function getDefinedVars(file) {
|
|
|
21
17
|
return vars;
|
|
22
18
|
}
|
|
23
19
|
function getUsedVars(file) {
|
|
24
|
-
const content =
|
|
20
|
+
const content = readFileSync(file, "utf8");
|
|
25
21
|
const useRegex = /var\(--([\w-]+)\)/g;
|
|
26
22
|
const used = new Set();
|
|
27
23
|
let match = useRegex.exec(content);
|
|
@@ -32,10 +28,9 @@ function getUsedVars(file) {
|
|
|
32
28
|
return used;
|
|
33
29
|
}
|
|
34
30
|
function walkCssFiles(dir) {
|
|
35
|
-
return
|
|
36
|
-
.readdirSync(dir)
|
|
31
|
+
return readdirSync(dir)
|
|
37
32
|
.filter((f) => f.endsWith(".css") && f !== "variables.css")
|
|
38
|
-
.map((f) =>
|
|
33
|
+
.map((f) => join(dir, f));
|
|
39
34
|
}
|
|
40
35
|
const definedVars = getDefinedVars(variablesFile);
|
|
41
36
|
const cssFiles = walkCssFiles(stylesDir);
|
|
@@ -44,7 +39,7 @@ cssFiles.forEach((file) => {
|
|
|
44
39
|
const usedVars = getUsedVars(file);
|
|
45
40
|
usedVars.forEach((v) => {
|
|
46
41
|
if (!definedVars.has(v)) {
|
|
47
|
-
console.error(`Undefined CSS variable --${v} used in ${
|
|
42
|
+
console.error(`Undefined CSS variable --${v} used in ${basename(file)}`);
|
|
48
43
|
hasError = true;
|
|
49
44
|
}
|
|
50
45
|
});
|
package/dist/todos.d.ts
CHANGED
package/dist/todos.js
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// check-todo.ts
|
|
2
3
|
// Script to check for the string "TODO:" in project files and count occurrences
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { walk } from "./walk.js";
|
|
6
7
|
const exts = [".js", ".ts", ".astro", ".css", ".tsx"];
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const rootDir = path.resolve(__dirname, "src");
|
|
10
|
-
const publicDir = path.resolve(__dirname, "public");
|
|
11
|
-
function walk(dir) {
|
|
12
|
-
let results = [];
|
|
13
|
-
const list = fs.readdirSync(dir);
|
|
14
|
-
list.forEach((file) => {
|
|
15
|
-
const filePath = path.join(dir, file);
|
|
16
|
-
const stat = fs.statSync(filePath);
|
|
17
|
-
if (stat === null || stat === void 0 ? void 0 : stat.isDirectory()) {
|
|
18
|
-
results = results.concat(walk(filePath));
|
|
19
|
-
}
|
|
20
|
-
else if (exts.includes(path.extname(file))) {
|
|
21
|
-
results.push(filePath);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return results;
|
|
25
|
-
}
|
|
8
|
+
const rootDir = resolve(process.cwd(), "src");
|
|
9
|
+
const publicDir = resolve(process.cwd(), "public");
|
|
26
10
|
function checkTodos(files) {
|
|
27
11
|
let totalCount = 0;
|
|
28
12
|
files.forEach((file) => {
|
|
29
|
-
const content =
|
|
13
|
+
const content = readFileSync(file, "utf8");
|
|
30
14
|
const matches = content.match(/TODO:/g);
|
|
31
15
|
if (matches && matches.length > 0) {
|
|
32
16
|
console.log(`Found ${matches.length} TODO(s) in: ${file}`);
|
|
@@ -35,8 +19,8 @@ function checkTodos(files) {
|
|
|
35
19
|
});
|
|
36
20
|
return totalCount;
|
|
37
21
|
}
|
|
38
|
-
const srcFiles = walk(rootDir);
|
|
39
|
-
const publicFiles = walk(publicDir);
|
|
22
|
+
const srcFiles = walk(rootDir, exts);
|
|
23
|
+
const publicFiles = walk(publicDir, exts);
|
|
40
24
|
const allFiles = srcFiles.concat(publicFiles);
|
|
41
25
|
const todoCount = checkTodos(allFiles);
|
|
42
26
|
if (todoCount > 0) {
|
package/dist/walk.d.ts
ADDED
package/dist/walk.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { extname, join } from "node:path";
|
|
3
|
+
function walk(dir, exts) {
|
|
4
|
+
let results = [];
|
|
5
|
+
const list = readdirSync(dir);
|
|
6
|
+
list.forEach((file) => {
|
|
7
|
+
const filePath = join(dir, file);
|
|
8
|
+
const stat = statSync(filePath);
|
|
9
|
+
if (stat === null || stat === void 0 ? void 0 : stat.isDirectory()) {
|
|
10
|
+
results = results.concat(walk(filePath, exts));
|
|
11
|
+
}
|
|
12
|
+
else if (exts.includes(extname(file))) {
|
|
13
|
+
results.push(filePath);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return results;
|
|
17
|
+
}
|
|
18
|
+
export { walk };
|