Comparing version 0.1.12 to 0.1.13
{ | ||
"name": "hjsx", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"module": "hjsx.ts", | ||
@@ -5,0 +5,0 @@ "main": "hjsx.js", |
115
publish.ts
@@ -1,40 +0,55 @@ | ||
/** | ||
* This script is used to do the following: | ||
* 1. Build the project | ||
* 2. Update the version in package.json | ||
* 3. Run tests | ||
* 4. Commit and push changes | ||
*/ | ||
import { colors } from "./util"; | ||
import { parseArgs } from "node:util"; | ||
const options = { | ||
patch: { | ||
type: "boolean", | ||
short: "p", | ||
}, | ||
minor: { | ||
type: "boolean", | ||
short: "m", | ||
}, | ||
major: { | ||
type: "boolean", | ||
short: "M", | ||
}, | ||
} as const; | ||
const args = process.argv.slice(2); | ||
const config = { args, options }; | ||
const quietSpawnOptions = { | ||
stdout: "pipe", | ||
stderr: "pipe", | ||
} as const; | ||
const { config, quietSpawnOptions } = getConfig(); | ||
await main(); | ||
await build(); | ||
const [oldVersion, newVersion] = await updateVersion(); | ||
const testsPassed = await runTests(); | ||
const readmeUpdated = await updateReadmeTestsBadge(testsPassed); | ||
const changedFiles = await getChangedFiles(); | ||
await commitAndPush(changedFiles); | ||
await publish(oldVersion, newVersion); | ||
/** | ||
* this script is used to do the following: | ||
* | ||
* 1. build the project | ||
* 2. update the version in package.json | ||
* 3. run tests | ||
* 4. update the tests badge in README.md | ||
* 5. commit and push changes to github | ||
* 6. publish to npm | ||
* | ||
* ## usage: | ||
* | ||
* patch version: | ||
* ```sh | ||
* bun publish.ts --patch | ||
* # or | ||
* bun publish.ts -p | ||
* ``` | ||
* | ||
* minor version: | ||
* ```sh | ||
* bun publish.ts --minor | ||
* # or | ||
* bun publish.ts -m | ||
* ``` | ||
* | ||
* major version: | ||
* ```sh | ||
* # major version | ||
* bun publish.ts --major | ||
* # or | ||
* bun publish.ts -M | ||
*``` | ||
* | ||
* no version change: | ||
* ```sh | ||
* bun publish.ts # no args | ||
* ``` | ||
*/ | ||
async function main() { | ||
await build(); | ||
const [oldVersion, newVersion] = await updatePkgVersion(); | ||
const testsPassed = await runTests(); | ||
const readmeUpdated = await updateReadmeTestsBadge(testsPassed); | ||
const changedFiles = await getChangedFiles(); | ||
await commitAndPush(changedFiles); | ||
await publish(oldVersion, newVersion); | ||
} | ||
@@ -93,6 +108,3 @@ async function getChangedFiles(): Promise<string[]> { | ||
} | ||
process = Bun.spawn( | ||
["git", "commit", "-m", "'updated, tested'"], | ||
quietSpawnOptions, | ||
); | ||
process = Bun.spawn(["git", "commit", "-m", "'updated, tested'"], quietSpawnOptions); | ||
exitCode = await process.exited; | ||
@@ -112,3 +124,3 @@ if (exitCode !== 0) { | ||
async function updateVersion(): Promise<[SemVer, SemVer]> { | ||
async function updatePkgVersion(): Promise<[SemVer, SemVer]> { | ||
console.log("updating version..."); | ||
@@ -162,2 +174,25 @@ const parsed = parseArgs(config); | ||
} | ||
function getConfig() { | ||
const options = { | ||
patch: { | ||
type: "boolean", | ||
short: "p", | ||
}, | ||
minor: { | ||
type: "boolean", | ||
short: "m", | ||
}, | ||
major: { | ||
type: "boolean", | ||
short: "M", | ||
}, | ||
} as const; | ||
const args = process.argv.slice(2); | ||
const config = { args, options }; | ||
const quietSpawnOptions = { | ||
stdout: "pipe", | ||
stderr: "pipe", | ||
} as const; | ||
return { config, quietSpawnOptions }; | ||
} | ||
@@ -164,0 +199,0 @@ type Package = { |
96056
1979