rucken
Version:
Console tools and scripts for nx and not only that I (EndyKaufman) use to automate the workflow and speed up the development process
97 lines • 4.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CopyPasteCommands = void 0;
const tslib_1 = require("tslib");
const nestjs_console_1 = require("../../nestjs-console");
const utils_service_1 = require("../utils/utils.service");
const copy_paste_config_1 = require("./copy-paste.config");
const copy_paste_service_1 = require("./copy-paste.service");
let CopyPasteCommands = class CopyPasteCommands {
copyPasteService;
utilsService;
config = {};
constructor(copyPasteService, utilsService) {
this.copyPasteService = copyPasteService;
this.utilsService = utilsService;
this.config = this.utilsService.getRuckenConfig(copy_paste_config_1.DEFAULT_COPY_PASTE_CONFIG)
.copyPaste;
}
async copyPaste({ path, find, findPlural, replace, replacePlural, destPath, extensions, globRules, replaceEnvs, }) {
this.copyPasteService.setLogger(copy_paste_service_1.CopyPasteService.title);
await this.copyPasteService.copyPasteHandler({
path,
find,
findPlural,
replace,
replacePlural,
destPath,
extensions: (extensions || this.config.extensions)
.split(',')
.map((s) => s.trim()),
cases: this.config.cases,
globRules,
replaceEnvs: replaceEnvs
? replaceEnvs.includes('key')
? replaceEnvs
: this.config.replaceEnvsKeyPattern
: undefined,
});
}
};
exports.CopyPasteCommands = CopyPasteCommands;
tslib_1.__decorate([
(0, nestjs_console_1.Command)({
alias: 'cp',
command: 'copy-paste',
description: 'copy paste source files to destination with singular and plural replace text in file contents and file paths',
options: [
{
flags: '-p,--path [strings]',
description: 'the path with the source code to copy, it uses the current CWD if it is not defined, default: "." (example: ../../src)',
},
{
flags: '-f,--find [strings]',
description: 'source singular text in kebab-case (example: user-role)',
required: true,
},
{
flags: '--find-plural [strings]',
description: 'source text in plural in kebab-case, if not defined, it will be automatically detected programmatically (example: user-rules)',
},
{
flags: '-r,--replace [strings]',
description: 'destination singular text in kebab-case (example: user-company)',
required: true,
},
{
flags: '--replace-plural [strings]',
description: 'destination text in plural in kebab-case, if not defined, it will be automatically detected programmatically (example: user-companies)',
},
{
flags: '-d,--dest-path [strings]',
description: 'the path with the destination code to paste, it uses the "path" if it is not defined, default: "." (example: ../../src)',
},
{
flags: '-e,--extensions [strings]',
description: 'extensions of files for copy paste, default: "ts,html,htm,scss,css,txt,json,yaml,yml,xml,js.esm,sh" (example: py,ini)',
},
{
flags: '--glob-rules [strings]',
description: 'match files using the patterns the shell uses',
},
{
flags: '--replace-envs [strings]',
description: 'do you need to replace environment variables when copying, you can specify a template, the default template is %key% (examples: "true", "%key%", "${key}")',
},
],
}),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object]),
tslib_1.__metadata("design:returntype", Promise)
], CopyPasteCommands.prototype, "copyPaste", null);
exports.CopyPasteCommands = CopyPasteCommands = tslib_1.__decorate([
(0, nestjs_console_1.Console)(),
tslib_1.__metadata("design:paramtypes", [copy_paste_service_1.CopyPasteService,
utils_service_1.UtilsService])
], CopyPasteCommands);
//# sourceMappingURL=copy-paste.commands.js.map