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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
},
"repository": "bump-sh/cli",
"scripts": {
"prepare": "npm run build",
"build": "shx rm -rf dist && tsc -b",
"clean": "rm -rf dist/ oclif.manifest.json",
"lint": "eslint . --ext .ts",
Expand Down
5 changes: 3 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class BumpApi {
}

// Check https://oclif.io/docs/config for details about Config.IConfig
public constructor(protected config: Config) {
public constructor(protected config?: Config) {
const baseURL = `${vars.apiUrl}${vars.apiBasePath}`
const userAgent = config?.userAgent || 'bump-cli'
const headers: {Authorization?: string; 'User-Agent': string} = {
'User-Agent': vars.apiUserAgent(config.userAgent),
'User-Agent': vars.apiUserAgent(userAgent),
}

this.client = axios.create({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class Diff extends BaseCommand<typeof Diff> {

ux.action.status = '...diff on Bump.sh in progress'

const diff: DiffResponse | undefined = await new CoreDiff(this.bump).run(
const diff: DiffResponse | undefined = await new CoreDiff(this.config).run(
args.file,
args.otherFile,
documentation,
Expand Down
23 changes: 17 additions & 6 deletions src/core/diff.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Config} from '@oclif/core'
import {CLIError} from '@oclif/core/errors'
import debug from 'debug'

Expand All @@ -10,9 +11,17 @@
static readonly TIMEOUT = 120

private _bump!: BumpApi
private _config: Config | undefined

public constructor(bumpClient: BumpApi) {
this._bump = bumpClient
public constructor(config?: Config) {
if (config) {
this._config = config
}
}

get bumpClient(): BumpApi {
if (!this._bump) this._bump = new BumpApi(this._config!)
return this._bump
}

get pollingPeriod(): number {
Expand All @@ -32,7 +41,7 @@
references,
}

const response = await this._bump.postDiff(request)
const response = await this.bumpClient.postDiff(request)

switch (response.status) {
case 201: {
Expand All @@ -48,7 +57,7 @@
}
}

async createVersion(

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on ubuntu-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on ubuntu-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on ubuntu-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on macos-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on macos-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on macos-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on windows-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on windows-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4

Check warning on line 60 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on windows-latest

Async method 'createVersion' has too many parameters (6). Maximum allowed is 4
file: string,
documentation: string,
token: string,
Expand All @@ -68,7 +77,7 @@
unpublished: true,
}

const response = await this._bump.postVersion(request, token)
const response = await this.bumpClient.postVersion(request, token)

switch (response.status) {
case 201: {
Expand All @@ -91,7 +100,7 @@
}

extractDiff(versionWithDiff: VersionResponse & WithDiff): DiffResponse {
// TODO: return a real diff_id in the GET /version API

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on ubuntu-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on ubuntu-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on ubuntu-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on macos-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on macos-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on macos-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on windows-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on windows-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'

Check warning on line 103 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on windows-latest

Unexpected 'todo' comment: 'TODO: return a real diff_id in the GET...'
return {
breaking: versionWithDiff.diff_breaking,
details: versionWithDiff.diff_details,
Expand All @@ -115,7 +124,7 @@
await this.delay(this.pollingPeriod)
}

public async run(

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on ubuntu-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on ubuntu-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on ubuntu-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on macos-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on macos-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on macos-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node latest - x64 on windows-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 23 - x64 on windows-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4

Check warning on line 127 in src/core/diff.ts

View workflow job for this annotation

GitHub Actions / Node 20 - x64 on windows-latest

Async method 'run' has too many parameters (8). Maximum allowed is 4
file1: string,
file2: string | undefined,
documentation: string | undefined,
Expand All @@ -125,6 +134,8 @@
format: string,
expires: string | undefined,
): Promise<DiffResponse | undefined> {
if (!this._config) this._config = await Config.load('../../')

let diffVersion: DiffResponse | VersionResponse | undefined

if (file2 && (!documentation || !token)) {
Expand Down Expand Up @@ -157,8 +168,8 @@
opts: {format: string; timeout: number},
): Promise<DiffResponse> {
const pollingResponse = await (this.isVersion(result) && token
? this._bump.getVersion(result.id, token)
: this._bump.getDiff(result.id, opts.format))
? this.bumpClient.getVersion(result.id, token)
: this.bumpClient.getDiff(result.id, opts.format))

if (opts.timeout <= 0) {
throw new CLIError(
Expand Down
Loading