@greatstore/cli 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/dist/cli.js +19 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -532,8 +532,14 @@ async function pullCommand(args) {
532
532
  JSON.stringify(data.manifest, null, 2) + "\n"
533
533
  );
534
534
  fs3.writeFileSync(path3.join(out, "bundle.js"), data.bundle);
535
+ const wrote = ["manifest.json", "bundle.js"];
536
+ if (data.source !== null) {
537
+ fs3.writeFileSync(path3.join(out, "component.tsx"), data.source);
538
+ wrote.push("component.tsx");
539
+ }
540
+ const sourceNote = data.source === null ? " (no source \u2014 this version was pushed without component.tsx)" : "";
535
541
  process.stdout.write(
536
- `Pulled ${name} v${data.version} \u2192 ${path3.resolve(out)}/{manifest.json, bundle.js}
542
+ `Pulled ${name} v${data.version} \u2192 ${path3.resolve(out)}/{${wrote.join(", ")}}${sourceNote}
537
543
  `
538
544
  );
539
545
  }
@@ -552,6 +558,7 @@ async function pushCommand(args) {
552
558
  const slug = resolveStore({ flag: flagString(args.flags, "store") });
553
559
  const manifestPath = path4.resolve(flagString(args.flags, "manifest") ?? "manifest.json");
554
560
  const bundlePath = path4.resolve(flagString(args.flags, "bundle") ?? "bundle.js");
561
+ const sourcePath = path4.resolve(flagString(args.flags, "source") ?? "component.tsx");
555
562
  if (!fs4.existsSync(manifestPath)) {
556
563
  throw new Error(`Manifest not found: ${manifestPath}`);
557
564
  }
@@ -576,13 +583,22 @@ async function pushCommand(args) {
576
583
  );
577
584
  }
578
585
  const bundleText = fs4.readFileSync(bundlePath, "utf8");
586
+ const sourceText = fs4.existsSync(sourcePath) ? fs4.readFileSync(sourcePath, "utf8") : null;
579
587
  const form = new FormData();
580
588
  form.append("manifest", new Blob([manifestText], { type: "application/json" }), "manifest.json");
581
589
  form.append("bundle", new Blob([bundleText], { type: "text/javascript" }), "bundle.js");
590
+ if (sourceText !== null) {
591
+ form.append(
592
+ "source",
593
+ new Blob([sourceText], { type: "text/plain; charset=utf-8" }),
594
+ path4.basename(sourcePath)
595
+ );
596
+ }
582
597
  const url = `${apiBaseFor(slug)}/api/builder/components/${encodeURIComponent(name)}`;
583
598
  const data = await request(url, { method: "POST", multipart: form });
599
+ const sourceNote = sourceText === null ? " (no source uploaded \u2014 `component.tsx` not found in cwd)" : "";
584
600
  process.stdout.write(
585
- `Pushed ${name} v${data.version} (draft) to ${slug}. Run \`gs publish ${name}\` to promote.
601
+ `Pushed ${name} v${data.version} (draft) to ${slug}${sourceNote}. Run \`gs publish ${name}\` to promote.
586
602
  `
587
603
  );
588
604
  }
@@ -858,7 +874,7 @@ function pascal(name) {
858
874
  }
859
875
 
860
876
  // src/index.ts
861
- var VERSION = true ? "0.0.6" : "0.0.0-dev";
877
+ var VERSION = true ? "0.0.7" : "0.0.0-dev";
862
878
  var HELP = `gs \u2014 GreatStore CLI (v${VERSION})
863
879
 
864
880
  Usage:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatstore/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "CLI for authoring and shipping GreatStore custom components.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",