@napi-rs/cli 3.0.0-alpha.65 → 3.0.0-alpha.66

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.
Files changed (2) hide show
  1. package/dist/index.cjs +126 -20
  2. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,13 +30,109 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // ../node_modules/fast-content-type-parse/index.js
34
+ var require_fast_content_type_parse = __commonJS({
35
+ "../node_modules/fast-content-type-parse/index.js"(exports2, module2) {
36
+ "use strict";
37
+ var NullObject = function NullObject2() {
38
+ };
39
+ NullObject.prototype = /* @__PURE__ */ Object.create(null);
40
+ var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
41
+ var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
42
+ var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u;
43
+ var defaultContentType = { type: "", parameters: new NullObject() };
44
+ Object.freeze(defaultContentType.parameters);
45
+ Object.freeze(defaultContentType);
46
+ function parse5(header) {
47
+ if (typeof header !== "string") {
48
+ throw new TypeError("argument header is required and must be a string");
49
+ }
50
+ let index = header.indexOf(";");
51
+ const type = index !== -1 ? header.slice(0, index).trim() : header.trim();
52
+ if (mediaTypeRE.test(type) === false) {
53
+ throw new TypeError("invalid media type");
54
+ }
55
+ const result = {
56
+ type: type.toLowerCase(),
57
+ parameters: new NullObject()
58
+ };
59
+ if (index === -1) {
60
+ return result;
61
+ }
62
+ let key;
63
+ let match;
64
+ let value;
65
+ paramRE.lastIndex = index;
66
+ while (match = paramRE.exec(header)) {
67
+ if (match.index !== index) {
68
+ throw new TypeError("invalid parameter format");
69
+ }
70
+ index += match[0].length;
71
+ key = match[1].toLowerCase();
72
+ value = match[2];
73
+ if (value[0] === '"') {
74
+ value = value.slice(1, value.length - 1);
75
+ quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
76
+ }
77
+ result.parameters[key] = value;
78
+ }
79
+ if (index !== header.length) {
80
+ throw new TypeError("invalid parameter format");
81
+ }
82
+ return result;
83
+ }
84
+ function safeParse2(header) {
85
+ if (typeof header !== "string") {
86
+ return defaultContentType;
87
+ }
88
+ let index = header.indexOf(";");
89
+ const type = index !== -1 ? header.slice(0, index).trim() : header.trim();
90
+ if (mediaTypeRE.test(type) === false) {
91
+ return defaultContentType;
92
+ }
93
+ const result = {
94
+ type: type.toLowerCase(),
95
+ parameters: new NullObject()
96
+ };
97
+ if (index === -1) {
98
+ return result;
99
+ }
100
+ let key;
101
+ let match;
102
+ let value;
103
+ paramRE.lastIndex = index;
104
+ while (match = paramRE.exec(header)) {
105
+ if (match.index !== index) {
106
+ return defaultContentType;
107
+ }
108
+ index += match[0].length;
109
+ key = match[1].toLowerCase();
110
+ value = match[2];
111
+ if (value[0] === '"') {
112
+ value = value.slice(1, value.length - 1);
113
+ quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
114
+ }
115
+ result.parameters[key] = value;
116
+ }
117
+ if (index !== header.length) {
118
+ return defaultContentType;
119
+ }
120
+ return result;
121
+ }
122
+ module2.exports.default = { parse: parse5, safeParse: safeParse2 };
123
+ module2.exports.parse = parse5;
124
+ module2.exports.safeParse = safeParse2;
125
+ module2.exports.defaultContentType = defaultContentType;
126
+ }
127
+ });
128
+
30
129
  // dist/index.js
31
- var dist_exports = {};
32
- __export(dist_exports, {
130
+ var index_exports = {};
131
+ __export(index_exports, {
33
132
  NapiCli: () => NapiCli,
34
133
  parseTriple: () => parseTriple
35
134
  });
36
- module.exports = __toCommonJS(dist_exports);
135
+ module.exports = __toCommonJS(index_exports);
37
136
 
38
137
  // dist/api/artifacts.js
39
138
  var import_node_path = require("node:path");
@@ -5640,13 +5739,10 @@ function lowercaseKeys(object) {
5640
5739
  }, {});
5641
5740
  }
