Skip to content

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ COPY . .
88

99
RUN npm install -g npminstall --registry=https://registry.npmmirror.com \
1010
&& npminstall -c \
11-
&& npm run tsc
11+
&& npm run tsc \
12+
&& npmupdate -c --production # remove devDependencies
1213

1314
ENV NODE_ENV=production \
1415
EGG_SERVER_ENV=prod

app/port/controller/AccessController.ts

-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,4 @@ export class AccessController extends AbstractController {
5050

5151
return res;
5252
}
53-
54-
5553
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
"s3-cnpmcore": "^1.1.2"
130130
},
131131
"devDependencies": {
132-
"@cnpmjs/npm-cli-login": "^1.1.0",
133132
"@eggjs/bin": "^7.1.0",
134133
"@eggjs/mock": "^6.0.7",
135134
"@elastic/elasticsearch-mock": "^2.0.0",

test/cli/CliUtil.ts

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import coffee from 'coffee';
1+
import fs from 'node:fs/promises';
22

33
export async function npmLogin(registry: string, userconfig: string) {
4-
await coffee
5-
.spawn('npm-cli-login', [], {
6-
env: {
7-
...process.env,
8-
NPM_USER: 'testuser',
9-
NPM_PASS: '123123123',
10-
NPM_EMAIL: '[email protected]',
11-
NPM_REGISTRY: registry,
12-
NPM_RC_PATH: userconfig,
13-
},
14-
})
15-
.debug()
16-
.expect('code', 0)
17-
.end();
4+
const response = await fetch(`${registry}/-/user/org.couchdb.user:testuser`, {
5+
headers: {
6+
Authorization: 'Bearer 123123123',
7+
'Content-Type': 'application/json',
8+
},
9+
method: 'PUT',
10+
body: JSON.stringify({
11+
name: 'testuser',
12+
password: '123123123',
13+
14+
type: 'user',
15+
}),
16+
});
17+
if (!response.ok) {
18+
throw new Error(`Failed to login: ${await response.text()}`);
19+
}
20+
const body = await response.json();
21+
const registryUrl = new URL(registry);
22+
await fs.writeFile(userconfig, `\n//${registryUrl.host}/:_authToken=${body.token}\n`);
1823
}

0 commit comments

Comments
 (0)