') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); npm-profile, npm-registry-fetch, emit input.start by lukekarrys · Pull Request #7457 · npm/cli · GitHub
Skip to content

npm-profile, npm-registry-fetch, emit input.start - #7457

Merged
lukekarrys merged 4 commits into
latestfrom
lk/help-and-url-input-start
May 2, 2024
Merged

npm-profile, npm-registry-fetch, emit input.start#7457
lukekarrys merged 4 commits into
latestfrom
lk/help-and-url-input-start

Conversation

@lukekarrys

@lukekarryslukekarrys commented Apr 30, 2024

Copy link
Copy Markdown
Contributor

Note: this relies on npm/npm-profile#131 This now includes npm-profile@10.0.0

This PR accomplishes the following:

  • wraps the help output and url openers in input.start so progress won't be shown while the terminal is running those commands
  • Moves otplease to auth.js. They share many of the same requires and all the commands that required auth.js also required otplease
  • Combines open-url and open-url-prompt files
  • Removes web-auth in favor of a new webAuthOpener method exported from npm-profile
  • Uses readline/promises for url prompts which can directly accept the new AbortSignal API from npm-profile

@lukekarrys
lukekarrys requested a review from a team as a code ownerApril 30, 2024 22:31
@lukekarrys
lukekarrysforce-pushed the lk/help-and-url-input-start branch 2 times, most recently from f66808b to 5b230c7CompareMay 1, 2024 01:38
@lukekarrys
lukekarrys marked this pull request as draft May 1, 2024 01:39
@lukekarrys
lukekarrysforce-pushed the lk/help-and-url-input-start branch 3 times, most recently from 8aac32d to 2f08cd7CompareMay 1, 2024 01:46
@lukekarrys
lukekarrys marked this pull request as ready for review May 1, 2024 06:16
@lukekarrys
lukekarrysforce-pushed the lk/help-and-url-input-start branch from 2f08cd7 to 19175d8CompareMay 2, 2024 16:03
@lukekarrys
lukekarrysforce-pushed the lk/help-and-url-input-start branch from 19175d8 to 531c674CompareMay 2, 2024 16:15
@lukekarryslukekarrys changed the title fix: run input.start around help and openining urlsnpm-profile, npm-registry-fetch, emit input.startMay 2, 2024
Comment threadlib/commands/help.js
args = ['emacsclient', ['-e', `(woman-find-file '${man}')`]]
}

return spawn(...args, { stdio: 'inherit' }).catch(err => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm was not using the return data from promise-spawn here so this is ok

https://github.com/npm/promise-spawn/blob/0aaf6f0f37e5b468277c8a4d8200b5ab18a4b387/lib/index.js#L27-L33

mocks: {
pacote,
'{LIB}/utils/open-url.js': openUrl,
'{LIB}/utils/open-url.js': { openUrl },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future we should use spawk for these

t.same(joinedOutput(), '', 'printed no output')
})
const { openUrlPrompt } = tmock(t, '{LIB}/utils/open-url.js', {
'@npmcli/promise-spawn': {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future we should use spawk here.

This also refactors auth and prompt related files to use
promises and new npm-profile behavior
@lukekarrys
lukekarrysforce-pushed the lk/help-and-url-input-start branch from 9c5075c to 8f73741CompareMay 2, 2024 16:38
@lukekarrys
lukekarrys merged commit 8ded848 into latestMay 2, 2024
@lukekarrys
lukekarrys deleted the lk/help-and-url-input-start branch May 2, 2024 16:50
@github-actionsgithub-actionsBot mentioned this pull request May 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lukekarrys@wraithgar