create-shopify-firebase-app 2.0.0 → 2.0.2

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/lib/index.js +60 -28
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * create-shopify-firebase-app — CLI core (v2)
3
3
  *
4
- * Android Studio-level scaffolding experience for Shopify + Firebase apps.
4
+ * Full-stack scaffolding for Shopify + Firebase apps.
5
5
  *
6
6
  * Flow:
7
7
  * 1. App type selection (extension-only vs full-stack Firebase)
@@ -324,7 +324,7 @@ export async function run(argv) {
324
324
  }
325
325
 
326
326
  // ═══════════════════════════════════════════════════════════════════
327
- // ── Interactive flow — like Android Studio's New Project wizard ────
327
+ // ── Interactive flow — guided project wizard ────
328
328
  // ═══════════════════════════════════════════════════════════════════
329
329
 
330
330
  // ── Banner ────────────────────────────────────────────────────────
@@ -640,15 +640,15 @@ export async function run(argv) {
640
640
  info("A browser window will open — sign in to your Partner account.");
641
641
  console.log();
642
642
  try {
643
- await execInteractive("shopify auth login", outputDir);
643
+ await execInteractive("shopify auth login");
644
644
  ok("Logged into Shopify");
645
645
  } catch {
646
646
  warn("Shopify login failed — continuing with manual setup");
647
647
  }
648
648
 
649
649
  // ── Create / Link app via Shopify CLI ──────────────────────
650
- // Run `shopify app config link` in the project directory
651
- // This command handles: org selection, app creation/linking, TOML generation
650
+ // Must `cd` into project dir Shopify CLI uses process.cwd(),
651
+ // not spawn's cwd option, for TOML generation.
652
652
  console.log();
653
653
  if (shopifyAction === "create") {
654
654
  info(`Creating a new Shopify app: ${c.cyan}${appName}${c.reset}`);
@@ -658,31 +658,63 @@ export async function run(argv) {
658
658
  }
659
659
  console.log();
660
660
 
661
+ // Use `cd` to ensure Shopify CLI writes files in the project directory
662
+ const cdCmd = process.platform === "win32"
663
+ ? `cd /d "${outputDir}" && shopify app config link`
664
+ : `cd "${outputDir}" && shopify app config link`;
665
+
661
666
  try {
662
- await execInteractive("shopify app config link", outputDir);
663
-
664
- // Parse the generated TOML for client_id
665
- const tomlFiles = fs.readdirSync(outputDir).filter((f) => f.endsWith(".toml"));
666
- for (const f of tomlFiles) {
667
- const clientId = parseTomlField(path.join(outputDir, f), "client_id");
668
- if (clientId && clientId !== "{{API_KEY}}") {
669
- config.apiKey = clientId;
670
- ok(`Client ID: ${c.cyan}${config.apiKey}${c.reset}`);
671
- break;
667
+ await execInteractive(cdCmd);
668
+ } catch {
669
+ // Shopify CLI may exit non-zero even after creating/linking the app
670
+ // (e.g. "directory doesn't have a package.json" warning)
671
+ warn("Shopify CLI exited with a warning");
672
+ }
673
+
674
+ // ── Parse client_id from any TOML (runs regardless of exit code) ──
675
+ // Check project dir first, then parent dir (Shopify CLI fallback location)
676
+ const dirsToCheck = [outputDir, path.dirname(outputDir)];
677
+ for (const dir of dirsToCheck) {
678
+ if (config.apiKey) break;
679
+ try {
680
+ const tomlFiles = fs.readdirSync(dir).filter((f) => f.endsWith(".toml"));
681
+ for (const f of tomlFiles) {
682
+ const filePath = path.join(dir, f);
683
+ const clientId = parseTomlField(filePath, "client_id");
684
+ if (clientId && clientId !== "{{API_KEY}}" && clientId.length > 5) {
685
+ config.apiKey = clientId;
686
+ ok(`Client ID: ${c.cyan}${config.apiKey}${c.reset}`);
687
+
688
+ // If TOML was in parent dir (Shopify CLI bug), move it to project dir
689
+ if (dir !== outputDir) {
690
+ const destPath = path.join(outputDir, f);
691
+ try {
692
+ // Don't overwrite our template — just read the client_id
693
+ if (!fs.existsSync(destPath)) {
694
+ fs.renameSync(filePath, destPath);
695
+ } else {
696
+ // Clean up the stray TOML from parent dir
697
+ fs.unlinkSync(filePath);
698
+ }
699
+ info(`${c.dim}Picked up credentials from Shopify CLI${c.reset}`);
700
+ } catch {}
701
+ }
702
+ break;
703
+ }
672
704
  }
673
- }
705
+ } catch {}
706
+ }
674
707
 
675
- if (!config.apiKey) {
676
- const res = await prompts({
677
- type: "text",
678
- name: "apiKey",
679
- message: "Could not read Client ID from TOML. Paste it here",
680
- validate: (v) => (v.trim() ? true : "Required"),
681
- }, { onCancel });
682
- config.apiKey = res.apiKey;
683
- }
684
- } catch {
685
- warn("Shopify CLI exited — entering credentials manually");
708
+ if (!config.apiKey) {
709
+ console.log();
710
+ info("Could not read Client ID from Shopify CLI output.");
711
+ const res = await prompts({
712
+ type: "text",
713
+ name: "apiKey",
714
+ message: "Paste your Client ID (from Partner Dashboard → Apps)",
715
+ validate: (v) => (v.trim() ? true : "Required"),
716
+ }, { onCancel });
717
+ config.apiKey = res.apiKey;
686
718
  }
687
719
  }
688
720
 
@@ -958,7 +990,7 @@ function printHelp() {
958
990
  ${c.bold}create-shopify-firebase-app${c.reset}
959
991
 
960
992
  Build Shopify apps for free. Serverless, zero-framework.
961
- Like Android Studio but for Shopify + Firebase.
993
+ The easiest way to build Shopify apps on Firebase.
962
994
 
963
995
  ${c.bold}Usage:${c.reset}
964
996
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-shopify-firebase-app",
3
- "version": "2.0.0",
4
- "description": "Android Studio-level scaffolding for Shopify apps. Multi-page dashboard, App Bridge, Polaris components, TypeScript or JavaScript deploy for free on Firebase.",
3
+ "version": "2.0.2",
4
+ "description": "Create Shopify apps powered by Firebase — multi-page dashboard, App Bridge, Polaris components, TypeScript or JavaScript. Deploy for free.",
5
5
  "keywords": [
6
6
  "shopify",
7
7
  "firebase",