zibri-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/assets/public/assets.svg +1 -0
- package/assets/public/favicon.ico +0 -0
- package/assets/public/favicon.png +0 -0
- package/assets/public/logo.jpg +0 -0
- package/assets/public/open-api/custom.css +72 -0
- package/assets/public/open-api/swagger-ui-bundle.js +2 -0
- package/assets/public/open-api/swagger-ui-standalone-preset.js +2 -0
- package/assets/public/open-api/swagger-ui.css +3 -0
- package/assets/public/open-api/swagger.png +0 -0
- package/assets/public/style.css +123 -0
- package/dist/commands/base-command.model.js +61 -0
- package/dist/commands/base-command.model.js.map +1 -0
- package/dist/commands/command.enum.js +16 -0
- package/dist/commands/command.enum.js.map +1 -0
- package/dist/commands/help/help.command.js +23 -0
- package/dist/commands/help/help.command.js.map +1 -0
- package/dist/commands/help/index.js +5 -0
- package/dist/commands/help/index.js.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/is-command.function.js +13 -0
- package/dist/commands/is-command.function.js.map +1 -0
- package/dist/commands/new/index.js +5 -0
- package/dist/commands/new/index.js.map +1 -0
- package/dist/commands/new/new.command.js +344 -0
- package/dist/commands/new/new.command.js.map +1 -0
- package/dist/commands/resolve-command.function.js +22 -0
- package/dist/commands/resolve-command.function.js.map +1 -0
- package/dist/commands/version/index.js +5 -0
- package/dist/commands/version/index.js.map +1 -0
- package/dist/commands/version/version.command.js +25 -0
- package/dist/commands/version/version.command.js.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/encapsulation/chalk.utilities.js +54 -0
- package/dist/encapsulation/chalk.utilities.js.map +1 -0
- package/dist/encapsulation/cp.utilities.js +42 -0
- package/dist/encapsulation/cp.utilities.js.map +1 -0
- package/dist/encapsulation/death.utilities.js +19 -0
- package/dist/encapsulation/death.utilities.js.map +1 -0
- package/dist/encapsulation/figlet.utilities.js +20 -0
- package/dist/encapsulation/figlet.utilities.js.map +1 -0
- package/dist/encapsulation/fs.utilities.js +238 -0
- package/dist/encapsulation/fs.utilities.js.map +1 -0
- package/dist/encapsulation/index.js +10 -0
- package/dist/encapsulation/index.js.map +1 -0
- package/dist/encapsulation/inquirer.utilities.js +54 -0
- package/dist/encapsulation/inquirer.utilities.js.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/exit-gracefully.function.js +22 -0
- package/dist/utilities/exit-gracefully.function.js.map +1 -0
- package/dist/utilities/exit-with-error.function.js +19 -0
- package/dist/utilities/exit-with-error.function.js.map +1 -0
- package/dist/utilities/exit-with-interrupt.function.js +15 -0
- package/dist/utilities/exit-with-interrupt.function.js.map +1 -0
- package/dist/utilities/get-path.function.js +26 -0
- package/dist/utilities/get-path.function.js.map +1 -0
- package/dist/utilities/index.js +10 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/is-error-with-signal.function.js +13 -0
- package/dist/utilities/is-error-with-signal.function.js.map +1 -0
- package/dist/utilities/is-exit-prompt-error.function.js +12 -0
- package/dist/utilities/is-exit-prompt-error.function.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FsUtilities = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const utilities_1 = require("../utilities");
|
|
7
|
+
/**
|
|
8
|
+
* Encapsulates functionality of the fs package.
|
|
9
|
+
*/
|
|
10
|
+
class FsUtilities {
|
|
11
|
+
/**
|
|
12
|
+
* Gets file lines between the provided indices.
|
|
13
|
+
* @param lines - The string lines to build the FileLine[] from.
|
|
14
|
+
* @param fromIndex - From which index to start.
|
|
15
|
+
* @param untilIndex - Until which index to build.
|
|
16
|
+
* @returns An array of FileLine.
|
|
17
|
+
*/
|
|
18
|
+
static getFileLines(lines, fromIndex, untilIndex) {
|
|
19
|
+
const allLines = [];
|
|
20
|
+
for (let i = 0; i < lines.length; i++) {
|
|
21
|
+
allLines.push({ content: lines[i], index: i });
|
|
22
|
+
}
|
|
23
|
+
return allLines.filter(l => l.index >= fromIndex && l.index <= untilIndex);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Tries to find a line inside the provided lines which contains the given content.
|
|
27
|
+
* You can optionally filter to only search in a specified line range.
|
|
28
|
+
* @param linesOrPath - The lines or the path of the file to search in.
|
|
29
|
+
* @param content - The content to search for.
|
|
30
|
+
* @param fromIndex - At which line the search should start. Defaults to 0,.
|
|
31
|
+
* @param untilIndex - At which line the search should end. Defaults to the end of the array.
|
|
32
|
+
* @returns The found line.
|
|
33
|
+
* @throws When no line could be found.
|
|
34
|
+
*/
|
|
35
|
+
static async findLineWithContent(linesOrPath, content, fromIndex = 0, untilIndex) {
|
|
36
|
+
const lines = typeof linesOrPath === 'string' ? await this.readFileLines(linesOrPath) : linesOrPath;
|
|
37
|
+
untilIndex = untilIndex ?? lines.length - 1;
|
|
38
|
+
let line = { index: fromIndex, content: lines[fromIndex] };
|
|
39
|
+
while (!line.content.includes(content)) {
|
|
40
|
+
const i = line.index + 1;
|
|
41
|
+
if (i > untilIndex) {
|
|
42
|
+
throw new Error(`Could not find line with content "${content}" in the lines ${fromIndex}-${untilIndex}`);
|
|
43
|
+
}
|
|
44
|
+
line = { index: i, content: lines[i] };
|
|
45
|
+
}
|
|
46
|
+
return line;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a file at the given path exists.
|
|
50
|
+
* @param path - The path to check.
|
|
51
|
+
* @returns True when a file could be accessed and false otherwise.
|
|
52
|
+
*/
|
|
53
|
+
static async exists(path) {
|
|
54
|
+
try {
|
|
55
|
+
await (0, promises_1.access)(path);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Renames "from" to "to".
|
|
64
|
+
* @param from - The old path.
|
|
65
|
+
* @param to - The new path.
|
|
66
|
+
*/
|
|
67
|
+
static async rename(from, to) {
|
|
68
|
+
await (0, promises_1.rename)(from, to);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Replace all instances of oldContent in the file at the given path with newContent.
|
|
72
|
+
* @param path - The path of the file.
|
|
73
|
+
* @param oldContent - The old content that should be replaced.
|
|
74
|
+
* @param newContent - The new content that should replace the old one.
|
|
75
|
+
* @param fromIndex - The starting line index (inclusive). Defaults to the start of the file.
|
|
76
|
+
* @param untilIndex - The ending line index (inclusive). Defaults to the end of the file.
|
|
77
|
+
*/
|
|
78
|
+
static async replaceAllInFile(path, oldContent, newContent, fromIndex, untilIndex) {
|
|
79
|
+
await this.replaceContentInFile(path, oldContent, newContent, true, fromIndex, untilIndex);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Replace all instances of oldContent in the file at the given path with newContent.
|
|
83
|
+
* @param path - The path of the file.
|
|
84
|
+
* @param oldContent - The old content that should be replaced.
|
|
85
|
+
* @param newContent - The new content that should replace the old one.
|
|
86
|
+
* @param fromIndex - The starting line index (inclusive). Defaults to the start of the file.
|
|
87
|
+
* @param untilIndex - The ending line index (inclusive). Defaults to the end of the file.
|
|
88
|
+
*/
|
|
89
|
+
static async replaceInFile(path, oldContent, newContent, fromIndex, untilIndex) {
|
|
90
|
+
await this.replaceContentInFile(path, oldContent, newContent, false, fromIndex, untilIndex);
|
|
91
|
+
}
|
|
92
|
+
static async replaceContentInFile(path, oldContent, newContent, all, fromIndex, untilIndex) {
|
|
93
|
+
let content = await this.readFile(path);
|
|
94
|
+
const lines = content.split('\n');
|
|
95
|
+
// Normalize indexes
|
|
96
|
+
const start = fromIndex ?? 0;
|
|
97
|
+
const end = untilIndex !== undefined ? untilIndex + 1 : lines.length;
|
|
98
|
+
const beforeLines = lines.slice(0, start);
|
|
99
|
+
const afterLines = lines.slice(end);
|
|
100
|
+
const stringToModify = lines.slice(start, end).join('\n');
|
|
101
|
+
const modifiedLines = stringToModify[all ? 'replaceAll' : 'replace'](oldContent, newContent);
|
|
102
|
+
content = [...beforeLines, ...modifiedLines.split('\n'), ...afterLines].join('\n');
|
|
103
|
+
await this.updateFile(path, content, 'replace');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates a file at the given path.
|
|
107
|
+
* @param path - The path of the new file to create.
|
|
108
|
+
* @param data - The data to write into the file. Can be a raw data string or an array of lines, which are joined by \n.
|
|
109
|
+
* @param recursive - Whether or not to recursively create the file.
|
|
110
|
+
* @param log - Whether or not the success of the creation should be logged to the console.
|
|
111
|
+
*/
|
|
112
|
+
static async createFile(path, data, recursive = true, log = true) {
|
|
113
|
+
if (await this.exists(path)) {
|
|
114
|
+
throw new Error(`File at ${path} already exists. Did you mean to call "updateFile"?`);
|
|
115
|
+
}
|
|
116
|
+
data = this.normalizeData(data);
|
|
117
|
+
const parentDir = (0, path_1.dirname)(path);
|
|
118
|
+
if (recursive && !await this.exists(parentDir)) {
|
|
119
|
+
await this.mkdir(parentDir, true, false);
|
|
120
|
+
}
|
|
121
|
+
await (0, promises_1.writeFile)(path, data);
|
|
122
|
+
if (log) {
|
|
123
|
+
// eslint-disable-next-line no-console
|
|
124
|
+
console.log('created', path);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
static normalizeData(data) {
|
|
128
|
+
if (Array.isArray(data)) {
|
|
129
|
+
data = data.join('\n');
|
|
130
|
+
}
|
|
131
|
+
data = data.replaceAll('\t', ' ');
|
|
132
|
+
return data.endsWith('\n') ? data.slice(0, -1) : data;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Updates the file at the given path with the given data.
|
|
136
|
+
* Can either replace, prepend or append.
|
|
137
|
+
* @param path - The path of the new file to create.
|
|
138
|
+
* @param data - The data to write into the file. Can be a raw data string or an array of lines, which are joined by \n.
|
|
139
|
+
* @param action - Whether the data should replace the current content or be pre-/appended.
|
|
140
|
+
* @param log - Whether or not the success of the update should be logged to the console.
|
|
141
|
+
*/
|
|
142
|
+
static async updateFile(path, data, action, log = true) {
|
|
143
|
+
if (!await this.exists(path)) {
|
|
144
|
+
throw new Error(`File at ${path} does not exist. Did you mean to call "createFile"?`);
|
|
145
|
+
}
|
|
146
|
+
data = this.normalizeData(data);
|
|
147
|
+
switch (action) {
|
|
148
|
+
case 'replace': {
|
|
149
|
+
await (0, promises_1.writeFile)(path, data);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'append': {
|
|
153
|
+
let currentContent = await this.readFileLines(path);
|
|
154
|
+
currentContent = currentContent[0].length ? [...currentContent, data] : [data];
|
|
155
|
+
await (0, promises_1.writeFile)(path, this.normalizeData(currentContent));
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case 'prepend': {
|
|
159
|
+
let currentContent = await this.readFileLines(path);
|
|
160
|
+
currentContent = currentContent[0].length ? [data, ...currentContent] : [data];
|
|
161
|
+
await (0, promises_1.writeFile)(path, this.normalizeData(currentContent));
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (log) {
|
|
166
|
+
// eslint-disable-next-line no-console
|
|
167
|
+
console.log('updated', path);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Reads the file content at the given path.
|
|
172
|
+
* Expects utf-8.
|
|
173
|
+
* @param path - The path of the file to read.
|
|
174
|
+
* @returns The content as a single string.
|
|
175
|
+
*/
|
|
176
|
+
static async readFile(path) {
|
|
177
|
+
return (0, promises_1.readFile)(path, { encoding: 'utf8' });
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Same as readFile, but returns the content as an array of lines instead.
|
|
181
|
+
* @param path - The path of the file to read the lines from.
|
|
182
|
+
* @returns The content as an array of line strings.
|
|
183
|
+
*/
|
|
184
|
+
static async readFileLines(path) {
|
|
185
|
+
const content = await this.readFile(path);
|
|
186
|
+
return content.split('\n');
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Removes either a file or directory.
|
|
190
|
+
* @param path - The path to remove.
|
|
191
|
+
* @param recursive - Whether or not subdirectories should be deleted as well. Defaults to true.
|
|
192
|
+
*/
|
|
193
|
+
static async rm(path, recursive = true) {
|
|
194
|
+
if (!await this.exists(path)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
await (0, promises_1.rm)(path, { recursive: recursive, force: true });
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates a directory at the given path.
|
|
201
|
+
* @param path - The path of the directory to create.
|
|
202
|
+
* @param recursive - Whether or not missing directories in the path should be created as well.
|
|
203
|
+
* @param log - Whether or not the success of the creation should be logged to the console.
|
|
204
|
+
*/
|
|
205
|
+
static async mkdir(path, recursive = true, log = true) {
|
|
206
|
+
await (0, promises_1.mkdir)(path, { recursive: recursive });
|
|
207
|
+
if (log) {
|
|
208
|
+
// eslint-disable-next-line no-console
|
|
209
|
+
console.log('created', path);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Gets the root level subdirectories and files of the directory at the provided path.
|
|
214
|
+
* @param path - The path of the directory to get the contents of.
|
|
215
|
+
* @returns An array of the directory contents.
|
|
216
|
+
*/
|
|
217
|
+
static async readdir(path) {
|
|
218
|
+
return (0, promises_1.readdir)(path, { withFileTypes: true });
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Moves the contents of the given source inside the given destination.
|
|
222
|
+
* Overrides any contents that might already exist inside the destination.
|
|
223
|
+
* @param sourcePath - The source folder to move the content of.
|
|
224
|
+
* @param destinationPath - The destination folder where the content should be moved inside.
|
|
225
|
+
* @param excludeElements - Optional array of elements which should not be moved.
|
|
226
|
+
*/
|
|
227
|
+
static async copyDirectoryContent(sourcePath, destinationPath, excludeElements = []) {
|
|
228
|
+
const entries = (await this.readdir(sourcePath)).filter(e => !excludeElements.includes(e.name));
|
|
229
|
+
await Promise.all(entries.map(e => this.copyEntry(e, destinationPath)));
|
|
230
|
+
}
|
|
231
|
+
static async copyEntry(entry, destination) {
|
|
232
|
+
const source = (0, utilities_1.getPath)(entry.parentPath, entry.name);
|
|
233
|
+
const dest = (0, utilities_1.getPath)(destination, entry.name);
|
|
234
|
+
await (0, promises_1.cp)(source, dest, { recursive: true, errorOnExist: true });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.FsUtilities = FsUtilities;
|
|
238
|
+
//# sourceMappingURL=fs.utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.utilities.js","sourceRoot":"","sources":["../../src/encapsulation/fs.utilities.ts"],"names":[],"mappings":";;;AACA,0CAA0F;AAC1F,+BAA+B;AAE/B,4CAA6C;AAiB7C;;GAEG;AACH,MAAsB,WAAW;IAE7B;;;;;;OAMG;IACH,MAAM,CAAC,YAAY,CAAC,KAAe,EAAE,SAAiB,EAAE,UAAkB;QACtE,MAAM,QAAQ,GAAe,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,IAAI,CAAC,CAAC,KAAK,IAAI,UAAU,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAC5B,WAA4B,EAC5B,OAAe,EACf,YAAoB,CAAC,EACrB,UAAmB;QAEnB,MAAM,KAAK,GAAa,OAA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MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAU;QAC3B,OAAO,IAAA,kBAAO,EAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,UAAgB,EAAE,eAAqB,EAAE,kBAA4B,EAAE;QACrG,MAAM,OAAO,GAAa,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1G,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,WAAmB;QAC7D,MAAM,MAAM,GAAS,IAAA,mBAAO,EAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAS,IAAA,mBAAO,EAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,IAAA,aAAE,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;CACJ;AAtRD,kCAsRC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./chalk.utilities"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./figlet.utilities"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./inquirer.utilities"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./death.utilities"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./fs.utilities"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./cp.utilities"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/encapsulation/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,6DAAmC;AACnC,+DAAqC;AACrC,4DAAkC;AAClC,yDAA+B;AAC/B,yDAA+B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InquirerUtilities = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const utilities_1 = require("../utilities");
|
|
7
|
+
/**
|
|
8
|
+
* Encapsulates functionality of the inquirer package.
|
|
9
|
+
*/
|
|
10
|
+
class InquirerUtilities {
|
|
11
|
+
/**
|
|
12
|
+
* Prompts the user for console input.
|
|
13
|
+
* @param questionsFor - The questions to ask the user.
|
|
14
|
+
* @returns The inputs from the user.
|
|
15
|
+
*/
|
|
16
|
+
static async prompt(questionsFor) {
|
|
17
|
+
const res = {};
|
|
18
|
+
for (const key in questionsFor) {
|
|
19
|
+
res[key] = await this.getResultForQuestion(questionsFor[key]);
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
static async getResultForQuestion(question) {
|
|
24
|
+
if (this.isQuestion(question)) {
|
|
25
|
+
try {
|
|
26
|
+
const res = await this.inquire(question);
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if ((0, utilities_1.isExitPromptError)(error) || ((0, utilities_1.isErrorWithSignal)(error) && error.signal === 'SIGINT')) {
|
|
31
|
+
return await (0, utilities_1.exitWithInterrupt)();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const res = {};
|
|
39
|
+
for (const key in question) {
|
|
40
|
+
res[key] = await this.getResultForQuestion(question[key]);
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
static isQuestion(question) {
|
|
45
|
+
const q = question;
|
|
46
|
+
return q.type != undefined && q.message != undefined;
|
|
47
|
+
}
|
|
48
|
+
static async inquire(question) {
|
|
49
|
+
const answers = await inquirer_1.default.prompt([question]);
|
|
50
|
+
return answers[''];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.InquirerUtilities = InquirerUtilities;
|
|
54
|
+
//# sourceMappingURL=inquirer.utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inquirer.utilities.js","sourceRoot":"","sources":["../../src/encapsulation/inquirer.utilities.ts"],"names":[],"mappings":";;;;AAAA,gEAAgC;AAGhC,4CAAuF;AASvF;;GAEG;AACH,MAAsB,iBAAiB;IACnC;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAI,YAA6B;QAChD,MAAM,GAAG,GAAM,EAAO,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC7B,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAI,QAA2C;QACpF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACD,MAAM,GAAG,GAAM,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC5C,OAAO,GAAG,CAAC;YACf,CAAC;YACD,OAAO,KAAK,EAAE,CAAC;gBACX,IAAI,IAAA,6BAAiB,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,6BAAiB,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,EAAE,CAAC;oBACtF,OAAO,MAAM,IAAA,6BAAiB,GAAE,CAAC;gBACrC,CAAC;qBACI,CAAC;oBACF,MAAM,KAAK,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;QACD,MAAM,GAAG,GAAM,EAAO,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAEO,MAAM,CAAC,UAAU,CAAI,QAA2C;QACpE,MAAM,CAAC,GAAoB,QAA2B,CAAC;QACvD,OAAO,CAAC,CAAC,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,OAAO,IAAI,SAAS,CAAC;IACzD,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAI,QAAyB;QACrD,MAAM,OAAO,GAAY,MAAM,kBAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3D,OAAO,OAAO,CAAC,EAAE,CAAM,CAAC;IAC5B,CAAC;CACJ;AA7CD,8CA6CC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commands_1 = require("./commands");
|
|
5
|
+
const encapsulation_1 = require("./encapsulation");
|
|
6
|
+
encapsulation_1.DeathUtilities.death();
|
|
7
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
8
|
+
async function main() {
|
|
9
|
+
const [, , ...args] = process.argv;
|
|
10
|
+
encapsulation_1.FigletUtilities.displayLogo();
|
|
11
|
+
const command = await (0, commands_1.resolveCommand)(args);
|
|
12
|
+
if (command === 'error') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
switch (command) {
|
|
16
|
+
case commands_1.Command.H:
|
|
17
|
+
case commands_1.Command.HELP: {
|
|
18
|
+
await new commands_1.HelpCommand().start(args);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
case commands_1.Command.VERSION:
|
|
22
|
+
case commands_1.Command.V: {
|
|
23
|
+
await new commands_1.VersionCommand().start(args);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
case commands_1.Command.NEW:
|
|
27
|
+
case commands_1.Command.N: {
|
|
28
|
+
await new commands_1.NewCommand().start(args);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
void main();
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAA8F;AAC9F,mDAAkE;AAElE,8BAAc,CAAC,KAAK,EAAE,CAAC;AAEvB,+CAA+C;AAC/C,KAAK,UAAU,IAAI;IACf,MAAM,CAAC,EAAC,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAElC,+BAAe,CAAC,WAAW,EAAE,CAAC;IAE9B,MAAM,OAAO,GAAsB,MAAM,IAAA,yBAAc,EAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACtB,OAAO;IACX,CAAC;IAED,QAAQ,OAAO,EAAE,CAAC;QACd,KAAK,kBAAO,CAAC,CAAC,CAAC;QACf,KAAK,kBAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAChB,MAAM,IAAI,sBAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,OAAO;QACX,CAAC;QACD,KAAK,kBAAO,CAAC,OAAO,CAAC;QACrB,KAAK,kBAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACb,MAAM,IAAI,yBAAc,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO;QACX,CAAC;QACD,KAAK,kBAAO,CAAC,GAAG,CAAC;QACjB,KAAK,kBAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACb,MAAM,IAAI,qBAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO;QACX,CAAC;IACL,CAAC;AACL,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exitGracefully = exitGracefully;
|
|
4
|
+
const promises_1 = require("node:stream/promises");
|
|
5
|
+
/**
|
|
6
|
+
* Exits the process gracefully.
|
|
7
|
+
* @param code - The exit code.
|
|
8
|
+
* @returns Never, as this will close the process.
|
|
9
|
+
*/
|
|
10
|
+
async function exitGracefully(code) {
|
|
11
|
+
process.exitCode = code;
|
|
12
|
+
try {
|
|
13
|
+
await Promise.all([
|
|
14
|
+
(0, promises_1.finished)(process.stdout, { writable: true }),
|
|
15
|
+
(0, promises_1.finished)(process.stderr, { writable: true })
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
return process.exit(code);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=exit-gracefully.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-gracefully.function.js","sourceRoot":"","sources":["../../src/utilities/exit-gracefully.function.ts"],"names":[],"mappings":";;AAOA,wCAWC;AAlBD,mDAAgD;AAEhD;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAAC,IAAY;IAC7C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC;YACd,IAAA,mBAAQ,EAAC,OAAO,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC5C,IAAA,mBAAQ,EAAC,OAAO,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SAC/C,CAAC,CAAC;IACP,CAAC;YACO,CAAC;QACL,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exitWithError = exitWithError;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const encapsulation_1 = require("../encapsulation");
|
|
6
|
+
const exit_gracefully_function_1 = require("./exit-gracefully.function");
|
|
7
|
+
/**
|
|
8
|
+
* Exits the cli with the given error message.
|
|
9
|
+
* @param message - The message/reason to display when exiting.
|
|
10
|
+
* @returns Never, as the program stops when this function finished running.
|
|
11
|
+
*/
|
|
12
|
+
async function exitWithError(message) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.error(encapsulation_1.ChalkUtilities.error(message));
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.log(constants_1.MORE_INFORMATION_MESSAGE);
|
|
17
|
+
return await (0, exit_gracefully_function_1.exitGracefully)(1);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=exit-with-error.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-with-error.function.js","sourceRoot":"","sources":["../../src/utilities/exit-with-error.function.ts"],"names":[],"mappings":";;AASA,sCAMC;AAfD,4CAAwD;AACxD,oDAAkD;AAClD,yEAA4D;AAE5D;;;;GAIG;AACI,KAAK,UAAU,aAAa,CAAC,OAAe;IAC/C,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,8BAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,oCAAwB,CAAC,CAAC;IACtC,OAAO,MAAM,IAAA,yCAAc,EAAC,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exitWithInterrupt = exitWithInterrupt;
|
|
4
|
+
const encapsulation_1 = require("../encapsulation");
|
|
5
|
+
const exit_gracefully_function_1 = require("./exit-gracefully.function");
|
|
6
|
+
/**
|
|
7
|
+
* Exits the cli when an interrupt occurs.
|
|
8
|
+
* @returns Never, as the program stops when this function finished running.
|
|
9
|
+
*/
|
|
10
|
+
async function exitWithInterrupt() {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.log(encapsulation_1.ChalkUtilities.secondary('\nProcess interrupted (Ctrl+C)'));
|
|
13
|
+
return await (0, exit_gracefully_function_1.exitGracefully)(130);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=exit-with-interrupt.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-with-interrupt.function.js","sourceRoot":"","sources":["../../src/utilities/exit-with-interrupt.function.ts"],"names":[],"mappings":";;AAOA,8CAIC;AAXD,oDAAkD;AAClD,yEAA4D;AAE5D;;;GAGG;AACI,KAAK,UAAU,iBAAiB;IACnC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,8BAAc,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC,CAAC;IACxE,OAAO,MAAM,IAAA,yCAAc,EAAC,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPath = getPath;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const encapsulation_1 = require("../encapsulation");
|
|
7
|
+
/**
|
|
8
|
+
* Gets a os agnostic path by joining the given parts.
|
|
9
|
+
* @param paths - The paths to combine.
|
|
10
|
+
* @returns The os agnostic file/dir path.
|
|
11
|
+
* @throws When the given paths could not be joined.
|
|
12
|
+
*/
|
|
13
|
+
function getPath(...paths) {
|
|
14
|
+
try {
|
|
15
|
+
const basePath = path_1.default.join(...paths);
|
|
16
|
+
if (path_1.default.isAbsolute(basePath)) {
|
|
17
|
+
return basePath;
|
|
18
|
+
}
|
|
19
|
+
const baseRoot = encapsulation_1.CPUtilities['cwd'] ?? '';
|
|
20
|
+
return path_1.default.join(baseRoot, basePath);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
throw new Error(`Error trying to get the path ${paths.join()}`, { cause: error });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=get-path.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-path.function.js","sourceRoot":"","sources":["../../src/utilities/get-path.function.ts"],"names":[],"mappings":";;AAkBA,0BAYC;;AA9BD,wDAAwB;AAExB,oDAA+C;AAU/C;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,GAAG,KAAe;IACtC,IAAI,CAAC;QACD,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC7C,IAAI,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,QAAgB,CAAC;QAC5B,CAAC;QACD,MAAM,QAAQ,GAAW,2BAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClD,OAAO,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAS,CAAC;IACjD,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./exit-with-error.function"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./exit-gracefully.function"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./exit-with-interrupt.function"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./is-error-with-signal.function"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./is-exit-prompt-error.function"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./get-path.function"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;AAAA,qEAA2C;AAC3C,qEAA2C;AAC3C,yEAA+C;AAC/C,0EAAgD;AAChD,0EAAgD;AAChD,8DAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isErrorWithSignal = isErrorWithSignal;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the given error has a signal like SIGINT, etc.
|
|
6
|
+
* @param error - The error to check.
|
|
7
|
+
* @returns True when the error has a 'signal' key, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
10
|
+
function isErrorWithSignal(error) {
|
|
11
|
+
return typeof error === 'object' && error !== null && 'signal' in error;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=is-error-with-signal.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-error-with-signal.function.js","sourceRoot":"","sources":["../../src/utilities/is-error-with-signal.function.ts"],"names":[],"mappings":";;AAOA,8CAEC;AARD;;;;GAIG;AACH,+CAA+C;AAC/C,SAAgB,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isExitPromptError = isExitPromptError;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the given error has a signal like SIGINT, etc.
|
|
6
|
+
* @param error - The error to check.
|
|
7
|
+
* @returns True when the error has a 'signal' key, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
function isExitPromptError(error) {
|
|
10
|
+
return typeof error === 'object' && error !== null && 'name' in error && error.name === 'ExitPromptError';
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=is-exit-prompt-error.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-exit-prompt-error.function.js","sourceRoot":"","sources":["../../src/utilities/is-exit-prompt-error.function.ts"],"names":[],"mappings":";;AAKA,8CAEC;AAPD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAC9G,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zibri-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": ["./dist", "./README.md", "./LICENSE", "./assets"],
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"zibri",
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
14
|
+
"author": "Tim Fabian",
|
|
15
|
+
"description": "",
|
|
16
|
+
"bin": {
|
|
17
|
+
"zi": "dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"start": "npm run build && cd sandbox && node ../dist/index.js",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"clear": "rm -rf sandbox && mkdir sandbox && npm run start n api",
|
|
23
|
+
"lint": "eslint . --max-warnings=0",
|
|
24
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
25
|
+
"prepublishOnly": "npm i && npm run build"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/death": "^1.1.5",
|
|
29
|
+
"@types/figlet": "^1.7.0",
|
|
30
|
+
"@types/node": "^22.15.18",
|
|
31
|
+
"eslint": "^9.24.0",
|
|
32
|
+
"eslint-config-service-soft": "^2.0.8",
|
|
33
|
+
"typescript": "^5.8.3"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"death": "^1.1.0",
|
|
37
|
+
"figlet": "^1.8.1",
|
|
38
|
+
"inquirer": "^10.2.2"
|
|
39
|
+
}
|
|
40
|
+
}
|