@ms-cloudpack/package-hashes 0.8.25 → 0.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,16 @@
1
1
  /**
2
- * Parses a patch file name and returns the package name and version
3
- * @param filePath - The path of the patch file (e.g. `users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch`)
4
- * @returns An object with the package name and version (e.g. `{ packageName: '@fluentui/react-combobox', version: '9.5.28' }`)
2
+ * Parses a patch file path and returns the package name and version.
3
+ *
4
+ * Supported filename patterns (without the .patch suffix):
5
+ * 1. Yarn / patch-package style (scoped packages use '+'):
6
+ * @scope+pkg+1.2.3 -> @scope/pkg version: 1.2.3
7
+ * pkg+1.2.3 -> pkg
8
+ *
9
+ * 2. pnpm patch styles:
10
+ * Unscoped: pkg@1.2.3 -> pkg
11
+ * Scoped: @scope__pkg@1.2.3 -> @scope/pkg (pnpm replaces '/' with '__')
12
+ *
13
+ * @param filePath e.g. patches/@fluentui+react-combobox+9.5.28.patch or patches/@fluentui__react-combobox@0.76.15.patch
5
14
  */
6
15
  export declare function parsePatchFilePath(filePath: string): {
7
16
  packageName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"parsePatchFilePath.d.ts","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqB7F"}
1
+ {"version":3,"file":"parsePatchFilePath.d.ts","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAwC7F"}
@@ -1,23 +1,50 @@
1
1
  import path from 'path';
2
2
  /**
3
- * Parses a patch file name and returns the package name and version
4
- * @param filePath - The path of the patch file (e.g. `users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch`)
5
- * @returns An object with the package name and version (e.g. `{ packageName: '@fluentui/react-combobox', version: '9.5.28' }`)
3
+ * Parses a patch file path and returns the package name and version.
4
+ *
5
+ * Supported filename patterns (without the .patch suffix):
6
+ * 1. Yarn / patch-package style (scoped packages use '+'):
7
+ * @scope+pkg+1.2.3 -> @scope/pkg version: 1.2.3
8
+ * pkg+1.2.3 -> pkg
9
+ *
10
+ * 2. pnpm patch styles:
11
+ * Unscoped: pkg@1.2.3 -> pkg
12
+ * Scoped: @scope__pkg@1.2.3 -> @scope/pkg (pnpm replaces '/' with '__')
13
+ *
14
+ * @param filePath e.g. patches/@fluentui+react-combobox+9.5.28.patch or patches/@fluentui__react-combobox@0.76.15.patch
6
15
  */
