npm-pkgbuild 20.9.5 → 20.10.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "20.9.5",
3
+ "version": "20.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false
@@ -60,9 +60,10 @@
60
60
  "key-value-transformer": "^3.3.2",
61
61
  "npm-package-walker": "^8.0.11",
62
62
  "npm-packlist": "^11.3.0",
63
- "pacc": "^11.5.4",
63
+ "pacc": "^11.6.0",
64
64
  "package-directory": "^8.2.0",
65
65
  "pacote": "^22.0.0",
66
+ "picomatch": "^4.0.7",
66
67
  "tar-stream": "^3.1.7",
67
68
  "uti": "^8.11.3"
68
69
  },
@@ -1,3 +1,4 @@
1
+ import picomatch from "picomatch";
1
2
  import { ContentEntry, CollectionEntry } from "content-entry";
2
3
 
3
4
  /**
@@ -30,6 +31,13 @@ export class ContentProvider {
30
31
  destination: this.entryProperties?.destination
31
32
  };
32
33
  }
34
+
35
+ this.permissions = new Map(
36
+ Object.entries(this.properties).map(([pattern, properties]) => [
37
+ picomatch(pattern),
38
+ properties
39
+ ])
40
+ );
33
41
  }
34
42
 
35
43
  /**
@@ -39,23 +47,11 @@ export class ContentProvider {
39
47
  * @returns {Object|undefined}
40
48
  */
41
49
  propertiesFor(name, isCollection) {
42
- for (const [pattern, properties] of Object.entries(this.properties)) {
43
- if (pattern === name) {
44
- return properties;
45
- }
46
- if (pattern.endsWith("**/*")) {
47
- const prefix = pattern.substring(0, pattern.length - 4);
48
- if (name.startsWith(prefix)) {
49
- return properties;
50
- }
51
- }
52
- if (pattern.endsWith("*")) {
53
- const prefix = pattern.substring(0, pattern.length - 1);
54
- if (name.startsWith(prefix)) {
55
- if (name.substring(prefix.length).indexOf("/") < 0) {
56
- return properties;
57
- }
58
- }
50
+ for (const [matcher, properties] of this.permissions) {
51
+ if (matcher(name)) {
52
+ return isCollection && properties.collection
53
+ ? properties.collection
54
+ : properties;
59
55
  }
60
56
  }
61
57