From 5164df7faa043733baaa0b315efe4407374737a7 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:19:12 -0700 Subject: [PATCH 01/14] Nightly publish CI --- .github/actions/ai-release-notes/action.yml | 83 ------------ .github/scripts/ai-release-notes.py | 123 ----------------- .github/scripts/get_prev_version_refs.py | 52 -------- .../scripts/overwrite_changeset_changelog.py | 62 --------- .github/scripts/parse_changeset_changelog.py | 64 --------- .github/scripts/release-notes-prompt.py | 125 ------------------ .github/workflows/build-vsix.yml | 45 ------- .github/workflows/codeql.yml | 11 -- .github/workflows/nightly-publish.yml | 57 ++++++++ apps/vscode-nightly/package.json | 1 + 10 files changed, 58 insertions(+), 565 deletions(-) delete mode 100644 .github/actions/ai-release-notes/action.yml delete mode 100644 .github/scripts/ai-release-notes.py delete mode 100644 .github/scripts/get_prev_version_refs.py delete mode 100755 .github/scripts/overwrite_changeset_changelog.py delete mode 100755 .github/scripts/parse_changeset_changelog.py delete mode 100644 .github/scripts/release-notes-prompt.py delete mode 100644 .github/workflows/build-vsix.yml create mode 100644 .github/workflows/nightly-publish.yml diff --git a/.github/actions/ai-release-notes/action.yml b/.github/actions/ai-release-notes/action.yml deleted file mode 100644 index 575e49c97c..0000000000 --- a/.github/actions/ai-release-notes/action.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: AI Release Notes -description: Generate AI release notes using git and openai, outputs 'RELEASE_NOTES' and 'OPENAI_PROMPT' - -inputs: - OPENAI_API_KEY: - required: true - type: string - GHA_PAT: - required: true - type: string - model_name: - required: false - type: string - default: gpt-4o-mini - repo_path: - required: false - type: string - custom_prompt: - required: false - default: '' - type: string - git_ref: - required: true - type: string - head_ref: - required: true - type: string - base_ref: - required: true - type: string - -outputs: - RELEASE_NOTES: - description: "AI generated release notes" - value: ${{ steps.ai_release_notes.outputs.RELEASE_NOTES }} - OPENAI_PROMPT: - description: "Prompt used to generate release notes" - value: ${{ steps.ai_prompt.outputs.OPENAI_PROMPT }} - -env: - GITHUB_REF: ${{ inputs.git_ref }} - BASE_REF: ${{ inputs.base_ref }} - HEAD_REF: ${{ inputs.head_ref }} - -runs: - using: "composite" - steps: - - uses: actions/checkout@v4 - with: - repository: ${{ inputs.repo_path }} - token: ${{ inputs.GHA_PAT }} - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Set Workspace - shell: bash - run: | - pip install tiktoken - pip install pytz - - # Github outputs: 'OPENAI_PROMPT' - - name: Add Git Info to base prompt - id: ai_prompt - shell: bash - env: - BASE_REF: ${{ env.BASE_REF }} - HEAD_SHA: ${{ env.HEAD_SHA }} - PR_TITLE: ${{ github.event.pull_request.title }} - PR_BODY: ${{ github.event.pull_request.body }} - MODEL_NAME: ${{ inputs.model_name }} - CUSTOM_PROMPT: ${{ inputs.custom_prompt }} # Default: '' - run: python .github/scripts/release-notes-prompt.py - - # Github outputs: 'RELEASE_NOTES' - - name: Generate AI release notes - id: ai_release_notes - shell: bash - env: - OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }} - CUSTOM_PROMPT: ${{ steps.ai_prompt.outputs.OPENAI_PROMPT }} - MODEL_NAME: ${{ inputs.model_name }} - run: python .github/scripts/ai-release-notes.py - diff --git a/.github/scripts/ai-release-notes.py b/.github/scripts/ai-release-notes.py deleted file mode 100644 index 5dc451810e..0000000000 --- a/.github/scripts/ai-release-notes.py +++ /dev/null @@ -1,123 +0,0 @@ -""" -AI-powered release notes generator that creates concise and informative release notes from git changes. - -This script uses OpenAI's API to analyze git changes (summary, diff, and commit log) and generate -well-formatted release notes in markdown. It focuses on important changes and their impact, -particularly highlighting new types and schemas while avoiding repetitive information. - -Environment Variables Required: - OPENAI_API_KEY: OpenAI API key for authentication - CHANGE_SUMMARY: Summary of changes made (optional if CUSTOM_PROMPT provided) - CHANGE_DIFF: Git diff of changes (optional if CUSTOM_PROMPT provided) - CHANGE_LOG: Git commit log (optional if CUSTOM_PROMPT provided) - GITHUB_OUTPUT: Path to GitHub output file - CUSTOM_PROMPT: Custom prompt to override default (optional) -""" - -import os -import requests # type: ignore -import json -import tiktoken # type: ignore - -OPENAI_API_KEY = os.environ["OPENAI_API_KEY"] -CHANGE_SUMMARY = os.environ.get('CHANGE_SUMMARY', '') -CHANGE_DIFF = os.environ.get('CHANGE_DIFF', '') -CHANGE_LOG = os.environ.get('CHANGE_LOG', '') -GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT") -OPEN_AI_BASE_URL = "https://api.openai.com/v1" -OPEN_API_HEADERS = {"Authorization": f"Bearer {OPENAI_API_KEY}", "Content-Type": "application/json"} -CUSTOM_PROMPT = os.environ.get('CUSTOM_PROMPT', '') -MODEL_NAME = os.environ.get('MODEL_NAME', 'gpt-3.5-turbo-16k') - -def num_tokens_from_string(string: str, model_name: str) -> int: - """ - Calculate the number of tokens in a text string for a specific model. - - Args: - string: The input text to count tokens for - model_name: Name of the OpenAI model to use for token counting - - Returns: - int: Number of tokens in the input string - """ - encoding = tiktoken.encoding_for_model(model_name) - num_tokens = len(encoding.encode(string)) - return num_tokens - -def truncate_to_token_limit(text, max_tokens, model_name): - """ - Truncate text to fit within a maximum token limit for a specific model. - - Args: - text: The input text to truncate - max_tokens: Maximum number of tokens allowed - model_name: Name of the OpenAI model to use for tokenization - - Returns: - str: Truncated text that fits within the token limit - """ - encoding = tiktoken.encoding_for_model(model_name) - encoded = encoding.encode(text) - truncated = encoded[:max_tokens] - return encoding.decode(truncated) - -def generate_release_notes(model_name): - """ - Generate release notes using OpenAI's API based on git changes. - - Uses the GPT-3.5-turbo model to analyze change summary, commit log, and code diff - to generate concise and informative release notes in markdown format. The notes - focus on important changes and their impact, with sections for new types/schemas - and other updates. - - Returns: - str: Generated release notes in markdown format - - Raises: - requests.exceptions.RequestException: If the OpenAI API request fails - """ - max_tokens = 14000 # Reserve some tokens for the response - - # Truncate inputs if necessary to fit within token limits - change_summary = '' if CUSTOM_PROMPT else truncate_to_token_limit(CHANGE_SUMMARY, 1000, model_name) - change_log = '' if CUSTOM_PROMPT else truncate_to_token_limit(CHANGE_LOG, 2000, model_name) - change_diff = '' if CUSTOM_PROMPT else truncate_to_token_limit(CHANGE_DIFF, max_tokens - num_tokens_from_string(change_summary, model_name) - num_tokens_from_string(change_log, model_name) - 1000, model_name) - - url = f"{OPEN_AI_BASE_URL}/chat/completions" - - # Construct prompt for OpenAI API - openai_prompt = CUSTOM_PROMPT if CUSTOM_PROMPT else f"""Based on the following summary of changes, commit log and code diff, please generate concise and informative release notes: - Summary of changes: - {change_summary} - Commit log: - {change_log} - Code Diff: - {json.dumps(change_diff)} - """ - - data = { - "model": model_name, - "messages": [{"role": "user", "content": openai_prompt}], - "temperature": 0.7, - "max_tokens": 1000, - } - - print("----------------------------------------------------------------------------------------------------------") - print("POST request to OpenAI") - print("----------------------------------------------------------------------------------------------------------") - ai_response = requests.post(url, headers=OPEN_API_HEADERS, json=data) - print(f"Status Code: {str(ai_response.status_code)}") - print(f"Response: {ai_response.text}") - ai_response.raise_for_status() - - return ai_response.json()["choices"][0]["message"]["content"] - -release_notes = generate_release_notes(MODEL_NAME) -print("----------------------------------------------------------------------------------------------------------") -print("OpenAI generated release notes") -print("----------------------------------------------------------------------------------------------------------") -print(release_notes) - -# Write the release notes to GITHUB_OUTPUT -with open(GITHUB_OUTPUT, "a") as outputs_file: - outputs_file.write(f"RELEASE_NOTES<= 3: - # Parse HEAD~1 (PR to generate notes for) - head_info = parse_merge_commit(commits[1]) - # Parse HEAD~2 (previous PR to compare against) - base_info = parse_merge_commit(commits[2]) - - if head_info and base_info: - # Set output for GitHub Actions - with open(os.environ['GITHUB_OUTPUT'], 'a') as gha_outputs: - gha_outputs.write(f"head_ref={head_info['sha']}\n") - gha_outputs.write(f"base_ref={base_info['sha']}") - - print(f"Head ref (PR #{head_info['pr_number']}): {head_info['sha']}") - print(f"Base ref (PR #{base_info['pr_number']}): {base_info['sha']}") - return head_info, base_info - - print("Could not find or parse sufficient merge history") - return None, None - -if __name__ == "__main__": - head_info, base_info = get_version_refs() \ No newline at end of file diff --git a/.github/scripts/overwrite_changeset_changelog.py b/.github/scripts/overwrite_changeset_changelog.py deleted file mode 100755 index 42e693d4ac..0000000000 --- a/.github/scripts/overwrite_changeset_changelog.py +++ /dev/null @@ -1,62 +0,0 @@ -""" -This script updates a specific version's release notes section in CHANGELOG.md with new content -or reformats existing content. - -The script: -1. Takes a version number, changelog path, and optionally new content as input from environment variables -2. Finds the section in the changelog for the specified version -3. Either: - a) Replaces the content with new content if provided, or - b) Reformats existing content by: - - Removing the first two lines of the changeset format - - Ensuring version numbers are wrapped in square brackets -4. Writes the updated changelog back to the file - -Environment Variables: - CHANGELOG_PATH: Path to the changelog file (defaults to 'CHANGELOG.md') - VERSION: The version number to update/format - PREV_VERSION: The previous version number (used to locate section boundaries) - NEW_CONTENT: Optional new content to insert for this version -""" - -#!/usr/bin/env python3 - -import os - -CHANGELOG_PATH = os.environ.get("CHANGELOG_PATH", "CHANGELOG.md") -VERSION = os.environ['VERSION'] -PREV_VERSION = os.environ.get("PREV_VERSION", "") -NEW_CONTENT = os.environ.get("NEW_CONTENT", "") - -def overwrite_changelog_section(changelog_text: str, new_content: str): - # Find the section for the specified version - version_pattern = f"## {VERSION}\n" - prev_version_pattern = f"## [{PREV_VERSION}]\n" - print(f"latest version: {VERSION}") - print(f"prev_version: {PREV_VERSION}") - - notes_start_index = changelog_text.find(version_pattern) + len(version_pattern) - notes_end_index = changelog_text.find(prev_version_pattern, notes_start_index) if PREV_VERSION and prev_version_pattern in changelog_text else len(changelog_text) - - if new_content: - return changelog_text[:notes_start_index] + f"{new_content}\n" + changelog_text[notes_end_index:] - else: - changeset_lines = changelog_text[notes_start_index:notes_end_index].split("\n") - # Remove the first two lines from the regular changeset format, ex: \n### Patch Changes - parsed_lines = "\n".join(changeset_lines[2:]) - updated_changelog = changelog_text[:notes_start_index] + parsed_lines + changelog_text[notes_end_index:] - updated_changelog = updated_changelog.replace(f"## {VERSION}", f"## [{VERSION}]") - return updated_changelog - -with open(CHANGELOG_PATH, 'r') as f: - changelog_content = f.read() - -new_changelog = overwrite_changelog_section(changelog_content, NEW_CONTENT) -print("----------------------------------------------------------------------------------") -print(new_changelog) -print("----------------------------------------------------------------------------------") -# Write back to CHANGELOG.md -with open(CHANGELOG_PATH, 'w') as f: - f.write(new_changelog) - -print(f"{CHANGELOG_PATH} updated successfully!") \ No newline at end of file diff --git a/.github/scripts/parse_changeset_changelog.py b/.github/scripts/parse_changeset_changelog.py deleted file mode 100755 index b21c444dd1..0000000000 --- a/.github/scripts/parse_changeset_changelog.py +++ /dev/null @@ -1,64 +0,0 @@ -""" -This script extracts the release notes section for a specific version from CHANGELOG.md. - -The script: -1. Takes a version number and changelog path as input from environment variables -2. Finds the section in the changelog for the specified version -3. Extracts the content between the current version header and the next version header - (or end of file if it's the latest version) -4. Outputs the extracted release notes to GITHUB_OUTPUT for use in creating GitHub releases - -Environment Variables: - GITHUB_OUTPUT: Path to GitHub Actions output file - CHANGELOG_PATH: Path to the changelog file (defaults to 'CHANGELOG.md') - VERSION: The version number to extract notes for -""" - -#!/usr/bin/env python3 - -import sys -import os -import subprocess - -GITHUB_OUTPUT = os.getenv("GITHUB_OUTPUT") -CHANGELOG_PATH = os.environ.get("CHANGELOG_PATH", "CHANGELOG.md") -VERSION = os.environ['VERSION'] - -def parse_changelog_section(content: str): - """Parse a specific version section from the changelog content. - - Args: - content: The full changelog content as a string - - Returns: - The formatted content for this version, or None if version not found - - Example: - >>> content = "## 1.2.0\\nChanges\\n## 1.1.0\\nOld changes" - >>> parse_changelog_section(content) - 'Changes\\n' - """ - # Find the section for the specified version - version_pattern = f"## {VERSION}\n" - print(f"latest version: {VERSION}") - notes_start_index = content.find(version_pattern) + len(version_pattern) - prev_version = subprocess.getoutput("git show origin/main:package.json | grep '\"version\":' | cut -d'\"' -f4") - print(f"prev_version: {prev_version}") - prev_version_pattern = f"## {prev_version}\n" - notes_end_index = content.find(prev_version_pattern, notes_start_index) if prev_version_pattern in content else len(content) - - return content[notes_start_index:notes_end_index] - -with open(CHANGELOG_PATH, 'r') as f: - content = f.read() - -formatted_content = parse_changelog_section(content) -if not formatted_content: - print(f"Version {VERSION} not found in changelog", file=sys.stderr) - sys.exit(1) - -print(formatted_content) - -# Write the extracted release notes to GITHUB_OUTPUT -with open(GITHUB_OUTPUT, "a") as gha_output: - gha_output.write(f"release-notes< and that contains [!IMPORTANT] - ellipsis_match = re.search(r'(.*?)', pr_body, re.DOTALL) - if ellipsis_match: - content = ellipsis_match.group(1).strip() - important_match = re.search(r'\[!IMPORTANT\](.*?)(?=\[!|$)', content, re.DOTALL) - if important_match: - important_text = important_match.group(1).strip() - important_text = re.sub(r'^-+\s*', '', important_text) - return important_text.strip() - return "" - -def extract_coderabbit_summary(pr_body): - # Find content between ## Summary by CodeRabbit and the next ## or end of text - summary_match = re.search(r'## Summary by CodeRabbit\s*\n(.*?)(?=\n##|$)', pr_body, re.DOTALL) - return summary_match.group(1).strip() if summary_match else "" - -def num_tokens_from_string(string: str, model_name: str) -> int: - """ - Calculate the number of tokens in a text string for a specific model. - - Args: - string: The input text to count tokens for - model_name: Name of the OpenAI model to use for token counting - - Returns: - int: Number of tokens in the input string - """ - encoding = tiktoken.encoding_for_model(model_name) - num_tokens = len(encoding.encode(string)) - return num_tokens - -def truncate_to_token_limit(text, max_tokens, model_name): - """ - Truncate text to fit within a maximum token limit for a specific model. - - Args: - text: The input text to truncate - max_tokens: Maximum number of tokens allowed - model_name: Name of the OpenAI model to use for tokenization - - Returns: - str: Truncated text that fits within the token limit - """ - encoding = tiktoken.encoding_for_model(model_name) - encoded = encoding.encode(text) - truncated = encoded[:max_tokens] - return encoding.decode(truncated) - -# Extract sections and combine into PR_OVERVIEW -description = extract_description_section(PR_BODY) -important = extract_ellipsis_important(PR_BODY) -summary = extract_coderabbit_summary(PR_BODY) - -PR_OVERVIEW = "\n\n".join(filter(None, [description, important, summary])) - -# Get git information -base_sha = subprocess.getoutput(f"git rev-parse origin/{BASE_REF}") if BASE_REF == 'main' else BASE_REF -diff_overview = subprocess.getoutput(f"git diff {base_sha}..{HEAD_SHA} --name-status | awk '{{print $2}}' | sort | uniq -c | awk '{{print $2 \": \" $1 \" files changed\"}}'") -git_log = subprocess.getoutput(f"git log {base_sha}..{HEAD_SHA} --pretty=format:'%h - %s (%an)' --reverse | head -n 50") -git_diff = subprocess.getoutput(f"git diff {base_sha}..{HEAD_SHA} --minimal --abbrev --ignore-cr-at-eol --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --unified=0 --diff-filter=ACDMRT") - -max_tokens = 14000 # Reserve some tokens for the response -changes_summary = truncate_to_token_limit(diff_overview, 1000, MODEL_NAME) -git_logs = truncate_to_token_limit(git_log, 2000, MODEL_NAME) -changes_diff = truncate_to_token_limit(git_diff, max_tokens - num_tokens_from_string(changes_summary, MODEL_NAME) - num_tokens_from_string(git_logs, MODEL_NAME) - 1000, MODEL_NAME) - -# Get today's existing changelog if any -existing_changelog = EXISTING_NOTES if EXISTING_NOTES != "null" else None -existing_changelog_text = f"\nAdditional context:\n{existing_changelog}" if existing_changelog else "" -TODAY = datetime.now(timezone('US/Eastern')).isoformat(sep=' ', timespec='seconds') - -BASE_PROMPT = CUSTOM_PROMPT if CUSTOM_PROMPT else f"""Based on the following 'PR Information', please generate concise and informative release notes to be read by developers. -Format the release notes with markdown, and always use this structure: a descriptive and very short title (no more than 8 words) with heading level 2, a paragraph with a summary of changes (no header), and if applicable, sections for '🚀 New Features & Improvements', '🐛 Bugs Fixed' and '🔧 Other Updates', with heading level 3, skip respectively the sections if not applicable. -Finally include the following markdown comment with the PR merged date: . -Avoid being repetitive and focus on the most important changes and their impact, discard any mention of version bumps/updates, changeset files, environment variables or syntax updates. -PR Information:""" - -OPENAI_PROMPT = f"""{BASE_PROMPT} -Git log summary: -{changes_summary} -Commit Messages: -{git_logs} -PR Title: -{PR_TITLE} -PR Overview: -{PR_OVERVIEW}{existing_changelog_text} -Code Diff: -{json.dumps(changes_diff)}""" - -print("OpenAI Prompt") -print("----------------------------------------------------------------") -print(OPENAI_PROMPT) - -# Write the prompt to GITHUB_OUTPUT -with open(GITHUB_OUTPUT, "a") as outputs_file: - outputs_file.write(f"OPENAI_PROMPT<> $GITHUB_OUTPUT + - name: Patch package.json version + env: + COMMIT_COUNT: ${{ steps.count.outputs.total }} + run: | + node <<'EOF' + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('apps/vscode-nightly/package.json','utf8')); + const [maj, min] = pkg.version.split('.'); + pkg.version = `${maj}.${min}.${process.env.COMMIT_COUNT}`; + fs.writeFileSync('apps/vscode-nightly/package.json', JSON.stringify(pkg, null, 2)); + console.log(`🔖 Nightly version set to ${pkg.version}`); + EOF + - name: Build VSIX + run: pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix + - name: Publish to VS Code Marketplace (Nightly channel) + env: + VSCE_PAT: ${{ secrets.VSCE_PAT_NIGHTLY }} + run: echo npx vsce publish --pre-release --packagePath "bin/$(/bin/ls bin | head -n1)" + - name: Publish to Open VSX + env: + OVSX_PAT: ${{ secrets.OVSX_PAT }} + run: echo npx ovsx publish "bin/$(ls bin | head -n1)" --pre-release diff --git a/apps/vscode-nightly/package.json b/apps/vscode-nightly/package.json index dcd0e55d00..0acff4df63 100644 --- a/apps/vscode-nightly/package.json +++ b/apps/vscode-nightly/package.json @@ -6,6 +6,7 @@ "scripts": { "build": "rimraf build && pnpm --filter @roo-code/build build && node esbuild.mjs --production && pnpm --filter @roo-code/vscode-webview build --mode nightly", "vsix": "pnpm build && cd build && mkdirp ../../../bin && npx vsce package --no-dependencies --out ../../../bin", + "publish:marketplace": "pnpm build && cd build && vsce publish --no-dependencies", "clean": "rimraf build" }, "dependencies": { From 1a90eb569e273a74aded9d205d2d2d1737096416 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:21:17 -0700 Subject: [PATCH 02/14] Revert this --- apps/vscode-nightly/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/vscode-nightly/package.json b/apps/vscode-nightly/package.json index 0acff4df63..dcd0e55d00 100644 --- a/apps/vscode-nightly/package.json +++ b/apps/vscode-nightly/package.json @@ -6,7 +6,6 @@ "scripts": { "build": "rimraf build && pnpm --filter @roo-code/build build && node esbuild.mjs --production && pnpm --filter @roo-code/vscode-webview build --mode nightly", "vsix": "pnpm build && cd build && mkdirp ../../../bin && npx vsce package --no-dependencies --out ../../../bin", - "publish:marketplace": "pnpm build && cd build && vsce publish --no-dependencies", "clean": "rimraf build" }, "dependencies": { From 40b2176f924defa6b7aea804e0458243f614a7a5 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:22:23 -0700 Subject: [PATCH 03/14] Add branch for testing --- .github/workflows/nightly-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 4c0cc82dc7..21966a2405 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -2,7 +2,7 @@ name: Nightly Publish on: push: - branches: [main] + branches: [main, cte/nightly-ci] workflow_dispatch: # Allows manual triggering. env: From 2134c52b2f0e4a15f1cb8621bddfd958d5fe1b9f Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:24:26 -0700 Subject: [PATCH 04/14] Fix path --- .github/workflows/nightly-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 21966a2405..026c1213c8 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -39,7 +39,7 @@ jobs: run: | node <<'EOF' const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('apps/vscode-nightly/package.json','utf8')); + const pkg = JSON.parse(fs.readFileSync('apps/vscode-nightly/package.nightly.json','utf8')); const [maj, min] = pkg.version.split('.'); pkg.version = `${maj}.${min}.${process.env.COMMIT_COUNT}`; fs.writeFileSync('apps/vscode-nightly/package.json', JSON.stringify(pkg, null, 2)); From 62cf7df0b038194c57836233430f8f03c8b58a4e Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:29:19 -0700 Subject: [PATCH 05/14] Debugging --- .github/workflows/nightly-publish.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 026c1213c8..bc3cf989a2 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install pnpm uses: pnpm/action-setup@v4 with: @@ -32,7 +34,9 @@ jobs: run: pnpm install --frozen-lockfile - name: Count commits id: count - run: echo "total=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT + run: | + git rev-list --count HEAD + echo "total=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT - name: Patch package.json version env: COMMIT_COUNT: ${{ steps.count.outputs.total }} @@ -46,7 +50,9 @@ jobs: console.log(`🔖 Nightly version set to ${pkg.version}`); EOF - name: Build VSIX - run: pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix + run: | + ls -al + pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix - name: Publish to VS Code Marketplace (Nightly channel) env: VSCE_PAT: ${{ secrets.VSCE_PAT_NIGHTLY }} From 3928d6acad65934373d7495d93ca77a6e6c68f10 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:32:24 -0700 Subject: [PATCH 06/14] SSH debugging --- .github/workflows/nightly-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index bc3cf989a2..69f40c72a3 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -49,6 +49,8 @@ jobs: fs.writeFileSync('apps/vscode-nightly/package.json', JSON.stringify(pkg, null, 2)); console.log(`🔖 Nightly version set to ${pkg.version}`); EOF + - name: Setup upterm session + uses: lhotari/action-upterm@v1 - name: Build VSIX run: | ls -al From abbbd94fe3199bc0b7f1211d2134548efa4006ad Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:35:49 -0700 Subject: [PATCH 07/14] Fix build --- .github/workflows/nightly-publish.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 69f40c72a3..fb373466e0 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -43,14 +43,16 @@ jobs: run: | node <<'EOF' const fs = require('fs'); - const pkg = JSON.parse(fs.readFileSync('apps/vscode-nightly/package.nightly.json','utf8')); + const path = require('path'); + const pkgPath = path.join(__dirname, 'apps', 'vscode-nightly', 'package.nightly.json'); + const pkg = JSON.parse(fs.readFileSync(pkgPath,'utf8')); const [maj, min] = pkg.version.split('.'); pkg.version = `${maj}.${min}.${process.env.COMMIT_COUNT}`; - fs.writeFileSync('apps/vscode-nightly/package.json', JSON.stringify(pkg, null, 2)); + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); console.log(`🔖 Nightly version set to ${pkg.version}`); EOF - - name: Setup upterm session - uses: lhotari/action-upterm@v1 + # - name: Setup upterm session + # uses: lhotari/action-upterm@v1 - name: Build VSIX run: | ls -al From 66890bfa75507f5896991978f4339579a37249c5 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:38:43 -0700 Subject: [PATCH 08/14] Test it out! --- .github/workflows/nightly-publish.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index fb373466e0..84980b76ea 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -34,9 +34,7 @@ jobs: run: pnpm install --frozen-lockfile - name: Count commits id: count - run: | - git rev-list --count HEAD - echo "total=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT + run: echo "total=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT - name: Patch package.json version env: COMMIT_COUNT: ${{ steps.count.outputs.total }} @@ -51,17 +49,13 @@ jobs: fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); console.log(`🔖 Nightly version set to ${pkg.version}`); EOF - # - name: Setup upterm session - # uses: lhotari/action-upterm@v1 - name: Build VSIX - run: | - ls -al - pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix + run: pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix - name: Publish to VS Code Marketplace (Nightly channel) env: VSCE_PAT: ${{ secrets.VSCE_PAT_NIGHTLY }} - run: echo npx vsce publish --pre-release --packagePath "bin/$(/bin/ls bin | head -n1)" + run: npx vsce publish --pre-release --packagePath "bin/$(/bin/ls bin | head -n1)" - name: Publish to Open VSX env: OVSX_PAT: ${{ secrets.OVSX_PAT }} - run: echo npx ovsx publish "bin/$(ls bin | head -n1)" --pre-release + run: npx ovsx publish "bin/$(ls bin | head -n1)" --pre-release From 0f2d4a107a5b922e9c7699a663cb7676a13d096d Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:44:38 -0700 Subject: [PATCH 09/14] Move build tools to root packge --- apps/vscode-nightly/package.json | 6 ------ package.json | 5 +++++ pnpm-lock.yaml | 28 +++++++++++++++------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/apps/vscode-nightly/package.json b/apps/vscode-nightly/package.json index dcd0e55d00..b7d611276c 100644 --- a/apps/vscode-nightly/package.json +++ b/apps/vscode-nightly/package.json @@ -10,11 +10,5 @@ }, "dependencies": { "@roo-code/build": "workspace:^" - }, - "devDependencies": { - "@vscode/vsce": "3.3.2", - "esbuild": "^0.25.0", - "mkdirp": "^3.0.1", - "rimraf": "^6.0.1" } } diff --git a/package.json b/package.json index 9d954de6d5..2a91b79fe5 100644 --- a/package.json +++ b/package.json @@ -20,12 +20,17 @@ "devDependencies": { "@changesets/cli": "^2.27.10", "@dotenvx/dotenvx": "^1.34.0", + "@vscode/vsce": "3.3.2", + "esbuild": "^0.25.0", "eslint": "^8.57.0", "husky": "^9.1.7", "knip": "^5.44.4", "lint-staged": "^15.2.11", + "mkdirp": "^3.0.1", "only-allow": "^1.2.1", + "ovsx": "0.10.2", "prettier": "^3.4.2", + "rimraf": "^6.0.1", "turbo": "^2.5.3", "typescript": "^5.4.5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed3dfa5c81..cde314be68 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,12 @@ importers: '@dotenvx/dotenvx': specifier: ^1.34.0 version: 1.44.0 + '@vscode/vsce': + specifier: 3.3.2 + version: 3.3.2 + esbuild: + specifier: ^0.25.0 + version: 0.25.4 eslint: specifier: ^8.57.0 version: 8.57.1 @@ -26,12 +32,21 @@ importers: lint-staged: specifier: ^15.2.11 version: 15.5.2 + mkdirp: + specifier: ^3.0.1 + version: 3.0.1 only-allow: specifier: ^1.2.1 version: 1.2.1 + ovsx: + specifier: 0.10.2 + version: 0.10.2 prettier: specifier: ^3.4.2 version: 3.5.3 + rimraf: + specifier: ^6.0.1 + version: 6.0.1 turbo: specifier: ^2.5.3 version: 2.5.3 @@ -44,19 +59,6 @@ importers: '@roo-code/build': specifier: workspace:^ version: link:../../packages/build - devDependencies: - '@vscode/vsce': - specifier: 3.3.2 - version: 3.3.2 - esbuild: - specifier: ^0.25.0 - version: 0.25.4 - mkdirp: - specifier: ^3.0.1 - version: 3.0.1 - rimraf: - specifier: ^6.0.1 - version: 6.0.1 e2e: devDependencies: From 0b473486cf02c2082d4aab00c839e2c35b536e80 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:47:09 -0700 Subject: [PATCH 10/14] Don't use the --pre-release flag --- .github/workflows/nightly-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 84980b76ea..321f288dd4 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -54,8 +54,8 @@ jobs: - name: Publish to VS Code Marketplace (Nightly channel) env: VSCE_PAT: ${{ secrets.VSCE_PAT_NIGHTLY }} - run: npx vsce publish --pre-release --packagePath "bin/$(/bin/ls bin | head -n1)" + run: npx vsce publish --packagePath "bin/$(/bin/ls bin | head -n1)" - name: Publish to Open VSX env: OVSX_PAT: ${{ secrets.OVSX_PAT }} - run: npx ovsx publish "bin/$(ls bin | head -n1)" --pre-release + run: npx ovsx publish "bin/$(ls bin | head -n1)" From dd17769b6bc3e04983647a6f28d340a1ab2fa82c Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:49:30 -0700 Subject: [PATCH 11/14] Fix VSCE_PAT --- .github/workflows/nightly-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 321f288dd4..0981dcc421 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -53,7 +53,7 @@ jobs: run: pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix - name: Publish to VS Code Marketplace (Nightly channel) env: - VSCE_PAT: ${{ secrets.VSCE_PAT_NIGHTLY }} + VSCE_PAT: ${{ secrets.VSCE_PAT }} run: npx vsce publish --packagePath "bin/$(/bin/ls bin | head -n1)" - name: Publish to Open VSX env: From 0ac4e3b4ae334460f95ea90eac5c0e94319a5e04 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 10:54:53 -0700 Subject: [PATCH 12/14] Tweak titles --- .github/workflows/nightly-publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 0981dcc421..cca169b5db 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -2,7 +2,7 @@ name: Nightly Publish on: push: - branches: [main, cte/nightly-ci] + branches: [main] workflow_dispatch: # Allows manual triggering. env: @@ -51,11 +51,11 @@ jobs: EOF - name: Build VSIX run: pnpm build:nightly # Produces bin/roo-code-nightly-0.0.[count].vsix - - name: Publish to VS Code Marketplace (Nightly channel) + - name: Publish to VS Code Marketplace env: VSCE_PAT: ${{ secrets.VSCE_PAT }} run: npx vsce publish --packagePath "bin/$(/bin/ls bin | head -n1)" - - name: Publish to Open VSX + - name: Publish to Open VSX Registry env: OVSX_PAT: ${{ secrets.OVSX_PAT }} run: npx ovsx publish "bin/$(ls bin | head -n1)" From fbf9a11cf5c7b7d181261c650f3e2ba839f5428e Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 11:17:40 -0700 Subject: [PATCH 13/14] Add README, CHANGELOG --- .github/workflows/nightly-publish.yml | 2 +- apps/vscode-nightly/esbuild.mjs | 4 +- src/.gitignore | 4 +- src/.vscodeignore | 8 +- src/LICENSE | 201 -------------------------- src/esbuild.js | 64 +++++--- 6 files changed, 55 insertions(+), 228 deletions(-) delete mode 100644 src/LICENSE diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index cca169b5db..2eca539449 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -2,7 +2,7 @@ name: Nightly Publish on: push: - branches: [main] + branches: [main, cte/nightly-ci] workflow_dispatch: # Allows manual triggering. env: diff --git a/apps/vscode-nightly/esbuild.mjs b/apps/vscode-nightly/esbuild.mjs index fe61ab4f14..718b444cf6 100644 --- a/apps/vscode-nightly/esbuild.mjs +++ b/apps/vscode-nightly/esbuild.mjs @@ -52,7 +52,9 @@ async function main() { setup(build) { build.onEnd(() => { const paths = [ - ["LICENSE", "LICENSE"], + ["../README.md", "README.md"], + ["../CHANGELOG.md", "CHANGELOG.md"], + ["../LICENSE", "LICENSE"], [".vscodeignore", ".vscodeignore"], ["assets", "assets"], ["integrations", "integrations"], diff --git a/src/.gitignore b/src/.gitignore index c7d4d26e07..cdbce7731c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,5 @@ +README.md +CHANGELOG.md +LICENSE webview-ui - assets/vscode-material-icons diff --git a/src/.vscodeignore b/src/.vscodeignore index cdbdf13cb2..3aaf4b677b 100644 --- a/src/.vscodeignore +++ b/src/.vscodeignore @@ -1,6 +1,11 @@ # Exclude everything ** +# Include README.md, CHANGELOG.md and LICENSE +!README.md +!CHANGELOG.md +!LICENSE + # Include package.json !package.json !package.nls.* @@ -15,9 +20,6 @@ !webview-ui/build/assets/*.ttf !webview-ui/build/assets/*.css -# Include the license file -!LICENSE - # Include default themes JSON files used in getTheme !integrations/theme/default-themes/** diff --git a/src/LICENSE b/src/LICENSE deleted file mode 100644 index 302fa51c8a..0000000000 --- a/src/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2025 Roo Code, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/src/esbuild.js b/src/esbuild.js index 12073f30dc..5bb554989a 100644 --- a/src/esbuild.js +++ b/src/esbuild.js @@ -5,6 +5,38 @@ const path = require("path") const production = process.argv.includes("--production") const watch = process.argv.includes("--watch") +/** + * @param {[string, string][]} copyPaths + * @param {string} srcDir + * @param {string} dstDir + * @returns {void} + */ +function copyPaths(copyPaths, srcDir, dstDir) { + copyPaths.forEach(([srcRelPath, dstRelPath]) => { + const stats = fs.lstatSync(path.join(srcDir, srcRelPath)) + + if (stats.isDirectory()) { + if (fs.existsSync(path.join(dstDir, dstRelPath))) { + fs.rmSync(path.join(dstDir, dstRelPath), { recursive: true }) + } + + 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}`) + } + }) +} + +/** + * @param {string} srcDir + * @param {string} dstDir + * @param {number} count + * @returns {number} + */ function copyDir(srcDir, dstDir, count) { const entries = fs.readdirSync(srcDir, { withFileTypes: true }) @@ -172,27 +204,17 @@ const copyAssets = { name: "copy-assets", setup(build) { build.onEnd(() => { - const copyPaths = [ - ["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"], - ["../webview-ui/audio", "webview-ui/audio"], - ] - - for (const [srcRelPath, dstRelPath] of copyPaths) { - const srcDir = path.join(__dirname, srcRelPath) - const dstDir = path.join(__dirname, dstRelPath) - - if (!fs.existsSync(srcDir)) { - throw new Error(`Directory does not exist: ${srcDir}`) - } - - if (fs.existsSync(dstDir)) { - fs.rmSync(dstDir, { recursive: true }) - } - - fs.mkdirSync(dstDir, { recursive: true }) - const count = copyDir(srcDir, dstDir, 0) - console.log(`[copy-assets] Copied ${count} assets from ${srcDir} to ${dstDir}`) - } + copyPaths( + [ + ["../README.md", "README.md"], + ["../CHANGELOG.md", "CHANGELOG.md"], + ["../LICENSE", "LICENSE"], + ["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"], + ["../webview-ui/audio", "webview-ui/audio"], + ], + __dirname, + __dirname, + ) }) }, } From 68274f45889898f7ff1df4f6b285958928fdc159 Mon Sep 17 00:00:00 2001 From: cte Date: Wed, 21 May 2025 11:27:45 -0700 Subject: [PATCH 14/14] Remove debugging --- .github/workflows/nightly-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-publish.yml b/.github/workflows/nightly-publish.yml index 2eca539449..cca169b5db 100644 --- a/.github/workflows/nightly-publish.yml +++ b/.github/workflows/nightly-publish.yml @@ -2,7 +2,7 @@ name: Nightly Publish on: push: - branches: [main, cte/nightly-ci] + branches: [main] workflow_dispatch: # Allows manual triggering. env: