@solana-mobile/dapp-store-cli 0.16.0 → 0.16.1
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/bin/dapp-store.js +3 -1
- package/lib/CliSetup.js +304 -505
- package/lib/CliUtils.js +6 -376
- package/lib/__tests__/CliSetupTest.js +484 -74
- package/lib/cli/__tests__/parseErrors.test.js +25 -0
- package/lib/cli/__tests__/signer.test.js +436 -0
- package/lib/cli/constants.js +23 -0
- package/lib/cli/messages.js +21 -0
- package/lib/cli/parseErrors.js +41 -0
- package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
- package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
- package/lib/index.js +96 -5
- package/lib/package.json +5 -24
- package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
- package/lib/portal/__tests__/translators.test.js +76 -0
- package/lib/portal/__tests__/workflowClient.test.js +457 -0
- package/lib/portal/attestationClient.js +143 -0
- package/lib/portal/files.js +64 -0
- package/lib/portal/http.js +364 -0
- package/lib/portal/records.js +64 -0
- package/lib/portal/releaseMetadata.js +748 -0
- package/lib/portal/translators.js +460 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflowClient.js +704 -0
- package/lib/publication/PublicationProgressReporter.js +1051 -0
- package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
- package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
- package/lib/publication/__tests__/publicationSummary.test.js +26 -0
- package/lib/publication/cliValidation.js +482 -0
- package/lib/publication/fundingPreflight.js +246 -0
- package/lib/publication/publicationSummary.js +99 -0
- package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
- package/package.json +5 -24
- package/src/CliSetup.ts +370 -505
- package/src/CliUtils.ts +9 -233
- package/src/__tests__/CliSetupTest.ts +272 -120
- package/src/cli/__tests__/parseErrors.test.ts +34 -0
- package/src/cli/__tests__/signer.test.ts +359 -0
- package/src/cli/constants.ts +3 -0
- package/src/cli/messages.ts +27 -0
- package/src/cli/parseErrors.ts +62 -0
- package/src/cli/selfUpdate.ts +59 -0
- package/src/cli/signer.ts +38 -0
- package/src/index.ts +31 -4
- package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
- package/src/portal/__tests__/translators.test.ts +82 -0
- package/src/portal/__tests__/workflowClient.test.ts +278 -0
- package/src/portal/attestationClient.ts +19 -0
- package/src/portal/files.ts +73 -0
- package/src/portal/http.ts +170 -0
- package/src/portal/records.ts +38 -0
- package/src/portal/releaseMetadata.ts +489 -0
- package/src/portal/translators.ts +750 -0
- package/src/portal/types.ts +27 -0
- package/src/portal/workflowClient.ts +575 -0
- package/src/publication/PublicationProgressReporter.ts +1026 -0
- package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
- package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
- package/src/publication/__tests__/publicationSummary.test.ts +30 -0
- package/src/publication/cliValidation.ts +264 -0
- package/src/publication/fundingPreflight.ts +123 -0
- package/src/publication/publicationSummary.ts +26 -0
- package/src/publication/runPublicationWorkflow.ts +46 -0
- package/lib/commands/create/CreateCliApp.js +0 -223
- package/lib/commands/create/CreateCliRelease.js +0 -290
- package/lib/commands/create/index.js +0 -40
- package/lib/commands/index.js +0 -3
- package/lib/commands/publish/PublishCliSubmit.js +0 -208
- package/lib/commands/publish/PublishCliUpdate.js +0 -211
- package/lib/commands/publish/index.js +0 -22
- package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
- package/lib/commands/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +0 -59
- package/lib/config/PublishDetails.js +0 -915
- package/lib/config/S3StorageManager.js +0 -93
- package/lib/config/index.js +0 -2
- package/lib/generated/config_obj.json +0 -1
- package/lib/generated/config_schema.json +0 -1
- package/lib/prebuild_schema/publishing_source.yaml +0 -64
- package/lib/prebuild_schema/schemagen.js +0 -25
- package/lib/upload/CachedStorageDriver.js +0 -458
- package/lib/upload/TurboStorageDriver.js +0 -718
- package/lib/upload/__tests__/CachedStorageDriver.test.js +0 -437
- package/lib/upload/__tests__/TurboStorageDriver.test.js +0 -17
- package/lib/upload/__tests__/contentGateway.test.js +0 -17
- package/lib/upload/contentGateway.js +0 -23
- package/lib/upload/index.js +0 -2
- package/src/commands/ValidateCommand.ts +0 -82
- package/src/commands/create/CreateCliApp.ts +0 -93
- package/src/commands/create/CreateCliRelease.ts +0 -149
- package/src/commands/create/index.ts +0 -47
- package/src/commands/index.ts +0 -3
- package/src/commands/publish/PublishCliRemove.ts +0 -66
- package/src/commands/publish/PublishCliSubmit.ts +0 -93
- package/src/commands/publish/PublishCliSupport.ts +0 -66
- package/src/commands/publish/PublishCliUpdate.ts +0 -101
- package/src/commands/publish/index.ts +0 -29
- package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
- package/src/commands/scaffolding/index.ts +0 -1
- package/src/commands/utils.ts +0 -33
- package/src/config/EnvVariables.ts +0 -39
- package/src/config/PublishDetails.ts +0 -456
- package/src/config/S3StorageManager.ts +0 -47
- package/src/config/index.ts +0 -2
- package/src/prebuild_schema/publishing_source.yaml +0 -64
- package/src/prebuild_schema/schemagen.js +0 -31
- package/src/upload/CachedStorageDriver.ts +0 -179
- package/src/upload/TurboStorageDriver.ts +0 -283
- package/src/upload/__tests__/CachedStorageDriver.test.ts +0 -246
- package/src/upload/__tests__/TurboStorageDriver.test.ts +0 -15
- package/src/upload/__tests__/contentGateway.test.ts +0 -31
- package/src/upload/contentGateway.ts +0 -37
- package/src/upload/index.ts +0 -2
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _async_iterator(iterable) {
|
|
10
|
+
var method, async, sync, retry = 2;
|
|
11
|
+
for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
|
|
12
|
+
if (async && null != (method = iterable[async])) return method.call(iterable);
|
|
13
|
+
if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
|
|
14
|
+
async = "@@asyncIterator", sync = "@@iterator";
|
|
15
|
+
}
|
|
16
|
+
throw new TypeError("Object is not async iterable");
|
|
17
|
+
}
|
|
18
|
+
function AsyncFromSyncIterator(s) {
|
|
19
|
+
function AsyncFromSyncIteratorContinuation(r) {
|
|
20
|
+
if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
|
|
21
|
+
var done = r.done;
|
|
22
|
+
return Promise.resolve(r.value).then(function(value) {
|
|
23
|
+
return {
|
|
24
|
+
value: value,
|
|
25
|
+
done: done
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return AsyncFromSyncIterator = function(s) {
|
|
30
|
+
this.s = s, this.n = s.next;
|
|
31
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
32
|
+
s: null,
|
|
33
|
+
n: null,
|
|
34
|
+
next: function() {
|
|
35
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
36
|
+
},
|
|
37
|
+
return: function(value) {
|
|
38
|
+
var ret = this.s.return;
|
|
39
|
+
return void 0 === ret ? Promise.resolve({
|
|
40
|
+
value: value,
|
|
41
|
+
done: !0
|
|
42
|
+
}) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
|
|
43
|
+
},
|
|
44
|
+
throw: function(value) {
|
|
45
|
+
var thr = this.s.return;
|
|
46
|
+
return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
|
|
47
|
+
}
|
|
48
|
+
}, new AsyncFromSyncIterator(s);
|
|
49
|
+
}
|
|
50
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
51
|
+
try {
|
|
52
|
+
var info = gen[key](arg);
|
|
53
|
+
var value = info.value;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
reject(error);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (info.done) {
|
|
59
|
+
resolve(value);
|
|
60
|
+
} else {
|
|
61
|
+
Promise.resolve(value).then(_next, _throw);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function _async_to_generator(fn) {
|
|
65
|
+
return function() {
|
|
66
|
+
var self = this, args = arguments;
|
|
67
|
+
return new Promise(function(resolve, reject) {
|
|
68
|
+
var gen = fn.apply(self, args);
|
|
69
|
+
function _next(value) {
|
|
70
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
71
|
+
}
|
|
72
|
+
function _throw(err) {
|
|
73
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
74
|
+
}
|
|
75
|
+
_next(undefined);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function _iterable_to_array_limit(arr, i) {
|
|
80
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
81
|
+
if (_i == null) return;
|
|
82
|
+
var _arr = [];
|
|
83
|
+
var _n = true;
|
|
84
|
+
var _d = false;
|
|
85
|
+
var _s, _e;
|
|
86
|
+
try {
|
|
87
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
88
|
+
_arr.push(_s.value);
|
|
89
|
+
if (i && _arr.length === i) break;
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
_d = true;
|
|
93
|
+
_e = err;
|
|
94
|
+
} finally{
|
|
95
|
+
try {
|
|
96
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
97
|
+
} finally{
|
|
98
|
+
if (_d) throw _e;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return _arr;
|
|
102
|
+
}
|
|
103
|
+
function _non_iterable_rest() {
|
|
104
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
105
|
+
}
|
|
106
|
+
function _sliced_to_array(arr, i) {
|
|
107
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
108
|
+
}
|
|
109
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
110
|
+
if (!o) return;
|
|
111
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
112
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
113
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
114
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
115
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
116
|
+
}
|
|
117
|
+
function _ts_generator(thisArg, body) {
|
|
118
|
+
var f, y, t, _ = {
|
|
119
|
+
label: 0,
|
|
120
|
+
sent: function() {
|
|
121
|
+
if (t[0] & 1) throw t[1];
|
|
122
|
+
return t[1];
|
|
123
|
+
},
|
|
124
|
+
trys: [],
|
|
125
|
+
ops: []
|
|
126
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
127
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
128
|
+
return this;
|
|
129
|
+
}), g;
|
|
130
|
+
function verb(n) {
|
|
131
|
+
return function(v) {
|
|
132
|
+
return step([
|
|
133
|
+
n,
|
|
134
|
+
v
|
|
135
|
+
]);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function step(op) {
|
|
139
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
140
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
141
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
142
|
+
if (y = 0, t) op = [
|
|
143
|
+
op[0] & 2,
|
|
144
|
+
t.value
|
|
145
|
+
];
|
|
146
|
+
switch(op[0]){
|
|
147
|
+
case 0:
|
|
148
|
+
case 1:
|
|
149
|
+
t = op;
|
|
150
|
+
break;
|
|
151
|
+
case 4:
|
|
152
|
+
_.label++;
|
|
153
|
+
return {
|
|
154
|
+
value: op[1],
|
|
155
|
+
done: false
|
|
156
|
+
};
|
|
157
|
+
case 5:
|
|
158
|
+
_.label++;
|
|
159
|
+
y = op[1];
|
|
160
|
+
op = [
|
|
161
|
+
0
|
|
162
|
+
];
|
|
163
|
+
continue;
|
|
164
|
+
case 7:
|
|
165
|
+
op = _.ops.pop();
|
|
166
|
+
_.trys.pop();
|
|
167
|
+
continue;
|
|
168
|
+
default:
|
|
169
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
170
|
+
_ = 0;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
174
|
+
_.label = op[1];
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
178
|
+
_.label = t[1];
|
|
179
|
+
t = op;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (t && _.label < t[2]) {
|
|
183
|
+
_.label = t[2];
|
|
184
|
+
_.ops.push(op);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
if (t[2]) _.ops.pop();
|
|
188
|
+
_.trys.pop();
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
op = body.call(thisArg, _);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
op = [
|
|
194
|
+
6,
|
|
195
|
+
e
|
|
196
|
+
];
|
|
197
|
+
y = 0;
|
|
198
|
+
} finally{
|
|
199
|
+
f = t = 0;
|
|
200
|
+
}
|
|
201
|
+
if (op[0] & 5) throw op[1];
|
|
202
|
+
return {
|
|
203
|
+
value: op[0] ? op[1] : void 0,
|
|
204
|
+
done: true
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
import fs from "node:fs";
|
|
209
|
+
import path from "node:path";
|
|
210
|
+
export var DEFAULT_LOCAL_PORTAL_URL = "http://localhost:3333";
|
|
211
|
+
export var DEFAULT_PRODUCTION_PORTAL_URL = "https://publish.solanamobile.com";
|
|
212
|
+
export var DEFAULT_API_KEY_ENV = "DAPP_STORE_API_KEY";
|
|
213
|
+
export var UPDATED_PUBLISHING_CLI_DOCS_URL = "https://docs.solanamobile.com/dapp-store/publishing-cli";
|
|
214
|
+
function normalizeUrl(value, label) {
|
|
215
|
+
try {
|
|
216
|
+
return new URL(value).toString().replace(/\/$/, "");
|
|
217
|
+
} catch (e) {
|
|
218
|
+
throw new Error("Invalid ".concat(label, ": ").concat(value));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function deriveApiBaseUrl(portalUrl) {
|
|
222
|
+
var normalized = new URL(portalUrl);
|
|
223
|
+
var basePath = normalized.pathname.replace(/\/$/, "");
|
|
224
|
+
normalized.pathname = basePath.length === 0 ? "/api" : "".concat(basePath, "/api");
|
|
225
|
+
return normalized.toString().replace(/\/$/, "");
|
|
226
|
+
}
|
|
227
|
+
function isLocalhostUrl(url) {
|
|
228
|
+
try {
|
|
229
|
+
var parsed = new URL(url);
|
|
230
|
+
return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname === "[::1]";
|
|
231
|
+
} catch (e) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
export function resolvePortalTargets(input) {
|
|
236
|
+
var _input_portalUrl, _ref, _ref1;
|
|
237
|
+
var portalUrl = (_ref1 = (_ref = (_input_portalUrl = input.portalUrl) !== null && _input_portalUrl !== void 0 ? _input_portalUrl : process.env.DAPP_STORE_PORTAL_URL) !== null && _ref !== void 0 ? _ref : input.localDev ? DEFAULT_LOCAL_PORTAL_URL : undefined) !== null && _ref1 !== void 0 ? _ref1 : DEFAULT_PRODUCTION_PORTAL_URL;
|
|
238
|
+
var normalizedPortalUrl = normalizeUrl(portalUrl, "portal URL");
|
|
239
|
+
var normalizedApiBaseUrl = normalizeUrl(deriveApiBaseUrl(normalizedPortalUrl), "portal API base URL");
|
|
240
|
+
if (input.localDev) {
|
|
241
|
+
var localTargets = [
|
|
242
|
+
[
|
|
243
|
+
"portal URL",
|
|
244
|
+
normalizedPortalUrl
|
|
245
|
+
],
|
|
246
|
+
[
|
|
247
|
+
"portal API base URL",
|
|
248
|
+
normalizedApiBaseUrl
|
|
249
|
+
]
|
|
250
|
+
];
|
|
251
|
+
var nonLocalTarget = localTargets.find(function(param) {
|
|
252
|
+
var _param = _sliced_to_array(param, 2), value = _param[1];
|
|
253
|
+
return !isLocalhostUrl(value);
|
|
254
|
+
});
|
|
255
|
+
if (nonLocalTarget) {
|
|
256
|
+
throw new Error("--local-dev only allows localhost portal endpoints. Received ".concat(nonLocalTarget[0], ": ").concat(nonLocalTarget[1]));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (!input.localDev) {
|
|
260
|
+
var portalTargets = [
|
|
261
|
+
[
|
|
262
|
+
"portal URL",
|
|
263
|
+
normalizedPortalUrl
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
"portal API base URL",
|
|
267
|
+
normalizedApiBaseUrl
|
|
268
|
+
]
|
|
269
|
+
];
|
|
270
|
+
var insecureTarget = portalTargets.find(function(param) {
|
|
271
|
+
var _param = _sliced_to_array(param, 2), value = _param[1];
|
|
272
|
+
return new URL(value).protocol !== "https:";
|
|
273
|
+
});
|
|
274
|
+
if (insecureTarget) {
|
|
275
|
+
throw new Error("Portal endpoints must use HTTPS unless --local-dev is set. Received ".concat(insecureTarget[0], ": ").concat(insecureTarget[1]));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
apiBaseUrl: normalizedApiBaseUrl
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export function validateNewVersionArgs(input) {
|
|
283
|
+
var apkSourceCount = (input.apkFile ? 1 : 0) + (input.apkUrl ? 1 : 0);
|
|
284
|
+
if (apkSourceCount !== 1) {
|
|
285
|
+
throw new Error("Specify exactly one of `--apk-file` or `--apk-url`.");
|
|
286
|
+
}
|
|
287
|
+
if (!input.whatsNew || input.whatsNew.trim().length === 0) {
|
|
288
|
+
throw new Error("`--whats-new` is required.");
|
|
289
|
+
}
|
|
290
|
+
if (!input.keypair || input.keypair.trim().length === 0) {
|
|
291
|
+
throw new Error("`--keypair` is required.");
|
|
292
|
+
}
|
|
293
|
+
if (input.apkFile) {
|
|
294
|
+
var apkPath = path.resolve(input.apkFile);
|
|
295
|
+
if (!fs.existsSync(apkPath)) {
|
|
296
|
+
throw new Error("APK file not found: ".concat(apkPath));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (input.apkUrl) {
|
|
300
|
+
var parsed;
|
|
301
|
+
try {
|
|
302
|
+
parsed = new URL(input.apkUrl);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
throw new Error("`--apk-url` must be a valid HTTPS URL.");
|
|
305
|
+
}
|
|
306
|
+
if (parsed.protocol !== "https:") {
|
|
307
|
+
throw new Error("`--apk-url` must use HTTPS.");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
export function validateResumeArgs(input) {
|
|
312
|
+
var releaseId = resolveResumeTarget(input.releaseId, input.resumeRelease, "--release-id", "--resume-release");
|
|
313
|
+
var sessionId = resolveResumeTarget(input.sessionId, input.resumeSession, "--session-id", "--resume-session");
|
|
314
|
+
var resumeTargetCount = (releaseId ? 1 : 0) + (sessionId ? 1 : 0);
|
|
315
|
+
if (resumeTargetCount !== 1) {
|
|
316
|
+
throw new Error("Specify exactly one of `--release-id` or `--session-id`.");
|
|
317
|
+
}
|
|
318
|
+
if (!input.keypair || input.keypair.trim().length === 0) {
|
|
319
|
+
throw new Error("`--keypair` is required.");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function resolveResumeTarget(primary, alias, primaryLabel, aliasLabel) {
|
|
323
|
+
var trimmedPrimary = primary === null || primary === void 0 ? void 0 : primary.trim();
|
|
324
|
+
var trimmedAlias = alias === null || alias === void 0 ? void 0 : alias.trim();
|
|
325
|
+
if (trimmedPrimary && trimmedAlias && trimmedPrimary !== trimmedAlias) {
|
|
326
|
+
throw new Error("Conflicting values were provided for ".concat(primaryLabel, " and ").concat(aliasLabel, "."));
|
|
327
|
+
}
|
|
328
|
+
return trimmedPrimary !== null && trimmedPrimary !== void 0 ? trimmedPrimary : trimmedAlias;
|
|
329
|
+
}
|
|
330
|
+
export function resolveApiKey(input) {
|
|
331
|
+
return _async_to_generator(function() {
|
|
332
|
+
var _process_env_envVarName, _input_apiKeyEnv, envVarName, envValue;
|
|
333
|
+
return _ts_generator(this, function(_state) {
|
|
334
|
+
switch(_state.label){
|
|
335
|
+
case 0:
|
|
336
|
+
envVarName = (_input_apiKeyEnv = input.apiKeyEnv) !== null && _input_apiKeyEnv !== void 0 ? _input_apiKeyEnv : DEFAULT_API_KEY_ENV;
|
|
337
|
+
if (!input.apiKeyStdin) return [
|
|
338
|
+
3,
|
|
339
|
+
2
|
|
340
|
+
];
|
|
341
|
+
return [
|
|
342
|
+
4,
|
|
343
|
+
readSecretFromStdin()
|
|
344
|
+
];
|
|
345
|
+
case 1:
|
|
346
|
+
return [
|
|
347
|
+
2,
|
|
348
|
+
_state.sent()
|
|
349
|
+
];
|
|
350
|
+
case 2:
|
|
351
|
+
envValue = (_process_env_envVarName = process.env[envVarName]) === null || _process_env_envVarName === void 0 ? void 0 : _process_env_envVarName.trim();
|
|
352
|
+
if (envValue) {
|
|
353
|
+
return [
|
|
354
|
+
2,
|
|
355
|
+
envValue
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
throw new Error(withUpdatedCliDocs("Portal API key is required. Set ".concat(envVarName, " or pass --api-key-stdin.")));
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
})();
|
|
362
|
+
}
|
|
363
|
+
export function formatUpdatedCliUsageError(message) {
|
|
364
|
+
return withUpdatedCliDocs(normalizeCliErrorMessage(message));
|
|
365
|
+
}
|
|
366
|
+
function readSecretFromStdin() {
|
|
367
|
+
return _async_to_generator(function() {
|
|
368
|
+
var chunks, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err, value;
|
|
369
|
+
return _ts_generator(this, function(_state) {
|
|
370
|
+
switch(_state.label){
|
|
371
|
+
case 0:
|
|
372
|
+
if (process.stdin.isTTY) {
|
|
373
|
+
throw new Error(withUpdatedCliDocs("No API key was piped into stdin."));
|
|
374
|
+
}
|
|
375
|
+
chunks = [];
|
|
376
|
+
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
377
|
+
_state.label = 1;
|
|
378
|
+
case 1:
|
|
379
|
+
_state.trys.push([
|
|
380
|
+
1,
|
|
381
|
+
6,
|
|
382
|
+
7,
|
|
383
|
+
12
|
|
384
|
+
]);
|
|
385
|
+
_iterator = _async_iterator(process.stdin);
|
|
386
|
+
_state.label = 2;
|
|
387
|
+
case 2:
|
|
388
|
+
return [
|
|
389
|
+
4,
|
|
390
|
+
_iterator.next()
|
|
391
|
+
];
|
|
392
|
+
case 3:
|
|
393
|
+
if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
|
|
394
|
+
3,
|
|
395
|
+
5
|
|
396
|
+
];
|
|
397
|
+
_value = _step.value;
|
|
398
|
+
chunk = _value;
|
|
399
|
+
chunks.push(Buffer.from(chunk));
|
|
400
|
+
_state.label = 4;
|
|
401
|
+
case 4:
|
|
402
|
+
_iteratorAbruptCompletion = false;
|
|
403
|
+
return [
|
|
404
|
+
3,
|
|
405
|
+
2
|
|
406
|
+
];
|
|
407
|
+
case 5:
|
|
408
|
+
return [
|
|
409
|
+
3,
|
|
410
|
+
12
|
|
411
|
+
];
|
|
412
|
+
case 6:
|
|
413
|
+
err = _state.sent();
|
|
414
|
+
_didIteratorError = true;
|
|
415
|
+
_iteratorError = err;
|
|
416
|
+
return [
|
|
417
|
+
3,
|
|
418
|
+
12
|
|
419
|
+
];
|
|
420
|
+
case 7:
|
|
421
|
+
_state.trys.push([
|
|
422
|
+
7,
|
|
423
|
+
,
|
|
424
|
+
10,
|
|
425
|
+
11
|
|
426
|
+
]);
|
|
427
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
|
|
428
|
+
3,
|
|
429
|
+
9
|
|
430
|
+
];
|
|
431
|
+
return [
|
|
432
|
+
4,
|
|
433
|
+
_iterator.return()
|
|
434
|
+
];
|
|
435
|
+
case 8:
|
|
436
|
+
_state.sent();
|
|
437
|
+
_state.label = 9;
|
|
438
|
+
case 9:
|
|
439
|
+
return [
|
|
440
|
+
3,
|
|
441
|
+
11
|
|
442
|
+
];
|
|
443
|
+
case 10:
|
|
444
|
+
if (_didIteratorError) {
|
|
445
|
+
throw _iteratorError;
|
|
446
|
+
}
|
|
447
|
+
return [
|
|
448
|
+
7
|
|
449
|
+
];
|
|
450
|
+
case 11:
|
|
451
|
+
return [
|
|
452
|
+
7
|
|
453
|
+
];
|
|
454
|
+
case 12:
|
|
455
|
+
value = Buffer.concat(chunks).toString("utf8").trim();
|
|
456
|
+
if (!value) {
|
|
457
|
+
throw new Error(withUpdatedCliDocs("No API key was provided on stdin."));
|
|
458
|
+
}
|
|
459
|
+
return [
|
|
460
|
+
2,
|
|
461
|
+
value
|
|
462
|
+
];
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
})();
|
|
466
|
+
}
|
|
467
|
+
function withUpdatedCliDocs(message) {
|
|
468
|
+
return [
|
|
469
|
+
message,
|
|
470
|
+
"",
|
|
471
|
+
"The publishing CLI has changed. See the updated usage guide:",
|
|
472
|
+
UPDATED_PUBLISHING_CLI_DOCS_URL
|
|
473
|
+
].join("\n");
|
|
474
|
+
}
|
|
475
|
+
function normalizeCliErrorMessage(message) {
|
|
476
|
+
var normalized = message.replace(/^error:\s*/i, "").trim();
|
|
477
|
+
if (normalized.length === 0) {
|
|
478
|
+
return "Invalid CLI arguments.";
|
|
479
|
+
}
|
|
480
|
+
var sentence = normalized.endsWith(".") ? normalized : "".concat(normalized, ".");
|
|
481
|
+
return sentence.charAt(0).toUpperCase() + sentence.slice(1);
|
|
482
|
+
}
|