7
16
  export function parsePatchFilePath(filePath) {
8
17
  const fileName = path.basename(filePath, '.patch');
9
- // Split the packageString based on '+'
10
- const parts = fileName.split('+');
11
- // If the parts array doesn't have the expected length throw an error
12
- if (parts.length < 2) {
13
- throw new Error(`Invalid patch file name: "${fileName}" - it should contain the package name and version separated by '+'`);
18
+ // Format 1: plus-delimited (patch-package)
19
+ if (fileName.includes('+')) {
20
+ const parts = fileName.split('+');
21
+ if (parts.length < 2) {
22
+ throw new Error(`Invalid patch file name: "${fileName}" - expected "<pkg+version>" or "<pkg@version>" format.`);
23
+ }
24
+ const version = parts.pop();
25
+ const packageName = parts.join('/'); // scoped packages reconstructed with '/'
26
+ if (!version) {
27
+ throw new Error(`Invalid patch file name: "${fileName}" - missing version segment.`);
28
+ }
29
+ return { packageName, version };
14
30
  }
15
- // Extract the package name and version
16
- const version = parts[parts.length - 1];
17
- const packageName = parts.slice(0, -1).join('/');
18
- return {
19
- packageName,
20
- version,
21
- };
31
+ // Format 2: at-delimited (pnpm style) — last '@' separates version
32
+ const atIndex = fileName.lastIndexOf('@');
33
+ if (atIndex > 0 && atIndex < fileName.length - 1) {
34
+ let packageName = fileName.slice(0, atIndex);
35
+ const version = fileName.slice(atIndex + 1);
36
+ if (!version) {
37
+ throw new Error(`Invalid patch file name: "${fileName}" - missing version after '@'.`);
38
+ }
39
+ // pnpm scoped form: @scope__pkg (translate single '__' back to '/')
40
+ if (packageName.startsWith('@') && !packageName.includes('/') && packageName.includes('__')) {
41
+ const parts = packageName.split('__');
42
+ if (parts.length === 2 && parts[0].startsWith('@') && parts[1]) {
43
+ packageName = `${parts[0]}/${parts[1]}`;
44
+ }
45
+ }
46
+ return { packageName, version };
47
+ }
48
+ throw new Error(`Invalid patch file name: "${fileName}" - expected one of:\n pkg+version.patch\n @scope+pkg+version.patch\n pkg@version.patch\n @scope__pkg@version.patch`);
22
49
  }
23
50
  //# sourceMappingURL=parsePatchFilePath.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parsePatchFilePath.js","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEnD,uCAAuC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,qEAAqE;IACrE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,6BAA6B,QAAQ,qEAAqE,CAC3G,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEjD,OAAO;QACL,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Parses a patch file name and returns the package name and version\n * @param filePath - The path of the patch file (e.g. `users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch`)\n * @returns An object with the package name and version (e.g. `{ packageName: '@fluentui/react-combobox', version: '9.5.28' }`)\n */\nexport function parsePatchFilePath(filePath: string): { packageName: string; version: string } {\n const fileName = path.basename(filePath, '.patch');\n\n // Split the packageString based on '+'\n const parts = fileName.split('+');\n\n // If the parts array doesn't have the expected length throw an error\n if (parts.length < 2) {\n throw new Error(\n `Invalid patch file name: \"${fileName}\" - it should contain the package name and version separated by '+'`,\n );\n }\n\n // Extract the package name and version\n const version = parts[parts.length - 1];\n const packageName = parts.slice(0, -1).join('/');\n\n return {\n packageName,\n version,\n };\n}\n"]}
1
+ {"version":3,"file":"parsePatchFilePath.js","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEnD,2CAA2C;IAC3C,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,yDAAyD,CAAC,CAAC;QAClH,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,yCA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AC/J,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Parses a patch file path and returns the package name and version.\n *\n * Supported filename patterns (without the .patch suffix):\n * 1. Yarn / patch-package style (scoped packages use '+'):\n * @scope+pkg+1.2.3 -> @scope/pkg version: 1.2.3\n * pkg+1.2.3 -> pkg\n *\n * 2. pnpm patch styles:\n * Unscoped: pkg@1.2.3 -> pkg\n * Scoped: @scope__pkg@1.2.3 -> @scope/pkg (pnpm replaces '/' with '__')\n *\n * @param filePath e.g. patches/@fluentui+react-combobox+9.5.28.patch or patches/@fluentui__react-combobox@0.76.15.patch\n */\nexport function parsePatchFilePath(filePath: string): { packageName: string; version: string } {\n const fileName = path.basename(filePath, '.patch');\n\n // Format 1: plus-delimited (patch-package)\n if (fileName.includes('+')) {\n const parts = fileName.split('+');\n if (parts.length < 2) {\n throw new Error(`Invalid patch file name: \"${fileName}\" - expected \"<pkg+version>\" or \"<pkg@version>\" format.`);\n }\n const version = parts.pop();\n const packageName = parts.join('/'); // scoped packages reconstructed with '/'\n if (!version) {\n throw new Error(`Invalid patch file name: \"${fileName}\" - missing version segment.`);\n }\n return { packageName, version };\n }\n\n // Format 2: at-delimited (pnpm style) — last '@' separates version\n const atIndex = fileName.lastIndexOf('@');\n if (atIndex > 0 && atIndex < fileName.length - 1) {\n let packageName = fileName.slice(0, atIndex);\n const version = fileName.slice(atIndex + 1);\n if (!version) {\n throw new Error(`Invalid patch file name: \"${fileName}\" - missing version after '@'.`);\n }\n\n // pnpm scoped form: @scope__pkg (translate single '__' back to '/')\n if (packageName.startsWith('@') && !packageName.includes('/') && packageName.includes('__')) {\n const parts = packageName.split('__');\n if (parts.length === 2 && parts[0].startsWith('@') && parts[1]) {\n packageName = `${parts[0]}/${parts[1]}`;\n }\n }\n\n return { packageName, version };\n }\n\n throw new Error(\n `Invalid patch file name: \"${fileName}\" - expected one of:\\n pkg+version.patch\\n @scope+pkg+version.patch\\n pkg@version.patch\\n @scope__pkg@version.patch`,\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-hashes",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "description": "Utilities for hashing packages.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,11 +14,11 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/common-types": "^0.27.4",
18
- "@ms-cloudpack/config": "^0.38.1",
19
- "@ms-cloudpack/package-utilities": "^12.3.25",
17
+ "@ms-cloudpack/common-types": "^0.27.6",
18
+ "@ms-cloudpack/config": "^0.38.3",
19
+ "@ms-cloudpack/package-utilities": "^12.5.0",
20
20
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
21
- "@ms-cloudpack/path-utilities": "^3.1.19",
21
+ "@ms-cloudpack/path-utilities": "^3.1.21",
22
22
  "glob-hasher": "^1.4.2",
23
23
  "object-hash": "^3.0.0",
24
24
  "tinyglobby": "^0.2.13"