Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: #1486 windows create pipe cli

Louis Beaumonta4120c4e8090
diff --git a/screenpipe-js/cli/dist/index.js b/screenpipe-js/cli/dist/index.js
index 873f60486..863ac5e57 100755
--- a/screenpipe-js/cli/dist/index.js
+++ b/screenpipe-js/cli/dist/index.js
@@ -62418,11 +62418,23 @@ var PIPE_ADDITIONS = {
};
async function downloadAndExtractSubdir(subdir, destPath) {
const tempDir = path3.join(destPath, "_temp");
- await import_fs_extra.default.ensureDir(tempDir);
- await esm_default13().clone("https://github.com/mediar-ai/screenpipe", tempDir);
- const sourcePath = path3.join(tempDir, subdir);
- await import_fs_extra.default.copy(sourcePath, destPath);
- await import_fs_extra.default.remove(tempDir);
+ try {
+ await import_fs_extra.default.ensureDir(destPath);
+ await import_fs_extra.default.ensureDir(tempDir);
+ const git = esm_default13();
+ await git.clone("https://github.com/mediar-ai/screenpipe", tempDir);
+ const sourcePath = path3.join(tempDir, subdir);
+ if (!await import_fs_extra.default.pathExists(sourcePath)) {
+ throw new Error(`Template directory '${subdir}' not found in repository`);
+ }
+ await import_fs_extra.default.copy(sourcePath, destPath);
+ await import_fs_extra.default.remove(tempDir);
+ } catch (error) {
+ if (await import_fs_extra.default.pathExists(tempDir)) {
+ await import_fs_extra.default.remove(tempDir);
+ }
+ throw new Error(`Failed to setup pipe: ${error.message}`);
+ }
}
var createPipeCommand = new Command().name("create").description("create a new pipe").action(async () => {
console.log(source_default.bold(`
@@ -62465,8 +62477,9 @@ welcome to screenpipe!
}
const loadingSpinner = spinner("creating your pipe...");
try {
- await downloadAndExtractSubdir("pipes/obsidian", directory);
- const pkgPath = path3.join(process.cwd(), directory, "package.json");
+ const absoluteDirectory = path3.resolve(process.cwd(), directory);
+ await downloadAndExtractSubdir("pipes/obsidian", absoluteDirectory);
+ const pkgPath = path3.join(absoluteDirectory, "package.json");
const pkg = await import_fs_extra.default.readJson(pkgPath);
pkg.name = pipeName;
pkg.dependencies = {
@@ -62481,7 +62494,7 @@ welcome to screenpipe!
loadingSpinner.succeed(source_default.green(`> pipe created successfully!`));
console.log(`
to get started:`);
- console.log(source_default.cyan(`cd ${directory}`));
+ console.log(source_default.cyan(`cd ${absoluteDirectory}`));
console.log(source_default.cyan("bun install # or use: npm install, pnpm install, yarn"));
console.log(source_default.cyan("bun dev # or use: npm run dev, pnpm dev, yarn dev"));
console.log(`
@@ -62603,6 +62616,17 @@ var registry_default = {
"@types/lodash"
]
},
+ "update-pipe-config": {
+ name: "update-pipe-config",
+ src: "https://api.github.com/repos/mediar-ai/screenpipe/contents/pipes/obsidian/src/lib/actions/update-pipe-config.tsx",
+ target: "./src/lib/actions/update-pipe-config.tsx",
+ dependencies: [
+ "@screenpipe/browser"
+ ],
+ registryDependencies: [
+ "types"
+ ]
+ },
"use-pipe-settings": {
name: "use-pipe-settings",
src: "https://api.github.com/repos/mediar-ai/screenpipe/contents/pipes/obsidian/src/lib/hooks/use-pipe-settings.tsx",
diff --git a/screenpipe-js/cli/package.json b/screenpipe-js/cli/package.json
index 751de0351..2ba89d68a 100644
--- a/screenpipe-js/cli/package.json
+++ b/screenpipe-js/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@screenpipe/dev",
- "version": "1.1.13",
+ "version": "1.1.14",
"description": "screenpipe development CLI",
"type": "module",
"main": "dist/index.js",
diff --git a/screenpipe-js/cli/src/commands/pipe/create.ts b/screenpipe-js/cli/src/commands/pipe/create.ts
index b0002e2e9..5f18d8a3c 100755
--- a/screenpipe-js/cli/src/commands/pipe/create.ts
+++ b/screenpipe-js/cli/src/commands/pipe/create.ts
@@ -22,11 +22,29 @@ const PIPE_ADDITIONS = {
async function downloadAndExtractSubdir(subdir: string, destPath: string) {
const tempDir = path.join(destPath, "_temp");
- await fs.ensureDir(tempDir);
- await simpleGit().clone("https://github.com/mediar-ai/screenpipe", tempDir);
- const sourcePath = path.join(tempDir, subdir);
- await fs.copy(sourcePath, destPath);
- await fs.remove(tempDir);
+ try {
+ // Ensure the destination path exists first
+ await fs.ensureDir(destPath);
+ await fs.ensureDir(tempDir);
+
+ // Use more specific error handling for git clone
+ const git = simpleGit();
+ await git.clone("https://github.com/mediar-ai/screenpipe", tempDir);
+
+ const sourcePath = path.join(tempDir, subdir);
+ if (!(await fs.pathExists(sourcePath))) {
+ throw new Error(`Template directory '${subdir}' not found in repository`);
+ }
+
+ await fs.copy(sourcePath, destPath);
+ await fs.remove(tempDir);
+ } catch (error: any) {
+ // Clean up temp directory if it exists
+ if (await fs.pathExists(tempDir)) {
+ await fs.remove(tempDir);
+ }
+ throw new Error(`Failed to setup pipe: ${error.message}`);
+ }
}
export const createPipeCommand = new Command()
@@ -73,11 +91,14 @@ export const createPipeCommand = new Command()
const loadingSpinner = spinner("creating your pipe...");
try {
+ // Ensure we have an absolute path
+ const absoluteDirectory = path.resolve(process.cwd(), directory);
+
// Download and extract the appropriate template
- await downloadAndExtractSubdir("pipes/obsidian", directory);
+ await downloadAndExtractSubdir("pipes/obsidian", absoluteDirectory);
// Update package.json with the pipe name
- const pkgPath = path.join(process.cwd(), directory, "package.json");
+ const pkgPath = path.join(absoluteDirectory, "package.json");
const pkg = await fs.readJson(pkgPath);
pkg.name = pipeName;
@@ -95,7 +116,7 @@ export const createPipeCommand = new Command()
loadingSpinner.succeed(chalk.green(`> pipe created successfully!`));
console.log("\nto get started:");
- console.log(chalk.cyan(`cd ${directory}`));
+ console.log(chalk.cyan(`cd ${absoluteDirectory}`));
console.log(
chalk.cyan("bun install # or use: npm install, pnpm install, yarn")
);