@forgecart/cli 1.0.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 (93) hide show
  1. package/README.md +179 -0
  2. package/bin/forgecart.js +3 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +30 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/delete.d.ts +3 -0
  8. package/dist/commands/delete.d.ts.map +1 -0
  9. package/dist/commands/delete.js +55 -0
  10. package/dist/commands/delete.js.map +1 -0
  11. package/dist/commands/deploy.d.ts +3 -0
  12. package/dist/commands/deploy.d.ts.map +1 -0
  13. package/dist/commands/deploy.js +128 -0
  14. package/dist/commands/deploy.js.map +1 -0
  15. package/dist/commands/env.d.ts +3 -0
  16. package/dist/commands/env.d.ts.map +1 -0
  17. package/dist/commands/env.js +100 -0
  18. package/dist/commands/env.js.map +1 -0
  19. package/dist/commands/init.d.ts +4 -0
  20. package/dist/commands/init.d.ts.map +1 -0
  21. package/dist/commands/init.js +233 -0
  22. package/dist/commands/init.js.map +1 -0
  23. package/dist/commands/list.d.ts +3 -0
  24. package/dist/commands/list.d.ts.map +1 -0
  25. package/dist/commands/list.js +61 -0
  26. package/dist/commands/list.js.map +1 -0
  27. package/dist/commands/logs.d.ts +3 -0
  28. package/dist/commands/logs.d.ts.map +1 -0
  29. package/dist/commands/logs.js +105 -0
  30. package/dist/commands/logs.js.map +1 -0
  31. package/dist/commands/scale.d.ts +3 -0
  32. package/dist/commands/scale.d.ts.map +1 -0
  33. package/dist/commands/scale.js +45 -0
  34. package/dist/commands/scale.js.map +1 -0
  35. package/dist/commands/status.d.ts +3 -0
  36. package/dist/commands/status.d.ts.map +1 -0
  37. package/dist/commands/status.js +85 -0
  38. package/dist/commands/status.js.map +1 -0
  39. package/dist/commands/whoami.d.ts +3 -0
  40. package/dist/commands/whoami.d.ts.map +1 -0
  41. package/dist/commands/whoami.js +46 -0
  42. package/dist/commands/whoami.js.map +1 -0
  43. package/dist/index.d.ts +3 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +5 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/lib/api-client.d.ts +21 -0
  48. package/dist/lib/api-client.d.ts.map +1 -0
  49. package/dist/lib/api-client.js +220 -0
  50. package/dist/lib/api-client.js.map +1 -0
  51. package/dist/lib/archive.d.ts +8 -0
  52. package/dist/lib/archive.d.ts.map +1 -0
  53. package/dist/lib/archive.js +96 -0
  54. package/dist/lib/archive.js.map +1 -0
  55. package/dist/lib/config.d.ts +12 -0
  56. package/dist/lib/config.d.ts.map +1 -0
  57. package/dist/lib/config.js +79 -0
  58. package/dist/lib/config.js.map +1 -0
  59. package/dist/lib/logger.d.ts +15 -0
  60. package/dist/lib/logger.d.ts.map +1 -0
  61. package/dist/lib/logger.js +54 -0
  62. package/dist/lib/logger.js.map +1 -0
  63. package/dist/lib/nx-generator.d.ts +8 -0
  64. package/dist/lib/nx-generator.d.ts.map +1 -0
  65. package/dist/lib/nx-generator.js +146 -0
  66. package/dist/lib/nx-generator.js.map +1 -0
  67. package/dist/templates/application-additions/.forgecartignore +37 -0
  68. package/dist/templates/application-additions/Procfile +1 -0
  69. package/dist/templates/application-additions/src/services/price-fetcher.service.ts +72 -0
  70. package/dist/templates/storefront-additions/.forgecartignore +40 -0
  71. package/dist/templates/storefront-additions/Procfile +1 -0
  72. package/dist/templates/storefront-additions/src/app/products/page.tsx +78 -0
  73. package/dist/templates/storefront-additions/src/lib/forgecart.ts +11 -0
  74. package/dist/types/index.d.ts +70 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +14 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/dist/utils/spinner.d.ts +4 -0
  79. package/dist/utils/spinner.d.ts.map +1 -0
  80. package/dist/utils/spinner.js +20 -0
  81. package/dist/utils/spinner.js.map +1 -0
  82. package/dist/utils/validation.d.ts +12 -0
  83. package/dist/utils/validation.d.ts.map +1 -0
  84. package/dist/utils/validation.js +66 -0
  85. package/dist/utils/validation.js.map +1 -0
  86. package/package.json +52 -0
  87. package/templates/application-additions/.forgecartignore +37 -0
  88. package/templates/application-additions/Procfile +1 -0
  89. package/templates/application-additions/src/services/price-fetcher.service.ts +72 -0
  90. package/templates/storefront-additions/.forgecartignore +40 -0
  91. package/templates/storefront-additions/Procfile +1 -0
  92. package/templates/storefront-additions/src/app/products/page.tsx +78 -0
  93. package/templates/storefront-additions/src/lib/forgecart.ts +11 -0
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@forgecart/cli",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "CLI tool for deploying applications to ForgéCart",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "forgecart": "./bin/forgecart.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "ts-node --esm src/index.ts",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "bin",
18
+ "templates"
19
+ ],
20
+ "dependencies": {
21
+ "archiver": "^7.0.1",
22
+ "chalk": "^5.3.0",
23
+ "cli-table3": "^0.6.5",
24
+ "commander": "^12.1.0",
25
+ "form-data": "^4.0.0",
26
+ "graphql": "^16.8.1",
27
+ "graphql-request": "^6.1.0",
28
+ "inquirer": "^9.2.23",
29
+ "node-fetch": "^3.3.2",
30
+ "ora": "^8.0.1",
31
+ "ws": "^8.17.1"
32
+ },
33
+ "devDependencies": {
34
+ "@types/archiver": "^6.0.2",
35
+ "@types/inquirer": "^9.0.7",
36
+ "@types/node": "^20.11.5",
37
+ "@types/ws": "^8.5.10",
38
+ "typescript": "^5.9.3"
39
+ },
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ },
43
+ "keywords": [
44
+ "forgecart",
45
+ "cli",
46
+ "deploy",
47
+ "paas",
48
+ "nodejs"
49
+ ],
50
+ "author": "ForgéCart",
51
+ "license": "MIT"
52
+ }
@@ -0,0 +1,37 @@
1
+ # ForgéCart deployment ignore file
2
+ # Files and directories listed here will not be uploaded during deployment
3
+
4
+ # Dependencies (will be installed during build)
5
+ node_modules/
6
+
7
+ # Development files
8
+ .git/
9
+ .gitignore
10
+ .env
11
+ .env.local
12
+ .env.development
13
+
14
+ # IDE
15
+ .idea/
16
+ .vscode/
17
+ *.swp
18
+ *.swo
19
+
20
+ # Build artifacts (we build on the server)
21
+ dist/
22
+
23
+ # Test files
24
+ __tests__/
25
+ test/
26
+ *.test.ts
27
+ *.spec.ts
28
+ coverage/
29
+
30
+ # Documentation
31
+ README.md
32
+ CHANGELOG.md
33
+ docs/
34
+
35
+ # OS files
36
+ .DS_Store
37
+ Thumbs.db
@@ -0,0 +1 @@
1
+ web: npm run start:prod
@@ -0,0 +1,72 @@
1
+ import { Injectable, OnModuleInit } from '@nestjs/common'
2
+ import { ForgecartClient } from '@forgecart/sdk'
3
+
4
+ // Example service demonstrating ForgéCart SDK integration
5
+ // This can be used for custom backend tasks like:
6
+ // - Scheduled price updates
7
+ // - Inventory synchronization
8
+ // - Custom order processing
9
+ // - Third-party integrations
10
+
11
+ @Injectable()
12
+ export class PriceFetcherService implements OnModuleInit {
13
+ private client: ForgecartClient
14
+
15
+ onModuleInit() {
16
+ this.client = new ForgecartClient({
17
+ channelToken: process.env.FORGECART_CHANNEL_TOKEN || '',
18
+ apiUrl: process.env.FORGECART_API_URL || 'https://api.forgecart.com',
19
+ })
20
+ }
21
+
22
+ async getProductPrices(productIds: string[]): Promise<
23
+ Array<{
24
+ productId: string
25
+ name: string
26
+ price: number
27
+ currencyCode: string
28
+ }>
29
+ > {
30
+ const prices = []
31
+
32
+ for (const productId of productIds) {
33
+ try {
34
+ const product = await this.client.shop.products.get(productId)
35
+ if (product && product.variants?.[0]) {
36
+ prices.push({
37
+ productId,
38
+ name: product.name,
39
+ price: product.variants[0].price,
40
+ currencyCode: product.variants[0].currencyCode,
41
+ })
42
+ }
43
+ } catch (error) {
44
+ console.error(`Failed to fetch price for product ${productId}:`, error)
45
+ }
46
+ }
47
+
48
+ return prices
49
+ }
50
+
51
+ async syncInventory(): Promise<{ synced: number; errors: number }> {
52
+ // Example: Sync inventory with external system
53
+ // This is a placeholder for custom business logic
54
+ let synced = 0
55
+ let errors = 0
56
+
57
+ try {
58
+ const products = await this.client.shop.products.list({ take: 100 })
59
+
60
+ for (const product of products.items || []) {
61
+ // Here you would implement your custom sync logic
62
+ // e.g., update external ERP, sync with warehouse system, etc.
63
+ synced++
64
+ }
65
+ } catch (error) {
66
+ console.error('Inventory sync failed:', error)
67
+ errors++
68
+ }
69
+
70
+ return { synced, errors }
71
+ }
72
+ }
@@ -0,0 +1,40 @@
1
+ # ForgéCart deployment ignore file
2
+ # Files and directories listed here will not be uploaded during deployment
3
+
4
+ # Dependencies (will be installed during build)
5
+ node_modules/
6
+
7
+ # Development files
8
+ .git/
9
+ .gitignore
10
+ .env
11
+ .env.local
12
+ .env.development
13
+ .env.development.local
14
+
15
+ # IDE
16
+ .idea/
17
+ .vscode/
18
+ *.swp
19
+ *.swo
20
+
21
+ # Build artifacts (we build on the server)
22
+ .next/
23
+ out/
24
+
25
+ # Test files
26
+ __tests__/
27
+ *.test.ts
28
+ *.test.tsx
29
+ *.spec.ts
30
+ *.spec.tsx
31
+ coverage/
32
+
33
+ # Documentation
34
+ README.md
35
+ CHANGELOG.md
36
+ docs/
37
+
38
+ # OS files
39
+ .DS_Store
40
+ Thumbs.db
@@ -0,0 +1 @@
1
+ web: npm run start
@@ -0,0 +1,78 @@
1
+ import forgecart from '../../lib/forgecart'
2
+
3
+ // Example product page using ForgéCart SDK
4
+ // This demonstrates how to fetch and display products
5
+
6
+ interface Product {
7
+ id: string
8
+ name: string
9
+ slug: string
10
+ description: string
11
+ featuredAsset?: {
12
+ preview: string
13
+ }
14
+ variants: Array<{
15
+ id: string
16
+ name: string
17
+ price: number
18
+ currencyCode: string
19
+ }>
20
+ }
21
+
22
+ async function getProducts(): Promise<Product[]> {
23
+ try {
24
+ // Fetch products from ForgéCart API
25
+ const result = await forgecart.shop.products.list({
26
+ take: 12,
27
+ })
28
+ return result.items || []
29
+ } catch (error) {
30
+ console.error('Failed to fetch products:', error)
31
+ return []
32
+ }
33
+ }
34
+
35
+ export default async function ProductsPage() {
36
+ const products = await getProducts()
37
+
38
+ return (
39
+ <div className="container mx-auto px-4 py-8">
40
+ <h1 className="text-3xl font-bold mb-8">Products</h1>
41
+
42
+ {products.length === 0 ? (
43
+ <p className="text-gray-600">
44
+ No products found. Make sure your ForgéCart channel is configured correctly.
45
+ </p>
46
+ ) : (
47
+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
48
+ {products.map((product) => (
49
+ <div
50
+ key={product.id}
51
+ className="border rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-shadow"
52
+ >
53
+ {product.featuredAsset && (
54
+ <img
55
+ src={product.featuredAsset.preview}
56
+ alt={product.name}
57
+ className="w-full h-48 object-cover"
58
+ />
59
+ )}
60
+ <div className="p-4">
61
+ <h2 className="text-lg font-semibold mb-2">{product.name}</h2>
62
+ <p className="text-gray-600 text-sm mb-3 line-clamp-2">
63
+ {product.description}
64
+ </p>
65
+ {product.variants[0] && (
66
+ <p className="text-lg font-bold text-blue-600">
67
+ {(product.variants[0].price / 100).toFixed(2)}{' '}
68
+ {product.variants[0].currencyCode}
69
+ </p>
70
+ )}
71
+ </div>
72
+ </div>
73
+ ))}
74
+ </div>
75
+ )}
76
+ </div>
77
+ )
78
+ }
@@ -0,0 +1,11 @@
1
+ import { ForgecartClient } from '@forgecart/sdk'
2
+
3
+ // Initialize the ForgéCart SDK client
4
+ // The channel token is read from environment variables
5
+ export const forgecart = new ForgecartClient({
6
+ channelToken: process.env.FORGECART_CHANNEL_TOKEN || '',
7
+ apiUrl: process.env.FORGECART_API_URL || 'https://api.forgecart.com',
8
+ })
9
+
10
+ // Export for use in server components
11
+ export default forgecart