"prepare": "husky install",
"format": "prettier --write .",
"build": "esbuild --bundle index.js --format=cjs --platform=node --outfile=outfile.cjs",
- "snapshot": "node snapshot.js",
+ "snapshot": "zx ./scripts/snapshot.mjs",
"pretest": "run-s build snapshot",
- "test": "node test.js",
+ "test": "zx ./scripts/test.mjs",
"prepublishOnly": "zx ./scripts/prepublish.mjs"
},
"repository": {
let { version } = JSON.parse(await fs.readFile('./package.json'))
-cd('./playground')
+const playgroundDir = path.resolve(__dirname, '../playground/')
+cd(playgroundDir)
await $`git add -A .`
try {
-import { spawnSync } from 'child_process'
-import path from 'path'
+#!/usr/bin/env zx
+import 'zx/globals'
-const __dirname = path
- .dirname(new URL(import.meta.url).pathname)
- .substring(process.platform === 'win32' ? 1 : 0)
+$.verbose = false
-const bin = path.resolve(__dirname, './outfile.cjs')
-const playgroundDir = path.resolve(__dirname, './playground/')
-
-function createProjectWithFeatureFlags(flags) {
- const projectName = flags.join('-')
- console.log(`Creating project ${projectName}`)
- const { status } = spawnSync(
- 'node',
- [bin, projectName, ...flags.map((flag) => `--${flag}`), '--force'],
- {
- cwd: playgroundDir,
- stdio: ['pipe', 'pipe', 'inherit']
- }
- )
-
- if (status !== 0) {
- process.exit(status)
- }
-}
+const bin = path.resolve(__dirname, '../outfile.cjs')
+const playgroundDir = path.resolve(__dirname, '../playground/')
const featureFlags = ['typescript', 'jsx', 'router', 'pinia', 'with-tests']
const flagCombinations = fullCombination(featureFlags)
flagCombinations.push(['default'])
+cd(playgroundDir)
for (const flags of flagCombinations) {
- createProjectWithFeatureFlags(flags)
+ const projectName = flags.join('-')
+ console.log(`Creating project ${projectName}`)
+
+ await $`node ${[bin, projectName, ...flags.map((flag) => `--${flag}`), '--force']}`
}
--- /dev/null
+#!/usr/bin/env zx
+import 'zx/globals'
+
+const playgroundDir = path.resolve(__dirname, '../playground/')
+
+for (const projectName of fs.readdirSync(playgroundDir)) {
+ if (projectName.endsWith('with-tests')) {
+ cd(path.resolve(playgroundDir, projectName))
+
+ console.log(`Running unit tests in ${projectName}`)
+ await $`pnpm test:unit:ci`
+
+ console.log(`Building ${projectName}`)
+ await $`pnpm build`
+
+ console.log(`Running e2e tests in ${projectName}`)
+ await $`pnpm test:e2e:ci`
+ }
+}
+++ /dev/null
-import fs from 'fs'
-import path from 'path'
-import { fileURLToPath } from 'url'
-
-import { spawnSync } from 'child_process'
-
-const __dirname = path.dirname(fileURLToPath(import.meta.url))
-const playgroundDir = path.resolve(__dirname, './playground/')
-
-for (const projectName of fs.readdirSync(playgroundDir)) {
- if (projectName.endsWith('with-tests')) {
- console.log(`Running unit tests in ${projectName}`)
- const unitTestResult = spawnSync('pnpm', ['test:unit:ci'], {
- cwd: path.resolve(playgroundDir, projectName),
- stdio: 'inherit',
- shell: true
- })
- if (unitTestResult.status !== 0) {
- throw new Error(`Unit tests failed in ${projectName}`)
- }
-
- console.log(`Building ${projectName}`)
- const buildResult = spawnSync('pnpm', ['build'], {
- cwd: path.resolve(playgroundDir, projectName),
- stdio: 'inherit',
- shell: true
- })
- if (buildResult.status !== 0) {
- throw new Error(`Build failed in ${projectName}`)
- }
-
- console.log(`Running e2e tests in ${projectName}`)
- const e2eTestResult = spawnSync('pnpm', ['test:e2e:ci'], {
- cwd: path.resolve(playgroundDir, projectName),
- stdio: 'inherit',
- shell: true
- })
- if (e2eTestResult.status !== 0) {
- throw new Error(`E2E tests failed in ${projectName}`)
- }
- }
-}