Giter Club home page Giter Club logo

Comments (8)

JamieMason avatar JamieMason commented on May 10, 2024 1

The refactoring is now done, this feature shouldn't be too far off now.

from syncpack.

JamieMason avatar JamieMason commented on May 10, 2024

Thanks @Aghassi, I'm curious about this idea but I need to know a bit more about what you're trying to do.

It could be that the output from syncpack list-mismatches is too vague and needs improving? Or maybe you're working on some tooling so that's why you mentioned JSON? to drive that?

This sounds interesting but I need a bit more context to get up to speed, thanks a lot David.

from syncpack.

Aghassi avatar Aghassi commented on May 10, 2024

Sure thing. My current situation is I'm writing a linter for arcanist https://secure.phabricator.com/book/phabricator/article/arcanist/.

The way arcanist is structured, it passes affected files into the linter and each file is linted with actionable information provided back to the user. Each lint message contains the line in the current file as well as the character that the error is located at.
Unfortunately, this shape is different from how syncpack runs currently, which is fine. I just want a way to validate and align package.json. Ideally, it would be nice to be able to use list-mismatches to in such a way that given a path (which I can do with --source today) it returns a payload that has the line number of the affected package in the current package.json. That would be step one so that it's easier for users to know where in a given file there is a mismatched.

Here is an example of how I'm currently formatting the output for Arcanist

      // Create an array of errors splitting on a character syncpack provides
      $errors = explode("", $stdout);

      // For each error, create an error message
      foreach ($errors as $error) {
        // Report the error for each package
        $message = new ArcanistLintMessage();
        $message->setPath($path);
        $message->setName('package.json Alignment Check');
        $message->setCode($this->getLinterName());
        $message->setDescription("Error, package mismatch found: \nx $error");
        $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
        $messages[] = $message;
      }
      // Return the array of errors to be presented individually
      return $messages;

In terms of "why json", I just like JSON. No reason in particular.

from syncpack.

JamieMason avatar JamieMason commented on May 10, 2024

The library code and the CLI are separate in syncpack, so you could use it as a node module. It would be a small job to add a main entry and to make a nice API you can import from the root of the package.

A little refactoring would be needed plus it's not a nice DX right now, but you can access the core functionality like so:

const { list } = require('syncpack/dist/commands/list')

You can see the code for the CLI and Library portions of the list command as an example.

To make this more useful as a library some changes would be needed, eg. the list() function would need modifying to return an array of messages instead of writing to the console etc, but they're not huge refactors.

Let me know if something like this would work for you.

from syncpack.

Aghassi avatar Aghassi commented on May 10, 2024

I'm currently just returning from a vacation, but I'd be happy to look at this. It sounds promising!

from syncpack.

pastelsky avatar pastelsky commented on May 10, 2024

Hi, I see that the PR for this was declined. Is there still a plan to expose a Node API for this?

from syncpack.

JamieMason avatar JamieMason commented on May 10, 2024

Hey @pastelsky, eventually that would be nice but for now I have closed it because:

  1. The internals of syncpack have had huge changes, multiple times, to support new feature requests that have come in (this is the main reason). So I want to wait for things to have settled for a while before exposing this.
  2. I don't have any good use cases from anyone for what they would want and what they would use it for, nothing concrete, so it's not clear yet who would use it, what for, and what best to give them to help them do whatever that is.

So I would say Shubham that this is on a medium to long term pause, but not dead 👍🏻

EDIT: hey, you made bundlephobia.com 👏🏻 I use it all the time

from syncpack.

duytan-hoang-eurostar avatar duytan-hoang-eurostar commented on May 10, 2024

Hi @JamieMason, is an Node API still in the backlog?

I have a rather unconventional use case where I want to be able to (temporarily) set dependency package versions to * when any dependent package/s have changed version. This is only when a PR is raised (which triggers an alpha release of that package) to be tested. Once tested and all is fine, all * versions will then be updated to the exact latest version upon merging to master.

I'm aware this doesn't fully follow the goal of syncpack, which is why an exposed API where I utilise the list-mismatches to get the affected packages would be great.

So the workflow I'm looking to achieve is (monorepo project):

  • Update package-a version
  • package-a is a dep in packages:
    • package-b
    • package-d
  • Use list-mismatches and change package-a version in package-b and package-d to *
  • package-b and package-d versions will then be semver patched
  • Upon raising a PR from the monorepo of the above changes, alpha releases will be made for package-a, package-b and package-d
  • Consumer app (outside of the monorepo) can then test these changes by installing all of these alpha releases
    • Ensures there are no multiple versions of package-a, package-b and package-d installed on the consumer app
  • Once all tested and ready to be merged (from the monorepo)
    • Run fix-mismatches to replace the * versions to the exact latest versions
    • Run at some point (e.g. merge queue or merge to master)

from syncpack.

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.