Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated npm-cli-login utility from buildutils #10828

Merged
merged 3 commits into from Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion buildutils/package.json
Expand Up @@ -50,7 +50,6 @@
"glob": "~7.1.6",
"inquirer": "^7.0.0",
"minimatch": "~3.0.4",
"npm-cli-login": "^0.1.1",
"os": "~0.1.1",
"package-json": "^6.5.0",
"prettier": "~2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion buildutils/src/ensure-repo.ts
Expand Up @@ -83,7 +83,7 @@ const UNUSED: Dict<string[]> = {
'webpack-cli',
'worker-loader'
],
'@jupyterlab/buildutils': ['npm-cli-login', 'verdaccio'],
'@jupyterlab/buildutils': ['verdaccio'],
'@jupyterlab/coreutils': ['path-browserify'],
'@jupyterlab/services': ['node-fetch', 'ws'],
'@jupyterlab/rendermime': ['@jupyterlab/mathjax2'],
Expand Down
52 changes: 43 additions & 9 deletions buildutils/src/local-repository.ts
Expand Up @@ -128,16 +128,50 @@ packages:
}

// Log in using cli and temp credentials
const env = {
...process.env,
NPM_USER: 'foo',
NPM_PASS: 'bar',
NPM_EMAIL: 'foo@bar.com',
NPM_REGISTRY: local_registry
};
const npm_cli_login_bin = path.join(bin_dir, 'npm-cli-login');
const user = 'foo';
const pass = 'bar';
const email = 'foo@bar.com';
console.log('Logging in');
child_process.execSync(npm_cli_login_bin, { env, stdio: 'pipe' });
const loginPs = child_process.spawn(
'npm',
`login -r ${local_registry}`.split(' ')
);

const loggedIn = new Promise<void>((accept, reject) => {
loginPs.stdout.on('data', (chunk: string) => {
const data = Buffer.from(chunk, 'utf-8').toString().trim();
console.log('stdout:', data);
switch (data) {
case 'Username:':
console.log('Passing username...');
loginPs.stdin.write(user + '\n');
break;
case 'Password:':
console.log('Passing password...');
loginPs.stdin.write(pass + '\n');
break;
case 'Email: (this IS public)':
console.log('Passing email...');
loginPs.stdin.write(email + '\n');
break;
default:
reject(`Unexpected prompt: "${data}"`);
}
if (data.indexOf('Logged in as') !== -1) {
loginPs.stdin.end();
// do not accept here yet, the token may not have been written
}
loginPs.stderr.on('data', (chunk: string) => {
const data = Buffer.from(chunk, 'utf-8').toString().trim();
console.log('stderr:', data);
});
});
loginPs.on('error', error => reject(error));
loginPs.on('close', () => accept());
});

await loggedIn;
loginPs.kill();

console.log('Running in', out_dir);
ps.exit(0);
Expand Down