Skip to content

Commit 13732a7

Browse files
Revert "chore: modified retrieve npm package functionality"
1 parent bc5f327 commit 13732a7

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
"docs": "sf-docs",
161161
"format": "sf-format",
162162
"lint": "sf-lint",
163-
"lint-fix": "yarn sf-lint --fix",
164163
"oclif-artifacts": "oclif-dev manifest",
165164
"postpack": "shx rm -f oclif.manifest.json",
166165
"posttest": "yarn lint && yarn test:deprecation-policy && yarn test:command-reference",

src/package.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ export class Package extends AsyncOptionalCreatable {
7878
return (await fs.readJson(pkgJsonPath)) as PackageJson;
7979
}
8080

81-
public retrieveNpmPackage(requiredVersion = ''): NpmPackage {
82-
const pacakgeName = requiredVersion ? `${this.name}@${requiredVersion}` : `${this.name}`;
83-
const result = exec(`npm view ${pacakgeName} ${this.registry.getRegistryParameter()} --json`, { silent: true });
81+
public retrieveNpmPackage(): NpmPackage {
82+
const result = exec(`npm view ${this.name} ${this.registry.getRegistryParameter()} --json`, { silent: true });
8483
return result.code === 0 ? (JSON.parse(result.stdout) as NpmPackage) : null;
8584
}
8685

@@ -114,8 +113,9 @@ export class Package extends AsyncOptionalCreatable {
114113
}
115114

116115
public nextVersionIsAvailable(): boolean {
117-
const pkg = this.retrieveNpmPackage(this.nextVersion);
118-
return pkg?.version === this.nextVersion;
116+
const pkg = this.retrieveNpmPackage();
117+
const versions = get(pkg, 'versions', []) as string[];
118+
return versions.includes(this.nextVersion);
119119
}
120120

121121
public writePackageJson(rootDir?: string): void {

test/package.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ describe('Package', () => {
124124
});
125125

126126
it('should return false if the next version is not listed yet', async () => {
127-
stubMethod($$.SANDBOX, Package.prototype, 'retrieveNpmPackage').returns(null);
127+
stubMethod($$.SANDBOX, Package.prototype, 'retrieveNpmPackage').returns({
128+
name: pkgName,
129+
version: '1.0.0',
130+
versions: ['0.0.1', '0.0.5', '1.0.0'],
131+
});
128132
const pkg = await Package.create();
129133
pkg.setNextVersion('1.1.0');
130134
expect(pkg.nextVersionIsAvailable()).to.equal(false);

0 commit comments

Comments
 (0)