Skip to content
Snippets Groups Projects
Select Git revision
  • 26d0495ee6dc06832fadb69b81f6a66d24bbf660
  • master default protected
  • gh-pages
  • dependabot/npm_and_yarn/eslint-plugin-jsdoc-51.0.3
  • dependabot/npm_and_yarn/nock-14.0.5
  • dependabot/npm_and_yarn/react-19.1.0
  • dependabot/npm_and_yarn/react-dom-19.1.0
  • server-2025-02-01-6100669a
  • server-2024-11-01-87cba042
  • server-2024-10-01-6875b7c8
  • dependabot/npm_and_yarn/path-to-regexp-8.2.0
  • server-2024-09-01-3d52575c
  • daily-tests-gha2
  • daily-tests-gha
  • server-2023-12-01-92d8fb8e
  • server-2023-11-01-a80c93fd
  • server-2023-10-01-31096085
  • coc-v2
  • server-2023-09-01-8edc3810
  • server-2023-08-01-75858a03
  • server-2023-07-01-02183d8d
  • server-2025-07-01
  • 5.0.2
  • 5.0.1
  • 5.0.0
  • server-2025-06-01
  • server-2025-05-01
  • server-2025-04-03
  • server-2025-03-02
  • server-2025-03-01
  • server-2025-02-02
  • server-2025-01-01
  • server-2024-12-01
  • server-2024-11-02
  • 4.1.0
  • server-2024-09-25
  • server-2024-09-02
  • server-2024-08-01
  • server-2024-07-01
  • 4.0.0
  • server-2024-06-01
41 results

load-simple-icons.js

Blame
  • pypi-status.service.js 1.59 KiB
    import PypiBase from './pypi-base.js'
    import { parseClassifiers } from './pypi-helpers.js'
    
    export default class PypiStatus extends PypiBase {
      static category = 'other'
    
      static route = this.buildRoute('pypi/status')
    
      static examples = [
        {
          title: 'PyPI - Status',
          pattern: ':packageName',
          namedParams: { packageName: 'Django' },
          staticPreview: this.render({ status: 'stable' }),
          keywords: ['python'],
        },
      ]
    
      static defaultBadgeData = { label: 'status' }
    
      static render({ status = '' }) {
        status = status.toLowerCase()
    
        const color = {
          planning: 'red',
          'pre-alpha': 'red',
          alpha: 'red',
          beta: 'yellow',
          stable: 'brightgreen',
          mature: 'brightgreen',
          inactive: 'red',
        }[status]
    
        return {
          message: status,
          color,
        }
      }
    
      async handle({ egg }) {
        const packageData = await this.fetch({ egg })
    
        // Possible statuses:
        // - Development Status :: 1 - Planning
        // - Development Status :: 2 - Pre-Alpha
        // - Development Status :: 3 - Alpha
        // - Development Status :: 4 - Beta
        // - Development Status :: 5 - Production/Stable
        // - Development Status :: 6 - Mature
        // - Development Status :: 7 - Inactive
        // https://pypi.org/pypi?%3Aaction=list_classifiers
        const status = parseClassifiers(
          packageData,
          /^Development Status :: (\d - \S+)$/
        )
          .sort()
          .map(classifier => classifier.split(' - ').pop())
          .map(classifier => classifier.replace(/production\/stable/i, 'stable'))
          .pop()
    
        return this.constructor.render({ status })
      }
    }