From 2d6f4851b8f80ec1cb38a55b9b55fad9934482de Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 27 May 2025 09:25:09 -0700 Subject: [PATCH 1/4] Fix Posthog by correctly copying .env in the build process --- src/esbuild.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/esbuild.mjs b/src/esbuild.mjs index d8c96b4ede..f9560ef48f 100644 --- a/src/esbuild.mjs +++ b/src/esbuild.mjs @@ -52,6 +52,7 @@ async function main() { ["../README.md", "README.md"], ["../CHANGELOG.md", "CHANGELOG.md"], ["../LICENSE", "LICENSE"], + ["../.env", ".env"], ["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"], ["../webview-ui/audio", "webview-ui/audio"], ], From 741448e40820f220425463a70d4dfe9273ca5e4e Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 27 May 2025 09:34:01 -0700 Subject: [PATCH 2/4] Fix vsix sanity check --- .github/workflows/marketplace-publish.yml | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/marketplace-publish.yml b/.github/workflows/marketplace-publish.yml index d86be2083b..6e2dc09a01 100644 --- a/.github/workflows/marketplace-publish.yml +++ b/.github/workflows/marketplace-publish.yml @@ -45,15 +45,22 @@ jobs: run: | current_package_version=$(node -p "require('./src/package.json').version") pnpm build - package=$(unzip -l bin/roo-cline-${current_package_version}.vsix) - echo "$package" | grep -q "extension/package.json" || exit 1 - echo "$package" | grep -q "extension/package.nls.json" || exit 1 - echo "$package" | grep -q "extension/dist/extension.js" || exit 1 - echo "$package" | grep -q "extension/webview-ui/audio/celebration.wav" || exit 1 - echo "$package" | grep -q "extension/webview-ui/build/assets/index.js" || exit 1 - echo "$package" | grep -q "extension/assets/codicons/codicon.ttf" || exit 1 - echo "$package" | grep -q "extension/assets/vscode-material-icons/icons/3d.svg" || exit 1 - echo "$package" | grep -q ".env" || exit 1 + + # Save VSIX contents to a temporary file to avoid broken pipe issues. + unzip -l bin/roo-cline-${current_package_version}.vsix > /tmp/roo-code-vsix-contents.txt + + # Check for required files. + grep -q "extension/package.json" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/package.nls.json" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/dist/extension.js" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/webview-ui/audio/celebration.wav" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/webview-ui/build/assets/index.js" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/assets/codicons/codicon.ttf" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q "extension/assets/vscode-material-icons/icons/3d.svg" /tmp/roo-code-vsix-contents.txt || exit 1 + grep -q ".env" /tmp/roo-code-vsix-contents.txt || exit 1 + + # Clean up temporary file. + rm /tmp/roo-code-vsix-contents.txt - name: Create and Push Git Tag run: | current_package_version=$(node -p "require('./src/package.json').version") From cbeeff4e9c7bc6b3f16f967fff7b465e8529be89 Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 27 May 2025 09:57:33 -0700 Subject: [PATCH 3/4] Make .env optional --- .prettierignore | 6 ----- .prettierrc.json | 3 ++- apps/vscode-nightly/esbuild.mjs | 1 + packages/build/src/esbuild.ts | 47 ++++++++++++++++++++++----------- src/esbuild.mjs | 2 +- 5 files changed, 36 insertions(+), 23 deletions(-) delete mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 7d8675f8cb..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -dist -build -out -.next -.venv -pnpm-lock.yaml diff --git a/.prettierrc.json b/.prettierrc.json index cd4329335c..520c1bd5f7 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,5 +3,6 @@ "useTabs": true, "printWidth": 120, "semi": false, - "bracketSameLine": true + "bracketSameLine": true, + "ignore": ["node_modules", "dist", "build", "out", ".next", ".venv", "pnpm-lock.yaml"] } diff --git a/apps/vscode-nightly/esbuild.mjs b/apps/vscode-nightly/esbuild.mjs index ccc999e78b..d4302fc100 100644 --- a/apps/vscode-nightly/esbuild.mjs +++ b/apps/vscode-nightly/esbuild.mjs @@ -67,6 +67,7 @@ async function main() { ["../README.md", "README.md"], ["../CHANGELOG.md", "CHANGELOG.md"], ["../LICENSE", "LICENSE"], + ["../.env", ".env", { optional: true }], [".vscodeignore", ".vscodeignore"], ["assets", "assets"], ["integrations", "integrations"], diff --git a/packages/build/src/esbuild.ts b/packages/build/src/esbuild.ts index e91275447d..ab76ca2ff7 100644 --- a/packages/build/src/esbuild.ts +++ b/packages/build/src/esbuild.ts @@ -29,7 +29,9 @@ function rmDir(dirPath: string, maxRetries: number = 3): void { return } catch (error) { const isLastAttempt = attempt === maxRetries - const isEnotemptyError = error instanceof Error && "code" in error && (error.code === 'ENOTEMPTY' || error.code === 'EBUSY') + + const isEnotemptyError = + error instanceof Error && "code" in error && (error.code === "ENOTEMPTY" || error.code === "EBUSY") if (isLastAttempt || !isEnotemptyError) { throw error // Re-throw if it's the last attempt or not a locking error. @@ -41,27 +43,42 @@ function rmDir(dirPath: string, maxRetries: number = 3): void { // Synchronous sleep for simplicity in build scripts. const start = Date.now() - while (Date.now() - start < delay) { /* Busy wait */ } + + while (Date.now() - start < delay) { + /* Busy wait */ + } } } } -export function copyPaths(copyPaths: [string, string][], srcDir: string, dstDir: string) { - copyPaths.forEach(([srcRelPath, dstRelPath]) => { - const stats = fs.lstatSync(path.join(srcDir, srcRelPath)) +type CopyPathOptions = { + optional?: boolean +} - if (stats.isDirectory()) { - if (fs.existsSync(path.join(dstDir, dstRelPath))) { - rmDir(path.join(dstDir, dstRelPath)) - } +export function copyPaths(copyPaths: [string, string, CopyPathOptions?][], srcDir: string, dstDir: string) { + copyPaths.forEach(([srcRelPath, dstRelPath, options = {}]) => { + try { + const stats = fs.lstatSync(path.join(srcDir, srcRelPath)) - fs.mkdirSync(path.join(dstDir, dstRelPath), { recursive: true }) + if (stats.isDirectory()) { + if (fs.existsSync(path.join(dstDir, dstRelPath))) { + rmDir(path.join(dstDir, dstRelPath)) + } - const count = copyDir(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath), 0) - console.log(`[copyPaths] Copied ${count} files from ${srcRelPath} to ${dstRelPath}`) - } else { - fs.copyFileSync(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath)) - console.log(`[copyPaths] Copied ${srcRelPath} to ${dstRelPath}`) + fs.mkdirSync(path.join(dstDir, dstRelPath), { recursive: true }) + + const count = copyDir(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath), 0) + console.log(`[copyPaths] Copied ${count} files from ${srcRelPath} to ${dstRelPath}`) + } else { + fs.copyFileSync(path.join(srcDir, srcRelPath), path.join(dstDir, dstRelPath)) + console.log(`[copyPaths] Copied ${srcRelPath} to ${dstRelPath}`) + } + } catch (error) { + if (options.optional) { + console.warn(`[copyPaths] Optional file not found: ${srcRelPath}`) + } else { + throw error + } } }) } diff --git a/src/esbuild.mjs b/src/esbuild.mjs index f9560ef48f..3f7986bfc5 100644 --- a/src/esbuild.mjs +++ b/src/esbuild.mjs @@ -52,7 +52,7 @@ async function main() { ["../README.md", "README.md"], ["../CHANGELOG.md", "CHANGELOG.md"], ["../LICENSE", "LICENSE"], - ["../.env", ".env"], + ["../.env", ".env", { optional: true }], ["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"], ["../webview-ui/audio", "webview-ui/audio"], ], From a439a84fbf4970f79a308d12a83b52aa55b76e57 Mon Sep 17 00:00:00 2001 From: cte Date: Tue, 27 May 2025 10:06:22 -0700 Subject: [PATCH 4/4] Add changeset --- .changeset/thirty-cases-fail.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thirty-cases-fail.md diff --git a/.changeset/thirty-cases-fail.md b/.changeset/thirty-cases-fail.md new file mode 100644 index 0000000000..cfa78e2102 --- /dev/null +++ b/.changeset/thirty-cases-fail.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Fix Posthog by correctly copying .env in the build process