Skip to content

Commit 61a3918

Browse files
authored
Minimize the code with webpack (#14)
1 parent 375a52d commit 61a3918

File tree

12 files changed

+1447
-220
lines changed

12 files changed

+1447
-220
lines changed

.github/workflows/publish.yml

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@ jobs:
77
build:
88
strategy:
99
matrix:
10-
os: [ubuntu-latest, windows-latest]
10+
include:
11+
- os: ubuntu-latest
12+
platform: linux-x64
13+
wheel_platform: manylinux_2_17_x86_64
14+
- os: ubuntu-24.04-arm
15+
platform: linux-arm64
16+
wheel_platform: manylinux_2_17_aarch64
17+
- os: windows-latest
18+
platform: win32-x64
19+
wheel_platform: win_amd64
20+
- os: macos-13
21+
platform: darwin-x64
22+
wheel_platform: macosx_10_9_x86_64
23+
- os: macos-latest
24+
platform: darwin-arm64
25+
wheel_platform: macosx_11_0_arm64
1126

1227
runs-on: ${{ matrix.os }}
1328

@@ -25,14 +40,83 @@ jobs:
2540
- run: npm ci
2641
- run: npm run build-webview
2742
- run: npm run build-cli
28-
- run: npm run package
43+
- name: Package VSCode Extension for Windows
44+
if: matrix.platform == 'win32-x64'
45+
run: npm run package:win
46+
- name: Package VSCode Extension for ${{ matrix.platform }}
47+
if: matrix.platform != 'win32-x64'
48+
run: npm run package -- --target ${{ matrix.platform }}
2949
- run: python -m pip install -e .[dev]
30-
- run: hatch build
31-
- uses: actions/upload-artifact@v4
50+
- run: hatch build -t wheel
51+
52+
# Upload VSIX files individually (not as zip)
53+
- name: Find VSIX file
54+
id: find-vsix
55+
shell: bash
56+
run: |
57+
VSIX_FILE=$(find . -name "*.vsix" -type f | head -1)
58+
if [ -z "$VSIX_FILE" ]; then
59+
echo "No VSIX file found!"
60+
exit 1
61+
fi
62+
echo "vsix-file=$VSIX_FILE" >> $GITHUB_OUTPUT
63+
# Extract base name and create platform-specific name
64+
BASE_NAME=$(basename "$VSIX_FILE" .vsix)
65+
PLATFORM_VSIX="${BASE_NAME}.vsix"
66+
echo "platform-vsix-name=$PLATFORM_VSIX" >> $GITHUB_OUTPUT
67+
68+
- name: Upload VSIX for ${{ matrix.platform }}
69+
uses: actions/upload-artifact@v4
3270
with:
33-
name: poml-vscode-${{ matrix.os }}
34-
path: "*.vsix"
35-
- uses: actions/upload-artifact@v4
71+
name: ${{ steps.find-vsix.outputs.platform-vsix-name }}
72+
path: ${{ steps.find-vsix.outputs.vsix-file }}
73+
compression-level: 0
74+
75+
# Upload Python wheel files individually
76+
- name: Find and upload Python wheel
77+
shell: bash
78+
run: |
79+
WHEEL_FILE=$(find dist -name "*.whl" -type f | head -1)
80+
if [ -z "$WHEEL_FILE" ]; then
81+
echo "No wheel file found!"
82+
exit 1
83+
fi
84+
echo "wheel-file=$WHEEL_FILE" >> $GITHUB_OUTPUT
85+
86+
# Parse the original wheel filename to extract components
87+
WHEEL_NAME=$(basename "$WHEEL_FILE" .whl)
88+
89+
# Split wheel name into components: name-version-python_tag-abi_tag-platform_tag
90+
# Example: poml-0.0.5-py3-none-any -> poml, 0.0.5, py3, none, any
91+
IFS='-' read -ra PARTS <<< "$WHEEL_NAME"
92+
93+
if [ ${#PARTS[@]} -ge 5 ]; then
94+
# Standard format: name-version-python_tag-abi_tag-platform_tag
95+
DIST_NAME="${PARTS[0]}"
96+
VERSION="${PARTS[1]}"
97+
PYTHON_TAG="${PARTS[2]}"
98+
ABI_TAG="${PARTS[3]}"
99+
# Join remaining parts as platform tag (in case there are extra hyphens)
100+
PLATFORM_TAG=$(IFS='-'; echo "${PARTS[*]:4}")
101+
else
102+
echo "Warning: Unexpected wheel filename format: $WHEEL_NAME"
103+
# Fallback to original naming
104+
echo "platform-wheel-name=$WHEEL_NAME-${{ matrix.platform }}.whl" >> $GITHUB_OUTPUT
105+
exit 0
106+
fi
107+
108+
# Create platform-specific wheel name with proper platform tag
109+
PLATFORM_WHEEL="${DIST_NAME}-${VERSION}-${PYTHON_TAG}-${ABI_TAG}-${{ matrix.wheel_platform }}.whl"
110+
echo "platform-wheel-name=$PLATFORM_WHEEL" >> $GITHUB_OUTPUT
111+
112+
# Rename the wheel file to platform-specific name
113+
cp "$WHEEL_FILE" "dist/$PLATFORM_WHEEL"
114+
echo "renamed-wheel-file=dist/$PLATFORM_WHEEL" >> $GITHUB_OUTPUT
115+
id: find-wheel
116+
117+
- name: Upload Python wheel for ${{ matrix.platform }}
118+
uses: actions/upload-artifact@v4
36119
with:
37-
name: poml-python-${{ matrix.os }}
38-
path: dist/*
120+
name: ${{ steps.find-wheel.outputs.platform-wheel-name }}
121+
path: ${{ steps.find-wheel.outputs.renamed-wheel-file }}
122+
compression-level: 0

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"type": "extensionHost",
1111
"request": "launch",
1212
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13-
"outFiles": ["${workspaceFolder}/out/**/*.js"],
14-
"preLaunchTask": "${defaultBuildTask}"
13+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
14+
"preLaunchTask": "build-extension-dev"
1515
},
1616
{
1717
"name": "Debug Jest Tests",

.vscode/settings.json

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.exclude": {
4-
"out": false // set this to true to hide the "out" folder with the compiled JS files
5-
},
6-
"search.exclude": {
7-
"out": true // set this to false to include "out" folder in search results
8-
},
9-
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10-
"typescript.tsc.autoDetect": "off",
11-
"editor.defaultFormatter": "esbenp.prettier-vscode",
12-
"editor.indentSize": "tabSize",
13-
"[typescript]": {
14-
"editor.tabSize": 2
15-
},
16-
"[python]": {
17-
"editor.defaultFormatter": "ms-python.black-formatter"
18-
}
3+
"files.exclude": {
4+
"out": false // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off",
11+
"editor.defaultFormatter": "esbenp.prettier-vscode",
12+
"editor.indentSize": "tabSize",
13+
"[typescript]": {
14+
"editor.tabSize": 2
15+
},
16+
"[python]": {
17+
"editor.defaultFormatter": "ms-python.black-formatter"
18+
},
19+
"mcp": {
20+
"servers": {
21+
"filesystem": {
22+
"command": "npx",
23+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "${workspaceFolder}"]
24+
}
25+
}
26+
}
1927
}

.vscode/tasks.json

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,48 @@
11
// See https://go.microsoft.com/fwlink/?LinkId=733558
22
// for the documentation about the tasks.json format
33
{
4-
"version": "2.0.0",
5-
"tasks": [
6-
{
7-
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
10-
"isBackground": true,
11-
"presentation": {
12-
"reveal": "never"
13-
},
14-
"group": {
15-
"kind": "build",
16-
"isDefault": true
17-
}
18-
}
19-
]
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": "build"
15+
},
16+
{
17+
"label": "build-extension-dev",
18+
"type": "shell",
19+
"command": "npm",
20+
"args": ["run", "build-extension-dev"],
21+
"problemMatcher": ["$tsc"],
22+
"group": {
23+
"kind": "build",
24+
"isDefault": true
25+
},
26+
"presentation": {
27+
"echo": true,
28+
"reveal": "silent",
29+
"focus": false,
30+
"panel": "shared",
31+
"showReuseMessage": true,
32+
"clear": false
33+
}
34+
},
35+
{
36+
"label": "watch-extension",
37+
"type": "shell",
38+
"command": "npm",
39+
"args": ["run", "watch-extension"],
40+
"problemMatcher": [],
41+
"isBackground": true,
42+
"presentation": {
43+
"reveal": "never"
44+
},
45+
"group": "build"
46+
}
47+
]
2048
}

.vscodeignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# This file is auto-generated by vscodeignore.js. DO NOT EDIT MANUALLY.
2+
# It ensures that only necessary production dependencies are packaged with the extension.
3+
14
.vscode/**
25
.vscode-test/**
6+
out/**
37
packages/**
48
python/**
59
examples/**
@@ -13,3 +17,30 @@ vsc-extension-quickstart.md
1317
**/.vscode-test.*
1418
webpack.config.*
1519
.pytest_cache/**
20+
21+
# Hard coded ignore and unignore
22+
node_modules/**
23+
dist/**/node_modules/**
24+
!node_modules/@img/**
25+
!node_modules/pdf-parse/lib/pdf.js/v1.10.100
26+
!node_modules/pdf-parse/lib/pdf-parse.js
27+
!node_modules/pdf-parse/index.js
28+
!node_modules/pdf-parse/package.json
29+
!node_modules/sharp/install
30+
!node_modules/sharp/lib
31+
!node_modules/sharp/package.json
32+
33+
# But, do NOT ignore the following required modules:
34+
!node_modules/@emnapi/runtime/**
35+
!node_modules/color/**
36+
!node_modules/color-convert/**
37+
!node_modules/color-name/**
38+
!node_modules/color-string/**
39+
!node_modules/debug/**
40+
!node_modules/detect-libc/**
41+
!node_modules/is-arrayish/**
42+
!node_modules/ms/**
43+
!node_modules/node-ensure/**
44+
!node_modules/semver/**
45+
!node_modules/simple-swizzle/**
46+
!node_modules/tslib/**

0 commit comments

Comments
 (0)