@doswiftly/cli 0.1.24 → 0.2.0
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/dist/commands/check.js +2 -2
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +8 -5
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +13 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +155 -63
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +3 -4
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +271 -166
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/sdk.d.ts +1 -1
- package/dist/commands/sdk.js +3 -3
- package/dist/commands/sdk.js.map +1 -1
- package/dist/commands/template.d.ts.map +1 -1
- package/dist/commands/template.js +4 -31
- package/dist/commands/template.js.map +1 -1
- package/dist/commands/verify.js +5 -5
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/i18n.d.ts +12 -0
- package/dist/lib/i18n.d.ts.map +1 -1
- package/dist/lib/i18n.js +24 -0
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/proxy-server.d.ts +22 -6
- package/dist/lib/proxy-server.d.ts.map +1 -1
- package/dist/lib/proxy-server.js +174 -75
- package/dist/lib/proxy-server.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/types.d.ts +0 -5
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands/types.js +0 -82
- package/dist/commands/types.js.map +0 -1
- package/templates/storefront-minimal/.env.example +0 -10
- package/templates/storefront-minimal/.github/workflows/build-template.yml +0 -119
- package/templates/storefront-minimal/app/globals.css +0 -18
- package/templates/storefront-minimal/app/layout.tsx +0 -26
- package/templates/storefront-minimal/app/page.tsx +0 -93
- package/templates/storefront-minimal/lib/graphql-client.ts +0 -23
- package/templates/storefront-minimal/next.config.ts +0 -15
- package/templates/storefront-minimal/open-next.config.ts +0 -3
- package/templates/storefront-minimal/package.json +0 -30
- package/templates/storefront-minimal/postcss.config.mjs +0 -5
- package/templates/storefront-minimal/tailwind.config.ts +0 -14
- package/templates/storefront-minimal/tsconfig.json +0 -27
- package/templates/storefront-minimal/wrangler.toml +0 -24
- package/templates/storefront-nextjs/.env.example +0 -68
- package/templates/storefront-nextjs/.github/workflows/build-template.yml +0 -119
- package/templates/storefront-nextjs/README.md +0 -524
- package/templates/storefront-nextjs/app/account/orders/page.tsx +0 -216
- package/templates/storefront-nextjs/app/account/page.tsx +0 -167
- package/templates/storefront-nextjs/app/auth/login/page.tsx +0 -135
- package/templates/storefront-nextjs/app/auth/register/page.tsx +0 -212
- package/templates/storefront-nextjs/app/cart/page.tsx +0 -263
- package/templates/storefront-nextjs/app/categories/[slug]/page.tsx +0 -200
- package/templates/storefront-nextjs/app/categories/page.tsx +0 -58
- package/templates/storefront-nextjs/app/checkout/page.tsx +0 -351
- package/templates/storefront-nextjs/app/collections/[slug]/page.tsx +0 -158
- package/templates/storefront-nextjs/app/collections/page.tsx +0 -61
- package/templates/storefront-nextjs/app/globals.css +0 -98
- package/templates/storefront-nextjs/app/layout.tsx +0 -39
- package/templates/storefront-nextjs/app/page.tsx +0 -136
- package/templates/storefront-nextjs/app/products/[slug]/page.tsx +0 -119
- package/templates/storefront-nextjs/app/products/page.tsx +0 -107
- package/templates/storefront-nextjs/app/search/page.tsx +0 -127
- package/templates/storefront-nextjs/components/auth/auth-guard.tsx +0 -94
- package/templates/storefront-nextjs/components/commerce/add-to-cart-button.tsx +0 -77
- package/templates/storefront-nextjs/components/commerce/cart-icon.tsx +0 -29
- package/templates/storefront-nextjs/components/commerce/currency-selector.tsx +0 -217
- package/templates/storefront-nextjs/components/commerce/pagination.tsx +0 -62
- package/templates/storefront-nextjs/components/commerce/product-actions.tsx +0 -135
- package/templates/storefront-nextjs/components/commerce/product-filters.tsx +0 -109
- package/templates/storefront-nextjs/components/commerce/product-price.tsx +0 -375
- package/templates/storefront-nextjs/components/commerce/search-input.tsx +0 -178
- package/templates/storefront-nextjs/components/commerce/sort-select.tsx +0 -64
- package/templates/storefront-nextjs/components/commerce/variant-selector.tsx +0 -210
- package/templates/storefront-nextjs/components/layout/footer.tsx +0 -107
- package/templates/storefront-nextjs/components/layout/header.tsx +0 -104
- package/templates/storefront-nextjs/components/providers.tsx +0 -62
- package/templates/storefront-nextjs/lib/auth/routes.ts +0 -52
- package/templates/storefront-nextjs/lib/currency.tsx +0 -140
- package/templates/storefront-nextjs/lib/format.ts +0 -159
- package/templates/storefront-nextjs/lib/graphql-queries.ts +0 -629
- package/templates/storefront-nextjs/lib/hooks.ts +0 -30
- package/templates/storefront-nextjs/middleware.ts +0 -80
- package/templates/storefront-nextjs/next.config.ts +0 -37
- package/templates/storefront-nextjs/open-next.config.ts +0 -3
- package/templates/storefront-nextjs/package.dev.json +0 -30
- package/templates/storefront-nextjs/package.json +0 -32
- package/templates/storefront-nextjs/package.json.template +0 -32
- package/templates/storefront-nextjs/postcss.config.mjs +0 -8
- package/templates/storefront-nextjs/tailwind.config.ts +0 -111
- package/templates/storefront-nextjs/tsconfig.json +0 -27
- package/templates/storefront-nextjs/wrangler.toml +0 -24
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Currency Utilities
|
|
3
|
-
*
|
|
4
|
-
* This file provides currency formatting helpers.
|
|
5
|
-
*
|
|
6
|
-
* For currency state management, use the SDK:
|
|
7
|
-
* ```tsx
|
|
8
|
-
* import { useCurrency } from '@doswiftly/storefront-sdk/graphql/react';
|
|
9
|
-
*
|
|
10
|
-
* function MyComponent() {
|
|
11
|
-
* const { currency, setCurrency, supportedCurrencies } = useCurrency();
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
// Re-export useCurrency from SDK for convenience
|
|
17
|
-
export { useCurrency } from "@doswiftly/storefront-sdk/graphql/react";
|
|
18
|
-
|
|
19
|
-
// Re-export types from SDK
|
|
20
|
-
import type { PriceMoney, Money } from "@doswiftly/storefront-sdk/graphql";
|
|
21
|
-
export type { PriceMoney, Money };
|
|
22
|
-
|
|
23
|
-
// ============================================================================
|
|
24
|
-
// CONSTANTS
|
|
25
|
-
// ============================================================================
|
|
26
|
-
|
|
27
|
-
/** Currency symbols mapping */
|
|
28
|
-
export const CURRENCY_SYMBOLS: Record<string, string> = {
|
|
29
|
-
PLN: "zł",
|
|
30
|
-
EUR: "€",
|
|
31
|
-
USD: "$",
|
|
32
|
-
GBP: "£",
|
|
33
|
-
CHF: "CHF",
|
|
34
|
-
CZK: "Kč",
|
|
35
|
-
SEK: "kr",
|
|
36
|
-
NOK: "kr",
|
|
37
|
-
DKK: "kr",
|
|
38
|
-
JPY: "¥",
|
|
39
|
-
CNY: "¥",
|
|
40
|
-
AUD: "A$",
|
|
41
|
-
CAD: "C$",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/** Currency locale mapping for proper formatting */
|
|
45
|
-
export const CURRENCY_LOCALES: Record<string, string> = {
|
|
46
|
-
PLN: "pl-PL",
|
|
47
|
-
EUR: "de-DE",
|
|
48
|
-
USD: "en-US",
|
|
49
|
-
GBP: "en-GB",
|
|
50
|
-
CHF: "de-CH",
|
|
51
|
-
CZK: "cs-CZ",
|
|
52
|
-
SEK: "sv-SE",
|
|
53
|
-
NOK: "nb-NO",
|
|
54
|
-
DKK: "da-DK",
|
|
55
|
-
JPY: "ja-JP",
|
|
56
|
-
CNY: "zh-CN",
|
|
57
|
-
AUD: "en-AU",
|
|
58
|
-
CAD: "en-CA",
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// ============================================================================
|
|
62
|
-
// UTILITY FUNCTIONS
|
|
63
|
-
// ============================================================================
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get currency symbol
|
|
67
|
-
*/
|
|
68
|
-
export function getCurrencySymbol(code: string): string {
|
|
69
|
-
return CURRENCY_SYMBOLS[code] || code;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Format price for display
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```tsx
|
|
77
|
-
* const formatted = formatPrice(product.priceRange.minVariantPrice);
|
|
78
|
-
* // => "115,20 €"
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export function formatPrice(
|
|
82
|
-
price: PriceMoney | Money | null | undefined
|
|
83
|
-
): string {
|
|
84
|
-
if (!price) return "";
|
|
85
|
-
|
|
86
|
-
const amount = parseFloat(price.amount);
|
|
87
|
-
const code = price.currencyCode;
|
|
88
|
-
const locale = CURRENCY_LOCALES[code] || "en-US";
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
return new Intl.NumberFormat(locale, {
|
|
92
|
-
style: "currency",
|
|
93
|
-
currency: code,
|
|
94
|
-
minimumFractionDigits: 2,
|
|
95
|
-
maximumFractionDigits: 2,
|
|
96
|
-
}).format(amount);
|
|
97
|
-
} catch {
|
|
98
|
-
// Fallback formatting
|
|
99
|
-
const symbol = CURRENCY_SYMBOLS[code] || code;
|
|
100
|
-
return `${amount.toFixed(2)} ${symbol}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Format amount with currency
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```tsx
|
|
109
|
-
* const formatted = formatAmount("115.20", "EUR");
|
|
110
|
-
* // => "115,20 €"
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export function formatAmount(
|
|
114
|
-
amount: string | number,
|
|
115
|
-
currencyCode: string
|
|
116
|
-
): string {
|
|
117
|
-
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
118
|
-
const locale = CURRENCY_LOCALES[currencyCode] || "en-US";
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
return new Intl.NumberFormat(locale, {
|
|
122
|
-
style: "currency",
|
|
123
|
-
currency: currencyCode,
|
|
124
|
-
minimumFractionDigits: 2,
|
|
125
|
-
maximumFractionDigits: 2,
|
|
126
|
-
}).format(numAmount);
|
|
127
|
-
} catch {
|
|
128
|
-
const symbol = CURRENCY_SYMBOLS[currencyCode] || currencyCode;
|
|
129
|
-
return `${numAmount.toFixed(2)} ${symbol}`;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Get currency header for GraphQL requests
|
|
135
|
-
*/
|
|
136
|
-
export function getCurrencyHeader(currency: string): Record<string, string> {
|
|
137
|
-
return {
|
|
138
|
-
"x-preferred-currency": currency,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formatting Utilities
|
|
3
|
-
*
|
|
4
|
-
* @module storefront-nextjs/lib/format
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { PriceMoney, Money } from "@doswiftly/storefront-sdk/graphql";
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// CURRENCY DATA
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
/** Currency symbols mapping */
|
|
14
|
-
const CURRENCY_SYMBOLS: Record<string, string> = {
|
|
15
|
-
PLN: "zł",
|
|
16
|
-
EUR: "€",
|
|
17
|
-
USD: "$",
|
|
18
|
-
GBP: "£",
|
|
19
|
-
CHF: "CHF",
|
|
20
|
-
CZK: "Kč",
|
|
21
|
-
SEK: "kr",
|
|
22
|
-
NOK: "kr",
|
|
23
|
-
DKK: "kr",
|
|
24
|
-
JPY: "¥",
|
|
25
|
-
CNY: "¥",
|
|
26
|
-
AUD: "A$",
|
|
27
|
-
CAD: "C$",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/** Currency locale mapping for proper formatting */
|
|
31
|
-
const CURRENCY_LOCALES: Record<string, string> = {
|
|
32
|
-
PLN: "pl-PL",
|
|
33
|
-
EUR: "de-DE",
|
|
34
|
-
USD: "en-US",
|
|
35
|
-
GBP: "en-GB",
|
|
36
|
-
CHF: "de-CH",
|
|
37
|
-
CZK: "cs-CZ",
|
|
38
|
-
SEK: "sv-SE",
|
|
39
|
-
NOK: "nb-NO",
|
|
40
|
-
DKK: "da-DK",
|
|
41
|
-
JPY: "ja-JP",
|
|
42
|
-
CNY: "zh-CN",
|
|
43
|
-
AUD: "en-AU",
|
|
44
|
-
CAD: "en-CA",
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// FORMATTING FUNCTIONS
|
|
49
|
-
// ============================================================================
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Get currency symbol
|
|
53
|
-
*/
|
|
54
|
-
export function getCurrencySymbol(code: string): string {
|
|
55
|
-
return CURRENCY_SYMBOLS[code] || code;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get locale for currency
|
|
60
|
-
*/
|
|
61
|
-
export function getCurrencyLocale(code: string): string {
|
|
62
|
-
return CURRENCY_LOCALES[code] || "en-US";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Format a PriceMoney or Money object for display
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```tsx
|
|
70
|
-
* const price = product.priceRange.minVariantPrice;
|
|
71
|
-
* formatPrice(price); // "115,20 €"
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export function formatPrice(
|
|
75
|
-
price: PriceMoney | Money | null | undefined
|
|
76
|
-
): string {
|
|
77
|
-
if (!price) return "";
|
|
78
|
-
|
|
79
|
-
const amount = parseFloat(price.amount);
|
|
80
|
-
const code = price.currencyCode;
|
|
81
|
-
const locale = CURRENCY_LOCALES[code] || "en-US";
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
return new Intl.NumberFormat(locale, {
|
|
85
|
-
style: "currency",
|
|
86
|
-
currency: code,
|
|
87
|
-
minimumFractionDigits: 2,
|
|
88
|
-
maximumFractionDigits: 2,
|
|
89
|
-
}).format(amount);
|
|
90
|
-
} catch {
|
|
91
|
-
// Fallback formatting
|
|
92
|
-
const symbol = CURRENCY_SYMBOLS[code] || code;
|
|
93
|
-
return `${amount.toFixed(2)} ${symbol}`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Format amount with currency code
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```tsx
|
|
102
|
-
* formatAmount(99.99, "EUR"); // "99,99 €"
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
export function formatAmount(
|
|
106
|
-
amount: string | number,
|
|
107
|
-
currencyCode: string
|
|
108
|
-
): string {
|
|
109
|
-
const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
|
|
110
|
-
const locale = CURRENCY_LOCALES[currencyCode] || "en-US";
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
return new Intl.NumberFormat(locale, {
|
|
114
|
-
style: "currency",
|
|
115
|
-
currency: currencyCode,
|
|
116
|
-
minimumFractionDigits: 2,
|
|
117
|
-
maximumFractionDigits: 2,
|
|
118
|
-
}).format(numAmount);
|
|
119
|
-
} catch {
|
|
120
|
-
const symbol = CURRENCY_SYMBOLS[currencyCode] || currencyCode;
|
|
121
|
-
return `${numAmount.toFixed(2)} ${symbol}`;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Format price range for display
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```tsx
|
|
130
|
-
* formatPriceRange(minPrice, maxPrice);
|
|
131
|
-
* // "€99.00 - €199.00" or "€99.00" if same
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
export function formatPriceRange(
|
|
135
|
-
minPrice: PriceMoney | Money | null | undefined,
|
|
136
|
-
maxPrice: PriceMoney | Money | null | undefined
|
|
137
|
-
): string {
|
|
138
|
-
if (!minPrice) return "";
|
|
139
|
-
|
|
140
|
-
const min = formatPrice(minPrice);
|
|
141
|
-
const max = maxPrice ? formatPrice(maxPrice) : null;
|
|
142
|
-
|
|
143
|
-
if (!max || min === max) {
|
|
144
|
-
return min;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return `${min} - ${max}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Check if prices are different (for showing "From" prefix)
|
|
152
|
-
*/
|
|
153
|
-
export function hasPriceRange(
|
|
154
|
-
minPrice: PriceMoney | Money | null | undefined,
|
|
155
|
-
maxPrice: PriceMoney | Money | null | undefined
|
|
156
|
-
): boolean {
|
|
157
|
-
if (!minPrice || !maxPrice) return false;
|
|
158
|
-
return minPrice.amount !== maxPrice.amount;
|
|
159
|
-
}
|