@forgecart/cli 1.0.0 → 1.1.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/LICENSE +21 -0
- package/README.md +7 -7
- package/bin/forgecart.js +1 -1
- package/dist/package.json +50 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/{cli.js → src/cli.js} +8 -6
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/delete.d.ts.map +1 -0
- package/dist/{commands → src/commands}/delete.js +8 -3
- package/dist/src/commands/delete.js.map +1 -0
- package/dist/src/commands/deploy.d.ts.map +1 -0
- package/dist/src/commands/deploy.js +243 -0
- package/dist/src/commands/deploy.js.map +1 -0
- package/dist/src/commands/env.d.ts.map +1 -0
- package/dist/{commands → src/commands}/env.js +70 -12
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/{commands → src/commands}/init.js +103 -17
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/list.d.ts.map +1 -0
- package/dist/{commands → src/commands}/list.js +6 -2
- package/dist/src/commands/list.js.map +1 -0
- package/dist/src/commands/login.d.ts +3 -0
- package/dist/src/commands/login.d.ts.map +1 -0
- package/dist/src/commands/login.js +120 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/logs.d.ts.map +1 -0
- package/dist/src/commands/logs.js +88 -0
- package/dist/src/commands/logs.js.map +1 -0
- package/dist/src/commands/scale.d.ts.map +1 -0
- package/dist/{commands → src/commands}/scale.js +7 -3
- package/dist/src/commands/scale.js.map +1 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/{commands → src/commands}/status.js +7 -2
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/whoami.d.ts.map +1 -0
- package/dist/{commands → src/commands}/whoami.js +20 -7
- package/dist/src/commands/whoami.js.map +1 -0
- package/dist/{index.d.ts.map → src/index.d.ts.map} +1 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +34 -0
- package/dist/src/lib/api-client.d.ts.map +1 -0
- package/dist/src/lib/api-client.js +141 -0
- package/dist/src/lib/api-client.js.map +1 -0
- package/dist/{lib → src/lib}/archive.d.ts +2 -1
- package/dist/src/lib/archive.d.ts.map +1 -0
- package/dist/{lib → src/lib}/archive.js +27 -5
- package/dist/src/lib/archive.js.map +1 -0
- package/dist/src/lib/config-updater.d.ts +10 -0
- package/dist/src/lib/config-updater.d.ts.map +1 -0
- package/dist/src/lib/config-updater.js +34 -0
- package/dist/src/lib/config-updater.js.map +1 -0
- package/dist/src/lib/config.d.ts +53 -0
- package/dist/src/lib/config.d.ts.map +1 -0
- package/dist/src/lib/config.js +162 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/env-sync.d.ts +44 -0
- package/dist/src/lib/env-sync.d.ts.map +1 -0
- package/dist/src/lib/env-sync.js +207 -0
- package/dist/src/lib/env-sync.js.map +1 -0
- package/dist/src/lib/logger.d.ts.map +1 -0
- package/dist/src/lib/logger.js.map +1 -0
- package/dist/src/lib/nx-generator.d.ts +22 -0
- package/dist/src/lib/nx-generator.d.ts.map +1 -0
- package/dist/src/lib/nx-generator.js +345 -0
- package/dist/src/lib/nx-generator.js.map +1 -0
- package/dist/src/lib/standalone.d.ts +28 -0
- package/dist/src/lib/standalone.d.ts.map +1 -0
- package/dist/src/lib/standalone.js +107 -0
- package/dist/src/lib/standalone.js.map +1 -0
- package/dist/{types → src/types}/index.d.ts +10 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/spinner.d.ts +16 -0
- package/dist/src/utils/spinner.d.ts.map +1 -0
- package/dist/src/utils/spinner.js +88 -0
- package/dist/src/utils/spinner.js.map +1 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/{utils → src/utils}/validation.js +18 -2
- package/dist/src/utils/validation.js.map +1 -0
- package/dist/templates/application-additions/.forgecartignore +1 -1
- package/dist/templates/application-additions/Procfile +1 -1
- package/dist/templates/application-additions/src/app/app.module.ts +16 -0
- package/dist/templates/application-additions/src/services/forgecart.service.ts +62 -0
- package/dist/templates/application-additions/src/services/index.ts +2 -0
- package/dist/templates/application-additions/src/services/product-event-listener.service.ts +150 -0
- package/dist/templates/application-e2e-additions/src/support/global-setup.ts +16 -0
- package/dist/templates/application-e2e-additions/src/support/test-setup.ts +9 -0
- package/dist/templates/storefront-additions/.forgecartignore +30 -6
- package/dist/templates/storefront-additions/Procfile +1 -1
- package/dist/templates/storefront-additions/package.json +11 -0
- package/dist/templates/storefront-additions/postcss.config.js +5 -0
- package/dist/templates/storefront-additions/src/app/cart/page.tsx +77 -0
- package/dist/templates/storefront-additions/src/app/global.css +1 -0
- package/dist/templates/storefront-additions/src/app/layout.tsx +25 -0
- package/dist/templates/storefront-additions/src/app/page.tsx +43 -0
- package/dist/templates/storefront-additions/src/components/AddToCartButton.tsx +29 -0
- package/dist/templates/storefront-additions/src/components/CartItem.tsx +82 -0
- package/dist/templates/storefront-additions/src/components/Header.tsx +42 -0
- package/dist/templates/storefront-additions/src/components/ProductCard.tsx +57 -0
- package/dist/templates/storefront-additions/src/components/QuantitySelector.tsx +35 -0
- package/dist/templates/storefront-additions/src/context/CartContext.tsx +158 -0
- package/dist/templates/storefront-additions/src/lib/forgecart.ts +19 -8
- package/dist/templates/storefront-additions/tailwind.config.js +8 -0
- package/dist/templates/storefront-e2e-additions/playwright.config.ts +26 -0
- package/dist/templates/storefront-e2e-additions/src/example.spec.ts +11 -0
- package/dist/templates/workspace/.nxignore +2 -0
- package/package.json +6 -28
- package/templates/application-additions/.forgecartignore +1 -1
- package/templates/application-additions/Procfile +1 -1
- package/templates/application-additions/src/app/app.module.ts +16 -0
- package/templates/application-additions/src/services/forgecart.service.ts +62 -0
- package/templates/application-additions/src/services/index.ts +2 -0
- package/templates/application-additions/src/services/product-event-listener.service.ts +150 -0
- package/templates/application-e2e-additions/src/support/global-setup.ts +16 -0
- package/templates/application-e2e-additions/src/support/test-setup.ts +9 -0
- package/templates/storefront-additions/.forgecartignore +30 -6
- package/templates/storefront-additions/Procfile +1 -1
- package/templates/storefront-additions/package.json +11 -0
- package/templates/storefront-additions/postcss.config.js +5 -0
- package/templates/storefront-additions/src/app/cart/page.tsx +77 -0
- package/templates/storefront-additions/src/app/global.css +1 -0
- package/templates/storefront-additions/src/app/layout.tsx +25 -0
- package/templates/storefront-additions/src/app/page.tsx +43 -0
- package/templates/storefront-additions/src/components/AddToCartButton.tsx +29 -0
- package/templates/storefront-additions/src/components/CartItem.tsx +82 -0
- package/templates/storefront-additions/src/components/Header.tsx +42 -0
- package/templates/storefront-additions/src/components/ProductCard.tsx +57 -0
- package/templates/storefront-additions/src/components/QuantitySelector.tsx +35 -0
- package/templates/storefront-additions/src/context/CartContext.tsx +158 -0
- package/templates/storefront-additions/src/lib/forgecart.ts +19 -8
- package/templates/storefront-additions/tailwind.config.js +8 -0
- package/templates/storefront-e2e-additions/playwright.config.ts +26 -0
- package/templates/storefront-e2e-additions/src/example.spec.ts +11 -0
- package/templates/workspace/.nxignore +2 -0
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/delete.d.ts.map +0 -1
- package/dist/commands/delete.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -128
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/env.d.ts.map +0 -1
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list.d.ts.map +0 -1
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/logs.d.ts.map +0 -1
- package/dist/commands/logs.js +0 -105
- package/dist/commands/logs.js.map +0 -1
- package/dist/commands/scale.d.ts.map +0 -1
- package/dist/commands/scale.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/api-client.d.ts +0 -21
- package/dist/lib/api-client.d.ts.map +0 -1
- package/dist/lib/api-client.js +0 -220
- package/dist/lib/api-client.js.map +0 -1
- package/dist/lib/archive.d.ts.map +0 -1
- package/dist/lib/archive.js.map +0 -1
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -79
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/logger.d.ts.map +0 -1
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/nx-generator.d.ts +0 -8
- package/dist/lib/nx-generator.d.ts.map +0 -1
- package/dist/lib/nx-generator.js +0 -146
- package/dist/lib/nx-generator.js.map +0 -1
- package/dist/templates/application-additions/src/services/price-fetcher.service.ts +0 -72
- package/dist/templates/storefront-additions/src/app/products/page.tsx +0 -78
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/utils/spinner.d.ts +0 -4
- package/dist/utils/spinner.d.ts.map +0 -1
- package/dist/utils/spinner.js +0 -20
- package/dist/utils/spinner.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
- package/templates/application-additions/src/services/price-fetcher.service.ts +0 -72
- package/templates/storefront-additions/src/app/products/page.tsx +0 -78
- /package/dist/{cli.d.ts → src/cli.d.ts} +0 -0
- /package/dist/{commands → src/commands}/delete.d.ts +0 -0
- /package/dist/{commands → src/commands}/deploy.d.ts +0 -0
- /package/dist/{commands → src/commands}/env.d.ts +0 -0
- /package/dist/{commands → src/commands}/init.d.ts +0 -0
- /package/dist/{commands → src/commands}/list.d.ts +0 -0
- /package/dist/{commands → src/commands}/logs.d.ts +0 -0
- /package/dist/{commands → src/commands}/scale.d.ts +0 -0
- /package/dist/{commands → src/commands}/status.d.ts +0 -0
- /package/dist/{commands → src/commands}/whoami.d.ts +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{lib → src/lib}/logger.d.ts +0 -0
- /package/dist/{lib → src/lib}/logger.js +0 -0
- /package/dist/{types → src/types}/index.js +0 -0
- /package/dist/{utils → src/utils}/validation.d.ts +0 -0
package/dist/lib/nx-generator.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import logger from './logger.js';
|
|
5
|
-
async function runCommand(command, args, cwd, silent = false) {
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
const child = spawn(command, args, {
|
|
8
|
-
cwd,
|
|
9
|
-
shell: true,
|
|
10
|
-
stdio: silent ? 'pipe' : 'inherit',
|
|
11
|
-
});
|
|
12
|
-
let output = '';
|
|
13
|
-
let error = '';
|
|
14
|
-
if (silent) {
|
|
15
|
-
child.stdout?.on('data', (data) => {
|
|
16
|
-
output += data.toString();
|
|
17
|
-
});
|
|
18
|
-
child.stderr?.on('data', (data) => {
|
|
19
|
-
error += data.toString();
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
child.on('close', (code) => {
|
|
23
|
-
resolve({
|
|
24
|
-
success: code === 0,
|
|
25
|
-
output,
|
|
26
|
-
error,
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
child.on('error', (err) => {
|
|
30
|
-
resolve({
|
|
31
|
-
success: false,
|
|
32
|
-
output,
|
|
33
|
-
error: err.message,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export async function createNxWorkspace(projectName, targetDir) {
|
|
39
|
-
logger.info(`Creating NX workspace: ${projectName}`);
|
|
40
|
-
const result = await runCommand('npx', [
|
|
41
|
-
'create-nx-workspace@latest',
|
|
42
|
-
projectName,
|
|
43
|
-
'--preset=apps',
|
|
44
|
-
'--nxCloud=skip',
|
|
45
|
-
'--packageManager=npm',
|
|
46
|
-
], targetDir);
|
|
47
|
-
if (!result.success) {
|
|
48
|
-
logger.error('Failed to create NX workspace');
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
export async function generateNextApp(appName, projectRoot) {
|
|
54
|
-
logger.info(`Generating Next.js application: ${appName}`);
|
|
55
|
-
const result = await runCommand('npx', ['nx', 'g', '@nx/next:application', appName, '--style=css', '--appDir=true'], projectRoot);
|
|
56
|
-
if (!result.success) {
|
|
57
|
-
logger.error('Failed to generate Next.js application');
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
export async function generateNestApp(appName, projectRoot) {
|
|
63
|
-
logger.info(`Generating NestJS application: ${appName}`);
|
|
64
|
-
const result = await runCommand('npx', ['nx', 'g', '@nx/nest:application', appName], projectRoot);
|
|
65
|
-
if (!result.success) {
|
|
66
|
-
logger.error('Failed to generate NestJS application');
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
export async function installDependency(packageName, projectRoot, dev = false) {
|
|
72
|
-
logger.info(`Installing ${packageName}`);
|
|
73
|
-
const args = ['install', packageName];
|
|
74
|
-
if (dev) {
|
|
75
|
-
args.push('--save-dev');
|
|
76
|
-
}
|
|
77
|
-
const result = await runCommand('npm', args, projectRoot);
|
|
78
|
-
if (!result.success) {
|
|
79
|
-
logger.error(`Failed to install ${packageName}`);
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
export async function runNxBuild(appName, projectRoot) {
|
|
85
|
-
logger.info(`Building ${appName}`);
|
|
86
|
-
const result = await runCommand('npx', ['nx', 'build', appName], projectRoot);
|
|
87
|
-
if (!result.success) {
|
|
88
|
-
logger.error(`Failed to build ${appName}`);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
export function copyTemplateFiles(templateDir, targetDir, overwrite = true) {
|
|
94
|
-
if (!fs.existsSync(templateDir)) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const files = getAllFiles(templateDir);
|
|
98
|
-
for (const file of files) {
|
|
99
|
-
const relativePath = path.relative(templateDir, file);
|
|
100
|
-
const targetPath = path.join(targetDir, relativePath);
|
|
101
|
-
const targetDirPath = path.dirname(targetPath);
|
|
102
|
-
if (!fs.existsSync(targetDirPath)) {
|
|
103
|
-
fs.mkdirSync(targetDirPath, { recursive: true });
|
|
104
|
-
}
|
|
105
|
-
if (overwrite || !fs.existsSync(targetPath)) {
|
|
106
|
-
fs.copyFileSync(file, targetPath);
|
|
107
|
-
logger.debug(`Copied: ${relativePath}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function getAllFiles(dir) {
|
|
112
|
-
const files = [];
|
|
113
|
-
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
114
|
-
for (const item of items) {
|
|
115
|
-
const fullPath = path.join(dir, item.name);
|
|
116
|
-
if (item.isDirectory()) {
|
|
117
|
-
files.push(...getAllFiles(fullPath));
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
files.push(fullPath);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return files;
|
|
124
|
-
}
|
|
125
|
-
export function getCliTemplatesDir() {
|
|
126
|
-
// When running from CLI package, templates can be in different locations:
|
|
127
|
-
// 1. Development: apps/cli/templates (relative to src/lib)
|
|
128
|
-
// 2. Installed: dist/templates (relative to dist/lib)
|
|
129
|
-
const currentFileUrl = new URL(import.meta.url);
|
|
130
|
-
const currentFilePath = currentFileUrl.pathname;
|
|
131
|
-
const libDir = path.dirname(currentFilePath);
|
|
132
|
-
// Try dist/templates first (installed package)
|
|
133
|
-
const distTemplatesPath = path.resolve(libDir, '..', 'templates');
|
|
134
|
-
if (fs.existsSync(distTemplatesPath)) {
|
|
135
|
-
return distTemplatesPath;
|
|
136
|
-
}
|
|
137
|
-
// Try apps/cli/templates (development)
|
|
138
|
-
const devTemplatesPath = path.resolve(libDir, '..', '..', 'templates');
|
|
139
|
-
if (fs.existsSync(devTemplatesPath)) {
|
|
140
|
-
return devTemplatesPath;
|
|
141
|
-
}
|
|
142
|
-
// Fallback - try to find templates directory
|
|
143
|
-
logger.warn('Templates directory not found, using fallback path');
|
|
144
|
-
return devTemplatesPath;
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=nx-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nx-generator.js","sourceRoot":"","sources":["../../src/lib/nx-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,MAAM,MAAM,aAAa,CAAA;AAQhC,KAAK,UAAU,UAAU,CACvB,OAAe,EACf,IAAc,EACd,GAAW,EACX,MAAM,GAAG,KAAK;IAEd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,GAAG;YACH,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACnC,CAAC,CAAA;QAEF,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI,KAAK,GAAG,EAAE,CAAA;QAEd,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAA;YAC3B,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAA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AC,gBAAgB,CAAC,EAAE,CAAC;QACpC,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,6CAA6C;IAC7C,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IACjE,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0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ACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB"}
|
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,2CAAyB,CAAA;IACzB,6CAA2B,CAAA;AAC7B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,uCAAmB,CAAA;AACrB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B"}
|
package/dist/utils/spinner.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/utils/spinner.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAK/C;AAED,wBAAsB,WAAW,CAAC,CAAC,EACjC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAWZ"}
|
package/dist/utils/spinner.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import ora from 'ora';
|
|
2
|
-
export function createSpinner(text) {
|
|
3
|
-
return ora({
|
|
4
|
-
text,
|
|
5
|
-
spinner: 'dots',
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export async function withSpinner(text, successText, failText, fn) {
|
|
9
|
-
const spinner = createSpinner(text).start();
|
|
10
|
-
try {
|
|
11
|
-
const result = await fn();
|
|
12
|
-
spinner.succeed(successText);
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
spinner.fail(failText);
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=spinner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/utils/spinner.ts"],"names":[],"mappings":"AAAA,OAAO,GAAY,MAAM,KAAK,CAAA;AAE9B,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,GAAG,CAAC;QACT,IAAI;QACJ,OAAO,EAAE,MAAM;KAChB,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAY,EACZ,WAAmB,EACnB,QAAgB,EAChB,EAAoB;IAEpB,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;IAE3C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;QACzB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC5B,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACtB,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAiCpE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAGlF;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAGpF;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,IAAI,EAAE,cAAc,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,IAAI,CAcP"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,gEAAgE;IAChE,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GA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,EAAE,IAAI,EAAE,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;IACxD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|