5642
5741
  function isPlainObject2(value) {
5643
- if (typeof value !== "object" || value === null)
5644
- return false;
5645
- if (Object.prototype.toString.call(value) !== "[object Object]")
5646
- return false;
5742
+ if (typeof value !== "object" || value === null) return false;
5743
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
5647
5744
  const proto = Object.getPrototypeOf(value);
5648
- if (proto === null)
5649
- return true;
5745
+ if (proto === null) return true;
5650
5746
  const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
5651
5747
  return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
5652
5748
  }
@@ -5654,10 +5750,8 @@ function mergeDeep(defaults, options) {
5654
5750
  const result = Object.assign({}, defaults);
5655
5751
  Object.keys(options).forEach((key) => {
5656
5752
  if (isPlainObject2(options[key])) {
5657
- if (!(key in defaults))
5658
- Object.assign(result, { [key]: options[key] });
5659
- else
5660
- result[key] = mergeDeep(defaults[key], options[key]);
5753
+ if (!(key in defaults)) Object.assign(result, { [key]: options[key] });
5754
+ else result[key] = mergeDeep(defaults[key], options[key]);
5661
5755
  } else {
5662
5756
  Object.assign(result, { [key]: options[key] });
5663
5757
  }
@@ -5934,6 +6028,9 @@ function withDefaults(oldDefaults, newDefaults) {
5934
6028
  }
5935
6029
  var endpoint = withDefaults(null, DEFAULTS);
5936
6030
 
6031
+ // ../node_modules/@octokit/rest/node_modules/@octokit/request/dist-bundle/index.js
6032
+ var import_fast_content_type_parse = __toESM(require_fast_content_type_parse(), 1);
6033
+
5937
6034
  // ../node_modules/@octokit/rest/node_modules/@octokit/request-error/dist-src/index.js
5938
6035
  var RequestError = class extends Error {
5939
6036
  name;
@@ -6088,13 +6185,23 @@ async function fetchWrapper(requestOptions) {
6088
6185
  }
6089
6186
  async function getResponseData(response) {
6090
6187
  const contentType = response.headers.get("content-type");
6091
- if (/application\/json/.test(contentType)) {
6092
- return response.json().catch(() => response.text()).catch(() => "");
6188
+ if (!contentType) {
6189
+ return response.text().catch(() => "");
6093
6190
  }
6094
- if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
6095
- return response.text();
6191
+ const mimetype = (0, import_fast_content_type_parse.safeParse)(contentType);
6192
+ if (mimetype.type === "application/json") {
6193
+ let text = "";
6194
+ try {
6195
+ text = await response.text();
6196
+ return JSON.parse(text);
6197
+ } catch (err) {
6198
+ return text;
6199
+ }
6200
+ } else if (mimetype.type.startsWith("text/") || mimetype.parameters.charset?.toLowerCase() === "utf-8") {
6201
+ return response.text().catch(() => "");
6202
+ } else {
6203
+ return response.arrayBuffer().catch(() => new ArrayBuffer(0));
6096
6204
  }
6097
- return response.arrayBuffer();
6098
6205
  }
6099
6206
  function toErrorMessage(data) {
6100
6207
  if (typeof data === "string") {
@@ -6175,8 +6282,7 @@ function graphql(request2, query, options) {
6175
6282
  );
6176
6283
  }
6177
6284
  for (const key in options) {
6178
- if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
6179
- continue;
6285
+ if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;
6180
6286
  return Promise.reject(
6181
6287
  new Error(
6182
6288
  `[@octokit/graphql] "${key}" cannot be used as variable name`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/cli",
3
- "version": "3.0.0-alpha.65",
3
+ "version": "3.0.0-alpha.66",
4
4
  "description": "Cli tools for napi-rs",
5
5
  "author": "LongYinan <lynweklm@gmail.com>",
6
6
  "homepage": "https://github.com/napi-rs/napi-rs",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@inquirer/prompts": "^7.0.0",
71
- "@napi-rs/cross-toolchain": "^0.0.16",
71
+ "@napi-rs/cross-toolchain": "^0.0.17",
72
72
  "@napi-rs/wasm-tools": "^0.0.2",
73
73
  "@octokit/rest": "^21.0.2",
74
74
  "clipanion": "^3.2.1",
@@ -129,5 +129,5 @@
129
129
  "**/__tests__/**/*.spec.ts"
130
130
  ]
131
131
  },
132
- "gitHead": "d23290f9c18134165a2100dcaa90fa6a7c6ec3f5"
132
+ "gitHead": "c796918787091b17f22e772861af62a5d3d08bd5"
133
133
  }