drizzle-auto 1.1.7 → 1.1.10

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.
Files changed (2) hide show
  1. package/index.js +32 -108
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,7 +6,7 @@ const path = require("path");
6
6
  const fs = require("fs");
7
7
 
8
8
  /* =============================================================
9
- 🎨 NEON-PULSE UI CORE (ChatGPT-Like Aesthetics)
9
+ 🎨 NEON-PULSE UI CORE (Same as Next)
10
10
  ============================================================= */
11
11
  const T = {
12
12
  reset: "\x1b[0m",
@@ -23,13 +23,8 @@ const T = {
23
23
  bg_dark: "\x1b[48;5;234m"
24
24
  };
25
25
 
26
- const rainbow = (text) => {
27
- const colors = [196, 208, 226, 118, 51, 201];
28
- return text.split('').map((char, i) => `\x1b[38;5;${colors[i % colors.length]}m${char}`).join('') + T.reset;
29
- };
30
-
31
26
  /* =============================================================
32
- HIGH-FIDELITY SPINNER & LOADING
27
+ ⏳ SPINNER & LOADING
33
28
  ============================================================= */
34
29
  const frames = ["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];
35
30
  let spinIdx = 0;
@@ -43,166 +38,95 @@ function startLoading(msg) {
43
38
  }
44
39
 
45
40
  function stopLoading() {
46
- if (spinInterval) {
47
- clearInterval(spinInterval);
48
- spinInterval = null;
49
- process.stdout.write("\r\x1b[K"); // Clear line
50
- }
41
+ if (spinInterval) { clearInterval(spinInterval); spinInterval = null; process.stdout.write("\r\x1b[K"); }
51
42
  }
52
43
 
53
- /* =============================================================
54
- 🧩 AUTO SCRIPT INJECTOR
55
- ============================================================= */
56
- const PKG = path.join(process.cwd(), "package.json");
57
- function injectScript() {
58
- if (!fs.existsSync(PKG)) return;
59
- const pkg = JSON.parse(fs.readFileSync(PKG, "utf8"));
60
- pkg.scripts ||= {};
61
- if (!pkg.scripts.tea) {
62
- pkg.scripts.tea = "drizzle-auto";
63
- fs.writeFileSync(PKG, JSON.stringify(pkg, null, 2));
64
- console.log(`${T.lime}☕ Script added → npm run tea${T.reset}`);
65
- }
66
- }
67
- injectScript();
68
-
69
- /* =============================================================
44
+ /* =========================
70
45
  🔍 ALL FILES DRIZZLE DETECTOR
71
- ============================================================= */
46
+ ========================= */
72
47
  function findDrizzleConfig(root) {
73
48
  const exts = ["js","mjs","ts","mts","cjs"];
74
49
  const files = [];
75
-
76
50
  function walk(dir) {
77
51
  fs.readdirSync(dir, { withFileTypes: true }).forEach(file => {
78
52
  const full = path.join(dir, file.name);
79
- if (file.isDirectory() && !/node_modules|\.git|\.next|dist/.test(file.name)) {
80
- walk(full);
81
- } else if (file.isFile() && exts.some(ext => file.name === `drizzle.config.${ext}`)) {
82
- files.push(full);
83
- }
53
+ if (file.isDirectory() && !/node_modules|\.git|\.next|dist/.test(file.name)) walk(full);
54
+ else if (file.isFile() && exts.some(ext => file.name === `drizzle.config.${ext}`)) files.push(full);
84
55
  });
85
56
  }
86
-
87
57
  walk(root);
88
58
  return files;
89
59
  }
90
60
 
91
61
  function justifyStructure() {
92
- const root = process.cwd();
93
- const configs = findDrizzleConfig(root);
62
+ const configs = findDrizzleConfig(process.cwd());
94
63
  if (configs.length === 0) return { ok: false, msg: "Missing drizzle.config.*" };
95
-
96
64
  for (const configPath of configs) {
97
65
  try {
98
66
  const content = fs.readFileSync(configPath, "utf8");
99
67
  const schemaMatch = content.match(/schema:\s*["'](.+?)["']/);
100
68
  if (schemaMatch && schemaMatch[1]) {
101
69
  const schemaFull = path.resolve(path.dirname(configPath), schemaMatch[1]);
102
- if (!fs.existsSync(schemaFull)) {
103
- return { ok: false, msg: `Schema not found: ${schemaMatch[1]} in ${configPath}` };
104
- }
70
+ if (!fs.existsSync(schemaFull)) return { ok: false, msg: `Schema not found: ${schemaMatch[1]}` };
105
71
  }
106
- } catch (e) {
107
- return { ok: false, msg: `Config parse error in ${configPath}` };
108
- }
72
+ } catch { return { ok: false, msg: `Config parse error in ${configPath}` }; }
109
73
  }
110
-
111
74
  return { ok: true, config: configs };
112
75
  }
113
76
 
114
- /* =============================================================
77
+ /* =========================
115
78
  ⚙️ SAFE STEP RUNNER
116
- ============================================================= */
79
+ ========================= */
117
80
  function runStep(args, label) {
118
- return new Promise((resolve) => {
81
+ return new Promise(resolve => {
119
82
  startLoading(`${T.pink}${label}${T.reset}`);
120
83
  let localErr = false;
121
-
122
- const child = spawn("npx", args, { shell: true, stdio: ["inherit", "pipe", "pipe"] });
123
-
124
- child.stdout.on("data", (data) => {
84
+ const child = spawn("npx", args, { shell: true, stdio: ["inherit","pipe","pipe"] });
85
+ child.stdout.on("data", data => {
125
86
  const out = data.toString();
126
- if (!out.includes('Pulling schema')) {
127
- stopLoading();
128
- process.stdout.write(`${T.gray}${out}${T.reset}`);
129
- }
87
+ if (!out.includes('Pulling schema')) { stopLoading(); process.stdout.write(`${T.gray}${out}${T.reset}`); }
130
88
  if (/error|failed|ENOTFOUND/i.test(out)) localErr = true;
131
89
  });
132
-
133
- child.stderr.on("data", (data) => {
134
- stopLoading();
135
- process.stderr.write(`${T.red}${T.bold}✖ ${data}${T.reset}`);
136
- localErr = true;
137
- });
138
-
139
- child.on("close", (code) => {
140
- stopLoading();
141
- resolve(code === 0 && !localErr);
142
- });
90
+ child.stderr.on("data", data => { stopLoading(); process.stderr.write(`${T.red}${T.bold}✖ ${data}${T.reset}`); localErr = true; });
91
+ child.on("close", code => { stopLoading(); resolve(code === 0 && !localErr); });
143
92
  });
144
93
  }
145
94
 
146
- /* =============================================================
95
+ /* =========================
147
96
  🔁 ENGINE WORKFLOW
148
- ============================================================= */
97
+ ========================= */
149
98
  let isRunning = false;
150
- let hasError = false;
151
99
 
152
100
  async function triggerEngine(event) {
153
101
  if (isRunning) return;
154
102
  isRunning = true;
155
103
 
156
- if (!hasError) console.clear();
157
- console.log(`\n${T.bg_dark} ${rainbow(" DRIZZLE-AUTO v2026 ")} ${T.reset}`);
158
- console.log(`${T.magenta}●${T.reset} ${T.bold}Event:${T.reset} ${T.cyan}${event}${T.reset}\n`);
159
-
160
104
  const audit = justifyStructure();
161
- if (!audit.ok) {
162
- console.log(`${T.red}${T.bold}🛑 CRITICAL FAILURE:${T.reset} ${audit.msg}`);
163
- hasError = true; isRunning = false; return;
164
- }
105
+ if (!audit.ok) { console.log(`${T.red}${T.bold}🛑 CRITICAL FAILURE:${T.reset} ${audit.msg}`); isRunning=false; return; }
165
106
 
166
107
  const steps = [
167
- { name: "Confirming Integrity", args: ["drizzle-kit", "check"] },
168
- { name: "Generating Migrations", args: ["drizzle-kit", "generate"] },
169
- { name: "Pushing to Database", args: ["drizzle-kit", "push"] }
108
+ { name: "Build Check", args:["drizzle-kit","check"] },
109
+ { name: "Generate Migrations", args:["drizzle-kit","generate"] },
110
+ { name: "Push Database", args:["drizzle-kit","push"] }
170
111
  ];
171
112
 
172
113
  for (const step of steps) {
173
114
  const success = await runStep(step.args, step.name);
174
- if (!success) {
175
- console.log(`\n${T.red}${T.bold}✖ PIPELINE CRASHED AT [${step.name.toUpperCase()}]${T.reset}`);
176
- hasError = true; isRunning = false; return;
177
- }
115
+ if (!success) { console.log(`\n${T.red}${T.bold}✖ PIPELINE CRASHED AT [${step.name.toUpperCase()}]${T.reset}`); isRunning=false; return; }
178
116
  }
179
117
 
180
- hasError = false;
181
118
  console.log(`\n${T.lime}${T.bold}✔ SYSTEM JUSTIFIED & SYNCED${T.reset}`);
182
119
  console.log(`${T.gray}Waiting for next server-side change...${T.reset}\n`);
183
120
  isRunning = false;
184
121
  }
185
122
 
186
- /* =============================================================
187
- 👀 WATCHER & GLOBAL CRASH PROTECTION
188
- ============================================================= */
189
- chokidar.watch(".", {
190
- ignored: [/node_modules/, /\.git/, /\.next/, /dist/],
191
- ignoreInitial: true,
192
- usePolling: true,
193
- interval: 300
194
- }).on("all", (e, f) => triggerEngine(`${e.toUpperCase()} -> ${path.basename(f)}`));
123
+ /* =========================
124
+ 👀 WATCHER & CRASH PROTECTION
125
+ ========================= */
126
+ chokidar.watch(".", { ignored:[/node_modules/, /\.git/, /\.next/, /dist/], ignoreInitial:true, usePolling:true, interval:300 })
127
+ .on("all",(e,f)=>triggerEngine(`${e.toUpperCase()} -> ${path.basename(f)}`));
195
128
 
196
129
  triggerEngine("Initial Audit");
197
130
 
198
- process.on("uncaughtException", (err) => {
199
- stopLoading();
200
- console.log(`\n${T.red}${T.bold}🛡️ PROTECTIVE SHIELD:${T.reset} ${err.message}`);
201
- isRunning = false;
202
- });
203
-
204
- process.on("SIGINT", () => {
205
- stopLoading();
206
- console.log(`\n${T.yellow}Shutting down Drizzle-Auto...${T.reset}`);
207
- process.exit();
208
- });
131
+ process.on("uncaughtException",(err)=>{ stopLoading(); console.log(`\n${T.red}${T.bold}🛡️ PROTECTIVE SHIELD:${T.reset} ${err.message}`); isRunning=false; });
132
+ process.on("SIGINT",()=>{ stopLoading(); console.log(`\n${T.yellow}Shutting down Drizzle-Auto...${T.reset}`); process.exit(); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-auto",
3
- "version": "1.1.7",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "pavel ahmmed hridoy",