@nordicsemiconductor/nrf-jlink-js 0.0.5 → 0.0.6
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/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/jlink.d.ts +1 -0
- package/dist/jlink.js +41 -56
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { downloadAndInstallJLink, getVersionToInstall, downloadAndSaveJLink } from './jlink';
|
|
2
|
-
export { downloadAndInstallJLink, getVersionToInstall, downloadAndSaveJLink };
|
|
1
|
+
import { downloadAndInstallJLink, getVersionToInstall, downloadAndSaveJLink, installJLink } from './jlink';
|
|
2
|
+
export { downloadAndInstallJLink, getVersionToInstall, downloadAndSaveJLink, installJLink };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadAndSaveJLink = exports.getVersionToInstall = exports.downloadAndInstallJLink = void 0;
|
|
3
|
+
exports.installJLink = exports.downloadAndSaveJLink = exports.getVersionToInstall = exports.downloadAndInstallJLink = void 0;
|
|
4
4
|
var jlink_1 = require("./jlink");
|
|
5
5
|
Object.defineProperty(exports, "downloadAndInstallJLink", { enumerable: true, get: function () { return jlink_1.downloadAndInstallJLink; } });
|
|
6
6
|
Object.defineProperty(exports, "getVersionToInstall", { enumerable: true, get: function () { return jlink_1.getVersionToInstall; } });
|
|
7
7
|
Object.defineProperty(exports, "downloadAndSaveJLink", { enumerable: true, get: function () { return jlink_1.downloadAndSaveJLink; } });
|
|
8
|
+
Object.defineProperty(exports, "installJLink", { enumerable: true, get: function () { return jlink_1.installJLink; } });
|
package/dist/jlink.d.ts
CHANGED
package/dist/jlink.js
CHANGED
|
@@ -35,20 +35,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
40
|
};
|
|
50
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.downloadAndInstallJLink = exports.downloadAndSaveJLink = exports.getVersionToInstall = void 0;
|
|
42
|
+
exports.downloadAndInstallJLink = exports.downloadAndSaveJLink = exports.getVersionToInstall = exports.installJLink = void 0;
|
|
52
43
|
var child_process_1 = require("child_process");
|
|
53
44
|
var os_1 = __importDefault(require("os"));
|
|
54
45
|
var path_1 = __importDefault(require("path"));
|
|
@@ -112,52 +103,45 @@ var getInstalledJLinkVersion = function () {
|
|
|
112
103
|
});
|
|
113
104
|
});
|
|
114
105
|
};
|
|
115
|
-
var downloadJLink = function (_a, onUpdate_1) {
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (status !== 200) {
|
|
153
|
-
throw new Error("Unable to download ".concat(url, ". Got status code ").concat(status, "."));
|
|
154
|
-
}
|
|
155
|
-
return [4 /*yield*/, (0, common_1.saveToFile)(stream, path_1.default.join(destinationPath, path_1.default.basename(url)))];
|
|
156
|
-
case 2: return [2 /*return*/, _e.sent()];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
106
|
+
var downloadJLink = function (_a, onUpdate_1, destinationFilePath_1) { return __awaiter(void 0, [_a, onUpdate_1, destinationFilePath_1], void 0, function (_b, onUpdate, destinationFilePath) {
|
|
107
|
+
var platform, arch, url, _c, status, stream;
|
|
108
|
+
var _d;
|
|
109
|
+
var jlinkUrls = _b.jlinkUrls;
|
|
110
|
+
return __generator(this, function (_e) {
|
|
111
|
+
switch (_e.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
platform = os_1.default.platform();
|
|
114
|
+
arch = os_1.default.arch();
|
|
115
|
+
// @ts-expect-error It is quite literally checked right before
|
|
116
|
+
if (!(platform in jlinkUrls) || !(arch in jlinkUrls[platform])) {
|
|
117
|
+
throw new Error("JLink not available for ".concat(platform, "/").concat(arch));
|
|
118
|
+
}
|
|
119
|
+
url = (_d = jlinkUrls[platform]) === null || _d === void 0 ? void 0 : _d[arch];
|
|
120
|
+
if (!url) {
|
|
121
|
+
throw new Error("JLink not available for ".concat(platform, "/").concat(arch));
|
|
122
|
+
}
|
|
123
|
+
return [4 /*yield*/, axios_1.default.get(url, {
|
|
124
|
+
responseType: 'stream',
|
|
125
|
+
onDownloadProgress: function (_a) {
|
|
126
|
+
var loaded = _a.loaded, total = _a.total;
|
|
127
|
+
return loaded &&
|
|
128
|
+
total &&
|
|
129
|
+
(onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({
|
|
130
|
+
step: 'download',
|
|
131
|
+
percentage: Number(((loaded / total) * 100).toFixed(2)),
|
|
132
|
+
}));
|
|
133
|
+
},
|
|
134
|
+
})];
|
|
135
|
+
case 1:
|
|
136
|
+
_c = _e.sent(), status = _c.status, stream = _c.data;
|
|
137
|
+
if (status !== 200) {
|
|
138
|
+
throw new Error("Unable to download ".concat(url, ". Got status code ").concat(status, "."));
|
|
139
|
+
}
|
|
140
|
+
return [4 /*yield*/, (0, common_1.saveToFile)(stream, destinationFilePath || path_1.default.join(os_1.default.tmpdir(), path_1.default.basename(url)))];
|
|
141
|
+
case 2: return [2 /*return*/, _e.sent()];
|
|
142
|
+
}
|
|
159
143
|
});
|
|
160
|
-
};
|
|
144
|
+
}); };
|
|
161
145
|
var installJLink = function (installerPath, onUpdate) {
|
|
162
146
|
var command;
|
|
163
147
|
var args;
|
|
@@ -190,6 +174,7 @@ var installJLink = function (installerPath, onUpdate) {
|
|
|
190
174
|
});
|
|
191
175
|
});
|
|
192
176
|
};
|
|
177
|
+
exports.installJLink = installJLink;
|
|
193
178
|
var convertToSemverVersion = function (version) {
|
|
194
179
|
var _a;
|
|
195
180
|
var _b = (_a = version.match(/V?(\d+\.\d+)(.)?/)) !== null && _a !== void 0 ? _a : [], majorMinor = _b[1], patchLetter = _b[2];
|
|
@@ -233,6 +218,6 @@ exports.downloadAndSaveJLink = downloadAndSaveJLink;
|
|
|
233
218
|
var downloadAndInstallJLink = function (onUpdate) {
|
|
234
219
|
return (0, common_1.fetchIndex)()
|
|
235
220
|
.then(function (v) { return downloadJLink(v, onUpdate); })
|
|
236
|
-
.then(function (v) { return installJLink(v, onUpdate); });
|
|
221
|
+
.then(function (v) { return (0, exports.installJLink)(v, onUpdate); });
|
|
237
222
|
};
|
|
238
223
|
exports.downloadAndInstallJLink = downloadAndInstallJLink;
|