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