Skip to content

@pnpm/lockfile-types: add new versions#4521

Draft
milahu wants to merge 17 commits into
pnpm:mainfrom
milahu:fix-lockfile-types-add-new-versions
Draft

@pnpm/lockfile-types: add new versions#4521
milahu wants to merge 17 commits into
pnpm:mainfrom
milahu:fix-lockfile-types-add-new-versions

Conversation

@milahu

@milahu milahu commented Apr 2, 2022

Copy link
Copy Markdown
Contributor

fix #4517

i opted to include old versions in src/version/*.ts
as some consumers may neeed them
and this is easier than installing many different versions of the @pnpm/lockfile-types package
one src/version/*.ts file has just 3000 bytes, so ... the space-overhead is acceptable

the additional exports are useful for tools like ts-json-schema-generator
which take a *.ts file and a tsconfig.json file, and generate a schema validator
see validate-lockfile.mjs in #4517

todo: add more old versions, at least between 5 and 5.3

todo: tests. maybe use the existing tests to generate lockfiles
then use these valid lockfiles to validate the lockfile-types.
these tests are time-consuming so they would run manually.
todo: what pnpm-version generates what lockfile-version?
LOCKFILE_VERSION in packages/constants/src/index.ts

edit: version map: https://github.com/pnpm/spec/tree/master/lockfile

version map
  • 5.3 since 6871d74 = v6.0.0 = 2021-02-25
  • 5.2 since fcdad63 = v5.10.0 = 2020-10-19
  • 5.1 since ac684d0 = v3.5.0 = 2019-06-08
    • renamed to LOCKFILE_VERSION in 5489e8c. old name: SHRINKWRAP_VERSION
    • renamed to pnpm-lock.yaml in 856536b. old name: shrinkwrap.yaml
  • 5 since 41b6f6b = v3.0.0 = 2019-03-02. requires node 10. node 12: TypeError: cb.apply is not a function
    • moved to packages/constants/src/index.ts in 41b6f6b. old file: packages/prune-shrinkwrap/src/constants.ts
    • v2.25.7 = 2019-03-05 gives shrinkwrapVersion: 3 and shrinkwrapMinorVersion: 9
  • 4 was never used?
  • 3.9 since 2.13.3
  • 3.8 since 2.8.0
  • 3.7 since 2.0.0
  • ...
  • 3 since 4198da2 or older = v2.21.0 = 2018-12-06

todo: make the src/version/*.ts files available in the published package
maybe just add src to the files array in package.json?

  "files": [
    "lib",
    "src",
    "!*.map"
  ],

@milahu milahu force-pushed the fix-lockfile-types-add-new-versions branch from f0fed07 to 9150983 Compare April 2, 2022 10:22
@zkochan

zkochan commented Apr 2, 2022

Copy link
Copy Markdown
Member

The versions are documented here: https://github.com/pnpm/spec/tree/master/lockfile

But I am not sure why you need this. We only support the two last major versions of pnpm. And including two versions of lockfile-types is not hard using aliases.

@milahu

milahu commented Apr 2, 2022

Copy link
Copy Markdown
Contributor Author

not sure why you need this

to write a pnpm lockfile parser for snyk/nodejs-lockfile-parser#111
i need the typescript types to generate a schema validator
(and to write the parser in typescript)

ideally the parser should support multiple lockfile versions
no need to support all versions, but a range from 5.0 would be nice

the alternative to maintaining multiple src/version/*.ts files in parallel:
updates and release @pnpm/lockfile-types for every lockfile-version
problem: to fix bugs in an old versions, we would need git branches

@pnpm/lockfile-types is used only by pnpm
and its a devDependency, so no need to optimize for bundle size

@zkochan

zkochan commented Apr 3, 2022

Copy link
Copy Markdown
Member

ok

@GustavEikaas

Copy link
Copy Markdown

Is this dead? Can I help in any way?

@milahu

milahu commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

this has low priority for me, so practically its abandoned

if you need this, feel free to continue

my devloop was something like

here are 150 MB of pnpm lockfiles: scrape-pnpm-lockfiles

there is some related work in nodejs-lockfile-parser/parse-pnpm-lockfiles
but to add pnpm support to nodejs-lockfile-parser, its probably simpler to use @pnpm/lockfile-walker as suggested in snyk/nodejs-lockfile-parser#111 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@pnpm/lockfile-types is outdated

3 participants