nowebcli 0.2.1 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nowebcli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Create, preview and publish community templates for Noweb",
5
5
  "license": "MIT",
6
6
  "repository": {
package/scripts/noweb.mjs CHANGED
@@ -34,7 +34,7 @@ function usage() {
34
34
  check validate and compile this template
35
35
  login connect the CLI to your Noweb account
36
36
  list list your uploaded templates
37
- download <slug> restore one into the current folder
37
+ download <slug|id> restore one into the current folder
38
38
  upload publish this template directly to Noweb
39
39
  publish [slug] publish validated templates (deployment only)`);
40
40
  }
@@ -200,7 +200,7 @@ async function listTemplates() {
200
200
  }
201
201
  if (templates.length) {
202
202
  console.log("Templates");
203
- for (const template of templates) console.log(`${template.slug}\t${template.name}`);
203
+ for (const template of templates) console.log(template.slug || template.id);
204
204
  }
205
205
  if (projects.length) {
206
206
  if (templates.length) console.log();
@@ -223,10 +223,11 @@ async function downloadTemplate(value) {
223
223
  if (!response.ok) throw new Error(result.error || `Download failed (${response.status}).`);
224
224
  const template = result.template;
225
225
  if (
226
- !template || template.metadata?.slug !== selectedSlug || typeof template.metadata?.name !== "string" ||
226
+ !template || typeof template.metadata?.slug !== "string" || typeof template.metadata?.name !== "string" ||
227
227
  !types.has(template.metadata?.type) || typeof template.source !== "string" ||
228
228
  !Array.isArray(template.customizations) || !Array.isArray(template.assets) || template.assets.length > 200
229
229
  ) throw new Error("The server returned an invalid template.");
230
+ const downloadedSlug = requireSlug(template.metadata.slug);
230
231
 
231
232
  const assets = await Promise.all(template.assets.map(async (asset) => {
232
233
  const path = requireAssetPath(asset?.path);
@@ -255,7 +256,7 @@ async function downloadTemplate(value) {
255
256
  ...(!assets.length ? [writeFile(join(root, "public/.gitkeep"), "")] : []),
256
257
  ]);
257
258
  await setupWorkspace(shouldInstall);
258
- console.log(`Downloaded ${selectedSlug} into ${root}`);
259
+ console.log(`Downloaded ${downloadedSlug} into ${root}`);
259
260
  }
260
261
 
261
262
  async function login() {