Skip to content

Commit 97796e0

Browse files
committed
Switch to Knex and implement bundling
1 parent 16ee42b commit 97796e0

Some content is hidden

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

43 files changed

+1325
-889
lines changed

.vscode/extensions.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See http://go.microsoft.com/fwlink/?LinkId=827846
33
// for the documentation about the extensions.json format
44
"recommendations": [
5-
"dbaeumer.vscode-eslint"
5+
"dbaeumer.vscode-eslint",
6+
"connor4312.esbuild-problem-matchers"
67
]
7-
}
8+
}

.vscode/launch.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--disable-extensions"],
13-
"outFiles": ["${workspaceFolder}/out/**/*.js"],
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}",
14+
"--disable-extensions"
15+
],
1416
"preLaunchTask": "${defaultBuildTask}"
1517
},
1618
{
1719
"name": "Extension Tests",
1820
"type": "extensionHost",
1921
"request": "launch",
20-
"args": ["--extensionDevelopmentPath=${workspaceFolder}", "--extensionTestsPath=${workspaceFolder}/out/test/suite/index", "--disable-extensions"],
21-
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
22+
"args": [
23+
"--extensionDevelopmentPath=${workspaceFolder}",
24+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
25+
"--disable-extensions"
26+
],
2227
"preLaunchTask": "${defaultBuildTask}"
2328
}
2429
]
25-
}
30+
}

.vscode/tasks.json

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1-
// See https://go.microsoft.com/fwlink/?LinkId=733558
2-
// for the documentation about the tasks.json format
31
{
42
"version": "2.0.0",
53
"tasks": [
64
{
7-
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
10-
"isBackground": true,
5+
"label": "watch",
6+
"dependsOn": [
7+
"npm: watch:tsc",
8+
"npm: watch:esbuild"
9+
],
1110
"presentation": {
1211
"reveal": "never"
1312
},
1413
"group": {
1514
"kind": "build",
1615
"isDefault": true
1716
}
17+
},
18+
{
19+
"type": "npm",
20+
"script": "watch:esbuild",
21+
"group": "build",
22+
"problemMatcher": "$esbuild-watch",
23+
"isBackground": true,
24+
"label": "npm: watch:esbuild",
25+
"presentation": {
26+
"group": "watch",
27+
"reveal": "never"
28+
}
29+
},
30+
{
31+
"type": "npm",
32+
"script": "watch:tsc",
33+
"group": "build",
34+
"problemMatcher": "$tsc-watch",
35+
"isBackground": true,
36+
"label": "npm: watch:tsc",
37+
"presentation": {
38+
"group": "watch",
39+
"reveal": "never"
40+
}
1841
}
1942
]
20-
}
43+
}

.vscodeignore

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
# Ignore everything by default
22
*
3-
*/**
3+
**
44

55
# Include only necessary files
66
!package.json
7-
!README.md
87
!LICENSE*
9-
!CHANGELOG.md
108

119
# Include source and compiled files
1210
!*.js
13-
!lib/**/*.js
14-
!src/**/*.js
15-
!out/**/*.js
11+
!dist/**/*.js
1612
!ui-shell/dist/**
1713

18-
# Include resources
19-
!resources/**/*.{png,gif,jpg,ico,svg}
14+
# Include icons
15+
!resources/devdb-128x128.png
16+
!resources/devdb.png
2017

2118
# Include snippets and schemas
2219
!snippets/*
2320
!schemas/*
24-
25-
# Include node_modules
26-
!node_modules/**
27-
28-
# Re-ignore unnecessary node_modules content
29-
node_modules/**/test/**
30-
node_modules/**/*.d.ts
31-
node_modules/**/*.md
32-
node_modules/**/.npmignore

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ The configuration file should contain a single array of database connection obje
137137
### Context Menu Entry
138138

