drizzle-auto 1.0.5 → 1.0.7
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 +44 -17
- package/package.json +1 -9
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;
|
|
@@ -20,7 +20,7 @@ const projectRoot = getProjectRoot();
|
|
|
20
20
|
const pkgPath = path.join(projectRoot, "package.json");
|
|
21
21
|
|
|
22
22
|
/* =========================
|
|
23
|
-
✍️ Inject "tea" script
|
|
23
|
+
✍️ Inject "tea" script automatically
|
|
24
24
|
========================= */
|
|
25
25
|
function injectTeaScript() {
|
|
26
26
|
if (!fs.existsSync(pkgPath)) return;
|
|
@@ -34,27 +34,54 @@ function injectTeaScript() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/* =========================
|
|
37
|
-
|
|
38
|
-
========================= */
|
|
39
|
-
if (process.argv.includes("--postinstall")) {
|
|
40
|
-
injectTeaScript();
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* =========================
|
|
45
|
-
🚀 Watcher / Drizzle Auto Logic
|
|
37
|
+
🚀 Run Drizzle pipeline
|
|
46
38
|
========================= */
|
|
47
39
|
let running = false;
|
|
48
40
|
|
|
49
|
-
function
|
|
41
|
+
function runPipeline() {
|
|
50
42
|
if (running) return;
|
|
51
43
|
running = true;
|
|
52
44
|
console.clear();
|
|
53
|
-
console.log("🚀
|
|
54
|
-
|
|
55
|
-
p
|
|
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 hook
|
|
62
|
+
========================= */
|
|
63
|
+
if (process.argv.includes("--postinstall") || process.env.npm_config_argv) {
|
|
64
|
+
injectTeaScript();
|
|
65
|
+
runPipeline();
|
|
56
66
|
}
|
|
57
67
|
|
|
68
|
+
/* =========================
|
|
69
|
+
👀 Watcher for any changes
|
|
70
|
+
========================= */
|
|
71
|
+
injectTeaScript();
|
|
72
|
+
runPipeline(); // run immediately on npx drizzle-auto
|
|
73
|
+
|
|
58
74
|
chokidar
|
|
59
|
-
.watch(projectRoot, {
|
|
60
|
-
|
|
75
|
+
.watch(projectRoot, {
|
|
76
|
+
ignored: /node_modules|\.git|\.next/,
|
|
77
|
+
ignoreInitial: true,
|
|
78
|
+
})
|
|
79
|
+
.on("all", (event, filePath) => {
|
|
80
|
+
console.log(`⚡ File changed → ${filePath}`);
|
|
81
|
+
runPipeline();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
process.on("uncaughtException", (err) => {
|
|
85
|
+
console.log("\x1b[31m🔥 Crash:\x1b[0m", err.message);
|
|
86
|
+
running = false;
|
|
87
|
+
});
|
package/package.json
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-auto",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Auto Drizzle sync with tea script injection",
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.7",
|
|
6
4
|
"bin": {
|
|
7
5
|
"drizzle-auto": "index.js"
|
|
8
6
|
},
|
|
9
7
|
"scripts": {
|
|
10
8
|
"postinstall": "node index.js --postinstall"
|
|
11
9
|
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
14
|
-
},
|
|
15
|
-
"keywords": ["drizzle", "automation", "nextjs", "watcher", "tea"],
|
|
16
|
-
"author": "Pavel Ahmmed Hridoy",
|
|
17
|
-
"license": "MIT",
|
|
18
10
|
"dependencies": {
|
|
19
11
|
"chokidar": "^4.0.1",
|
|
20
12
|
"cross-spawn": "^7.0.6"
|