@@ -11,7 +11,8 @@ const TGZ_PATH = path.resolve(__dirname, "resources", "test-package-1.0.1.tgz");
11
11
const AUTH = {
12
12
username : "Username" ,
13
13
password : "Password" ,
14
- email : "test@example.com"
14
+ email : "test@example.com" ,
15
+ // alwaysAuth: true,
15
16
} ;
16
17
17
18
describe ( 'npm-api' , ( ) => {
@@ -33,6 +34,7 @@ describe('npm-api', () => {
33
34
jest . setTimeout ( 3 * 60_000 ) ;
34
35
//https://github.com/npm/npm-registry-client
35
36
//https://github.com/postmanlabs/npm-cli-login/blob/master/lib/login.js#L51
37
+ await addUser ( REGISTRY , AUTH )
36
38
await publishAsync ( REGISTRY , TGZ_PATH , MODULE_NAME , AUTH )
37
39
expect ( await getModuleInfo ( REGISTRY , MODULE_NAME , "1.0.1" , AUTH ) != undefined ) . toEqual ( true )
38
40
} )
@@ -43,6 +45,26 @@ function testSkip(name: string, lambda: any) {
43
45
44
46
}
45
47
48
+ async function addUser ( registryUrl : string , auth : any ) : Promise < unknown > {
49
+ return await new Promise ( ( resolve : ( value ?: unknown ) => void , reject : ( reason ?: any ) => void ) => {
50
+ const regClient = new RegClient ( ) ;
51
+ regClient . adduser (
52
+ registryUrl ,
53
+ {
54
+ auth : auth
55
+ } ,
56
+ ( err : any , data : any ) => {
57
+ if ( err ) {
58
+ console . log ( "err: " , err )
59
+ reject ( err )
60
+ } else {
61
+ resolve ( data )
62
+ }
63
+ }
64
+ )
65
+ } ) ;
66
+ }
67
+
46
68
async function publishAsync ( registryUrl : string , tgzPath : string , moduleName : string , auth : any ) : Promise < unknown > {
47
69
return await new Promise ( ( resolve : ( value ?: unknown ) => void , reject : ( reason ?: any ) => void ) => {
48
70
const regClient = new RegClient ( ) ;
@@ -52,7 +74,7 @@ async function publishAsync(registryUrl: string, tgzPath: string, moduleName: st
52
74
body : fs . createReadStream ( tgzPath ) ,
53
75
metadata : {
54
76
name : moduleName , //todo определять автоматически
55
- version : "1.0.1"
77
+ version : "1.0.1" //todo определять автоматически
56
78
} ,
57
79
auth : auth
58
80
} ,
0 commit comments