@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.
Files changed (98) hide show
  1. package/dist/commands/check.js +2 -2
  2. package/dist/commands/deploy.d.ts.map +1 -1
  3. package/dist/commands/deploy.js +8 -5
  4. package/dist/commands/deploy.js.map +1 -1
  5. package/dist/commands/dev.d.ts +13 -0
  6. package/dist/commands/dev.d.ts.map +1 -1
  7. package/dist/commands/dev.js +155 -63
  8. package/dist/commands/dev.js.map +1 -1
  9. package/dist/commands/doctor.d.ts.map +1 -1
  10. package/dist/commands/doctor.js +3 -4
  11. package/dist/commands/doctor.js.map +1 -1
  12. package/dist/commands/init.d.ts.map +1 -1
  13. package/dist/commands/init.js +271 -166
  14. package/dist/commands/init.js.map +1 -1
  15. package/dist/commands/sdk.d.ts +1 -1
  16. package/dist/commands/sdk.js +3 -3
  17. package/dist/commands/sdk.js.map +1 -1
  18. package/dist/commands/template.d.ts.map +1 -1
  19. package/dist/commands/template.js +4 -31
  20. package/dist/commands/template.js.map +1 -1
  21. package/dist/commands/verify.js +5 -5
  22. package/dist/commands/verify.js.map +1 -1
  23. package/dist/index.js +2 -3
  24. package/dist/index.js.map +1 -1
  25. package/dist/lib/i18n.d.ts +12 -0
  26. package/dist/lib/i18n.d.ts.map +1 -1
  27. package/dist/lib/i18n.js +24 -0
  28. package/dist/lib/i18n.js.map +1 -1
  29. package/dist/lib/proxy-server.d.ts +22 -6
  30. package/dist/lib/proxy-server.d.ts.map +1 -1
  31. package/dist/lib/proxy-server.js +174 -75
  32. package/dist/lib/proxy-server.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/commands/types.d.ts +0 -5
  35. package/dist/commands/types.d.ts.map +0 -1
  36. package/dist/commands/types.js +0 -82
  37. package/dist/commands/types.js.map +0 -1
  38. package/templates/storefront-minimal/.env.example +0 -10
  39. package/templates/storefront-minimal/.github/workflows/build-template.yml +0 -119
  40. package/templates/storefront-minimal/app/globals.css +0 -18
  41. package/templates/storefront-minimal/app/layout.tsx +0 -26
  42. package/templates/storefront-minimal/app/page.tsx +0 -93
  43. package/templates/storefront-minimal/lib/graphql-client.ts +0 -23
  44. package/templates/storefront-minimal/next.config.ts +0 -15
  45. package/templates/storefront-minimal/open-next.config.ts +0 -3
  46. package/templates/storefront-minimal/package.json +0 -30
  47. package/templates/storefront-minimal/postcss.config.mjs +0 -5
  48. package/templates/storefront-minimal/tailwind.config.ts +0 -14
  49. package/templates/storefront-minimal/tsconfig.json +0 -27
  50. package/templates/storefront-minimal/wrangler.toml +0 -24
  51. package/templates/storefront-nextjs/.env.example +0 -68
  52. package/templates/storefront-nextjs/.github/workflows/build-template.yml +0 -119
  53. package/templates/storefront-nextjs/README.md +0 -524
  54. package/templates/storefront-nextjs/app/account/orders/page.tsx +0 -216
  55. package/templates/storefront-nextjs/app/account/page.tsx +0 -167
  56. package/templates/storefront-nextjs/app/auth/login/page.tsx +0 -135
  57. package/templates/storefront-nextjs/app/auth/register/page.tsx +0 -212
  58. package/templates/storefront-nextjs/app/cart/page.tsx +0 -263
  59. package/templates/storefront-nextjs/app/categories/[slug]/page.tsx +0 -200
  60. package/templates/storefront-nextjs/app/categories/page.tsx +0 -58
  61. package/templates/storefront-nextjs/app/checkout/page.tsx +0 -351
  62. package/templates/storefront-nextjs/app/collections/[slug]/page.tsx +0 -158
  63. package/templates/storefront-nextjs/app/collections/page.tsx +0 -61
  64. package/templates/storefront-nextjs/app/globals.css +0 -98
  65. package/templates/storefront-nextjs/app/layout.tsx +0 -39
  66. package/templates/storefront-nextjs/app/page.tsx +0 -136
  67. package/templates/storefront-nextjs/app/products/[slug]/page.tsx +0 -119
  68. package/templates/storefront-nextjs/app/products/page.tsx +0 -107
  69. package/templates/storefront-nextjs/app/search/page.tsx +0 -127
  70. package/templates/storefront-nextjs/components/auth/auth-guard.tsx +0 -94
  71. package/templates/storefront-nextjs/components/commerce/add-to-cart-button.tsx +0 -77
  72. package/templates/storefront-nextjs/components/commerce/cart-icon.tsx +0 -29
  73. package/templates/storefront-nextjs/components/commerce/currency-selector.tsx +0 -217
  74. package/templates/storefront-nextjs/components/commerce/pagination.tsx +0 -62
  75. package/templates/storefront-nextjs/components/commerce/product-actions.tsx +0 -135
  76. package/templates/storefront-nextjs/components/commerce/product-filters.tsx +0 -109
  77. package/templates/storefront-nextjs/components/commerce/product-price.tsx +0 -375
  78. package/templates/storefront-nextjs/components/commerce/search-input.tsx +0 -178
  79. package/templates/storefront-nextjs/components/commerce/sort-select.tsx +0 -64
  80. package/templates/storefront-nextjs/components/commerce/variant-selector.tsx +0 -210
  81. package/templates/storefront-nextjs/components/layout/footer.tsx +0 -107
  82. package/templates/storefront-nextjs/components/layout/header.tsx +0 -104
  83. package/templates/storefront-nextjs/components/providers.tsx +0 -62
  84. package/templates/storefront-nextjs/lib/auth/routes.ts +0 -52
  85. package/templates/storefront-nextjs/lib/currency.tsx +0 -140
  86. package/templates/storefront-nextjs/lib/format.ts +0 -159
  87. package/templates/storefront-nextjs/lib/graphql-queries.ts +0 -629
  88. package/templates/storefront-nextjs/lib/hooks.ts +0 -30
  89. package/templates/storefront-nextjs/middleware.ts +0 -80
  90. package/templates/storefront-nextjs/next.config.ts +0 -37
  91. package/templates/storefront-nextjs/open-next.config.ts +0 -3
  92. package/templates/storefront-nextjs/package.dev.json +0 -30
  93. package/templates/storefront-nextjs/package.json +0 -32
  94. package/templates/storefront-nextjs/package.json.template +0 -32
  95. package/templates/storefront-nextjs/postcss.config.mjs +0 -8
  96. package/templates/storefront-nextjs/tailwind.config.ts +0 -111
  97. package/templates/storefront-nextjs/tsconfig.json +0 -27
  98. package/templates/storefront-nextjs/wrangler.toml +0 -24
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAuCA;;GAEG;AACH,wBAAsB,iBAAiB,kBAuDtC"}
@@ -1,82 +0,0 @@
1
- import chalk from "chalk";
2
- import ora from "ora";
3
- import https from "https";
4
- import http from "http";
5
- import { existsSync, readFileSync } from "fs";
6
- /**
7
- * Fetch JSON from URL
8
- */
9
- async function fetchJson(url) {
10
- return new Promise((resolve, reject) => {
11
- const parsedUrl = new URL(url);
12
- const client = parsedUrl.protocol === "https:" ? https : http;
13
- const req = client.get(url, { timeout: 10000 }, (res) => {
14
- if (res.statusCode !== 200) {
15
- reject(new Error(`HTTP ${res.statusCode}`));
16
- return;
17
- }
18
- let data = "";
19
- res.on("data", (chunk) => (data += chunk));
20
- res.on("end", () => {
21
- try {
22
- resolve(JSON.parse(data));
23
- }
24
- catch (e) {
25
- reject(new Error("Invalid JSON response"));
26
- }
27
- });
28
- });
29
- req.on("error", reject);
30
- req.on("timeout", () => {
31
- req.destroy();
32
- reject(new Error("Request timeout"));
33
- });
34
- });
35
- }
36
- /**
37
- * Check Commerce SDK version against npm registry
38
- */
39
- export async function sdkVersionCommand() {
40
- console.log(chalk.bold.blue("\n📦 DoSwiftly Commerce SDK\n"));
41
- // Check if package.json exists
42
- if (!existsSync("package.json")) {
43
- console.log(chalk.red("✖ No package.json found\n"));
44
- console.log(chalk.gray(" Run this command from your project root.\n"));
45
- process.exit(1);
46
- }
47
- // Read package.json
48
- const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
49
- const installedVersion = pkg.dependencies?.["@doswiftly/storefront-sdk"];
50
- if (!installedVersion) {
51
- console.log(chalk.red("✖ @doswiftly/storefront-sdk not installed\n"));
52
- console.log(chalk.gray(" Install with: pnpm add @doswiftly/storefront-sdk\n"));
53
- process.exit(1);
54
- }
55
- const spinner = ora("Checking for updates...").start();
56
- try {
57
- // Fetch latest version from npm registry
58
- const response = await fetchJson("https://registry.npmjs.org/@doswiftly/storefront-sdk/latest");
59
- const latestVersion = response.version;
60
- spinner.stop();
61
- // Clean version strings (remove ^ and ~)
62
- const cleanInstalled = installedVersion.replace(/[\^~]/, "");
63
- console.log(` Installed: ${chalk.cyan(cleanInstalled)}`);
64
- console.log(` Latest: ${chalk.cyan(latestVersion)}`);
65
- console.log("");
66
- // Compare versions
67
- if (cleanInstalled === latestVersion) {
68
- console.log(chalk.green("✔ Commerce SDK is up to date!\n"));
69
- }
70
- else {
71
- console.log(chalk.yellow("⚠ Update available!\n"));
72
- console.log(chalk.gray(" Run: pnpm update @doswiftly/storefront-sdk@latest\n"));
73
- }
74
- }
75
- catch (error) {
76
- spinner.fail(chalk.red("Failed to check npm registry"));
77
- console.error(chalk.red(` ${error.message}\n`));
78
- console.log(chalk.gray(" Make sure you have internet connection.\n"));
79
- process.exit(1);
80
- }
81
- }
82
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE9C;;GAEG;AACH,KAAK,UAAU,SAAS,CAAI,GAAW;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAE9D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YACtD,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,UAAU,EAAE,CAAC,C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AAC,CAAC;YACnD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CAAC,uDAAuD,CAAC,CACpE,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAM,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,10 +0,0 @@
1
- # DoSwiftly Commerce - Environment Variables
2
- # Copy this file to .env.local and fill in your values
3
-
4
- # API Configuration (required)
5
- NEXT_PUBLIC_API_URL={{API_URL}}
6
- NEXT_PUBLIC_SHOP_SLUG={{SHOP_SLUG}}
7
-
8
- # Site Configuration (optional)
9
- NEXT_PUBLIC_SITE_URL=http://localhost:3000
10
- NEXT_PUBLIC_SITE_NAME={{PROJECT_NAME}}
@@ -1,119 +0,0 @@
1
- name: Build & Publish Template
2
-
3
- on:
4
- push:
5
- branches: [main, master]
6
- tags: ['v*']
7
- workflow_dispatch:
8
- inputs:
9
- version:
10
- description: 'Version to publish (e.g., 1.0.0)'
11
- required: false
12
-
13
- env:
14
- # Repository name (e.g., "default1", "minimal", "shadcn")
15
- # Worker will be named: storefront-template-{TEMPLATE_NAME}
16
- TEMPLATE_NAME: ${{ github.event.repository.name }}
17
-
18
- jobs:
19
- build:
20
- runs-on: ubuntu-latest
21
- steps:
22
- - uses: actions/checkout@v4
23
-
24
- - name: Normalize template name
25
- id: template
26
- run: |
27
- # Strip "storefront-" prefix if present
28
- RAW_NAME="${{ env.TEMPLATE_NAME }}"
29
- NORMALIZED="${RAW_NAME#storefront-}"
30
- echo "name=${NORMALIZED}" >> $GITHUB_OUTPUT
31
- echo "Template name: ${NORMALIZED}"
32
-
33
- - name: Setup Node.js
34
- uses: actions/setup-node@v4
35
- with:
36
- node-version: '20'
37
-
38
- - name: Setup pnpm
39
- uses: pnpm/action-setup@v4
40
- with:
41
- version: 9
42
-
43
- - name: Install dependencies
44
- run: pnpm install
45
-
46
- - name: Build for Cloudflare (OpenNext)
47
- run: npx @opennextjs/cloudflare build
48
-
49
- - name: List build output
50
- run: |
51
- echo "=== Build output ==="
52
- ls -la .open-next/ || echo "No .open-next directory"
53
- if [ -f ".open-next/worker.js" ]; then
54
- echo "Worker size: $(wc -c < .open-next/worker.js) bytes"
55
- fi
56
-
57
- - name: Create deployment wrangler.toml
58
- run: |
59
- cat > .open-next/wrangler.toml << EOF
60
- name = "storefront-template-${{ steps.template.outputs.name }}"
61
- main = "worker.js"
62
- compatibility_date = "2024-09-23"
63
- compatibility_flags = ["nodejs_compat"]
64
- assets = { directory = "assets", binding = "ASSETS" }
65
-
66
- [observability]
67
- enabled = true
68
- head_sampling_rate = 1
69
-
70
- [observability.logs]
71
- enabled = true
72
- head_sampling_rate = 1
73
- persist = true
74
- invocation_logs = true
75
- EOF
76
-
77
- - name: Determine version
78
- id: version
79
- run: |
80
- if [ -n "${{ github.event.inputs.version }}" ]; then
81
- echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
82
- elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
83
- echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
84
- else
85
- echo "version=$(jq -r .version package.json)-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
86
- fi
87
-
88
- - name: Deploy to Cloudflare Workers
89
- working-directory: .open-next
90
- env:
91
- CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
92
- CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
93
- run: |
94
- if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
95
- echo "⏭️ Skipping CF deploy (CLOUDFLARE_API_TOKEN not set)"
96
- exit 0
97
- fi
98
- npx wrangler@latest deploy
99
-
100
- - name: Upload worker bundle artifact
101
- uses: actions/upload-artifact@v4
102
- with:
103
- name: worker-bundle
104
- path: .open-next/
105
- retention-days: 7
106
- if-no-files-found: error
107
- include-hidden-files: true
108
-
109
- - name: Publish to DoSwiftly (on tag or manual)
110
- if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
111
- env:
112
- DOSWIFTLY_TOKEN: ${{ secrets.DOSWIFTLY_DEPLOY_TOKEN }}
113
- DOSWIFTLY_API_URL: ${{ secrets.DOSWIFTLY_API_URL }}
114
- run: |
115
- # Upload bundle to DoSwiftly R2 via API
116
- curl -X POST "${DOSWIFTLY_API_URL}/cli/templates/${{ steps.template.outputs.name }}/publish" \
117
- -H "Authorization: Bearer ${DOSWIFTLY_TOKEN}" \
118
- -F "bundle=@.open-next/worker.js" \
119
- -F "version=${{ steps.version.outputs.version }}"
@@ -1,18 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- :root {
4
- --foreground-rgb: 0, 0, 0;
5
- --background-rgb: 255, 255, 255;
6
- }
7
-
8
- @media (prefers-color-scheme: dark) {
9
- :root {
10
- --foreground-rgb: 255, 255, 255;
11
- --background-rgb: 0, 0, 0;
12
- }
13
- }
14
-
15
- body {
16
- color: rgb(var(--foreground-rgb));
17
- background: rgb(var(--background-rgb));
18
- }
@@ -1,26 +0,0 @@
1
- import type { Metadata } from 'next';
2
- import { Inter } from 'next/font/google';
3
- import './globals.css';
4
-
5
- const inter = Inter({ subsets: ['latin'] });
6
-
7
- const siteName = process.env.NEXT_PUBLIC_SITE_NAME || '{{PROJECT_NAME}}';
8
-
9
- export const metadata: Metadata = {
10
- title: `${siteName} - E-commerce Store`,
11
- description: 'Welcome to our online store powered by DoSwiftly Commerce',
12
- };
13
-
14
- export default function RootLayout({
15
- children,
16
- }: {
17
- children: React.ReactNode;
18
- }) {
19
- return (
20
- <html lang="en">
21
- <body className={inter.className}>
22
- <main className="min-h-screen">{children}</main>
23
- </body>
24
- </html>
25
- );
26
- }
@@ -1,93 +0,0 @@
1
- import { headers } from 'next/headers';
2
-
3
- // Shop configuration from Dispatch Worker headers
4
- interface ShopConfig {
5
- shopId: string;
6
- shopSlug: string;
7
- templateName: string;
8
- templateVersion: string;
9
- apiUrl: string;
10
- currency: string;
11
- }
12
-
13
- async function getShopConfig(): Promise<ShopConfig | null> {
14
- const headersList = await headers();
15
- const configHeader = headersList.get('x-shop-config');
16
-
17
- if (configHeader) {
18
- try {
19
- return JSON.parse(configHeader);
20
- } catch {
21
- return null;
22
- }
23
- }
24
-
25
- // Fallback to individual headers
26
- const shopSlug = headersList.get('x-shop-slug');
27
- const apiUrl = headersList.get('x-api-url');
28
-
29
- if (shopSlug) {
30
- return {
31
- shopId: headersList.get('x-shop-id') || '',
32
- shopSlug,
33
- templateName: 'unknown',
34
- templateVersion: 'unknown',
35
- apiUrl: apiUrl || process.env.NEXT_PUBLIC_API_URL || '',
36
- currency: 'PLN',
37
- };
38
- }
39
-
40
- // Development fallback to env vars
41
- return {
42
- shopId: '',
43
- shopSlug: process.env.NEXT_PUBLIC_SHOP_SLUG || '',
44
- templateName: 'development',
45
- templateVersion: '0.0.0',
46
- apiUrl: process.env.NEXT_PUBLIC_API_URL || '',
47
- currency: 'PLN',
48
- };
49
- }
50
-
51
- export default async function Home() {
52
- const config = await getShopConfig();
53
-
54
- return (
55
- <div className="flex flex-col items-center justify-center min-h-screen p-8">
56
- <h1 className="text-4xl font-bold mb-4">Welcome to your storefront</h1>
57
- <p className="text-lg text-gray-600 mb-8">
58
- Your DoSwiftly Commerce storefront is ready to be customized.
59
- </p>
60
-
61
- <div className="bg-gray-100 dark:bg-gray-800 rounded-lg p-6 max-w-md w-full">
62
- <h2 className="text-xl font-semibold mb-4">Configuration</h2>
63
- <dl className="space-y-2">
64
- <div>
65
- <dt className="text-sm text-gray-500">Shop Slug</dt>
66
- <dd className="font-mono text-sm">{config?.shopSlug || 'Not configured'}</dd>
67
- </div>
68
- <div>
69
- <dt className="text-sm text-gray-500">API URL</dt>
70
- <dd className="font-mono text-sm">{config?.apiUrl || 'Not configured'}</dd>
71
- </div>
72
- <div>
73
- <dt className="text-sm text-gray-500">Template</dt>
74
- <dd className="font-mono text-sm">{config?.templateName} v{config?.templateVersion}</dd>
75
- </div>
76
- <div>
77
- <dt className="text-sm text-gray-500">Currency</dt>
78
- <dd className="font-mono text-sm">{config?.currency}</dd>
79
- </div>
80
- </dl>
81
- </div>
82
-
83
- <div className="mt-8 text-center">
84
- <p className="text-sm text-gray-500 mb-4">Next steps:</p>
85
- <ul className="text-sm text-gray-600 space-y-1">
86
- <li>1. Build your storefront components</li>
87
- <li>2. Connect to the GraphQL API</li>
88
- <li>3. Customize the design</li>
89
- </ul>
90
- </div>
91
- </div>
92
- );
93
- }
@@ -1,23 +0,0 @@
1
- import { GraphQLClient } from 'graphql-request';
2
-
3
- const API_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.doswiftly.pl';
4
- const SHOP_SLUG = process.env.NEXT_PUBLIC_SHOP_SLUG || '';
5
-
6
- /**
7
- * GraphQL client for the Storefront API
8
- */
9
- export const graphqlClient = new GraphQLClient(`${API_URL}/storefront-graphql`, {
10
- headers: {
11
- 'x-shop-slug': SHOP_SLUG,
12
- },
13
- });
14
-
15
- /**
16
- * Execute a GraphQL query
17
- */
18
- export async function executeQuery<TData, TVariables extends Record<string, unknown>>(
19
- document: { toString(): string },
20
- variables?: TVariables
21
- ): Promise<TData> {
22
- return graphqlClient.request<TData>(document.toString(), variables);
23
- }
@@ -1,15 +0,0 @@
1
- import type { NextConfig } from 'next';
2
-
3
- const nextConfig: NextConfig = {
4
- reactStrictMode: true,
5
- images: {
6
- remotePatterns: [
7
- {
8
- protocol: 'https',
9
- hostname: '**.doswiftly.pl',
10
- },
11
- ],
12
- },
13
- };
14
-
15
- export default nextConfig;
@@ -1,3 +0,0 @@
1
- import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2
-
3
- export default defineCloudflareConfig({});
@@ -1,30 +0,0 @@
1
- {
2
- "name": "{{PROJECT_NAME}}",
3
- "version": "0.1.0",
4
- "private": true,
5
- "scripts": {
6
- "dev": "next dev",
7
- "build": "next build",
8
- "build:cf": "npx @opennextjs/cloudflare build",
9
- "start": "next start",
10
- "lint": "next lint"
11
- },
12
- "dependencies": {
13
- "graphql": "^16.10.0",
14
- "graphql-request": "^7.1.2",
15
- "next": "^15.1.9",
16
- "react": "^19.0.0",
17
- "react-dom": "^19.0.0"
18
- },
19
- "devDependencies": {
20
- "@opennextjs/cloudflare": "^1.0.0",
21
- "@types/node": "^22.0.0",
22
- "@types/react": "^19.0.0",
23
- "@types/react-dom": "^19.0.0",
24
- "typescript": "^5.7.0",
25
- "@tailwindcss/postcss": "^4.0.0",
26
- "tailwindcss": "^4.0.0",
27
- "eslint": "^9.0.0",
28
- "eslint-config-next": "^15.1.9"
29
- }
30
- }
@@ -1,5 +0,0 @@
1
- export default {
2
- plugins: {
3
- '@tailwindcss/postcss': {},
4
- },
5
- };
@@ -1,14 +0,0 @@
1
- import type { Config } from 'tailwindcss';
2
-
3
- const config: Config = {
4
- content: [
5
- './app/**/*.{js,ts,jsx,tsx,mdx}',
6
- './components/**/*.{js,ts,jsx,tsx,mdx}',
7
- ],
8
- theme: {
9
- extend: {},
10
- },
11
- plugins: [],
12
- };
13
-
14
- export default config;
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["dom", "dom.iterable", "esnext"],
4
- "allowJs": true,
5
- "skipLibCheck": true,
6
- "strict": true,
7
- "noEmit": true,
8
- "esModuleInterop": true,
9
- "module": "esnext",
10
- "moduleResolution": "bundler",
11
- "resolveJsonModule": true,
12
- "isolatedModules": true,
13
- "jsx": "preserve",
14
- "incremental": true,
15
- "plugins": [
16
- {
17
- "name": "next"
18
- }
19
- ],
20
- "paths": {
21
- "@/*": ["./*"]
22
- },
23
- "target": "ES2017"
24
- },
25
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
- "exclude": ["node_modules"]
27
- }
@@ -1,24 +0,0 @@
1
- #:schema node_modules/wrangler/config-schema.json
2
-
3
- name = "storefront-template-{{PROJECT_NAME}}"
4
- main = ".open-next/worker.js"
5
- compatibility_date = "2024-09-23"
6
- compatibility_flags = ["nodejs_compat"]
7
-
8
- # Assets directory for static files
9
- assets = { directory = ".open-next/assets", binding = "ASSETS" }
10
-
11
- # Cloudflare Images binding for Next.js /_next/image optimization
12
- [images]
13
- binding = "IMAGES"
14
-
15
- # Observability — logs persisted in Cloudflare Dashboard
16
- [observability]
17
- enabled = true
18
- head_sampling_rate = 1
19
-
20
- [observability.logs]
21
- enabled = true
22
- head_sampling_rate = 1
23
- persist = true
24
- invocation_logs = true
@@ -1,68 +0,0 @@
1
- # ===========================================
2
- # DoSwiftly Commerce - Environment Variables
3
- # ===========================================
4
- # Copy this file to .env.local and fill in your values
5
- # Get these values from your DoSwiftly dashboard
6
-
7
- # ===========================================
8
- # Required: API Configuration
9
- # ===========================================
10
-
11
- # DoSwiftly API URL
12
- # Default: https://api.doswiftly.pl
13
- # For local development, use your local backend URL
14
- NEXT_PUBLIC_API_URL={{API_URL}}
15
-
16
- # Your Shop Slug (unique identifier)
17
- # This is the unique identifier for your shop used by the Storefront GraphQL API
18
- # Find this in your DoSwiftly dashboard under Shop Settings
19
- # Example: my-awesome-shop
20
- NEXT_PUBLIC_SHOP_SLUG={{SHOP_SLUG}}
21
-
22
- # Storefront Access Token (optional, for private storefronts)
23
- # Leave empty for public storefront access
24
- # NEXT_PUBLIC_STOREFRONT_TOKEN=
25
-
26
- # ===========================================
27
- # Optional: Site Configuration
28
- # ===========================================
29
-
30
- # Site URL (used for SEO and social sharing)
31
- NEXT_PUBLIC_SITE_URL=http://localhost:3000
32
-
33
- # Site Name (displayed in browser tab and SEO)
34
- NEXT_PUBLIC_SITE_NAME={{PROJECT_NAME}}
35
-
36
- # ===========================================
37
- # Optional: Analytics & Tracking
38
- # ===========================================
39
-
40
- # Google Analytics Measurement ID
41
- # NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX
42
-
43
- # Facebook Pixel ID
44
- # NEXT_PUBLIC_FB_PIXEL_ID=
45
-
46
- # ===========================================
47
- # Optional: Payment Configuration
48
- # ===========================================
49
-
50
- # Stripe Publishable Key (for client-side Stripe.js)
51
- # NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
52
-
53
- # PayU POS ID (for PayU integration)
54
- # NEXT_PUBLIC_PAYU_POS_ID=
55
-
56
- # ===========================================
57
- # Server-side Only (do not prefix with NEXT_PUBLIC_)
58
- # ===========================================
59
-
60
- # DoSwiftly API Key (for server-side operations)
61
- # Keep this secret! Never expose in client-side code
62
- # DOSWIFTLY_API_KEY=
63
-
64
- # Stripe Secret Key (for server-side Stripe operations)
65
- # STRIPE_SECRET_KEY=sk_test_...
66
-
67
- # Webhook Secret (for verifying webhook signatures)
68
- # WEBHOOK_SECRET=