drizzle-auto 1.1.8 → 1.1.11

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