vaderjs 1.4.0-16b2234 → 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 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. Installing Bun.js - (Required)
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
- bun add vaderjs@latest
23
+ npx vaderjs@latest
28
24
  ```
29
25
 
30
26
  4. Create Proper Folders
@@ -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 lang="en">
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
@@ -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";
@@ -324,7 +323,7 @@ async function generateProviderRoutes(){
324
323
  }
325
324
  routes.forEach((r) => {
326
325
  if(r.path === '/'
327
- || prev.find((p) => p.source === '/'+ r.path + '/index.html')
326
+ || prev.find((p) => p.destination === '/'+ r.path + '/index.html')
328
327
  ){
329
328
  return void 0;
330
329
  }
@@ -556,6 +555,7 @@ async function transForm(){
556
555
 
557
556
 
558
557
  if(globalThis.mode === 'dev' && !globalThis.oneAndDone || globalThis.mode === 'build'){
558
+ console.log('Generating routes...')
559
559
 
560
560
  /**
561
561
  * @description - create an html file for each route
@@ -606,17 +606,20 @@ switch (true) {
606
606
  globalThis.mode = 'dev'
607
607
  Server(port)
608
608
  transForm()
609
+
609
610
  Bun.spawn({
610
611
  cwd: process.cwd() + '/node_modules/vaderjs/binaries/',
611
- env:{
612
+ env: {
613
+ PWD: process.cwd(),
612
614
  FOLDERS: 'pages,src,public',
613
- PWD: process.cwd(),
615
+ onExit: (code) => {
616
+ globalThis.isBuilding = false
617
+ globalThis.oneAndDone = true
618
+ }
614
619
  },
615
- cmd: ['node', 'watcher.js'],
616
- onExit: (code) => {
617
- console.log('Exited', code)
618
- }
620
+ cmd: ['node', 'watcher.js'],
619
621
  })
622
+
620
623
  const ws = new WebSocket(`ws://localhost:${3434}`)
621
624
  ws.on('open', () => {
622
625
  console.log('Watching for changes...')
@@ -668,23 +671,7 @@ url: http://localhost:${port}
668
671
  Server(port)
669
672
  break;
670
673
  default:
671
- // add color
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
- `)
674
+
688
675
  break;
689
676
 
690
677
  }
@@ -0,0 +1,7 @@
1
+ $chrometest = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
2
+
3
+ if($chrometest -eq $true){
4
+ Write-Host "Google Chrome is installed"
5
+ }else{
6
+ Write-Host "Google Chrome is not installed"
7
+ }
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-16b2234",
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 fs from 'fs';
3
- let vaderisInstalled = process.cwd() + '/node_modules/vaderjs/binaries/main.js'
4
- if(!fs.existsSync(process.cwd() +'/_dev')){
5
- fs.mkdirSync(process.cwd() +'/_dev');
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() +'/_dev/vader.js')){
9
- console.log('Copying vader to dev folder....')
10
- fs.copyFileSync(vaderisInstalled, process.cwd() +'/_dev/vader.js');
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
- let args = process.argv.slice(2);
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(arg){
16
- if(!fs.existsSync(process.cwd() + '/package.json')){
17
- fs.writeFileSync(process.cwd() + '/package.json', JSON.stringify({name: 'my_app', version: '1.0.0'}, null, 2));
18
- return;
19
- }
20
- let packageJson = JSON.parse(fs.readFileSync(process.cwd() + '/package.json').toString());
21
- if(!packageJson.scripts){
22
- packageJson.scripts = {};
23
- }
24
- packageJson.scripts['dev'] = 'bun run ./_dev/vader.js dev';
25
- packageJson.scripts['build'] = 'bun run ./_dev/vader.js build';
26
- packageJson.scripts['start'] = 'bun run ./_dev/vader.js start';
27
- if(!packageJson.dependencies){
28
- packageJson.dependencies = {};
29
- }
30
- fs.writeFileSync(process.cwd() + '/package.json', JSON.stringify(packageJson, null, 2));
31
- console.log(`
32
- Vader.js is a reactive framework for building interactive applications for the web built ontop of bun.js!
33
-
34
- Usage: vader <command>
35
-
36
- Commands:
37
-
38
- bun run dev -p <number> Start the development server
39
-
40
- bun run build Build the project to ./dist
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
- bun run start -p <number> Production Mode (default 3000 or process.env.PORT)
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
- run()
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
+ });