rn-logo-replacer
Version:
This is a project aiming at remplacing the logo of a react native app with a single npx command
64 lines (63 loc) • 2.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineCliActions = defineCliActions;
const commander_1 = require("commander");
const platform_1 = require("../mobile/icon/platform");
const operation_1 = require("../file_actions_obj/operation");
function defineCliActions() {
let cliInput = {
source: "",
destination: "",
platform: [],
operation: ""
};
const cliRn = new commander_1.Command();
Object.values(operation_1.Operation).forEach(op => {
const cliRnCommand = cliRn.command(op);
cliRnCommand
.option("-p, --platform <platform>", `
Default value : android,ios (both)
Put one of theose values : ${Object.values(platform_1.Platform)}
`, "android,ios")
.option("-s, --source <sourceFolderCli>", `
Must be a valid path or it will be created
`);
// destination
if (op != operation_1.Operation.Delete) {
cliRnCommand
.option("-d, --destination <path>", `
Must be a valid path or it will be created
But be careful with this option, because if
you don't set the option platform to only 1
value, it will put both images of android and
ios in the same folder.
`)
.action((options) => {
cliInput.operation = op;
cliInput.platform = options.platform;
cliInput.source = options.source;
cliInput.destination = options.destination;
console.log(`cliInput.operation : ${cliInput.operation}`);
});
}
else {
// Define the action of the command
cliRnCommand
.action((options) => {
cliInput.operation = op;
cliInput.platform = options.platform;
cliInput.source = options.source;
});
}
const helperText = `
source : Must be a valid path or it will be created
${op != operation_1.Operation.Delete ? "destination : Must be a valid path or it will be created" : ""}
operation : ${Object.values(operation_1.Operation)}
platform : ${Object.values(platform_1.Platform)}
`;
// help
cliRnCommand
.addHelpText("afterAll", helperText);
});
return [cliRn, cliInput];
}