8000 addUser · avdim/github-script@d6e2e98 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6e2e98

Browse files
committed
addUser
1 parent c5e3b1b commit d6e2e98

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

__test__/npm-api.test.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const TGZ_PATH = path.resolve(__dirname, "resources", "test-package-1.0.1.tgz");
1111
const AUTH = {
1212
username: "Username",
1313
password: "Password",
14-
email: "test@example.com"
14+
email: "test@example.com",
15+
// alwaysAuth: true,
1516
};
1617

1718
describe('npm-api', () => {
@@ -33,6 +34,7 @@ describe('npm-api', () => {
3334
jest.setTimeout(3 * 60_000);
3435
//https://github.com/npm/npm-registry-client
3536
//https://github.com/postmanlabs/npm-cli-login/blob/master/lib/login.js#L51
37+
await addUser(REGISTRY, AUTH)
3638
await publishAsync(REGISTRY, TGZ_PATH, MODULE_NAME, AUTH)
3739
expect(await getModuleInfo(REGISTRY, MODULE_NAME, "1.0.1", AUTH) != undefined).toEqual(true)
3840
})
@@ -43,6 +45,26 @@ function testSkip(name: string, lambda: any) {
4345

4446
}
4547

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+
4668
async function publishAsync(registryUrl: string, tgzPath: string, moduleName: string, auth: any): Promise<unknown> {
4769
return await new Promise((resolve: (value?: unknown) => void, reject: (reason?: any) => void) => {
4870
const regClient = new RegClient();
@@ -52,7 +74,7 @@ async function publishAsync(registryUrl: string, tgzPath: string, moduleName: st
5274
body: fs.createReadStream(tgzPath),
5375
metadata: {
5476
name: moduleName,//todo определять автоматически
55-
version: "1.0.1"
77+
version: "1.0.1"//todo определять автоматически
5678
},
5779
auth: auth
5880
},

test-npm-api.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ docker-compose --file npm-registries.yml up -d
1212
sleep 2
1313
#echo "start"
1414

15-
node_modules/.bin/npm-cli-login -u Username -p Password -e test@example.com -r http://localhost:55552
16-
1715
node_modules/.bin/jest --testNamePattern=npm-api && echo "upload test success" # && clear
1816

1917
#clear #todo clear if fails

0 commit comments

Comments
 (0)
0