drizzle-auto 1.0.23 → 1.0.24

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 +25 -31
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12,97 +12,90 @@ const ROOT = process.cwd();
12
12
  const PKG = path.join(ROOT, "package.json");
13
13
 
14
14
  /* =========================
15
- šŸŽØ COLOR HELPERS
15
+ šŸŽØ COLORS
16
16
  ========================= */
17
17
  const colors = {
18
18
  reset: "\x1b[0m",
19
- bright: "\x1b[1m",
20
19
  red: "\x1b[31m",
21
20
  green: "\x1b[32m",
22
21
  yellow: "\x1b[33m",
23
- blue: "\x1b[34m",
24
- magenta: "\x1b[35m",
25
22
  cyan: "\x1b[36m",
23
+ magenta: "\x1b[35m",
26
24
  };
27
25
 
28
26
  /* =========================
29
27
  🧩 SCRIPT INJECTOR
30
28
  ========================= */
31
- function injectScript() {
29
+ function injectTeaScript() {
32
30
  if (!fs.existsSync(PKG)) return;
33
31
  const pkg = JSON.parse(fs.readFileSync(PKG, "utf8"));
34
32
  pkg.scripts ||= {};
35
-
36
33
  if (!pkg.scripts.tea) {
37
34
  pkg.scripts.tea = "drizzle-auto";
38
35
  fs.writeFileSync(PKG, JSON.stringify(pkg, null, 2));
39
- console.log(`${colors.cyan}ā˜• Script added → npm run tea${colors.reset}`);
36
+ console.log(`${colors.cyan}ā˜• Added npm run tea${colors.reset}`);
40
37
  }
41
38
  }
42
39
 
43
40
  /* =========================
44
- šŸ” DRIZZLE DETECTOR
41
+ šŸ” DRIZZLE CONFIG DETECTION
45
42
  ========================= */
46
- function detectDrizzle() {
47
- const configs = ["js","mjs","ts","mts"]
48
- .map(e => `drizzle.config.${e}`) // āœ… Fixed
49
- .find(f => fs.existsSync(path.join(ROOT, f)));
50
-
51
- if (!configs) {
43
+ function findDrizzleConfig() {
44
+ const files = ["drizzle.config.js","drizzle.config.mjs","drizzle.config.ts","drizzle.config.mts"];
45
+ const found = files.map(f => path.join(ROOT, f)).find(fs.existsSync);
46
+ if (!found) {
52
47
  console.log(`${colors.yellow}āš ļø No drizzle.config found${colors.reset}`);
53
48
  return null;
54
49
  }
55
50
 
56
- let schemaPath = null;
51
+ let schema = null;
57
52
  try {
58
- const content = fs.readFileSync(path.join(ROOT, configs), "utf8");
53
+ const content = fs.readFileSync(found, "utf8");
59
54
  const match = content.match(/schema:\s*["'](.+?)["']/);
60
- if (match) schemaPath = path.join(ROOT, match[1]);
55
+ if (match) schema = path.join(ROOT, match[1]);
61
56
  } catch {}
62
-
63
- if (schemaPath && !fs.existsSync(schemaPath)) {
64
- console.log(`${colors.red}āŒ Schema file missing${colors.reset}`);
57
+
58
+ if (schema && !fs.existsSync(schema)) {
59
+ console.log(`${colors.red}āŒ Schema file missing: ${schema}${colors.reset}`);
65
60
  return null;
66
61
  }
67
62
 
68
- return { config: configs, schema: schemaPath };
63
+ return { config: found, schema };
69
64
  }
70
65
 
71
66
  /* =========================
72
- āš™ļø SAFE COMMAND RUNNER
67
+ āš™ļø SAFE RUNNER
73
68
  ========================= */
74
69
  function run(cmd) {
75
- return new Promise((resolve) => {
70
+ return new Promise(resolve => {
76
71
  let failed = false;
77
72
  const p = spawn("npx", cmd, { shell: true });
78
-
79
73
  p.stdout.on("data", d => process.stdout.write(`${colors.green}${d}${colors.reset}`));
80
74
  p.stderr.on("data", d => {
81
75
  failed = true;
82
76
  process.stderr.write(`${colors.red}${d}${colors.reset}`);
83
77
  });
84
-
85
78
  p.on("close", code => resolve(code === 0 && !failed));
86
79
  });
87
80
  }
88
81
 
89
82
  /* =========================
90
- šŸ” PIPELINE (NON-KILLING)
83
+ šŸ” PIPELINE
91
84
  ========================= */
92
85
  let busy = false;
93
86
 
94
87
  async function pipeline(trigger) {
95
88
  if (busy) return;
96
89
  busy = true;
97
-
98
90
  console.log(`${colors.magenta}\n⚔ Trigger → ${trigger}${colors.reset}`);
99
91
 
100
- const drizzle = detectDrizzle();
92
+ const drizzle = findDrizzleConfig();
101
93
  if (!drizzle) {
102
94
  busy = false;
103
95
  return;
104
96
  }
105
97
 
98
+ // 1ļøāƒ£ Generate
106
99
  const genOK = await run(["drizzle-kit", "generate"]);
107
100
  if (!genOK) {
108
101
  console.log(`${colors.red}šŸ›‘ Generate failed — pipeline paused${colors.reset}`);
@@ -110,6 +103,7 @@ async function pipeline(trigger) {
110
103
  return;
111
104
  }
112
105
 
106
+ // 2ļøāƒ£ Push
113
107
  const pushOK = await run(["drizzle-kit", "push"]);
114
108
  if (!pushOK) {
115
109
  console.log(`${colors.red}šŸ›‘ Push failed — server still running${colors.reset}`);
@@ -122,9 +116,9 @@ async function pipeline(trigger) {
122
116
  }
123
117
 
124
118
  /* =========================
125
- šŸ‘€ WATCHER (ALWAYS ALIVE)
119
+ šŸ‘€ WATCHER
126
120
  ========================= */
127
- injectScript();
121
+ injectTeaScript();
128
122
  pipeline("Initial");
129
123
 
130
124
  chokidar.watch(ROOT, {
@@ -132,4 +126,4 @@ chokidar.watch(ROOT, {
132
126
  ignoreInitial: true,
133
127
  usePolling: true,
134
128
  interval: 300
135
- }).on("all", (_, file) => pipeline(path.basename(file)));
129
+ }).on("all", (_, file) => pipeline(file));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-auto",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "pavel ahmmed hridoy",