Skip to content

Commit e6c751d

Browse files
committed
fix: fix npm api
1 parent 41ca7f5 commit e6c751d

2 files changed

Lines changed: 17 additions & 22 deletions

File tree

lib/package.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,13 @@ export default class Package {
613613
}
614614

615615
async runScript ( script, args ) {
616-
return this.npm.api.runScript( script, { args } );
616+
return this.npm.runScript( script, { args } );
617617
}
618618

619619
async getOutdatedDependencies ( { all } = {} ) {
620620
if ( !this.dependencies.hasDependencies ) return result( 200 );
621621

622-
return this.npm.api.getOutdatedDependencies( { all } );
622+
return this.npm.getOutdatedDependencies( { all } );
623623
}
624624

625625
async updateDependencies ( { all, outdated, install, reinstall, commit, quiet, confirmInstall, outdatedDependencies, cache = {} } = {} ) {
@@ -836,7 +836,7 @@ export default class Package {
836836
// perform update
837837
process.stdout.write( "Updating dependencies ... " );
838838

839-
res = await this.npm.api.exec( "update" );
839+
res = await this.npm.exec( "update" );
840840

841841
if ( res.ok ) {
842842
console.log( ansi.ok( " OK " ) );
@@ -934,7 +934,7 @@ export default class Package {
934934
res = result( [ 200, "No tests to run" ] );
935935
}
936936
else {
937-
res = await this.npm.api.runScript( "test", { log } );
937+
res = await this.npm.runScript( "test", { log } );
938938
}
939939

940940
if ( log ) {

lib/package/npm.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,22 @@ import { TmpDir } from "#core/tmp";
55
import { repeatAction } from "#core/utils";
66
import Package from "#lib/package";
77

8-
export default class Npm {
8+
export default class Npm extends NpmApi {
99
#pkg;
10-
#api;
1110

1211
constructor ( pkg ) {
13-
this.#pkg = pkg;
14-
15-
this.#api = new NpmApi( {
16-
"cwd": this.#pkg.root,
12+
super( {
13+
"cwd": pkg.root,
1714
} );
15+
16+
this.#pkg = pkg;
1817
}
1918

2019
// properties
2120
get pkg () {
2221
return this.#pkg;
2322
}
2423

25-
get api () {
26-
return this.#api;
27-
}
28-
2924
// public
3025
async publish ( { commitRef, accessStatus, repeatOnError } = {} ) {
3126
var res;
@@ -165,7 +160,7 @@ export default class Npm {
165160
if ( !commit?.isRelease ) return result( [ 400, "Git commit is not released" ] );
166161

167162
// get package versions
168-
res = await this.api.getPackageVersions( this.pkg.name );
163+
res = await super.getPackageVersions( this.pkg.name );
169164
if ( !res.ok ) {
170165

171166
// package not found
@@ -191,7 +186,7 @@ export default class Npm {
191186
: "" ) );
192187

193188
// pack
194-
res = await pkg.npm.api.pack( {
189+
res = await pkg.npm.pack( {
195190
"executablesPatterns": pkg.cliConfig?.meta?.executables,
196191
} );
197192
if ( !res.ok ) throw res;
@@ -202,7 +197,7 @@ export default class Npm {
202197
}
203198

204199
// publish
205-
res = await pkg.npm.api.publish( {
200+
res = await pkg.npm.publish( {
206201
"packPath": pack.path,
207202
accessStatus,
208203
"tag": commit.tags.has( "latest" )
@@ -226,7 +221,7 @@ export default class Npm {
226221

227222
const tags = {};
228223

229-
res = await this.api.getPackageTags( this.pkg.name );
224+
res = await super.getPackageTags( this.pkg.name );
230225
if ( !res.ok ) {
231226
if ( res.data?.error?.code === "E404" ) {
232227
return result( [ 404, "Package not fouund" ] );
@@ -248,7 +243,7 @@ export default class Npm {
248243

249244
// set
250245
if ( version && remoteTags[ tag ] !== version.version ) {
251-
res = await this.api.setPackageTag( this.pkg.name, version.version, tag );
246+
res = await super.setPackageTag( this.pkg.name, version.version, tag );
252247

253248
if ( !res.ok ) {
254249
if ( res.data?.error?.code !== "E404" ) {
@@ -262,7 +257,7 @@ export default class Npm {
262257

263258
// delete
264259
else if ( remoteTags[ tag ] && !version ) {
265-
res = await this.api.deletePackageTag( this.pkg.name, tag );
260+
res = await super.deletePackageTag( this.pkg.name, tag );
266261
if ( !res.ok ) return res;
267262

268263
updated = true;
@@ -279,11 +274,11 @@ export default class Npm {
279274
var res,
280275
updated = false;
281276

282-
res = await this.api.getPackageAccessStatus( this.pkg.name );
277+
res = await super.getPackageAccessStatus( this.pkg.name );
283278
if ( !res.ok ) return res;
284279

285280
if ( res.data.accessStatus !== accessStatus ) {
286-
res = await this.api.setPackageAccessStatus( this.pkg.name, accessStatus );
281+
res = await super.setPackageAccessStatus( this.pkg.name, accessStatus );
287282
if ( !res.ok ) return res;
288283

289284
updated = true;

0 commit comments

Comments
 (0)