@nordicsemiconductor/nrf-jlink-js 0.0.0-alpha1 → 0.0.0-alpha3

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/dist/common.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface JLinkVariant {
9
9
  }
10
10
  export interface JLinkIndex {
11
11
  version: string;
12
- jlinkUrl: JLinkVariant;
12
+ jlinkUrls: JLinkVariant;
13
13
  }
14
14
  export declare const fetchIndex: () => Promise<JLinkIndex>;
15
15
  export declare const saveToFile: (stream: NodeJS.ReadableStream, destinationFile: string) => Promise<string>;
package/dist/common.js CHANGED
@@ -56,7 +56,7 @@ var fetchJSON = function (url) { return __awaiter(void 0, void 0, void 0, functi
56
56
  }
57
57
  });
58
58
  }); };
59
- var indexUrl = "https://files.nordicsemi.com/artifactory/swtools/external/jlink/index.json";
59
+ var indexUrl = "https://files.nordicsemi.com/artifactory/swtools/external/ncd/jlink/index.json";
60
60
  var fetchIndex = function () { return __awaiter(void 0, void 0, void 0, function () {
61
61
  var res;
62
62
  return __generator(this, function (_a) {
@@ -64,8 +64,8 @@ var fetchIndex = function () { return __awaiter(void 0, void 0, void 0, function
64
64
  case 0: return [4 /*yield*/, fetchJSON(indexUrl)];
65
65
  case 1:
66
66
  res = _a.sent();
67
- if (res == null || typeof res !== 'object' || res.version !== undefined || res.jlinkUrl !== undefined) {
68
- throw new Error('`source.json` does not have the expected content.');
67
+ if (res == null || typeof res !== 'object' || res.version === undefined || res.jlinkUrls === undefined) {
68
+ throw new Error('`index.json` does not have the expected content.');
69
69
  }
70
70
  return [2 /*return*/, res];
71
71
  }
package/dist/jlink.js CHANGED
@@ -73,9 +73,9 @@ var getInstalledJLinkVersion = function () {
73
73
  var output = data.toString();
74
74
  var versionRegExp = /DLL version (V\d+\.\d+\w*),.*/;
75
75
  var versionMatch = output.match(versionRegExp);
76
- if (versionMatch) {
76
+ if (versionMatch === null || versionMatch === void 0 ? void 0 : versionMatch[1]) {
77
77
  jlinkExeCmd.kill(9);
78
- // resolve(versionMatch[1])
78
+ resolve(versionMatch[1]);
79
79
  }
80
80
  else if (data.toString().includes("Connecting to")) {
81
81
  jlinkExeCmd.kill(9);
@@ -88,12 +88,22 @@ var getInstalledJLinkVersion = function () {
88
88
  });
89
89
  };
90
90
  var downloadJLink = function (_a, onUpdate_1) { return __awaiter(void 0, [_a, onUpdate_1], void 0, function (_b, onUpdate) {
91
- var url, _c, status, stream, destinationFile;
92
- var jlinkUrls = _b.jlinkUrl;
93
- return __generator(this, function (_d) {
94
- switch (_d.label) {
91
+ var platform, arch, url, _c, status, stream, destinationFile;
92
+ var _d;
93
+ var jlinkUrls = _b.jlinkUrls;
94
+ return __generator(this, function (_e) {
95
+ switch (_e.label) {
95
96
  case 0:
96
- url = "";
97
+ platform = os_1.default.platform();
98
+ arch = os_1.default.arch();
99
+ // @ts-expect-error It is quite literally checked right before
100
+ if (!(platform in jlinkUrls) || !(arch in jlinkUrls[platform])) {
101
+ throw new Error("JLink not available for ".concat(platform, "/").concat(arch));
102
+ }
103
+ url = (_d = jlinkUrls[platform]) === null || _d === void 0 ? void 0 : _d[arch];
104
+ if (!url) {
105
+ throw new Error("JLink not available for ".concat(platform, "/").concat(arch));
106
+ }
97
107
  return [4 /*yield*/, axios_1.default.get(url, {
98
108
  responseType: "stream",
99
109
  onDownloadProgress: function (_a) {
@@ -103,16 +113,16 @@ var downloadJLink = function (_a, onUpdate_1) { return __awaiter(void 0, [_a, on
103
113
  },
104
114
  })];
105
115
  case 1:
106
- _c = _d.sent(), status = _c.status, stream = _c.data;
116
+ _c = _e.sent(), status = _c.status, stream = _c.data;
107
117
  if (status !== 200) {
108
118
  throw new Error("Unable to download ".concat(jlinkUrls, ". Got status code ").concat(status, "."));
109
119
  }
110
120
  destinationFile = path_1.default.join(os_1.default.tmpdir(), path_1.default.basename(url));
111
121
  return [4 /*yield*/, (0, promises_1.mkdir)(path_1.default.dirname(destinationFile), { recursive: true })];
112
122
  case 2:
113
- _d.sent();
123
+ _e.sent();
114
124
  return [4 /*yield*/, (0, common_1.saveToFile)(stream, destinationFile)];
115
- case 3: return [2 /*return*/, _d.sent()];
125
+ case 3: return [2 /*return*/, _e.sent()];
116
126
  }
117
127
  });
118
128
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/nrf-jlink-js",
3
- "version": "0.0.0-alpha1",
3
+ "version": "0.0.0-alpha3",
4
4
  "main": "dist",
5
5
  "types": "dist",
6
6
  "files": [
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/NordicSemiconductor/nrf-jlink-js.git"
24
+ "url": "git+https://github.com/NordicSemiconductor/nrf-jlink-js.git"
25
25
  },
26
26
  "author": "Nordic Semiconductor ASA",
27
27
  "license": "Proprietary",