@nullpay/cli 1.0.3 → 1.0.4
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/dist/commands/onboard.js +19 -2
- package/package.json +1 -1
package/dist/commands/onboard.js
CHANGED
|
@@ -119,6 +119,13 @@ function formatCurrencyLabel(currency) {
|
|
|
119
119
|
return 'CREDITS + USDCX + USAD';
|
|
120
120
|
return currency;
|
|
121
121
|
}
|
|
122
|
+
function resolveOutputPath(input) {
|
|
123
|
+
const trimmed = input.trim();
|
|
124
|
+
if (!trimmed) {
|
|
125
|
+
return path.resolve(process.cwd(), 'nullpay.json');
|
|
126
|
+
}
|
|
127
|
+
return path.resolve(process.cwd(), trimmed);
|
|
128
|
+
}
|
|
122
129
|
async function validateMerchant(secretKey, merchantAddress) {
|
|
123
130
|
const res = await fetch(`${BACKEND_URL}/sdk/onboard/validate`, {
|
|
124
131
|
method: 'POST',
|
|
@@ -478,13 +485,23 @@ async function onboard() {
|
|
|
478
485
|
line(` ${C.rose('X')} ${C.white('No invoices confirmed. Exiting.')}`);
|
|
479
486
|
process.exit(1);
|
|
480
487
|
}
|
|
481
|
-
|
|
482
|
-
const
|
|
488
|
+
blank();
|
|
489
|
+
const defaultOutputPath = path.resolve(process.cwd(), 'nullpay.json');
|
|
490
|
+
const { outputPathInput } = await inquirer_1.default.prompt([{
|
|
491
|
+
type: 'input',
|
|
492
|
+
name: 'outputPathInput',
|
|
493
|
+
message: C.slate('Write nullpay.json to'),
|
|
494
|
+
prefix: C.brand(' >'),
|
|
495
|
+
default: defaultOutputPath,
|
|
496
|
+
validate: (v) => v.trim().length ? true : C.rose('Path cannot be empty'),
|
|
497
|
+
}]);
|
|
498
|
+
const outputPath = resolveOutputPath(outputPathInput);
|
|
483
499
|
const output = {
|
|
484
500
|
merchant: resolvedAddress,
|
|
485
501
|
generated_at: new Date().toISOString(),
|
|
486
502
|
invoices: generatedInvoices,
|
|
487
503
|
};
|
|
504
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
488
505
|
fs.writeFileSync(outputPath, JSON.stringify(output, null, 2));
|
|
489
506
|
blank();
|
|
490
507
|
blank();
|