diff --git a/src/commands/init/index.ts b/src/commands/init/index.ts index 75bef98..98d4d2e 100644 --- a/src/commands/init/index.ts +++ b/src/commands/init/index.ts @@ -165,7 +165,7 @@ export default class Init extends Command { } private async _resolveVersion(packageConfig: PackageConfig, verbose: boolean): Promise { - const packageVersions = await packageConfig.getPackageVersions(); + const packageVersions = await packageConfig.getPackageVersions(verbose); const packageVersion = resolveVersionIdentifier(packageVersions, packageConfig.version); if (verbose) { diff --git a/src/commands/upgrade/index.ts b/src/commands/upgrade/index.ts index 8901940..4e98dbd 100644 --- a/src/commands/upgrade/index.ts +++ b/src/commands/upgrade/index.ts @@ -81,7 +81,7 @@ export default class Upgrade extends Command { flags: any, ): Promise { const initialVersionSpecifier = packageConfig.version; - const availableVersions = await packageConfig.getPackageVersions(); + const availableVersions = await packageConfig.getPackageVersions(flags.verbose); const matchedVersion = flags['ignore-bounds'] ? getLatestVersion(availableVersions.all) : resolveVersionIdentifier(availableVersions, packageConfig.version); diff --git a/src/modules/exec.ts b/src/modules/exec.ts index b2a48d0..d8c5ff6 100644 --- a/src/modules/exec.ts +++ b/src/modules/exec.ts @@ -14,7 +14,7 @@ import { IPty, spawn } from 'node-pty'; import { exec } from 'node:child_process'; -import { join, resolve } from 'node:path'; +import { resolve } from 'node:path'; import { ExecSpec, ProgramSpec } from './component'; import { ProjectCache } from './project-cache'; import { ProjectConfig } from './projectConfig/projectConfig'; diff --git a/src/modules/package-downloader.ts b/src/modules/package-downloader.ts index 47bfb43..cb2c522 100644 --- a/src/modules/package-downloader.ts +++ b/src/modules/package-downloader.ts @@ -30,11 +30,17 @@ export class PackageDownloader { await this.git.clone(this.packageConfig.getPackageRepo(), packageDir, cloneOpts); } - private async _updateRepository(checkRepoAction: CheckRepoActions): Promise { + private async _updateRepository(checkRepoAction: CheckRepoActions, verbose: boolean): Promise { const localRepoExists = await this.git.checkIsRepo(checkRepoAction); if (localRepoExists) { - await this.git.fetch(['--force', '--tags', '--prune', '--prune-tags']); + try { + await this.git.fetch(['--force', '--tags', '--prune', '--prune-tags']); + } catch (error) { + if (verbose) { + console.log(`... Could not check the server version for ${this.packageConfig.repo}`); + } + } } } @@ -59,12 +65,13 @@ export class PackageDownloader { return await simpleGit(packageDir).checkIsRepo(checkRepoAction); } - public async downloadPackage(option: { checkVersionOnly: boolean }): Promise { + public async downloadPackage(option: { checkVersionOnly?: boolean; verbose?: boolean }): Promise { + const { checkVersionOnly = false, verbose = false } = option; let packageDir: string = this.packageConfig.getPackageDirectory(); let checkRepoAction: CheckRepoActions; const cloneOpts: string[] = []; - if (option.checkVersionOnly) { + if (checkVersionOnly) { packageDir = join(packageDir, '_cache'); cloneOpts.push('--bare'); checkRepoAction = CheckRepoActions.BARE; @@ -75,9 +82,9 @@ export class PackageDownloader { await this._checkForValidRepo(packageDir, cloneOpts, checkRepoAction); this.git = simpleGit(packageDir); - await this._updateRepository(checkRepoAction); + await this._updateRepository(checkRepoAction, verbose); - if (!option.checkVersionOnly) { + if (!checkVersionOnly) { await this._checkoutVersion(this.packageConfig.version); } diff --git a/src/modules/package.ts b/src/modules/package.ts index 830d168..29e2250 100644 --- a/src/modules/package.ts +++ b/src/modules/package.ts @@ -92,9 +92,9 @@ export class PackageConfig { this.version = version; } - async getPackageVersions(): Promise { + async getPackageVersions(verbose?: boolean): Promise { try { - const packageInformation = await packageDownloader(this).downloadPackage({ checkVersionOnly: true }); + const packageInformation = await packageDownloader(this).downloadPackage({ checkVersionOnly: true, verbose: verbose }); const packageVersionTags = await packageInformation.tags(); return packageVersionTags; } catch (error) { @@ -108,7 +108,7 @@ export class PackageConfig { async downloadPackageVersion(verbose?: boolean): Promise { try { - await packageDownloader(this).downloadPackage({ checkVersionOnly: false }); + await packageDownloader(this).downloadPackage({ verbose: verbose }); } catch (error) { console.error(error); }