@h3ravel/console 11.0.7 → 11.1.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/bin/fire.cjs +2 -0
- package/bin/fire.js +2 -0
- package/dist/Utils-7OrjoB1C.d.cts +22 -0
- package/dist/Utils-B1kpj9-1.cjs +130 -0
- package/dist/Utils-B1kpj9-1.cjs.map +1 -0
- package/dist/Utils-DAJvoXlr.js +86 -0
- package/dist/Utils-DAJvoXlr.js.map +1 -0
- package/dist/Utils-DxnHOGMz.d.ts +22 -0
- package/dist/Utils.cjs +3 -217
- package/dist/Utils.d.cts +2 -0
- package/dist/Utils.d.ts +2 -0
- package/dist/Utils.js +3 -9
- package/dist/index.cjs +885 -933
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +270 -290
- package/dist/index.d.ts +270 -290
- package/dist/index.js +899 -44
- package/dist/index.js.map +1 -0
- package/package.json +35 -23
- package/bin/chunk-6Z5DP356.js +0 -1
- package/bin/lexer-DQCqS3nf-XQPNMZG6.js +0 -4
- package/bin/run.cjs +0 -26
- package/bin/run.js +0 -26
- package/dist/Commands/Command.cjs +0 -104
- package/dist/Commands/Command.js +0 -7
- package/dist/Commands/MakeCommand.cjs +0 -433
- package/dist/Commands/MakeCommand.js +0 -9
- package/dist/Commands/MigrateCommand.cjs +0 -200
- package/dist/Commands/MigrateCommand.js +0 -8
- package/dist/Commands/ServeCommand.cjs +0 -159
- package/dist/Commands/ServeCommand.js +0 -8
- package/dist/Contracts/ICommand.cjs +0 -18
- package/dist/Contracts/ICommand.js +0 -1
- package/dist/IO/app.cjs +0 -946
- package/dist/IO/app.js +0 -17
- package/dist/IO/providers.cjs +0 -930
- package/dist/IO/providers.js +0 -16
- package/dist/Kernel.cjs +0 -890
- package/dist/Kernel.js +0 -14
- package/dist/Musket.cjs +0 -835
- package/dist/Musket.js +0 -13
- package/dist/Providers/ConsoleServiceProvider.cjs +0 -912
- package/dist/Providers/ConsoleServiceProvider.js +0 -15
- package/dist/Signature.cjs +0 -172
- package/dist/Signature.js +0 -7
- package/dist/chunk-23QH5R54.js +0 -27
- package/dist/chunk-2O2AYFAG.js +0 -63
- package/dist/chunk-3ASEWMRX.js +0 -37
- package/dist/chunk-3FVPHQCH.js +0 -151
- package/dist/chunk-3RX6CLNR.js +0 -32
- package/dist/chunk-3VCNSA6P.js +0 -14
- package/dist/chunk-3WHUADTN.js +0 -6
- package/dist/chunk-6OCHCPBP.js +0 -36
- package/dist/chunk-6OIH6FS4.js +0 -32
- package/dist/chunk-7EWRZPTX.js +0 -63
- package/dist/chunk-7PUQ5ZIN.js +0 -6
- package/dist/chunk-A5AONVOH.js +0 -6
- package/dist/chunk-ADIVRUAJ.js +0 -27
- package/dist/chunk-CCEWV2BR.js +0 -39
- package/dist/chunk-CTQ6DUT2.js +0 -8
- package/dist/chunk-DXQTBFGG.js +0 -31
- package/dist/chunk-E4SSLXFT.js +0 -63
- package/dist/chunk-E5XIGIEX.js +0 -14
- package/dist/chunk-EIOQKTRM.js +0 -104
- package/dist/chunk-FOSDCKCR.js +0 -106
- package/dist/chunk-G4OE26TZ.js +0 -33
- package/dist/chunk-GVGO5OAK.js +0 -8
- package/dist/chunk-GXRCTWKL.js +0 -16
- package/dist/chunk-HVKW7JK4.js +0 -8
- package/dist/chunk-IGEFNODG.js +0 -22
- package/dist/chunk-JXL4VJHZ.js +0 -36
- package/dist/chunk-K3GOQSS3.js +0 -6
- package/dist/chunk-KCJKQP37.js +0 -133
- package/dist/chunk-KMIFCLXG.js +0 -16
- package/dist/chunk-KZA3MC77.js +0 -151
- package/dist/chunk-LLL3V7LB.js +0 -6
- package/dist/chunk-LQ6DL2HS.js +0 -68
- package/dist/chunk-M4ZRDJJ2.js +0 -68
- package/dist/chunk-MAQAT3PU.js +0 -32
- package/dist/chunk-MPXPSSLJ.js +0 -133
- package/dist/chunk-NADN2PHB.js +0 -0
- package/dist/chunk-NFRXMBRP.js +0 -24
- package/dist/chunk-NVPKTRMT.js +0 -7
- package/dist/chunk-O45AB4MX.js +0 -83
- package/dist/chunk-ORPRWIQ2.js +0 -33
- package/dist/chunk-P7M5PEDY.js +0 -18
- package/dist/chunk-PBNCVQZC.js +0 -6
- package/dist/chunk-PMV4TMFS.js +0 -151
- package/dist/chunk-POF4JGTX.js +0 -186
- package/dist/chunk-PYSJMSNM.js +0 -27
- package/dist/chunk-Q3OMG6YH.js +0 -186
- package/dist/chunk-QCNBVSFO.js +0 -68
- package/dist/chunk-QMEO4OUR.js +0 -151
- package/dist/chunk-QSQNELZQ.js +0 -83
- package/dist/chunk-RRP7K5LI.js +0 -36
- package/dist/chunk-SHUYVCID.js +0 -6
- package/dist/chunk-SP4JKAUC.js +0 -63
- package/dist/chunk-T6OOKENF.js +0 -6
- package/dist/chunk-TBDROT3I.js +0 -6356
- package/dist/chunk-TH2RWMWA.js +0 -133
- package/dist/chunk-TJZCDDEV.js +0 -36
- package/dist/chunk-TN5SV7LF.js +0 -133
- package/dist/chunk-U6TOLKGJ.js +0 -22
- package/dist/chunk-UCOXL3OM.js +0 -0
- package/dist/chunk-URLTFJET.js +0 -68
- package/dist/chunk-UWCTG2LX.js +0 -24
- package/dist/chunk-WO2BXMBQ.js +0 -6
- package/dist/chunk-XAWZUZVP.js +0 -32
- package/dist/chunk-XCOSZXAE.js +0 -133
- package/dist/chunk-XD2Q7LWE.js +0 -24
- package/dist/chunk-XSL373TG.js +0 -36
- package/dist/chunk-XUYTJO6X.js +0 -104
- package/dist/chunk-YAYU7VOK.js +0 -8
- package/dist/chunk-YRUCICBV.js +0 -24
- package/dist/chunk-Z5XE72Q5.js +0 -68
- package/dist/chunk-ZTIO25VB.js +0 -8
- package/dist/lexer-DQCqS3nf-6W2BHF4T.js +0 -68
- package/dist/run.cjs +0 -943
- package/dist/run.js +0 -14
package/bin/fire.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));require(`tsx/esm`);let c=require(`@h3ravel/core`);c=s(c);let l=require(`@h3ravel/console`);l=s(l);let u=require(`execa`);u=s(u);let d=require(`node:fs/promises`);d=s(d);let f=require(`node:path`);f=s(f);let p=require(`preferred-pm`);p=s(p);let m=require(`@h3ravel/http`);m=s(m);let h=require(`@h3ravel/router`);h=s(h);let g=require(`@h3ravel/database`);g=s(g);let _=require(`@h3ravel/cache`);_=s(_);let v=require(`@h3ravel/queue`);v=s(v);let y=require(`@h3ravel/mail`);y=s(y);let b=require(`@h3ravel/config`);b=s(b);var x=[m.HttpServiceProvider,b.ConfigServiceProvider,h.RouteServiceProvider,h.AssetsServiceProvider,g.DatabaseServiceProvider,_.CacheServiceProvider,v.QueueServiceProvider,y.MailServiceProvider],S=class{async fire(){let e=(await(0,p.default)(process.cwd()))?.name??`pnpm`;await(0,u.execa)(e,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`],{stdout:`inherit`,stderr:`inherit`,env:Object.assign({},process.env,{EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`development`})});let t=new c.Application(process.cwd()),n=app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`);for await(let e of(0,d.glob)(n)){let t=f.default.basename(e).replace(`.js`,``);try{x.push((await import(e))[t])}catch{}}x.push(l.ConsoleServiceProvider),t.registerProviders(x),await t.registerConfiguredProviders(),await t.boot()}};new S().fire();
|
package/bin/fire.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import"tsx/esm";import{Application as e}from"@h3ravel/core";import{ConsoleServiceProvider as t}from"@h3ravel/console";import{execa as n}from"execa";import{glob as r}from"node:fs/promises";import i from"node:path";import a from"preferred-pm";import{HttpServiceProvider as o}from"@h3ravel/http";import{AssetsServiceProvider as s,RouteServiceProvider as c}from"@h3ravel/router";import{DatabaseServiceProvider as l}from"@h3ravel/database";import{CacheServiceProvider as u}from"@h3ravel/cache";import{QueueServiceProvider as d}from"@h3ravel/queue";import{MailServiceProvider as f}from"@h3ravel/mail";import{ConfigServiceProvider as p}from"@h3ravel/config";var m=[o,p,c,s,l,u,d,f];new class{async fire(){let o=(await(a(process.cwd())))?.name??`pnpm`;await n(o,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`],{stdout:`inherit`,stderr:`inherit`,env:Object.assign({},process.env,{EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`development`})});let s=new e(process.cwd()),c=(app_path(`Providers/*.js`).replace(`/src/`,`/.h3ravel/serve/`));for await(let e of r(c)){let t=(i.basename(e).replace(`.js`,``));try{m.push((await import(e))[t])}catch{}}m.push(t),s.registerProviders(m),await s.registerConfiguredProviders(),await s.boot()}}().fire();export{};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/Utils.d.ts
|
|
2
|
+
declare class Utils {
|
|
3
|
+
static findModulePkg(moduleId: string, cwd?: string): string | undefined;
|
|
4
|
+
static getMigrationPaths(cwd: string, migrator: any, defaultPath: string, path: string): Promise<any[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Check if file exists
|
|
7
|
+
*
|
|
8
|
+
* @param path
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
static fileExists(path: string): Promise<boolean>;
|
|
12
|
+
static findUpConfig(cwd: string, name: string, extensions: string[]): string | void;
|
|
13
|
+
static installCommand(pkg: string): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
declare class TableGuesser {
|
|
16
|
+
static CREATE_PATTERNS: RegExp[];
|
|
17
|
+
static CHANGE_PATTERNS: RegExp[];
|
|
18
|
+
static guess(migration: string): (string | boolean)[];
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { TableGuesser, Utils };
|
|
22
|
+
//# sourceMappingURL=Utils-7OrjoB1C.d.cts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let fs_promises = require("fs/promises");
|
|
25
|
+
fs_promises = __toESM(fs_promises);
|
|
26
|
+
let path = require("path");
|
|
27
|
+
path = __toESM(path);
|
|
28
|
+
let fs = require("fs");
|
|
29
|
+
fs = __toESM(fs);
|
|
30
|
+
let preferred_pm = require("preferred-pm");
|
|
31
|
+
preferred_pm = __toESM(preferred_pm);
|
|
32
|
+
|
|
33
|
+
//#region ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
|
|
34
|
+
function sync_default(start, callback) {
|
|
35
|
+
let dir = (0, path.resolve)(".", start);
|
|
36
|
+
let tmp;
|
|
37
|
+
if (!(0, fs.statSync)(dir).isDirectory()) dir = (0, path.dirname)(dir);
|
|
38
|
+
while (true) {
|
|
39
|
+
tmp = callback(dir, (0, fs.readdirSync)(dir));
|
|
40
|
+
if (tmp) return (0, path.resolve)(dir, tmp);
|
|
41
|
+
dir = (0, path.dirname)(tmp = dir);
|
|
42
|
+
if (tmp === dir) break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/Utils.ts
|
|
48
|
+
const join = path.default.join;
|
|
49
|
+
var Utils = class {
|
|
50
|
+
static findModulePkg(moduleId, cwd) {
|
|
51
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
52
|
+
let packageName = "";
|
|
53
|
+
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
54
|
+
packageName += parts.shift();
|
|
55
|
+
const packageJson = path.default.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
56
|
+
const resolved = this.findUpConfig(packageJson, "package", ["json"]);
|
|
57
|
+
if (!resolved) return;
|
|
58
|
+
return path.default.join(path.default.dirname(resolved), parts.join("/"));
|
|
59
|
+
}
|
|
60
|
+
static async getMigrationPaths(cwd, migrator, defaultPath, path$2) {
|
|
61
|
+
if (path$2) return [join(cwd, path$2)];
|
|
62
|
+
return [...migrator.getPaths(), join(cwd, defaultPath)];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if file exists
|
|
66
|
+
*
|
|
67
|
+
* @param path
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
static async fileExists(path$2) {
|
|
71
|
+
try {
|
|
72
|
+
await (0, fs_promises.access)(path$2);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
static findUpConfig(cwd, name, extensions) {
|
|
79
|
+
return sync_default(cwd, (_dir, names) => {
|
|
80
|
+
for (const ext of extensions) {
|
|
81
|
+
const filename = `${name}.${ext}`;
|
|
82
|
+
if (names.includes(filename)) return filename;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
static async installCommand(pkg) {
|
|
88
|
+
const pm = (await (0, preferred_pm.default)(process.cwd()))?.name ?? "pnpm";
|
|
89
|
+
let cmd = "install";
|
|
90
|
+
if (pm === "yarn" || pm === "pnpm") cmd = "add";
|
|
91
|
+
else if (pm === "bun") cmd = "create";
|
|
92
|
+
return `${pm} ${cmd} ${pkg}`;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var TableGuesser = class TableGuesser {
|
|
96
|
+
static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
|
|
97
|
+
static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
|
|
98
|
+
static guess(migration) {
|
|
99
|
+
for (const pattern of TableGuesser.CREATE_PATTERNS) {
|
|
100
|
+
const matches = migration.match(pattern);
|
|
101
|
+
if (matches) return [matches[1], true];
|
|
102
|
+
}
|
|
103
|
+
for (const pattern of TableGuesser.CHANGE_PATTERNS) {
|
|
104
|
+
const matches = migration.match(pattern);
|
|
105
|
+
if (matches) return [matches[2], false];
|
|
106
|
+
}
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
Object.defineProperty(exports, 'TableGuesser', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return TableGuesser;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, 'Utils', {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return Utils;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, '__toESM', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return __toESM;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=Utils-B1kpj9-1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils-B1kpj9-1.cjs","names":["path","escalade"],"sources":["../../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs","../src/Utils.ts"],"sourcesContent":["import { dirname, resolve } from 'path';\nimport { readdirSync, statSync } from 'fs';\n\nexport default function (start, callback) {\n\tlet dir = resolve('.', start);\n\tlet tmp, stats = statSync(dir);\n\n\tif (!stats.isDirectory()) {\n\t\tdir = dirname(dir);\n\t}\n\n\twhile (true) {\n\t\ttmp = callback(dir, readdirSync(dir));\n\t\tif (tmp) return resolve(dir, tmp);\n\t\tdir = dirname(tmp = dir);\n\t\tif (tmp === dir) break;\n\t}\n}\n","import { access } from 'fs/promises'\nimport escalade from 'escalade/sync'\nimport path from 'path'\nimport preferredPM from 'preferred-pm'\n\nconst join = path.join\n\nexport class Utils {\n static findModulePkg (moduleId: string, cwd?: string) {\n const parts = moduleId.replace(/\\\\/g, '/').split('/')\n\n let packageName = ''\n // Handle scoped package name\n if (parts.length > 0 && parts[0][0] === '@') {\n packageName += parts.shift() + '/'\n }\n packageName += parts.shift()\n\n const packageJson = path.join(cwd ?? process.cwd(), 'node_modules', packageName)\n\n const resolved = this.findUpConfig(packageJson, 'package', ['json'])\n\n if (!resolved) {\n return\n }\n\n return path.join(path.dirname(resolved), parts.join('/'))\n }\n\n static async getMigrationPaths (cwd: string, migrator: any, defaultPath: string, path: string) {\n if (path) {\n return [join(cwd, path)]\n }\n return [\n ...migrator.getPaths(),\n join(cwd, defaultPath),\n ]\n }\n\n /**\n * Check if file exists\n * \n * @param path \n * @returns \n */\n static async fileExists (path: string): Promise<boolean> {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n }\n\n static findUpConfig (cwd: string, name: string, extensions: string[]) {\n return escalade(cwd, (_dir, names) => {\n for (const ext of extensions) {\n const filename = `${name}.${ext}`\n if (names.includes(filename)) {\n return filename\n }\n }\n return false\n })\n }\n\n static async installCommand (pkg: string) {\n const pm = (await preferredPM(process.cwd()))?.name ?? 'pnpm'\n\n let cmd = 'install'\n if (pm === 'yarn' || pm === 'pnpm')\n cmd = 'add'\n else if (pm === 'bun')\n cmd = 'create'\n\n return `${pm} ${cmd} ${pkg}`\n }\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sBAAyB,OAAO,UAAU;CACzC,IAAI,wBAAc,KAAK,MAAM;CAC7B,IAAI;AAEJ,KAAI,kBAFsB,IAAI,CAEnB,aAAa,CACvB,yBAAc,IAAI;AAGnB,QAAO,MAAM;AACZ,QAAM,SAAS,yBAAiB,IAAI,CAAC;AACrC,MAAI,IAAK,0BAAe,KAAK,IAAI;AACjC,0BAAc,MAAM,IAAI;AACxB,MAAI,QAAQ,IAAK;;;;;;ACVnB,MAAM,OAAO,aAAK;AAElB,IAAa,QAAb,MAAmB;CACjB,OAAO,cAAe,UAAkB,KAAc;EACpD,MAAM,QAAQ,SAAS,QAAQ,OAAO,IAAI,CAAC,MAAM,IAAI;EAErD,IAAI,cAAc;AAElB,MAAI,MAAM,SAAS,KAAK,MAAM,GAAG,OAAO,IACtC,gBAAe,MAAM,OAAO,GAAG;AAEjC,iBAAe,MAAM,OAAO;EAE5B,MAAM,cAAc,aAAK,KAAK,OAAO,QAAQ,KAAK,EAAE,gBAAgB,YAAY;EAEhF,MAAM,WAAW,KAAK,aAAa,aAAa,WAAW,CAAC,OAAO,CAAC;AAEpE,MAAI,CAAC,SACH;AAGF,SAAO,aAAK,KAAK,aAAK,QAAQ,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;;CAG3D,aAAa,kBAAmB,KAAa,UAAe,aAAqB,QAAc;AAC7F,MAAIA,OACF,QAAO,CAAC,KAAK,KAAKA,OAAK,CAAC;AAE1B,SAAO,CACL,GAAG,SAAS,UAAU,EACtB,KAAK,KAAK,YAAY,CACvB;;;;;;;;CASH,aAAa,WAAY,QAAgC;AACvD,MAAI;AACF,iCAAaA,OAAK;AAClB,UAAO;UACD;AACN,UAAO;;;CAIX,OAAO,aAAc,KAAa,MAAc,YAAsB;AACpE,SAAOC,aAAS,MAAM,MAAM,UAAU;AACpC,QAAK,MAAM,OAAO,YAAY;IAC5B,MAAM,WAAW,GAAG,KAAK,GAAG;AAC5B,QAAI,MAAM,SAAS,SAAS,CAC1B,QAAO;;AAGX,UAAO;IACP;;CAGJ,aAAa,eAAgB,KAAa;EACxC,MAAM,MAAM,gCAAkB,QAAQ,KAAK,CAAC,GAAG,QAAQ;EAEvD,IAAI,MAAM;AACV,MAAI,OAAO,UAAU,OAAO,OAC1B,OAAM;WACC,OAAO,MACd,OAAM;AAER,SAAO,GAAG,GAAG,GAAG,IAAI,GAAG;;;AAI3B,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { access } from "fs/promises";
|
|
2
|
+
import path, { dirname, resolve } from "path";
|
|
3
|
+
import { readdirSync, statSync } from "fs";
|
|
4
|
+
import preferredPM from "preferred-pm";
|
|
5
|
+
|
|
6
|
+
//#region ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
|
|
7
|
+
function sync_default(start, callback) {
|
|
8
|
+
let dir = resolve(".", start);
|
|
9
|
+
let tmp;
|
|
10
|
+
if (!statSync(dir).isDirectory()) dir = dirname(dir);
|
|
11
|
+
while (true) {
|
|
12
|
+
tmp = callback(dir, readdirSync(dir));
|
|
13
|
+
if (tmp) return resolve(dir, tmp);
|
|
14
|
+
dir = dirname(tmp = dir);
|
|
15
|
+
if (tmp === dir) break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/Utils.ts
|
|
21
|
+
const join$1 = path.join;
|
|
22
|
+
var Utils = class {
|
|
23
|
+
static findModulePkg(moduleId, cwd) {
|
|
24
|
+
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
25
|
+
let packageName = "";
|
|
26
|
+
if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
|
|
27
|
+
packageName += parts.shift();
|
|
28
|
+
const packageJson = path.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
29
|
+
const resolved = this.findUpConfig(packageJson, "package", ["json"]);
|
|
30
|
+
if (!resolved) return;
|
|
31
|
+
return path.join(path.dirname(resolved), parts.join("/"));
|
|
32
|
+
}
|
|
33
|
+
static async getMigrationPaths(cwd, migrator, defaultPath, path$1) {
|
|
34
|
+
if (path$1) return [join$1(cwd, path$1)];
|
|
35
|
+
return [...migrator.getPaths(), join$1(cwd, defaultPath)];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if file exists
|
|
39
|
+
*
|
|
40
|
+
* @param path
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static async fileExists(path$1) {
|
|
44
|
+
try {
|
|
45
|
+
await access(path$1);
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
static findUpConfig(cwd, name, extensions) {
|
|
52
|
+
return sync_default(cwd, (_dir, names) => {
|
|
53
|
+
for (const ext of extensions) {
|
|
54
|
+
const filename = `${name}.${ext}`;
|
|
55
|
+
if (names.includes(filename)) return filename;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
static async installCommand(pkg) {
|
|
61
|
+
const pm = (await preferredPM(process.cwd()))?.name ?? "pnpm";
|
|
62
|
+
let cmd = "install";
|
|
63
|
+
if (pm === "yarn" || pm === "pnpm") cmd = "add";
|
|
64
|
+
else if (pm === "bun") cmd = "create";
|
|
65
|
+
return `${pm} ${cmd} ${pkg}`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var TableGuesser = class TableGuesser {
|
|
69
|
+
static CREATE_PATTERNS = [/^create_(\w+)_table$/, /^create_(\w+)$/];
|
|
70
|
+
static CHANGE_PATTERNS = [/.+_(to|from|in)_(\w+)_table$/, /.+_(to|from|in)_(\w+)$/];
|
|
71
|
+
static guess(migration) {
|
|
72
|
+
for (const pattern of TableGuesser.CREATE_PATTERNS) {
|
|
73
|
+
const matches = migration.match(pattern);
|
|
74
|
+
if (matches) return [matches[1], true];
|
|
75
|
+
}
|
|
76
|
+
for (const pattern of TableGuesser.CHANGE_PATTERNS) {
|
|
77
|
+
const matches = migration.match(pattern);
|
|
78
|
+
if (matches) return [matches[2], false];
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { TableGuesser, Utils };
|
|
86
|
+
//# sourceMappingURL=Utils-DAJvoXlr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils-DAJvoXlr.js","names":["join","path","escalade"],"sources":["../../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs","../src/Utils.ts"],"sourcesContent":["import { dirname, resolve } from 'path';\nimport { readdirSync, statSync } from 'fs';\n\nexport default function (start, callback) {\n\tlet dir = resolve('.', start);\n\tlet tmp, stats = statSync(dir);\n\n\tif (!stats.isDirectory()) {\n\t\tdir = dirname(dir);\n\t}\n\n\twhile (true) {\n\t\ttmp = callback(dir, readdirSync(dir));\n\t\tif (tmp) return resolve(dir, tmp);\n\t\tdir = dirname(tmp = dir);\n\t\tif (tmp === dir) break;\n\t}\n}\n","import { access } from 'fs/promises'\nimport escalade from 'escalade/sync'\nimport path from 'path'\nimport preferredPM from 'preferred-pm'\n\nconst join = path.join\n\nexport class Utils {\n static findModulePkg (moduleId: string, cwd?: string) {\n const parts = moduleId.replace(/\\\\/g, '/').split('/')\n\n let packageName = ''\n // Handle scoped package name\n if (parts.length > 0 && parts[0][0] === '@') {\n packageName += parts.shift() + '/'\n }\n packageName += parts.shift()\n\n const packageJson = path.join(cwd ?? process.cwd(), 'node_modules', packageName)\n\n const resolved = this.findUpConfig(packageJson, 'package', ['json'])\n\n if (!resolved) {\n return\n }\n\n return path.join(path.dirname(resolved), parts.join('/'))\n }\n\n static async getMigrationPaths (cwd: string, migrator: any, defaultPath: string, path: string) {\n if (path) {\n return [join(cwd, path)]\n }\n return [\n ...migrator.getPaths(),\n join(cwd, defaultPath),\n ]\n }\n\n /**\n * Check if file exists\n * \n * @param path \n * @returns \n */\n static async fileExists (path: string): Promise<boolean> {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n }\n\n static findUpConfig (cwd: string, name: string, extensions: string[]) {\n return escalade(cwd, (_dir, names) => {\n for (const ext of extensions) {\n const filename = `${name}.${ext}`\n if (names.includes(filename)) {\n return filename\n }\n }\n return false\n })\n }\n\n static async installCommand (pkg: string) {\n const pm = (await preferredPM(process.cwd()))?.name ?? 'pnpm'\n\n let cmd = 'install'\n if (pm === 'yarn' || pm === 'pnpm')\n cmd = 'add'\n else if (pm === 'bun')\n cmd = 'create'\n\n return `${pm} ${cmd} ${pkg}`\n }\n}\n\nclass TableGuesser {\n static CREATE_PATTERNS = [\n /^create_(\\w+)_table$/,\n /^create_(\\w+)$/\n ]\n static CHANGE_PATTERNS = [\n /.+_(to|from|in)_(\\w+)_table$/,\n /.+_(to|from|in)_(\\w+)$/\n ]\n static guess (migration: string) {\n for (const pattern of TableGuesser.CREATE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[1], true]\n }\n }\n for (const pattern of TableGuesser.CHANGE_PATTERNS) {\n const matches = migration.match(pattern)\n if (matches) {\n return [matches[2], false]\n }\n }\n return []\n }\n}\n\nexport { TableGuesser }\n"],"x_google_ignoreList":[0],"mappings":";;;;;;AAGA,sBAAyB,OAAO,UAAU;CACzC,IAAI,MAAM,QAAQ,KAAK,MAAM;CAC7B,IAAI;AAEJ,KAAI,CAFa,SAAS,IAAI,CAEnB,aAAa,CACvB,OAAM,QAAQ,IAAI;AAGnB,QAAO,MAAM;AACZ,QAAM,SAAS,KAAK,YAAY,IAAI,CAAC;AACrC,MAAI,IAAK,QAAO,QAAQ,KAAK,IAAI;AACjC,QAAM,QAAQ,MAAM,IAAI;AACxB,MAAI,QAAQ,IAAK;;;;;;ACVnB,MAAMA,SAAO,KAAK;AAElB,IAAa,QAAb,MAAmB;CACjB,OAAO,cAAe,UAAkB,KAAc;EACpD,MAAM,QAAQ,SAAS,QAAQ,OAAO,IAAI,CAAC,MAAM,IAAI;EAErD,IAAI,cAAc;AAElB,MAAI,MAAM,SAAS,KAAK,MAAM,GAAG,OAAO,IACtC,gBAAe,MAAM,OAAO,GAAG;AAEjC,iBAAe,MAAM,OAAO;EAE5B,MAAM,cAAc,KAAK,KAAK,OAAO,QAAQ,KAAK,EAAE,gBAAgB,YAAY;EAEhF,MAAM,WAAW,KAAK,aAAa,aAAa,WAAW,CAAC,OAAO,CAAC;AAEpE,MAAI,CAAC,SACH;AAGF,SAAO,KAAK,KAAK,KAAK,QAAQ,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;;CAG3D,aAAa,kBAAmB,KAAa,UAAe,aAAqB,QAAc;AAC7F,MAAIC,OACF,QAAO,CAACD,OAAK,KAAKC,OAAK,CAAC;AAE1B,SAAO,CACL,GAAG,SAAS,UAAU,EACtBD,OAAK,KAAK,YAAY,CACvB;;;;;;;;CASH,aAAa,WAAY,QAAgC;AACvD,MAAI;AACF,SAAM,OAAOC,OAAK;AAClB,UAAO;UACD;AACN,UAAO;;;CAIX,OAAO,aAAc,KAAa,MAAc,YAAsB;AACpE,SAAOC,aAAS,MAAM,MAAM,UAAU;AACpC,QAAK,MAAM,OAAO,YAAY;IAC5B,MAAM,WAAW,GAAG,KAAK,GAAG;AAC5B,QAAI,MAAM,SAAS,SAAS,CAC1B,QAAO;;AAGX,UAAO;IACP;;CAGJ,aAAa,eAAgB,KAAa;EACxC,MAAM,MAAM,MAAM,YAAY,QAAQ,KAAK,CAAC,GAAG,QAAQ;EAEvD,IAAI,MAAM;AACV,MAAI,OAAO,UAAU,OAAO,OAC1B,OAAM;WACC,OAAO,MACd,OAAM;AAER,SAAO,GAAG,GAAG,GAAG,IAAI,GAAG;;;AAI3B,IAAM,eAAN,MAAM,aAAa;CACjB,OAAO,kBAAkB,CACvB,wBACA,iBACD;CACD,OAAO,kBAAkB,CACvB,gCACA,yBACD;CACD,OAAO,MAAO,WAAmB;AAC/B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,KAAK;;AAG7B,OAAK,MAAM,WAAW,aAAa,iBAAiB;GAClD,MAAM,UAAU,UAAU,MAAM,QAAQ;AACxC,OAAI,QACF,QAAO,CAAC,QAAQ,IAAI,MAAM;;AAG9B,SAAO,EAAE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/Utils.d.ts
|
|
2
|
+
declare class Utils {
|
|
3
|
+
static findModulePkg(moduleId: string, cwd?: string): string | undefined;
|
|
4
|
+
static getMigrationPaths(cwd: string, migrator: any, defaultPath: string, path: string): Promise<any[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Check if file exists
|
|
7
|
+
*
|
|
8
|
+
* @param path
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
static fileExists(path: string): Promise<boolean>;
|
|
12
|
+
static findUpConfig(cwd: string, name: string, extensions: string[]): string | void;
|
|
13
|
+
static installCommand(pkg: string): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
declare class TableGuesser {
|
|
16
|
+
static CREATE_PATTERNS: RegExp[];
|
|
17
|
+
static CHANGE_PATTERNS: RegExp[];
|
|
18
|
+
static guess(migration: string): (string | boolean)[];
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { TableGuesser, Utils };
|
|
22
|
+
//# sourceMappingURL=Utils-DxnHOGMz.d.ts.map
|
package/dist/Utils.cjs
CHANGED
|
@@ -1,218 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
const require_Utils = require('./Utils-B1kpj9-1.cjs');
|
|
30
2
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
__export(Utils_exports, {
|
|
34
|
-
TableGuesser: () => TableGuesser,
|
|
35
|
-
Utils: () => Utils
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(Utils_exports);
|
|
38
|
-
var import_promises = require("fs/promises");
|
|
39
|
-
var import_chalk = __toESM(require("chalk"), 1);
|
|
40
|
-
|
|
41
|
-
// ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
|
|
42
|
-
var import_path = require("path");
|
|
43
|
-
var import_fs = require("fs");
|
|
44
|
-
function sync_default(start, callback) {
|
|
45
|
-
let dir = (0, import_path.resolve)(".", start);
|
|
46
|
-
let tmp, stats = (0, import_fs.statSync)(dir);
|
|
47
|
-
if (!stats.isDirectory()) {
|
|
48
|
-
dir = (0, import_path.dirname)(dir);
|
|
49
|
-
}
|
|
50
|
-
while (true) {
|
|
51
|
-
tmp = callback(dir, (0, import_fs.readdirSync)(dir));
|
|
52
|
-
if (tmp) return (0, import_path.resolve)(dir, tmp);
|
|
53
|
-
dir = (0, import_path.dirname)(tmp = dir);
|
|
54
|
-
if (tmp === dir) break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
__name(sync_default, "default");
|
|
58
|
-
|
|
59
|
-
// src/Utils.ts
|
|
60
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
61
|
-
var join = import_path2.default.join;
|
|
62
|
-
var Utils = class {
|
|
63
|
-
static {
|
|
64
|
-
__name(this, "Utils");
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Wraps text with chalk
|
|
68
|
-
*
|
|
69
|
-
* @param txt
|
|
70
|
-
* @param color
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
static textFormat(txt, color) {
|
|
74
|
-
return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Ouput formater object
|
|
78
|
-
*
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
static output() {
|
|
82
|
-
return {
|
|
83
|
-
success: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
84
|
-
console.log(import_chalk.default.green("\u2713"), this.textFormat(msg, import_chalk.default.bgGreen), "\n");
|
|
85
|
-
if (exit) process.exit(0);
|
|
86
|
-
}, "success"),
|
|
87
|
-
info: /* @__PURE__ */ __name((msg, exit = false) => {
|
|
88
|
-
console.log(import_chalk.default.blue("\u2139"), this.textFormat(msg, import_chalk.default.bgBlue), "\n");
|
|
89
|
-
if (exit) process.exit(0);
|
|
90
|
-
}, "info"),
|
|
91
|
-
error: /* @__PURE__ */ __name((msg, exit = true) => {
|
|
92
|
-
if (msg instanceof Error) {
|
|
93
|
-
if (msg.message) {
|
|
94
|
-
console.error(import_chalk.default.red("\u2716"), this.textFormat("ERROR:" + msg.message, import_chalk.default.bgRed));
|
|
95
|
-
}
|
|
96
|
-
console.error(import_chalk.default.red(`${msg.detail ? `${msg.detail}
|
|
97
|
-
` : ""}${msg.stack}`), "\n");
|
|
98
|
-
} else {
|
|
99
|
-
console.error(import_chalk.default.red("\u2716"), this.textFormat(msg, import_chalk.default.bgRed), "\n");
|
|
100
|
-
}
|
|
101
|
-
if (exit) process.exit(1);
|
|
102
|
-
}, "error"),
|
|
103
|
-
split: /* @__PURE__ */ __name((name, value, status, exit = false) => {
|
|
104
|
-
status ??= "info";
|
|
105
|
-
const color = {
|
|
106
|
-
success: import_chalk.default.bgGreen,
|
|
107
|
-
info: import_chalk.default.bgBlue,
|
|
108
|
-
error: import_chalk.default.bgRed
|
|
109
|
-
};
|
|
110
|
-
const regex = /\x1b\[\d+m/g;
|
|
111
|
-
const width = Math.min(process.stdout.columns, 100);
|
|
112
|
-
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
113
|
-
console.log(this.textFormat(name, color[status]), import_chalk.default.gray(".".repeat(dots)), value);
|
|
114
|
-
if (exit) process.exit(0);
|
|
115
|
-
}, "split"),
|
|
116
|
-
quiet: /* @__PURE__ */ __name(() => {
|
|
117
|
-
process.exit(0);
|
|
118
|
-
}, "quiet")
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
static findModulePkg(moduleId, cwd) {
|
|
122
|
-
const parts = moduleId.replace(/\\/g, "/").split("/");
|
|
123
|
-
let packageName = "";
|
|
124
|
-
if (parts.length > 0 && parts[0][0] === "@") {
|
|
125
|
-
packageName += parts.shift() + "/";
|
|
126
|
-
}
|
|
127
|
-
packageName += parts.shift();
|
|
128
|
-
const packageJson = import_path2.default.join(cwd ?? process.cwd(), "node_modules", packageName);
|
|
129
|
-
const resolved = this.findUpConfig(packageJson, "package", [
|
|
130
|
-
"json"
|
|
131
|
-
]);
|
|
132
|
-
if (!resolved) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
return import_path2.default.join(import_path2.default.dirname(resolved), parts.join("/"));
|
|
136
|
-
}
|
|
137
|
-
static async getMigrationPaths(cwd, migrator, defaultPath, path2) {
|
|
138
|
-
if (path2) {
|
|
139
|
-
return [
|
|
140
|
-
join(cwd, path2)
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
|
-
return [
|
|
144
|
-
...migrator.getPaths(),
|
|
145
|
-
join(cwd, defaultPath)
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
static twoColumnDetail(name, value) {
|
|
149
|
-
const regex = /\x1b\[\d+m/g;
|
|
150
|
-
const width = Math.min(process.stdout.columns, 100);
|
|
151
|
-
const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
|
|
152
|
-
return console.log(name, import_chalk.default.gray(".".repeat(dots)), value);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Check if file exists
|
|
156
|
-
*
|
|
157
|
-
* @param path
|
|
158
|
-
* @returns
|
|
159
|
-
*/
|
|
160
|
-
static async fileExists(path2) {
|
|
161
|
-
try {
|
|
162
|
-
await (0, import_promises.access)(path2);
|
|
163
|
-
return true;
|
|
164
|
-
} catch {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
static findUpConfig(cwd, name, extensions) {
|
|
169
|
-
return sync_default(cwd, (_dir, names) => {
|
|
170
|
-
for (const ext of extensions) {
|
|
171
|
-
const filename = `${name}.${ext}`;
|
|
172
|
-
if (names.includes(filename)) {
|
|
173
|
-
return filename;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return false;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
var TableGuesser = class TableGuesser2 {
|
|
181
|
-
static {
|
|
182
|
-
__name(this, "TableGuesser");
|
|
183
|
-
}
|
|
184
|
-
static CREATE_PATTERNS = [
|
|
185
|
-
/^create_(\w+)_table$/,
|
|
186
|
-
/^create_(\w+)$/
|
|
187
|
-
];
|
|
188
|
-
static CHANGE_PATTERNS = [
|
|
189
|
-
/.+_(to|from|in)_(\w+)_table$/,
|
|
190
|
-
/.+_(to|from|in)_(\w+)$/
|
|
191
|
-
];
|
|
192
|
-
static guess(migration) {
|
|
193
|
-
for (const pattern of TableGuesser2.CREATE_PATTERNS) {
|
|
194
|
-
const matches = migration.match(pattern);
|
|
195
|
-
if (matches) {
|
|
196
|
-
return [
|
|
197
|
-
matches[1],
|
|
198
|
-
true
|
|
199
|
-
];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
for (const pattern of TableGuesser2.CHANGE_PATTERNS) {
|
|
203
|
-
const matches = migration.match(pattern);
|
|
204
|
-
if (matches) {
|
|
205
|
-
return [
|
|
206
|
-
matches[2],
|
|
207
|
-
false
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
-
0 && (module.exports = {
|
|
216
|
-
TableGuesser,
|
|
217
|
-
Utils
|
|
218
|
-
});
|
|
3
|
+
exports.TableGuesser = require_Utils.TableGuesser;
|
|
4
|
+
exports.Utils = require_Utils.Utils;
|
package/dist/Utils.d.cts
ADDED
package/dist/Utils.d.ts
ADDED
package/dist/Utils.js
CHANGED