Compare commits
48
Commits
1.2.14
...
e6b404f009
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6b404f009 | ||
|
|
30b87d515f | ||
|
|
087dc3dad1 | ||
|
|
8fb2196e67 | ||
|
|
fe4e5393e0 | ||
|
|
437f07ccc1 | ||
|
|
afa57178d9 | ||
|
|
f9824e1523 | ||
|
|
9fa19fe316 | ||
|
|
1e8b682afc | ||
|
|
7ee9dd2a49 | ||
|
|
9535565349 | ||
|
|
bcabfe6db1 | ||
|
|
b67d12ecdd | ||
|
|
2d865f87dd | ||
|
|
9403710c8a | ||
|
|
cb5b4478e5 | ||
|
|
05cf7e7256 | ||
|
|
c9b39ffca0 | ||
|
|
0ddeb439ee | ||
|
|
5316114dae | ||
|
|
edb296c6e8 | ||
|
|
143eff95bc | ||
|
|
ce7dd93de5 | ||
|
|
f250f48788 | ||
|
|
840564fc69 | ||
|
|
a7086bdaf6 | ||
|
|
6ec43bf622 | ||
|
|
73494bf805 | ||
|
|
94b058a6e7 | ||
|
|
a896a8e7fc | ||
|
|
a05d2218c6 | ||
|
|
8908a32a68 | ||
|
|
695d1c1b50 | ||
|
|
7da16a82e5 | ||
|
|
c297beb494 | ||
|
|
da5bbfe1a8 | ||
|
|
5b116e016c | ||
|
|
39b5d46122 | ||
|
|
fa606b745d | ||
|
|
b98b3db80b | ||
|
|
44b8302801 | ||
|
|
b16b775efb | ||
|
|
f332115e6a | ||
|
|
24a26551ce | ||
|
|
ef8c92a4b4 | ||
|
|
bf88d3526f | ||
|
|
c70435e58a |
@@ -18,6 +18,7 @@ steps:
|
||||
commands:
|
||||
- npm install -g vsce
|
||||
- npm ci
|
||||
- xvfb-run -a npm test
|
||||
- vsce package
|
||||
|
||||
- name: gitea_release
|
||||
|
||||
@@ -32,3 +32,5 @@ data/
|
||||
.aider*
|
||||
/dist/
|
||||
tsconfig.tsbuildinfo
|
||||
.twig-cs-fixer.cache
|
||||
testfront-screenshots/
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"*.js": ["eslint --fix", "prettier --write"],
|
||||
"*.ts": ["eslint --fix", "prettier --write"],
|
||||
"*.css": ["prettier --write"],
|
||||
"*.jsx": ["prettier --write"],
|
||||
"*.html.twig": ["twig-cs-fixer lint --fix", "myhtmlvalidate -q"],
|
||||
"*.tsx": ["prettier --write"],
|
||||
"*.php": ["php-cs-fixer fix --config .php-cs-fixer.php"],
|
||||
"Dockerfile": ["hadolint --ignore DL3002 --ignore DL3003 --ignore DL3008 --ignore DL3013 --ignore DL3016 --ignore DL3022"],
|
||||
"*.md": ["markdownlint --fix"],
|
||||
|
||||
@@ -7,3 +7,4 @@ data/*
|
||||
.vscode-test/
|
||||
/dist/
|
||||
tsconfig.tsbuildinfo
|
||||
legacy/*
|
||||
|
||||
@@ -5,14 +5,15 @@ collect stats about a user's activity in vscode
|
||||
## Features
|
||||
|
||||
it can track :
|
||||
|
||||
- file opening
|
||||
- file saving
|
||||
- window focus
|
||||
|
||||
## Extension Settings
|
||||
|
||||
* `vscodestat.setUrl`: function to set the remote server's url
|
||||
this will set the variable vscodestat.url
|
||||
* `vscodestat.callUrl`: funciton to test if it works
|
||||
- `vscodestat.setUrl`: function to set the remote server's url
|
||||
this will set the variable vscodestat.url
|
||||
- `vscodestat.callUrl`: funciton to test if it works
|
||||
|
||||
Sample url : https://xxxxxx/vscodestat?userName=raf
|
||||
|
||||
+7
-5
@@ -4,6 +4,8 @@ import tsplugin from '@typescript-eslint/eslint-plugin';
|
||||
import globals from 'globals';
|
||||
|
||||
export default [
|
||||
// remonte (et --fix supprime) tout eslint-disable inutile : regle deja off, inactive, ou qui ne tire pas
|
||||
{ linterOptions: { reportUnusedDisableDirectives: 'error' } },
|
||||
js.configs.recommended,
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
@@ -30,10 +32,10 @@ export default [
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
},
|
||||
],
|
||||
'curly': 'warn',
|
||||
'eqeqeq': 'warn',
|
||||
curly: 'warn',
|
||||
eqeqeq: 'warn',
|
||||
'no-throw-literal': 'warn',
|
||||
'semi': 'off',
|
||||
semi: 'off',
|
||||
// Règles générales réutilisées de flatbay
|
||||
'prefer-const': ['error', { destructuring: 'all' }],
|
||||
'no-var': 'error',
|
||||
@@ -45,7 +47,7 @@ export default [
|
||||
'one-var-declaration-per-line': ['error', 'always'],
|
||||
'one-var': ['error', 'never'],
|
||||
'vars-on-top': 'error',
|
||||
'yoda': 'error',
|
||||
yoda: 'error',
|
||||
'prefer-arrow-callback': 'error',
|
||||
'no-implicit-globals': 'error',
|
||||
'no-labels': 'error',
|
||||
@@ -61,6 +63,6 @@ export default [
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ['out/', 'dist/', '.vscode-test/', '**/*.d.ts'],
|
||||
ignores: ['legacy/', 'out/', 'dist/', '.vscode-test/', '**/*.d.ts'],
|
||||
},
|
||||
];
|
||||
|
||||
Generated
+572
-910
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vscodestat",
|
||||
"displayName": "vscodestat",
|
||||
"version": "1.2.14",
|
||||
"version": "1.8.8",
|
||||
"description": "",
|
||||
"categories": [
|
||||
"Other"
|
||||
@@ -51,22 +51,22 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "25.x",
|
||||
"@types/vscode": "^1.120.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.60.0",
|
||||
"@typescript-eslint/parser": "^8.60.0",
|
||||
"@vscode/test-cli": "^0.0.12",
|
||||
"@vscode/test-electron": "^2.5.2",
|
||||
"@types/node": "26.x",
|
||||
"@types/vscode": "^1.125.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
||||
"@typescript-eslint/parser": "^8.65.0",
|
||||
"@vscode/test-cli": "^0.0.15",
|
||||
"@vscode/test-electron": "^3.1.0",
|
||||
"eslint": "^10.1.0",
|
||||
"globals": "^17.6.0",
|
||||
"globals": "^17.8.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^17.0.6",
|
||||
"prettier": "^3.8.3",
|
||||
"lint-staged": "^17.2.0",
|
||||
"prettier": "^3.9.6",
|
||||
"ts-api-utils": "^2.5.0",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.120.0"
|
||||
"vscode": "^1.125.0"
|
||||
},
|
||||
"icon": "icon.png",
|
||||
"extensionKind": [
|
||||
|
||||
+24
-24
@@ -4,71 +4,71 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
console.log('Congratulations, your extension "vscodestat" is now active!');
|
||||
|
||||
// commande pour definir l'url
|
||||
const disposable2 = vscode.commands.registerCommand('vscodestat.setUrl', async () => {
|
||||
const setUrlCommand = vscode.commands.registerCommand('vscodestat.setUrl', async () => {
|
||||
const url = await vscode.window.showInputBox({
|
||||
prompt: 'Enter the URL:',
|
||||
placeHolder: ''
|
||||
placeHolder: '',
|
||||
});
|
||||
|
||||
if (url) {
|
||||
vscode.workspace.getConfiguration().update('vscodestat.url', url, vscode.ConfigurationTarget.Global);
|
||||
await vscode.workspace.getConfiguration().update('vscodestat.url', url, vscode.ConfigurationTarget.Global);
|
||||
vscode.window.showInformationMessage('URL set successfully.');
|
||||
}
|
||||
});
|
||||
context.subscriptions.push(disposable2);
|
||||
context.subscriptions.push(setUrlCommand);
|
||||
|
||||
// commande pour tester l'url
|
||||
const disposable3 = vscode.commands.registerCommand('vscodestat.callUrl', async () => {
|
||||
const callUrlCommand = vscode.commands.registerCommand('vscodestat.callUrl', async () => {
|
||||
const storedUrl = vscode.workspace.getConfiguration().get('vscodestat.url') as string;
|
||||
if (!storedUrl) {
|
||||
vscode.window.showWarningMessage('URL is not set. Please set the URL first.');
|
||||
return;
|
||||
}
|
||||
await makeHttpRequest({ event: 'ping'});
|
||||
await makeHttpRequest({ event: 'ping' });
|
||||
vscode.window.showInformationMessage('callUrl done');
|
||||
});
|
||||
context.subscriptions.push(disposable3);
|
||||
context.subscriptions.push(callUrlCommand);
|
||||
|
||||
// detecte une ouverture de fichier / nouvel onglet
|
||||
vscode.window.onDidChangeActiveTextEditor(async editor => {
|
||||
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
|
||||
if (editor) {
|
||||
const filePath = editor.document.fileName;
|
||||
console.log('Opened file:', filePath);
|
||||
|
||||
// vscode.window.showInformationMessage(`Opened file: ${filePath}`);
|
||||
await makeHttpRequest({ event: 'open', project: extractProjectName(filePath) });
|
||||
await makeHttpRequest({ event: 'open', project: extractProjectName(filePath), source: 'vscode' });
|
||||
}
|
||||
});
|
||||
|
||||
// detecte une sauvegarde de fichier
|
||||
vscode.workspace.onDidSaveTextDocument(async document => {
|
||||
vscode.workspace.onDidSaveTextDocument(async (document) => {
|
||||
const filePath = document.fileName;
|
||||
console.log('Saved file:', filePath);
|
||||
|
||||
// vscode.window.showInformationMessage(`Saved file: ${filePath}`);
|
||||
await makeHttpRequest({ event: 'save', project: extractProjectName(filePath) });
|
||||
await makeHttpRequest({ event: 'save', project: extractProjectName(filePath), source: 'vscode' });
|
||||
});
|
||||
|
||||
// detecte un focus / blur de la fenetre vscode
|
||||
vscode.window.onDidChangeWindowState(async event => {
|
||||
vscode.window.onDidChangeWindowState(async (event) => {
|
||||
console.log('Window state changed:', event.focused);
|
||||
await makeHttpRequest({ event: 'focus', focused: event.focused });
|
||||
});
|
||||
}
|
||||
|
||||
export function deactivate() { }
|
||||
export function deactivate() {}
|
||||
|
||||
/*
|
||||
* extractProjectName will extract a project name from a path
|
||||
* /root/docker/monitoringserver/controller/homeController.js
|
||||
* => monitoringserver
|
||||
*/
|
||||
* extractProjectName will extract a project name from a path
|
||||
* /root/docker/monitoringserver/controller/homeController.js
|
||||
* => monitoringserver
|
||||
*/
|
||||
export function extractProjectName(path: string) {
|
||||
// des c'est l'un des fois l'autre ?
|
||||
// /root/docker/vscodestat/src/extension.ts
|
||||
// \root\docker\vscodestat\src\extension.ts
|
||||
path = path.replace(/\\/g, '/');
|
||||
|
||||
|
||||
const match = path.match(/\/docker\/([^/]+)/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
@@ -78,8 +78,8 @@ export function extractProjectName(path: string) {
|
||||
}
|
||||
|
||||
/*
|
||||
* fonction qui envoie un event au serveur
|
||||
*/
|
||||
* fonction qui envoie un event au serveur
|
||||
*/
|
||||
async function makeHttpRequest(json: Object) {
|
||||
try {
|
||||
const url = vscode.workspace.getConfiguration().get('vscodestat.url') as string;
|
||||
@@ -91,16 +91,16 @@ async function makeHttpRequest(json: Object) {
|
||||
const rawResponse = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(json)
|
||||
body: JSON.stringify(json),
|
||||
});
|
||||
const content = await rawResponse.json();
|
||||
|
||||
console.log(content);
|
||||
// vscode.window.showInformationMessage('HTTP request successful.');
|
||||
} catch (error:any) {
|
||||
} catch (error: any) {
|
||||
console.error('Error making HTTP request:', error);
|
||||
// vscode.window.showErrorMessage('Error making HTTP request: ' + error.message);
|
||||
}
|
||||
|
||||
@@ -3,17 +3,11 @@ import { extractProjectName } from '../extension.js';
|
||||
|
||||
suite('extractProjectName', () => {
|
||||
test('extrait le nom de projet depuis un path Linux /root/docker/X', () => {
|
||||
assert.strictEqual(
|
||||
extractProjectName('/root/docker/vscodestat/src/extension.ts'),
|
||||
'vscodestat'
|
||||
);
|
||||
assert.strictEqual(extractProjectName('/root/docker/vscodestat/src/extension.ts'), 'vscodestat');
|
||||
});
|
||||
|
||||
test('extrait le nom de projet depuis un path Windows \\root\\docker\\X', () => {
|
||||
assert.strictEqual(
|
||||
extractProjectName('C:\\root\\docker\\monitoringserver\\controller\\homeController.js'),
|
||||
'monitoringserver'
|
||||
);
|
||||
assert.strictEqual(extractProjectName('C:\\root\\docker\\monitoringserver\\controller\\homeController.js'), 'monitoringserver');
|
||||
});
|
||||
|
||||
test('retourne null pour un path hors /docker/', () => {
|
||||
@@ -25,16 +19,10 @@ suite('extractProjectName', () => {
|
||||
});
|
||||
|
||||
test('extrait correctement quand le chemin contient docker plusieurs fois', () => {
|
||||
assert.strictEqual(
|
||||
extractProjectName('/root/docker/flatbay/lib/docker/foo.js'),
|
||||
'flatbay'
|
||||
);
|
||||
assert.strictEqual(extractProjectName('/root/docker/flatbay/lib/docker/foo.js'), 'flatbay');
|
||||
});
|
||||
|
||||
test('gere les paths avec tirets et chiffres', () => {
|
||||
assert.strictEqual(
|
||||
extractProjectName('/root/docker/gextra6/bin/console'),
|
||||
'gextra6'
|
||||
);
|
||||
assert.strictEqual(extractProjectName('/root/docker/gextra6/bin/console'), 'gextra6');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
REVIEW DE CODE — 2026-04-26
|
||||
============================================
|
||||
|
||||
Extension VSCode (TypeScript) qui collecte des metriques sur
|
||||
l'activite du user dans VSCode :
|
||||
- ouverture de fichier / changement d'onglet (event 'open')
|
||||
- sauvegarde de fichier (event 'save')
|
||||
- focus/blur de la fenetre (event 'focus')
|
||||
|
||||
Envoie un POST JSON a la URL configuree (`vscodestat.url`).
|
||||
|
||||
NB : extension force-installed dans les containers vscode + vscodeluigi
|
||||
(cf vscode/todo.txt). C'est l'extension de monitoring activite dev.
|
||||
|
||||
SECURITE
|
||||
--------
|
||||
|
||||
[ ] makeHttpRequest envoie au serveur l'event sans auth
|
||||
src/extension.ts : `fetch(url, { method: 'POST',
|
||||
headers: ..., body: JSON.stringify(json) })`. Pas de token.
|
||||
Cote serveur (cf monitoringserver/todo.txt), `/vscodestat` est
|
||||
aussi sans auth => tout le monde peut envoyer des metriques.
|
||||
|
||||
BUGS / FRAGILITE
|
||||
----------------
|
||||
[ ] Pas de batching
|
||||
Chaque event = 1 fetch. Pas de queue + flush periodique.
|
||||
Si reseau down, perte d'events (pas de retry). A capper.
|
||||
|
||||
[ ] makeHttpRequest catch silencieux
|
||||
src/extension.ts : catch + console.error. Pas de
|
||||
retry, pas de notification user. Si serveur down, events
|
||||
perdus.
|
||||
+10
-20
@@ -1,22 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"ES2022"
|
||||
],
|
||||
"types": [
|
||||
"node",
|
||||
"mocha",
|
||||
"vscode"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"strict": true /* enable all strict type-checking options */
|
||||
/* Additional Checks */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
}
|
||||
"compilerOptions": {
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"outDir": "out",
|
||||
"lib": ["ES2022"],
|
||||
"types": ["node", "mocha", "vscode"],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user