@zalify/cli 0.12.0 → 0.12.1

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 +11 -4
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -12836,9 +12836,12 @@ async function shopifyImport(storeDir, options = {}) {
12836
12836
  console.log(` ✓ pruned ${node.handle}`);
12837
12837
  }
12838
12838
  }
12839
+ const collectionIds = [];
12839
12840
  for (const c of catalog.collections ?? []) {
12840
12841
  const existing = await gql(auth, `query($q: String!) { collections(first: 1, query: $q) { nodes { id handle } } }`, { q: `handle:${c.handle}` });
12841
- if (existing.collections.nodes[0]?.handle === c.handle) {
12842
+ const existingNode = existing.collections.nodes[0];
12843
+ if (existingNode?.handle === c.handle) {
12844
+ collectionIds.push(existingNode.id);
12842
12845
  console.log(` - collection ${c.handle} exists, skipped`);
12843
12846
  continue;
12844
12847
  }
@@ -12862,19 +12865,23 @@ async function shopifyImport(storeDir, options = {}) {
12862
12865
  const errs = data.collectionCreate.userErrors;
12863
12866
  if (errs.length)
12864
12867
  console.error(` ✗ collection ${c.handle}: ${joinErrors(errs)}`);
12865
- else
12868
+ else {
12869
+ if (data.collectionCreate.collection) {
12870
+ collectionIds.push(data.collectionCreate.collection.id);
12871
+ }
12866
12872
  console.log(` ✓ collection ${c.handle}`);
12873
+ }
12867
12874
  }
12868
12875
  try {
12869
12876
  const pubs = await gql(auth, `{ publications(first: 10) { nodes { id name } } }`);
12870
12877
  const online = pubs.publications.nodes.find((n) => n.name === "Online Store");
12871
12878
  if (online) {
12872
- for (const id of productIds) {
12879
+ for (const id of [...productIds, ...collectionIds]) {
12873
12880
  await gql(auth, `mutation($id: ID!, $input: [PublicationInput!]!) {
12874
12881
  publishablePublish(id: $id, input: $input) { userErrors { field message } }
12875
12882
  }`, { id, input: [{ publicationId: online.id }] });
12876
12883
  }
12877
- console.log(` ✓ published ${productIds.length} products to Online Store`);
12884
+ console.log(` ✓ published ${productIds.length} products and ${collectionIds.length} collections to Online Store`);
12878
12885
  }
12879
12886
  } catch (e) {
12880
12887
  console.warn(` ! could not publish to Online Store (write_publications scope missing?): ${e instanceof Error ? e.message : String(e)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalify/cli",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Zalify CLI - command-line interface for Zalify",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",