Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _stories/Highlights.PackageComparison.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import waffleConfig from '../packages/waffle-chart/examples/tp5-style.json'
import dataTableConfig from '../packages/data-table/examples/data-table-example.json'
import markupConfig from '../packages/markup-include/src/_stories/_mock/primary.json'
import filteredTextConfig from '../packages/filtered-text/examples/default.json'
import filteredTextData from '../packages/filtered-text/examples/sex-ageGroup-with-values.json'
import filteredTextData from '../packages/filtered-text/examples/__data__/sex-ageGroup-with-values.json'

const sectionStyles = {
border: '1px solid #d9d9d9',
Expand Down
108 changes: 108 additions & 0 deletions dev-portal/run-dev-portal.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { spawn } from 'node:child_process'
import path from 'node:path'

const mode = process.argv[2] === 'compare' ? 'compare' : 'portal'
const rootDir = process.cwd()

const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const viteBin = path.resolve(rootDir, 'node_modules', '.bin', process.platform === 'win32' ? 'vite.cmd' : 'vite')

const packageCommands = [
['run', 'dev:chart', '--', '--no-open'],
['run', 'dev:dashboard', '--', '--no-open'],
['run', 'dev:data-bite', '--', '--no-open'],
['run', 'dev:data-table', '--', '--no-open'],
['run', 'dev:filtered-text', '--', '--no-open'],
['run', 'dev:map', '--', '--no-open'],
['run', 'dev:markup-include', '--', '--no-open'],
['run', 'dev:waffle-chart', '--', '--no-open']
]

const portalArgsByMode = {
portal: ['--config', 'dev-portal/vite.config.dev-portal.js', '--open'],
compare: ['--config', 'dev-portal/vite.config.compare.js', '--open', '/compare.html']
}

const children = []
let shuttingDown = false
let forceKillTimer = null

const killChildTree = (child, signal) => {
if (!child || child.exitCode !== null || child.signalCode) return

if (process.platform === 'win32') {
spawn('taskkill', ['/pid', String(child.pid), '/T', '/F'], { stdio: 'ignore' })
return
}

try {
process.kill(-child.pid, signal)
} catch {
// Child may already be gone.
}
}

const shutdown = (signal = 'SIGTERM', exitCode = 0) => {
if (shuttingDown) return
shuttingDown = true

for (const child of children) {
killChildTree(child, signal)
}

if (signal === 'SIGKILL') {
process.exit(exitCode)
}

forceKillTimer = setTimeout(() => {
for (const child of children) {
killChildTree(child, 'SIGKILL')
}
process.exit(exitCode)
}, 3000)

forceKillTimer.unref()
}

const spawnManaged = (command, args) => {
const child = spawn(command, args, {
cwd: rootDir,
stdio: 'inherit',
detached: process.platform !== 'win32'
})

children.push(child)

child.on('exit', (code, signal) => {
if (shuttingDown) return

const isSignalExit = signal && signal !== 'SIGTERM' && signal !== 'SIGINT'
const isFailure = code !== 0 && code !== null

if (isFailure || isSignalExit) {
const label = [command, ...args].join(' ')
console.error(`\n[run-dev-portal] Child exited unexpectedly: ${label}`)
shutdown('SIGTERM', code ?? 1)
}
})

child.on('error', err => {
if (shuttingDown) return
console.error(`\n[run-dev-portal] Failed to start ${command}:`, err)
shutdown('SIGTERM', 1)
})

return child
}

for (const args of packageCommands) {
spawnManaged(npmCmd, args)
}

spawnManaged(viteBin, portalArgsByMode[mode])

process.on('SIGINT', () => shutdown('SIGTERM', 130))
process.on('SIGTERM', () => shutdown('SIGTERM', 143))
process.on('exit', () => {
if (forceKillTimer) clearTimeout(forceKillTimer)
})
2 changes: 1 addition & 1 deletion docs/TESTING_BEST_PRACTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ await performAndAssert(
## Creating New Tests: Quick Checklist

1. ✅ Import helpers from `@cdc/core/helpers/testing`
2. ✅ Use existing config: `import ExampleConfig from '../../examples/example-config.json'`
2. ✅ Use existing config: `import ExampleConfig from '../../examples/default.json'`
3. ✅ Set editor mode: `args: { config: ExampleConfig, isEditor: true }`
4. ✅ Check EditorPanel.tsx for actual accordion sections
5. ✅ Create one test story per accordion section
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@
"clean": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +",
"deploy": "gh-pages -d .storybook_build -t true",
"dev:all": "npm run dev:chart & npm run dev:dashboard & npm run dev:data-bite & npm run dev:data-table & npm run dev:editor & npm run dev:filtered-text & npm run dev:map & npm run dev:markup-include & npm run dev:waffle-chart & wait",
"dev:compare": "npm run dev:chart -- --no-open & npm run dev:dashboard -- --no-open & npm run dev:data-bite -- --no-open & npm run dev:data-table -- --no-open & npm run dev:filtered-text -- --no-open & npm run dev:map -- --no-open & npm run dev:markup-include -- --no-open & npm run dev:waffle-chart -- --no-open & vite --config dev-portal/vite.config.compare.js --open /compare.html",
"dev:portal": "npm run dev:chart -- --no-open & npm run dev:dashboard -- --no-open & npm run dev:data-bite -- --no-open & npm run dev:data-table -- --no-open & npm run dev:filtered-text -- --no-open & npm run dev:map -- --no-open & npm run dev:markup-include -- --no-open & npm run dev:waffle-chart -- --no-open & vite --config dev-portal/vite.config.dev-portal.js --open",
"dev:chart": "lerna run --scope @cdc/chart start -- --port 3001",
"dev:dashboard": "lerna run --scope @cdc/dashboard start -- --port 3003",
"dev:data-bite": "lerna run --scope @cdc/data-bite start -- --port 3004",
"dev:data-table": "lerna run --scope @cdc/data-table start -- --port 3005",
"dev:editor": "lerna run --scope @cdc/editor start -- --port 3006",
"dev:filtered-text": "lerna run --scope @cdc/filtered-text start -- --port 3007",
"dev:map": "lerna run --scope @cdc/map start -- --port 3008",
"dev:markup-include": "lerna run --scope @cdc/markup-include start -- --port 3009",
"dev:waffle-chart": "lerna run --scope @cdc/waffle-chart start -- --port 3010",
"dev:compare": "node dev-portal/run-dev-portal.mjs compare",
"dev:portal": "node dev-portal/run-dev-portal.mjs",
"dev:chart": "lerna run --scope @cdc/chart start -- --port 3001 --strictPort",
"dev:dashboard": "lerna run --scope @cdc/dashboard start -- --port 3003 --strictPort",
"dev:data-bite": "lerna run --scope @cdc/data-bite start -- --port 3004 --strictPort",
"dev:data-table": "lerna run --scope @cdc/data-table start -- --port 3005 --strictPort",
"dev:editor": "lerna run --scope @cdc/editor start -- --port 3006 --strictPort",
"dev:filtered-text": "lerna run --scope @cdc/filtered-text start -- --port 3007 --strictPort",
"dev:map": "lerna run --scope @cdc/map start -- --port 3008 --strictPort",
"dev:markup-include": "lerna run --scope @cdc/markup-include start -- --port 3009 --strictPort",
"dev:waffle-chart": "lerna run --scope @cdc/waffle-chart start -- --port 3010 --strictPort",
"knip": "knip",
"knip:production": "knip --production",
"knip:unused-deps": "knip --include dependencies,devDependencies",
Expand Down
Loading
Loading