From d2c77760b3e2001e5d18b48e5abf218d0998a4cd Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Fri, 8 Apr 2022 18:07:41 +0300 Subject: [PATCH] deploy: Support all valid semver versions in balena.yml Resolves: #2337 Change-type: minor Depends-on: https://github.com/balena-io/open-balena-api/pull/982 Depends-on: https://github.com/balena-io/balena-api/pull/3584 See: https://jel.ly.fish/product-improvement-draft-releases-and-release-versioning-d0391f45-c2f9-4f4e-b964-1a7e9023a3f4 Signed-off-by: Thodoris Greasidis --- lib/utils/compose_ts.ts | 10 ++++------ npm-shrinkwrap.json | 9 +++------ package.json | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index fda9bec9..f9690385 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -28,6 +28,7 @@ import type { ImageDescriptor, } from 'resin-compose-parse'; import type * as MultiBuild from 'resin-multibuild'; +import * as semver from 'semver'; import type { Duplex, Readable } from 'stream'; import type { Pack } from 'tar-stream'; @@ -1348,9 +1349,6 @@ async function pushServiceImages( ); } -// TODO: This should be shared between the CLI & the Builder -const PLAIN_SEMVER_REGEX = /^([0-9]+)\.([0-9]+)\.([0-9]+)$/; - export async function deployProject( docker: Dockerode, logger: Logger, @@ -1373,10 +1371,10 @@ export async function deployProject( const contractPath = path.join(projectPath, 'balena.yml'); const contract = await getContractContent(contractPath); - if (contract?.version && !PLAIN_SEMVER_REGEX.test(contract?.version)) { + if (contract?.version && !semver.valid(contract.version)) { throw new ExpectedError(stripIndent`\ - Error: expected the version field in "${contractPath}" - to be a basic semver in the format '1.2.3'. Got '${contract.version}' instead`); + Error: the version field in "${contractPath}" + is not a valid semver`); } const $release = await runSpinner( diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index f9f37280..a1406b79 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -2946,12 +2946,9 @@ } }, "@types/semver": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.1.tgz", - "integrity": "sha512-ooD/FJ8EuwlDKOI6D9HWxgIgJjMg2cuziXm/42npDC8y4NjxplBUn9loewZiBNCt44450lHAU0OSb51/UqXeag==", - "requires": { - "@types/node": "*" - } + "version": "7.3.9", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.9.tgz", + "integrity": "sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==" }, "@types/serve-static": { "version": "1.13.10", diff --git a/package.json b/package.json index eb3af6d5..a85e0d87 100644 --- a/package.json +++ b/package.json @@ -155,6 +155,7 @@ "@types/request": "^2.48.7", "@types/rewire": "^2.5.28", "@types/rimraf": "^3.0.2", + "@types/semver": "^7.3.9", "@types/shell-escape": "^0.2.0", "@types/sinon": "^10.0.6", "@types/split": "^1.0.0",