angel-manager
Version:
<p align="center"> <img src="angel-manager.webp" alt="Angel Manager" width="300"> </p>
606 lines (605 loc) • 18 kB
JavaScript
import { _ as y, a as w, L as M, b as P, c as E } from "../liquid.browser-ICKyr_MB.js";
import m from "fs";
import u from "path";
import { pathToFileURL as W } from "url";
import { Command as J } from "commander";
import { build as X } from "esbuild";
var D = function(r) {
for (var e = r; e !== u.parse(e).root; ) {
if (m.existsSync(u.join(e, "package.json")))
return e;
e = u.dirname(e);
}
throw new Error("Angel Manager: package.json not found. Not a Node.js project.");
}, G = process.cwd(), B = D(G), H = function(r) {
var e = u.join(r, "../temp");
m.mkdir(e, { recursive: !0 }, function(t) {
if (t) {
console.error("Angel Manager [internal]: Error creating temp directory:", t);
return;
}
});
}, V = function(r) {
var e = u.join(r, "../temp");
m.rm(e, { recursive: !0, force: !0 }, function(t) {
if (t) {
console.error("Angel Manager [internal]: Error deleting temp directory:", t);
return;
}
});
}, K = function() {
return y(void 0, void 0, void 0, function() {
var r, e, t, n;
return w(this, function(i) {
switch (i.label) {
case 0:
if (r = u.join(B, "angel-managerrc.json"), e = {}, !m.existsSync(r)) return [3, 4];
i.label = 1;
case 1:
return i.trys.push([1, 3, , 4]), [4, m.promises.readFile(r, "utf-8")];
case 2:
return t = i.sent(), e = JSON.parse(t), [2, e];
case 3:
return n = i.sent(), console.error("Angel Manager [internal]: Error parsing configuration file:", n), [3, 4];
case 4:
return [2, {}];
}
});
});
};
const Q = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), Y = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), Z = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), ee = /[^\p{L}\d]+/giu, F = "$1\0$2", z = "";
function T(r) {
let e = r.trim();
e = e.replace(Q, F).replace(Y, F), e = e.replace(ee, "\0");
let t = 0, n = e.length;
for (; e.charAt(t) === "\0"; )
t++;
if (t === n)
return [];
for (; e.charAt(n - 1) === "\0"; )
n--;
return e.slice(t, n).split(/\0/g);
}
function re(r) {
const e = T(r);
for (let t = 0; t < e.length; t++) {
const n = e[t], i = Z.exec(n);
if (i) {
const s = i.index + (i[1] ?? i[2]).length;
e.splice(t, 1, n.slice(0, s), n.slice(s));
}
}
return e;
}
function U(r, e) {
const [t, n, i] = R(r, e);
return t + n.map(L(e?.locale)).join(e?.delimiter ?? " ") + i;
}
function te(r, e) {
const [t, n, i] = R(r, e), s = L(e?.locale), o = _(e?.locale), l = q(s, o);
return t + n.map((f, p) => p === 0 ? s(f) : l(f, p)).join("") + i;
}
function ne(r, e) {
const [t, n, i] = R(r, e), s = L(e?.locale), o = _(e?.locale), l = q(s, o);
return t + n.map(l).join("") + i;
}
function ae(r, e) {
return U(r, { delimiter: "-", ...e });
}
function ie(r, e) {
return U(r, { delimiter: "_", ...e });
}
function L(r) {
return r === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(r);
}
function _(r) {
return (e) => e.toLocaleUpperCase(r);
}
function q(r, e) {
return (t, n) => {
const i = t[0];
return (n > 0 && i >= "0" && i <= "9" ? "_" + i : e(i)) + r(t.slice(1));
};
}
function R(r, e = {}) {
const t = e.split ?? (e.separateNumbers ? re : T), n = e.prefixCharacters ?? z, i = e.suffixCharacters ?? z;
let s = 0, o = r.length;
for (; s < r.length; ) {
const l = r.charAt(s);
if (!n.includes(l))
break;
s++;
}
for (; o > s; ) {
const l = o - 1, f = r.charAt(l);
if (!i.includes(f))
break;
o = l;
}
return [
r.slice(0, s),
t(r.slice(s, o)),
r.slice(o)
];
}
var se = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function oe(r) {
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
function ce(r) {
throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var N = { exports: {} };
(function(r, e) {
(function(t, n) {
typeof ce == "function" ? r.exports = n() : t.pluralize = n();
})(se, function() {
var t = [], n = [], i = {}, s = {}, o = {};
function l(a) {
return typeof a == "string" ? new RegExp("^" + a + "$", "i") : a;
}
function f(a, c) {
return a === c ? c : a === a.toLowerCase() ? c.toLowerCase() : a === a.toUpperCase() ? c.toUpperCase() : a[0] === a[0].toUpperCase() ? c.charAt(0).toUpperCase() + c.substr(1).toLowerCase() : c.toLowerCase();
}
function p(a, c) {
return a.replace(/\$(\d{1,2})/g, function($, h) {
return c[h] || "";
});
}
function g(a, c) {
return a.replace(c[0], function($, h) {
var v = p(c[1], arguments);
return f($ === "" ? a[h - 1] : $, v);
});
}
function b(a, c, $) {
if (!a.length || i.hasOwnProperty(a))
return c;
for (var h = $.length; h--; ) {
var v = $[h];
if (v[0].test(c)) return g(c, v);
}
return c;
}
function j(a, c, $) {
return function(h) {
var v = h.toLowerCase();
return c.hasOwnProperty(v) ? f(h, v) : a.hasOwnProperty(v) ? f(h, a[v]) : b(v, h, $);
};
}
function A(a, c, $, h) {
return function(v) {
var x = v.toLowerCase();
return c.hasOwnProperty(x) ? !0 : a.hasOwnProperty(x) ? !1 : b(x, x, $) === x;
};
}
function d(a, c, $) {
var h = c === 1 ? d.singular(a) : d.plural(a);
return ($ ? c + " " : "") + h;
}
return d.plural = j(
o,
s,
t
), d.isPlural = A(
o,
s,
t
), d.singular = j(
s,
o,
n
), d.isSingular = A(
s,
o,
n
), d.addPluralRule = function(a, c) {
t.push([l(a), c]);
}, d.addSingularRule = function(a, c) {
n.push([l(a), c]);
}, d.addUncountableRule = function(a) {
if (typeof a == "string") {
i[a.toLowerCase()] = !0;
return;
}
d.addPluralRule(a, "$0"), d.addSingularRule(a, "$0");
}, d.addIrregularRule = function(a, c) {
c = c.toLowerCase(), a = a.toLowerCase(), o[a] = c, s[c] = a;
}, [
// Pronouns.
["I", "we"],
["me", "us"],
["he", "they"],
["she", "they"],
["them", "them"],
["myself", "ourselves"],
["yourself", "yourselves"],
["itself", "themselves"],
["herself", "themselves"],
["himself", "themselves"],
["themself", "themselves"],
["is", "are"],
["was", "were"],
["has", "have"],
["this", "these"],
["that", "those"],
// Words ending in with a consonant and `o`.
["echo", "echoes"],
["dingo", "dingoes"],
["volcano", "volcanoes"],
["tornado", "tornadoes"],
["torpedo", "torpedoes"],
// Ends with `us`.
["genus", "genera"],
["viscus", "viscera"],
// Ends with `ma`.
["stigma", "stigmata"],
["stoma", "stomata"],
["dogma", "dogmata"],
["lemma", "lemmata"],
["schema", "schemata"],
["anathema", "anathemata"],
// Other irregular rules.
["ox", "oxen"],
["axe", "axes"],
["die", "dice"],
["yes", "yeses"],
["foot", "feet"],
["eave", "eaves"],
["goose", "geese"],
["tooth", "teeth"],
["quiz", "quizzes"],
["human", "humans"],
["proof", "proofs"],
["carve", "carves"],
["valve", "valves"],
["looey", "looies"],
["thief", "thieves"],
["groove", "grooves"],
["pickaxe", "pickaxes"],
["passerby", "passersby"]
].forEach(function(a) {
return d.addIrregularRule(a[0], a[1]);
}), [
[/s?$/i, "s"],
[/[^\u0000-\u007F]$/i, "$0"],
[/([^aeiou]ese)$/i, "$1"],
[/(ax|test)is$/i, "$1es"],
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
[/(e[mn]u)s?$/i, "$1s"],
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
[/(seraph|cherub)(?:im)?$/i, "$1im"],
[/(her|at|gr)o$/i, "$1oes"],
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
[/sis$/i, "ses"],
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
[/([^aeiouy]|qu)y$/i, "$1ies"],
[/([^ch][ieo][ln])ey$/i, "$1ies"],
[/(x|ch|ss|sh|zz)$/i, "$1es"],
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
[/(pe)(?:rson|ople)$/i, "$1ople"],
[/(child)(?:ren)?$/i, "$1ren"],
[/eaux$/i, "$0"],
[/m[ae]n$/i, "men"],
["thou", "you"]
].forEach(function(a) {
return d.addPluralRule(a[0], a[1]);
}), [
[/s$/i, ""],
[/(ss)$/i, "$1"],
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
[/ies$/i, "y"],
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
[/\b(mon|smil)ies$/i, "$1ey"],
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
[/(seraph|cherub)im$/i, "$1"],
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
[/(test)(?:is|es)$/i, "$1is"],
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
[/(alumn|alg|vertebr)ae$/i, "$1a"],
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
[/(matr|append)ices$/i, "$1ix"],
[/(pe)(rson|ople)$/i, "$1rson"],
[/(child)ren$/i, "$1"],
[/(eau)x?$/i, "$1"],
[/men$/i, "man"]
].forEach(function(a) {
return d.addSingularRule(a[0], a[1]);
}), [
// Singular words with no plurals.
"adulthood",
"advice",
"agenda",
"aid",
"aircraft",
"alcohol",
"ammo",
"analytics",
"anime",
"athletics",
"audio",
"bison",
"blood",
"bream",
"buffalo",
"butter",
"carp",
"cash",
"chassis",
"chess",
"clothing",
"cod",
"commerce",
"cooperation",
"corps",
"debris",
"diabetes",
"digestion",
"elk",
"energy",
"equipment",
"excretion",
"expertise",
"firmware",
"flounder",
"fun",
"gallows",
"garbage",
"graffiti",
"hardware",
"headquarters",
"health",
"herpes",
"highjinks",
"homework",
"housework",
"information",
"jeans",
"justice",
"kudos",
"labour",
"literature",
"machinery",
"mackerel",
"mail",
"media",
"mews",
"moose",
"music",
"mud",
"manga",
"news",
"only",
"personnel",
"pike",
"plankton",
"pliers",
"police",
"pollution",
"premises",
"rain",
"research",
"rice",
"salmon",
"scissors",
"series",
"sewage",
"shambles",
"shrimp",
"software",
"species",
"staff",
"swine",
"tennis",
"traffic",
"transportation",
"trout",
"tuna",
"wealth",
"welfare",
"whiting",
"wildebeest",
"wildlife",
"you",
/pok[eé]mon$/i,
// Regexes.
/[^aeiou]ese$/i,
// "chinese", "japanese"
/deer$/i,
// "deer", "reindeer"
/fish$/i,
// "fish", "blowfish", "angelfish"
/measles$/i,
/o[iu]s$/i,
// "carnivorous"
/pox$/i,
// "chickpox", "smallpox"
/sheep$/i
].forEach(d.addUncountableRule), d;
});
})(N);
var le = N.exports;
const C = /* @__PURE__ */ oe(le);
var ue = {
base: {},
camel: {},
kebab: {},
snake: {},
pascal: {},
plural: {
camel: {},
kebab: {},
snake: {},
pascal: {}
}
}, fe = function(r) {
return r.map(function(e) {
return "<".concat(e.name, ">");
}).join(" ");
}, I = function(r, e) {
var t = JSON.parse(JSON.stringify(ue));
return r.forEach(function(n, i) {
if (!(typeof n != "string" && typeof n != "number")) {
var s = e[i], o = s.name, l = s.type;
if (l === "number") {
t.base[o] = Number(n);
return;
}
t.base[o] = n;
var f = te(n), p = ae(n), g = ie(n), b = ne(n);
t.camel[o] = f, t.kebab[o] = p, t.snake[o] = g, t.pascal[o] = b, t.plural.camel[o] = C(f), t.plural.kebab[o] = C(p), t.plural.snake[o] = C(g), t.plural.pascal[o] = C(b);
}
}), t;
}, me = function(r, e, t) {
r.command("".concat(e.commandName, " ").concat(fe(e.args()))).description(e.description).action(function() {
for (var n = [], i = 0; i < arguments.length; i++)
n[i] = arguments[i];
return y(void 0, void 0, void 0, function() {
var s, o;
return w(this, function(l) {
return s = e.args(), n.length - 2 !== s.length && console.warn("Warning: Expected ".concat(s.length, " arguments but received ").concat(n.length, ".")), o = I(n, s), e.run({ arguments: o, __dirname: t }), [
2
/*return*/
];
});
});
});
};
function de(r) {
var e = [
u.join(r, "src/scaffolding"),
u.join(r, "src/scaffolding/architecture"),
u.join(r, "src/scaffolding/commands")
];
e.forEach(function(t) {
m.existsSync(t) || m.mkdirSync(t, { recursive: !0 });
}), console.log("Scaffolding directory initialized successfully!");
}
function O(r, e) {
if (m.existsSync(r)) {
m.existsSync(e) || m.mkdirSync(e, { recursive: !0 });
var t = m.readdirSync(r);
t.forEach(function(n) {
var i = u.join(r, n), s = u.join(e, n);
m.statSync(i).isDirectory() && (m.existsSync(s) || m.mkdirSync(s, { recursive: !0 }), O(i, s));
});
}
}
var pe = function(r, e) {
var t = new M(), n = u.join(P, "templates/command.liquid"), i = m.readFileSync(n, "utf8");
r.command("init").description("Initializes the required directories").action(function() {
de(e);
}), r.command("apply").description("Applies the modeled architecture").action(function() {
var s = u.join(e, "src", "scaffolding", "architecture"), o = u.join(e, "src");
O(s, o), console.log("Modeled architecture applied successfully!");
}), r.command("create:command <commandName>").description("Creates a new command").action(function() {
for (var s = [], o = 0; o < arguments.length; o++)
s[o] = arguments[o];
return y(void 0, void 0, void 0, function() {
var l, f, p;
return w(this, function(g) {
switch (g.label) {
case 0:
return l = I(s, [
{ name: "commandName", type: "string" }
]), [4, K()];
case 1:
f = g.sent(), g.label = 2;
case 2:
return g.trys.push([2, 4, , 5]), [4, t.parseAndRender(i, E(E({}, l), { model: E({}, f) })).then(function(b) {
var j = u.join(e, "src/scaffolding/commands/".concat(l.plural.pascal.commandName, ".ts"));
m.writeFileSync(j, b), console.log("Command created successfully!");
})];
case 3:
return g.sent(), [3, 5];
case 4:
throw p = g.sent(), p;
case 5:
return [
2
/*return*/
];
}
});
});
});
}, k = new J(), he = process.cwd(), S = D(he);
function ge(r) {
return y(this, void 0, void 0, function() {
var e;
return w(this, function(t) {
switch (t.label) {
case 0:
return [4, import(r)];
case 1:
return e = t.sent().default, [2, new e()];
}
});
});
}
function ve() {
return y(this, void 0, void 0, function() {
var r, e, t, n, i, s, o, l, f;
return w(this, function(p) {
switch (p.label) {
case 0:
if (r = u.join(S, "src/scaffolding/commands"), !m.existsSync(r))
return [
2
/*return*/
];
e = m.readdirSync(r).filter(function(g) {
return g.endsWith(".ts");
}), H(P), t = 0, n = e, p.label = 1;
case 1:
return t < n.length ? (i = n[t], s = u.join(P, "../temp"), o = u.join(r, i), l = u.join(s, i.replace(/\.ts$/, ".js")), [4, X({
entryPoints: [o],
outfile: l,
bundle: !1,
platform: "node",
format: "esm",
sourcemap: !1,
tsconfig: u.join(S, "tsconfig.json"),
// mudar para o ts do projeto
target: "ESNext"
})]) : [3, 5];
case 2:
return p.sent(), [4, ge(W(l).href)];
case 3:
f = p.sent(), me(k, f, S), p.label = 4;
case 4:
return t++, [3, 1];
case 5:
return V(P), [
2
/*return*/
];
}
});
});
}
(function() {
return y(void 0, void 0, void 0, function() {
return w(this, function(r) {
switch (r.label) {
case 0:
return pe(k, S), [4, ve()];
case 1:
return r.sent(), k.parse(process.argv), [
2
/*return*/
];
}
});
});
})();