Skip to content

Commit c9fd6c6

Browse files
jordanverasamyodacrem
authored andcommitted
change camelCase flag names to kebab-case
1 parent f284c9f commit c9fd6c6

File tree

9 files changed

+293
-27
lines changed

9 files changed

+293
-27
lines changed

CLAUDE.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## WRITING TESTS
2+
DO NOT ADD COMMENTS UNLESS TO OVERRIDE ESLINT DIRECTIVES
3+
DO NOT us vi.clearAllMocks()
4+
ALWAYS LINT THE TESTS AND CLEAN UP PRETTIER ERRORS ETC
5+
ALWAYS TYPECHECK
6+
ALWAYS RUN KNIP AND CHECK FOR UNUSED EXPORTS ETC
7+
8+
## TOOLS
9+
10+
### CLEAN A PACKAGE (e.g. store package)
11+
pnpm nx run store:clean
12+
13+
### BUILD A PACKAGE (e.g. store package)
14+
pnpm nx run store:build
15+
16+
### TEST A PACKAGE (e.g. store package)
17+
pnpm nx run store:test
18+
19+
### TYPECHECK A PACKAGE (e.g. store package)
20+
nx run store:type-check
21+
22+
### LINT A PACKAGE (e.g. store package)
23+
pnpm nx run store:lint
24+
25+
### CHECK TEST COVERAGE FOR A PACKAGE (e.g. store package)
26+
nx run store:test --coverage
27+
28+
### RUN FEATURES/CUCUMBER/ACCEPTANCE TEST FOR A PACKAGE (e.g store package)
29+
FEATURE=features/store.feature pnpm nx run features:test
30+
31+
### RUN KNIP / CHECK FOR UNUSED EXPORTS
32+
pnpm run knip
33+
34+
### UPDATE GRAPQHL SCHEMAS
35+
pnpm graphql-codegen:get-graphql-schemas
36+
37+
### GENERATE GRAPHQL TYPES
38+
pnpm graphql-codegen

add_products.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# Default number of rows to add if no argument provided
4+
NUM_ROWS=${1:-5}
5+
6+
# Validate input is a positive number
7+
if ! [[ "$NUM_ROWS" =~ ^[0-9]+$ ]] || [ "$NUM_ROWS" -eq 0 ]; then
8+
echo "Error: Please provide a positive number of rows to add"
9+
echo "Usage: $0 [number_of_rows]"
10+
echo "Example: $0 10"
11+
exit 1
12+
fi
13+
14+
# Database file
15+
DB_FILE="large.sqlite"
16+
17+
# Check if database exists
18+
if [ ! -f "$DB_FILE" ]; then
19+
echo "Error: Database file '$DB_FILE' not found"
20+
exit 1
21+
fi
22+
23+
echo "Adding $NUM_ROWS new rows to the products table..."
24+
25+
# Add the specified number of rows
26+
for i in $(seq 1 $NUM_ROWS); do
27+
sqlite3 "$DB_FILE" <<EOF
28+
INSERT INTO products (
29+
shopifyId,
30+
handle,
31+
title,
32+
status,
33+
vendor,
34+
productType,
35+
descriptionHtml,
36+
giftCard,
37+
giftCardTemplateSuffix,
38+
options,
39+
"productCategory.productTaxonomyNodeId",
40+
publishedToOnlineStore,
41+
"seo.title",
42+
"seo.description",
43+
requiresSellingPlan,
44+
tags,
45+
templateSuffix
46+
)
47+
SELECT
48+
NULL,
49+
'handle-' || (SELECT MAX(id) + 1 FROM products),
50+
'row-' || (SELECT MAX(id) + 1 FROM products),
51+
status,
52+
vendor,
53+
productType,
54+
descriptionHtml,
55+
giftCard,
56+
giftCardTemplateSuffix,
57+
options,
58+
"productCategory.productTaxonomyNodeId",
59+
publishedToOnlineStore,
60+
"seo.title",
61+
"seo.description",
62+
requiresSellingPlan,
63+
tags,
64+
templateSuffix
65+
FROM products
66+
WHERE id = (SELECT MAX(id) FROM products);
67+
EOF
68+
done
69+
70+
# Show the new row count
71+
NEW_COUNT=$(sqlite3 "$DB_FILE" "SELECT COUNT(*) FROM products;")
72+
echo "Success! The products table now has $NEW_COUNT rows."
73+
74+
# Show the last few rows added
75+
echo -e "\nLast 3 rows added:"
76+
sqlite3 "$DB_FILE" -header -column "SELECT id, handle, title FROM products ORDER BY id DESC LIMIT 3;"

