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 CHANGED
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/bang.js CHANGED
@@ -1,34 +1,16 @@
1
- "use strict";
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 = node_path_1.default.resolve(new URL(".", import.meta.url).pathname, "src");
12
- const publicDir = node_path_1.default.resolve(new URL(".", import.meta.url).pathname, "public");
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 = node_fs_1.default.readFileSync(file, "utf8");
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);
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
@@ -1,26 +1,21 @@
1
- "use strict";
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
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"));
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 node_fs_1.default.readdirSync(dir)
16
- .filter((f) => exts.includes(node_path_1.default.extname(f)))
17
- .map((f) => node_path_1.default.join(dir, 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 = node_fs_1.default.readFileSync(file, "utf8");
23
- named_colors_ts_1.namedColors.forEach((color) => {
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) {
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/css-vars.js CHANGED
@@ -1,17 +1,12 @@
1
- "use strict";
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
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 = fs_1.default.readFileSync(file, "utf8");
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 = fs_1.default.readFileSync(file, "utf8");
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 fs_1.default
37
- .readdirSync(dir)
31
+ return readdirSync(dir)
38
32
  .filter((f) => f.endsWith(".css") && f !== "variables.css")
39
- .map((f) => path_1.default.join(dir, 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 ${path_1.default.basename(file)}`);
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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";
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.namedColors = void 0;
4
- exports.namedColors = [
1
+ export const namedColors = [
5
2
  "aliceblue",
6
3
  "antiquewhite",
7
4
  "aqua",
package/dist/todos.d.ts CHANGED
@@ -1 +1,2 @@
1
+ #!/usr/bin/env node
1
2
  export {};
package/dist/todos.js CHANGED
@@ -1,34 +1,16 @@
1
- "use strict";
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 = node_path_1.default.resolve(new URL(".", import.meta.url).pathname, "src");
12
- const publicDir = node_path_1.default.resolve(new URL(".", import.meta.url).pathname, "public");
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 = node_fs_1.default.readFileSync(file, "utf8");
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
@@ -0,0 +1,2 @@
1
+ declare function walk(dir: string, exts: string[]): string[];
2
+ export { walk };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stay-gold",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "Checks and balances for code quality. Run as a dev dependency in any project.",
6
6
  "main": "dist/index.js",