Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
chore(cli): add create-user command to manage user creation
johaven203af802f2c1
diff --git a/scripts/npm-sync-in-server.js b/scripts/npm-sync-in-server.jsindex 9db42b83..e5c5206f 100644--- a/scripts/npm-sync-in-server.js+++ b/scripts/npm-sync-in-server.js@@ -20,6 +20,7 @@ const fs = require('fs')// Paths relative to this scriptconst PKILL_GRACEFUL_TIMEOUT = 10000 // 10s timeoutconst ROOT_DIR = path.resolve(__dirname)+const CREATE_USER_SCRIPT = path.join(ROOT_DIR, 'server', 'infrastructure', 'database', 'scripts', 'create-user.js')const SERVER_ENTRY = path.join(ROOT_DIR, 'server', 'main.js')const ENV_DIST_FILE = path.join(ROOT_DIR, 'environment', 'environment.dist.yaml')const ENV_DIST_MIN_FILE = path.join(ROOT_DIR, 'environment', 'environment.dist.min.yaml')@@ -40,6 +41,7 @@ Available commands:status Show server status (daemon mode only)version Show installed sync-in-server versionmigrate-db Run database migrations+ create-user Create an admin user in the databaseupdate Update the server versionhelp Show this help message@@ -47,6 +49,7 @@ Examples:npx sync-in-server init # copy default environment.yamlnpx sync-in-server start # attached modenpx sync-in-server start -d # daemon mode+ npx sync-in-server create-user --role admin --login "userLogin" --password "userPassword"npx sync-in-server versionnpx sync-in-server help`)@@ -224,6 +227,17 @@ async function updateVersion() {console.log('✅ Sync-in Server updated.')}+async function createUser(args) {+ console.log('👤 Creating user in database...')+ const scriptArgs = [CREATE_USER_SCRIPT, ...args]+ const result = spawnSync('node', scriptArgs, { stdio: 'inherit' })+ if (result.status !== 0) {+ console.error('❌ User creation failed.')+ process.exit(result.status)+ }+ console.log('✅ User created successfully.')+}+function getPackageJson() {try {const pkgPath = path.join(ROOT_DIR, 'package.json')@@ -294,6 +308,9 @@ function waitForProcessExit(pid) {case 'migrate-db':migrateDatabase()break+ case 'create-user':+ createUser(args.slice(1)).catch(console.error)+ breakcase 'update':updateVersion().catch(console.error)break