Skip to content

Init workflow #2

Closed
Closed

Description

@arcanis

This thread is meant to discuss the init workflow. For example, what happens when running yarn init or npm init? Under the current model those commands will fail, because pmm is implemented in such a way that the package.json is created before spawning the process, which will then detect the preexisting manifest and refuse to update it.

Activity

  1. paul-soporan commented on Aug 11, 2020

    @paul-soporan
    Contributor

    The way I see it (I'll use a more complicated example with Yarn's update-on-init workflow in mind. It would also apply for workflows without this part):

    • User creates a new folder and cds into it
    • User runs yarn init -2y (Tells Yarn 1 to initialize a new Yarn 2 project with the defaults set)
    • pmm asks the user if they want to initialize the folder as a new Yarn 1.22.4 project (the default version set in the pmm config) and the user accepts
    • pmm calls yarn init -2y on the project
    • Yarn does its init and update magic without pmm being aware of it
    • pmm asks Yarn for the version to pin in the package.json engines field via yarn --version (all package managers support a --version command)
    • Yarn does its YARN_PATH magic yet again and answers with 2.1.1
    • pmm then updates the package.json (or creates it if it doesn't already exist) to include the following part:
    "engines": {
      "pm": "yarn@2.1.1"
    },

    Note the fact that the range would be exact, not caret, since many things can change between versions (Example: Fixing a bug which affects Yarn's archive generation - it would update the checksums of all affected archives and it would not be consistent between versions).

    • Now the project is pinned to Yarn 2.1.1, so no other package manager / Yarn version can be used here.

    This way, pmm doesn't lie to the user when asking if they want to init a new Yarn 1.22.4 project, it's just that Yarn 1.22.4 updates itself on init when using a specific flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions