Skip to content

Commit

Permalink
Merge pull request #4 from mohankumarelec/wsl-issues
Browse files Browse the repository at this point in the history
Fixed WSL Issues
  • Loading branch information
mohankumarelec authored Nov 12, 2024
2 parents effabea + a942f78 commit 4d66e75
Show file tree
Hide file tree
Showing 35 changed files with 4,664 additions and 837 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ jobs:
build:
name: "Build VS Code Extension"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
[
"win32-arm64",
"win32-x64",
"linux-arm64",
"linux-x64",
"linux-armhf",
"alpine-x64",
"darwin-x64",
"darwin-arm64",
"alpine-arm64",
]

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -24,17 +40,17 @@ jobs:
- name: Install dependencies
run: npm install

- name: Install vsce tool
run: npm install -g @vscode/vsce

- name: Checking Linting
run: npm run lint

- name: Compile Extension
run: npm run package -- --target ${{ matrix.platform }}

- name: Package extension
run: vsce package --out "extension.vsix"
run: npx vsce package --target ${{ matrix.platform }} --out "flexpilot-${{ matrix.platform }}.vsix"

- name: Upload extension vsix as artifact
uses: actions/upload-artifact@v4
with:
name: "extension.vsix"
path: "extension.vsix"
name: "flexpilot-${{ matrix.platform }}.vsix"
path: "flexpilot-${{ matrix.platform }}.vsix"
38 changes: 30 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ jobs:
name: "Release VS Code Extension"
runs-on: ubuntu-latest
environment: production
strategy:
fail-fast: false
matrix:
platform:
[
"win32-arm64",
"win32-x64",
"linux-arm64",
"linux-x64",
"linux-armhf",
"alpine-x64",
"darwin-x64",
"darwin-arm64",
"alpine-arm64",
]

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -58,27 +74,33 @@ jobs:
- name: Install dependencies
run: npm install

- name: Install vsce tool
run: npm install -g @vscode/vsce

- name: Checking Linting
run: npm run lint

- name: Compile Extension
run: npm run package -- --target ${{ matrix.platform }}

- name: Package extension
run: vsce package --out "extension.vsix"
run: npx vsce package --target ${{ matrix.platform }} --out "flexpilot-${{ matrix.platform }}.vsix"

- name: Upload extension vsix as artifact
uses: actions/upload-artifact@v4
with:
name: "extension.vsix"
path: "extension.vsix"
name: "flexpilot-${{ matrix.platform }}.vsix"
path: "flexpilot-${{ matrix.platform }}.vsix"

- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
files: extension.vsix
files: "flexpilot-${{ matrix.platform }}.vsix"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release to VS Code Marketplace
run: vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 6
retry_on: error
retry_wait_seconds: 10
command: npx vsce publish --packagePath "flexpilot-${{ matrix.platform }}.vsix" -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
7 changes: 7 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
#!/bin/sh
npx lint-staged

if git diff --cached --name-only | grep -qE "^(package\.json|package-lock\.json)$"; then
echo "Error: Changes to package.json or package-lock.json are not allowed."
exit 1
fi

echo "Completed Pre Commit Hooks ..."
35 changes: 35 additions & 0 deletions build/post-build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Command, Option } from "commander";
import * as fs from "fs";
import * as path from "path";
import extensionConfig from "../webpack.config.mjs";

const targetMapping = {
"win32-x64": "node-napi.win32-x64-msvc.node",
"win32-arm64": "node-napi.win32-arm64-msvc.node",
"linux-x64": "node-napi.linux-x64-gnu.node",
"linux-arm64": "node-napi.linux-arm64-gnu.node",
"linux-armhf": "node-napi.linux-arm-gnueabihf.node",
"alpine-x64": "node-napi.linux-x64-musl.node",
"darwin-x64": "node-napi.darwin-x64.node",
"darwin-arm64": "node-napi.darwin-arm64.node",
"alpine-arm64": "node-napi.linux-arm64-musl.node",
};

const args = new Command()
.addOption(
new Option("--target [platform]", "Specify the target VS Code platform")
.choices(Object.keys(targetMapping))
.makeOptionMandatory(),
)
.parse()
.opts();

const outDir = extensionConfig[0].output.path;
for (const file of fs.readdirSync(outDir)) {
if (file === targetMapping[args.target]) {
continue;
} else if (file.startsWith("node-napi")) {
console.log(`Deleting file: ${file}`);
fs.unlinkSync(path.join(outDir, file));
}
}
20 changes: 20 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@ export default [
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
{
ignores: ["node_modules/**", "build/**"],
rules: {
"no-restricted-imports": [
"error",
{
paths: [
{
name: "fs",
message: "Please use vscode.workspace.fs",
},
{
name: "fs/promises",
message: "Please use vscode.workspace.fs",
},
],
},
],
},
},
];
Loading

0 comments on commit 4d66e75

Please sign in to comment.