noxt-cli 0.1.6 → 0.1.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/bin/cmd_start.js +11 -23
- package/bin/noxt-cli +1 -1
- package/package.json +1 -1
- package/starter/lib/utils.js +3 -0
- package/starter/units/main.js +12 -0
- package/starter/views/pages/PageIndex.jsx +4 -3
package/bin/cmd_start.js
CHANGED
|
@@ -7,7 +7,16 @@ import { startServer } from 'noxt-server';
|
|
|
7
7
|
|
|
8
8
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function die(msg) {
|
|
11
|
+
console.error(msg);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function warn(msg) {
|
|
16
|
+
console.warn(msg);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function execute([recipe], options) {
|
|
11
20
|
// read deafault config
|
|
12
21
|
let config = yaml.load(fs.readFileSync(path.resolve(__dirname, '../default.config.yaml'), 'utf8'));
|
|
13
22
|
|
|
@@ -31,7 +40,7 @@ export function execute([recipe], options) {
|
|
|
31
40
|
// override config with command line options
|
|
32
41
|
for (const key in options) {
|
|
33
42
|
if (!(key in config)) {
|
|
34
|
-
warn(`Unknown config option: ${key}`);
|
|
43
|
+
//warn(`Unknown config option: ${key}`);
|
|
35
44
|
}
|
|
36
45
|
config[key] = options[key] ?? config[key];
|
|
37
46
|
}
|
|
@@ -41,25 +50,4 @@ export function execute([recipe], options) {
|
|
|
41
50
|
console.log(`[noxt-server]`, err.stack);
|
|
42
51
|
process.exit(1);
|
|
43
52
|
});
|
|
44
|
-
|
|
45
53
|
}
|
|
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
|
export const route = '/';
|
|
2
2
|
|
|
3
|
-
export default function PageIndex({
|
|
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>
|
|
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 />
|