Update Npm to 7.1.2

pull/1421/head
MasterEnoc 4 years ago
parent ee66e4c139
commit 80bd43af6f

@ -2,36 +2,17 @@ module Docs
class Npm class Npm
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
if root_page?
css('#enterprise', '#policies', '#viewAll').remove
else
@doc = doc.at_css('#page')
css('meta', '.colophon').remove
end
css('a.deep-link[id]', 'a.anchor[id]').each do |node| css('.dZYhXG', '.fONtKn').remove
node.parent['id'] = node['id']
node.remove
end
css('> section').each do |node| css('.kSYjyK').remove
node.before(node.children).remove
end
css('pre.editor').each do |node| css('.cDvIaH').remove
node.inner_html = node.inner_html.gsub(/<\/div>(?!\n|\z)/, "</div>\n")
end
css('h1 + h1.subtitle').each do |node| css('.jRndWL').remove_attribute('style')
node.name = 'p'
node.inner_html += '.'
end
css('pre').each do |node|
node.content = node.content
end
doc doc
end end
end end
end end

@ -1,43 +1,27 @@
module Docs module Docs
class Npm class Npm
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name
if slug.start_with?('api') && at_css('pre').content =~ /\A\s*npm\.([\w\-]+\.)*[\w\-]+/
name = $&.strip
else
name = at_css('nav > section.active a.active').content
end
name << ' (CLI)' if slug.start_with?('cli') def get_name
name at_css('h1').content
end end
def get_type def get_type
case slug at_css('.active').content
when 'files/package.json'
'package.json'
when 'misc/config'
'Config'
else
at_css('nav > section.active > h2').content
end
end end
def additional_entries def additional_entries
case slug entries = []
when 'files/package.json'
css('#page > h2').each_with_object [] do |node, entries| if name == 'config'
next if node.content =~ /\A[A-Z]/ css('h4').each do |node|
entries << ["package.json: #{node.content}", node.at_css('.anchor')['id']] entries << [node['id'], slug + '#' + node['id'], 'Config Settings']
end
when 'misc/config'
css('h2:contains("Config Settings") ~ h3').map do |node|
["config: #{node.content}", node.at_css('.anchor')['id']]
end end
else
[]
end end
entries
end end
end end
end end
end end

@ -2,7 +2,7 @@ module Docs
class Npm < UrlScraper class Npm < UrlScraper
self.name = 'npm' self.name = 'npm'
self.type = 'npm' self.type = 'npm'
self.release = '6.4.0' self.release = '7.1.2'
self.base_url = 'https://docs.npmjs.com/' self.base_url = 'https://docs.npmjs.com/'
self.force_gzip = true self.force_gzip = true
self.links = { self.links = {
@ -10,14 +10,20 @@ module Docs
code: 'https://github.com/npm/npm' code: 'https://github.com/npm/npm'
} }
html_filters.push 'npm/entries', 'npm/clean_html', 'title' html_filters.push 'npm/entries', 'npm/clean_html'
options[:max_image_size] = 130_000 options[:max_image_size] = 130_000
options[:container] = ->(filter) { filter.root_page? ? '.toc' : nil }
options[:title] = false
options[:root_title] = 'npm'
options[:skip] = %w(all misc/index) options[:skip] = [
'all',
'misc/index',
'cli',
'orgs/',
'removing-members-from-your-org',
'adding-members-to-your-org',
'downloading-and-installing-packages'
]
options[:skip_patterns] = [ options[:skip_patterns] = [
/\Aenterprise/, /\Aenterprise/,
/\Acompany/, /\Acompany/,
@ -30,8 +36,45 @@ module Docs
npm is a trademark of npm, Inc. npm is a trademark of npm, Inc.
HTML HTML
# fix duplicates
options[:fix_urls] = -> (url) do
url.sub!('private-modules/intro', 'creating-and-publishing-private-packages')
url.sub!('cli/audit', 'cli/v6/commands/npm-audit')
url.sub!('cli/uninstall', 'cli/v6/commands/npm-uninstall')
url.sub!('cli/npm', 'cli/v6/commands/npm')
url.sub!('cli-documentation', 'cli/v6')
url.sub!('misc/registry', 'cli/v6/using-npm/registry')
url.sub!('cli/adduser', 'cli/v6/commands/npm-adduser')
url.sub!('cli/profile', 'cli/v6/commands/npm-profile')
url.sub!('cli/token', 'cli/v6/commands/npm-token')
url.sub!('cli/publish', 'cli/v6/commands/npm-publish')
url.sub!('cli/unpublish', 'cli/v6/commands/npm-unpublish')
url.sub!('cli/deprecate', 'cli/v6/commands/npm-deprecate')
url.sub!('cli/access', 'cli/v6/commands/npm-access')
url.sub!('misc/config', 'cli/v6/using-npm/config')
url.sub!('misc/developers', 'cli/v6/using-npm/developers')
url.sub!('managing-team-access-to-packages', 'managing-team-access-to-organization-packages')
url.sub!('accepting-or-rejecting-an-org-invitation', 'accepting-or-rejecting-an-organization-invitation')
url.sub!('org-roles-and-permissions', 'organization-roles-and-permissions')
url.sub!('upgrading-to-a-paid-org-plan', 'upgrading-to-a-paid-organization-plan')
url.sub!('files/package.json', 'cli/v6/configuring-npm/package-json')
url.sub!('managing-team-access-to-org-packages', 'managing-team-access-to-organization-packages')
url.sub!('about-package-json-and-package-lock-json-files', 'creating-a-package-json-file')
url.sub!('cli/team', 'cli/v6/commands/npm-team')
url.sub!('cli/version', 'cli/v6/commands/npm-version')
url.sub!('creating-a-packge-json-file', 'cli/v6/configuring-npm/package-json')
url.sub!('cli/outdated', 'cli/v6/commands/npm-outdated')
url.sub!('cli/owner', 'cli/v6/commands/npm-owner')
url.sub!('cli/install', 'cli/v6/commands/npm-install')
url.sub!('cli/update', 'cli/v6/commands/npm-update')
url.sub!('cli/config', 'cli/v6/commands/npm-config')
url.sub!('cli/dist-tag', 'cli/v6/commands/npm-dist-tag')
url
end
def get_latest_version(opts) def get_latest_version(opts)
get_latest_github_release('npm', 'cli', opts) get_latest_github_release('npm', 'cli', opts)
end end
end end
end end

Loading…
Cancel
Save