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