noxt-cli 0.1.14 → 0.1.15

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/bin/cmd_create.js CHANGED
@@ -10,6 +10,12 @@ import {
10
10
  import { spawnSync } from 'child_process';
11
11
 
12
12
  const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const { _: args, ...options } = minimist(process.argv.slice(2), {
14
+ string: ['views'], // treat as strings
15
+ unknown: (arg) => true
16
+ });
17
+
18
+ execute(args, options);
13
19
 
14
20
  async function copyDir(src, dest) {
15
21
  await mkdir(dest, { recursive: true });
package/bin/cmd_start.js CHANGED
@@ -3,9 +3,15 @@ import fs from 'fs';
3
3
  import path from 'path';
4
4
  import yaml from 'js-yaml';
5
5
  import { startServer } from 'noxt-server';
6
+ import minimist from 'minimist';
6
7
  //import 'console-with-location';
7
8
 
8
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
9
+
10
+ const { _: args, ...options } = minimist(process.argv.slice(2), {
11
+ string: ['views'], // treat as strings
12
+ unknown: (arg) => true
13
+ });
14
+ await execute(args, options);
9
15
 
10
16
  function die(msg) {
11
17
  console.error(msg);
@@ -18,7 +24,7 @@ function warn(msg) {
18
24
 
19
25
  export async function execute([recipe], options) {
20
26
  // read deafault config
21
- let config = yaml.load(fs.readFileSync(path.resolve(__dirname, '../default.config.yaml'), 'utf8'));
27
+ let config = {} // yaml.load(fs.readFileSync(path.resolve(__dirname, '../default.config.yaml'), 'utf8'));
22
28
 
23
29
  // read local config if exists
24
30
  const configPath = 'noxt.config.yaml';
@@ -45,8 +51,7 @@ export async function execute([recipe], options) {
45
51
  config[key] = options[key] ?? config[key];
46
52
  }
47
53
 
48
-
49
- startServer({ config, recipe }).catch(err => {
54
+ startServer({ config, recipe, import: p => import(p) }).catch(err => {
50
55
  console.error(`[noxt-server] Error starting server: ${err.message}`);
51
56
  console.log(`[noxt-server]`, err.stack);
52
57
  process.exit(1);
package/bin/noxt-cli CHANGED
@@ -1,25 +1,15 @@
1
- #!/usr/bin/env node
2
- import minimist from 'minimist';
3
- //import 'console-with-location';
1
+ #!/bin/sh
2
+ echo "Noxt CLI"
3
+ SCRIPT_DIR="$(dirname "$(realpath "$0")")"
4
4
 
5
- import * as cmd_start from './cmd_start.js';
6
- import * as cmd_create from './cmd_create.js';
5
+ if [ "$1" = "start" ]; then
6
+ node --input-type=module -e "$(cat "$SCRIPT_DIR/cmd_start.js")" "$@"
7
+ exit
8
+ fi
7
9
 
8
- const commands = {
9
- start: cmd_start,
10
- create: cmd_create,
11
- };
10
+ if [ "$1" = "create" ]; then
11
+ cat $(dirname $(realpath $0))/cmd_create.js | node - "$@"
12
+ exit
13
+ fi
12
14
 
13
- const { _: args, ...options } = minimist(process.argv.slice(2), {
14
- string: ['views'], // treat as strings
15
- unknown: (arg) => true
16
- });
17
-
18
- const cmd = args.shift() ?? 'start';
19
-
20
- if (cmd in commands) {
21
- await commands[cmd].execute(args, options);
22
- } else {
23
- console.log(`Usage: noxt-cli <${Object.keys(commands).join('|')}> [options]`);
24
- process.exit(1);
25
- }
15
+ echo "Usage: noxt-cli <start|create> [options]"
@@ -1,7 +1,5 @@
1
1
  port: 3000
2
2
  ssl: false
3
3
  host: localhost
4
- logLevel: info
5
- views: []
6
- static: []
7
- context: []
4
+ views: views
5
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noxt-cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "CLI starter for noxt-server",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "author": "Zoran Obradović [https://github.com/zocky]",
23
23
  "license": "GPL-3.0-or-later",
24
- "dependencies": {
24
+ "peerDependencies": {
25
25
  "js-yaml": "^4.1.0",
26
26
  "minimist": "^1.2.8",
27
27
  "noxt-server": "^0.1.14"
@@ -8,7 +8,11 @@
8
8
  "dev": "nodemon -e js,jsx,css,yaml,json,html --exec noxt-cli start app/main",
9
9
  "prod": "NODE_ENV=production noxt-cli start app/main"
10
10
  },
11
+ "dependencies": {
12
+ "minimist": "^1.2.8"
13
+ },
11
14
  "devDependencies": {
15
+ "noxt-server": "^0.1.14",
12
16
  "nodemon": "^3.0.1"
13
17
  }
14
18
  }
@@ -4,17 +4,17 @@ export const fetch = {
4
4
  tasks: 'https://jsonplaceholder.typicode.com/todos'
5
5
  }
6
6
 
7
- export default function PageTasks({ tasks }, {
7
+ export default async function PageTasks({ tasks }, {
8
8
  // all components are available here
9
9
  Json, PageTask, Sidebar,
10
10
  // so are request and response objects
11
11
  req, res, params,
12
12
  // utils are extendable by your units in ../../units
13
13
  utils,
14
- // use slot(name,key,value) to pass values to the layout
14
+ // use await slot(name,key,value) to pass values to the layout
15
15
  slot,
16
16
  }) {
17
- slot('title', 'main', 'Tasks');
17
+ await slot('title', 'main', 'Tasks');
18
18
  return (
19
19
  <>
20
20
  <main>