@@ -5,27 +5,22 @@ import { TmpDir } from "#core/tmp";
55import { repeatAction } from "#core/utils" ;
66import 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