| 39 | const buildProject = () => runCommand('yarn build'); |
| 40 | |
| 41 | const registerUser = async (npmRegistryUrl: string) => { |
| 42 | const dummyUser = randomBytes(4).toString('hex'); |
| 43 | const dummyPassword = randomBytes(4).toString('hex'); |
| 44 | |
| 45 | const goAuthResponse = await go(() => |
| 46 | axios.put( |
| 47 | `${npmRegistryUrl}/-/user/org.couchdb.user:${dummyUser}`, |
| 48 | { |
| 49 | name: dummyUser, |
| 50 | password: dummyPassword, |
| 51 | }, |
| 52 | { |
| 53 | headers: { |
| 54 | 'Content-Type': 'application/json', |
| 55 | }, |
| 56 | } |
| 57 | ) |
| 58 | ); |
| 59 | |
| 60 | if (!goAuthResponse.success) { |
| 61 | throw new Error(`Can't authenticate against NPM registry ${npmRegistryUrl}: ${goAuthResponse.error}`); |
| 62 | } |
| 63 | |
| 64 | return goAuthResponse.data.data.token; |
| 65 | }; |
| 66 | |
| 67 | const authNpmRegistry = (npmRegistryUrl: string, npmAuthToken: string) => { |
| 68 | const npmrcPath = join(homedir(), '.npmrc'); |