@plitzi/cli 0.37.6 → 0.37.8
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/CHANGELOG.md +44 -0
- package/README.md +3 -2
- package/dist/index.js +41 -22
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @plitzi/cli
|
|
2
2
|
|
|
3
|
+
## 0.37.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4d10e0a: ## Fixed: an api container could not read a file from a CDN
|
|
8
|
+
|
|
9
|
+
- **What happened:** the api container sent `Content-Type: application/json` on every request, including a GET with no
|
|
10
|
+
body to describe. That made every read a non-simple cross-origin request, so the browser asked the host's
|
|
11
|
+
permission first.
|
|
12
|
+
- **Who it hit:** hosts that allow plain cross-origin reads (GET and HEAD from any origin, the usual CORS of a public
|
|
13
|
+
bucket, the space's own CDN among them) refused that preflight. The file never loaded. Tremor's world outlines on
|
|
14
|
+
`cdn-dev.plitzi.com` are one example.
|
|
15
|
+
- **What changes:** a read now sends `Accept: application/json`, and `Content-Type` goes only with a body, unless the
|
|
16
|
+
author set their own. Headers the author adds still make the request non-simple, as they must.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [4d10e0a]
|
|
19
|
+
- @plitzi/sdk-authoring@0.37.8
|
|
20
|
+
|
|
21
|
+
## 0.37.7
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 4d10e0a: ## CDNs with several buckets
|
|
26
|
+
|
|
27
|
+
A CDN is the customer's own storage account — S3 or R2, which they run and pay for — and now holds any number of
|
|
28
|
+
buckets, each with its own configuration: its name at the provider, its region, `public` (served at its domain) or
|
|
29
|
+
`private` (no domain, read only by the platform with the CDN's credential).
|
|
30
|
+
|
|
31
|
+
- `Cdn` carries `buckets: CdnBucket[]`; `domain`, `visibility`, `bucketName` and `region` moved from the CDN to its
|
|
32
|
+
buckets. `Resource.bucketIdentifier` names the bucket a file is in.
|
|
33
|
+
- `SpaceAddCdn(name, provider, endpoint, buckets)` creates the account with its buckets; `SpaceUpdateCdn` changes the
|
|
34
|
+
account only. New `SpaceAddCdnBucket`, `SpaceUpdateCdnBucket` and `SpaceRemoveCdnBucket`.
|
|
35
|
+
- `SpaceResources`, `SpaceAddResource`, `SpaceRemoveResource` and `SpaceMoveResource` take `bucketIdentifier`.
|
|
36
|
+
- Server code — functions and runtime — goes in the space's oldest private bucket. A bucket that keeps code a version
|
|
37
|
+
runs can be neither made public, pointed at another bucket nor removed, and neither can its CDN.
|
|
38
|
+
- Builder: Resources shows each CDN with its buckets — add, edit and remove buckets, upload and browse per bucket; the
|
|
39
|
+
account (name, provider, endpoint, credential) is edited apart. Saving an element as a template picks a public
|
|
40
|
+
bucket (`elementAsTemplate({ cdnIdentifier, bucketIdentifier }, …)`).
|
|
41
|
+
- CLI: `plitzi upload plugin --bucket <identifier>` (with `--cdn` to narrow); only public buckets are offered, a private
|
|
42
|
+
one is refused.
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [4d10e0a]
|
|
45
|
+
- @plitzi/sdk-authoring@0.37.7
|
|
46
|
+
|
|
3
47
|
## 0.37.6
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -172,8 +172,9 @@ up in the live one because of a flag.
|
|
|
172
172
|
`upload plugin` takes the zip named, or the one `pack plugin` left in the project (the newest, when there are several —
|
|
173
173
|
asked at a terminal). It is checked for its `plugin-manifest.json` before anything is sent. Without a connection, or
|
|
174
174
|
without a space, the browser opens for what is missing, so the first upload is one command too. It goes on one of the
|
|
175
|
-
space's
|
|
176
|
-
|
|
175
|
+
space's public buckets — `--bucket <identifier>` (narrowed to one CDN with `--cdn <identifier>`), or asked when there
|
|
176
|
+
are several; a private bucket is refused, since no page could load from it — and is installed, as the builder does when
|
|
177
|
+
a zip is dropped under Resources: added, or the plugin already there moved to the new version with its settings kept.
|
|
177
178
|
|
|
178
179
|
`--api` (or `PLITZI_API_URL`) points it at another platform, a self-hosted or local one; the CLI trusts the
|
|
179
180
|
certificate authorities the system trusts, as the browser beside it does.
|
package/dist/index.js
CHANGED
|
@@ -4552,28 +4552,43 @@ var manifestOf = (zip) => {
|
|
|
4552
4552
|
return;
|
|
4553
4553
|
}
|
|
4554
4554
|
};
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4555
|
+
/**
|
|
4556
|
+
* The public bucket a plugin goes in — the one `--cdn` and `--bucket` name, the only one there is, or the one picked.
|
|
4557
|
+
* A private bucket keeps server code and has no public address, so it is never one.
|
|
4558
|
+
*/
|
|
4559
|
+
var chooseTarget = async (cdns, { cdn: givenCdn, bucket: givenBucket }, spaceName) => {
|
|
4560
|
+
if (givenCdn && !cdns.some((cdn) => cdn.identifier === givenCdn)) {
|
|
4561
|
+
fail(`${spaceName} has no CDN "${givenCdn}". Its CDNs: ${cdns.map((cdn) => cdn.identifier).join(", ")}.`);
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4564
|
+
const candidates = cdns.filter((cdn) => !givenCdn || cdn.identifier === givenCdn).flatMap((cdn) => cdn.buckets.map((bucket) => ({
|
|
4565
|
+
cdn,
|
|
4566
|
+
bucket
|
|
4567
|
+
})));
|
|
4568
|
+
if (givenBucket) {
|
|
4569
|
+
const named = candidates.find(({ bucket }) => bucket.identifier === givenBucket);
|
|
4570
|
+
if (!named) {
|
|
4571
|
+
fail(`${spaceName} has no bucket "${givenBucket}"${givenCdn ? ` in the CDN "${givenCdn}"` : ""}.`);
|
|
4572
|
+
return;
|
|
4573
|
+
}
|
|
4574
|
+
if (named.bucket.visibility === "private") {
|
|
4575
|
+
fail(`"${givenBucket}" is a private bucket: it has no public address, so no page could load a plugin from it.`);
|
|
4562
4576
|
return;
|
|
4563
4577
|
}
|
|
4564
4578
|
return named;
|
|
4565
4579
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4580
|
+
const targets = candidates.filter(({ bucket }) => bucket.visibility === "public");
|
|
4581
|
+
if (targets.length === 0) {
|
|
4582
|
+
fail(`${spaceName} has no public bucket to put a plugin in. Add one to a CDN in the builder, under Resources.`);
|
|
4568
4583
|
return;
|
|
4569
4584
|
}
|
|
4570
|
-
if (
|
|
4585
|
+
if (targets.length === 1) return targets[0];
|
|
4571
4586
|
if (!atTerminal()) {
|
|
4572
4587
|
refuseWithoutTerminal("upload", [{
|
|
4573
|
-
flag: "--
|
|
4574
|
-
choices:
|
|
4575
|
-
question: `Which of ${spaceName}'s
|
|
4576
|
-
}], "plitzi upload plugin stopped before uploading anything: which
|
|
4588
|
+
flag: "--bucket",
|
|
4589
|
+
choices: targets.map(({ bucket }) => bucket.identifier),
|
|
4590
|
+
question: `Which of ${spaceName}'s public buckets does the plugin go in? (narrow with --cdn)`
|
|
4591
|
+
}], "plitzi upload plugin stopped before uploading anything: which bucket serves the plugin is a choice");
|
|
4577
4592
|
return;
|
|
4578
4593
|
}
|
|
4579
4594
|
const rl = readline.createInterface({
|
|
@@ -4581,9 +4596,9 @@ var chooseCdn = async (listed, given, spaceName) => {
|
|
|
4581
4596
|
output: process.stdout
|
|
4582
4597
|
});
|
|
4583
4598
|
try {
|
|
4584
|
-
return await askPick(rl, `Which of ${spaceName}'s
|
|
4585
|
-
label: `${cdn.name} ${chalk.dim(`${
|
|
4586
|
-
value:
|
|
4599
|
+
return await askPick(rl, `Which of ${spaceName}'s public buckets does the plugin go in?`, targets.map((target) => ({
|
|
4600
|
+
label: `${target.cdn.name} — ${target.bucket.name} ${chalk.dim(`${target.bucket.identifier} · ${target.bucket.domain}`)}`,
|
|
4601
|
+
value: target
|
|
4587
4602
|
})));
|
|
4588
4603
|
} finally {
|
|
4589
4604
|
rl.close();
|
|
@@ -4617,11 +4632,15 @@ var uploadPluginCommand = async (zipGiven, options) => {
|
|
|
4617
4632
|
fail(listed.value.reply.data.error ?? `Could not list ${space.name}'s CDNs (${listed.value.reply.status}).`);
|
|
4618
4633
|
return;
|
|
4619
4634
|
}
|
|
4620
|
-
const
|
|
4621
|
-
if (!
|
|
4635
|
+
const target = await chooseTarget(listed.value.reply.data.cdns ?? [], options, space.name);
|
|
4636
|
+
if (!target) return;
|
|
4637
|
+
const { cdn, bucket } = target;
|
|
4622
4638
|
const label = `${manifest.root}${manifest.version ? ` ${manifest.version}` : ""}`;
|
|
4623
|
-
console.log(`\nUploading ${chalk.bold(label)} to ${chalk.bold(space.name)},
|
|
4624
|
-
const query = new URLSearchParams({
|
|
4639
|
+
console.log(`\nUploading ${chalk.bold(label)} to ${chalk.bold(space.name)}, in ${cdn.name} — ${bucket.name}…`);
|
|
4640
|
+
const query = new URLSearchParams({
|
|
4641
|
+
filename: path.basename(zipPath),
|
|
4642
|
+
bucket: bucket.identifier
|
|
4643
|
+
});
|
|
4625
4644
|
const uploaded = await authorizedRequest(listed.value.connection, `/spaces/${space.id}/cdns/${encodeURIComponent(cdn.identifier)}/plugins?${query}`, {
|
|
4626
4645
|
method: "POST",
|
|
4627
4646
|
headers: { "Content-Type": "application/zip" },
|
|
@@ -4674,7 +4693,7 @@ program.command("login").description("Sign in, in your browser. The session is k
|
|
|
4674
4693
|
program.command("logout").description("Sign out: the session is revoked on the platform and forgotten here").action(() => logout());
|
|
4675
4694
|
program.command("whoami").description("Who the CLI is signed in as, and the space it works in").option(...API_OPTION).action((options) => whoami(options));
|
|
4676
4695
|
program.command("space").description("Choose the space to work in, in your browser. One at a time: it replaces the one chosen before").option(...API_OPTION).action((options) => space(options));
|
|
4677
|
-
program.command("upload").description("Put something of this project on the space you work in").command("plugin").argument("[zip]", "The zip plitzi pack plugin built. Left out: the one packed in this project.").description("Upload a packed plugin to a CDN of the space you work in, and install it there").option("--cdn <identifier>", "Which of the space’s CDNs. Asked for when
|
|
4696
|
+
program.command("upload").description("Put something of this project on the space you work in").command("plugin").argument("[zip]", "The zip plitzi pack plugin built. Left out: the one packed in this project.").description("Upload a packed plugin to a CDN of the space you work in, and install it there").option("--cdn <identifier>", "Which of the space’s CDNs the bucket is in.").option("--bucket <identifier>", "Which public bucket the plugin goes in. Asked for when there are several.").option(...API_OPTION).action((zip, options) => uploadPluginCommand(zip, options));
|
|
4678
4697
|
var functions = program.command("functions").description("The space’s own server code: functions/ in this project is a working copy of it");
|
|
4679
4698
|
functions.command("pull").description("Write the space’s functions into functions/ — refused when that would overwrite what is not pushed").option("-f, --force", "Overwrite what is not pushed, or a copy of another space").option(...API_OPTION).action((options) => pullFunctions(options));
|
|
4680
4699
|
functions.command("push").description("Save functions/ as the space’s draft: built and checked on the platform, refused if it moved on since").option(...API_OPTION).action((options) => pushFunctions(options));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/cli",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.8",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"description": "Command line for Plitzi: scaffold a project that renders a space, a plugin package, or an element of your own.",
|
|
6
6
|
"files": [
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@plitzi/sdk-authoring": "0.37.
|
|
24
|
+
"@plitzi/sdk-authoring": "0.37.8",
|
|
25
25
|
"chalk": "^6.0.0",
|
|
26
26
|
"commander": "^15.0.0",
|
|
27
27
|
"esbuild": "^0.28.2",
|
|
28
28
|
"fflate": "^0.8.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@plitzi/sdk-shared": "0.37.
|
|
31
|
+
"@plitzi/sdk-shared": "0.37.8",
|
|
32
32
|
"@types/node": "^26.6.2",
|
|
33
33
|
"eslint": "^9.39.5",
|
|
34
34
|
"eslint-plugin-import": "^2.32.0",
|