-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: consola tags
- Loading branch information
Showing
22 changed files
with
223 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,41 @@ | ||
import { resolve } from 'path' | ||
import rollupBabel from 'rollup-plugin-babel' | ||
import commonJS from 'rollup-plugin-commonjs' | ||
import nodeResolve from 'rollup-plugin-node-resolve' | ||
import license from 'rollup-plugin-license' | ||
|
||
import packageJson from '../package.json' | ||
import pck from '../package.json' | ||
import nuxt from '../node_modules/nuxt/package.json' | ||
|
||
const dependencies = [ | ||
'os', | ||
'cluster', | ||
...Object.keys(packageJson.dependencies), | ||
...Object.keys(require('../node_modules/nuxt/package.json').dependencies) | ||
'fs', | ||
'os', | ||
'path', | ||
'util', | ||
...Object.keys(pck.dependencies), | ||
...Object.keys(nuxt.dependencies) | ||
] | ||
|
||
const version = packageJson.version || process.env.VERSION | ||
|
||
// ----------------------------- | ||
// Banner | ||
// ----------------------------- | ||
const banner = | ||
'/*!\n' + | ||
' * Nuxt-Generate-Cluster v' + version + '\n' + | ||
' * Released under the MIT License.\n' + | ||
' */' | ||
|
||
const plugins = [] | ||
Object.keys(nuxt.dependencies).forEach((nuxtPkg) => { | ||
const pck = require(`../node_modules/${nuxtPkg}/package.json`) | ||
Array.prototype.push.apply(dependencies, Object.keys(pck.dependencies).filter(p => !dependencies.includes(p))) | ||
}) | ||
|
||
// ----------------------------- | ||
// Aliases | ||
// ----------------------------- | ||
const rootDir = resolve(__dirname, '..') | ||
|
||
export default { | ||
export default [{ | ||
input: resolve(rootDir, 'lib', 'index.js'), | ||
output: { | ||
name: 'Nuxt Generate Cluster', | ||
file: resolve(rootDir, 'dist', 'generator.js'), | ||
format: 'cjs', | ||
preferConst: true, | ||
sourcemap: true | ||
}, | ||
external: dependencies, | ||
plugins: [ | ||
nodeResolve({ preferBuiltins: true }), | ||
commonJS(), | ||
license({ banner }) | ||
].concat(plugins) | ||
} | ||
nodeResolve({ | ||
only: [/lodash/] | ||
}), | ||
commonJS() | ||
] | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import path from 'path' | ||
import consola from 'consola' | ||
|
||
const localNodeModules = path.resolve(process.cwd(), 'node_modules') | ||
|
||
// Prefer importing modules from local node_modules (for NPX and global bin) | ||
async function _import(modulePath) { | ||
let m | ||
for (const mp of [ path.resolve(localNodeModules, modulePath), modulePath ]) { | ||
try { | ||
m = await import(mp) | ||
} catch (e) { | ||
/* istanbul ignore next */ | ||
if (e.code !== 'MODULE_NOT_FOUND') { | ||
throw e | ||
} else if (mp === modulePath) { | ||
consola.fatal( | ||
`Module ${modulePath} not found.\n\n`, | ||
`Please install missing dependency:\n\n`, | ||
`Using npm: npm i ${modulePath}\n\n`, | ||
`Using yarn: yarn add ${modulePath}` | ||
) | ||
} | ||
} | ||
} | ||
return m | ||
} | ||
|
||
export const builder = () => _import('@nuxt/builder') | ||
export const webpack = () => _import('@nuxt/webpack') | ||
export const generator = () => _import('@nuxt/generator') | ||
export const core = () => _import('@nuxt/core') | ||
export const importModule = _import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as imports from './imports' | ||
|
||
export const getNuxt = async function getNuxt(options) { | ||
const { Nuxt } = await imports.core() | ||
const nuxt = new Nuxt(options) | ||
await nuxt.ready() | ||
return nuxt | ||
} | ||
|
||
export const getBuilder = async function getBuilder(nuxt) { | ||
const { Builder } = await imports.builder() | ||
const { BundleBuilder } = await imports.webpack() | ||
return new Builder(nuxt, BundleBuilder) | ||
} | ||
|
||
export const getGenerator = async function getGenerator(nuxt) { | ||
const { Generator } = await imports.generator() | ||
const builder = await getBuilder(nuxt) | ||
return new Generator(nuxt, builder) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.