@assylman/riverpod-cli
Version:
nodejs cli for creating well structured flutter riverpod folders and files needed to work with Riverpod plugin
56 lines (55 loc) • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const services_1 = require("./services");
const managers_1 = require("./managers");
const utils_1 = require("./utils");
const repositories_1 = require("./repositories");
const features_1 = require("./features");
const program = new commander_1.Command();
program
.command(utils_1.Commands.service)
.argument('<string>', 'service name')
.option('-t, --target <string>', 'Path to your features directory in a format \'/lib/features\' [default value is \'/lib/features\']')
.option('--use-imports <string>', 'Pass \'relative\', if you want relative imports. [defaults value is \'absolute\']')
.option('-l', 'Create local service')
.option('-r', 'Create remote service')
.option('-i', 'Create index barrel files')
.action((name, options) => {
const packageInfo = (0, utils_1.getInformationFromPubspec)(name, options);
(0, services_1.generateService)(name, { ...options, ...packageInfo });
})
.description('Create service with a given name');
program
.command(utils_1.Commands.repository)
.argument('<string>', 'repository name')
.option('-t, --target <string>', 'Path to your features directory in a format \'/lib/features\' [default value is \'/lib/features\']')
.option('-i', 'Create index barrel files')
.action((name, options) => {
const packageInfo = (0, utils_1.getInformationFromPubspec)(name, options);
(0, repositories_1.generateRepository)(name, { ...options, ...packageInfo });
})
.description('Create repository with a given name');
program
.command(utils_1.Commands.manager)
.argument('<string>', 'manager name')
.option('-t, --target <string>', 'Path to your features directory in a format \'/lib/features\' [default value is \'/lib/features\']')
.option('-i', 'Create index barrel files')
.action((name, options) => {
const packageInfo = (0, utils_1.getInformationFromPubspec)(name, options);
(0, managers_1.generateManager)(name, { ...options, ...packageInfo });
})
.description('Create manager with a given name');
program
.command(utils_1.Commands.feature)
.argument('<string>', 'feature name')
.option('-t, --target <string>', 'Path to your features directory in a format \'/lib/features\' [default value is \'/lib/features\']')
.option('-i', 'Create index barrel files')
.option('-p', 'Create feature\'s providers file')
.action((name, options) => {
const packageInfo = (0, utils_1.getInformationFromPubspec)(name, options);
(0, features_1.generateFeature)(name, { ...options, ...packageInfo });
})
.description('Create feature [manager, repository, service] with a given name');
program.parse(process.argv);