Skip to content

Commit

Permalink
fix(cli): error gracefully when user exits prompt (#1288)
Browse files Browse the repository at this point in the history
* fix(cli): error gracefully when user exits prompt

* chore: update cli
  • Loading branch information
oliverqx authored Feb 7, 2025
1 parent 00d9129 commit 97e1c1d
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 72 deletions.
98 changes: 58 additions & 40 deletions screenpipe-js/cli/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12891,7 +12891,7 @@ var require_sbcs_data_generated = __commonJS((exports, module) => {
csibm863: "cp863",
cp864: {
type: "_sbcs",
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b\t
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$٪&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~°·∙√▒─│┼┤┬├┴┐┌└┘β∞φ±½¼≈«»ﻷﻸ��ﻻﻼ� ­ﺂ£¤ﺄ��ﺎﺏﺕﺙ،ﺝﺡﺥ٠١٢٣٤٥٦٧٨٩ﻑ؛ﺱﺵﺹ؟¢ﺀﺁﺃﺅﻊﺋﺍﺑﺓﺗﺛﺟﺣﺧﺩﺫﺭﺯﺳﺷﺻﺿﻁﻅﻋﻏ¦¬÷×ﻉـﻓﻗﻛﻟﻣﻧﻫﻭﻯﻳﺽﻌﻎﻍﻡﹽّﻥﻩﻬﻰﻲﻐﻕﻵﻶﻝﻙﻱ■�`
},
ibm864: "cp864",
Expand Down Expand Up @@ -13030,7 +13030,7 @@ var require_sbcs_data_generated = __commonJS((exports, module) => {
},
tcvn: {
type: "_sbcs",
chars: `\x00ÚỤ\x03ỪỬỮ\x07\b\t
chars: `\x00ÚỤ\x03ỪỬỮ\x07\b
\v\f\r\x0E\x0F\x10ỨỰỲỶỸÝỴ\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ÀẢÃÁẠẶẬÈẺẼÉẸỆÌỈĨÍỊÒỎÕÓỌỘỜỞỠỚỢÙỦŨ ĂÂÊÔƠƯĐăâêôơưđẶ̀̀̉̃́àảãáạẲằẳẵắẴẮẦẨẪẤỀặầẩẫấậèỂẻẽéẹềểễếệìỉỄẾỒĩíịòỔỏõóọồổỗốộờởỡớợùỖủũúụừửữứựỳỷỹýỵỐ`
},
georgianacademy: {
Expand All @@ -13047,17 +13047,17 @@ var require_sbcs_data_generated = __commonJS((exports, module) => {
},
viscii: {
type: "_sbcs",
chars: `\x00\x01Ẳ\x03\x04ẴẪ\x07\b\t
chars: `\x00\x01Ẳ\x03\x04ẴẪ\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13Ỷ\x15\x16\x17\x18Ỹ\x1A\x1B\x1C\x1DỴ\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~ẠẮẰẶẤẦẨẬẼẸẾỀỂỄỆỐỒỔỖỘỢỚỜỞỊỎỌỈỦŨỤỲÕắằặấầẩậẽẹếềểễệốồổỗỠƠộờởịỰỨỪỬơớƯÀÁÂÃẢĂẳẵÈÉÊẺÌÍĨỳĐứÒÓÔạỷừửÙÚỹỵÝỡưàáâãảăữẫèéêẻìíĩỉđựòóôõỏọụùúũủýợỮ`
},
iso646cn: {
type: "_sbcs",
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b\t
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#¥%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������`
},
iso646jp: {
type: "_sbcs",
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b\t
chars: `\x00\x01\x02\x03\x04\x05\x06\x07\b
\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[¥]^_\`abcdefghijklmnopqrstuvwxyz{|}‾��������������������������������������������������������������������������������������������������������������������������������`
},
hproman8: {
Expand Down Expand Up @@ -62301,19 +62301,29 @@ welcome to screenpipe! \uD83D\uDE80
logger.log("pipes are plugins that interact with captured screen and audio data.");
logger.log(`build powerful agents, monetize it, etc.
`);
const pipeName = await esm_default5({
message: "what is your pipe name?",
default: "my-screenpipe",
validate: (input) => {
if (input.trim().length === 0)
return "pipe name is required";
return true;
}
});
const directory = await esm_default5({
message: "where would you like to create your pipe?",
default: pipeName
});
let pipeName = "";
try {
pipeName = await esm_default5({
message: "what is your pipe name?",
default: "my-screenpipe",
validate: (input) => {
if (input.trim().length === 0)
return "pipe name is required";
return true;
}
});
} catch (error) {
handleError(error);
}
let directory = "";
try {
directory = await esm_default5({
message: "where would you like to create your pipe?",
default: pipeName
});
} catch (error) {
handleError(error);
}
const spinner2 = ora("creating your pipe...").start();
try {
await downloadAndExtractSubdir("pipes/obsidian", directory);
Expand Down Expand Up @@ -62360,28 +62370,36 @@ var TEMPLATE_REPOS = {
var createAppCommand = new Command().name("create").description("create a new desktop app project").option("-a, --name <name>", "the name of your app (optional)").option("-t, --appType <type>", "the type of desktop app (electron or tauri)").action(async (options) => {
let { name, appType } = options;
if (!appType) {
let { appTypePrompt } = await esm_default12.prompt({
name: "appTypePrompt",
type: "select",
message: "what type of desktop app would you like to create?",
choices: [
{ name: "electron", value: "electron" },
{ name: "tauri", value: "tauri" }
],
default: "tauri"
});
appType = appTypePrompt;
try {
let { appTypePrompt } = await esm_default12.prompt({
name: "appTypePrompt",
type: "select",
message: "what type of desktop app would you like to create?",
choices: [
{ name: "electron", value: "electron" },
{ name: "tauri", value: "tauri" }
],
default: "tauri"
});
appType = appTypePrompt;
} catch (error) {
handleError(error);
}
}
if (!name || name.length === 0) {
name = await esm_default5({
message: "What is your project name?",
default: "my-desktop-app",
validate: (input) => {
if (input.trim().length === 0)
return "project name is required.";
return true;
}
});
try {
name = await esm_default5({
message: "What is your project name?",
default: "my-desktop-app",
validate: (input) => {
if (input.trim().length === 0)
return "project name is required.";
return true;
}
});
} catch (error) {
handleError(error);
}
}
const loadingSpinner = spinner("creating your desktop app...");
try {
Expand Down Expand Up @@ -64123,8 +64141,8 @@ var throwOnStrictDeadlockError = (isSubprocess) => {
This can be fixed by both sending a message and listening to incoming messages at the same time:

const [receivedMessage] = await Promise.all([
\t${getMethodName("getOneMessage", isSubprocess)},
\t${getMethodName("sendMessage", isSubprocess, "message, {strict: true}")},
${getMethodName("getOneMessage", isSubprocess)},
${getMethodName("sendMessage", isSubprocess, "message, {strict: true}")},
]);`);
};
var getStrictResponseError = (error, isSubprocess) => new Error(`${getMethodName("sendMessage", isSubprocess)} failed when sending an acknowledgment response to the ${getOtherProcessName(isSubprocess)}.`, { cause: error });
Expand Down
47 changes: 27 additions & 20 deletions screenpipe-js/cli/src/commands/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,37 @@ export const createAppCommand = new Command()
let { name, appType } = options;

if (!appType) {
let { appTypePrompt } = await inquirer.prompt({
name: "appTypePrompt",
type: "select",
message: "what type of desktop app would you like to create?",
choices: [
{ name: "electron", value: "electron"},
{ name: "tauri", value: "tauri"}
],
default: "tauri"
});

appType = appTypePrompt
try {
let { appTypePrompt } = await inquirer.prompt({
name: "appTypePrompt",
type: "select",
message: "what type of desktop app would you like to create?",
choices: [
{ name: "electron", value: "electron"},
{ name: "tauri", value: "tauri"}
],
default: "tauri"
});
appType = appTypePrompt
} catch (error) {
handleError(error);
}
}


if (!name || name.length === 0) {
name = await input({
message: "What is your project name?",
default: "my-desktop-app",
validate: (input) => {
if (input.trim().length === 0) return "project name is required.";
return true;
},
});
try {
name = await input({
message: "What is your project name?",
default: "my-desktop-app",
validate: (input) => {
if (input.trim().length === 0) return "project name is required.";
return true;
},
});
} catch (error) {
handleError(error);
}
}

const loadingSpinner = spinner("creating your desktop app...");
Expand Down
34 changes: 22 additions & 12 deletions screenpipe-js/cli/src/commands/pipe/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,29 @@ export const createPipeCommand = new Command()
);
logger.log("build powerful agents, monetize it, etc.\n");

const pipeName = await input({
message: "what is your pipe name?",
default: "my-screenpipe",
validate: (input) => {
if (input.trim().length === 0) return "pipe name is required";
return true;
},
});
let pipeName = "";
try {
pipeName = await input({
message: "what is your pipe name?",
default: "my-screenpipe",
validate: (input) => {
if (input.trim().length === 0) return "pipe name is required";
return true;
},
});
} catch (error) {
handleError(error);
}

const directory = await input({
message: "where would you like to create your pipe?",
default: pipeName,
});
let directory = "";
try {
directory = await input({
message: "where would you like to create your pipe?",
default: pipeName,
});
} catch (error) {
handleError(error);
}

const spinner = ora("creating your pipe...").start();

Expand Down

0 comments on commit 97e1c1d

Please sign in to comment.