clishop 1.3.2 → 1.3.3
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/index.js +79 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -936,7 +936,7 @@ async function runSetupWizard() {
|
|
|
936
936
|
console.log();
|
|
937
937
|
console.log(chalk4.bold.cyan(" W E L C O M E T O C L I S H O P"));
|
|
938
938
|
console.log(chalk4.dim(" Order anything from your terminal."));
|
|
939
|
-
console.log(chalk4.dim(` Build: ${"2026-03-
|
|
939
|
+
console.log(chalk4.dim(` Build: ${"2026-03-22T18:05:29.439Z"}`));
|
|
940
940
|
console.log();
|
|
941
941
|
divider(chalk4.cyan);
|
|
942
942
|
console.log();
|
|
@@ -988,18 +988,91 @@ async function runSetupWizard() {
|
|
|
988
988
|
console.log();
|
|
989
989
|
console.log(" " + chalk4.cyan.underline(webSetupUrl));
|
|
990
990
|
console.log();
|
|
991
|
-
console.log(
|
|
992
|
-
chalk4.dim(" Complete the setup there, then return here and run:")
|
|
993
|
-
);
|
|
994
|
-
console.log(chalk4.dim(" ") + chalk4.white("clishop login"));
|
|
995
|
-
console.log();
|
|
996
991
|
const opened = await openBrowser(webSetupUrl);
|
|
997
992
|
if (!opened) {
|
|
998
993
|
console.log(
|
|
999
994
|
chalk4.yellow(" Could not open browser automatically. Please visit the link above.")
|
|
1000
995
|
);
|
|
1001
996
|
}
|
|
997
|
+
console.log(
|
|
998
|
+
chalk4.dim(" Create your account and configure everything on the website.")
|
|
999
|
+
);
|
|
1000
|
+
console.log(
|
|
1001
|
+
chalk4.dim(" When you're done, come back here to link your account to the CLI.")
|
|
1002
|
+
);
|
|
1003
|
+
console.log();
|
|
1004
|
+
await inquirer4.prompt([
|
|
1005
|
+
{
|
|
1006
|
+
type: "input",
|
|
1007
|
+
name: "done",
|
|
1008
|
+
message: "Press Enter after completing setup on the website..."
|
|
1009
|
+
}
|
|
1010
|
+
]);
|
|
1011
|
+
console.log();
|
|
1012
|
+
console.log(chalk4.bold(" Now let's link your account to the CLI."));
|
|
1013
|
+
console.log();
|
|
1014
|
+
const creds = await inquirer4.prompt([
|
|
1015
|
+
{ type: "input", name: "email", message: "Email (same as on the website):" },
|
|
1016
|
+
{ type: "password", name: "password", message: "Password:", mask: "*" }
|
|
1017
|
+
]);
|
|
1018
|
+
const spinner = ora3("Logging in...").start();
|
|
1019
|
+
try {
|
|
1020
|
+
const user = await login(creds.email, creds.password);
|
|
1021
|
+
spinner.succeed(chalk4.green(`Logged in as ${chalk4.bold(user.name)}.`));
|
|
1022
|
+
} catch (error) {
|
|
1023
|
+
spinner.fail(
|
|
1024
|
+
chalk4.red(
|
|
1025
|
+
`Login failed: ${error?.response?.data?.message || error.message}`
|
|
1026
|
+
)
|
|
1027
|
+
);
|
|
1028
|
+
console.log();
|
|
1029
|
+
console.log(
|
|
1030
|
+
chalk4.dim(" You can try again with: ") + chalk4.white("clishop login")
|
|
1031
|
+
);
|
|
1032
|
+
console.log();
|
|
1033
|
+
config.set("setupCompleted", true);
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
const syncSpinner = ora3("Syncing your settings from the website...").start();
|
|
1037
|
+
try {
|
|
1038
|
+
const api = getApiClient();
|
|
1039
|
+
const agent = getActiveAgent();
|
|
1040
|
+
await ensureAgentOnBackend(agent.name);
|
|
1041
|
+
const [addrRes, pmRes] = await Promise.all([
|
|
1042
|
+
api.get("/addresses", { params: { agent: agent.name } }),
|
|
1043
|
+
api.get("/payment-methods", { params: { agent: agent.name } })
|
|
1044
|
+
]);
|
|
1045
|
+
const addresses = addrRes.data.addresses || [];
|
|
1046
|
+
const methods = pmRes.data.paymentMethods || [];
|
|
1047
|
+
const synced = [];
|
|
1048
|
+
if (addresses.length > 0) {
|
|
1049
|
+
updateAgent(agent.name, { defaultAddressId: addresses[0].id });
|
|
1050
|
+
synced.push(`address "${addresses[0].label || "Home"}"`);
|
|
1051
|
+
}
|
|
1052
|
+
if (methods.length > 0) {
|
|
1053
|
+
updateAgent(agent.name, { defaultPaymentMethodId: methods[0].id });
|
|
1054
|
+
synced.push(`payment "${methods[0].label}"`);
|
|
1055
|
+
}
|
|
1056
|
+
if (synced.length > 0) {
|
|
1057
|
+
syncSpinner.succeed(chalk4.green(`Synced: ${synced.join(", ")}`));
|
|
1058
|
+
} else {
|
|
1059
|
+
syncSpinner.info(
|
|
1060
|
+
chalk4.dim("No addresses or payment methods found yet. You can add them with:") + "\n " + chalk4.white("clishop address add") + "\n " + chalk4.white("clishop payment add")
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
} catch {
|
|
1064
|
+
syncSpinner.warn(chalk4.yellow("Could not sync settings \u2014 you can add them manually later."));
|
|
1065
|
+
}
|
|
1002
1066
|
config.set("setupCompleted", true);
|
|
1067
|
+
console.log();
|
|
1068
|
+
divider(chalk4.green);
|
|
1069
|
+
console.log();
|
|
1070
|
+
console.log(chalk4.bold.green(" \u2713 You're all set!"));
|
|
1071
|
+
console.log();
|
|
1072
|
+
console.log(chalk4.dim(" Try: ") + chalk4.white('clishop search "headphones"'));
|
|
1073
|
+
console.log();
|
|
1074
|
+
divider(chalk4.green);
|
|
1075
|
+
console.log();
|
|
1003
1076
|
return;
|
|
1004
1077
|
}
|
|
1005
1078
|
stepHeader(1, 5, "Account");
|