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
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/cli",
"version": "4.14.6",
"version": "4.15.0",
"description": "Botpress CLI",
"scripts": {
"build": "pnpm run bundle && pnpm run template:gen",
Expand Down
14 changes: 9 additions & 5 deletions packages/cli/src/api/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as client from '@botpress/client'
import semver from 'semver'
import yn from 'yn'
import * as errors from '../errors'
import type { Logger } from '../logger'
import { formatPackageRef, ApiPackageRef, NamePackageRef } from '../package-ref'
import * as utils from '../utils'
import { findPreviousIntegrationVersion } from './find-previous-version'
import * as paging from './paging'
import * as retry from './retry'

Expand Down Expand Up @@ -279,11 +280,14 @@ export class ApiClient {
public listAllPages = paging.listAllPages

public async findPreviousIntegrationVersion(ref: NamePackageRef): Promise<PublicOrPrivateIntegration | undefined> {
const previous = await findPreviousIntegrationVersion(this.client, ref)
if (!previous) {
return
const isValidSemverVersion = semver.valid(ref.version)

// Sanity check (this should never happen):
if (!isValidSemverVersion) {
throw new errors.BotpressCLIError(`Invalid version "${ref.version}" for integration "${ref.name}"`)
}
return this.findPublicOrPrivateIntegration({ type: 'id', id: previous.id })

return this.findPublicOrPrivateIntegration({ ...ref, version: `<${ref.version}` })
}

public async findBotByName(name: string): Promise<BotSummary | undefined> {
Expand Down
61 changes: 0 additions & 61 deletions packages/cli/src/api/find-previous-version.test.ts

This file was deleted.

41 changes: 0 additions & 41 deletions packages/cli/src/api/find-previous-version.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/cli/src/package-ref.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('parsePackageRef', () => {
test('parse with invalid version should return undefined', () => {
// arrange
const ref0 = `${name}@lol`
const ref1 = `${name}@1`
const ref2 = `${name}@1.0`
const ref1 = `${name}@>>1`
const ref2 = `${name}@1.0.b`
// act
const result0 = parsePackageRef(ref0)
const result1 = parsePackageRef(ref1)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/package-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const parseNamePackageRef = (ref: string): NamePackageRef | undefined => {
return
}

const cleanedVersion = version === LATEST_TAG ? version : semver.clean(version)
const cleanedVersion = version === LATEST_TAG ? version : semver.validRange(version)
if (!cleanedVersion) {
return
}
Expand Down
Loading