Coder Social home page Coder Social logo

Comments (5)

joshbax189 avatar joshbax189 commented on June 17, 2024

I recovered the "expected" behavior with only a few small changes to search.js (marked in comments)

class Search extends BaseCommand {
// ...
  async exec (args) {
    const opts = {
      ...this.npm.flatOptions,
      ...this.npm.flatOptions.search,
      detailed: true, // NEW: request full response from search API
      include: args.map(s => s.toLowerCase()).filter(s => s),
      exclude: this.npm.flatOptions.search.exclude.split(/\s+/),
    }

    // NEW: long is not in flatOptions
    const returnLong = this.npm.config.get('long');

    if (opts.include.length === 0) {
      throw new Error('search must be called with arguments')
    }

    // Used later to figure out whether we had any packages go out
    let anyOutput = false

    class FilterStream extends Minipass {
      constructor () {
        super({ objectMode: true })
        console.log(opts);
      }

      write (pkg) {
        // NEW: pkg now contains a package prop plus extra info
        if (filter(pkg.package, opts.include, opts.exclude)) {
          // NEW: only JSON output supports extra fields
          super.write((returnLong && opts.json) ? pkg : pkg.package)
        }
      }
    }
// ... class continues
}

This would add support for --long when using --json, but not otherwise. It would be helpful to have access to the popularity and flags.insecure props from the CLI ;)

On the other hand, it would also make loads of sense to just remove the --long flag from search altogether and update the docs appropriately.

from cli.

wraithgar avatar wraithgar commented on June 17, 2024

I thing --long probably doesn't make sense anymore. It was a bandage over the real problem, which is that table output for search was not a good fit. All it ever actually did was prevent the columns from truncating, which it looks like it hasn't been doing since npm@6.

As far as adding those flags, that'd be a separate feature request. I don't thing popularity is likely to be added, but I think adding an extra line of caution if insecure is not 0 would be a great addition to the search results.

from cli.

wraithgar avatar wraithgar commented on June 17, 2024

Closing this as it's not a bug, but if someone wants to submit a PR to add something if insecure is true that would probably be an easy task.

from cli.

wraithgar avatar wraithgar commented on June 17, 2024

Reopening cause we should remove this from the params

from cli.

joshbax189 avatar joshbax189 commented on June 17, 2024

Nice job :)

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.