Skip to content

Commit

Permalink
Merge branch 'main' into feat/additional-files-for-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
doosuu authored Jun 11, 2024
2 parents 8193177 + df566c0 commit 12e0b76
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class Init extends Command {
}

private async _resolveVersion(packageConfig: PackageConfig, verbose: boolean): Promise<void> {
const packageVersions = await packageConfig.getPackageVersions();
const packageVersions = await packageConfig.getPackageVersions(verbose);
const packageVersion = resolveVersionIdentifier(packageVersions, packageConfig.version);

if (verbose) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/upgrade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class Upgrade extends Command {
flags: any,
): Promise<boolean> {
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);
Expand Down
19 changes: 13 additions & 6 deletions src/modules/package-downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ export class PackageDownloader {
await this.git.clone(this.packageConfig.getPackageRepo(), packageDir, cloneOpts);
}

private async _updateRepository(checkRepoAction: CheckRepoActions): Promise<void> {
private async _updateRepository(checkRepoAction: CheckRepoActions, verbose: boolean): Promise<void> {
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}`);
}
}
}
}

Expand All @@ -59,12 +65,13 @@ export class PackageDownloader {
return await simpleGit(packageDir).checkIsRepo(checkRepoAction);
}

public async downloadPackage(option: { checkVersionOnly: boolean }): Promise<SimpleGit> {
public async downloadPackage(option: { checkVersionOnly?: boolean; verbose?: boolean }): Promise<SimpleGit> {
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;
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/modules/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class PackageConfig {
this.version = version;
}

async getPackageVersions(): Promise<TagResult> {
async getPackageVersions(verbose?: boolean): Promise<TagResult> {
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) {
Expand All @@ -108,7 +108,7 @@ export class PackageConfig {

async downloadPackageVersion(verbose?: boolean): Promise<void> {
try {
await packageDownloader(this).downloadPackage({ checkVersionOnly: false });
await packageDownloader(this).downloadPackage({ verbose: verbose });
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit 12e0b76

Please sign in to comment.