Skip to content

Commit

Permalink
Add Remote Build Task
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Dec 4, 2024
1 parent 010d181 commit 18df755
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions hammer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export async function clean() {
await folder('node_modules/typebox').delete()
await folder('target').delete()
}

// -------------------------------------------------------------------------------
// Format
// -------------------------------------------------------------------------------
export async function format() {
await shell('prettier --no-semi --single-quote --print-width 240 --trailing-comma all --write src test task example/index.ts')
}

// -------------------------------------------------------------------------------
// Start
// -------------------------------------------------------------------------------
Expand All @@ -28,6 +30,7 @@ export async function benchmark() {
await Benchmark.compression()
await Benchmark.measurement()
}

// -------------------------------------------------------------------------------
// Test
// -------------------------------------------------------------------------------
Expand All @@ -49,6 +52,7 @@ export async function test(filter = '') {
await test_static()
await test_runtime(filter)
}

// -------------------------------------------------------------------------------
// Build
// -------------------------------------------------------------------------------
Expand All @@ -69,6 +73,25 @@ export async function build(target = 'target/build') {
await shell(`cd ${target} && npm pack`)
await build_check(target)
}

// -------------------------------------------------------------------------------
// Build To
// -------------------------------------------------------------------------------
export async function build_to(remote = 'target/build', target = 'target/build') {
await clean()
await Promise.all([
Build.Package.build(target),
Build.Esm.build(target),
Build.Cjs.build(target),
])
await folder(target).add('readme.md')
await folder(target).add('license')
await shell(`cd ${target} && npm pack`)
const { version } = JSON.parse(Fs.readFileSync('package.json', 'utf8'))
const filename = `${target}/sinclair-typebox-${version}.tgz`
await folder(remote).add(filename)
}

// -------------------------------------------------------------------------------
// Install
// -------------------------------------------------------------------------------
Expand All @@ -77,6 +100,7 @@ export async function install_local() {
await build('target/typebox')
await folder('node_modules').add('target/typebox')
}

// -------------------------------------------------------------
// Publish
// -------------------------------------------------------------
Expand All @@ -87,6 +111,7 @@ export async function publish(otp, target = 'target/build') {
await shell(`git tag ${version}`)
await shell(`git push origin ${version}`)
}

// -------------------------------------------------------------
// Publish-Dev
// -------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test:runtime": "hammer task test_runtime",
"install:local": "hammer task install_local",
"benchmark": "hammer task benchmark",
"build:to": "hammer task build_to",
"build": "hammer task build",
"test": "hammer task test",
"clean": "hammer task clean",
Expand Down

0 comments on commit 18df755

Please sign in to comment.