Skip to content

Commit 93fc192

Browse files
lennondotwclaude
andcommitted
🎉 initial: complete pnpm workspace extension with workspace dependencies copy feature
Co-Authored-By: Claude <noreply@anthropic.com>
0 parents  commit 93fc192

39 files changed

Lines changed: 7139 additions & 0 deletions

‎.gitattributes‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.png filter=lfs diff=lfs merge=lfs -text
2+
*.jpg filter=lfs diff=lfs merge=lfs -text
3+
*.jpeg filter=lfs diff=lfs merge=lfs -text
4+
5+
# Ensure consistent line endings across platforms
6+
* text=auto eol=lf
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Setup cache
2+
description: Setup cache for all node_modules/.cache and .next/cache directories
3+
4+
inputs:
5+
restore-key-prefix:
6+
description: The prefix to use for the restore key
7+
required: false
8+
default: 'cache'
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Get versions and cache info
14+
id: cache-info
15+
shell: bash
16+
run: |
17+
NODE_VERSION=$(jq -r '.engines.node' package.json)
18+
PNPM_VERSION=$(jq -r '.engines.pnpm' package.json)
19+
PACKAGE_MANAGER_VERSION=$(jq -r '.packageManager' package.json | cut -d'@' -f2)
20+
21+
# Use package manager version if engines.pnpm is not set
22+
PNPM_VERSION=${PNPM_VERSION:-$PACKAGE_MANAGER_VERSION}
23+
24+
# Calculate week number since Unix epoch
25+
# Week number helps with periodic cache invalidation
26+
CURRENT_TIMESTAMP=$(date +%s)
27+
WEEK_NUMBER=$(( CURRENT_TIMESTAMP / 604800 ))
28+
29+
PNPM_STORE_PATH=$(pnpm store path --silent)
30+
LOCKFILE_HASH=${{ hashFiles('**/pnpm-lock.yaml') }}
31+
LOCKFILE_SHORT_HASH=${LOCKFILE_HASH:0:7}
32+
33+
OS=${{ runner.os }}
34+
LOWERCASE_OS=$(echo "${OS}" | tr '[:upper:]' '[:lower:]')
35+
36+
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
37+
echo "pnpm_version=${PNPM_VERSION}" >> $GITHUB_OUTPUT
38+
echo "week_number=${WEEK_NUMBER}" >> $GITHUB_OUTPUT
39+
echo "lockfile_hash=${LOCKFILE_SHORT_HASH}" >> $GITHUB_OUTPUT
40+
echo "os=${LOWERCASE_OS}" >> $GITHUB_OUTPUT
41+
echo "pnpm_store_path=${PNPM_STORE_PATH}" >> $GITHUB_OUTPUT
42+
43+
- name: Setup build cache
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
${{ steps.cache-info.outputs.pnpm_store_path }}
48+
**/node_modules/.cache/
49+
!**/node_modules/**/node_modules/.cache/
50+
**/node_modules/.vscode-test/
51+
!**/node_modules/**/node_modules/.vscode-test/
52+
**/node_modules/.vscode-test-web/
53+
!**/node_modules/**/node_modules/.vscode-test-web/
54+
key: |
55+
${{ inputs.restore-key-prefix }}-${{ steps.cache-info.outputs.os }}-w${{ steps.cache-info.outputs.week_number }}-lockfile-${{ steps.cache-info.outputs.lockfile_hash }}-pnpm${{ steps.cache-info.outputs.pnpm_version }}-node${{ steps.cache-info.outputs.node_version }}
56+
restore-keys: |
57+
${{ inputs.restore-key-prefix }}-${{ steps.cache-info.outputs.os }}-w${{ steps.cache-info.outputs.week_number }}-lockfile-${{ steps.cache-info.outputs.lockfile_hash }}-
58+
${{ inputs.restore-key-prefix }}-${{ steps.cache-info.outputs.os }}-w${{ steps.cache-info.outputs.week_number }}-
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Setup Node.js with corepack
2+
description: Setup Node.js from package.json and enable corepack
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Read Node.js version from package.json
8+
id: node-version
9+
shell: bash
10+
run: |
11+
NODE_VERSION=$(jq -r '.engines.node' package.json)
12+
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: ${{ steps.node-version.outputs.node_version }}
18+
19+
- name: Enable corepack
20+
shell: bash
21+
run: corepack enable
22+
23+
- name: Prepare package manager
24+
shell: bash
25+
run: corepack prepare
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Build and Publish
4+
5+
on:
6+
push:
7+
branches:
8+
- '*'
9+
tags:
10+
- 'v*'
11+
pull_request:
12+
branches:
13+
- main
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
name: Lint and typecheck
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
lfs: true
25+
26+
- name: Setup Node.js with corepack
27+
uses: ./.github/actions/setup-node
28+
29+
- name: Setup cache
30+
uses: ./.github/actions/setup-cache
31+
with:
32+
restore-key-prefix: 'lint-cache'
33+
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
37+
- name: Run typecheck
38+
run: pnpm run check-types
39+
40+
- name: Run linting
41+
run: pnpm run lint
42+
43+
test:
44+
name: Run tests
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [macos-latest, ubuntu-latest, windows-latest]
49+
runs-on: ${{ matrix.os }}
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
lfs: true
56+
57+
- name: Setup Node.js with corepack
58+
uses: ./.github/actions/setup-node
59+
60+
- name: Setup cache
61+
uses: ./.github/actions/setup-cache
62+
with:
63+
restore-key-prefix: 'test-cache'
64+
65+
- name: Install dependencies
66+
run: pnpm install --frozen-lockfile
67+
68+
- name: Run tests (Linux)
69+
if: runner.os == 'Linux'
70+
run: xvfb-run -a pnpm run test
71+
72+
- name: Run tests (non-Linux)
73+
if: runner.os != 'Linux'
74+
run: pnpm run test
75+
76+
build:
77+
runs-on: ubuntu-latest
78+
name: Build extension
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4
83+
with:
84+
lfs: true
85+
86+
- name: Setup Node.js with corepack
87+
uses: ./.github/actions/setup-node
88+
89+
- name: Setup cache
90+
uses: ./.github/actions/setup-cache
91+
with:
92+
restore-key-prefix: 'build-cache'
93+
94+
- name: Install dependencies
95+
run: pnpm install --frozen-lockfile
96+
97+
- name: Build extension
98+
run: pnpm run package
99+
100+
- name: Validate package version
101+
run: |
102+
PACKAGE_VERSION=$(jq -r '.version' package.json)
103+
MINOR_VERSION=$(echo "$PACKAGE_VERSION" | cut -d. -f2)
104+
if [ $((MINOR_VERSION % 2)) -ne 0 ]; then
105+
echo "Error: Minor version must be even. Current version: $PACKAGE_VERSION"
106+
echo "::error title=Minor version must be even::Minor version in package.json must be even. Current version: $PACKAGE_VERSION"
107+
exit 1
108+
fi
109+
echo "Version validation passed: $PACKAGE_VERSION"
110+
111+
- name: Set version for packaging
112+
id: version
113+
run: |
114+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
115+
PACKAGE_VERSION=$(jq -r '.version' package.json)
116+
VERSION="${PACKAGE_VERSION}"
117+
else
118+
PACKAGE_VERSION=$(jq -r '.version' package.json)
119+
MAJOR=$(echo "$PACKAGE_VERSION" | cut -d. -f1)
120+
MINOR=$(echo "$PACKAGE_VERSION" | cut -d. -f2)
121+
NEXT_MINOR=$((MINOR + 1))
122+
# Use GitHub run number for guaranteed increment
123+
PATCH="${{ github.run_number }}"
124+
VERSION="${MAJOR}.${NEXT_MINOR}.${PATCH}"
125+
fi
126+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
127+
128+
- name: Package extension (Pre-release)
129+
if: github.ref_type != 'tag'
130+
run: |
131+
# Temporarily update package.json version for pre-release packaging
132+
jq --arg version "${{ steps.version.outputs.version }}" '.version = $version' package.json > package.json.tmp
133+
mv package.json.tmp package.json
134+
135+
pnpm vsce package --no-dependencies --pre-release --out "package-navigator-${{ steps.version.outputs.version }}.vsix"
136+
echo "📦 Build type: Pre-release" >> $GITHUB_STEP_SUMMARY
137+
echo "🚀 Version: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
138+
139+
- name: Package extension (Release)
140+
if: github.ref_type == 'tag'
141+
run: |
142+
pnpm vsce package --no-dependencies --out "package-navigator-${{ steps.version.outputs.version }}.vsix"
143+
echo "📦 Build type: Release" >> $GITHUB_STEP_SUMMARY
144+
echo "🚀 Version: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
145+
146+
- name: Upload build artifacts
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: vscode-extension
150+
path: '*.vsix'
151+
152+
publish-ovsx:
153+
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref == 'refs/heads/main')
154+
needs:
155+
- lint
156+
- test
157+
- build
158+
runs-on: ubuntu-latest
159+
name: Publish to Open VSX
160+
161+
steps:
162+
- name: Setup Node.js
163+
uses: actions/setup-node@v4
164+
with:
165+
node-version: 22
166+
167+
- name: Enable corepack
168+
shell: bash
169+
run: corepack enable
170+
171+
- name: Prepare pnpm
172+
shell: bash
173+
run: |
174+
corepack prepare pnpm@latest --activate
175+
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
176+
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
177+
178+
- name: Install ovsx CLI
179+
run: pnpm add -g ovsx --dangerously-allow-all-builds
180+
181+
- name: Download build artifacts
182+
uses: actions/download-artifact@v4
183+
with:
184+
name: vscode-extension
185+
186+
- name: Publish to Open VSX
187+
run: ovsx publish --packagePath *.vsix --pat ${{ secrets.OVSX_TOKEN }}
188+
189+
publish-vsce:
190+
if: github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref == 'refs/heads/main')
191+
needs:
192+
- lint
193+
- test
194+
- build
195+
runs-on: ubuntu-latest
196+
name: Publish to VS Code Marketplace
197+
198+
steps:
199+
- name: Setup Node.js
200+
uses: actions/setup-node@v4
201+
with:
202+
node-version: 22
203+
204+
- name: Enable corepack
205+
shell: bash
206+
run: corepack enable
207+
208+
- name: Prepare pnpm
209+
shell: bash
210+
run: |
211+
corepack prepare pnpm@latest --activate
212+
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
213+
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH
214+
215+
- name: Install vsce CLI
216+
run: pnpm add -g vsce --dangerously-allow-all-builds
217+
218+
- name: Download build artifacts
219+
uses: actions/download-artifact@v4
220+
with:
221+
name: vscode-extension
222+
223+
- name: Publish to VS Code Marketplace
224+
run: vsce publish --packagePath *.vsix --pat ${{ secrets.VSCE_TOKEN }}

