Skip to content

Commit

Permalink
rcBranchVersion script
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Jan 23, 2024
1 parent 6d07cc8 commit 95dae14
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"prepublish": "pnpm build && cp ../../README.md ../../LICENSE ./",
"prepack": "pnpm tsn ./scripts/prepack.ts",
"ver": "pnpm tsn ./scripts/updateVersion.ts",
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts"
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts",
"rcBranchVersion": "pnpm tsn ./scripts/rcBranchVersion.ts"
},
"dependencies": {
"@adraffy/ens-normalize": "1.9.0",
Expand Down
27 changes: 27 additions & 0 deletions packages/ensjs/scripts/rcBranchVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
import * as url from 'url'

// get branch name from local git command
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
.toString('utf-8')
.replace(/\//g, '-')
.trim()

// timestamp
const timestamp = new Date().toISOString().replace(/[-:.]/g, '').slice(0, -1)

const newVersion = `0.0.0-${branchName}.${timestamp}`

// // change version in package.json
execSync(`pnpm version --no-workspaces-update ${newVersion}`, {
stdio: 'inherit',
})

const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

// // Writes the new version to `./src/errors/version.ts`.
const versionFilePath = path.join(__dirname, '../src/errors/version.ts')

fs.writeFileSync(versionFilePath, `export const version = '${newVersion}'\n`)

0 comments on commit 95dae14

Please sign in to comment.