paddle-checkout-accelerator 2.5.0 → 2.6.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.
|
@@ -118,6 +118,120 @@ function appendEnvSafe(values) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
function readEnvFile() {
|
|
122
|
+
const envPath =
|
|
123
|
+
path.join(cwd, ".env.local");
|
|
124
|
+
|
|
125
|
+
if (!fs.existsSync(envPath)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return fs.readFileSync(envPath, "utf8");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function hasEnvValue(env, key) {
|
|
133
|
+
if (!env) return false;
|
|
134
|
+
|
|
135
|
+
const line =
|
|
136
|
+
env
|
|
137
|
+
.split("\n")
|
|
138
|
+
.find((entry) =>
|
|
139
|
+
entry.startsWith(`${key}=`)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
if (!line) return false;
|
|
143
|
+
|
|
144
|
+
const value =
|
|
145
|
+
line.slice(key.length + 1).trim();
|
|
146
|
+
|
|
147
|
+
return value.length > 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function runDoctor() {
|
|
151
|
+
const env =
|
|
152
|
+
readEnvFile();
|
|
153
|
+
|
|
154
|
+
const checks = [
|
|
155
|
+
{
|
|
156
|
+
label: ".env.local exists",
|
|
157
|
+
pass: Boolean(env),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: "PADDLE_API_KEY set",
|
|
161
|
+
pass: hasEnvValue(env, "PADDLE_API_KEY"),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
label: "PADDLE_WEBHOOK_SECRET set",
|
|
165
|
+
pass: hasEnvValue(env, "PADDLE_WEBHOOK_SECRET"),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
label: "NEXT_PUBLIC_PADDLE_CLIENT_TOKEN set",
|
|
169
|
+
pass: hasEnvValue(env, "NEXT_PUBLIC_PADDLE_CLIENT_TOKEN"),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
label: "billing config exists",
|
|
173
|
+
pass: exists("src/lib/billing.ts"),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
label: "webhook route exists",
|
|
177
|
+
pass: exists("src/app/api/paddle/webhook/route.ts"),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
label: "portal route exists",
|
|
181
|
+
pass: exists("src/app/api/paddle/portal-session/route.ts"),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: "refresh route exists",
|
|
185
|
+
pass: exists("src/app/api/paddle/refresh-subscription/route.ts"),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
label: "repair route exists",
|
|
189
|
+
pass: exists("src/app/api/paddle/repair-by-email/route.ts"),
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
label: "pricing page exists",
|
|
193
|
+
pass: exists("src/app/billing/pricing/page.tsx"),
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
label: "billing dashboard exists",
|
|
197
|
+
pass: exists("src/app/billing/dashboard/page.tsx"),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
label: "customer repair page exists",
|
|
201
|
+
pass: exists("src/app/billing/customer-repair/page.tsx"),
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
console.log("");
|
|
206
|
+
console.log("Paddle Checkout Accelerator Doctor");
|
|
207
|
+
console.log("");
|
|
208
|
+
|
|
209
|
+
let failed = 0;
|
|
210
|
+
|
|
211
|
+
for (const check of checks) {
|
|
212
|
+
if (check.pass) {
|
|
213
|
+
console.log(`✅ ${check.label}`);
|
|
214
|
+
} else {
|
|
215
|
+
failed += 1;
|
|
216
|
+
console.log(`❌ ${check.label}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
console.log("");
|
|
221
|
+
|
|
222
|
+
if (failed === 0) {
|
|
223
|
+
console.log("All checks passed.");
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
console.log(`${failed} check(s) failed.`);
|
|
228
|
+
console.log("");
|
|
229
|
+
console.log("Fix the missing items above, then run:");
|
|
230
|
+
console.log(" npx paddle-checkout-accelerator doctor");
|
|
231
|
+
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
|
|
121
235
|
async function getConfig() {
|
|
122
236
|
const detectedAdapter =
|
|
123
237
|
detectAdapter();
|
|
@@ -647,11 +761,16 @@ Usage:
|
|
|
647
761
|
npx paddle-checkout-accelerator init
|
|
648
762
|
npx paddle-checkout-accelerator init --interactive
|
|
649
763
|
npx paddle-checkout-accelerator init --force
|
|
764
|
+
npx paddle-checkout-accelerator doctor
|
|
650
765
|
npx paddle-checkout-accelerator init --minimal
|
|
651
766
|
`);
|
|
652
767
|
process.exit(0);
|
|
653
768
|
}
|
|
654
769
|
|
|
770
|
+
if (command === "doctor") {
|
|
771
|
+
runDoctor();
|
|
772
|
+
}
|
|
773
|
+
|
|
655
774
|
if (command !== "init") {
|
|
656
775
|
console.error(
|
|
657
776
|
`Unknown command: ${command}`
|