noxt-cli 0.1.6 → 0.1.7

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_start.js CHANGED
@@ -7,7 +7,7 @@ import { startServer } from 'noxt-server';
7
7
 
8
8
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
9
9
 
10
- export function execute([recipe], options) {
10
+ export async function execute([recipe], options) {
11
11
  // read deafault config
12
12
  let config = yaml.load(fs.readFileSync(path.resolve(__dirname, '../default.config.yaml'), 'utf8'));
13
13
 
@@ -41,25 +41,4 @@ export function execute([recipe], options) {
41
41
  console.log(`[noxt-server]`, err.stack);
42
42
  process.exit(1);
43
43
  });
44
-
45
44
  }
46
- function cmd_create() {
47
- // copy the starter pack from ./starter, but only if it is empty
48
- const starterPath = targetPath.resolve(__dirname, '../starter');
49
- const pathArg = args.shift();
50
- const targetPath = pathArg ? targetPath.resolve(process.cwd(), pathArg) : process.cwd();
51
- // if not exists, create recursively
52
- if (!fs.existsSync(targetPath)) {
53
- fs.mkdirSync(targetPath, { recursive: true });
54
- } else {
55
- // if not empty, except for node_modules, refuse to overwrite
56
- const files = fs.readdirSync(targetPath).filter(file => file !== 'node_modules');
57
- if (files.length) {
58
- die(`Directory ${targetPath} is not empty. Refusing to overwrite it.`);
59
- }
60
- }
61
- // recursively copy starterPath to targetPath
62
- fs.cpSync(starterPath, targetPath, { recursive: true });
63
- console.log(`Created noxt starter pack in ${targetPath}\ncd ${targetPath}\nnpx noxt-cli`);
64
- process.exit(0);
65
- }
package/bin/noxt-cli CHANGED
@@ -18,7 +18,7 @@ const { _: args, ...options } = minimist(process.argv.slice(2), {
18
18
  const cmd = args.shift() ?? 'start';
19
19
 
20
20
  if (cmd in commands) {
21
- commands[cmd].execute(args, options);
21
+ await commands[cmd].execute(args, options);
22
22
  } else {
23
23
  console.log(`Usage: noxt-cli <${Object.keys(commands).join('|')}> [options]`);
24
24
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noxt-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "CLI starter for noxt-server",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,3 @@
1
+ export function greet(name = 'world') {
2
+ return 'Hello ' + name;
3
+ }
@@ -0,0 +1,12 @@
1
+ import * as utils from '../lib/utils.js'
2
+
3
+ export const info = {
4
+ name: 'app/main',
5
+ version: '1.0.0',
6
+ description: 'Main module',
7
+ requires: ['noxt-dev']
8
+ }
9
+
10
+ export default mlm => ({
11
+ utils: {...utils}
12
+ })
@@ -1,6 +1,6 @@
1
1
  export const route = '/';
2
2
 
3
- export default function PageIndex({ tasks }, {
3
+ export default function PageIndex({ }, { utils } {
4
4
  // all components are available here
5
5
  Json, Sidebar,
6
6
  // so are request and response objects
@@ -11,11 +11,12 @@ export default function PageIndex({ tasks }, {
11
11
  slot,
12
12
  }) {
13
13
  slot('title', 'Welcome to Noxt');
14
+
14
15
  return (
15
16
  <article>
16
17
  <main>
17
- <h2>Here are some tasks</h2>
18
- <PageTasks.Link text="Tasks" />
18
+ <h2>{utils.greet('user')}</h2>
19
+ Here are some tasks: <PageTasks.Link text="Tasks" />
19
20
  </main>
20
21
  <aside>
21
22
  <Sidebar />