From 462d9770eb93fe513e5451d7437bc4fd660d67ca Mon Sep 17 00:00:00 2001 From: Tushar <codingid6@gmail.com> Date: Tue, 14 Mar 2023 06:50:54 +0000 Subject: [PATCH] Remove cli.js --- central-config/cli.js | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 central-config/cli.js diff --git a/central-config/cli.js b/central-config/cli.js deleted file mode 100644 index 950f88f..0000000 --- a/central-config/cli.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 ODK Central Developers -// See the NOTICE file at the top-level directory of this distribution and at -// https://github.com/getodk/central-backend/blob/master/NOTICE. -// This file is part of ODK Central. It is subject to the license terms in -// the LICENSE file found in the top-level directory of this distribution and at -// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, -// including this file, may be copied, modified, propagated, or distributed -// except according to the terms contained in the LICENSE file. -// -// This script is our primary administrative utility, providing a packaged way -// for people deploying this server to run basic tasks like creating users and -// resetting their passwords. As much as possible, this file itself tries only -// to parse the command-line input and delegate the actual work to tasks that -// are already defined. - -const { run } = require('../task/task'); -const { createUser, promoteUser, setUserPassword } = require('../task/account'); - -// gets a password interactively if not supplied in cli args. -const prompt = require('prompt'); -const withPassword = (f) => { - prompt.start(); - prompt.get([{ name: 'password', hidden: true, replace: '*' }], (_, { password }) => f(password)); -}; - -// command line nonsense (i'm not a huge fan of this library). -const cli = require('cli'); -const cliArgs = { - email: [ 'u', 'For user create and set password commands, supplies the email.', 'email' ] -}; -const cliCommands = [ 'user-create', 'user-promote', 'user-set-password' ]; -cli.parse(cliArgs, cliCommands); - -// map commands to tasks. -cli.main((args, options) => { - if (cli.command === 'user-create') - withPassword((password) => run(createUser(options.email, password))); - else if (cli.command === 'user-promote') - run(promoteUser(options.email)); - else if (cli.command === 'user-set-password') - withPassword((password) => run(setUserPassword(options.email, password))); -}); -- GitLab