‎.gitignore‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
out/
2+
dist/
3+
dist-test/
4+
node_modules/
5+
.vscode-test/
6+
.vscode-test-web/
7+
*.vsix
8+
.DS_Store

‎.npmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enable-pre-post-scripts = true

‎.prettierrc.mjs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** @type {import('prettier').Config} */
2+
export default {
3+
semi: true,
4+
printWidth: 120,
5+
trailingComma: 'es5',
6+
singleQuote: true,
7+
tabWidth: 2,
8+
plugins: ['prettier-plugin-organize-imports'],
9+
organizeImportsSkipDestructiveCodeActions: true,
10+
endOfLine: 'lf',
11+
overrides: [
12+
{
13+
files: 'tsconfig{,.*}.json',
14+
options: { parser: 'jsonc', trailingComma: 'none' },
15+
},
16+
],
17+
};

‎.vscode-test.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'dist-test/extension.test.cjs',
5+
});

‎.vscode/extensions.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"dbaeumer.vscode-eslint",
6+
"connor4312.esbuild-problem-matchers",
7+
"ms-vscode.extension-test-runner"
8+
]
9+
}

‎.vscode/launch.json‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"],
13+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
14+
"preLaunchTask": "${defaultBuildTask}"
15+
},
16+
{
17+
"name": "Run Web Extension",
18+
"type": "extensionHost",
19+
"debugWebWorkerHost": true,
20+
"request": "launch",
21+
"args": [
22+
"--extensionDevelopmentPath=${workspaceFolder}",
23+
"--extensionDevelopmentKind=web",
24+
"--disable-extensions"
25+
],
26+
"outFiles": ["${workspaceFolder}/dist/web/**/*.js"],
27+
"preLaunchTask": "${defaultBuildTask}"
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)