Skip to content

Commit

Permalink
allow root as positional argument, more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Feb 19, 2025
1 parent a414c67 commit 59421e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/nuekit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function runCommand(args) {
// create nue
if (cmd == 'create') {
const { create } = await import('./create.js')
return await create({ ...args, root, name: args.paths[0], port })
return await create({ ...args, root, port })
}

const nue = await createKit(args)
Expand Down
9 changes: 5 additions & 4 deletions packages/nuekit/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ async function serve(args) {
}

export async function create(args = {}) {
if (!args.name) args.name = 'simple-blog'
if (!args.root) args.root = args.name
if (!args.name) args.name = args.paths.shift() || 'simple-blog'
if (!args.root) args.root = args.paths.shift() || args.name

// debug mode with: `nue create test`
args.debug = args.name == 'test'
Expand All @@ -30,7 +30,7 @@ export async function create(args = {}) {
const { debug, name, root } = args

// check if template exists
if (!Object.keys(templates).includes(name)){
if (!Object.keys(templates).includes(name)) {
console.error(`Template "${name}" does not exist!`)
console.error('Available templates:')
for (const t of Object.keys(templates)) console.error(' -', t)
Expand All @@ -51,7 +51,7 @@ export async function create(args = {}) {

// download archive
console.info('Loading template...')
const archive_name = join(root, `${name}-source.tar.gz`)
const archive_name = join(root, 'source.tar.gz')
const archive_web = `https://${name}.nuejs.org/${debug ? 'test' : 'source'}.tar.gz`
const archive = await fetch(archive_web)

Expand All @@ -66,5 +66,6 @@ export async function create(args = {}) {
await fs.rm(archive_name)

// serve
console.info(`Created template "${name}" to "${root}".`)
return await serve(args)
}

2 comments on commit 59421e2

@nobkd
Copy link
Collaborator Author

@nobkd nobkd commented on 59421e2 Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can now use create like this: nue create simple-blog mydir instead of nue create simple-blog -r mydir. Though if both are used, like nue create simple-blog myotherdir -r mydir, the -r option has priority

@tipiirai
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

Please sign in to comment.