139139
Open any database table in DevDb by right-clicking its name/model/entity from the editor in **any** framework/programming language.
140-
Example from a Node.js app ([Sequelize model definition](https://sequelize.org/docs/v6/core-concepts/model-basics/#model-definition)):
140+
141+
Example from a Node.js app
141142

142143
![image](resources/screenshots/new/context-menu-contributions.png)
143144

bun.lock

+440-198
Large diffs are not rendered by default.

esbuild.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const esbuild = require('esbuild');
2+
3+
const production = process.argv.includes('--production');
4+
const watch = process.argv.includes('--watch');
5+
6+
async function main () {
7+
const ctx = await esbuild.context({
8+
entryPoints: ['src/extension.ts'],
9+
bundle: true,
10+
format: 'cjs',
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: 'node',
15+
outfile: 'dist/extension.js',
16+
external: ['vscode', 'sqlite3'],
17+
metafile: true,
18+
logLevel: 'warning',
19+
plugins: [
20+
/* add to the end of plugins array */
21+
esbuildProblemMatcherPlugin
22+
]
23+
});
24+
if (watch) {
25+
await ctx.watch();
26+
} else {
27+
await ctx.rebuild();
28+
await ctx.dispose();
29+
}
30+
}
31+
32+
/**
33+
* @type {import('esbuild').Plugin}
34+
*/
35+
const esbuildProblemMatcherPlugin = {
36+
name: 'esbuild-problem-matcher',
37+
38+
setup (build) {
39+
build.onStart(() => {
40+
console.log('[watch] build started');
41+
});
42+
build.onEnd(result => {
43+
result.errors.forEach(({ text, location }) => {
44+
console.error(`✘ [ERROR] ${text}`);
45+
if (location == null) return;
46+
console.error(` ${location.file}:${location.line}:${location.column}:`);
47+
});
48+
49+
console.log('[watch] build finished');
50+
});
51+
}
52+
};
53+
54+
main().catch(e => {
55+
console.error(e);
56+
process.exit(1);
57+
});

package.json

+25-10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"theme": "light"
3434
},
3535
"preview": false,
36-
"main": "./out/extension.js",
36+
"main": "./dist/extension.js",
3737
"homepage": "https://github.com/damms005/devdb-vscode/blob/main/README.md",
3838
"bugs": {
3939
"url": "https://github.com/damms005/devdb-vscode/discussions",
@@ -108,7 +108,8 @@
108108
{
109109
"type": "webview",
110110
"id": "devdb",
111-
"name": "DevDb"
111+
"name": "DevDb",
112+
"icon": "resources/devdb.png"
112113
}
113114
]
114115
},
@@ -209,15 +210,19 @@
209210
}
210211
},
211212
"scripts": {
212-
"vscode:prepublish": "npm run compile",
213-
"compile": "tsc -p ./",
214-
"hot-reload": "chokidar './package.json' './src/**/*.ts' -c \"clear && echo 'Compiling extension code\\n' && npm run compile \"",
215213
"pretest": "npm run compile && npm run lint",
216214
"lint": "eslint src --ext ts",
217215
"test": "node ./out/test/runTest.js",
218216
"mocha": "./node_modules/.bin/mocha --bail --require ts-node/register",
219217
"test-services": "./node_modules/.bin/mocha --bail --timeout 30000 --require ts-node/register ./src/test/suite/**/*.test.ts",
220-
"publish": "./publish.sh"
218+
"publish": "./publish.sh",
219+
"compile": "npm run check-types && node esbuild.js",
220+
"check-types": "tsc --noEmit",
221+
"watch": "npm-run-all -p watch:*",
222+
"watch:esbuild": "node esbuild.js --watch",
223+
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
224+
"vscode:prepublish": "npm run package",
225+
"package": "npm run check-types && node esbuild.js --production"
221226
},
222227
"devDependencies": {
223228
"@testcontainers/mssqlserver": "^10.18.0",
@@ -241,19 +246,29 @@
241246
"typescript": "^5.8.2"
242247
},
243248
"dependencies": {
249+
"@azure/app-configuration": "^1.8.0",
250+
"@azure/keyvault-secrets": "^4.9.0",
251+
"better-sqlite3": "^11.9.0",
244252
"case": "^1.6.3",
245253
"cosmiconfig": "^8.3.6",
246254
"csv-parse": "^5.6.0",
247255
"dotenv": "^16.4.7",
256+
"esbuild": "^0.25.1",
257+
"knex": "^3.1.0",
248258
"lru-cache": "^11.0.2",
259+
"mysql": "^2.18.1",
249260
"mysql2": "^3.13.0",
250-
"pg": "^8.13.3",
261+
"npm-run-all": "^4.1.5",
262+
"oci-common": "^2.105.0",
263+
"oci-objectstorage": "^2.105.0",
264+
"oci-secrets": "^2.105.0",
265+
"oracledb": "^6.8.0",
266+
"pg": "^8.14.0",
251267
"pg-hstore": "^2.3.4",
268+
"pg-query-stream": "^4.8.0",
252269
"php-parser": "^3.2.2",
253270
"pluralize": "^8.0.0",
254-
"sequelize": "^6.37.6",
255271
"sql-formatter": "^13.1.0",
256-
"sqlite3": "^5.1.7",
257272
"tedious": "^18.6.1",
258273
"yaml": "^2.7.0"
259274
},
@@ -267,4 +282,4 @@
267282
"singleQuote": true,
268283
"arrowParens": "avoid"
269284
}
270-
}
285+
}

0 commit comments

Comments
 (0)