@kubb/core 2.0.0-beta.12 → 2.0.0-beta.14
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/dist/chunk-35FDNG5F.cjs +71 -0
- package/dist/chunk-35FDNG5F.cjs.map +1 -0
- package/dist/chunk-7CNPSL5M.js +85 -0
- package/dist/chunk-7CNPSL5M.js.map +1 -0
- package/dist/chunk-DKYWBKNH.js +18 -0
- package/dist/chunk-DKYWBKNH.js.map +1 -0
- package/dist/chunk-EZSRGYAY.js +128 -0
- package/dist/chunk-EZSRGYAY.js.map +1 -0
- package/dist/chunk-GBX7KRCX.cjs +162 -0
- package/dist/chunk-GBX7KRCX.cjs.map +1 -0
- package/dist/chunk-ICRPOCV4.cjs +2290 -0
- package/dist/chunk-ICRPOCV4.cjs.map +1 -0
- package/dist/chunk-LAS7UYTK.cjs +129 -0
- package/dist/chunk-LAS7UYTK.cjs.map +1 -0
- package/dist/chunk-LJHT3DNH.js +67 -0
- package/dist/chunk-LJHT3DNH.js.map +1 -0
- package/dist/chunk-MM42A6GN.cjs +91 -0
- package/dist/chunk-MM42A6GN.cjs.map +1 -0
- package/dist/chunk-SRGTC4FJ.js +129 -0
- package/dist/chunk-SRGTC4FJ.js.map +1 -0
- package/dist/chunk-ST7GHHSU.cjs +104 -0
- package/dist/chunk-ST7GHHSU.cjs.map +1 -0
- package/dist/chunk-U4C2WTCI.cjs +131 -0
- package/dist/chunk-U4C2WTCI.cjs.map +1 -0
- package/dist/chunk-UIQUKFF4.js +155 -0
- package/dist/chunk-UIQUKFF4.js.map +1 -0
- package/dist/chunk-WTSDXEWD.js +71 -0
- package/dist/chunk-WTSDXEWD.js.map +1 -0
- package/dist/fs.cjs +20 -2372
- package/dist/fs.cjs.map +1 -1
- package/dist/fs.d.cts +1 -1
- package/dist/fs.d.ts +1 -1
- package/dist/fs.js +4 -2373
- package/dist/fs.js.map +1 -1
- package/dist/index.cjs +930 -3261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -15
- package/dist/index.d.ts +17 -15
- package/dist/index.js +208 -3490
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +19 -141
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -0
- package/dist/logger.d.ts +1 -0
- package/dist/logger.js +3 -135
- package/dist/logger.js.map +1 -1
- package/dist/transformers.cjs +40 -208
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.js +15 -201
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +22 -524
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +11 -517
- package/dist/utils.js.map +1 -1
- package/dist/{write-46ytbnu9.d.cts → write-A6VgHkYA.d.cts} +4 -1
- package/dist/{write-46ytbnu9.d.ts → write-A6VgHkYA.d.ts} +4 -1
- package/package.json +9 -8
- package/src/BarrelManager.ts +3 -3
- package/src/FileManager.ts +66 -62
- package/src/PluginManager.ts +11 -18
- package/src/build.ts +57 -32
- package/src/fs/clean.ts +2 -2
- package/src/fs/read.ts +1 -0
- package/src/fs/write.ts +40 -24
- package/src/logger.ts +10 -0
- package/src/utils/FunctionParams.ts +2 -2
- package/src/utils/URLPath.ts +5 -5
- package/src/utils/index.ts +0 -2
- package/dist/Queue-2-6pMcCx.d.cts +0 -32
- package/dist/Queue-2-6pMcCx.d.ts +0 -32
- package/src/utils/Queue.ts +0 -110
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkICRPOCV4_cjs = require('./chunk-ICRPOCV4.cjs');
|
|
4
|
+
var chunkMM42A6GN_cjs = require('./chunk-MM42A6GN.cjs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var jsRuntime = require('js-runtime');
|
|
7
|
+
|
|
8
|
+
// src/fs/clean.ts
|
|
9
|
+
chunkMM42A6GN_cjs.init_cjs_shims();
|
|
10
|
+
var import_fs_extra = chunkMM42A6GN_cjs.__toESM(chunkICRPOCV4_cjs.require_lib(), 1);
|
|
11
|
+
async function clean(path) {
|
|
12
|
+
return import_fs_extra.default.remove(path);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/fs/read.ts
|
|
16
|
+
chunkMM42A6GN_cjs.init_cjs_shims();
|
|
17
|
+
var import_fs_extra2 = chunkMM42A6GN_cjs.__toESM(chunkICRPOCV4_cjs.require_lib(), 1);
|
|
18
|
+
function slash(path, platform = "linux") {
|
|
19
|
+
const isWindowsPath = /^\\\\\?\\/.test(path);
|
|
20
|
+
if (["linux", "mac"].includes(platform) && !isWindowsPath) {
|
|
21
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
22
|
+
}
|
|
23
|
+
return path.replaceAll(/\\/g, "/").replace("../", "").trimEnd();
|
|
24
|
+
}
|
|
25
|
+
function getRelativePath(rootDir, filePath, platform = "linux") {
|
|
26
|
+
if (!rootDir || !filePath) {
|
|
27
|
+
throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
|
|
28
|
+
}
|
|
29
|
+
const relativePath = path.relative(rootDir, filePath);
|
|
30
|
+
const slashedPath = slash(relativePath, platform);
|
|
31
|
+
if (slashedPath.startsWith("../")) {
|
|
32
|
+
return slashedPath.replace(path.basename(slashedPath), path.basename(slashedPath, path.extname(filePath)));
|
|
33
|
+
}
|
|
34
|
+
return `./${slashedPath.replace(path.basename(slashedPath), path.basename(slashedPath, path.extname(filePath)))}`;
|
|
35
|
+
}
|
|
36
|
+
var reader = jsRuntime.switcher(
|
|
37
|
+
{
|
|
38
|
+
node: async (path) => {
|
|
39
|
+
return import_fs_extra2.default.readFile(path, { encoding: "utf8" });
|
|
40
|
+
},
|
|
41
|
+
bun: async (path) => {
|
|
42
|
+
const file = Bun.file(path);
|
|
43
|
+
return file.text();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"node"
|
|
47
|
+
);
|
|
48
|
+
var syncReader = jsRuntime.switcher(
|
|
49
|
+
{
|
|
50
|
+
node: (path) => {
|
|
51
|
+
return import_fs_extra2.default.readFileSync(path, { encoding: "utf8" });
|
|
52
|
+
},
|
|
53
|
+
bun: () => {
|
|
54
|
+
throw new Error("Bun cannot read sync");
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"node"
|
|
58
|
+
);
|
|
59
|
+
async function read(path) {
|
|
60
|
+
return reader(path);
|
|
61
|
+
}
|
|
62
|
+
function readSync(path) {
|
|
63
|
+
return syncReader(path);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.clean = clean;
|
|
67
|
+
exports.getRelativePath = getRelativePath;
|
|
68
|
+
exports.read = read;
|
|
69
|
+
exports.readSync = readSync;
|
|
70
|
+
//# sourceMappingURL=out.js.map
|
|
71
|
+
//# sourceMappingURL=chunk-35FDNG5F.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fs/clean.ts","../src/fs/read.ts"],"names":["fs","import_fs_extra"],"mappings":";;;;;;;;;AAAA;AAAA,sBAAe;AAEf,eAAsB,MAAM,MAA6B;AACvD,SAAO,gBAAAA,QAAG,OAAO,IAAI;AACvB;;;ACJA;AAEA,IAAAC,mBAAe;AAFf,SAAS,UAAU,SAAS,gBAAgB;AAI5C,SAAS,gBAAgB;AAEzB,SAAS,MAAM,MAAc,WAAwC,SAAS;AAC5E,QAAM,gBAAgB,YAAY,KAAK,IAAI;AAE3C,MAAI,CAAC,SAAS,KAAK,EAAE,SAAS,QAAQ,KAAK,CAAC,eAAe;AAEzD,WAAO,KAAK,WAAW,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ;AAAA,EAChE;AAGA,SAAO,KAAK,WAAW,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ;AAChE;AAEO,SAAS,gBAAgB,SAAyB,UAA0B,WAAwC,SAAiB;AAC1I,MAAI,CAAC,WAAW,CAAC,UAAU;AACzB,UAAM,IAAI,MAAM,uEAAuE,WAAW,EAAE,IAAI,YAAY,EAAE,EAAE;AAAA,EAC1H;AAEA,QAAM,eAAe,SAAS,SAAS,QAAQ;AAI/C,QAAM,cAAc,MAAM,cAAc,QAAQ;AAEhD,MAAI,YAAY,WAAW,KAAK,GAAG;AACjC,WAAO,YAAY,QAAQ,SAAS,WAAW,GAAG,SAAS,aAAa,QAAQ,QAAQ,CAAC,CAAC;AAAA,EAC5F;AAEA,SAAO,KAAK,YAAY,QAAQ,SAAS,WAAW,GAAG,SAAS,aAAa,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAClG;AAEA,IAAM,SAAS;AAAA,EACb;AAAA,IACE,MAAM,OAAO,SAAiB;AAC5B,aAAO,iBAAAD,QAAG,SAAS,MAAM,EAAE,UAAU,OAAO,CAAC;AAAA,IAC/C;AAAA,IACA,KAAK,OAAO,SAAiB;AAC3B,YAAM,OAAO,IAAI,KAAK,IAAI;AAE1B,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AAAA,EACA;AACF;AAEA,IAAM,aAAa;AAAA,EACjB;AAAA,IACE,MAAM,CAAC,SAAiB;AACtB,aAAO,iBAAAA,QAAG,aAAa,MAAM,EAAE,UAAU,OAAO,CAAC;AAAA,IACnD;AAAA,IACA,KAAK,MAAM;AACT,YAAM,IAAI,MAAM,sBAAsB;AAAA,IACxC;AAAA,EACF;AAAA,EACA;AACF;AAEA,eAAsB,KAAK,MAA+B;AACxD,SAAO,OAAO,IAAI;AACpB;AAEO,SAAS,SAAS,MAAsB;AAC7C,SAAO,WAAW,IAAI;AACxB","sourcesContent":["import fs from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return fs.remove(path)\n}\n","import { basename, extname, relative } from 'node:path'\n\nimport fs from 'fs-extra'\n\nimport { switcher } from 'js-runtime'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n }\n\n // windows\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))\n }\n\n return `./${slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))}`\n}\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\n}\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { init_esm_shims } from './chunk-WTSDXEWD.js';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { switcher } from 'js-runtime';
|
|
6
|
+
|
|
7
|
+
createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// src/fs/write.ts
|
|
10
|
+
init_esm_shims();
|
|
11
|
+
var writer = switcher(
|
|
12
|
+
{
|
|
13
|
+
node: async (path, data, { sanity }) => {
|
|
14
|
+
try {
|
|
15
|
+
const oldContent = await fs.readFile(resolve(path), { encoding: "utf-8" });
|
|
16
|
+
if (oldContent?.toString() === data?.toString()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
} catch (_err) {
|
|
20
|
+
}
|
|
21
|
+
await fs.outputFile(resolve(path), data, { encoding: "utf-8" });
|
|
22
|
+
if (sanity) {
|
|
23
|
+
const savedData = await fs.readFile(resolve(path), { encoding: "utf-8" });
|
|
24
|
+
if (savedData?.toString() !== data?.toString()) {
|
|
25
|
+
throw new Error(`Sanity check failed for ${path}
|
|
26
|
+
|
|
27
|
+
Data[${data.length}]:
|
|
28
|
+
${data}
|
|
29
|
+
|
|
30
|
+
Saved[${savedData.length}]:
|
|
31
|
+
${savedData}
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
return savedData;
|
|
35
|
+
}
|
|
36
|
+
return data;
|
|
37
|
+
},
|
|
38
|
+
bun: async (path, data, { sanity }) => {
|
|
39
|
+
try {
|
|
40
|
+
await Bun.write(resolve(path), data);
|
|
41
|
+
if (sanity) {
|
|
42
|
+
const file = Bun.file(resolve(path));
|
|
43
|
+
const savedData = await file.text();
|
|
44
|
+
if (savedData?.toString() !== data?.toString()) {
|
|
45
|
+
throw new Error(`Sanity check failed for ${path}
|
|
46
|
+
|
|
47
|
+
Data[${data.length}]:
|
|
48
|
+
${data}
|
|
49
|
+
|
|
50
|
+
Saved[${savedData.length}]:
|
|
51
|
+
${savedData}
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
return savedData;
|
|
55
|
+
}
|
|
56
|
+
return data;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.log(e, resolve(path));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"node"
|
|
63
|
+
);
|
|
64
|
+
async function write(data, path, options = {}) {
|
|
65
|
+
if (data.trim() === "") {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
return writer(path, data.trim(), options);
|
|
69
|
+
}
|
|
70
|
+
async function writeLog(data) {
|
|
71
|
+
if (data.trim() === "") {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
const path = resolve(process.cwd(), "kubb-log.log");
|
|
75
|
+
let previousLogs = "";
|
|
76
|
+
try {
|
|
77
|
+
previousLogs = await fs.readFile(resolve(path), { encoding: "utf-8" });
|
|
78
|
+
} catch (_err) {
|
|
79
|
+
}
|
|
80
|
+
return writer(path, [previousLogs, data.trim()].filter(Boolean).join("\n\n\n"), { sanity: false });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { write, writeLog };
|
|
84
|
+
//# sourceMappingURL=out.js.map
|
|
85
|
+
//# sourceMappingURL=chunk-7CNPSL5M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fs/write.ts"],"names":[],"mappings":";;;;;;;;;AAAA;AAAA,SAAS,eAAe;AAExB,OAAO,QAAQ;AACf,SAAS,gBAAgB;AAIzB,IAAM,SAAS;AAAA,EACb;AAAA,IACE,MAAM,OAAO,MAAc,MAAc,EAAE,OAAO,MAAe;AAC/D,UAAI;AACF,cAAM,aAAa,MAAM,GAAG,SAAS,QAAQ,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AACzE,YAAI,YAAY,SAAS,MAAM,MAAM,SAAS,GAAG;AAC/C;AAAA,QACF;AAAA,MACF,SAAS,MAAM;AAAA,MAEf;AAEA,YAAM,GAAG,WAAW,QAAQ,IAAI,GAAG,MAAM,EAAE,UAAU,QAAQ,CAAC;AAE9D,UAAI,QAAQ;AACV,cAAM,YAAY,MAAM,GAAG,SAAS,QAAQ,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AAExE,YAAI,WAAW,SAAS,MAAM,MAAM,SAAS,GAAG;AAC9C,gBAAM,IAAI,MAAM,2BAA2B,IAAI;AAAA;AAAA,OAAY,KAAK,MAAM;AAAA,EAAO,IAAI;AAAA;AAAA,QAAa,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AAQ,MAAM,CAAC;AACnG","sourcesContent":["import { resolve } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\ntype Options = { sanity?: boolean }\n\nconst writer = switcher(\n {\n node: async (path: string, data: string, { sanity }: Options) => {\n try {\n const oldContent = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })\n\n if (sanity) {\n const savedData = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n },\n bun: async (path: string, data: string, { sanity }: Options) => {\n try {\n await Bun.write(resolve(path), data)\n\n if (sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n } catch (e) {\n console.log(e, resolve(path))\n }\n },\n },\n 'node',\n)\n\nexport async function write(data: string, path: string, options: Options = {}): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim(), options)\n}\n\nexport async function writeLog(data: string): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n const path = resolve(process.cwd(), 'kubb-log.log')\n let previousLogs = ''\n\n try {\n previousLogs = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n } catch (_err) {\n /* empty */\n }\n\n return writer(path, [previousLogs, data.trim()].filter(Boolean).join('\\n\\n\\n'), { sanity: false })\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { init_esm_shims } from './chunk-WTSDXEWD.js';
|
|
3
|
+
import { camelCase as camelCase$1, pascalCase as pascalCase$1 } from 'change-case';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
// src/transformers/casing.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
function camelCase(text) {
|
|
10
|
+
return camelCase$1(text, { delimiter: "", mergeAmbiguousCharacters: true });
|
|
11
|
+
}
|
|
12
|
+
function pascalCase(text) {
|
|
13
|
+
return pascalCase$1(text, { delimiter: "", mergeAmbiguousCharacters: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { camelCase, pascalCase };
|
|
17
|
+
//# sourceMappingURL=out.js.map
|
|
18
|
+
//# sourceMappingURL=chunk-DKYWBKNH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transformers/casing.ts"],"names":[],"mappings":";;;;;;;;;AAAA;AAAA,SAAS,aAAa,iBAAiB,cAAc,wBAAwB;AAEtE,SAAS,UAAU,MAAsB;AAC9C,SAAO,gBAAgB,MAAM,EAAE,WAAW,IAAI,0BAA0B,KAAK,CAAC;AAChF;AAEO,SAAS,WAAW,MAAsB;AAC/C,SAAO,iBAAiB,MAAM,EAAE,WAAW,IAAI,0BAA0B,KAAK,CAAC;AACjF","sourcesContent":["import { camelCase as changeCaseCamel, pascalCase as changePascalCase } from 'change-case'\n\nexport function camelCase(text: string): string {\n return changeCaseCamel(text, { delimiter: '', mergeAmbiguousCharacters: true })\n}\n\nexport function pascalCase(text: string): string {\n return changePascalCase(text, { delimiter: '', mergeAmbiguousCharacters: true })\n}\n"]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { camelCase } from './chunk-DKYWBKNH.js';
|
|
3
|
+
import { init_esm_shims } from './chunk-WTSDXEWD.js';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
// src/utils/URLPath.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var URLPath = class {
|
|
10
|
+
constructor(path) {
|
|
11
|
+
this.path = path;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
16
|
+
* @example /pet/{petId} => /pet/:petId
|
|
17
|
+
*/
|
|
18
|
+
get URL() {
|
|
19
|
+
return this.toURLPath();
|
|
20
|
+
}
|
|
21
|
+
get isURL() {
|
|
22
|
+
try {
|
|
23
|
+
const url = new URL(this.path);
|
|
24
|
+
if (url?.href) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
34
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
35
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
36
|
+
* @example /account/userID => `/account/${userId}`
|
|
37
|
+
*/
|
|
38
|
+
get template() {
|
|
39
|
+
return this.toTemplateString();
|
|
40
|
+
}
|
|
41
|
+
get object() {
|
|
42
|
+
return this.toObject();
|
|
43
|
+
}
|
|
44
|
+
get params() {
|
|
45
|
+
return this.getParams();
|
|
46
|
+
}
|
|
47
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
48
|
+
const object = {
|
|
49
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString(replacer),
|
|
50
|
+
params: this.getParams()
|
|
51
|
+
};
|
|
52
|
+
if (stringify) {
|
|
53
|
+
if (type === "template") {
|
|
54
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
55
|
+
}
|
|
56
|
+
if (object.params) {
|
|
57
|
+
return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
58
|
+
}
|
|
59
|
+
return `{ url: '${object.url}' }`;
|
|
60
|
+
}
|
|
61
|
+
return object;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
65
|
+
* @example /pet/{petId} => `/pet/${petId}`
|
|
66
|
+
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
67
|
+
* @example /account/userID => `/account/${userId}`
|
|
68
|
+
*/
|
|
69
|
+
toTemplateString(replacer) {
|
|
70
|
+
const regex = /{(\w|-)*}/g;
|
|
71
|
+
const found = this.path.match(regex);
|
|
72
|
+
let newPath = this.path.replaceAll("{", "${");
|
|
73
|
+
if (found) {
|
|
74
|
+
newPath = found.reduce((prev, curr) => {
|
|
75
|
+
const pathParam = replacer ? replacer(camelCase(curr)) : camelCase(curr);
|
|
76
|
+
const replacement = `\${${pathParam}}`;
|
|
77
|
+
return prev.replace(curr, replacement);
|
|
78
|
+
}, this.path);
|
|
79
|
+
}
|
|
80
|
+
return `\`${newPath}\``;
|
|
81
|
+
}
|
|
82
|
+
getParams(replacer) {
|
|
83
|
+
const regex = /{(\w|-)*}/g;
|
|
84
|
+
const found = this.path.match(regex);
|
|
85
|
+
if (!found) {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
const params = {};
|
|
89
|
+
found.forEach((item) => {
|
|
90
|
+
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
91
|
+
const pathParam = replacer ? replacer(camelCase(item)) : camelCase(item);
|
|
92
|
+
params[pathParam] = pathParam;
|
|
93
|
+
}, this.path);
|
|
94
|
+
return params;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Convert Swagger path to URLPath(syntax of Express)
|
|
98
|
+
* @example /pet/{petId} => /pet/:petId
|
|
99
|
+
*/
|
|
100
|
+
toURLPath() {
|
|
101
|
+
return this.path.replaceAll("{", ":").replaceAll("}", "");
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/utils/uniqueName.ts
|
|
106
|
+
init_esm_shims();
|
|
107
|
+
function getUniqueName(originalName, data) {
|
|
108
|
+
let used = data[originalName] || 0;
|
|
109
|
+
if (used) {
|
|
110
|
+
data[originalName] = ++used;
|
|
111
|
+
originalName += used;
|
|
112
|
+
}
|
|
113
|
+
data[originalName] = 1;
|
|
114
|
+
return originalName;
|
|
115
|
+
}
|
|
116
|
+
function setUniqueName(originalName, data) {
|
|
117
|
+
let used = data[originalName] || 0;
|
|
118
|
+
if (used) {
|
|
119
|
+
data[originalName] = ++used;
|
|
120
|
+
return originalName;
|
|
121
|
+
}
|
|
122
|
+
data[originalName] = 1;
|
|
123
|
+
return originalName;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { URLPath, getUniqueName, setUniqueName };
|
|
127
|
+
//# sourceMappingURL=out.js.map
|
|
128
|
+
//# sourceMappingURL=chunk-EZSRGYAY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/URLPath.ts","../src/utils/uniqueName.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAaO,IAAM,UAAN,MAAc;AAAA,EAGnB,YAAY,MAAc;AACxB,SAAK,OAAO;AAEZ,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,MAAc;AAChB,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EACA,IAAI,QAAiB;AACnB,QAAI;AACF,YAAM,MAAM,IAAI,IAAI,KAAK,IAAI;AAC7B,UAAI,KAAK,MAAM;AACb,eAAO;AAAA,MACT;AAAA,IACF,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,WAAmB;AACrB,WAAO,KAAK,iBAAiB;AAAA,EAC/B;AAAA,EACA,IAAI,SAA6B;AAC/B,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EACA,IAAI,SAA6C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O,KAAK,WAAW,KAAK,EAAE,EAAE,WAAW,KAAK,EAAE;AAElD,YAAM,YAAY,WACd,SAAS,UAAU,IAAI,CAAC,IACxB,UAAU,IAAI;AAElB,aAAO,SAAS,IAAI;AAAA,IACtB,GAAG,KAAK,IAAI;AAEZ,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAoB;AAClB,WAAO,KAAK,KAAK,WAAW,KAAK,GAAG,EAAE,WAAW,KAAK,EAAE;AAAA,EAC1D;AACF;;;ACpIA;AAAO,SAAS,cAAc,cAAsB,MAAsC;AACxF,MAAI,OAAO,KAAK,YAAY,KAAK;AACjC,MAAI,MAAM;AACR,SAAK,YAAY,IAAI,EAAE;AACvB,oBAAgB;AAAA,EAClB;AACA,OAAK,YAAY,IAAI;AACrB,SAAO;AACT;AAEO,SAAS,cAAc,cAAsB,MAAsC;AACxF,MAAI,OAAO,KAAK,YAAY,KAAK;AACjC,MAAI,MAAM;AACR,SAAK,YAAY,IAAI,EAAE;AAEvB,WAAO;AAAA,EACT;AACA,OAAK,YAAY,IAAI;AACrB,SAAO;AACT","sourcesContent":["import { camelCase } from '../transformers/casing.ts'\n\nexport type URLObject = {\n url: string\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n type?: 'path' | 'template'\n replacer?: (pathParam: string) => string\n stringify?: boolean\n}\n\nexport class URLPath {\n path: string\n\n constructor(path: string) {\n this.path = path\n\n return this\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n get URL(): string {\n return this.toURLPath()\n }\n get isURL(): boolean {\n try {\n const url = new URL(this.path)\n if (url?.href) {\n return true\n }\n } catch (error) {\n return false\n }\n return false\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n get template(): string {\n return this.toTemplateString()\n }\n get object(): URLObject | string {\n return this.toObject()\n }\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString(replacer),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n toTemplateString(replacer?: (pathParam: string) => string): string {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n let newPath = this.path.replaceAll('{', '${')\n\n if (found) {\n newPath = found.reduce((prev, curr) => {\n const pathParam = replacer\n ? replacer(camelCase(curr))\n : camelCase(curr)\n const replacement = `\\${${pathParam}}`\n\n return prev.replace(curr, replacement)\n }, this.path)\n }\n\n return `\\`${newPath}\\``\n }\n\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n\n if (!found) {\n return undefined\n }\n\n const params: Record<string, string> = {}\n found.forEach((item) => {\n item = item.replaceAll('{', '').replaceAll('}', '')\n\n const pathParam = replacer\n ? replacer(camelCase(item))\n : camelCase(item)\n\n params[pathParam] = pathParam\n }, this.path)\n\n return params\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n toURLPath(): string {\n return this.path.replaceAll('{', ':').replaceAll('}', '')\n }\n}\n","export function getUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n originalName += used\n }\n data[originalName] = 1\n return originalName\n}\n\nexport function setUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n\n return originalName\n }\n data[originalName] = 1\n return originalName\n}\n"]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkICRPOCV4_cjs = require('./chunk-ICRPOCV4.cjs');
|
|
4
|
+
var chunkMM42A6GN_cjs = require('./chunk-MM42A6GN.cjs');
|
|
5
|
+
var seedrandom = require('seedrandom');
|
|
6
|
+
var tty = require('tty');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var seedrandom__default = /*#__PURE__*/_interopDefault(seedrandom);
|
|
11
|
+
|
|
12
|
+
// src/logger.ts
|
|
13
|
+
chunkMM42A6GN_cjs.init_cjs_shims();
|
|
14
|
+
|
|
15
|
+
// ../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/node.js
|
|
16
|
+
chunkMM42A6GN_cjs.init_cjs_shims();
|
|
17
|
+
|
|
18
|
+
// ../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/chunk-5WCZOS7T.js
|
|
19
|
+
chunkMM42A6GN_cjs.init_cjs_shims();
|
|
20
|
+
var b = {
|
|
21
|
+
reset: [0, 0],
|
|
22
|
+
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
23
|
+
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
24
|
+
italic: [3, 23],
|
|
25
|
+
underline: [4, 24],
|
|
26
|
+
inverse: [7, 27],
|
|
27
|
+
hidden: [8, 28],
|
|
28
|
+
strikethrough: [9, 29],
|
|
29
|
+
black: [30, 39],
|
|
30
|
+
red: [31, 39],
|
|
31
|
+
green: [32, 39],
|
|
32
|
+
yellow: [33, 39],
|
|
33
|
+
blue: [34, 39],
|
|
34
|
+
magenta: [35, 39],
|
|
35
|
+
cyan: [36, 39],
|
|
36
|
+
white: [37, 39],
|
|
37
|
+
gray: [90, 39],
|
|
38
|
+
bgBlack: [40, 49],
|
|
39
|
+
bgRed: [41, 49],
|
|
40
|
+
bgGreen: [42, 49],
|
|
41
|
+
bgYellow: [43, 49],
|
|
42
|
+
bgBlue: [44, 49],
|
|
43
|
+
bgMagenta: [45, 49],
|
|
44
|
+
bgCyan: [46, 49],
|
|
45
|
+
bgWhite: [47, 49]
|
|
46
|
+
};
|
|
47
|
+
var C = Object.entries(b);
|
|
48
|
+
function d(r2) {
|
|
49
|
+
return String(r2);
|
|
50
|
+
}
|
|
51
|
+
d.open = "";
|
|
52
|
+
d.close = "";
|
|
53
|
+
function p(r2 = false) {
|
|
54
|
+
let n = typeof process != "undefined" ? process : void 0, t = (n == null ? void 0 : n.env) || {}, a = (n == null ? void 0 : n.argv) || [];
|
|
55
|
+
return !("NO_COLOR" in t || a.includes("--no-color")) && !("GITHUB_ACTIONS" in t) && ("FORCE_COLOR" in t || a.includes("--color") || (n == null ? void 0 : n.platform) === "win32" || r2 && t.TERM !== "dumb" || "CI" in t) || typeof window != "undefined" && !!window.chrome;
|
|
56
|
+
}
|
|
57
|
+
function w(r2 = false) {
|
|
58
|
+
let n = p(r2), t = (e, o, c, i) => {
|
|
59
|
+
let u = e.substring(0, i) + c, s = e.substring(i + o.length), l = s.indexOf(o);
|
|
60
|
+
return ~l ? u + t(s, o, c, l) : u + s;
|
|
61
|
+
}, a = (e, o, c = e) => {
|
|
62
|
+
let i = (u) => {
|
|
63
|
+
let s = String(u), l = s.indexOf(o, e.length);
|
|
64
|
+
return ~l ? e + t(s, o, c, l) + o : e + s + o;
|
|
65
|
+
};
|
|
66
|
+
return i.open = e, i.close = o, i;
|
|
67
|
+
}, g = {
|
|
68
|
+
isColorSupported: n
|
|
69
|
+
}, f = (e) => `\x1B[${e}m`;
|
|
70
|
+
for (let [e, o] of C)
|
|
71
|
+
g[e] = n ? a(
|
|
72
|
+
f(o[0]),
|
|
73
|
+
f(o[1]),
|
|
74
|
+
o[2]
|
|
75
|
+
) : d;
|
|
76
|
+
return g;
|
|
77
|
+
}
|
|
78
|
+
var p2 = w(tty.isatty(1));
|
|
79
|
+
|
|
80
|
+
// src/logger.ts
|
|
81
|
+
var LogLevel = {
|
|
82
|
+
silent: "silent",
|
|
83
|
+
info: "info",
|
|
84
|
+
debug: "debug"
|
|
85
|
+
};
|
|
86
|
+
function createLogger({ logLevel, name, spinner }) {
|
|
87
|
+
const logs = [];
|
|
88
|
+
const log = (message) => {
|
|
89
|
+
if (message && spinner) {
|
|
90
|
+
spinner.text = message;
|
|
91
|
+
logs.push(message);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const error = (message) => {
|
|
95
|
+
if (message) {
|
|
96
|
+
throw new Error(message || "Something went wrong");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const warn = (message) => {
|
|
100
|
+
if (message && spinner) {
|
|
101
|
+
spinner.warn(p2.yellow(message));
|
|
102
|
+
logs.push(message);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const info = (message) => {
|
|
106
|
+
if (message && spinner && logLevel !== LogLevel.silent) {
|
|
107
|
+
spinner.info(message);
|
|
108
|
+
logs.push(message);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const debug = async (message) => {
|
|
112
|
+
if (message) {
|
|
113
|
+
await chunkICRPOCV4_cjs.writeLog(message);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const logger = {
|
|
117
|
+
name,
|
|
118
|
+
logLevel,
|
|
119
|
+
log,
|
|
120
|
+
error,
|
|
121
|
+
warn,
|
|
122
|
+
info,
|
|
123
|
+
debug,
|
|
124
|
+
spinner,
|
|
125
|
+
logs
|
|
126
|
+
};
|
|
127
|
+
return logger;
|
|
128
|
+
}
|
|
129
|
+
var defaultColours = ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
130
|
+
function randomColour(text, colours = defaultColours) {
|
|
131
|
+
if (!text) {
|
|
132
|
+
return "white";
|
|
133
|
+
}
|
|
134
|
+
const random = seedrandom__default.default(text);
|
|
135
|
+
const colour = colours.at(Math.floor(random() * colours.length)) || "white";
|
|
136
|
+
return colour;
|
|
137
|
+
}
|
|
138
|
+
function randomCliColour(text, colors = defaultColours) {
|
|
139
|
+
const colours = w(true);
|
|
140
|
+
if (!text) {
|
|
141
|
+
return colours.white(text);
|
|
142
|
+
}
|
|
143
|
+
const colour = randomColour(text, colors);
|
|
144
|
+
const isDark = colour.includes("dark");
|
|
145
|
+
const key = colour.replace("dark", "").toLowerCase();
|
|
146
|
+
const formatter = colours[key];
|
|
147
|
+
if (isDark) {
|
|
148
|
+
return p2.bold(formatter(text));
|
|
149
|
+
}
|
|
150
|
+
if (typeof formatter !== "function") {
|
|
151
|
+
throw new Error("Formatter for picoColor is not of type function/Formatter");
|
|
152
|
+
}
|
|
153
|
+
return formatter(text);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.LogLevel = LogLevel;
|
|
157
|
+
exports.createLogger = createLogger;
|
|
158
|
+
exports.p = p2;
|
|
159
|
+
exports.randomCliColour = randomCliColour;
|
|
160
|
+
exports.randomColour = randomColour;
|
|
161
|
+
//# sourceMappingURL=out.js.map
|
|
162
|
+
//# sourceMappingURL=chunk-GBX7KRCX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logger.ts","../../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/node.js","../../../node_modules/.pnpm/tinyrainbow@1.1.1/node_modules/tinyrainbow/dist/chunk-5WCZOS7T.js"],"names":["r","p"],"mappings":";;;;;;;;AAAA;AAAA,OAAO,gBAAgB;;;ACAvB;;;ACAA;AACA,IAAI,IAAI;AAAA,EACN,OAAO,CAAC,GAAG,CAAC;AAAA,EACZ,MAAM,CAAC,GAAG,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Q,MAAM,IAAI;AAAA,EAC3B;AAEA,QAAM,SAAS,aAAa,MAAM,MAAM;AACxC,QAAM,SAAS,OAAO,SAAS,MAAM;AACrC,QAAM,MAAM,OAAO,QAAQ,QAAQ,EAAE,EAAE,YAAY;AACnD,QAAM,YAAuB,QAAQ,GAAG;AAExC,MAAI,QAAQ;AACV,WAAOA,GAAE,KAAK,UAAU,IAAI,CAAC;AAAA,EAC/B;AAEA,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,SAAO,UAAU,IAAI;AACvB","sourcesContent":["import seedrandom from 'seedrandom'\nimport c, { createColors } from 'tinyrainbow'\n\nimport { writeLog } from './fs/write.ts'\n\nimport type { Ora } from 'ora'\nimport type { Formatter } from 'tinyrainbow'\n\nexport const LogLevel = {\n silent: 'silent',\n info: 'info',\n debug: 'debug',\n} as const\n\nexport type LogLevel = keyof typeof LogLevel\n\nexport type Logger = {\n /**\n * Optional config name to show in CLI output\n */\n name?: string\n logLevel: LogLevel\n log: (message: string | null) => void\n error: (message: string | null) => void\n info: (message: string | null) => void\n warn: (message: string | null) => void\n debug: (message: string | null) => Promise<void>\n spinner?: Ora\n logs: string[]\n}\n\ntype Props = {\n name?: string\n logLevel: LogLevel\n spinner?: Ora\n}\n\nexport function createLogger({ logLevel, name, spinner }: Props): Logger {\n const logs: string[] = []\n const log: Logger['log'] = (message) => {\n if (message && spinner) {\n spinner.text = message\n logs.push(message)\n }\n }\n\n const error: Logger['error'] = (message) => {\n if (message) {\n throw new Error(message || 'Something went wrong')\n }\n }\n\n const warn: Logger['warn'] = (message) => {\n if (message && spinner) {\n spinner.warn(c.yellow(message))\n logs.push(message)\n }\n }\n\n const info: Logger['warn'] = (message) => {\n if (message && spinner && logLevel !== LogLevel.silent) {\n spinner.info(message)\n logs.push(message)\n }\n }\n\n const debug: Logger['debug'] = async (message) => {\n if (message) {\n await writeLog(message)\n }\n }\n\n const logger: Logger = {\n name,\n logLevel,\n log,\n error,\n warn,\n info,\n debug,\n spinner,\n logs,\n }\n\n return logger\n}\n\nconst defaultColours = ['black', 'blue', 'darkBlue', 'cyan', 'gray', 'green', 'darkGreen', 'magenta', 'red', 'darkRed', 'yellow', 'darkYellow'] as const\n\nexport function randomColour(text?: string, colours = defaultColours): string {\n if (!text) {\n return 'white'\n }\n\n const random = seedrandom(text)\n const colour = colours.at(Math.floor(random() * colours.length)) || 'white'\n\n return colour\n}\n\nexport function randomCliColour(text?: string, colors = defaultColours): string {\n const colours = createColors(true)\n\n if (!text) {\n return colours.white(text)\n }\n\n const colour = randomColour(text, colors)\n const isDark = colour.includes('dark')\n const key = colour.replace('dark', '').toLowerCase() as keyof typeof colours\n const formatter: Formatter = colours[key] as Formatter\n\n if (isDark) {\n return c.bold(formatter(text))\n }\n\n if (typeof formatter !== 'function') {\n throw new Error('Formatter for picoColor is not of type function/Formatter')\n }\n return formatter(text)\n}\n","import {\n a as t,\n b as e,\n c as o\n} from \"./chunk-5WCZOS7T.js\";\n\n// src/node.ts\nimport { isatty as r } from \"tty\";\nvar p = o(r(1));\nexport {\n o as createColors,\n p as default,\n t as getDefaultColors,\n e as isSupported\n};\n","// src/index.ts\nvar b = {\n reset: [0, 0],\n bold: [1, 22, \"\\x1B[22m\\x1B[1m\"],\n dim: [2, 22, \"\\x1B[22m\\x1B[2m\"],\n italic: [3, 23],\n underline: [4, 24],\n inverse: [7, 27],\n hidden: [8, 28],\n strikethrough: [9, 29],\n black: [30, 39],\n red: [31, 39],\n green: [32, 39],\n yellow: [33, 39],\n blue: [34, 39],\n magenta: [35, 39],\n cyan: [36, 39],\n white: [37, 39],\n gray: [90, 39],\n bgBlack: [40, 49],\n bgRed: [41, 49],\n bgGreen: [42, 49],\n bgYellow: [43, 49],\n bgBlue: [44, 49],\n bgMagenta: [45, 49],\n bgCyan: [46, 49],\n bgWhite: [47, 49]\n}, C = Object.entries(b);\nfunction d(r) {\n return String(r);\n}\nd.open = \"\";\nd.close = \"\";\nvar m = /* @__PURE__ */ C.reduce(\n (r, [n]) => (r[n] = d, r),\n { isColorSupported: !1 }\n);\nfunction x() {\n return { ...m };\n}\nfunction p(r = !1) {\n let n = typeof process != \"undefined\" ? process : void 0, t = (n == null ? void 0 : n.env) || {}, a = (n == null ? void 0 : n.argv) || [];\n return !(\"NO_COLOR\" in t || a.includes(\"--no-color\")) && !(\"GITHUB_ACTIONS\" in t) && (\"FORCE_COLOR\" in t || a.includes(\"--color\") || (n == null ? void 0 : n.platform) === \"win32\" || r && t.TERM !== \"dumb\" || \"CI\" in t) || typeof window != \"undefined\" && !!window.chrome;\n}\nfunction w(r = !1) {\n let n = p(r), t = (e, o, c, i) => {\n let u = e.substring(0, i) + c, s = e.substring(i + o.length), l = s.indexOf(o);\n return ~l ? u + t(s, o, c, l) : u + s;\n }, a = (e, o, c = e) => {\n let i = (u) => {\n let s = String(u), l = s.indexOf(o, e.length);\n return ~l ? e + t(s, o, c, l) + o : e + s + o;\n };\n return i.open = e, i.close = o, i;\n }, g = {\n isColorSupported: n\n }, f = (e) => `\\x1B[${e}m`;\n for (let [e, o] of C)\n g[e] = n ? a(\n f(o[0]),\n f(o[1]),\n o[2]\n ) : d;\n return g;\n}\n\nexport {\n x as a,\n p as b,\n w as c\n};\n"]}
|