feat: allow version with commit hash

This commit is contained in:
Adam Uhlíř 2022-05-05 16:21:02 +02:00
parent b7659fc8b4
commit 9c99180aac
No known key found for this signature in database
GPG Key ID: 1D17A9E81F76155B
2 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,7 @@ import {
import { waitForBlockchain, waitForQueen, waitForWorkers } from '../utils/wait'
import ora from 'ora'
import { VerbosityLevel } from './root-command/logging'
import { findBeeVersion } from '../utils/config-sources'
import { findBeeVersion, stripCommit } from '../utils/config-sources'
const DEFAULT_REPO = 'ethersphere'
@ -85,6 +85,8 @@ export class Start extends RootCommand implements LeafCommand {
this.console.log(`Spinning up cluster with Bee version ${this.beeVersion}.`)
}
this.beeVersion = stripCommit(this.beeVersion)
const dockerOptions = await this.buildDockerOptions()
const docker = new Docker(this.console, this.envPrefix, this.imagePrefix, this.repo)
const status = await docker.getAllStatus()

View File

@ -1,6 +1,17 @@
import { readFile } from 'fs/promises'
import * as path from 'path'
const VERSION_REGEX = /^\d\.\d\.\d(-\w+)+$/
export function stripCommit(version: string): string {
if (!VERSION_REGEX.test(version)) {
throw new Error('The version does not have expected format!')
}
// If the version contains commit ==> hash remove it
return version.replace(/(-\w+)+$/g, '')
}
async function searchPackageJson(): Promise<string | undefined> {
const expectedPath = path.join(process.cwd(), 'package.json')
const pkgJson = JSON.parse(await readFile(expectedPath, { encoding: 'utf8' }))