demo.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [ "$#" -ne 2 ]; then
6+
echo "Hi. Please provide source store and target store as arguments."
7+
exit 1
8+
fi
9+
10+
11+
FROM_STORE="$1"
12+
TO_STORE="$2"
13+
14+
15+
# generate a unique name for the export file
16+
EXPORT_FILE="export-$(date +%Y%m%d%H%M%S).sqlite"
17+
18+
clear
19+
20+
echo
21+
echo "copying data from $FROM_STORE to $TO_STORE"
22+
echo "shopify store copy --from-store=$FROM_STORE --to-store=$TO_STORE -y"
23+
shopify store copy --from-store=$FROM_STORE --to-store=$TO_STORE -y
24+
25+
echo "now exporting data from $TO_STORE to a file"
26+
echo "shopify store copy --from-store=$TO_STORE --to-file=$EXPORT_FILE -y"
27+
shopify store copy --from-store=$TO_STORE --to-file=$EXPORT_FILE -y
28+
29+
echo "now updating the data in the file so all products are upper case"
30+
31+
# update all the product titles to be upper case
32+
# in the sqlite file products table
33+
sqlite3 $EXPORT_FILE <<EOF
34+
UPDATE products SET title = UPPER(title);
35+
EOF
36+
37+
echo "now importing the modified data back to the store"
38+
echo "shopify store copy --to-store=$TO_STORE --from-file=$EXPORT_FILE -y"
39+
shopify store copy --to-store=$TO_STORE --from-file=$EXPORT_FILE -y
40+
41+
# download again
42+
echo "now exporting the data again to verify the titles are upper case"
43+
echo "shopify store copy --from-store=$TO_STORE --to-file=$EXPORT_FILE -y"
44+
shopify store copy --from-store=$TO_STORE --to-file=$EXPORT_FILE -y
45+
46+
47+
echo "now checking if all product titles are upper case"
48+
if sqlite3 $EXPORT_FILE "SELECT title FROM products WHERE title != UPPER(title);" | grep -q .; then
49+
echo "Boo! Product titles are not upper case"
50+
exit 1
51+
else
52+
echo "Product titles are upper case. Huzzah!"
53+
fi
54+
55+
echo "done!"

