I'm trying to parse a git diff string to get all updated npm packages.
This is my regex new RegExp(/^\+\s{4}\"(.*)\":\s\"(.*)\"/gm) using with this example string:
index ab40f85..dc6d42f 100755
--- a/package.json
+++ b/package.json
@@ -1,7 +1,6 @@
{
"name": "name",
"version": "0.0.0",
"repository": {
"type": "git",
@@ -79,7 +78,7 @@
"next": "12.0.4",
"next-auth": "^3.29.0",
"next-with-apollo": "^5.2.1",
- "passport": "^0.5.0",
+ "passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"pdfkit": "^0.13.0",
@@ -113,18 +112,18 @@
"@graphql-codegen/typescript-react-apollo": "^3.2.1",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
- "@nrwl/cli": "13.2.3",
- "@nrwl/cypress": "13.2.3",
- "@nrwl/eslint-plugin-nx": "13.2.3",
- "@nrwl/jest": "13.2.3",
- "@nrwl/linter": "13.2.3",
- "@nrwl/nest": "13.2.3",
- "@nrwl/next": "13.2.3",
- "@nrwl/node": "13.2.3",
- "@nrwl/react": "13.2.3",
- "@nrwl/tao": "13.2.3",
- "@nrwl/web": "13.2.3",
- "@nrwl/workspace": "13.2.3",
+ "@nrwl/cli": "13.2.4",
+ "@nrwl/cypress": "13.2.4",
+ "@nrwl/eslint-plugin-nx": "13.2.4",
+ "@nrwl/jest": "13.2.4",
+ "@nrwl/linter": "13.2.4",
+ "@nrwl/nest": "13.2.4",
+ "@nrwl/next": "13.2.4",
+ "@nrwl/node": "13.2.4",
+ "@nrwl/react": "13.2.4",
+ "@nrwl/tao": "13.2.4",
+ "@nrwl/web": "13.2.4",
+ "@nrwl/workspace": "13.2.4",
"@testing-library/cypress": "^8.0.1",
"@testing-library/dom": "^8.11.1",
"@testing-library/jest-dom": "^5.15.0",
With the regex I should get all packages starting with an + and the groups should have the name and the version.
But running
const updated = diff.match(regex)
console.log(updated)
gives me
[
'+ "passport": "^0.4.0"',
'+ "@nrwl/cli": "13.2.4"',
'+ "@nrwl/cypress": "13.2.4"',
'+ "@nrwl/eslint-plugin-nx": "13.2.4"',
'+ "@nrwl/jest": "13.2.4"',
'+ "@nrwl/linter": "13.2.4"',
'+ "@nrwl/nest": "13.2.4"',
'+ "@nrwl/next": "13.2.4"',
'+ "@nrwl/node": "13.2.4"',
'+ "@nrwl/react": "13.2.4"',
'+ "@nrwl/tao": "13.2.4"',
'+ "@nrwl/web": "13.2.4"',
'+ "@nrwl/workspace": "13.2.4"'
]
I'm missing the group results. And I would expect only the names and the versions (without spaces, " and :) and I need both for further processing.