Skip to content

Commit 7615852

Browse files
committed
fix(scripts): correct rootPath in validation scripts and remove stale vitest import
Fix two critical issues preventing CI from passing: 1. Validation scripts rootPath bug: - All scripts in scripts/validate/ were using path.join(__dirname, '..') - Should be path.join(__dirname, '..', '..') since they're nested two levels deep - Caused scripts to look in scripts/ instead of project root - Fixed in 7 validation scripts: bundle-deps, esbuild-minify, file-count, file-size, markdown-filenames, no-cdn-refs, no-link-deps 2. CDN validator self-exclusion bug: - Script was checking for 'validate-no-cdn-refs.mjs' but actual filename is 'no-cdn-refs.mjs' - Caused validator to flag itself as containing CDN references - Fixed filename check to match actual file 3. Vitest config stale import: - Removed import of get-local-package-aliases.mjs (deleted in 40d1abe) - Removed unused resolve.alias configuration - Config now matches isolated config pattern All checks and tests now pass locally and should pass in CI.
1 parent 167412e commit 7615852

File tree

8 files changed

+8
-18
lines changed

8 files changed

+8
-18
lines changed

.config/vitest.config.mts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@
2020
* - Full process isolation between tests
2121
* - File naming: *.isolated.test.mts suffix
2222
*/
23-
import path from 'node:path'
24-
import { fileURLToPath } from 'node:url'
25-
2623
import { defineConfig } from 'vitest/config'
2724

28-
import { getLocalPackageAliases } from '../scripts/utils/get-local-package-aliases.mjs'
29-
30-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
31-
3225
// Check if coverage is enabled via CLI flags or environment.
3326
const isCoverageEnabled =
3427
process.env.COVERAGE === 'true' ||
@@ -42,9 +35,6 @@ if (isCoverageEnabled) {
4235

4336
export default defineConfig({
4437
cacheDir: './.cache/vitest',
45-
resolve: {
46-
alias: getLocalPackageAliases(path.join(__dirname, '..')),
47-
},
4838
test: {
4939
globals: false,
5040
environment: 'node',

scripts/validate/bundle-deps.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import path from 'node:path'
1515
import { fileURLToPath } from 'node:url'
1616

1717
const __dirname = path.dirname(fileURLToPath(import.meta.url))
18-
const rootPath = path.join(__dirname, '..')
18+
const rootPath = path.join(__dirname, '..', '..')
1919

2020
// Node.js builtins to ignore (including node: prefix variants)
2121
const BUILTIN_MODULES = new Set([

scripts/validate/esbuild-minify.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import path from 'node:path'
77
import { fileURLToPath } from 'node:url'
88

99
const __dirname = path.dirname(fileURLToPath(import.meta.url))
10-
const rootPath = path.join(__dirname, '..')
10+
const rootPath = path.join(__dirname, '..', '..')
1111

1212
/**
1313
* Validate esbuild configuration has minify: false.

scripts/validate/file-count.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const logger = loggerPkg.getDefaultLogger()
1818
const execAsync = promisify(exec)
1919

2020
const __dirname = path.dirname(fileURLToPath(import.meta.url))
21-
const rootPath = path.join(__dirname, '..')
21+
const rootPath = path.join(__dirname, '..', '..')
2222

2323
// Maximum number of files in a single commit
2424
const MAX_FILES_PER_COMMIT = 50

scripts/validate/file-size.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import loggerPkg from '@socketsecurity/lib/logger'
1616
const logger = loggerPkg.getDefaultLogger()
1717

1818
const __dirname = path.dirname(fileURLToPath(import.meta.url))
19-
const rootPath = path.join(__dirname, '..')
19+
const rootPath = path.join(__dirname, '..', '..')
2020

2121
// Maximum file size: 2MB (2,097,152 bytes)
2222
const MAX_FILE_SIZE = 2 * 1024 * 1024

scripts/validate/markdown-filenames.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import loggerPkg from '@socketsecurity/lib/logger'
2525
const logger = loggerPkg.getDefaultLogger()
2626

2727
const __dirname = path.dirname(fileURLToPath(import.meta.url))
28-
const rootPath = path.join(__dirname, '..')
28+
const rootPath = path.join(__dirname, '..', '..')
2929

3030
// Allowed SCREAMING_CASE markdown files (without .md extension for comparison)
3131
const ALLOWED_SCREAMING_CASE = new Set([

scripts/validate/no-cdn-refs.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import loggerPkg from '@socketsecurity/lib/logger'
2121
const logger = loggerPkg.getDefaultLogger()
2222

2323
const __dirname = path.dirname(fileURLToPath(import.meta.url))
24-
const rootPath = path.join(__dirname, '..')
24+
const rootPath = path.join(__dirname, '..', '..')
2525

2626
// CDN domains to block
2727
const CDN_PATTERNS = [
@@ -114,7 +114,7 @@ async function findTextFiles(dir, files = []) {
114114
*/
115115
async function checkFileForCdnRefs(filePath) {
116116
// Skip this validator script itself (it mentions CDN domains by necessity)
117-
if (filePath.endsWith('validate-no-cdn-refs.mjs')) {
117+
if (filePath.endsWith('no-cdn-refs.mjs')) {
118118
return []
119119
}
120120

scripts/validate/no-link-deps.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import path from 'node:path'
88
import { fileURLToPath } from 'node:url'
99

1010
const __dirname = path.dirname(fileURLToPath(import.meta.url))
11-
const rootPath = path.join(__dirname, '..')
11+
const rootPath = path.join(__dirname, '..', '..')
1212

1313
/**
1414
* Find all package.json files in the repository.

0 commit comments

Comments
 (0)