shopq 0.3.0 → 0.3.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 +10 -3
- package/skills/shopq/SKILL.md +182 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopq",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A zero-dependency Shopify Admin CLI built on Bun",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"shopq": "dist/shopq.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"skills"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
15
|
"build": "bun build bin/shopq.ts --target=node --outfile dist/shopq.js && chmod +x dist/shopq.js",
|
|
@@ -30,8 +31,14 @@
|
|
|
30
31
|
"cli",
|
|
31
32
|
"admin",
|
|
32
33
|
"graphql",
|
|
33
|
-
"bun"
|
|
34
|
+
"bun",
|
|
35
|
+
"pi-package"
|
|
34
36
|
],
|
|
37
|
+
"pi": {
|
|
38
|
+
"skills": [
|
|
39
|
+
"./skills"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
35
42
|
"engines": {
|
|
36
43
|
"bun": ">=1.3.0"
|
|
37
44
|
},
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shopq
|
|
3
|
+
description: Manage Shopify stores via the Admin GraphQL API. Use when the user needs to list, create, update, or delete products, pages, collections, menus, files, or themes — or run raw GraphQL queries against a Shopify store.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# shopq — Shopify Admin CLI
|
|
7
|
+
|
|
8
|
+
A zero-dependency Shopify Admin CLI. Structured JSON output, predictable exit codes, no interactive prompts.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
Install globally:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun install -g shopq
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Configure credentials (one of):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Option 1: CLI config
|
|
22
|
+
shopq config set --store your-store.myshopify.com --client-id YOUR_ID --client-secret YOUR_SECRET
|
|
23
|
+
|
|
24
|
+
# Option 2: Environment variables
|
|
25
|
+
export SHOPIFY_STORE=your-store.myshopify.com
|
|
26
|
+
export SHOPIFY_CLIENT_ID=your-client-id
|
|
27
|
+
export SHOPIFY_CLIENT_SECRET=your-client-secret
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Credentials come from a [Shopify Dev Dashboard app](https://shopify.dev/docs/apps/build/authentication-authorization/client-credentials) using Client Credentials grant.
|
|
31
|
+
|
|
32
|
+
## Command Pattern
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
shopq <resource> <verb> [args] [flags]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Always use `--json` (or `-j`) when you need to parse output programmatically.
|
|
39
|
+
|
|
40
|
+
### Global Flags
|
|
41
|
+
|
|
42
|
+
| Flag | Description |
|
|
43
|
+
|------|-------------|
|
|
44
|
+
| `--json, -j` | Output as JSON (always use this) |
|
|
45
|
+
| `--store <url>` | Override store for this command |
|
|
46
|
+
| `--no-color` | Disable colored output |
|
|
47
|
+
|
|
48
|
+
## Key Concept: `gql` as the Escape Hatch
|
|
49
|
+
|
|
50
|
+
The resource commands (`product`, `page`, etc.) cover common operations with pagination, safety, and multi-step orchestration. But **`shopq gql` gives you direct access to the entire Shopify Admin GraphQL API**. If a resource command doesn't exist for what you need (e.g., creating collections, managing orders, customers, inventory, discounts, metafields, webhooks), use `gql`. Don't tell the user something isn't possible — use `gql` to query or mutate it directly. The Shopify Admin API reference applies: https://shopify.dev/docs/api/admin-graphql
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
54
|
+
### Shop & Config
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
shopq shop get --json # Store metadata (name, email, domain, plan, currency)
|
|
58
|
+
shopq config show # Current configuration (never prints secrets)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Products
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# List with filtering and pagination
|
|
65
|
+
shopq product list --json
|
|
66
|
+
shopq product list --status active --vendor "Nike" --limit 10 --json
|
|
67
|
+
shopq product list --cursor "eyJsYXN0..." --json
|
|
68
|
+
|
|
69
|
+
# Get by ID (numeric, GID) or exact title
|
|
70
|
+
shopq product get "T-Shirt" --json
|
|
71
|
+
shopq product get 12345 --json
|
|
72
|
+
|
|
73
|
+
# Create (defaults to draft status)
|
|
74
|
+
shopq product create --title "T-Shirt" --type "Apparel" --vendor "Brand" --tags "summer,cotton" --status draft --json
|
|
75
|
+
|
|
76
|
+
# Create with variants (requires --options and --variants JSON file)
|
|
77
|
+
shopq product create --title "T-Shirt" --options "Size,Color" --variants variants.json --json
|
|
78
|
+
# variants.json uses optionValues: [{ "name": "Large", "optionName": "Size" }]
|
|
79
|
+
|
|
80
|
+
# Update by ID or title
|
|
81
|
+
shopq product update "T-Shirt" --title "New Name" --status active --json
|
|
82
|
+
|
|
83
|
+
# Delete (requires --yes for safety)
|
|
84
|
+
shopq product delete "T-Shirt" --yes --json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Pages
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
shopq page list --json
|
|
91
|
+
shopq page get --handle "about-us" --json
|
|
92
|
+
|
|
93
|
+
# Create (defaults to unpublished)
|
|
94
|
+
shopq page create --title "FAQ" --body "<h1>FAQ</h1>" --published true --json
|
|
95
|
+
shopq page create --title "FAQ" --body-file faq.html --seo-title "FAQ" --seo-desc "Frequently asked questions" --json
|
|
96
|
+
|
|
97
|
+
# Update by handle
|
|
98
|
+
shopq page update about-us --title "About" --body "<p>Updated</p>" --json
|
|
99
|
+
|
|
100
|
+
# Delete
|
|
101
|
+
shopq page delete about-us --yes --json
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Collections (read-only)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
shopq collection list --json
|
|
108
|
+
shopq collection list --limit 100 --json
|
|
109
|
+
shopq collection get "summer-sale" --json # By handle or ID
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Menus (read-only)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
shopq menu list --json # All menus with nested item trees
|
|
116
|
+
shopq menu get "main-menu" --json # By handle or ID
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Files (read-only)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
shopq file list --json
|
|
123
|
+
shopq file list --type IMAGE --limit 50 --json # Types: IMAGE, VIDEO, GENERIC_FILE
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Themes (read-only)
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
shopq theme list --json # All themes; role=MAIN is the live theme
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Raw GraphQL — `gql`
|
|
133
|
+
|
|
134
|
+
**This is the most important command.** It covers anything the resource commands don't — orders, customers, inventory, discounts, metafields, webhooks, fulfillments, draft orders, price rules, and every other Shopify Admin API resource. Always prefer a resource command when one exists (they handle pagination, multi-step mutations, and safety), but fall back to `gql` for everything else.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Inline query
|
|
138
|
+
shopq gql "{ shop { name email } }" --json
|
|
139
|
+
|
|
140
|
+
# From stdin or file
|
|
141
|
+
shopq gql - < query.graphql --json
|
|
142
|
+
|
|
143
|
+
# Mutations with variables
|
|
144
|
+
shopq gql "mutation($id: ID!) { productDelete(input: {id: \$id}) { deletedProductId } }" --variables '{"id": "gid://shopify/Product/123"}' --json
|
|
145
|
+
|
|
146
|
+
# Examples of things only gql can do:
|
|
147
|
+
shopq gql "{ orders(first: 10) { edges { node { id name totalPriceSet { shopMoney { amount } } } } } }" --json
|
|
148
|
+
shopq gql "{ customers(first: 5) { edges { node { id email } } } }" --json
|
|
149
|
+
shopq gql 'mutation { webhookSubscriptionCreate(topic: ORDERS_CREATE, webhookSubscription: {callbackUrl: "https://example.com/hook", format: JSON}) { webhookSubscription { id } userErrors { field message } } }' --json
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The response is raw Shopify JSON: `{ data, extensions?, errors? }`. GraphQL errors go to stderr with exit code 1.
|
|
153
|
+
|
|
154
|
+
## Output Format
|
|
155
|
+
|
|
156
|
+
JSON output uses a consistent envelope:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"data": [ ... ],
|
|
161
|
+
"pageInfo": { "hasNextPage": true, "endCursor": "cursor_string" }
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- Use `pageInfo.endCursor` with `--cursor` to paginate
|
|
166
|
+
- Default page size is 50, max is 250
|
|
167
|
+
|
|
168
|
+
## Exit Codes
|
|
169
|
+
|
|
170
|
+
| Code | Meaning |
|
|
171
|
+
|------|---------|
|
|
172
|
+
| 0 | Success |
|
|
173
|
+
| 1 | Runtime/API error |
|
|
174
|
+
| 2 | Usage error (bad flags, missing args) |
|
|
175
|
+
|
|
176
|
+
## Important Notes
|
|
177
|
+
|
|
178
|
+
- Destructive commands (`delete`) require `--yes` — without it, prints what would happen and exits
|
|
179
|
+
- `product create` defaults to `draft` status — set `--status active` explicitly to publish
|
|
180
|
+
- `page create` defaults to unpublished — set `--published true` explicitly
|
|
181
|
+
- Product title lookups that match multiple products print candidates and exit with code 1
|
|
182
|
+
- For collection products, theme files, or other advanced operations, use `shopq gql`
|