Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Every build command requires `--content <dir>`. The path is resolved from the wo

Use `yarn purestack --help` or `yarn purestack help` to print the CLI's own usage summary. Options can be written as `--content ./content` or `--content=./content`.

Use `yarn purestack --version` or `yarn purestack -v` to print the installed PureStack version.

### `build`: generate static files

```sh
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "purestack-repo",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.18.1",
"type": "module",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/purestack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purestack",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/purestack.mjs",
"types": "./dist/purestack.d.mts",
Expand Down
18 changes: 16 additions & 2 deletions packages/purestack/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#!/usr/bin/env node
import { runCli } from '@purestack/ts-ssg'
import { readFileSync } from 'node:fs'

runCli(process.argv.slice(2)).catch((error) => {
async function main() {
const args = process.argv.slice(2)
if (args[0] === '--version' || args[0] === '-v') {
const { version } = JSON.parse(
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
)
console.log(version)
return
}

const { runCli } = await import('@purestack/ts-ssg')
await runCli(args)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
2 changes: 1 addition & 1 deletion packages/purestack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const version: string = '1.1.6'
export const version: string = '1.1.7'

export * from '@purestack/ts-ssg'
2 changes: 1 addition & 1 deletion packages/ts-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-common",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-common.mjs",
"types": "./dist/ts-common.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-components",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-components.mjs",
"types": "./dist/ts-components.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-css",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-css.mjs",
"types": "./dist/ts-css.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-html",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-html.mjs",
"types": "./dist/ts-html.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-minidom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-minidom",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-minidom.mjs",
"types": "./dist/ts-minidom.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-page-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-page-scripts",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-page-scripts.mjs",
"types": "./dist/ts-page-scripts.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-render",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-render.mjs",
"types": "./dist/ts-render.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-ssg-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "purestack-component-navigation",
"displayName": "PureStack Component Tools",
"description": "Component navigation, prop IntelliSense, lit-html syntax highlighting, and template formatting for Markdown, Regor MDX, and TypeScript templates.",
"version": "1.1.6",
"version": "1.1.7",
"private": true,
"publisher": "purestack",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-ssg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-ssg",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-ssg.mjs",
"types": "./dist/ts-ssg.d.mts",
Expand Down
7 changes: 6 additions & 1 deletion packages/ts-ssg/src/cli-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,16 @@ class CliUsageError extends Error {
}

const USAGE = `Usage:
purestack --version
purestack build --content <dir> [--clean]
purestack serve --content <dir> [--host <host>] [--port <port>] [--clean] [--no-watch] [--no-reload] [--full-render]
purestack publish --content <dir>

Commands:
build Build a content directory into its configured outDir.
serve Start the dev server; --full-render builds all pages once at startup.
publish Clean and build a publish artifact using the configured publishDir.`
publish Clean and build a publish artifact using the configured publishDir.

Options:
--help, -h Print this usage summary.
--version, -v Print the installed PureStack version.`
2 changes: 1 addition & 1 deletion packages/ts-ssg/src/config/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getHead(config?: BasicHeadConfig) {
const head = createHead(getHeadConfig(merge(DEFAULTS, config))).push(
h('meta').attr({
name: 'generator',
content: 'PureStack v1.1.6',
content: 'PureStack v1.1.7',
}),
h('meta').attr({
name: 'color-scheme',
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-style/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-style",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-style.mjs",
"types": "./dist/ts-style.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-svg-icons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-svg-icons",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-svg-icons.mjs",
"types": "./dist/ts-svg-icons.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-util-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-util-node",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-util-node.mjs",
"types": "./dist/ts-util-node.d.mts",
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purestack/ts-util",
"version": "1.1.6",
"version": "1.1.7",
"packageManager": "yarn@4.9.2",
"module": "./dist/ts-util.mjs",
"types": "./dist/ts-util.d.mts",
Expand Down
18 changes: 5 additions & 13 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import { globSync, readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { bumpVersion, versionPattern } from './version'

const projectRoot = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
'..',
)
if (process.argv.length > 2) {
throw new Error('Usage: yarn bump-version (no arguments)')
if (process.argv.length > 3) {
throw new Error('Usage: yarn bump-version [delta] (default: 1)')
}

const versionPattern = /^(0|[1-9]\d*)\.([0-9])\.([0-9])$/
const delta = process.argv[2] ?? '1'
const rootManifest = JSON.parse(
readFileSync(path.join(projectRoot, 'package.json'), 'utf8'),
) as { version: string }
const currentVersion = rootManifest.version
const current = versionPattern.exec(currentVersion)
if (!current)
throw new Error(
`Expected a root version with single-digit minor and patch numbers, received ${currentVersion}.`,
)

// Treat minor and patch as decimal digits, carrying into the next component.
const [major, minor, patch] = current.slice(1).map(BigInt)
const incremented = major * 100n + minor * 10n + patch + 1n
const nextVersion = `${incremented / 100n}.${(incremented / 10n) % 10n}.${incremented % 10n}`
const nextVersion = bumpVersion(currentVersion, delta)

type Update = { relativePath: string; source: string }
const updates: Update[] = []
Expand Down
23 changes: 23 additions & 0 deletions scripts/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const versionPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d?)$/

export function bumpVersion(version: string, delta = '1') {
const increment = Number(delta)
if (!/^\+?[1-9]\d*$/.test(delta) || !Number.isSafeInteger(increment)) {
throw new Error(`Expected a positive integer delta, received ${delta}.`)
}

const current = versionPattern.exec(version)
if (!current) {
throw new Error(
`Expected a major.minor.patch version with patch 0–99, received ${version}.`,
)
}

const [, major, minor, patch] = current
const totalPatch = Number(patch) + increment
const nextMinor = Number(minor) + Math.floor(totalPatch / 100)
if (!Number.isSafeInteger(totalPatch) || !Number.isSafeInteger(nextMinor)) {
throw new Error('The resulting version exceeds the safe integer range.')
}
return `${major}.${nextMinor}.${totalPatch % 100}`
}
Loading