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

always build project (#1541)

neo7731251a9e00cad
diff --git a/screenpipe-js/cli/dist/index.js b/screenpipe-js/cli/dist/index.js
index ba7656bc9..e83f61dfd 100755
--- a/screenpipe-js/cli/dist/index.js
+++ b/screenpipe-js/cli/dist/index.js
@@ -20179,12 +20179,6 @@ function archiveStandardProject(archive, ig) {
mark: true
});
}
-function isProjectBuilt() {
- if (fs3.existsSync("next.config.js") || fs3.existsSync("next.config.mjs") || fs3.existsSync("next.config.ts")) {
- return fs3.existsSync(".next") && fs3.existsSync(".next/server");
- }
- return fs3.existsSync("dist") || fs3.existsSync("build") || fs3.existsSync("out");
-}
function runBuildCommand() {
logger.info(
colors.info(
@@ -20235,6 +20229,16 @@ var publishCommand = new Command4("publish").description("publish or update a pi
);
process.exit(1);
}
+ if (!opts.skipBuildCheck) {
+ try {
+ runBuildCommand();
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error(colors.error(`${symbols.error} ${error.message}`));
+ process.exit(1);
+ }
+ }
+ }
if (opts.verbose) {
console.log(colors.dim(`${symbols.arrow} reading package.json...`));
}
@@ -20334,24 +20338,6 @@ ${symbols.info} publishing ${colors.highlight(
if (opts.verbose) {
console.log(colors.dim(`${symbols.arrow} calculating file hash...`));
}
- if (!opts.skipBuildCheck && !isProjectBuilt()) {
- if (opts.build) {
- runBuildCommand();
- } else {
- console.error(
- colors.error(
- `${symbols.error} Project has not been built. Run ${colors.highlight(
- "bun run build"
- )} or ${colors.highlight(
- "npm run build"
- )} first, or use ${colors.highlight(
- "--build"
- )} flag to build automatically.`
- )
- );
- process.exit(1);
- }
- }
try {
console.log(colors.dim(`${symbols.arrow} getting upload URL...`));
const urlResponse = await fetch(`${API_BASE_URL}/api/plugins/publish`, {
diff --git a/screenpipe-js/cli/src/commands/pipe/publish.ts b/screenpipe-js/cli/src/commands/pipe/publish.ts
index 73b8fda9c..0dc3e4422 100644
--- a/screenpipe-js/cli/src/commands/pipe/publish.ts
+++ b/screenpipe-js/cli/src/commands/pipe/publish.ts
@@ -99,22 +99,6 @@ async function retryFetch(
throw new Error("Retry failed"); // Fallback error
}
-function isProjectBuilt(): boolean {
- // For Next.js projects
- if (
- fs.existsSync("next.config.js") ||
- fs.existsSync("next.config.mjs") ||
- fs.existsSync("next.config.ts")
- ) {
- return fs.existsSync(".next") && fs.existsSync(".next/server");
- }
-
- // For other projects - check common build directories
- return (
- fs.existsSync("dist") || fs.existsSync("build") || fs.existsSync("out")
- );
-}
-
function runBuildCommand(): void {
logger.info(
colors.info(
@@ -179,6 +163,17 @@ export const publishCommand = new Command("publish")
);
process.exit(1);
}
+ // Check if the project needs to be built
+ if (!opts.skipBuildCheck) {
+ try {
+ runBuildCommand();
+ } catch (error) {
+ if (error instanceof Error) {
+ console.error(colors.error(`${symbols.error} ${error.message}`));
+ process.exit(1);
+ }
+ }
+ }
if (opts.verbose) {
console.log(colors.dim(`${symbols.arrow} reading package.json...`));
@@ -305,29 +300,6 @@ export const publishCommand = new Command("publish")
console.log(colors.dim(`${symbols.arrow} calculating file hash...`));
}
- // Check if project is built (unless explicitly skipped)
- if (!opts.skipBuildCheck && !isProjectBuilt()) {
- if (opts.build) {
- // Run build if --build flag is provided
- runBuildCommand();
- } else {
- console.error(
- colors.error(
- `${
- symbols.error
- } Project has not been built. Run ${colors.highlight(
- "bun run build"
- )} or ${colors.highlight(
- "npm run build"
- )} first, or use ${colors.highlight(
- "--build"
- )} flag to build automatically.`
- )
- );
- process.exit(1);
- }
- }
-
// Replace the upload section with this:
try {
// First get the signed URL