packages/cli/oclif.manifest.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4880,21 +4880,21 @@
48804880
"customPluginName": "@shopify/store",
48814881
"description": "Copy data between stores, export store data to SQLite, or import data from SQLite to a store",
48824882
"flags": {
4883-
"fromFile": {
4883+
"from-file": {
48844884
"description": "The SQLite file to import data from.",
48854885
"env": "SHOPIFY_FLAG_FROM_FILE",
48864886
"hasDynamicHelp": false,
48874887
"multiple": false,
4888-
"name": "fromFile",
4888+
"name": "from-file",
48894889
"required": false,
48904890
"type": "option"
48914891
},
4892-
"fromStore": {
4892+
"from-store": {
48934893
"description": "The source store domain to copy/export data from (e.g., source.myshopify.com).",
48944894
"env": "SHOPIFY_FLAG_FROM_STORE",
48954895
"hasDynamicHelp": false,
48964896
"multiple": false,
4897-
"name": "fromStore",
4897+
"name": "from-store",
48984898
"required": false,
48994899
"type": "option"
49004900
},
@@ -4937,21 +4937,21 @@
49374937
"required": false,
49384938
"type": "boolean"
49394939
},
4940-
"toFile": {
4940+
"to-file": {
49414941
"description": "The SQLite file path to export data to. Omit to auto-generate filename.",
49424942
"env": "SHOPIFY_FLAG_TO_FILE",
49434943
"hasDynamicHelp": false,
49444944
"multiple": false,
4945-
"name": "toFile",
4945+
"name": "to-file",
49464946
"required": false,
49474947
"type": "option"
49484948
},
4949-
"toStore": {
4949+
"to-store": {
49504950
"description": "The target store domain to copy/import data to (e.g., target.myshopify.com).",
49514951
"env": "SHOPIFY_FLAG_TO_STORE",
49524952
"hasDynamicHelp": false,
49534953
"multiple": false,
4954-
"name": "toStore",
4954+
"name": "to-store",
49554955
"required": false,
49564956
"type": "option"
49574957
},

packages/features/steps/store.steps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ When(
7373
{timeout: 60 * 1000},
7474
async function (source: string, destination: string) {
7575
try {
76-
const args = ['store', 'copy', '--fromStore', source, '--toStore', destination, '--mock', '--no-prompt']
76+
const args = ['store', 'copy', '--from-store', source, '--to-store', destination, '--mock', '--no-prompt']
7777
const result = await this.execCLI(args)
7878
const context = storeContext
7979
context.operationResult = result

packages/store/src/commands/store/copy.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,24 @@ describe('Copy', () => {
108108
}
109109

110110
test('should instantiate StoreCopyOperation for store-to-store copy', async () => {
111-
await run(['--fromStore=source.myshopify.com', '--toStore=target.myshopify.com'])
111+
await run(['--from-store=source.myshopify.com', '--to-store=target.myshopify.com'])
112112

113113
expect(StoreCopyOperation).toHaveBeenCalledTimes(1)
114114
expect(mockExecute).toHaveBeenCalledWith('source.myshopify.com', 'target.myshopify.com', expect.any(Object))
115115
})
116116

117117
test('should instantiate StoreExportOperation for store-to-file export', async () => {
118-
await run(['--fromStore=source.myshopify.com', '--toFile=output.sqlite'])
118+
await run(['--from-store=source.myshopify.com', '--to-file=output.sqlite'])
119119

120120
expect(StoreExportOperation).toHaveBeenCalledTimes(1)
121121
expect(mockExecute).toHaveBeenCalledWith('source.myshopify.com', 'output.sqlite', expect.any(Object))
122122
})
123123

124-
test('should auto-generate toFile path when exporting without toFile parameter', async () => {
124+
test('should auto-generate to-file path when exporting without to-file parameter', async () => {
125125
const mockDate = new Date('2024-01-01T12:00:00Z')
126126
vi.spyOn(Date, 'now').mockReturnValue(mockDate.getTime())
127127

128-
await run(['--fromStore=source.myshopify.com'])
128+
await run(['--from-store=source.myshopify.com'])
129129

130130
expect(StoreExportOperation).toHaveBeenCalledTimes(1)
131131
expect(mockExecute).toHaveBeenCalledWith(
@@ -135,11 +135,11 @@ describe('Copy', () => {
135135
)
136136
})
137137

138-
test('should sanitize domain name when auto-generating toFile path', async () => {
138+
test('should sanitize domain name when auto-generating to-file path', async () => {
139139
const mockDate = new Date('2024-01-01T12:00:00Z')
140140
vi.spyOn(Date, 'now').mockReturnValue(mockDate.getTime())
141141

142-
await run(['--fromStore=test@store!.myshopify.com'])
142+
await run(['--from-store=test@store!.myshopify.com'])
143143

144144
expect(StoreExportOperation).toHaveBeenCalledTimes(1)
145145
expect(mockExecute).toHaveBeenCalledWith(
@@ -150,14 +150,14 @@ describe('Copy', () => {
150150
})
151151

152152
test('should instantiate StoreImportOperation for file-to-store import', async () => {
153-
await run(['--fromFile=input.sqlite', '--toStore=target.myshopify.com'])
153+
await run(['--from-file=input.sqlite', '--to-store=target.myshopify.com'])
154154

155155
expect(StoreImportOperation).toHaveBeenCalledTimes(1)
156156
expect(mockExecute).toHaveBeenCalledWith('input.sqlite', 'target.myshopify.com', expect.any(Object))
157157
})
158158

159-
test('should auto-generate toFile for export when only fromStore is provided', async () => {
160-
await run(['--fromStore=source.myshopify.com'])
159+
test('should auto-generate to-file for export when only from-store is provided', async () => {
160+
await run(['--from-store=source.myshopify.com'])
161161

162162
expect(StoreExportOperation).toHaveBeenCalledTimes(1)
163163
expect(mockExecute).toHaveBeenCalledWith(
@@ -168,7 +168,7 @@ describe('Copy', () => {
168168
})
169169

170170
test('should show help when invalid flag combination', async () => {
171-
await run(['--toFile=output.sqlite'])
171+
await run(['--to-file=output.sqlite'])
172172

173173
expect(loadHelpClass).toHaveBeenCalledWith(expect.any(Object))
174174
expect(mockShowHelp).toHaveBeenCalledWith(['store:copy'])
@@ -188,7 +188,7 @@ describe('Copy', () => {
188188
})
189189

190190
test('should show help when mixing store and file flags', async () => {
191-
await run(['--fromStore=source.myshopify.com', '--fromFile=input.sqlite', '--toStore=target.myshopify.com'])
191+
await run(['--from-store=source.myshopify.com', '--from-file=input.sqlite', '--to-store=target.myshopify.com'])
192192

193193
expect(loadHelpClass).toHaveBeenCalledWith(expect.any(Object))
194194
expect(mockShowHelp).toHaveBeenCalledWith(['store:copy'])
@@ -198,7 +198,7 @@ describe('Copy', () => {
198198
})
199199

200200
test('should pass flags to the operation', async () => {
201-
await run(['--fromStore=source.myshopify.com', '--toStore=target.myshopify.com', '--no-prompt', '--mock'])
201+
await run(['--from-store=source.myshopify.com', '--to-store=target.myshopify.com', '--no-prompt', '--mock'])
202202

203203
expect(mockExecute).toHaveBeenCalledWith(
204204
'source.myshopify.com',

packages/store/src/commands/store/copy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default class Copy extends BaseBDCommand {
3232
const bpSession = await apiClient.ensureAuthenticatedBusinessPlatform()
3333
const allOrgs = await apiClient.fetchOrganizations(bpSession)
3434

35-
const {fromStore, toStore, fromFile, _} = this.flags
36-
let {toFile} = this.flags
35+
const {'from-store': fromStore, 'to-store': toStore, 'from-file': fromFile} = this.flags
36+
let {'to-file': toFile} = this.flags
3737
const operationMode = this.determineOperationMode(fromStore, toStore, fromFile, toFile)
3838

3939
if (!operationMode) {

packages/store/src/lib/flags.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import {Flags} from '@oclif/core'
22

33
export const storeFlags = {
4-
fromStore: Flags.string({
4+
'from-store': Flags.string({
55
description: 'The source store domain to copy/export data from (e.g., source.myshopify.com).',
66
required: false,
77
env: 'SHOPIFY_FLAG_FROM_STORE',
88
}),
9-
toStore: Flags.string({
9+
'to-store': Flags.string({
1010
description: 'The target store domain to copy/import data to (e.g., target.myshopify.com).',
1111
required: false,
1212
env: 'SHOPIFY_FLAG_TO_STORE',
1313
}),
1414
}
1515

1616
export const fileFlags = {
17-
fromFile: Flags.string({
17+
'from-file': Flags.string({
1818
description: 'The SQLite file to import data from.',
1919
required: false,
2020
env: 'SHOPIFY_FLAG_FROM_FILE',
2121
}),
22-
toFile: Flags.string({
22+
'to-file': Flags.string({
2323
description: 'The SQLite file path to export data to. Omit to auto-generate filename.',
2424
required: false,
2525
env: 'SHOPIFY_FLAG_TO_FILE',

0 commit comments

Comments
 (0)