vaderjs 1.4.0-169o234 → 1.4.0-22bho234
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 -7
- package/binaries/generator.js +2 -6
- package/binaries/main.js +2 -1
- package/binaries/win32/check.ps1 +7 -0
- package/package.json +1 -2
- package/vader.js +257 -41
package/README.md
CHANGED
|
@@ -17,15 +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 on windows it will not work due to path resolution use the experimental version :}
|
|
22
|
-
|
|
23
|
-
([Install Bun](https://bun.sh/docs/installation))
|
|
24
|
-
|
|
25
|
-
2. Install vaderjs
|
|
20
|
+
1. Install vaderjs
|
|
26
21
|
|
|
27
22
|
```bash
|
|
28
|
-
|
|
23
|
+
npx vaderjs@latest
|
|
29
24
|
```
|
|
30
25
|
|
|
31
26
|
4. Create Proper Folders
|
package/binaries/generator.js
CHANGED
|
@@ -89,11 +89,9 @@ wss.on("connection", async function connection(ws) {
|
|
|
89
89
|
baseFolder = baseFolder.replace("//", "/");
|
|
90
90
|
globalThis.routeDocuments[folder] = `<!DOCTYPE html>
|
|
91
91
|
|
|
92
|
-
<html
|
|
92
|
+
<html>
|
|
93
93
|
<head>
|
|
94
94
|
<meta charset="UTF-8">
|
|
95
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
96
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
97
95
|
<title>Document</title>
|
|
98
96
|
<script id="server">
|
|
99
97
|
window.$SERVER = true
|
|
@@ -197,6 +195,4 @@ wss.on("connection", async function connection(ws) {
|
|
|
197
195
|
|
|
198
196
|
}
|
|
199
197
|
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
});
|
package/binaries/main.js
CHANGED
|
@@ -323,7 +323,7 @@ async function generateProviderRoutes(){
|
|
|
323
323
|
}
|
|
324
324
|
routes.forEach((r) => {
|
|
325
325
|
if(r.path === '/'
|
|
326
|
-
|| prev.find((p) => p.
|
|
326
|
+
|| prev.find((p) => p.destination === '/'+ r.path + '/index.html')
|
|
327
327
|
){
|
|
328
328
|
return void 0;
|
|
329
329
|
}
|
|
@@ -555,6 +555,7 @@ async function transForm(){
|
|
|
555
555
|
|
|
556
556
|
|
|
557
557
|
if(globalThis.mode === 'dev' && !globalThis.oneAndDone || globalThis.mode === 'build'){
|
|
558
|
+
console.log('Generating routes...')
|
|
558
559
|
|
|
559
560
|
/**
|
|
560
561
|
* @description - create an html file for each route
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "vaderjs",
|
|
3
3
|
"description": "A Reactive library aimed to helping you build reactive applications inspired by react.js",
|
|
4
4
|
"module": "vader.js",
|
|
5
|
-
"version": "1.4.0-
|
|
5
|
+
"version": "1.4.0-22bho234",
|
|
6
6
|
"bin": {
|
|
7
7
|
"vader": "./vader.js"
|
|
8
8
|
},
|
|
@@ -32,6 +32,5 @@
|
|
|
32
32
|
"dotenv":"latest",
|
|
33
33
|
"prettier": "latest",
|
|
34
34
|
"source-map": "latest"
|
|
35
|
-
|
|
36
35
|
}
|
|
37
36
|
}
|
package/vader.js
CHANGED
|
@@ -1,50 +1,266 @@
|
|
|
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
|
+
globalThis.isRunning = false;
|
|
6
|
+
let vaderisInstalled = process.cwd() + "/node_modules/vaderjs/vader.js";
|
|
7
|
+
if (!fs.existsSync(process.cwd() + "/_dev")) {
|
|
8
|
+
fs.mkdirSync(process.cwd() + "/_dev");
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
if(!fs.existsSync(process.cwd() +
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
11
|
+
if (!fs.existsSync(process.cwd() + "/_dev/vader.js")) {
|
|
12
|
+
console.log("Copying vader to dev folder....");
|
|
13
|
+
fs.copyFileSync(vaderisInstalled, process.cwd() + "/_dev/vader.js");
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
function checkIFBundleIsInstalled() {
|
|
17
|
+
if(fs.existsSync(process.cwd() + '/_dev/bun')){
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
resolve(true);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
exec("bun -v", (err, stdout, stderr) => {
|
|
24
|
+
if (err) {
|
|
25
|
+
reject(err);
|
|
26
|
+
}
|
|
27
|
+
if (stdout) {
|
|
28
|
+
resolve(`Bun.js is installed: ${stdout}`);
|
|
29
|
+
}
|
|
30
|
+
if (stderr) {
|
|
31
|
+
reject(`Bun.js is not installed: ${stderr}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
14
36
|
|
|
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
|
-
|
|
37
|
+
function run() {
|
|
38
|
+
if (!fs.existsSync(process.cwd() + "/package.json")) {
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
process.cwd() + "/package.json",
|
|
41
|
+
JSON.stringify({ name: "my_app", version: "1.0.0" }, null, 2)
|
|
42
|
+
);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let packageJson = JSON.parse(
|
|
46
|
+
fs.readFileSync(process.cwd() + "/package.json").toString()
|
|
47
|
+
);
|
|
48
|
+
if (!packageJson.scripts) {
|
|
49
|
+
packageJson.scripts = {};
|
|
50
|
+
}
|
|
51
|
+
packageJson.scripts["dev"] = "bun run ./_dev/vader.js dev";
|
|
52
|
+
packageJson.scripts["build"] = "bun run ./_dev/vader.js build";
|
|
53
|
+
packageJson.scripts["start"] = "bun run ./_dev/vader.js start";
|
|
54
|
+
if (!packageJson.dependencies) {
|
|
55
|
+
packageJson.dependencies = {};
|
|
56
|
+
}
|
|
57
|
+
fs.writeFileSync(
|
|
58
|
+
process.cwd() + "/package.json",
|
|
59
|
+
JSON.stringify(packageJson, null, 2)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if (currentCommand) {
|
|
64
|
+
let child = exec(currentCommand)
|
|
65
|
+
child.stdout.pipe(process.stdout);
|
|
66
|
+
child.stderr.pipe(process.stderr);
|
|
67
|
+
child.on('exit', (code) => {
|
|
68
|
+
process.exit(code);
|
|
69
|
+
});
|
|
70
|
+
child.on('message', (message) => {
|
|
71
|
+
console.log(message.toString());
|
|
72
|
+
});
|
|
73
|
+
child.on('error', (err) => {
|
|
74
|
+
console.error(err);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log(`
|
|
81
|
+
Vader.js is a reactive framework for building interactive applications for the web built ontop of bun.js!
|
|
82
|
+
|
|
83
|
+
Usage: npx vaderjs <command>
|
|
84
|
+
|
|
85
|
+
Commands:
|
|
41
86
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Learn more about vader: https://vader-js.pages.dev/
|
|
87
|
+
vaderjs run dev -p <number> Start the development server
|
|
45
88
|
|
|
46
|
-
|
|
89
|
+
vaderjs run build Build the project to ./dist
|
|
90
|
+
|
|
91
|
+
vaderjs run start -p <number> Production Mode (default 3000 or process.env.PORT)
|
|
92
|
+
|
|
93
|
+
Learn more about vader: https://vader-js.pages.dev/
|
|
94
|
+
|
|
95
|
+
`);
|
|
96
|
+
|
|
47
97
|
}
|
|
48
98
|
|
|
49
|
-
|
|
50
|
-
|
|
99
|
+
function checkIFChromeIumIsInstalled() {
|
|
100
|
+
let platform = process.platform;
|
|
101
|
+
let findChrome = {
|
|
102
|
+
windows:`powershell -c "${ process.cwd() + '\\node_modules\\vaderjs\\binaries\\win32\\check.ps1'}"`,
|
|
103
|
+
others: "/usr/bin/chromium-browser --version",
|
|
104
|
+
};
|
|
105
|
+
let installCommands = {
|
|
106
|
+
windows: `winget install Google.Chrome`,
|
|
107
|
+
others: "sudo apt-get install chromium-browser -y",
|
|
108
|
+
};
|
|
109
|
+
findChrome.windows = findChrome.windows.replace(/\n/g, " ");
|
|
110
|
+
let commandToRun =
|
|
111
|
+
platform === "win32" ? findChrome.windows : findChrome.others;
|
|
112
|
+
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
if(fs.existsSync(process.cwd() + '/_dev/chrome')){
|
|
115
|
+
resolve(true);
|
|
116
|
+
}else{
|
|
117
|
+
exec(commandToRun, (err, stdout, stderr) => {
|
|
118
|
+
let hasError = false;
|
|
119
|
+
if (err) {
|
|
120
|
+
console.log(err);
|
|
121
|
+
hasError = true;
|
|
122
|
+
console.log(
|
|
123
|
+
`Attempting to install DEPENDENCY: ${platform === "win32" ? "Google Chrome" : "Chromium"}`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (stdout && !hasError) {
|
|
127
|
+
resolve(
|
|
128
|
+
`${platform === "win32" ? "Google Chrome" : "Chromium"} is installed: ${stdout}`
|
|
129
|
+
);
|
|
130
|
+
fs.writeFileSync(process.cwd() + '/_dev/chrome', `Installed: ${stdout}`);
|
|
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 && !isRunning) {
|
|
201
|
+
if(!fs.existsSync(process.cwd() + '/_dev/bun')){
|
|
202
|
+
fs.writeFileSync(process.cwd() + "/_dev/bun", `Installed: ${stdout}`);
|
|
203
|
+
}
|
|
204
|
+
run();
|
|
205
|
+
globalThis.isRunning = true;
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
.catch(async (err) => {
|
|
209
|
+
console.log("Bun.js is not installed. Installing....");
|
|
210
|
+
let installScipt = {
|
|
211
|
+
windows: 'powershell -c "irm bun.sh/install.ps1|iex',
|
|
212
|
+
others: "curl -fsSL https://bun.sh/install.sh | bash",
|
|
213
|
+
};
|
|
214
|
+
let scriptotRun =
|
|
215
|
+
process.platform === "win32"
|
|
216
|
+
? installScipt.windows
|
|
217
|
+
: installScipt.others;
|
|
218
|
+
exec(scriptotRun, async (err, stdout, stderr) => {
|
|
219
|
+
if (err) {
|
|
220
|
+
console.log("Error installing bun.js");
|
|
221
|
+
process.exit(1);
|
|
222
|
+
}
|
|
223
|
+
if (stdout) {
|
|
224
|
+
if (!platform === "win32") {
|
|
225
|
+
await new Promise((resolve, reject) => {
|
|
226
|
+
console.log(`Adding bun.js to path...`);
|
|
227
|
+
let shell = null;
|
|
228
|
+
exec("source ~/.bashrc", (err, stdout, stderr) => {
|
|
229
|
+
if (err) {
|
|
230
|
+
console.log("Error installing bun.js");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (stdout) {
|
|
234
|
+
run();
|
|
235
|
+
}
|
|
236
|
+
if (stderr) {
|
|
237
|
+
console.log("Error installing bun.js");
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
exec("chmod +x bun.sh/install.sh", (err, stdout, stderr) => {
|
|
243
|
+
if (err) {
|
|
244
|
+
console.log("Error installing bun.js");
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (stdout) {
|
|
248
|
+
console.log("Bun.js installed successfully");
|
|
249
|
+
run();
|
|
250
|
+
}
|
|
251
|
+
if (stderr) {
|
|
252
|
+
console.log("Error installing bun.js");
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
run();
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
.catch(async (err) => {
|
|
264
|
+
console.error(err);
|
|
265
|
+
process.exit(1);
|
|
266
|
+
});
|