@bananacool467/authtics-host 0.2.7 → 0.2.8

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
@@ -1,6 +1,6 @@
1
1
  # Authtics Host
2
2
 
3
- Version 0.2.7, License: MIT
3
+ Version 0.2.8, License: MIT
4
4
 
5
5
  Authtics Host is a web framework inspired by Next.js. Authtics Host supports SSR (Server-Side Rendering), SSG (Static Site Generation), CSR (Client-Side Rendering) and SRTWS (Site Rendering Through WebSockets) and uses **Esbuild**. This is not to be confused with auth platforms.
6
6
 
@@ -17,6 +17,11 @@ or
17
17
  npm install @bananacool467/authtics-host@latest
18
18
  ```
19
19
 
20
+ You may have to get **React** and **React DOM**:
21
+ ```bash
22
+ npm i @types/react @types/react-dom
23
+ ```
24
+
20
25
  You can have auto paging enabled, auto paging checks your given directory for HTML and TSX files and then adds them to route. If auto filing is enabled, auto filing will check your given directory for files and add them accessible to route.
21
26
 
22
27
  To make your app, with auto paging and auto filing, your file tree should look like:
@@ -172,6 +177,11 @@ To run the project use:
172
177
  node --experimental-strip-types index.ts
173
178
  ```
174
179
 
180
+ Or:
181
+ ```
182
+ hostjs start
183
+ ```
184
+
175
185
  ## Result
176
186
 
177
187
  Then when you run your project, you will get a page just saying **"Hello, World!"** and you should see a clickable Developer Panel at the bottom-right.
@@ -366,6 +376,33 @@ There isn't any limit of DATs you can add.
366
376
 
367
377
  **(Note: Adding your DAT will give you access to Restart and Shutdown and Pause/Resume Users and other features in the Developer Panel)**
368
378
 
379
+ ## HostJS commands
380
+
381
+ There are 3 different HostJS commands:
382
+
383
+ ```bash
384
+ hostjs -v
385
+ # or:
386
+ hostjs --version
387
+ # or:
388
+ hostjs version
389
+ ```
390
+ Returns the current HostJS *version*.
391
+
392
+ ```bash
393
+ hostjs help
394
+ ```
395
+ Returns all the avaliable HostJS commands.
396
+
397
+ ```bash
398
+ hostjs start
399
+ ```
400
+ Runs `node --experimental-strip-types index.ts` but you can use:
401
+ ```bash
402
+ hostjs start path/to/script.ts
403
+ ```
404
+ Which runs the same command but uses the path to the script instead of `index.ts`
405
+
369
406
  ## Reasons for the name, Authtics Host
370
407
 
371
408
  I named this web framework Authtics Host because it uses DAT (For the **Auth**tics part) for developer authentication for dev panel, and for "Host" is because it let's the developer **Restart**/**Shutdown** the server.
