Skip to content

Commit 728d222

Browse files
committed
refactor(scripts): organize scripts into subdirectories
Move scripts into logical subdirectories and remove redundant prefixes: - Build scripts → scripts/build/ - Fix scripts → scripts/fix/ - Validation scripts → scripts/validate/ (removed validate- prefix) - Test scripts → scripts/test/ - Update all import paths and package.json script references - Fix rootPath calculations for nested scripts - Rename index.mjs files to main.mjs for clarity
1 parent 460e619 commit 728d222

21 files changed

+40
-225
lines changed

scripts/clean.mjs renamed to scripts/build/clean.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import { isQuiet } from '#socketsecurity/lib/argv/flags'
1313
import { getDefaultLogger } from '#socketsecurity/lib/logger'
1414
import { printHeader } from '#socketsecurity/lib/stdio/header'
1515

16-
import { parseArgs } from './utils/parse-args.mjs'
16+
import { parseArgs } from '../utils/parse-args.mjs'
1717

1818
const logger = getDefaultLogger()
1919

2020
const rootPath = path.resolve(
2121
path.dirname(fileURLToPath(import.meta.url)),
2222
'..',
23+
'..',
2324
)
2425

2526
/**

scripts/build-externals.mjs renamed to scripts/build/externals.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isQuiet } from '#socketsecurity/lib/argv/flags'
1111
import { getDefaultLogger } from '#socketsecurity/lib/logger'
1212
import { pluralize } from '#socketsecurity/lib/words'
1313

14-
import { buildExternals } from './build-externals/orchestrator.mjs'
14+
import { buildExternals } from '../build-externals/orchestrator.mjs'
1515

1616
const logger = getDefaultLogger()
1717
const printCompletedHeader = title => console.log(colors.green(`✓ ${title}`))

scripts/build-js.mjs renamed to scripts/build/js.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
analyzeMetafile,
1010
buildConfig,
1111
watchConfig,
12-
} from '../.config/esbuild.config.mjs'
12+
} from '../../.config/esbuild.config.mjs'
1313
import { getDefaultLogger } from '#socketsecurity/lib/logger'
1414

1515
const logger = getDefaultLogger()

scripts/build.mjs renamed to scripts/build/main.mjs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import {
1313
analyzeMetafile,
1414
buildConfig,
1515
watchConfig,
16-
} from '../.config/esbuild.config.mjs'
16+
} from '../../.config/esbuild.config.mjs'
1717
import { isQuiet } from '#socketsecurity/lib/argv/flags'
1818
import { getDefaultLogger } from '#socketsecurity/lib/logger'
1919
import { printFooter, printHeader } from '#socketsecurity/lib/stdio/header'
2020

21-
import { parseArgs } from './utils/parse-args.mjs'
22-
import { runSequence } from './utils/run-command.mjs'
21+
import { parseArgs } from '../utils/parse-args.mjs'
22+
import { runSequence } from '../utils/run-command.mjs'
2323

2424
const logger = getDefaultLogger()
2525

@@ -29,6 +29,7 @@ const printCompletedHeader = title => console.log(colors.green(`✓ ${title}`))
2929
const rootPath = path.resolve(
3030
path.dirname(fileURLToPath(import.meta.url)),
3131
'..',
32+
'..',
3233
)
3334

3435
/**
@@ -42,7 +43,7 @@ async function buildSource(options = {}) {
4243
if (!skipClean) {
4344
const exitCode = await runSequence([
4445
{
45-
args: ['scripts/clean.mjs', '--dist', '--quiet'],
46+
args: ['scripts/build/clean.mjs', '--dist', '--quiet'],
4647
command: 'node',
4748
},
4849
])
@@ -89,7 +90,7 @@ async function buildTypes(options = {}) {
8990

9091
if (!skipClean) {
9192
commands.push({
92-
args: ['scripts/clean.mjs', '--types', '--quiet'],
93+
args: ['scripts/build/clean.mjs', '--types', '--quiet'],
9394
command: 'node',
9495
})
9596
}
@@ -120,7 +121,7 @@ async function buildTypes(options = {}) {
120121
async function buildExternals(options = {}) {
121122
const { quiet = false, verbose = false } = options
122123

123-
const args = ['scripts/build-externals.mjs']
124+
const args = ['scripts/build/externals.mjs']
124125
if (quiet) {
125126
args.push('--quiet')
126127
}
@@ -151,7 +152,7 @@ async function buildExternals(options = {}) {
151152
async function fixExports(options = {}) {
152153
const { quiet = false, verbose = false } = options
153154

154-
const fixArgs = ['scripts/fix-build.mjs']
155+
const fixArgs = ['scripts/fix/main.mjs']
155156
if (quiet) {
156157
fixArgs.push('--quiet')
157158
}
@@ -390,7 +391,7 @@ async function main() {
390391

391392
exitCode = await runSequence([
392393
{
393-
args: ['scripts/clean.mjs', '--dist', '--types', '--quiet'],
394+
args: ['scripts/build/clean.mjs', '--dist', '--types', '--quiet'],
394395
command: 'node',
395396
},
396397
])

scripts/check.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,49 +35,49 @@ async function main() {
3535
},
3636
},
3737
{
38-
args: ['scripts/validate-no-link-deps.mjs'],
38+
args: ['scripts/validate/no-link-deps.mjs'],
3939
command: 'node',
4040
options: {
4141
...(process.platform === 'win32' && { shell: true }),
4242
},
4343
},
4444
{
45-
args: ['scripts/validate-no-extraneous-dependencies.mjs'],
45+
args: ['scripts/validate/no-extraneous-dependencies.mjs'],
4646
command: 'node',
4747
options: {
4848
...(process.platform === 'win32' && { shell: true }),
4949
},
5050
},
5151
{
52-
args: ['scripts/validate-esbuild-minify.mjs'],
52+
args: ['scripts/validate/esbuild-minify.mjs'],
5353
command: 'node',
5454
options: {
5555
...(process.platform === 'win32' && { shell: true }),
5656
},
5757
},
5858
{
59-
args: ['scripts/validate-no-cdn-refs.mjs'],
59+
args: ['scripts/validate/no-cdn-refs.mjs'],
6060
command: 'node',
6161
options: {
6262
...(process.platform === 'win32' && { shell: true }),
6363
},
6464
},
6565
{
66-
args: ['scripts/validate-markdown-filenames.mjs'],
66+
args: ['scripts/validate/markdown-filenames.mjs'],
6767
command: 'node',
6868
options: {
6969
...(process.platform === 'win32' && { shell: true }),
7070
},
7171
},
7272
{
73-
args: ['scripts/validate-file-size.mjs'],
73+
args: ['scripts/validate/file-size.mjs'],
7474
command: 'node',
7575
options: {
7676
...(process.platform === 'win32' && { shell: true }),
7777
},
7878
},
7979
{
80-
args: ['scripts/validate-file-count.mjs'],
80+
args: ['scripts/validate/file-count.mjs'],
8181
command: 'node',
8282
options: {
8383
...(process.platform === 'win32' && { shell: true }),

scripts/fix-build.mjs

Lines changed: 0 additions & 66 deletions
This file was deleted.
File renamed without changes.

scripts/fix-external-imports.mjs renamed to scripts/fix/external-imports.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import colors from 'yoctocolors-cjs'
1212
import { isQuiet } from '#socketsecurity/lib/argv/flags'
1313
import { getDefaultLogger } from '#socketsecurity/lib/logger'
1414

15-
import { externalPackages, scopedPackages } from './build-externals/config.mjs'
15+
import { externalPackages, scopedPackages } from '../build-externals/config.mjs'
1616

1717
const logger = getDefaultLogger()
1818
const printCompletedHeader = title => console.log(colors.green(`✓ ${title}`))

scripts/generate-package-exports.mjs renamed to scripts/fix/generate-package-exports.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
2424
const constants = {
2525
EXT_DTS: '.d.ts',
2626
EXT_JSON: '.json',
27-
registryPkgPath: path.join(__dirname, '..'),
27+
registryPkgPath: path.join(__dirname, '..', '..'),
2828
ignoreGlobs: [
2929
'**/node_modules/**',
3030
'**/.git/**',
File renamed without changes.

0 commit comments

Comments
 (0)