Run lint-staged on all new files

This commit is contained in:
Andrew Ferrazzutti
2025-02-05 09:43:21 -05:00
parent caabc37519
commit b36705c4f4
3 changed files with 47 additions and 47 deletions
+6 -6
View File
@@ -28,8 +28,8 @@ Add module configuration into `modules` section of `homeserver.yaml`:
```yaml ```yaml
modules: modules:
- module: synapse_guest_module.GuestModule - module: synapse_guest_module.GuestModule
config: {} config: {}
``` ```
## Module configuration ## Module configuration
@@ -45,10 +45,10 @@ Example configuration:
```yaml ```yaml
modules: modules:
- module: synapse_guest_module.GuestModule - module: synapse_guest_module.GuestModule
config: config:
# Use a german suffix # Use a german suffix
display_name_suffix: ' (Gast)' display_name_suffix: " (Gast)"
``` ```
## Production installation ## Production installation
+19 -19
View File
@@ -1,21 +1,21 @@
{ {
"name": "@element-hq/synapse-guest-module", "name": "@element-hq/synapse-guest-module",
"version": "2.0.0", "version": "2.0.0",
"private": true, "private": true,
"description": "A synapse module to restrict the actions of guests", "description": "A synapse module to restrict the actions of guests",
"author": "New Vector Ltd.", "author": "New Vector Ltd.",
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"clean": "echo \"Nothing to clean\"", "clean": "echo \"Nothing to clean\"",
"build": "echo \"Nothing to build\"", "build": "echo \"Nothing to build\"",
"docker:build": "docker build -t element-hq/synapse-guest-module -f Dockerfile .", "docker:build": "docker build -t element-hq/synapse-guest-module -f Dockerfile .",
"tsc": "echo \"Nothing to tsc\"", "tsc": "echo \"Nothing to tsc\"",
"lint": "echo \"Nothing to lint\"", "lint": "echo \"Nothing to lint\"",
"types:py": "node ./scripts/run_in_venv.js tox -e check_types", "types:py": "node ./scripts/run_in_venv.js tox -e check_types",
"lint:py": "node ./scripts/run_in_venv.js tox -e check_codestyle", "lint:py": "node ./scripts/run_in_venv.js tox -e check_codestyle",
"lint:fix": "node ./scripts/run_in_venv.js tox -e fix_codestyle", "lint:fix": "node ./scripts/run_in_venv.js tox -e fix_codestyle",
"test": "node ./scripts/run_in_venv.js tox -e py", "test": "node ./scripts/run_in_venv.js tox -e py",
"depcheck": "echo \"Nothing to check\"", "depcheck": "echo \"Nothing to check\"",
"package": "yarn docker:build" "package": "yarn docker:build"
} }
} }
@@ -21,39 +21,39 @@
// //
// Example: $ node ./run_in_venv.js python --version // Example: $ node ./run_in_venv.js python --version
const fs = require('fs'); const fs = require("fs");
const path = require('path'); const path = require("path");
const child_process = require('child_process'); const child_process = require("child_process");
const cwd = path.resolve(__dirname, '..'); const cwd = path.resolve(__dirname, "..");
const venvPath = path.resolve(__dirname, '../../../.venv'); const venvPath = path.resolve(__dirname, "../../../.venv");
const venvRelativeToCwd = path.relative(cwd, venvPath); const venvRelativeToCwd = path.relative(cwd, venvPath);
function run(command) { function run(command) {
return new Promise((resolve) => { return new Promise((resolve) => {
const proc = child_process.spawn( const proc = child_process.spawn(`source ${venvRelativeToCwd}/bin/activate && ${command}`, [], {
`source ${venvRelativeToCwd}/bin/activate && ${command}`, cwd,
[], stdio: "inherit",
{ cwd, stdio: 'inherit', shell: true }, shell: true,
); });
proc.on('close', (code) => { proc.on("close", (code) => {
console.log('command terminated:', code); console.log("command terminated:", code);
resolve(); resolve();
});
}); });
});
} }
async function main() { async function main() {
if (!fs.existsSync(venvPath) || !fs.lstatSync(venvPath).isDirectory()) { if (!fs.existsSync(venvPath) || !fs.lstatSync(venvPath).isDirectory()) {
child_process.execSync(`python3 -m venv ${venvRelativeToCwd}`, { cwd }); child_process.execSync(`python3 -m venv ${venvRelativeToCwd}`, { cwd });
await run('pip install tox'); await run("pip install tox");
await run('pip install -e ."[dev]"'); await run('pip install -e ."[dev]"');
} }
const command = process.argv.slice(2).join(' '); const command = process.argv.slice(2).join(" ");
await run(command); await run(command);
} }
main(); main();