npm-pkgbuild 7.19.5 → 7.19.9

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": "7.19.5",
3
+ "version": "7.19.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -55,7 +55,7 @@ export class NodeModulesContentProvider extends ContentProvider {
55
55
  })) {
56
56
  if (
57
57
  !name.match(
58
- /(~|\.orig|\.log|\.tmp|\.bak|\.bat|yarn\.lock|\.DS_Store|\.travis\.yml|\.npm.*|\.git.*|rollup\.config\.(js|mjs|cjs)|readme.*\.md|\.c|\.cc|\.h|\.cmake|\.mk|\.\d)$/i
58
+ /(~|\.orig|\.log|\.tmp|\.bak|\.bat|\.gyp|yarn\.lock|\.DS_Store|\.travis\.yml|\.npm.*|\.git.*|rollup\.config\.(js|mjs|cjs)|CHANGELOG(\.md?)|HISTORY\.md|LICENSE(\-\w+|\.md)?|readme.*\.md|\.a|\.c|\.cc|\.h|Makefile|\.cmake|\.mk|\.\d)$/i
59
59
  )
60
60
  ) {
61
61
  yield Object.assign(
@@ -74,7 +74,6 @@ const toBeIgnored = [
74
74
  "*.d.ts*",
75
75
  "*.patch",
76
76
  "*.h.in",
77
- "*.gyp",
78
77
  ".jshintrc*",
79
78
  ".esl*",
80
79
  ".zuul.yml",
@@ -110,14 +109,11 @@ const toBeIgnored = [
110
109
  {
111
110
  options: { ignoreCase: true },
112
111
  pattern: [
113
- "*Makefile*",
114
112
  "CONTRIBUTING*",
115
113
  "Contributors*",
116
- "CHANGES*",
117
114
  "PATENTS*",
118
115
  "AUTHORS*",
119
116
  "NOTICE*",
120
- "HISTORY*",
121
117
  "SUMMARY.md",
122
118
  "MIGRAT*.md",
123
119
  "UPGRAD*.md",
@@ -131,8 +127,7 @@ const toBeIgnored = [
131
127
  "Porting-Buffer.md",
132
128
  "chains and topics.md",
133
129
  "CODE_OF_CONDUCT*",
134
- "CODEOWNERS",
135
- "LICENSE.DOCS*"
130
+ "CODEOWNERS"
136
131
  ]
137
132
  }
138
133
  ];
@@ -1,6 +1,7 @@
1
1
  import { join, dirname } from "path";
2
2
  import { tmpdir } from "os";
3
3
  import { mkdtemp, mkdir } from "fs/promises";
4
+ import { analysePublish } from "../publish.mjs";
4
5
 
5
6
  /**
6
7
  * @typedef {Object} Field
@@ -83,14 +84,9 @@ export class Packager {
83
84
  }
84
85
 
85
86
  if (options.publish) {
86
- const m = options.publish.match(/^([\w_\+]+):\/\/(.*)/);
87
+ const { publish, scheme } = analysePublish(options.publish, out.properties);
87
88
 
88
- if (m) {
89
- out.destination = m[1] === "file" ? m[2] : tmpdir;
90
- }
91
- else {
92
- out.destination = options.publish;
93
- }
89
+ out.destination = scheme === 'file:' ? publish : tmpdir;
94
90
 
95
91
  await mkdir(dirname(out.destination), { recursive: true });
96
92
  }
package/src/publish.mjs CHANGED
@@ -2,24 +2,30 @@ import { basename } from "path";
2
2
  import { createReadStream } from "fs";
3
3
  import fetch from "node-fetch";
4
4
 
5
- export async function publish(fileName, destination, properties) {
6
-
7
- if(!destination) {
8
- return;
9
- }
10
-
11
- destination = destination.replace(
5
+ export function analysePublish(publish, properties) {
6
+ publish = publish.replace(
12
7
  /\{\{(\w+)\}\}/m,
13
8
  (match, key, offset, string) => properties[key]
14
9
  );
15
10
 
16
- destination = destination + '/' + basename(fileName);
11
+ const m = publish.match(/^([\w_\+]+:)\/\/(.*)/);
12
+ const scheme = m ? m[0] : "file:";
17
13
 
18
- console.log(destination);
14
+ return { publish, scheme };
15
+ }
19
16
 
20
- // const m = destination.match(/^([^:]+):/);
17
+ export async function publish(fileName, destination, properties) {
18
+ if (!destination) {
19
+ return;
20
+ }
21
+
22
+ let { publish, scheme } = analysePublish(destination, properties);
21
23
 
22
- if (destination.startsWith("http://") || destination.startsWith("https://")) {
24
+ publish = publish + "/" + basename(fileName);
25
+
26
+ console.log(publish);
27
+
28
+ if (scheme === "http:" || scheme === "https:") {
23
29
  const headers = {};
24
30
 
25
31
  if (properties.username) {
@@ -28,11 +34,9 @@ export async function publish(fileName, destination, properties) {
28
34
  Buffer.from(properties.username + ":" + properties.password).toString(
29
35
  "base64"
30
36
  );
31
-
32
- console.log(headers.authorization);
33
37
  }
34
38
 
35
- const response = await fetch(destination, {
39
+ const response = await fetch(publish, {
36
40
  method: "PUT",
37
41
  headers,
38
42
  body: createReadStream(fileName)