{"library":"sdc-build-wp","title":"SDC WordPress Build Process","description":"sdc-build-wp is a custom build process specifically designed for WordPress development, currently at version 5.6.13. It streamlines common development tasks like asset compilation (CSS, JavaScript), offers intelligent caching for faster rebuilds, and provides an interactive watch mode with keyboard controls (e.g., restart, clear cache). The package receives frequent minor updates, often weekly or bi-weekly, indicating active maintenance. It enforces a Node.js runtime of version 22 or higher and integrates PHP code linting (via an upgraded PHP Code Sniffer), differentiating it from generic build tools by its WordPress-centric optimizations and developer experience features like a custom text-based user interface (TUI) for managing the build workflow.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install sdc-build-wp"],"cli":{"name":"sdc-build-wp","version":null}},"imports":["npx sdc-build-wp [args]","import 'sdc-build-wp/index.js';","import { spawn } from 'child_process';\nspawn('npx', ['sdc-build-wp', '--watch'], { stdio: 'inherit' });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { spawn } from 'child_process';\nimport { mkdtempSync, writeFileSync, rmSync, mkdirSync, existsSync } from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nasync function runQuickstart() {\n  const tmpDir = mkdtempSync(path.join(os.tmpdir(), 'sdc-build-wp-quickstart-'));\n  const projectRoot = path.join(tmpDir, 'my-wp-theme');\n\n  console.log(`Setting up a dummy WordPress theme in: ${projectRoot}`);\n  mkdirSync(projectRoot, { recursive: true });\n  writeFileSync(path.join(projectRoot, 'style.css'), '/* Theme Name: My Test Theme */');\n  writeFileSync(path.join(projectRoot, 'index.php'), '<?php echo \"Hello World\"; ?>');\n  mkdirSync(path.join(projectRoot, 'src', 'js'), { recursive: true });\n  writeFileSync(path.join(projectRoot, 'src', 'js', 'main.js'), 'console.log(\"Hello from main.js\");');\n\n  console.log('Installing sdc-build-wp locally...');\n  const installProcess = spawn('npm', ['install', 'sdc-build-wp'], {\n    cwd: projectRoot,\n    stdio: 'pipe',\n  });\n\n  let installOutput = '';\n  installProcess.stdout.on('data', (data) => { installOutput += data.toString(); });\n  installProcess.stderr.on('data', (data) => { installOutput += data.toString(); });\n\n  await new Promise((resolve, reject) => {\n    installProcess.on('close', (code) => {\n      if (code === 0) {\n        console.log('Installation complete.');\n        resolve();\n      } else {\n        console.error(`npm install failed with code ${code}.\\nOutput:\\n${installOutput}`);\n        reject(new Error('Installation failed'));\n      }\n    });\n    installProcess.on('error', reject);\n  });\n\n  console.log('\\nRunning sdc-build-wp --watch (will run for ~15 seconds)');\n  const buildProcess = spawn(path.join(projectRoot, 'node_modules', '.bin', 'sdc-build-wp'), ['--watch'], {\n    cwd: projectRoot,\n    stdio: 'inherit',\n    env: { ...process.env },\n  });\n\n  console.log('--- CLI Output Start ---');\n  const timeoutId = setTimeout(() => {\n    console.log('\\n--- CLI Output End ---');\n    console.log('Stopping sdc-build-wp --watch after 15 seconds.');\n    buildProcess.kill('SIGTERM');\n  }, 15000);\n\n  buildProcess.on('close', (code) => {\n    clearTimeout(timeoutId);\n    console.log(`sdc-build-wp process exited with code ${code}.`);\n    try {\n      rmSync(tmpDir, { recursive: true, force: true });\n      console.log(`Cleaned up temporary directory: ${tmpDir}`);\n    } catch (cleanupErr) {\n      console.error(`Error during cleanup: ${cleanupErr.message}`);\n    }\n  });\n\n  buildProcess.on('error', (err) => {\n    clearTimeout(timeoutId);\n    console.error(`Failed to start sdc-build-wp: ${err.message}`);\n    try {\n      if (existsSync(tmpDir)) {\n        rmSync(tmpDir, { recursive: true, force: true });\n        console.log(`Cleaned up temporary directory: ${tmpDir}`);\n      }\n    } catch (cleanupErr) {\n      console.error(`Error during cleanup: ${cleanupErr.message}`);\n    }\n    process.exit(1);\n  });\n}\n\nif (import.meta.url === path.join('file://', __filename)) {\n  runQuickstart().catch(error => {\n    console.error('Quickstart failed:', error);\n    process.exit(1);\n  });\n}","lang":"javascript","description":"This quickstart demonstrates how to programmatically install `sdc-build-wp` in a temporary WordPress theme project and then run its `--watch` command for a short period, mimicking a development workflow.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}