{"library":"spago","title":"Spago: PureScript Package Manager and Build Tool","type":"library","description":"Spago is the official PureScript package manager and build tool, currently at version 1.0.4. It facilitates project initialization, dependency management using a package set model, compilation, and bundling of PureScript applications. The 1.x.x series represents a significant architectural shift, being a complete rewrite of the tool from its original Haskell codebase (versions up to 0.21.x) into PureScript itself. This rewrite aims for improved maintainability and tighter integration with the PureScript ecosystem. Spago provides a streamlined command-line interface for common PureScript development workflows, abstracting away the complexities of managing `purs` compiler invocations and project dependencies. Its release cadence typically involves patch updates for the stable 1.x series, following the major rewrite which occurred with the transition from 0.x to 1.x. A key differentiator is its reliance on curated package sets for consistent and conflict-free dependency resolution within the PureScript ecosystem.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install spago"],"cli":{"name":"spago","version":null}},"imports":["import { runCli } from 'spago'","const { runCli } = require('spago')","import { spawnSync } from 'child_process'; spawnSync('spago', ['init'], { stdio: 'inherit' });"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/purescript/spago","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/spago","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { spawnSync } from 'child_process';\nimport { mkdtempSync, rmSync, existsSync } from 'fs';\nimport { join } from 'path';\n\n// Create a temporary directory for the project\nconst tempDir = mkdtempSync('purescript-pasta-');\nconsole.log(`Created temporary directory: ${tempDir}`);\nprocess.chdir(tempDir);\n\ntry {\n  console.log('Running spago init...');\n  let result = spawnSync('spago', ['init'], { stdio: 'inherit' });\n  if (result.error || result.status !== 0) throw new Error('spago init failed');\n  console.log('spago init successful. Project files created.');\n\n  if (existsSync('src/Main.purs')) {\n      console.log('src/Main.purs exists, proceeding to build and run.');\n      console.log('Running spago run...');\n      result = spawnSync('spago', ['run'], { stdio: 'inherit' });\n      if (result.error || result.status !== 0) throw new Error('spago run failed');\n      console.log('spago run successful.');\n\n      console.log('Running spago bundle...');\n      result = spawnSync('spago', ['bundle', '--bundle-type', 'app', '--platform', 'node'], { stdio: 'inherit' });\n      if (result.error || result.status !== 0) throw new Error('spago bundle failed');\n      console.log('spago bundle successful.');\n\n      console.log('Running bundled app...');\n      result = spawnSync('node', ['.'], { stdio: 'inherit' });\n      if (result.error || result.status !== 0) throw new Error('Bundled app run failed');\n      console.log('Bundled app ran successfully.');\n  } else {\n      console.warn('src/Main.purs not found after spago init. Skipping build and run steps.');\n  }\n\n} catch (error) {\n  console.error('An error occurred:', error.message);\n  process.exit(1);\n} finally {\n  // Clean up the temporary directory\n  process.chdir(__dirname); // Change back to original directory before deleting tempDir\n  rmSync(tempDir, { recursive: true, force: true });\n  console.log(`Cleaned up temporary directory: ${tempDir}`);\n}","lang":"typescript","description":"Demonstrates how to programmatically initialize, build, and run a new PureScript project using `spago` commands executed via Node.js `child_process`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}