fresh-squeezy 1.0.20
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 +114 -0
- package/dist/.cursor/skills/wizard/utils/validation.d.ts +3 -0
- package/dist/.cursor/skills/wizard/utils/validation.d.ts.map +1 -0
- package/dist/.cursor/skills/wizard/utils/validation.js +113 -0
- package/dist/.cursor/skills/wizard/utils/validation.js.map +1 -0
- package/dist/billing-config.d.ts +3 -0
- package/dist/billing-config.d.ts.map +1 -0
- package/dist/billing-config.js +37 -0
- package/dist/billing-config.js.map +1 -0
- package/dist/bootstrap.d.ts +8 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +42 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +27 -0
- package/dist/cache.js.map +1 -0
- package/dist/checkout.d.ts +3 -0
- package/dist/checkout.d.ts.map +1 -0
- package/dist/checkout.js +42 -0
- package/dist/checkout.js.map +1 -0
- package/dist/cli-validate.d.ts +2 -0
- package/dist/cli-validate.d.ts.map +1 -0
- package/dist/cli-validate.js +206 -0
- package/dist/cli-validate.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +40 -0
- package/dist/cli.js.map +1 -0
- package/dist/createBilling.d.ts +3 -0
- package/dist/createBilling.d.ts.map +1 -0
- package/dist/createBilling.js +82 -0
- package/dist/createBilling.js.map +1 -0
- package/dist/customers.d.ts +3 -0
- package/dist/customers.d.ts.map +1 -0
- package/dist/customers.js +57 -0
- package/dist/customers.js.map +1 -0
- package/dist/dedup.d.ts +60 -0
- package/dist/dedup.d.ts.map +1 -0
- package/dist/dedup.js +74 -0
- package/dist/dedup.js.map +1 -0
- package/dist/express.d.ts +13 -0
- package/dist/express.d.ts.map +1 -0
- package/dist/express.js +70 -0
- package/dist/express.js.map +1 -0
- package/dist/health.d.ts +3 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +38 -0
- package/dist/health.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/licenses.d.ts +3 -0
- package/dist/licenses.d.ts.map +1 -0
- package/dist/licenses.js +70 -0
- package/dist/licenses.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +75 -0
- package/dist/logger.js.map +1 -0
- package/dist/plans.d.ts +5 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +72 -0
- package/dist/plans.js.map +1 -0
- package/dist/portal.d.ts +2 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +15 -0
- package/dist/portal.js.map +1 -0
- package/dist/retry.d.ts +2 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +35 -0
- package/dist/retry.js.map +1 -0
- package/dist/src/billing-config.d.ts +3 -0
- package/dist/src/billing-config.d.ts.map +1 -0
- package/dist/src/billing-config.js +34 -0
- package/dist/src/billing-config.js.map +1 -0
- package/dist/src/cli/cli-validate.d.ts +2 -0
- package/dist/src/cli/cli-validate.d.ts.map +1 -0
- package/dist/src/cli/cli-validate.js +206 -0
- package/dist/src/cli/cli-validate.js.map +1 -0
- package/dist/src/cli/cli.d.ts +3 -0
- package/dist/src/cli/cli.d.ts.map +1 -0
- package/dist/src/cli/cli.js +40 -0
- package/dist/src/cli/cli.js.map +1 -0
- package/dist/src/core/bootstrap.d.ts +8 -0
- package/dist/src/core/bootstrap.d.ts.map +1 -0
- package/dist/src/core/bootstrap.js +42 -0
- package/dist/src/core/bootstrap.js.map +1 -0
- package/dist/src/core/cache.d.ts +5 -0
- package/dist/src/core/cache.d.ts.map +1 -0
- package/dist/src/core/cache.js +27 -0
- package/dist/src/core/cache.js.map +1 -0
- package/dist/src/core/checkout.d.ts +3 -0
- package/dist/src/core/checkout.d.ts.map +1 -0
- package/dist/src/core/checkout.js +42 -0
- package/dist/src/core/checkout.js.map +1 -0
- package/dist/src/core/createBilling.d.ts +3 -0
- package/dist/src/core/createBilling.d.ts.map +1 -0
- package/dist/src/core/createBilling.js +82 -0
- package/dist/src/core/createBilling.js.map +1 -0
- package/dist/src/core/customers.d.ts +3 -0
- package/dist/src/core/customers.d.ts.map +1 -0
- package/dist/src/core/customers.js +57 -0
- package/dist/src/core/customers.js.map +1 -0
- package/dist/src/core/dedup.d.ts +60 -0
- package/dist/src/core/dedup.d.ts.map +1 -0
- package/dist/src/core/dedup.js +74 -0
- package/dist/src/core/dedup.js.map +1 -0
- package/dist/src/core/express.d.ts +13 -0
- package/dist/src/core/express.d.ts.map +1 -0
- package/dist/src/core/express.js +70 -0
- package/dist/src/core/express.js.map +1 -0
- package/dist/src/core/health.d.ts +3 -0
- package/dist/src/core/health.d.ts.map +1 -0
- package/dist/src/core/health.js +38 -0
- package/dist/src/core/health.js.map +1 -0
- package/dist/src/core/index.d.ts +9 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +9 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/licenses.d.ts +3 -0
- package/dist/src/core/licenses.d.ts.map +1 -0
- package/dist/src/core/licenses.js +70 -0
- package/dist/src/core/licenses.js.map +1 -0
- package/dist/src/core/logger.d.ts +4 -0
- package/dist/src/core/logger.d.ts.map +1 -0
- package/dist/src/core/logger.js +150 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/plans.d.ts +5 -0
- package/dist/src/core/plans.d.ts.map +1 -0
- package/dist/src/core/plans.js +72 -0
- package/dist/src/core/plans.js.map +1 -0
- package/dist/src/core/portal.d.ts +2 -0
- package/dist/src/core/portal.d.ts.map +1 -0
- package/dist/src/core/portal.js +15 -0
- package/dist/src/core/portal.js.map +1 -0
- package/dist/src/core/retry.d.ts +2 -0
- package/dist/src/core/retry.d.ts.map +1 -0
- package/dist/src/core/retry.js +35 -0
- package/dist/src/core/retry.js.map +1 -0
- package/dist/src/core/subscriptions.d.ts +3 -0
- package/dist/src/core/subscriptions.d.ts.map +1 -0
- package/dist/src/core/subscriptions.js +46 -0
- package/dist/src/core/subscriptions.js.map +1 -0
- package/dist/src/core/webhook.d.ts +7 -0
- package/dist/src/core/webhook.d.ts.map +1 -0
- package/dist/src/core/webhook.js +233 -0
- package/dist/src/core/webhook.js.map +1 -0
- package/dist/src/core/webhooks.d.ts +3 -0
- package/dist/src/core/webhooks.d.ts.map +1 -0
- package/dist/src/core/webhooks.js +28 -0
- package/dist/src/core/webhooks.js.map +1 -0
- package/dist/src/types/billing/billing.d.ts +36 -0
- package/dist/src/types/billing/billing.d.ts.map +1 -0
- package/dist/src/types/billing/billing.js +2 -0
- package/dist/src/types/billing/billing.js.map +1 -0
- package/dist/src/types/billing/index.d.ts +2 -0
- package/dist/src/types/billing/index.d.ts.map +1 -0
- package/dist/src/types/billing/index.js +2 -0
- package/dist/src/types/billing/index.js.map +1 -0
- package/dist/src/types/billing/types.d.ts +50 -0
- package/dist/src/types/billing/types.d.ts.map +1 -0
- package/dist/src/types/billing/types.js +2 -0
- package/dist/src/types/billing/types.js.map +1 -0
- package/dist/src/types/cache/index.d.ts +2 -0
- package/dist/src/types/cache/index.d.ts.map +1 -0
- package/dist/src/types/cache/index.js +2 -0
- package/dist/src/types/cache/index.js.map +1 -0
- package/dist/src/types/cache/types.d.ts +62 -0
- package/dist/src/types/cache/types.d.ts.map +1 -0
- package/dist/src/types/cache/types.js +2 -0
- package/dist/src/types/cache/types.js.map +1 -0
- package/dist/src/types/config/index.d.ts +2 -0
- package/dist/src/types/config/index.d.ts.map +1 -0
- package/dist/src/types/config/index.js +2 -0
- package/dist/src/types/config/index.js.map +1 -0
- package/dist/src/types/config/types.d.ts +138 -0
- package/dist/src/types/config/types.d.ts.map +1 -0
- package/dist/src/types/config/types.js +2 -0
- package/dist/src/types/config/types.js.map +1 -0
- package/dist/src/types/index.d.ts +9 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +9 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/license/index.d.ts +2 -0
- package/dist/src/types/license/index.d.ts.map +1 -0
- package/dist/src/types/license/index.js +2 -0
- package/dist/src/types/license/index.js.map +1 -0
- package/dist/src/types/license/types.d.ts +32 -0
- package/dist/src/types/license/types.d.ts.map +1 -0
- package/dist/src/types/license/types.js +2 -0
- package/dist/src/types/license/types.js.map +1 -0
- package/dist/src/types/management/index.d.ts +2 -0
- package/dist/src/types/management/index.d.ts.map +1 -0
- package/dist/src/types/management/index.js +2 -0
- package/dist/src/types/management/index.js.map +1 -0
- package/dist/src/types/management/types.d.ts +37 -0
- package/dist/src/types/management/types.d.ts.map +1 -0
- package/dist/src/types/management/types.js +2 -0
- package/dist/src/types/management/types.js.map +1 -0
- package/dist/src/types/subscription/index.d.ts +2 -0
- package/dist/src/types/subscription/index.d.ts.map +1 -0
- package/dist/src/types/subscription/index.js +2 -0
- package/dist/src/types/subscription/index.js.map +1 -0
- package/dist/src/types/subscription/types.d.ts +46 -0
- package/dist/src/types/subscription/types.d.ts.map +1 -0
- package/dist/src/types/subscription/types.js +2 -0
- package/dist/src/types/subscription/types.js.map +1 -0
- package/dist/src/types/types.d.ts +2 -0
- package/dist/src/types/types.d.ts.map +1 -0
- package/dist/src/types/types.js +2 -0
- package/dist/src/types/types.js.map +1 -0
- package/dist/src/types/webhook/index.d.ts +2 -0
- package/dist/src/types/webhook/index.d.ts.map +1 -0
- package/dist/src/types/webhook/index.js +2 -0
- package/dist/src/types/webhook/index.js.map +1 -0
- package/dist/src/types/webhook/types.d.ts +14 -0
- package/dist/src/types/webhook/types.d.ts.map +1 -0
- package/dist/src/types/webhook/types.js +2 -0
- package/dist/src/types/webhook/types.js.map +1 -0
- package/dist/src/wizard.d.ts +22 -0
- package/dist/src/wizard.d.ts.map +1 -0
- package/dist/src/wizard.js +628 -0
- package/dist/src/wizard.js.map +1 -0
- package/dist/subscriptions.d.ts +3 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +46 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/types.d.ts +286 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook.d.ts +7 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +227 -0
- package/dist/webhook.js.map +1 -0
- package/dist/webhooks.d.ts +3 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +28 -0
- package/dist/webhooks.js.map +1 -0
- package/dist/wizard.d.ts +22 -0
- package/dist/wizard.d.ts.map +1 -0
- package/dist/wizard.js +615 -0
- package/dist/wizard.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yosef Hayim Sabag
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Project Refactoring Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Successfully completed the refactoring of the `src/wizard.ts` file and reorganized the project structure to enable better modularity and maintainability.
|
|
6
|
+
|
|
7
|
+
## Changes Made
|
|
8
|
+
|
|
9
|
+
### 1. Created Skills Folder Structure
|
|
10
|
+
|
|
11
|
+
- **Root Skills Directory**: `/skills/`
|
|
12
|
+
- **Wizard Skill**: `/skills/wizard/` - Interactive setup wizard functionality
|
|
13
|
+
- `components/` - Reusable UI components (banner, loading animations)
|
|
14
|
+
- `steps/` - Individual wizard steps (API key, store selection, etc.)
|
|
15
|
+
- `utils/` - Wizard-specific utilities (validation, file generation)
|
|
16
|
+
- `types.ts` - Wizard-specific type definitions
|
|
17
|
+
- **CLI Skill**: `/skills/cli/` - Command-line interface functionality
|
|
18
|
+
- `commands/` - Individual CLI command implementations
|
|
19
|
+
- `utils/` - CLI utilities and helpers
|
|
20
|
+
- **Validation Skill**: `/skills/validation/` - Testing and validation functionality
|
|
21
|
+
- `tests/` - Validation test implementations
|
|
22
|
+
- `utils/` - Validation utilities and helpers
|
|
23
|
+
|
|
24
|
+
### 2. Reorganized Source Code Structure
|
|
25
|
+
|
|
26
|
+
- **Core Directory**: `/src/core/` - Core billing functionality
|
|
27
|
+
- Moved all core billing logic from root src/ directory
|
|
28
|
+
- Updated all import paths to use new structure
|
|
29
|
+
- **CLI Directory**: `/src/cli/` - CLI-related files
|
|
30
|
+
- `cli.ts` - Main CLI entry point
|
|
31
|
+
- `cli-validate.ts` - Validation functionality
|
|
32
|
+
- **Types Directory**: `/src/types/` - Type definitions
|
|
33
|
+
- `types.ts` - Main types export
|
|
34
|
+
- Existing type subdirectories preserved
|
|
35
|
+
- **Utils Directory**: `/src/utils/` - Utility files (created but empty for now)
|
|
36
|
+
|
|
37
|
+
### 3. Split Wizard.ts into Modular Components
|
|
38
|
+
|
|
39
|
+
The original monolithic `wizard.ts` (~1000 lines) was split into:
|
|
40
|
+
|
|
41
|
+
- **Main Wizard Class**: `/skills/wizard/main.ts`
|
|
42
|
+
- **Type Definitions**: `/skills/wizard/types.ts`
|
|
43
|
+
- **UI Components**:
|
|
44
|
+
- `/skills/wizard/components/banner.ts`
|
|
45
|
+
- `/skills/wizard/components/loading.ts`
|
|
46
|
+
- **Wizard Steps**:
|
|
47
|
+
- `/skills/wizard/steps/api-key.ts`
|
|
48
|
+
- `/skills/wizard/steps/store-selection.ts`
|
|
49
|
+
- `/skills/wizard/steps/product-selection.ts`
|
|
50
|
+
- `/skills/wizard/steps/webhook-setup.ts`
|
|
51
|
+
- `/skills/wizard/steps/configuration.ts`
|
|
52
|
+
- `/skills/wizard/steps/generate-files.ts`
|
|
53
|
+
- **Utilities**:
|
|
54
|
+
- `/skills/wizard/utils/file-generation.ts`
|
|
55
|
+
- `/skills/wizard/utils/validation.ts`
|
|
56
|
+
- `/skills/wizard/utils/real-cycle.ts`
|
|
57
|
+
|
|
58
|
+
### 4. Updated Import Paths
|
|
59
|
+
|
|
60
|
+
- Updated all import statements throughout the project to use the new directory structure
|
|
61
|
+
- Fixed TypeScript compilation issues
|
|
62
|
+
- Ensured all modules can find their dependencies
|
|
63
|
+
|
|
64
|
+
### 5. Created Comprehensive Documentation
|
|
65
|
+
|
|
66
|
+
- **Root README**: This summary document
|
|
67
|
+
- **Skills README**: Architecture overview and usage instructions
|
|
68
|
+
- **Wizard README**: Detailed wizard functionality documentation
|
|
69
|
+
- **CLI README**: CLI command documentation
|
|
70
|
+
- **Validation README**: Testing and validation documentation
|
|
71
|
+
|
|
72
|
+
## Benefits Achieved
|
|
73
|
+
|
|
74
|
+
1. **Improved Modularity**: Each wizard step is now a separate, testable module
|
|
75
|
+
2. **Better Maintainability**: Clear separation of concerns makes code easier to understand and modify
|
|
76
|
+
3. **Enhanced Reusability**: Components can be reused across different parts of the system
|
|
77
|
+
4. **Cleaner Architecture**: Logical grouping of related functionality
|
|
78
|
+
5. **Easier Testing**: Individual modules can be tested independently
|
|
79
|
+
6. **Better Developer Experience**: Clear documentation and organized structure
|
|
80
|
+
|
|
81
|
+
## Project Structure
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
fresh-squeezy/
|
|
85
|
+
├── skills/ # Modular skills system
|
|
86
|
+
│ ├── wizard/ # Interactive setup wizard
|
|
87
|
+
│ │ ├── components/ # UI components
|
|
88
|
+
│ │ ├── steps/ # Wizard steps
|
|
89
|
+
│ │ ├── utils/ # Wizard utilities
|
|
90
|
+
│ │ ├── types.ts # Wizard types
|
|
91
|
+
│ │ └── main.ts # Main wizard class
|
|
92
|
+
│ ├── cli/ # CLI functionality
|
|
93
|
+
│ │ ├── commands/ # CLI commands
|
|
94
|
+
│ │ └── utils/ # CLI utilities
|
|
95
|
+
│ └── validation/ # Testing and validation
|
|
96
|
+
│ ├── tests/ # Validation tests
|
|
97
|
+
│ └── utils/ # Validation utilities
|
|
98
|
+
├── src/ # Source code
|
|
99
|
+
│ ├── core/ # Core billing functionality
|
|
100
|
+
│ ├── cli/ # CLI-related files
|
|
101
|
+
│ ├── types/ # Type definitions
|
|
102
|
+
│ └── utils/ # Utility files
|
|
103
|
+
└── README.md # This documentation
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Testing Status
|
|
107
|
+
|
|
108
|
+
- ✅ TypeScript compilation passes
|
|
109
|
+
- ✅ Build process completes successfully
|
|
110
|
+
- ✅ All import paths updated and working
|
|
111
|
+
- ✅ Modular structure implemented
|
|
112
|
+
- ✅ Documentation created
|
|
113
|
+
|
|
114
|
+
The refactoring is complete and the project is ready for continued development with the new modular structure.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../.cursor/skills/wizard/utils/validation.ts"],"names":[],"mappings":"AAQA,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BxD;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsDxD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { loading } from "@wizard/components/loading.js";
|
|
6
|
+
import { runRealCycleFlow } from "@wizard/utils/real-cycle.js";
|
|
7
|
+
// Function to open URLs in the default browser
|
|
8
|
+
export async function openUrl(url) {
|
|
9
|
+
const { execSync } = await import("child_process");
|
|
10
|
+
const os = await import("os");
|
|
11
|
+
const platform = os.platform();
|
|
12
|
+
let command;
|
|
13
|
+
switch (platform) {
|
|
14
|
+
case 'darwin': // macOS
|
|
15
|
+
command = `open "${url}"`;
|
|
16
|
+
break;
|
|
17
|
+
case 'win32': // Windows
|
|
18
|
+
command = `start "" "${url}"`;
|
|
19
|
+
break;
|
|
20
|
+
case 'linux': // Linux
|
|
21
|
+
command = `xdg-open "${url}"`;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
execSync(command, { stdio: 'ignore' });
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.log(`[x] Failed to open URL: ${error instanceof Error ? error.message : error}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function runValidationTests() {
|
|
34
|
+
console.log("\n" + chalk.dim("Running validation tests..."));
|
|
35
|
+
try {
|
|
36
|
+
// Test TypeScript compilation
|
|
37
|
+
loading.start("Testing TypeScript compilation");
|
|
38
|
+
execSync('pnpm typecheck', { stdio: 'pipe' });
|
|
39
|
+
loading.stop("[+] TypeScript compilation passed");
|
|
40
|
+
// Test build process
|
|
41
|
+
loading.start("Testing build process");
|
|
42
|
+
execSync('pnpm build', { stdio: 'pipe' });
|
|
43
|
+
loading.stop("[+] Build process passed");
|
|
44
|
+
// Test example file syntax
|
|
45
|
+
loading.start("Testing example file syntax");
|
|
46
|
+
execSync('node --check example.ts', { stdio: 'pipe' });
|
|
47
|
+
loading.stop("[+] Example file syntax valid");
|
|
48
|
+
// Test billing configuration
|
|
49
|
+
loading.start("Testing billing configuration");
|
|
50
|
+
// Check if billing-config.ts exists and has proper exports
|
|
51
|
+
const configPath = resolve(process.cwd(), 'billing-config.ts');
|
|
52
|
+
if (!existsSync(configPath)) {
|
|
53
|
+
loading.stop("[x] billing-config.ts file not found");
|
|
54
|
+
throw new Error("billing-config.ts file not found");
|
|
55
|
+
}
|
|
56
|
+
const fs = await import('node:fs');
|
|
57
|
+
const configContent = fs.readFileSync(configPath, 'utf8');
|
|
58
|
+
if (!configContent.includes('export const billingConfig')) {
|
|
59
|
+
loading.stop("[x] billing-config.ts does not export billingConfig");
|
|
60
|
+
throw new Error("billing-config.ts does not export billingConfig");
|
|
61
|
+
}
|
|
62
|
+
loading.stop("[+] Billing configuration valid");
|
|
63
|
+
console.log("\n[+] All validation tests passed! ✅");
|
|
64
|
+
console.log("Your billing integration is ready to use.");
|
|
65
|
+
// Check if sandbox API key and offer real cycle flow
|
|
66
|
+
await offerRealCycleFlow();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.log("\n[x] Validation tests failed:");
|
|
70
|
+
console.error("Error:", error instanceof Error ? error.message : error);
|
|
71
|
+
console.log("\nPlease review the generated files and fix any issues.");
|
|
72
|
+
console.log("You can run the following commands to debug:");
|
|
73
|
+
console.log(" pnpm typecheck");
|
|
74
|
+
console.log(" pnpm build");
|
|
75
|
+
console.log(" node --check example.ts");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function offerRealCycleFlow() {
|
|
80
|
+
console.log("\n" + chalk.dim("Checking API key type..."));
|
|
81
|
+
// Check if this is a sandbox/test API key
|
|
82
|
+
const isSandboxKey = process.env.LEMON_SQUEEZY_API_KEY?.includes('test_') ||
|
|
83
|
+
process.env.LEMON_SQUEEZY_API_KEY?.includes('sandbox_') ||
|
|
84
|
+
process.env.LS_TEST_API_KEY === process.env.LEMON_SQUEEZY_API_KEY;
|
|
85
|
+
if (!isSandboxKey) {
|
|
86
|
+
console.log("[-] Live API key detected. Skipping real cycle flow test.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
console.log("[+] Sandbox API key detected!");
|
|
90
|
+
console.log("\n" + chalk.dim("Would you like to run a real cycle flow test? (use SPACE to select, ENTER to submit):"));
|
|
91
|
+
const prompts = await import("prompts");
|
|
92
|
+
const response = await prompts.default({
|
|
93
|
+
type: "multiselect",
|
|
94
|
+
name: "runTest",
|
|
95
|
+
message: "Run real cycle flow test:",
|
|
96
|
+
choices: [
|
|
97
|
+
{ title: "Yes, run test cycle", value: "yes" },
|
|
98
|
+
{ title: "No, skip test", value: "no" }
|
|
99
|
+
],
|
|
100
|
+
instructions: false,
|
|
101
|
+
hint: "Space to select, Enter to submit",
|
|
102
|
+
onState: (state) => {
|
|
103
|
+
if (state.aborted)
|
|
104
|
+
throw new Error('Aborted');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (!response.runTest.includes("yes")) {
|
|
108
|
+
console.log("[-] Skipping real cycle flow test");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
await runRealCycleFlow();
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../.cursor/skills/wizard/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,E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BNhlkD2nyAyGdABn52wQaBkpcMy3XgUGI",
|
|
3
|
+
storeId: "270009",
|
|
4
|
+
webhookSecret: "ls_ntifo0x50q",
|
|
5
|
+
cachePath: "./billing-cache.json",
|
|
6
|
+
logger: { filePath: "./billing.log" },
|
|
7
|
+
callbacks: {
|
|
8
|
+
onPurchase: async (event) => {
|
|
9
|
+
console.log("Purchase:", event);
|
|
10
|
+
},
|
|
11
|
+
onRefund: async (event) => {
|
|
12
|
+
console.log("Refund:", event);
|
|
13
|
+
},
|
|
14
|
+
onSubscriptionCreated: async (event) => {
|
|
15
|
+
console.log("Subscription created:", event);
|
|
16
|
+
},
|
|
17
|
+
onSubscriptionUpdated: async (event) => {
|
|
18
|
+
console.log("Subscription updated:", event);
|
|
19
|
+
},
|
|
20
|
+
onSubscriptionCancelled: async (event) => {
|
|
21
|
+
console.log("Subscription cancelled:", event);
|
|
22
|
+
},
|
|
23
|
+
onSubscriptionExpired: async (event) => {
|
|
24
|
+
console.log("Subscription expired:", event);
|
|
25
|
+
},
|
|
26
|
+
onPaymentFailed: async (event) => {
|
|
27
|
+
console.log("Payment failed:", event);
|
|
28
|
+
},
|
|
29
|
+
onLicenseKeyCreated: async (event) => {
|
|
30
|
+
console.log("License key created:", event);
|
|
31
|
+
},
|
|
32
|
+
onLicenseKeyUpdated: async (event) => {
|
|
33
|
+
console.log("License key updated:", event);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=billing-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing-config.js","sourceRoot":"","sources":["../src/billing-config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,6gCAA6gC;IAC1jC,OAAO,EAAE,QAAQ;IACjB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,sBAAsB;IACjC,MAAM,EAA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type { BillingConfig, BillingCache, StoreInfo, Plan } from "./types.js";
|
|
2
|
+
export interface BootstrapResult {
|
|
3
|
+
stores: StoreInfo[];
|
|
4
|
+
plans: Plan[];
|
|
5
|
+
cache: BillingCache;
|
|
6
|
+
}
|
|
7
|
+
export declare function bootstrap(config: BillingConfig): Promise<BootstrapResult>;
|
|
8
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAI/E,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAiD/E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { lemonSqueezySetup } from "@lemonsqueezy/lemonsqueezy.js";
|
|
2
|
+
import { fetchStores, fetchProducts, flattenPlans } from "./plans.js";
|
|
3
|
+
import { readCache, writeCache, isCacheValid } from "./cache.js";
|
|
4
|
+
export async function bootstrap(config) {
|
|
5
|
+
lemonSqueezySetup({ apiKey: config.apiKey });
|
|
6
|
+
const existingCache = readCache(config.cachePath);
|
|
7
|
+
if (isCacheValid(existingCache, config.cacheTtlMs) && existingCache) {
|
|
8
|
+
const plans = flattenPlans(existingCache.products);
|
|
9
|
+
return {
|
|
10
|
+
stores: [existingCache.store],
|
|
11
|
+
plans,
|
|
12
|
+
cache: existingCache,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const stores = await fetchStores();
|
|
16
|
+
if (stores.length === 0) {
|
|
17
|
+
throw new Error("No stores found for this API key. Verify your Lemon Squeezy API key.");
|
|
18
|
+
}
|
|
19
|
+
const selectedStore = config.storeId
|
|
20
|
+
? stores.find((s) => s.id === config.storeId)
|
|
21
|
+
: stores[0];
|
|
22
|
+
if (!selectedStore) {
|
|
23
|
+
const available = stores.map((s) => `${s.name} (${s.id})`).join(", ");
|
|
24
|
+
throw new Error(`Store "${config.storeId}" not found. Available: ${available}`);
|
|
25
|
+
}
|
|
26
|
+
const products = await fetchProducts(selectedStore.id);
|
|
27
|
+
if (products.length === 0) {
|
|
28
|
+
throw new Error(`No published products found for store ${selectedStore.id}. Create products in the Lemon Squeezy dashboard first.`);
|
|
29
|
+
}
|
|
30
|
+
const cache = {
|
|
31
|
+
generatedAt: new Date().toISOString(),
|
|
32
|
+
store: selectedStore,
|
|
33
|
+
products,
|
|
34
|
+
};
|
|
35
|
+
writeCache(cache, config.cachePath);
|
|
36
|
+
return {
|
|
37
|
+
stores,
|
|
38
|
+
plans: flattenPlans(products),
|
|
39
|
+
cache,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQjE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAqB;IACnD,iBAAiB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClD,IAAI,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,aA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;IAEF,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAEpC,OAAO;QACL,MAAM;QACN,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC;QAC7B,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BillingCache } from "./types.js";
|
|
2
|
+
export declare function readCache(cachePath?: string): BillingCache | undefined;
|
|
3
|
+
export declare function writeCache(cache: BillingCache, cachePath?: string): void;
|
|
4
|
+
export declare function isCacheValid(cache: BillingCache | undefined, ttlMs?: number): boolean;
|
|
5
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAQtE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAIxE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAKrF"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
const DEFAULT_CACHE_PATH = "./billing-cache.json";
|
|
4
|
+
const DEFAULT_TTL_MS = 3_600_000;
|
|
5
|
+
export function readCache(cachePath) {
|
|
6
|
+
const path = cachePath ?? DEFAULT_CACHE_PATH;
|
|
7
|
+
try {
|
|
8
|
+
const raw = readFileSync(path, "utf-8");
|
|
9
|
+
return JSON.parse(raw);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function writeCache(cache, cachePath) {
|
|
16
|
+
const path = cachePath ?? DEFAULT_CACHE_PATH;
|
|
17
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
18
|
+
writeFileSync(path, JSON.stringify(cache, null, 2) + "\n", "utf-8");
|
|
19
|
+
}
|
|
20
|
+
export function isCacheValid(cache, ttlMs) {
|
|
21
|
+
if (!cache)
|
|
22
|
+
return false;
|
|
23
|
+
const ttl = ttlMs ?? DEFAULT_TTL_MS;
|
|
24
|
+
const generatedAt = new Date(cache.generatedAt).getTime();
|
|
25
|
+
return Date.now() - generatedAt < ttl;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAClD,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,MAAM,UAAU,SAAS,CAAC,SAAkB;IAC1C,MAAM,IAAI,GAAG,SAAS,IAAI,kBAAkB,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAmB,EAAE,SAAkB;IAChE,MAAM,IAAI,GAAG,SAAS,IAAI,kBAAkB,CAAC;IAC7C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAA+B,EAAE,KAAc;IAC1E,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,GAAG,GAAG,KAAK,IAAI,cAAc,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,GAAG,GAAG,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAWjD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,IAC1E,QAAQ,cAAc,KAAG,OAAO,CAAC,MAAM,CAAC,CAuCvD"}
|
package/dist/checkout.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createCheckout as lsCreateCheckout } from "@lemonsqueezy/lemonsqueezy.js";
|
|
2
|
+
import { withRetry } from "./retry.js";
|
|
3
|
+
const DEFAULT_EXPIRES_IN_MS = 86_400_000;
|
|
4
|
+
function getExpiresAt(expiresInMs) {
|
|
5
|
+
if (expiresInMs === null)
|
|
6
|
+
return undefined;
|
|
7
|
+
const ms = expiresInMs ?? DEFAULT_EXPIRES_IN_MS;
|
|
8
|
+
return new Date(Date.now() + ms).toISOString();
|
|
9
|
+
}
|
|
10
|
+
export function createCheckoutFactory(storeId, checkoutExpiresInMs) {
|
|
11
|
+
return async (params) => {
|
|
12
|
+
const expiresAt = getExpiresAt(checkoutExpiresInMs);
|
|
13
|
+
const response = await withRetry(() => lsCreateCheckout(storeId, params.variantId, {
|
|
14
|
+
checkoutData: {
|
|
15
|
+
email: params.email,
|
|
16
|
+
custom: { user_id: params.userId },
|
|
17
|
+
},
|
|
18
|
+
checkoutOptions: {
|
|
19
|
+
embed: false,
|
|
20
|
+
media: true,
|
|
21
|
+
logo: true,
|
|
22
|
+
},
|
|
23
|
+
...(expiresAt ? { expiresAt } : {}),
|
|
24
|
+
}), "createCheckout");
|
|
25
|
+
if (response.error) {
|
|
26
|
+
const lsError = response.error;
|
|
27
|
+
const details = Array.isArray(lsError.cause)
|
|
28
|
+
? lsError.cause.join("; ")
|
|
29
|
+
: String(lsError.message ?? "Unknown checkout error");
|
|
30
|
+
throw new Error(`Checkout failed: ${details}`);
|
|
31
|
+
}
|
|
32
|
+
if (!response.data) {
|
|
33
|
+
throw new Error("Checkout session created but no data returned");
|
|
34
|
+
}
|
|
35
|
+
const url = response.data.data.attributes.url;
|
|
36
|
+
if (!url) {
|
|
37
|
+
throw new Error("Checkout session created but no URL returned");
|
|
38
|
+
}
|
|
39
|
+
return url;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEzC,SAAS,YAAY,CAAC,WAAsC;IAC1D,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,EAAE,GAAG,WAAW,IAAI,qBAAqB,CAAC;IAChD,OAAO,IAAI,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