You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
paul-soporan commentedon Aug 11, 2020
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):
cds into ityarn init -2y(Tells Yarn 1 to initialize a new Yarn 2 project with the defaults set)pmmasks the user if they want to initialize the folder as a new Yarn 1.22.4 project (the default version set in thepmmconfig) and the user acceptspmmcallsyarn init -2yon the projectpmmbeing aware of itpmmasks Yarn for the version to pin in thepackage.jsonengines field viayarn --version(all package managers support a--versioncommand)YARN_PATHmagic yet again and answers with2.1.1pmmthen updates thepackage.json(or creates it if it doesn't already exist) to include the following part: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).This way,
pmmdoesn'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.