Befor generating

This commit is contained in:
marys
2026-06-01 13:17:37 +02:00
parent 3383f4bf4a
commit 1aa1b5f625
6756 changed files with 649946 additions and 1 deletions
@@ -0,0 +1,13 @@
declare class GetFilesResponse {
files: string[];
dirs: string[];
constructor(files: string[], dirs: string[]);
}
/**
* Function which finds all the files and dirs in folders
* @private
* @param dir directory to find files and dirs in.
* @param includeSubDirs should the function iterate through subdirectories to search for files and dirs?
*/
export declare function getStatsInDir(dir: string): Promise<GetFilesResponse>;
export {};
@@ -0,0 +1,103 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStatsInDir = void 0;
var path_1 = __importDefault(require("path"));
var fs_1 = __importDefault(require("fs"));
var util_1 = require("util");
var _1 = require(".");
var readdir = util_1.promisify(fs_1.default.readdir);
var stat = util_1.promisify(fs_1.default.stat);
var GetFilesResponse = /** @class */ (function () {
function GetFilesResponse(files, dirs) {
this.files = files;
this.dirs = dirs;
}
return GetFilesResponse;
}());
/**
* Function which finds all the files and dirs in folders
* @private
* @param dir directory to find files and dirs in.
* @param includeSubDirs should the function iterate through subdirectories to search for files and dirs?
*/
function getStatsInDir(dir) {
return __awaiter(this, void 0, void 0, function () {
var allFiles, files, dirs, _i, allFiles_1, filename, res, stats, resolveFilenameCallback;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, readdir(dir)];
case 1:
allFiles = _a.sent();
files = [];
dirs = [];
_i = 0, allFiles_1 = allFiles;
_a.label = 2;
case 2:
if (!(_i < allFiles_1.length)) return [3 /*break*/, 5];
filename = allFiles_1[_i];
res = path_1.default.resolve(dir, filename);
return [4 /*yield*/, stat(res)];
case 3:
stats = _a.sent();
if (stats.isDirectory()) {
dirs.push(res);
}
else if (_1.isJsFile(filename)) {
files.push(res);
}
_a.label = 4;
case 4:
_i++;
return [3 /*break*/, 2];
case 5:
resolveFilenameCallback = function (filename) {
return path_1.default.resolve(dir, filename);
};
files = files.map(resolveFilenameCallback);
dirs = dirs.map(resolveFilenameCallback);
return [2 /*return*/, new GetFilesResponse(files, dirs)];
}
});
});
}
exports.getStatsInDir = getStatsInDir;
//# sourceMappingURL=getStatsInDir.js.map
@@ -0,0 +1 @@
{"version":3,"file":"getStatsInDir.js","sourceRoot":"","sources":["../../src/utils/getStatsInDir.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,0CAAoB;AACpB,6BAAiC;AACjC,sBAA6B;AAE7B,IAAM,OAAO,GAAG,gBAAS,CAAC,YAAE,CAAC,OAAO,CAAC,CAAC;AACtC,IAAM,IAAI,GAAG,gBAAS,CAAC,YAAE,CAAC,IAAI,CAAC,CAAC;AAEhC;IAGI,0BAAa,KAAe,EAAE,IAAc;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACL,uBAAC;AAAD,CAAC,AAPD,IAOC;AAED;;;;;GAKG;AACH,SAAsB,aAAa,CAAC,GAAW;;;;;wBAC1B,qBAAM,OAAO,CAAC,GAAG,CAAC,EAAA;;oBAA7B,QAAQ,GAAG,SAAkB;oBAC/B,KAAK,GAAa,EAAE,CAAC;oBACrB,IAAI,GAAa,EAAE,CAAC;0BACO,EAAR,qBAAQ;;;yBAAR,CAAA,sBAAQ,CAAA;oBAApB,QAAQ;oBACT,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;oBAC1B,qBAAM,IAAI,CAAC,GAAG,CAAC,EAAA;;oBAAvB,KAAK,GAAG,SAAe;oBAC7B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;wBACrB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;qBACjB;yBAAM,IAAI,WAAQ,CAAC,QAAQ,CAAC,EAAE;wBAC3B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACnB;;;oBAPkB,IAAQ,CAAA;;;oBASzB,uBAAuB,GAAG,UAAC,QAAgB;wBAC7C,OAAO,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;oBACvC,CAAC,CAAA;oBACD,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;oBAC3C,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;oBACzC,sBAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAC;;;;CAC5C;AAnBD,sCAmBC"}
@@ -0,0 +1,4 @@
export * from "./getStatsInDir";
export * from "./isJsFile";
export * from "./withIndendation";
export * from "./withNewLines";
@@ -0,0 +1,17 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./getStatsInDir"), exports);
__exportStar(require("./isJsFile"), exports);
__exportStar(require("./withIndendation"), exports);
__exportStar(require("./withNewLines"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,6CAA2B;AAC3B,oDAAkC;AAClC,iDAA+B"}
@@ -0,0 +1,7 @@
/**
* Function which checks if file is JS file
* @private
* @param {string} filename
* @returns {boolean}
*/
export declare function isJsFile(filename?: string): boolean;
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isJsFile = void 0;
var ALLOWED_EXTS = ['js', 'jsx', 'cjs'];
/**
* Function which checks if file is JS file
* @private
* @param {string} filename
* @returns {boolean}
*/
function isJsFile(filename) {
if (filename === void 0) { filename = ''; }
var ext = filename.split('.').pop() || '';
return ALLOWED_EXTS.includes(ext);
}
exports.isJsFile = isJsFile;
//# sourceMappingURL=isJsFile.js.map
@@ -0,0 +1 @@
{"version":3,"file":"isJsFile.js","sourceRoot":"","sources":["../../src/utils/isJsFile.ts"],"names":[],"mappings":";;;AAAA,IAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,QAAqB;IAArB,yBAAA,EAAA,aAAqB;IAC5C,IAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAC5C,OAAO,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAHD,4BAGC"}
@@ -0,0 +1,20 @@
/**
* Type of indentation to use
* @readonly
* @enum {string}
* @property {string} TABS - indicate to use tabs as separator
* @property {string} SPACES - indicate to use spaces as separator
*/
export declare enum IndentationTypes {
TABS = "tabs",
SPACES = "spaces"
}
/**
* Ensures indentations are prepended to content.
* @private
* @param {string} content to prepend the indentation
* @param {number} size the number of indendations to use
* @param {IndentationTypes} type the type of indendations to use. SPACES by default.
* @returns {string}
*/
export declare function withIndendation(content: string | undefined, size: number, type?: IndentationTypes): string;
@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withIndendation = exports.IndentationTypes = void 0;
/**
* Type of indentation to use
* @readonly
* @enum {string}
* @property {string} TABS - indicate to use tabs as separator
* @property {string} SPACES - indicate to use spaces as separator
*/
var IndentationTypes;
(function (IndentationTypes) {
IndentationTypes["TABS"] = "tabs";
IndentationTypes["SPACES"] = "spaces";
})(IndentationTypes = exports.IndentationTypes || (exports.IndentationTypes = {}));
/**
* Ensures indentations are prepended to content.
* @private
* @param {string} content to prepend the indentation
* @param {number} size the number of indendations to use
* @param {IndentationTypes} type the type of indendations to use. SPACES by default.
* @returns {string}
*/
function withIndendation(content, size, type) {
if (content === void 0) { content = ''; }
if (type === void 0) { type = IndentationTypes.SPACES; }
if (size < 1) {
return content;
}
// if the content includes new lines ensure that they have the added indentation as well.
if (content.includes('\n')) {
var newLineArray = content.split('\n');
return newLineArray.reduce(function (accumulator, value) {
var newValue = value.trim() === '' ? value : "" + getIndentation(size, type) + value;
return accumulator === "" ? newValue : accumulator + "\n" + newValue;
}, "");
}
return "" + getIndentation(size, type) + content;
}
exports.withIndendation = withIndendation;
/**
* Get the indendation string based on how many and which type of indentation are requested.
* @private
* @param {number} size the number of indendations to use
* @param {IndentationTypes} type the type of indendations to use. SPACES by default.
* @returns {string}
*/
function getIndentation(size, type) {
if (size === void 0) { size = 0; }
if (type === void 0) { type = IndentationTypes.SPACES; }
var whitespaceChar = type === IndentationTypes.SPACES ? ' ' : '\t';
return Array(size).fill(whitespaceChar).join("");
}
//# sourceMappingURL=withIndendation.js.map
@@ -0,0 +1 @@
{"version":3,"file":"withIndendation.js","sourceRoot":"","sources":["../../src/utils/withIndendation.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,qCAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,OAAoB,EAAE,IAAY,EAAE,IAAgD;IAApF,wBAAA,EAAA,YAAoB;IAAgB,qBAAA,EAAA,OAAyB,gBAAgB,CAAC,MAAM;IAClH,IAAI,IAAI,GAAG,CAAC,EAAE;QACZ,OAAO,OAAO,CAAC;KAChB;IAED,yFAAyF;IACzF,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAC1B,IAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,YAAY,CAAC,MAAM,CAAC,UAAC,WAAW,EAAE,KAAK;YAC5C,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAO,CAAC;YACvF,OAAO,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAI,WAAW,UAAK,QAAU,CAAC;QACvE,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IACD,OAAO,KAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,OAAS,CAAC;AACnD,CAAC;AAdD,0CAcC;AAED;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,IAAgB,EAAE,IAAgD;IAAlE,qBAAA,EAAA,QAAgB;IAAE,qBAAA,EAAA,OAAyB,gBAAgB,CAAC,MAAM;IACxF,IAAM,cAAc,GAAG,IAAI,KAAK,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACrE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,8 @@
/**
* Prepend given number of the new lines to content.
* @private
* @param {string} content
* @param {number} number
* @returns {string}
*/
export declare function withNewLines(content?: string, number?: number): string;
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withNewLines = void 0;
/**
* Prepend given number of the new lines to content.
* @private
* @param {string} content
* @param {number} number
* @returns {string}
*/
function withNewLines(content, number) {
if (content === void 0) { content = ''; }
if (number === void 0) { number = 0; }
var newLines = Array(number).fill('\n').join('');
return content + newLines;
}
exports.withNewLines = withNewLines;
//# sourceMappingURL=withNewLines.js.map
@@ -0,0 +1 @@
{"version":3,"file":"withNewLines.js","sourceRoot":"","sources":["../../src/utils/withNewLines.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAAoB,EAAE,MAAkB;IAAxC,wBAAA,EAAA,YAAoB;IAAE,uBAAA,EAAA,UAAkB;IACnE,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,OAAO,OAAO,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAHD,oCAGC"}