feat: create nu cli

This commit is contained in:
Pooya Parsa 2021-03-28 23:01:51 +02:00
parent 55f2b3c4c1
commit c9347e3f5b
6 changed files with 34 additions and 6 deletions

View File

@ -7,10 +7,9 @@
],
"scripts": {
"link": "lerna link",
"nuxt": "jiti ./scripts/nuxt",
"build": "yarn workspaces run build --silent",
"stub": "yarn workspaces run stub --silent",
"play": "yarn nuxt dev playground",
"play": "yarn nu dev playground",
"lint": "eslint --ext .vue,.ts,.js .",
"test": "yarn lint",
"postinstall": "yarn stub"

3
packages/nu/bin/nu.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('..').main()

24
packages/nu/package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "@nuxt/nu",
"version": "0.0.0",
"repository": "nuxt/framework",
"license": "MIT",
"main": "./dist/index.js",
"bin": {
"nu": "./bin/nu.js"
},
"files": [
"bin",
"dist"
],
"scripts": {
"build": "jiti ../../scripts/build .",
"stub": "yarn build --stub",
"prepublishOnly": "yarn build"
},
"build": {
"entries": {
"index": { "format": "cjs" }
}
}
}

View File

@ -1,17 +1,20 @@
import { resolve } from 'path'
import { loadNuxt } from './core/load'
import { build } from './builder'
async function _main () {
const args = process.argv.splice(2)
const cmd = args[0]
if (!['dev', 'build'].includes(cmd)) {
// eslint-disable-next-line no-console
console.error('Usage nuxt dev|build [rootDir]')
process.exit(1)
}
const isDev = cmd === 'dev'
const rootDir = resolve(process.cwd(), args[1] || '.')
const { loadNuxt, build } = await import('nuxt3')
const nuxt = await loadNuxt({ for: isDev ? 'dev' : 'build', rootDir })
if (isDev) {

View File

@ -1,3 +1,3 @@
export { loadNuxt } from './core'
export { build } from './builder'
export { main } from './cli'
export { main } from '../../nu/src'

View File

@ -1 +0,0 @@
require('nuxt3').main()