package/bin/hostjs.js ADDED
@@ -0,0 +1,62 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { logger } from './logger.js';
3
+ import { spawnSync } from 'node:child_process';
4
+ import path from "node:path";
5
+ import fs from "node:fs/promises";
6
+ import url from "node:url";
7
+
8
+ const { positionals } = parseArgs({
9
+ allowPositionals: true
10
+ });
11
+
12
+ const [arg, arg2] = positionals;
13
+ if ( !arg ) {
14
+ process.exit(0);
15
+ }
16
+
17
+ if ( arg != "help" && arg != "version" && arg != "--version" && arg != "start" && arg != "-v" ) {
18
+ logger.error(`Unknown command: \x1b[33m${arg}`);
19
+ logger.skip();
20
+ logger.notice("You can get commands by typing \"hostjs help\".");
21
+ process.exit(1);
22
+ } else if ( arg == "help" ) {
23
+ logger.log("Avaliable HostJS commands:");
24
+ logger.skip();
25
+ logger.log(" help => Get help with HostJS commands.");
26
+ logger.log(" version => See the current downloaded version.");
27
+ logger.log(" [-v|--version] => Other ways to get version.");
28
+ logger.log(" start => Start your website.");
29
+ } else if ( arg == "start" ) {
30
+ logger.notice("Starting...");
31
+ let file = "index.ts";
32
+ const command = "node";
33
+ const commandArg = "--experimental-strip-types";
34
+ if ( arg2 != null ) file = arg2;
35
+
36
+ const result = spawnSync(command, [commandArg, file], { stdio: 'inherit' });
37
+
38
+ if ( result.status !== 0 ) {
39
+ logger.error(`Process exited with code ${result.status}`);
40
+ process.exit(result.status || 1);
41
+ }
42
+ } else if ( arg == "-v" || arg == "version" || arg == "--version" ) {
43
+ const __filename = url.fileURLToPath(import.meta.url);
44
+ const __dirname = path.dirname(__filename);
45
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
46
+ async function loadPackageConfig() {
47
+ try {
48
+ const rawData = await fs.readFile(packageJsonPath, 'utf-8');
49
+
50
+ const packageJson = JSON.parse(rawData);
51
+
52
+ return packageJson
53
+ } catch (error) {
54
+ logger.error('Failed to read package.json:', error);
55
+ process.exit(1);
56
+ }
57
+ }
58
+
59
+ const package_ = await loadPackageConfig();
60
+ logger.notice(`Authtics Host version: ${package_.version}`);
61
+ }
62
+ process.exit(0);
package/bin/logger.js ADDED
@@ -0,0 +1,29 @@
1
+ function skip () {
2
+ return console.log('');
3
+ }
4
+
5
+ function error (msg) {
6
+ return console.error(`[HostJS \x1b[31mError\x1b[0m]: \x1b[31m${msg}\x1b[0m`);
7
+ }
8
+
9
+ function notice (msg) {
10
+ return console.log(`[HostJS \x1b[32mNotice\x1b[0m]: \x1b[32m${msg}\x1b[0m`)
11
+ }
12
+
13
+ function log (msg) {
14
+ return console.log(msg);
15
+ }
16
+
17
+ function warn (msg) {
18
+ return console.log(`[HostJS \x1b[33mWarn\x1b[0m]: \x1b[33m${msg}\x1b[0m`)
19
+ }
20
+
21
+ const logger = {
22
+ skip,
23
+ error,
24
+ notice,
25
+ log,
26
+ warn
27
+ }
28
+
29
+ export { logger };
package/dist/devPanel.js CHANGED
@@ -1081,7 +1081,7 @@ export default function DevPanel() {
1081
1081
  alignItems: 'center',
1082
1082
  whiteSpace: 'nowrap',
1083
1083
  gap: '4px'
1084
- }, children: [_jsx(ShieldCheck, { size: 16, color: "#f472b6", style: { flexShrink: 0 } }), " Authtics Host"] }), _jsxs("p", { style: { color: 'red', fontSize: '12px' }, children: ["Error found (", selectedError, "/", errors.length, ")"] }), _jsx(PanelButton, { onClick: () => { setErrorBoxOpen(false); sleepErrorNotifications(); }, style: { marginLeft: 'auto', }, children: "Close" })] }), _jsxs("div", { style: {
1084
+ }, children: [_jsx(ShieldCheck, { size: 16, color: "#f472b6", style: { flexShrink: 0 } }), " Authtics Host"] }), _jsxs("p", { style: { color: 'red', fontSize: '12px' }, children: ["Error found (", selectedError, "/", errors.length, ")"] }), _jsx(PanelButton, { onClick: () => { setErrorBoxOpen(false); sleepErrorNotifications(); setErrors([]); setSelectedError(1); }, style: { marginLeft: 'auto', }, children: "Close" })] }), _jsxs("div", { style: {
1085
1085
  padding: '6px 2px',
1086
1086
  display: 'flex',
1087
1087
  alignItems: 'center',
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@bananacool467/authtics-host",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Authtics Host, A Next.js-inspired web framework for Node.js and React with TypeScript and JSX support.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "bin": {
10
- "host": "dist/cli.js"
10
+ "hostjs": "./bin/hostjs.js"
11
11
  },
12
12
  "exports": {
13
13
  ".": "./dist/index.js"