@displaydev/cli 0.8.1 → 0.9.0
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/api-client.js +19 -7
- package/dist/main.js +6 -2
- package/package.json +1 -1
package/dist/api-client.js
CHANGED
|
@@ -561,17 +561,29 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
561
561
|
{
|
|
562
562
|
key: "exportSource",
|
|
563
563
|
value: /**
|
|
564
|
-
* Fetch the
|
|
565
|
-
* the
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
|
|
564
|
+
* Fetch the source bytes of an artifact. `format: 'original'` returns
|
|
565
|
+
* the publisher's upload (markdown for `.md`, HTML for `.html`).
|
|
566
|
+
* `format: 'markdown'` returns markdown regardless — `.md` is unchanged,
|
|
567
|
+
* `.html` is converted server-side via Workers AI (cached).
|
|
568
|
+
*
|
|
569
|
+
* Returns the body plus the response's Content-Type. Throws `ApiError`
|
|
570
|
+
* on non-2xx (CLI maps 404 to a clean message + exit 4).
|
|
571
|
+
*/ function exportSource(shortId, version, format) {
|
|
569
572
|
return _async_to_generator(function() {
|
|
570
|
-
var _res_headers_get, qs, url, res, _parsed_message, text, parsed, arrayBuffer;
|
|
573
|
+
var _res_headers_get, params, qs, url, res, _parsed_message, text, parsed, arrayBuffer;
|
|
571
574
|
return _ts_generator(this, function(_state) {
|
|
572
575
|
switch(_state.label){
|
|
573
576
|
case 0:
|
|
574
|
-
|
|
577
|
+
params = [];
|
|
578
|
+
if (version !== undefined) {
|
|
579
|
+
params.push("v=".concat(version));
|
|
580
|
+
}
|
|
581
|
+
// `original` is the API default — omit so smoke tests / network
|
|
582
|
+
// logs aren't littered with redundant query params.
|
|
583
|
+
if (format !== undefined && format !== 'original') {
|
|
584
|
+
params.push("format=".concat(format));
|
|
585
|
+
}
|
|
586
|
+
qs = params.length > 0 ? "?".concat(params.join('&')) : '';
|
|
575
587
|
url = "".concat(this.baseUrl, "/v1/artifacts/").concat(shortId, "/source").concat(qs);
|
|
576
588
|
return [
|
|
577
589
|
4,
|
package/dist/main.js
CHANGED
|
@@ -781,7 +781,7 @@ program.command('get <shortId>').description('Get artifact details').option('--i
|
|
|
781
781
|
})();
|
|
782
782
|
});
|
|
783
783
|
// --- export ---
|
|
784
|
-
program.command('export <shortId>').description('Print the published source bytes to stdout. Pin a version with @<n>.').action(function(shortIdArg) {
|
|
784
|
+
program.command('export <shortId>').description('Print the published source bytes to stdout. Pin a version with @<n>.').option('--format <format>', 'Representation: "original" (default — bytes as uploaded) or "markdown" (.html artifacts are converted via Workers AI).', 'original').action(function(shortIdArg, opts) {
|
|
785
785
|
return _async_to_generator(function() {
|
|
786
786
|
var parsed, auth, client, result, err, msg;
|
|
787
787
|
return _ts_generator(this, function(_state) {
|
|
@@ -792,6 +792,10 @@ program.command('export <shortId>').description('Print the published source byte
|
|
|
792
792
|
console.error('Invalid argument. Expected <shortId> or <shortId>@<version> (version must be a positive integer).');
|
|
793
793
|
process.exit(2);
|
|
794
794
|
}
|
|
795
|
+
if (opts.format !== 'original' && opts.format !== 'markdown') {
|
|
796
|
+
console.error('Invalid --format. Expected "original" or "markdown".');
|
|
797
|
+
process.exit(2);
|
|
798
|
+
}
|
|
795
799
|
return [
|
|
796
800
|
4,
|
|
797
801
|
resolveAuthOrConfig()
|
|
@@ -809,7 +813,7 @@ program.command('export <shortId>').description('Print the published source byte
|
|
|
809
813
|
]);
|
|
810
814
|
return [
|
|
811
815
|
4,
|
|
812
|
-
client.exportSource(parsed.shortId, parsed.version)
|
|
816
|
+
client.exportSource(parsed.shortId, parsed.version, opts.format)
|
|
813
817
|
];
|
|
814
818
|
case 3:
|
|
815
819
|
result = _state.sent();
|