@launchql/cli
Version:
LaunchQL CLI
51 lines (46 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@launchql/core");
const logger_1 = require("@launchql/logger");
const pg_env_1 = require("pg-env");
const log = new logger_1.Logger('admin-users-bootstrap');
const bootstrapUsageText = `
LaunchQL Admin Users Bootstrap Command:
lql admin-users bootstrap [OPTIONS]
Initialize LaunchQL roles and permissions. This command must be run before adding users.
Creates the standard LaunchQL roles: anonymous, authenticated, administrator.
Options:
--help, -h Show this help message
--cwd <directory> Working directory (default: current directory)
Examples:
lql admin-users bootstrap # Initialize LaunchQL roles
`;
exports.default = async (argv, prompter, _options) => {
// Show usage if explicitly requested
if (argv.help || argv.h) {
console.log(bootstrapUsageText);
process.exit(0);
}
const pgEnv = (0, pg_env_1.getPgEnvOptions)();
const { yes } = await prompter.prompt(argv, [
{
type: 'confirm',
name: 'yes',
message: 'Are you sure you want to initialize LaunchQL roles and permissions?',
default: false
}
]);
if (!yes) {
log.info('Operation cancelled.');
return;
}
const init = new core_1.LaunchQLInit(pgEnv);
try {
await init.bootstrapRoles();
log.success('LaunchQL roles and permissions initialized successfully.');
}
finally {
await init.close();
}
return argv;
};