vaderjs 1.4.0-16b2234 → 1.4.0-90gbho234
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/README.md +2 -6
- package/binaries/main.js +10 -24
- package/package.json +1 -1
- package/vader.js +256 -41
package/README.md
CHANGED
|
@@ -17,14 +17,10 @@
|
|
|
17
17
|
> Do not use any alpha versions as these where changed multiple times any version under latest is considered lts and are deemed to be stable
|
|
18
18
|
## Get Started
|
|
19
19
|
|
|
20
|
-
1.
|
|
21
|
-
> Warning - do not use wsl version of bun with vader alot will not work due to path resolution use the experimental version :}
|
|
22
|
-
([Install Bun](https://bun.sh/docs/installation))
|
|
23
|
-
|
|
24
|
-
2. Install vaderjs
|
|
20
|
+
1. Install vaderjs
|
|
25
21
|
|
|
26
22
|
```bash
|
|
27
|
-
|
|
23
|
+
npx vaderjs@latest
|
|
28
24
|
```
|
|
29
25
|
|
|
30
26
|
4. Create Proper Folders
|
package/binaries/main.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
1
|
import { Glob } from "bun";
|
|
3
2
|
import fs from "fs";
|
|
4
3
|
import * as Bun from "bun";
|
|
@@ -606,17 +605,20 @@ switch (true) {
|
|
|
606
605
|
globalThis.mode = 'dev'
|
|
607
606
|
Server(port)
|
|
608
607
|
transForm()
|
|
608
|
+
|
|
609
609
|
Bun.spawn({
|
|
610
610
|
cwd: process.cwd() + '/node_modules/vaderjs/binaries/',
|
|
611
|
-
env:{
|
|
611
|
+
env: {
|
|
612
|
+
PWD: process.cwd(),
|
|
612
613
|
FOLDERS: 'pages,src,public',
|
|
613
|
-
|
|
614
|
+
onExit: (code) => {
|
|
615
|
+
globalThis.isBuilding = false
|
|
616
|
+
globalThis.oneAndDone = true
|
|
617
|
+
}
|
|
614
618
|
},
|
|
615
|
-
cmd: ['node', 'watcher.js'],
|
|
616
|
-
onExit: (code) => {
|
|
617
|
-
console.log('Exited', code)
|
|
618
|
-
}
|
|
619
|
+
cmd: ['node', 'watcher.js'],
|
|
619
620
|
})
|
|
621
|
+
|
|
620
622
|
const ws = new WebSocket(`ws://localhost:${3434}`)
|
|
621
623
|
ws.on('open', () => {
|
|
622
624
|
console.log('Watching for changes...')
|
|
@@ -668,23 +670,7 @@ url: http://localhost:${port}
|
|
|
668
670
|
Server(port)
|
|
669
671
|
break;
|
|
670
672
|
default:
|
|
671
|
-
|
|
672
|
-
console.log(`
|
|
673
|
-
Vader.js is a reactive framework for building interactive applications for the web built ontop of bun.js!
|
|
674
|
-
|
|
675
|
-
Usage: vader <command>
|
|
676
|
-
|
|
677
|
-
Commands:
|
|
678
|
-
|
|
679
|
-
vaderjs dev -p <number> Start the development server
|
|
680
|
-
|
|
681
|
-
vaderjs build Build the project to ./dist
|
|
682
|
-
|
|
683
|
-
vaderjs start -p <number> Production Mode (default 3000 or process.env.PORT)
|
|
684
|
-
|
|
685
|
-
Learn more about vader: https://vader-js.pages.dev/
|
|
686
|
-
|
|
687
|
-
`)
|
|
673
|
+
|
|
688
674
|
break;
|
|
689
675
|
|
|
690
676
|
}
|
package/package.json
CHANGED
package/vader.js
CHANGED
|
@@ -1,50 +1,265 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
globalThis.currentCommand = null;
|
|
5
|
+
let vaderisInstalled = process.cwd() + "/node_modules/vaderjs/vader.js";
|
|
6
|
+
if (!fs.existsSync(process.cwd() + "/_dev")) {
|
|
7
|
+
fs.mkdirSync(process.cwd() + "/_dev");
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
if(!fs.existsSync(process.cwd() +
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
10
|
+
if (!fs.existsSync(process.cwd() + "/_dev/vader.js")) {
|
|
11
|
+
console.log("Copying vader to dev folder....");
|
|
12
|
+
fs.copyFileSync(vaderisInstalled, process.cwd() + "/_dev/vader.js");
|
|
13
|
+
}
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
function checkIFBundleIsInstalled() {
|
|
16
|
+
if(fs.existsSync(process.cwd() + '/_dev/bun')){
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
resolve(true);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
exec("bun -v", (err, stdout, stderr) => {
|
|
23
|
+
if (err) {
|
|
24
|
+
reject(err);
|
|
25
|
+
}
|
|
26
|
+
if (stdout) {
|
|
27
|
+
resolve(`Bun.js is installed: ${stdout}`);
|
|
28
|
+
}
|
|
29
|
+
if (stderr) {
|
|
30
|
+
reject(`Bun.js is not installed: ${stderr}`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
14
35
|
|
|
15
|
-
function run(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
function run() {
|
|
37
|
+
if (!fs.existsSync(process.cwd() + "/package.json")) {
|
|
38
|
+
fs.writeFileSync(
|
|
39
|
+
process.cwd() + "/package.json",
|
|
40
|
+
JSON.stringify({ name: "my_app", version: "1.0.0" }, null, 2)
|
|
41
|
+
);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let packageJson = JSON.parse(
|
|
45
|
+
fs.readFileSync(process.cwd() + "/package.json").toString()
|
|
46
|
+
);
|
|
47
|
+
if (!packageJson.scripts) {
|
|
48
|
+
packageJson.scripts = {};
|
|
49
|
+
}
|
|
50
|
+
packageJson.scripts["dev"] = "bun run ./_dev/vader.js dev";
|
|
51
|
+
packageJson.scripts["build"] = "bun run ./_dev/vader.js build";
|
|
52
|
+
packageJson.scripts["start"] = "bun run ./_dev/vader.js start";
|
|
53
|
+
if (!packageJson.dependencies) {
|
|
54
|
+
packageJson.dependencies = {};
|
|
55
|
+
}
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
process.cwd() + "/package.json",
|
|
58
|
+
JSON.stringify(packageJson, null, 2)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if (currentCommand) {
|
|
63
|
+
let child = exec(currentCommand)
|
|
64
|
+
child.stdout.pipe(process.stdout);
|
|
65
|
+
child.stderr.pipe(process.stderr);
|
|
66
|
+
child.on('exit', (code) => {
|
|
67
|
+
process.exit(code);
|
|
68
|
+
});
|
|
69
|
+
child.on('message', (message) => {
|
|
70
|
+
console.log(message.toString());
|
|
71
|
+
});
|
|
72
|
+
child.on('error', (err) => {
|
|
73
|
+
console.error(err);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(`
|
|
80
|
+
Vader.js is a reactive framework for building interactive applications for the web built ontop of bun.js!
|
|
81
|
+
|
|
82
|
+
Usage: npx vaderjs <command>
|
|
83
|
+
|
|
84
|
+
Commands:
|
|
41
85
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Learn more about vader: https://vader-js.pages.dev/
|
|
86
|
+
vaderjs run dev -p <number> Start the development server
|
|
45
87
|
|
|
46
|
-
|
|
88
|
+
vaderjs run build Build the project to ./dist
|
|
89
|
+
|
|
90
|
+
vaderjs run start -p <number> Production Mode (default 3000 or process.env.PORT)
|
|
91
|
+
|
|
92
|
+
Learn more about vader: https://vader-js.pages.dev/
|
|
93
|
+
|
|
94
|
+
`);
|
|
95
|
+
|
|
47
96
|
}
|
|
48
97
|
|
|
49
|
-
|
|
50
|
-
|
|
98
|
+
function checkIFChromeIumIsInstalled() {
|
|
99
|
+
let platform = process.platform;
|
|
100
|
+
let findChrome = {
|
|
101
|
+
windows:`powershell -c "${ process.cwd() + '\\test.ps1'}"`,
|
|
102
|
+
others: "/usr/bin/chromium-browser --version",
|
|
103
|
+
};
|
|
104
|
+
let installCommands = {
|
|
105
|
+
windows: `winget install Google.Chrome`,
|
|
106
|
+
others: "sudo apt-get install chromium-browser -y",
|
|
107
|
+
};
|
|
108
|
+
findChrome.windows = findChrome.windows.replace(/\n/g, " ");
|
|
109
|
+
let commandToRun =
|
|
110
|
+
platform === "win32" ? findChrome.windows : findChrome.others;
|
|
111
|
+
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
if(fs.existsSync(process.cwd() + '/_dev/chrome')){
|
|
114
|
+
resolve(true);
|
|
115
|
+
}else{
|
|
116
|
+
exec(commandToRun, (err, stdout, stderr) => {
|
|
117
|
+
let hasError = false;
|
|
118
|
+
if (err) {
|
|
119
|
+
console.log(err);
|
|
120
|
+
hasError = true;
|
|
121
|
+
console.log(
|
|
122
|
+
`Attempting to install DEPENDENCY: ${platform === "win32" ? "Google Chrome" : "Chromium"}`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
if (stdout && !hasError) {
|
|
126
|
+
resolve(
|
|
127
|
+
`${platform === "win32" ? "Google Chrome" : "Chromium"} is installed: ${stdout}`
|
|
128
|
+
);
|
|
129
|
+
fs.writeFileSync(process.cwd() + '/_dev/chrome', `Installed: ${stdout}`);
|
|
130
|
+
run();
|
|
131
|
+
}
|
|
132
|
+
if (stderr) {
|
|
133
|
+
console.log(stderr);
|
|
134
|
+
console.log(
|
|
135
|
+
`Installing DEPENDENCY: ${platform === "win32" ? "Google Chrome" : "Chromium"}`
|
|
136
|
+
);
|
|
137
|
+
let installCommand =
|
|
138
|
+
platform === "win32"
|
|
139
|
+
? installCommands.windows
|
|
140
|
+
: installCommands.others;
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
exec(installCommand, (err, stdout, stderr) => {
|
|
143
|
+
if (err) {
|
|
144
|
+
reject(err);
|
|
145
|
+
}
|
|
146
|
+
if (stdout) {
|
|
147
|
+
resolve(
|
|
148
|
+
`${platform === "win32" ? "Google Chrome" : "Chromium"} installed successfully: ${stdout}`
|
|
149
|
+
);
|
|
150
|
+
fs.writeFileSync(process.cwd() + '/_dev/chrome', `Installed: ${stdout}`);
|
|
151
|
+
run();
|
|
152
|
+
}
|
|
153
|
+
if (stderr) {
|
|
154
|
+
reject(
|
|
155
|
+
`${platform === "win32" ? "Google Chrome" : "Chromium"} failed to install: ${stderr}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
let Commands = {
|
|
166
|
+
dev: `bun run dev`,
|
|
167
|
+
build: `bun run build`,
|
|
168
|
+
start: `bun run start`,
|
|
169
|
+
};
|
|
170
|
+
let port = process.argv.includes("-p") || process.argv.includes("--port")
|
|
171
|
+
? process.argv[process.argv.indexOf("-p") + 1] || process.argv[process.argv.indexOf("--port") + 1] || process.env.PORT || 3000
|
|
172
|
+
: process.env.PORT || 3000;
|
|
173
|
+
switch (true) {
|
|
174
|
+
case process.argv.includes("dev") &&
|
|
175
|
+
!process.argv.includes("build") &&
|
|
176
|
+
!process.argv.includes("start"):
|
|
177
|
+
|
|
178
|
+
currentCommand = Commands.dev + (port ? ` -p ${port}` : "");
|
|
179
|
+
break;
|
|
180
|
+
case process.argv.includes("build") &&
|
|
181
|
+
!process.argv.includes("dev") &&
|
|
182
|
+
!process.argv.includes("start"):
|
|
183
|
+
currentCommand = Commands.build + (port ? ` -p ${port}` : "");
|
|
184
|
+
break;
|
|
185
|
+
case process.argv.includes("start") &&
|
|
186
|
+
!process.argv.includes("dev") &&
|
|
187
|
+
!process.argv.includes("build"):
|
|
188
|
+
currentCommand = Commands.start + (port ? ` -p ${port}` : "");
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
currentCommand = null;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
checkIFChromeIumIsInstalled()
|
|
195
|
+
.then((stdout) => {
|
|
196
|
+
|
|
197
|
+
if (stdout) {
|
|
198
|
+
checkIFBundleIsInstalled()
|
|
199
|
+
.then((stdout) => {
|
|
200
|
+
if (stdout) {
|
|
201
|
+
if(!fs.existsSync(process.cwd() + '/_dev/bun')){
|
|
202
|
+
fs.writeFileSync(process.cwd() + "/_dev/bun", `Installed: ${stdout}`);
|
|
203
|
+
}
|
|
204
|
+
run();
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
.catch(async (err) => {
|
|
208
|
+
console.log("Bun.js is not installed. Installing....");
|
|
209
|
+
let installScipt = {
|
|
210
|
+
windows: 'powershell -c "irm bun.sh/install.ps1|iex',
|
|
211
|
+
others: "curl -fsSL https://bun.sh/install.sh | bash",
|
|
212
|
+
};
|
|
213
|
+
let scriptotRun =
|
|
214
|
+
process.platform === "win32"
|
|
215
|
+
? installScipt.windows
|
|
216
|
+
: installScipt.others;
|
|
217
|
+
exec(scriptotRun, async (err, stdout, stderr) => {
|
|
218
|
+
if (err) {
|
|
219
|
+
console.log("Error installing bun.js");
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
if (stdout) {
|
|
223
|
+
if (!platform === "win32") {
|
|
224
|
+
await new Promise((resolve, reject) => {
|
|
225
|
+
console.log(`Adding bun.js to path...`);
|
|
226
|
+
let shell = null;
|
|
227
|
+
exec("source ~/.bashrc", (err, stdout, stderr) => {
|
|
228
|
+
if (err) {
|
|
229
|
+
console.log("Error installing bun.js");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (stdout) {
|
|
233
|
+
run();
|
|
234
|
+
}
|
|
235
|
+
if (stderr) {
|
|
236
|
+
console.log("Error installing bun.js");
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
exec("chmod +x bun.sh/install.sh", (err, stdout, stderr) => {
|
|
242
|
+
if (err) {
|
|
243
|
+
console.log("Error installing bun.js");
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (stdout) {
|
|
247
|
+
console.log("Bun.js installed successfully");
|
|
248
|
+
run();
|
|
249
|
+
}
|
|
250
|
+
if (stderr) {
|
|
251
|
+
console.log("Error installing bun.js");
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
run();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
})
|
|
262
|
+
.catch(async (err) => {
|
|
263
|
+
console.error(err);
|
|
264
|
+
process.exit(1);
|
|
265
|
+
});
|