drizzle-auto 1.0.5 → 1.0.6
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/index.js +43 -15
- package/package.json +9 -3
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const chokidar = require("chokidar");
|
|
|
6
6
|
const spawn = require("cross-spawn");
|
|
7
7
|
|
|
8
8
|
/* =========================
|
|
9
|
-
🧠 Detect
|
|
9
|
+
🧠 Detect project root
|
|
10
10
|
========================= */
|
|
11
11
|
function getProjectRoot() {
|
|
12
12
|
const init = process.env.INIT_CWD;
|
|
@@ -34,27 +34,55 @@ function injectTeaScript() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/* =========================
|
|
37
|
-
|
|
37
|
+
🚀 Run Drizzle pipeline
|
|
38
|
+
========================= */
|
|
39
|
+
let running = false;
|
|
40
|
+
|
|
41
|
+
function runPipeline() {
|
|
42
|
+
if (running) return;
|
|
43
|
+
running = true;
|
|
44
|
+
console.clear();
|
|
45
|
+
console.log("🚀 Drizzle Pipeline starting...");
|
|
46
|
+
|
|
47
|
+
const p = spawn("npx", ["drizzle-kit", "check", "generate", "push"], {
|
|
48
|
+
stdio: "inherit",
|
|
49
|
+
shell: true,
|
|
50
|
+
cwd: projectRoot,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
p.on("close", (code) => {
|
|
54
|
+
running = false;
|
|
55
|
+
if (code === 0) console.log("✅ Drizzle synced!");
|
|
56
|
+
else console.log("❌ Drizzle pipeline failed. Fix errors & save files.");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* =========================
|
|
61
|
+
👀 Postinstall / Auto inject
|
|
38
62
|
========================= */
|
|
39
63
|
if (process.argv.includes("--postinstall")) {
|
|
40
64
|
injectTeaScript();
|
|
65
|
+
runPipeline(); // first run after install
|
|
41
66
|
process.exit(0);
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
/* =========================
|
|
45
|
-
|
|
70
|
+
👀 Watcher
|
|
46
71
|
========================= */
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function run(cmd) {
|
|
50
|
-
if (running) return;
|
|
51
|
-
running = true;
|
|
52
|
-
console.clear();
|
|
53
|
-
console.log("🚀 Running Drizzle Pipeline...");
|
|
54
|
-
const p = spawn("npx", cmd, { stdio: "inherit", shell: true });
|
|
55
|
-
p.on("close", () => (running = false));
|
|
56
|
-
}
|
|
72
|
+
injectTeaScript();
|
|
73
|
+
runPipeline(); // first run immediately when running npx drizzle-auto
|
|
57
74
|
|
|
58
75
|
chokidar
|
|
59
|
-
.watch(projectRoot, {
|
|
60
|
-
|
|
76
|
+
.watch(projectRoot, {
|
|
77
|
+
ignored: /node_modules|\.git|\.next/,
|
|
78
|
+
ignoreInitial: true,
|
|
79
|
+
})
|
|
80
|
+
.on("all", (event, filePath) => {
|
|
81
|
+
console.log(`⚡ File changed → ${filePath}`);
|
|
82
|
+
runPipeline();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
process.on("uncaughtException", (err) => {
|
|
86
|
+
console.log("\x1b[31m🔥 Crash:\x1b[0m", err.message);
|
|
87
|
+
running = false;
|
|
88
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-auto",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Auto Drizzle sync with tea script injection",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,11 +12,17 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"drizzle",
|
|
17
|
+
"automation",
|
|
18
|
+
"nextjs",
|
|
19
|
+
"watcher",
|
|
20
|
+
"tea"
|
|
21
|
+
],
|
|
16
22
|
"author": "Pavel Ahmmed Hridoy",
|
|
17
23
|
"license": "MIT",
|
|
18
24
|
"dependencies": {
|
|
19
25
|
"chokidar": "^4.0.1",
|
|
20
26
|
"cross-spawn": "^7.0.6"
|
|
21
27
|
}
|
|
22
|
-
}
|
|
28
|
+
}
|