@varity-labs/sdk 2.0.0-alpha.1
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 +31 -0
- package/README.md +253 -0
- package/dist/analytics/index.d.ts +7 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/tracker.d.ts +128 -0
- package/dist/analytics/tracker.d.ts.map +1 -0
- package/dist/analytics/tracker.js +203 -0
- package/dist/blockchain/BlockchainService.d.ts +100 -0
- package/dist/blockchain/BlockchainService.d.ts.map +1 -0
- package/dist/blockchain/BlockchainService.js +188 -0
- package/dist/blockchain/NFTLicensingService.d.ts +69 -0
- package/dist/blockchain/NFTLicensingService.d.ts.map +1 -0
- package/dist/blockchain/NFTLicensingService.js +136 -0
- package/dist/blockchain/RevenueSplitService.d.ts +71 -0
- package/dist/blockchain/RevenueSplitService.d.ts.map +1 -0
- package/dist/blockchain/RevenueSplitService.js +111 -0
- package/dist/blockchain/index.d.ts +48 -0
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +46 -0
- package/dist/blockchain/types.d.ts +63 -0
- package/dist/blockchain/types.d.ts.map +1 -0
- package/dist/blockchain/types.js +6 -0
- package/dist/chains/arbitrum.d.ts +89 -0
- package/dist/chains/arbitrum.d.ts.map +1 -0
- package/dist/chains/arbitrum.js +134 -0
- package/dist/chains/base.d.ts +84 -0
- package/dist/chains/base.d.ts.map +1 -0
- package/dist/chains/base.js +131 -0
- package/dist/chains/index.d.ts +36 -0
- package/dist/chains/index.d.ts.map +1 -0
- package/dist/chains/index.js +32 -0
- package/dist/chains/registry.d.ts +113 -0
- package/dist/chains/registry.d.ts.map +1 -0
- package/dist/chains/registry.js +201 -0
- package/dist/chains/varityL3.d.ts +81 -0
- package/dist/chains/varityL3.d.ts.map +1 -0
- package/dist/chains/varityL3.js +125 -0
- package/dist/cli/commands/clone.d.ts +8 -0
- package/dist/cli/commands/clone.d.ts.map +1 -0
- package/dist/cli/commands/clone.js +391 -0
- package/dist/cli/commands/dev.d.ts +8 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +40 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +303 -0
- package/dist/cli/commands/init.d.ts +8 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +317 -0
- package/dist/cli/commands/validate.d.ts +8 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +69 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +33 -0
- package/dist/cli/utils/logger.d.ts +17 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +35 -0
- package/dist/cli/utils/prompts.d.ts +21 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/prompts.js +103 -0
- package/dist/contracts/abis/iso/AccessControlRegistry.json +1468 -0
- package/dist/contracts/abis/iso/DataProofRegistry.json +797 -0
- package/dist/contracts/abis/iso/MerchantRegistry.json +1237 -0
- package/dist/contracts/abis/iso/RepPerformance.json +1351 -0
- package/dist/contracts/abis/iso/ResidualCalculator.json +1118 -0
- package/dist/contracts/abis/iso/TransactionVault.json +1588 -0
- package/dist/contracts/abis/iso/VarityWalletFactory.json +475 -0
- package/dist/contracts/addresses.d.ts +88 -0
- package/dist/contracts/addresses.d.ts.map +1 -0
- package/dist/contracts/addresses.js +94 -0
- package/dist/contracts/index.d.ts +7 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +6 -0
- package/dist/core/VaritySDK.d.ts +177 -0
- package/dist/core/VaritySDK.d.ts.map +1 -0
- package/dist/core/VaritySDK.js +325 -0
- package/dist/core/config.d.ts +120 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +187 -0
- package/dist/core/credentials-proxy.d.ts +157 -0
- package/dist/core/credentials-proxy.d.ts.map +1 -0
- package/dist/core/credentials-proxy.js +345 -0
- package/dist/core/credentials.d.ts +219 -0
- package/dist/core/credentials.d.ts.map +1 -0
- package/dist/core/credentials.js +345 -0
- package/dist/core/template-loader.d.ts +15 -0
- package/dist/core/template-loader.d.ts.map +1 -0
- package/dist/core/template-loader.js +380 -0
- package/dist/core/template.d.ts +321 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +189 -0
- package/dist/core/types.d.ts +572 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +52 -0
- package/dist/dev/dev-server.d.ts +16 -0
- package/dist/dev/dev-server.d.ts.map +1 -0
- package/dist/dev/dev-server.js +119 -0
- package/dist/generators/contracts/generator.d.ts +21 -0
- package/dist/generators/contracts/generator.d.ts.map +1 -0
- package/dist/generators/contracts/generator.js +252 -0
- package/dist/generators/tests/generator.d.ts +20 -0
- package/dist/generators/tests/generator.d.ts.map +1 -0
- package/dist/generators/tests/generator.js +375 -0
- package/dist/generators/types/generator.d.ts +19 -0
- package/dist/generators/types/generator.d.ts.map +1 -0
- package/dist/generators/types/generator.js +165 -0
- package/dist/generators/ui/component-generator.d.ts +20 -0
- package/dist/generators/ui/component-generator.d.ts.map +1 -0
- package/dist/generators/ui/component-generator.js +749 -0
- package/dist/generators/ui/dashboard-generator.d.ts +20 -0
- package/dist/generators/ui/dashboard-generator.d.ts.map +1 -0
- package/dist/generators/ui/dashboard-generator.js +349 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/modules/analytics/AnalyticsModule.d.ts +349 -0
- package/dist/modules/analytics/AnalyticsModule.d.ts.map +1 -0
- package/dist/modules/analytics/AnalyticsModule.js +274 -0
- package/dist/modules/analytics/index.d.ts +3 -0
- package/dist/modules/analytics/index.d.ts.map +1 -0
- package/dist/modules/analytics/index.js +1 -0
- package/dist/modules/auth/AccessKeyModule.d.ts +189 -0
- package/dist/modules/auth/AccessKeyModule.d.ts.map +1 -0
- package/dist/modules/auth/AccessKeyModule.js +322 -0
- package/dist/modules/auth/AuthModule.d.ts +133 -0
- package/dist/modules/auth/AuthModule.d.ts.map +1 -0
- package/dist/modules/auth/AuthModule.js +214 -0
- package/dist/modules/auth/index.d.ts +8 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +6 -0
- package/dist/modules/cache/CacheModule.d.ts +279 -0
- package/dist/modules/cache/CacheModule.d.ts.map +1 -0
- package/dist/modules/cache/CacheModule.js +493 -0
- package/dist/modules/cache/index.d.ts +3 -0
- package/dist/modules/cache/index.d.ts.map +1 -0
- package/dist/modules/cache/index.js +1 -0
- package/dist/modules/compute/ComputeModule.d.ts +226 -0
- package/dist/modules/compute/ComputeModule.d.ts.map +1 -0
- package/dist/modules/compute/ComputeModule.js +379 -0
- package/dist/modules/compute/index.d.ts +6 -0
- package/dist/modules/compute/index.d.ts.map +1 -0
- package/dist/modules/compute/index.js +4 -0
- package/dist/modules/contracts/ContractsModule.d.ts +164 -0
- package/dist/modules/contracts/ContractsModule.d.ts.map +1 -0
- package/dist/modules/contracts/ContractsModule.js +242 -0
- package/dist/modules/contracts/index.d.ts +6 -0
- package/dist/modules/contracts/index.d.ts.map +1 -0
- package/dist/modules/contracts/index.js +4 -0
- package/dist/modules/export/ExportModule.d.ts +346 -0
- package/dist/modules/export/ExportModule.d.ts.map +1 -0
- package/dist/modules/export/ExportModule.js +432 -0
- package/dist/modules/export/index.d.ts +3 -0
- package/dist/modules/export/index.d.ts.map +1 -0
- package/dist/modules/export/index.js +1 -0
- package/dist/modules/forecasting/ForecastingModule.d.ts +579 -0
- package/dist/modules/forecasting/ForecastingModule.d.ts.map +1 -0
- package/dist/modules/forecasting/ForecastingModule.js +310 -0
- package/dist/modules/forecasting/index.d.ts +3 -0
- package/dist/modules/forecasting/index.d.ts.map +1 -0
- package/dist/modules/forecasting/index.js +1 -0
- package/dist/modules/monitoring/MonitoringModule.d.ts +359 -0
- package/dist/modules/monitoring/MonitoringModule.d.ts.map +1 -0
- package/dist/modules/monitoring/MonitoringModule.js +483 -0
- package/dist/modules/monitoring/index.d.ts +3 -0
- package/dist/modules/monitoring/index.d.ts.map +1 -0
- package/dist/modules/monitoring/index.js +1 -0
- package/dist/modules/notifications/NotificationsModule.d.ts +336 -0
- package/dist/modules/notifications/NotificationsModule.d.ts.map +1 -0
- package/dist/modules/notifications/NotificationsModule.js +418 -0
- package/dist/modules/notifications/index.d.ts +3 -0
- package/dist/modules/notifications/index.d.ts.map +1 -0
- package/dist/modules/notifications/index.js +1 -0
- package/dist/modules/oracle/OracleModule.d.ts +110 -0
- package/dist/modules/oracle/OracleModule.d.ts.map +1 -0
- package/dist/modules/oracle/OracleModule.js +151 -0
- package/dist/modules/oracle/index.d.ts +6 -0
- package/dist/modules/oracle/index.d.ts.map +1 -0
- package/dist/modules/oracle/index.js +4 -0
- package/dist/modules/storage/S3Module.d.ts +377 -0
- package/dist/modules/storage/S3Module.d.ts.map +1 -0
- package/dist/modules/storage/S3Module.js +680 -0
- package/dist/modules/storage/StorageModule.d.ts +157 -0
- package/dist/modules/storage/StorageModule.d.ts.map +1 -0
- package/dist/modules/storage/StorageModule.js +302 -0
- package/dist/modules/storage/adapters/AdapterFactory.d.ts +100 -0
- package/dist/modules/storage/adapters/AdapterFactory.d.ts.map +1 -0
- package/dist/modules/storage/adapters/AdapterFactory.js +209 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.d.ts +94 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.js +263 -0
- package/dist/modules/storage/adapters/IStorageAdapter.d.ts +287 -0
- package/dist/modules/storage/adapters/IStorageAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/IStorageAdapter.js +81 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.d.ts +187 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.js +430 -0
- package/dist/modules/storage/adapters/index.d.ts +12 -0
- package/dist/modules/storage/adapters/index.d.ts.map +1 -0
- package/dist/modules/storage/adapters/index.js +12 -0
- package/dist/modules/storage/index.d.ts +16 -0
- package/dist/modules/storage/index.d.ts.map +1 -0
- package/dist/modules/storage/index.js +15 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.d.ts +227 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.d.ts.map +1 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.js +367 -0
- package/dist/modules/storage/tiering/CostOptimizer.d.ts +248 -0
- package/dist/modules/storage/tiering/CostOptimizer.d.ts.map +1 -0
- package/dist/modules/storage/tiering/CostOptimizer.js +356 -0
- package/dist/modules/storage/tiering/MetadataStore.d.ts +287 -0
- package/dist/modules/storage/tiering/MetadataStore.d.ts.map +1 -0
- package/dist/modules/storage/tiering/MetadataStore.js +535 -0
- package/dist/modules/storage/tiering/TieringEngine.d.ts +237 -0
- package/dist/modules/storage/tiering/TieringEngine.d.ts.map +1 -0
- package/dist/modules/storage/tiering/TieringEngine.js +419 -0
- package/dist/modules/storage/tiering/example.d.ts +8 -0
- package/dist/modules/storage/tiering/example.d.ts.map +1 -0
- package/dist/modules/storage/tiering/example.js +250 -0
- package/dist/modules/storage/tiering/index.d.ts +17 -0
- package/dist/modules/storage/tiering/index.d.ts.map +1 -0
- package/dist/modules/storage/tiering/index.js +13 -0
- package/dist/modules/webhooks/WebhooksModule.d.ts +476 -0
- package/dist/modules/webhooks/WebhooksModule.d.ts.map +1 -0
- package/dist/modules/webhooks/WebhooksModule.js +359 -0
- package/dist/modules/webhooks/index.d.ts +3 -0
- package/dist/modules/webhooks/index.d.ts.map +1 -0
- package/dist/modules/webhooks/index.js +1 -0
- package/dist/modules/zk/ZKModule.d.ts +153 -0
- package/dist/modules/zk/ZKModule.d.ts.map +1 -0
- package/dist/modules/zk/ZKModule.js +262 -0
- package/dist/modules/zk/index.d.ts +7 -0
- package/dist/modules/zk/index.d.ts.map +1 -0
- package/dist/modules/zk/index.js +4 -0
- package/dist/thirdweb/BridgeClient.d.ts +228 -0
- package/dist/thirdweb/BridgeClient.d.ts.map +1 -0
- package/dist/thirdweb/BridgeClient.js +160 -0
- package/dist/thirdweb/EngineClient.d.ts +396 -0
- package/dist/thirdweb/EngineClient.d.ts.map +1 -0
- package/dist/thirdweb/EngineClient.js +386 -0
- package/dist/thirdweb/GatewayClient.d.ts +190 -0
- package/dist/thirdweb/GatewayClient.d.ts.map +1 -0
- package/dist/thirdweb/GatewayClient.js +257 -0
- package/dist/thirdweb/NebulaClient.d.ts +292 -0
- package/dist/thirdweb/NebulaClient.d.ts.map +1 -0
- package/dist/thirdweb/NebulaClient.js +180 -0
- package/dist/thirdweb/StorageClient.d.ts +445 -0
- package/dist/thirdweb/StorageClient.d.ts.map +1 -0
- package/dist/thirdweb/StorageClient.js +405 -0
- package/dist/thirdweb/ThirdwebWrapper.d.ts +236 -0
- package/dist/thirdweb/ThirdwebWrapper.d.ts.map +1 -0
- package/dist/thirdweb/ThirdwebWrapper.js +332 -0
- package/dist/thirdweb/index.d.ts +21 -0
- package/dist/thirdweb/index.d.ts.map +1 -0
- package/dist/thirdweb/index.js +28 -0
- package/dist/thirdweb/varity-chain.d.ts +48 -0
- package/dist/thirdweb/varity-chain.d.ts.map +1 -0
- package/dist/thirdweb/varity-chain.js +64 -0
- package/dist/thirdweb/x402Client.d.ts +319 -0
- package/dist/thirdweb/x402Client.d.ts.map +1 -0
- package/dist/thirdweb/x402Client.js +223 -0
- package/dist/tracking/gasTracker.d.ts +158 -0
- package/dist/tracking/gasTracker.d.ts.map +1 -0
- package/dist/tracking/gasTracker.js +227 -0
- package/dist/tracking/index.d.ts +10 -0
- package/dist/tracking/index.d.ts.map +1 -0
- package/dist/tracking/index.js +8 -0
- package/dist/tracking/types.d.ts +327 -0
- package/dist/tracking/types.d.ts.map +1 -0
- package/dist/tracking/types.js +8 -0
- package/dist/ui/components/ChartWidget.d.ts +36 -0
- package/dist/ui/components/ChartWidget.d.ts.map +1 -0
- package/dist/ui/components/ChartWidget.js +82 -0
- package/dist/ui/components/DashboardLayout.d.ts +41 -0
- package/dist/ui/components/DashboardLayout.d.ts.map +1 -0
- package/dist/ui/components/DashboardLayout.js +102 -0
- package/dist/ui/components/DataTable.d.ts +49 -0
- package/dist/ui/components/DataTable.d.ts.map +1 -0
- package/dist/ui/components/DataTable.js +96 -0
- package/dist/ui/components/EntityForm.d.ts +60 -0
- package/dist/ui/components/EntityForm.d.ts.map +1 -0
- package/dist/ui/components/EntityForm.js +182 -0
- package/dist/ui/components/KPICard.d.ts +29 -0
- package/dist/ui/components/KPICard.d.ts.map +1 -0
- package/dist/ui/components/KPICard.js +61 -0
- package/dist/ui/components/Modal.d.ts +34 -0
- package/dist/ui/components/Modal.d.ts.map +1 -0
- package/dist/ui/components/Modal.js +30 -0
- package/dist/ui/components/index.d.ts +18 -0
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/ui/components/index.js +11 -0
- package/dist/validation/template-validator.d.ts +25 -0
- package/dist/validation/template-validator.d.ts.map +1 -0
- package/dist/validation/template-validator.js +305 -0
- package/package.json +102 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* varity clone - Clone existing template
|
|
3
|
+
*
|
|
4
|
+
* Quickly create new template from existing one
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { Logger } from '../utils/logger';
|
|
10
|
+
import inquirer from 'inquirer';
|
|
11
|
+
export const cloneCommand = new Command('clone')
|
|
12
|
+
.description('Clone an existing template to create a new one')
|
|
13
|
+
.option('--from <template>', 'Source template name')
|
|
14
|
+
.option('--to <name>', 'New template name')
|
|
15
|
+
.option('-d, --dir <directory>', 'Output directory', '.')
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
try {
|
|
18
|
+
Logger.header('📋 Clone Template');
|
|
19
|
+
// Get source and destination if not provided
|
|
20
|
+
let sourceTemplate = options.from;
|
|
21
|
+
let newTemplateName = options.to;
|
|
22
|
+
if (!sourceTemplate || !newTemplateName) {
|
|
23
|
+
const answers = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: 'input',
|
|
26
|
+
name: 'sourceTemplate',
|
|
27
|
+
message: 'Source template to clone from (e.g., iso, healthcare):',
|
|
28
|
+
when: !sourceTemplate,
|
|
29
|
+
validate: (input) => {
|
|
30
|
+
if (!input || input.trim().length === 0) {
|
|
31
|
+
return 'Source template is required';
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'input',
|
|
38
|
+
name: 'newTemplateName',
|
|
39
|
+
message: 'New template name:',
|
|
40
|
+
when: !newTemplateName,
|
|
41
|
+
validate: (input) => {
|
|
42
|
+
if (!input || input.trim().length === 0) {
|
|
43
|
+
return 'New template name is required';
|
|
44
|
+
}
|
|
45
|
+
if (!/^[a-z][a-z0-9-]*$/.test(input)) {
|
|
46
|
+
return 'Template name must be lowercase letters, numbers, and hyphens only';
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
sourceTemplate = sourceTemplate || answers.sourceTemplate;
|
|
53
|
+
newTemplateName = newTemplateName || answers.newTemplateName;
|
|
54
|
+
}
|
|
55
|
+
const outputDir = path.join(options.dir, newTemplateName);
|
|
56
|
+
// Check if output directory already exists
|
|
57
|
+
if (fs.existsSync(outputDir)) {
|
|
58
|
+
Logger.error(`Directory ${outputDir} already exists`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
Logger.step(1, 5, `Locating source template: ${sourceTemplate}...`);
|
|
62
|
+
// Find source template
|
|
63
|
+
const sourceTemplatePath = findSourceTemplate(sourceTemplate);
|
|
64
|
+
if (!sourceTemplatePath) {
|
|
65
|
+
Logger.error(`Source template "${sourceTemplate}" not found`);
|
|
66
|
+
Logger.info('Available templates in SDK:');
|
|
67
|
+
Logger.code(' - iso');
|
|
68
|
+
Logger.newline();
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
Logger.step(2, 5, 'Copying template structure...');
|
|
72
|
+
// Create output directory
|
|
73
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
74
|
+
// Copy and transform template JSON
|
|
75
|
+
const templateJson = loadAndTransformTemplate(path.join(sourceTemplatePath, `${sourceTemplate}.template.json`), sourceTemplate, newTemplateName);
|
|
76
|
+
// Create project structure
|
|
77
|
+
createProjectStructure(outputDir);
|
|
78
|
+
// Write transformed template
|
|
79
|
+
const templatesDir = path.join(outputDir, 'templates');
|
|
80
|
+
fs.mkdirSync(templatesDir, { recursive: true });
|
|
81
|
+
fs.writeFileSync(path.join(templatesDir, `${newTemplateName}.template.json`), JSON.stringify(templateJson, null, 2));
|
|
82
|
+
Logger.step(3, 5, 'Generating environment configuration...');
|
|
83
|
+
generateEnvFile(outputDir, newTemplateName, templateJson.api?.basePath);
|
|
84
|
+
Logger.step(4, 5, 'Creating package.json...');
|
|
85
|
+
generatePackageJson(outputDir, newTemplateName, templateJson.description);
|
|
86
|
+
Logger.step(5, 5, 'Creating README.md...');
|
|
87
|
+
generateReadme(outputDir, newTemplateName, templateJson);
|
|
88
|
+
Logger.newline();
|
|
89
|
+
Logger.success(`Template cloned successfully from "${sourceTemplate}" to "${newTemplateName}"!`);
|
|
90
|
+
Logger.newline();
|
|
91
|
+
Logger.info('Next steps:');
|
|
92
|
+
Logger.code(` cd ${newTemplateName}`);
|
|
93
|
+
Logger.code(` npm install`);
|
|
94
|
+
Logger.code(` # Edit templates/${newTemplateName}.template.json to customize entities`);
|
|
95
|
+
Logger.code(` varity generate contracts`);
|
|
96
|
+
Logger.code(` varity generate ui`);
|
|
97
|
+
Logger.code(` varity generate dashboard`);
|
|
98
|
+
Logger.code(` varity dev --watch`);
|
|
99
|
+
Logger.newline();
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
Logger.error(`Failed to clone template: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Find source template in SDK
|
|
108
|
+
*/
|
|
109
|
+
function findSourceTemplate(templateName) {
|
|
110
|
+
// Check in SDK templates directory
|
|
111
|
+
const sdkTemplatesPath = path.join(__dirname, '..', '..', '..', 'templates');
|
|
112
|
+
const templatePath = path.join(sdkTemplatesPath, `${templateName}.template.json`);
|
|
113
|
+
if (fs.existsSync(templatePath)) {
|
|
114
|
+
return sdkTemplatesPath;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Load and transform template JSON
|
|
120
|
+
*/
|
|
121
|
+
function loadAndTransformTemplate(sourcePath, sourceTemplate, newTemplate) {
|
|
122
|
+
const content = fs.readFileSync(sourcePath, 'utf-8');
|
|
123
|
+
const template = JSON.parse(content);
|
|
124
|
+
// Transform template
|
|
125
|
+
template.type = newTemplate;
|
|
126
|
+
template.name = `${capitalize(newTemplate)} Business Template`;
|
|
127
|
+
template.description = `${capitalize(newTemplate)} business template (cloned from ${sourceTemplate})`;
|
|
128
|
+
// Update storage namespaces
|
|
129
|
+
if (template.storage) {
|
|
130
|
+
if (template.storage.varityNamespace) {
|
|
131
|
+
template.storage.varityNamespace = template.storage.varityNamespace.replace(sourceTemplate, newTemplate);
|
|
132
|
+
}
|
|
133
|
+
if (template.storage.industryNamespace) {
|
|
134
|
+
template.storage.industryNamespace = template.storage.industryNamespace.replace(sourceTemplate, newTemplate);
|
|
135
|
+
}
|
|
136
|
+
if (template.storage.customerNamespacePattern) {
|
|
137
|
+
template.storage.customerNamespacePattern = template.storage.customerNamespacePattern.replace(sourceTemplate, newTemplate);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Update API base path
|
|
141
|
+
if (template.api) {
|
|
142
|
+
template.api.basePath = `/api/v1/${newTemplate}`;
|
|
143
|
+
}
|
|
144
|
+
// Update contract ABIs paths (only if they're strings)
|
|
145
|
+
if (template.contracts) {
|
|
146
|
+
template.contracts = template.contracts.map(contract => ({
|
|
147
|
+
...contract,
|
|
148
|
+
abi: typeof contract.abi === 'string'
|
|
149
|
+
? contract.abi.replace(sourceTemplate, newTemplate)
|
|
150
|
+
: contract.abi
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
return template;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create project structure
|
|
157
|
+
*/
|
|
158
|
+
function createProjectStructure(baseDir) {
|
|
159
|
+
const dirs = [
|
|
160
|
+
path.join(baseDir, 'contracts'),
|
|
161
|
+
path.join(baseDir, 'contracts', 'abis'),
|
|
162
|
+
path.join(baseDir, 'templates'),
|
|
163
|
+
path.join(baseDir, 'scripts'),
|
|
164
|
+
path.join(baseDir, 'test'),
|
|
165
|
+
path.join(baseDir, 'src'),
|
|
166
|
+
path.join(baseDir, 'src', 'components'),
|
|
167
|
+
path.join(baseDir, 'src', 'hooks'),
|
|
168
|
+
path.join(baseDir, 'src', 'services')
|
|
169
|
+
];
|
|
170
|
+
dirs.forEach(dir => {
|
|
171
|
+
if (!fs.existsSync(dir)) {
|
|
172
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
// Create .gitignore
|
|
176
|
+
const gitignore = `
|
|
177
|
+
node_modules
|
|
178
|
+
.env
|
|
179
|
+
.env.local
|
|
180
|
+
dist
|
|
181
|
+
build
|
|
182
|
+
*.log
|
|
183
|
+
.DS_Store
|
|
184
|
+
deployments
|
|
185
|
+
cache
|
|
186
|
+
artifacts
|
|
187
|
+
typechain-types
|
|
188
|
+
`.trim();
|
|
189
|
+
fs.writeFileSync(path.join(baseDir, '.gitignore'), gitignore);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Generate .env.example file
|
|
193
|
+
*/
|
|
194
|
+
function generateEnvFile(baseDir, templateName, basePath) {
|
|
195
|
+
const envContent = `# Varity SDK Configuration
|
|
196
|
+
|
|
197
|
+
# Network
|
|
198
|
+
VARITY_NETWORK=arbitrum-sepolia
|
|
199
|
+
|
|
200
|
+
# API Configuration
|
|
201
|
+
VARITY_API_KEY=
|
|
202
|
+
VARITY_API_ENDPOINT=https://api.varity.io${basePath || `/api/v1/${templateName}`}
|
|
203
|
+
|
|
204
|
+
# RPC URLs
|
|
205
|
+
ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
|
|
206
|
+
ARBITRUM_L3_TESTNET_RPC=
|
|
207
|
+
ARBITRUM_L3_MAINNET_RPC=
|
|
208
|
+
|
|
209
|
+
# Contract Addresses (populated after deployment)
|
|
210
|
+
# Arbitrum Sepolia contracts
|
|
211
|
+
# Add your contract addresses here after deployment
|
|
212
|
+
|
|
213
|
+
# Storage Configuration
|
|
214
|
+
PINATA_API_KEY=
|
|
215
|
+
CELESTIA_TESTNET_RPC=https://rpc-mocha.pops.one
|
|
216
|
+
|
|
217
|
+
# Private Key (NEVER commit this!)
|
|
218
|
+
PRIVATE_KEY=
|
|
219
|
+
`;
|
|
220
|
+
fs.writeFileSync(path.join(baseDir, '.env.example'), envContent);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Generate package.json
|
|
224
|
+
*/
|
|
225
|
+
function generatePackageJson(baseDir, templateName, description) {
|
|
226
|
+
const packageJson = {
|
|
227
|
+
name: `varity-${templateName}-template`,
|
|
228
|
+
version: '1.0.0',
|
|
229
|
+
description: description || `Varity ${capitalize(templateName)} template`,
|
|
230
|
+
scripts: {
|
|
231
|
+
'generate:contracts': 'varity generate contracts',
|
|
232
|
+
'generate:ui': 'varity generate ui',
|
|
233
|
+
'generate:dashboard': 'varity generate dashboard',
|
|
234
|
+
'generate:types': 'varity generate types',
|
|
235
|
+
'generate:tests': 'varity generate tests',
|
|
236
|
+
'generate:all': 'npm run generate:contracts && npm run generate:ui && npm run generate:dashboard && npm run generate:types',
|
|
237
|
+
'dev': 'varity dev --watch',
|
|
238
|
+
'validate': 'varity validate',
|
|
239
|
+
'test': 'hardhat test',
|
|
240
|
+
'deploy:sepolia': 'varity deploy --network arbitrum-sepolia',
|
|
241
|
+
'deploy:testnet': 'varity deploy --network arbitrum-l3-testnet',
|
|
242
|
+
'deploy:mainnet': 'varity deploy --network arbitrum-l3-mainnet',
|
|
243
|
+
'start': 'react-scripts start',
|
|
244
|
+
'build': 'react-scripts build'
|
|
245
|
+
},
|
|
246
|
+
dependencies: {
|
|
247
|
+
'@varity-labs/sdk': '^2.0.0-beta.1',
|
|
248
|
+
'react': '^18.2.0',
|
|
249
|
+
'react-dom': '^18.2.0',
|
|
250
|
+
'react-scripts': '^5.0.1',
|
|
251
|
+
'ethers': '^6.9.0',
|
|
252
|
+
'@mui/material': '^5.15.0',
|
|
253
|
+
'@mui/icons-material': '^5.15.0',
|
|
254
|
+
'@emotion/react': '^11.11.0',
|
|
255
|
+
'@emotion/styled': '^11.11.0'
|
|
256
|
+
},
|
|
257
|
+
devDependencies: {
|
|
258
|
+
'@nomicfoundation/hardhat-toolbox': '^4.0.0',
|
|
259
|
+
'hardhat': '^2.19.0',
|
|
260
|
+
'typescript': '^5.0.0',
|
|
261
|
+
'@types/react': '^18.2.0',
|
|
262
|
+
'@types/react-dom': '^18.2.0'
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
fs.writeFileSync(path.join(baseDir, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Generate README.md
|
|
269
|
+
*/
|
|
270
|
+
function generateReadme(baseDir, templateName, template) {
|
|
271
|
+
const entityNames = template.entities?.map(e => e.displayName || capitalize(e.name)).join(', ') || 'entities';
|
|
272
|
+
const readme = `# ${capitalize(templateName)} Template
|
|
273
|
+
|
|
274
|
+
${template.description || `Business template for ${capitalize(templateName)}`}
|
|
275
|
+
|
|
276
|
+
**Business Entities**: ${entityNames}
|
|
277
|
+
|
|
278
|
+
## Quick Start
|
|
279
|
+
|
|
280
|
+
\`\`\`bash
|
|
281
|
+
# Install dependencies
|
|
282
|
+
npm install
|
|
283
|
+
|
|
284
|
+
# Generate all code
|
|
285
|
+
npm run generate:all
|
|
286
|
+
|
|
287
|
+
# Start development mode (hot-reload)
|
|
288
|
+
npm run dev
|
|
289
|
+
|
|
290
|
+
# Validate template configuration
|
|
291
|
+
npm run validate
|
|
292
|
+
\`\`\`
|
|
293
|
+
|
|
294
|
+
## Development Workflow
|
|
295
|
+
|
|
296
|
+
### 1. Customize Template
|
|
297
|
+
|
|
298
|
+
Edit \`templates/${templateName}.template.json\` to define your business entities:
|
|
299
|
+
|
|
300
|
+
\`\`\`json
|
|
301
|
+
{
|
|
302
|
+
"entities": [
|
|
303
|
+
{
|
|
304
|
+
"name": "customer",
|
|
305
|
+
"fields": [
|
|
306
|
+
{ "name": "customerId", "type": "string", "required": true },
|
|
307
|
+
{ "name": "email", "type": "string", "required": true }
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
### 2. Generate Code
|
|
315
|
+
|
|
316
|
+
\`\`\`bash
|
|
317
|
+
# Generate smart contracts
|
|
318
|
+
npm run generate:contracts
|
|
319
|
+
|
|
320
|
+
# Generate UI components (CRUD interfaces)
|
|
321
|
+
npm run generate:ui
|
|
322
|
+
|
|
323
|
+
# Generate dashboard layouts
|
|
324
|
+
npm run generate:dashboard
|
|
325
|
+
|
|
326
|
+
# Generate TypeScript types
|
|
327
|
+
npm run generate:types
|
|
328
|
+
|
|
329
|
+
# Or generate everything at once
|
|
330
|
+
npm run generate:all
|
|
331
|
+
\`\`\`
|
|
332
|
+
|
|
333
|
+
### 3. Test & Deploy
|
|
334
|
+
|
|
335
|
+
\`\`\`bash
|
|
336
|
+
# Test on Arbitrum Sepolia
|
|
337
|
+
npm run deploy:sepolia
|
|
338
|
+
|
|
339
|
+
# Run tests
|
|
340
|
+
npm test
|
|
341
|
+
|
|
342
|
+
# Deploy to mainnet
|
|
343
|
+
npm run deploy:mainnet
|
|
344
|
+
\`\`\`
|
|
345
|
+
|
|
346
|
+
## Generated Structure
|
|
347
|
+
|
|
348
|
+
After running \`npm run generate:all\`:
|
|
349
|
+
|
|
350
|
+
\`\`\`
|
|
351
|
+
${templateName}/
|
|
352
|
+
├── contracts/ # Generated Solidity contracts
|
|
353
|
+
├── src/
|
|
354
|
+
│ ├── components/
|
|
355
|
+
│ │ ├── entities/ # Generated CRUD components
|
|
356
|
+
│ │ └── dashboards/ # Generated dashboard layouts
|
|
357
|
+
│ ├── hooks/ # React hooks for SDK
|
|
358
|
+
│ └── services/ # API service layer
|
|
359
|
+
├── test/ # Generated test suites
|
|
360
|
+
└── templates/ # Template configuration
|
|
361
|
+
\`\`\`
|
|
362
|
+
|
|
363
|
+
## Features
|
|
364
|
+
|
|
365
|
+
- ✅ Automated smart contract generation
|
|
366
|
+
- ✅ Complete CRUD UI components
|
|
367
|
+
- ✅ Dashboard layouts with KPIs and charts
|
|
368
|
+
- ✅ TypeScript type safety
|
|
369
|
+
- ✅ Comprehensive test coverage
|
|
370
|
+
- ✅ Hot-reload development mode
|
|
371
|
+
- ✅ One-command deployment
|
|
372
|
+
|
|
373
|
+
## Documentation
|
|
374
|
+
|
|
375
|
+
- [Varity SDK Documentation](https://docs.varity.com)
|
|
376
|
+
- [CLI Guide](https://docs.varity.com/cli)
|
|
377
|
+
- [Template Guide](https://docs.varity.com/templates)
|
|
378
|
+
|
|
379
|
+
## Support
|
|
380
|
+
|
|
381
|
+
- Discord: https://discord.gg/varity
|
|
382
|
+
- Email: support@varity.com
|
|
383
|
+
`;
|
|
384
|
+
fs.writeFileSync(path.join(baseDir, 'README.md'), readme);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Capitalize first letter
|
|
388
|
+
*/
|
|
389
|
+
function capitalize(str) {
|
|
390
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
391
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,UAAU,SAiCnB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* varity dev - Development mode with hot-reload
|
|
3
|
+
*
|
|
4
|
+
* Watches for changes and automatically regenerates code
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { Logger } from '../utils/logger';
|
|
9
|
+
import { startDevServer } from '../../dev/dev-server';
|
|
10
|
+
export const devCommand = new Command('dev')
|
|
11
|
+
.description('Start development mode with hot-reload')
|
|
12
|
+
.option('-t, --template <path>', 'Path to template JSON file', './templates/template.json')
|
|
13
|
+
.option('-c, --contracts <path>', 'Contracts output directory', './contracts')
|
|
14
|
+
.option('-w, --watch', 'Enable file watching (default: true)', true)
|
|
15
|
+
.option('-p, --port <number>', 'Development server port', '3001')
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
try {
|
|
18
|
+
Logger.header('🔥 Varity Development Mode');
|
|
19
|
+
const templatePath = path.resolve(options.template);
|
|
20
|
+
const contractsPath = path.resolve(options.contracts);
|
|
21
|
+
const port = parseInt(options.port, 10);
|
|
22
|
+
Logger.info('Configuration:');
|
|
23
|
+
Logger.code(` Template: ${templatePath}`);
|
|
24
|
+
Logger.code(` Contracts: ${contractsPath}`);
|
|
25
|
+
Logger.code(` Watch mode: ${options.watch ? 'enabled' : 'disabled'}`);
|
|
26
|
+
Logger.code(` Port: ${port}`);
|
|
27
|
+
Logger.newline();
|
|
28
|
+
// Start dev server
|
|
29
|
+
await startDevServer({
|
|
30
|
+
templatePath,
|
|
31
|
+
contractsPath,
|
|
32
|
+
watch: options.watch,
|
|
33
|
+
port
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
Logger.error(`Failed to start dev server: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuUnC,eAAO,MAAM,eAAe,SAMW,CAAA"}
|