Skip to content

Commit 98ebc22

Browse files
Merge pull request #65 from magebitcom/release
Release
2 parents bf6c4a7 + 5126445 commit 98ebc22

File tree

69 files changed

+3970
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3970
-154
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Run CI jobs
2+
on: [push, pull_request]
3+
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-node@v3
11+
with:
12+
node-version: '22'
13+
- run: npm install
14+
- run: npm run lint
15+
16+
test:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: '22'
24+
- run: npm install
25+
- run: xvfb-run -a npm test

.github/workflows/lint.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.vscode-test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineConfig } from '@vscode/test-cli';
22

33
export default defineConfig({
4-
files: 'out/test/**/*.test.js',
4+
files: ['dist/test/setup.js', 'dist/test/**/*.test.js'],
55
});

.vscode/tasks.json

Lines changed: 42 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,46 @@
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-
"label": "watch",
8-
"dependsOn": [
9-
"npm: watch:tsc",
10-
"npm: watch:esbuild"
11-
],
12-
"presentation": {
13-
"reveal": "never"
14-
},
15-
"group": {
16-
"kind": "build",
17-
"isDefault": true
18-
}
19-
},
20-
{
21-
"type": "npm",
22-
"script": "watch:esbuild",
23-
"group": "build",
24-
"problemMatcher": "$esbuild-watch",
25-
"isBackground": true,
26-
"label": "npm: watch:esbuild",
27-
"presentation": {
28-
"group": "watch",
29-
"reveal": "never"
30-
}
31-
},
32-
{
33-
"type": "npm",
34-
"script": "watch:tsc",
35-
"group": "build",
36-
"problemMatcher": "$tsc-watch",
37-
"isBackground": true,
38-
"label": "npm: watch:tsc",
39-
"presentation": {
40-
"group": "watch",
41-
"reveal": "never"
42-
}
43-
},
44-
{
45-
"type": "npm",
46-
"script": "watch-tests",
47-
"problemMatcher": "$tsc-watch",
48-
"isBackground": true,
49-
"presentation": {
50-
"reveal": "never",
51-
"group": "watchers"
52-
},
53-
"group": "build"
54-
},
55-
{
56-
"label": "tasks: watch-tests",
57-
"dependsOn": [
58-
"npm: watch",
59-
"npm: watch-tests"
60-
],
61-
"problemMatcher": []
62-
}
63-
]
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "watch",
8+
"dependsOn": ["npm: watch:esbuild"],
9+
"presentation": {
10+
"reveal": "never"
11+
},
12+
"group": {
13+
"kind": "build",
14+
"isDefault": true
15+
}
16+
},
17+
{
18+
"type": "npm",
19+
"script": "watch:esbuild",
20+
"group": "build",
21+
"problemMatcher": "$esbuild-watch",
22+
"isBackground": true,
23+
"label": "npm: watch:esbuild",
24+
"presentation": {
25+
"group": "watch",
26+
"reveal": "never"
27+
}
28+
},
29+
{
30+
"type": "npm",
31+
"script": "watch-tests",
32+
"problemMatcher": "$tsc-watch",
33+
"isBackground": true,
34+
"presentation": {
35+
"reveal": "never",
36+
"group": "watchers"
37+
},
38+
"group": "build"
39+
},
40+
{
41+
"label": "tasks: watch-tests",
42+
"dependsOn": ["npm: watch", "npm: watch-tests"],
43+
"problemMatcher": []
44+
}
45+
]
6446
}

esbuild.test.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
const esbuild = require('esbuild');
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
const production = process.argv.includes('--production');
6+
const watch = process.argv.includes('--watch');
7+
8+
/**
9+
* @type {import('esbuild').Plugin}
10+
*/
11+
const esbuildProblemMatcherPlugin = {
12+
name: 'esbuild-problem-matcher',
13+
14+
setup(build) {
15+
build.onStart(() => {
16+
console.log('[watch] test build started');
17+
});
18+
build.onEnd(result => {
19+
result.errors.forEach(({ text, location }) => {
20+
console.error(`✘ [ERROR] ${text}`);
21+
console.error(` ${location.file}:${location.line}:${location.column}:`);
22+
});
23+
console.log('[watch] test build finished');
24+
});
25+
},
26+
};
27+
28+
/**
29+
* @type {import('esbuild').Plugin}
30+
*/
31+
const copyAssetsPlugin = {
32+
name: 'copy-assets',
33+
setup(build) {
34+
build.onEnd(() => {
35+
const copyDir = (src, dest) => {
36+
if (!fs.existsSync(dest)) {
37+
fs.mkdirSync(dest, { recursive: true });
38+
}
39+
40+
const entries = fs.readdirSync(src, { withFileTypes: true });
41+
42+
for (const entry of entries) {
43+
const srcPath = path.join(src, entry.name);
44+
const destPath = path.join(dest, entry.name);
45+
46+
if (entry.isDirectory()) {
47+
copyDir(srcPath, destPath);
48+
} else {
49+
fs.copyFileSync(srcPath, destPath);
50+
}
51+
}
52+
};
53+
54+
copyDir('test-resources', 'dist/test-resources');
55+
});
56+
},
57+
};
58+
59+
async function main() {
60+
// Test build context
61+
const testCtx = await esbuild.context({
62+
entryPoints: ['src/test/**/*.ts'],
63+
bundle: true,
64+
format: 'cjs',
65+
minify: production,
66+
sourcemap: true,
67+
sourcesContent: !production,
68+
platform: 'node',
69+
outdir: 'dist/test',
70+
define: {
71+
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
72+
},
73+
external: ['vscode', 'mocha'],
74+
logLevel: 'info',
75+
plugins: [esbuildProblemMatcherPlugin, copyAssetsPlugin],
76+
});
77+
78+
if (watch) {
79+
await testCtx.watch();
80+
} else {
81+
await testCtx.rebuild();
82+
await testCtx.dispose();
83+
}
84+
}
85+
86+
main().catch(e => {
87+
console.error(e);
88+
process.exit(1);
89+
});

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import eslintConfigPrettier from 'eslint-config-prettier';
55

66
export default [
77
{
8-
files: ['**/*.ts', '**/*.tsx'],
8+
files: ['src/**/*.ts', 'src/**/*.tsx'],
99
},
1010
{
1111
plugins: {

0 commit comments

Comments
 (0)