Skip to content

Commit

Permalink
feat: migrate to monorepo (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Apr 12, 2020
1 parent 72706d2 commit 64991bb
Show file tree
Hide file tree
Showing 106 changed files with 2,612 additions and 281 deletions.
7 changes: 4 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_*.js
template/nuxt/pages/index.vue
template/frameworks/iview/pages/index.vue
template/frameworks/jest/jest.config.js
node_modules
packages/cna-template/template/nuxt/pages/index.vue
packages/cna-template/template/frameworks/iview/pages/index.vue
packages/cna-template/template/frameworks/jest/jest.config.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules

# Logs
npm-debug.log
yarn-error.log

# Coverage
coverage
Expand Down
2 changes: 1 addition & 1 deletion ava.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
ignoredByWatcher: ['!**/*.{js}'],
files: ['./test/*.test.js', '!template'],
files: ['./packages/*/test/*.test.js', '!template'],
tap: false,
verbose: true,
babel: true
Expand Down
25 changes: 25 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "2.15.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"command": {
"publish": {
"npmClient": "npm"
},
"version": {
"conventionalCommits": true
}
},
"changelog": {
"labels": {
"feat": "New Feature",
"fix": "Bug Fix",
"docs": "Documentation",
"perf": "Performance",
"refactor": "Code Refactoring"
}
}
}
37 changes: 7 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"name": "create-nuxt-app",
"version": "2.15.0",
"description": "Create a Nuxt.js App in seconds.",
"bin": "cli.js",
"files": [
"cli.js",
"prompts.js",
"saofile.js",
"template/"
"private": true,
"workspaces": [
"packages/*"
],
"repository": {
"url": "git+https://github.com/nuxt/create-nuxt-app.git",
Expand All @@ -16,31 +10,14 @@
"scripts": {
"lint": "eslint --ext .js,.mjs,.vue .",
"test": "ava --verbose",
"test:snapshot": "ava --verbose --update-snapshots",
"release": "standard-version"
},
"dependencies": {
"cac": "^6.5.8",
"chalk": "^2.4.2",
"cross-spawn": "^7.0.2",
"envinfo": "^7.5.0",
"glob": "^7.1.6",
"lodash": "^4.17.15",
"sao": "^1.7.0",
"superb": "^4.0.0",
"validate-npm-package-name": "^3.0.0"
"test:snapshot": "ava --verbose --update-snapshots"
},
"devDependencies": {
"@nuxtjs/eslint-config": "^2.0.2",
"@ava/babel": "^1.0.1",
"@nuxtjs/eslint-config": "^2.0.2",
"ava": "^3.5.2",
"eslint": "^6.8.0",
"standard-version": "^7.1.0"
"lerna": "^3.20.2"
},
"authors": [
"Egoist <[email protected]>",
"Nuxt team <[email protected]>",
"Clark Du <[email protected]>"
],
"license": "MIT"
"name": "create-nuxt-app"
}
9 changes: 9 additions & 0 deletions packages/cna-template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "cna-template",
"version": "2.15.0",
"description": "Templates for Create Nuxt App.",
"files": [
"template"
],
"license": "MIT"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cli.js → packages/create-nuxt-app/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const sao = require('sao')
const cac = require('cac')
const chalk = require('chalk')
const envinfo = require('envinfo')
const { version } = require('./package.json')
const { version } = require('../package.json')

const generator = path.resolve(__dirname, './')

Expand Down
File renamed without changes.
19 changes: 11 additions & 8 deletions saofile.js → packages/create-nuxt-app/lib/saofile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const { join, relative } = require('path')
const { dirname, join, relative } = require('path')
const glob = require('glob')
const spawn = require('cross-spawn')
const validate = require('validate-npm-package-name')

const rootDir = __dirname
const cnaTemplateDir = join(dirname(require.resolve('cna-template/package.json')))
const templateDir = join(cnaTemplateDir, 'template')
const frameworksDir = join(templateDir, 'frameworks')

module.exports = {
prompts: require('./prompts'),
Expand Down Expand Up @@ -53,7 +55,7 @@ module.exports = {
const actions = [{
type: 'add',
files: '**',
templateDir: 'template/nuxt',
templateDir: join(templateDir, 'nuxt'),
filters: {
'static/icon.png': 'features.includes("pwa")'
}
Expand All @@ -63,23 +65,23 @@ module.exports = {
actions.push({
type: 'add',
files: '**',
templateDir: `template/frameworks/${this.answers.ui}`
templateDir: join(frameworksDir, this.answers.ui)
})
}

if (this.answers.test !== 'none') {
actions.push({
type: 'add',
files: '**',
templateDir: `template/frameworks/${this.answers.test}`
templateDir: join(frameworksDir, this.answers.test)
})
}

if (this.answers.server !== 'none') {
if (this.answers.server === 'adonis') {
const files = {}
for (const action of actions) {
const options = { cwd: join(rootDir, action.templateDir), dot: true }
const options = { cwd: action.templateDir, dot: true }
for (const file of glob.sync('*', options)) {
files[file] = `resources/${file}`
}
Expand All @@ -95,7 +97,7 @@ module.exports = {
actions.push({
type: 'add',
files: '**',
templateDir: `template/frameworks/${this.answers.server}`
templateDir: join(frameworksDir, this.answers.server)
})
}

Expand All @@ -110,7 +112,8 @@ module.exports = {
'semantic.yml': 'devTools.includes("semantic-pull-requests")',
'.env': 'features.includes("dotenv")',
'_stylelint.config.js': 'linter.includes("stylelint")'
}
},
templateDir
})

actions.push({
Expand Down
27 changes: 27 additions & 0 deletions packages/create-nuxt-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "create-nuxt-app",
"version": "2.15.0",
"description": "Create a Nuxt.js App in seconds.",
"bin": "lib/cli.js",
"files": [
"lib"
],
"dependencies": {
"cac": "^6.5.8",
"chalk": "^2.4.2",
"cna-template": "^2.15.0",
"cross-spawn": "^7.0.2",
"envinfo": "^7.5.0",
"glob": "^7.1.6",
"lodash": "^4.17.15",
"sao": "^1.7.0",
"superb": "^4.0.0",
"validate-npm-package-name": "^3.0.0"
},
"authors": [
"Egoist <[email protected]>",
"Nuxt team <[email protected]>",
"Clark Du <[email protected]>"
],
"license": "MIT"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path'
import test from 'ava'
import sao from 'sao'
import saoConfig from '../saofile'
import saoConfig from '../lib/saofile'

const generator = path.join(__dirname, '..')
const generator = path.join(__dirname, '../lib')

const getPkgFields = (pkg) => {
pkg = JSON.parse(pkg)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Snapshot report for `test/index.test.js`
# Snapshot report for `packages/create-nuxt-app/test/index.test.js`

The actual snapshot is saved in `index.test.js.snap`.

Expand Down
Binary file not shown.
Loading

0 comments on commit 64991bb

Please sign in to comment.