diff --git a/.dependabot/config.yml b/.dependabot/config.yml deleted file mode 100644 index c7d4c698..00000000 --- a/.dependabot/config.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: 1 - -update_configs: - - package_manager: "javascript" - directory: "/" - update_schedule: "live" - target_branch: "develop" - version_requirement_updates: "increase_versions" - commit_message: - prefix: "fix" - prefix_development: "chore" - include_scope: true - automerged_updates: - - match: - dependency_type: "development" - update_type: "semver:minor" - - match: - dependency_type: "production" - update_type: "semver:patch" diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..fec87921 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "npm" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + target-branch: "develop" + versioning-strategy: "increase" + commit-message: + prefix: "fix" + prefix-development: "chore" diff --git a/.prettierignore b/.prettierignore index f4296a68..949bf088 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ CHANGELOG.md templates/front/*/tsconfig.json +templates/server/package.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f5582358..5783fb6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [0.9.0](https://github.com/frouriojs/create-frourio-app/compare/v0.8.0...v0.9.0) (2020-06-29) + + +### Features + +* **next:** separate package.json ([26466d1](https://github.com/frouriojs/create-frourio-app/commit/26466d1c377fb9d76cba8ccbd25c2b10a50ff991)) +* **none:** separete package.json ([2e688e2](https://github.com/frouriojs/create-frourio-app/commit/2e688e27299e26877874f6a9f4b95199e31caefa)) +* **nuxt:** separate package.json ([99863fb](https://github.com/frouriojs/create-frourio-app/commit/99863fb9d647e1d35c9019e8ebad7f572dbf043d)) +* **nuxt:** update 2.13.0 ([834e3c4](https://github.com/frouriojs/create-frourio-app/commit/834e3c4b3abac44db13a22b1fa5e3b22906649b6)) +* update frourio@0.10.2 ([cbb049a](https://github.com/frouriojs/create-frourio-app/commit/cbb049af4b061dc6431e1236c102032ccb2a38be)) + + +### Bug Fixes + +* pm2 package.json ([eaaf9f2](https://github.com/frouriojs/create-frourio-app/commit/eaaf9f2c0e4eb7108e03d1d14e08a51e186052f2)) +* pm2.config.json ([b0b204a](https://github.com/frouriojs/create-frourio-app/commit/b0b204aae2ac7e8875704d96af0dc4d81486d455)) + ## [0.8.0](https://github.com/frouriojs/create-frourio-app/compare/v0.7.2...v0.8.0) (2020-06-18) diff --git a/README.md b/README.md index c2aadc75..b5435d46 100644 --- a/README.md +++ b/README.md @@ -42,20 +42,26 @@ yarn create frourio-app ## Features :tada: -1. Choose frontend framework +1. Frontend framework: - [Next.js](https://nextjs.org/learn/excel/typescript) - [Nuxt.js](https://typescript.nuxtjs.org/) - None -1. Choose HTTP client of aspida +1. Nuxt.js rendering mode: + - [Universal (SSR / Static)](https://nuxtjs.org/guide/#server-rendered-universal-ssr-) + - [SPA](https://nuxtjs.org/guide/#single-page-applications-spa-) +1. Nuxt.js deployment target: + - [Server (Node.js hosting)](https://nuxtjs.org/api/configuration-target) + - [Static (Static/JAMStack hosting)](https://nuxtjs.org/api/configuration-target) +1. HTTP client of aspida: - [axios](https://github.com/axios/axios) - [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) -1. Choose the package manager +1. Package manager: - Yarn - Npm -1. Choose the daemon process manager +1. Daemon process manager: - None - [PM2](https://pm2.keymetrics.io/) -1. Choose the database type of TypeORM +1. Database type of TypeORM: - None - [MySQL](https://www.mysql.com/) - [PostgreSQL](https://www.postgresql.org/) diff --git a/lib/package.js b/lib/package.js index 3705f3d4..b4cf5e25 100644 --- a/lib/package.js +++ b/lib/package.js @@ -28,6 +28,8 @@ module.exports = { }) } + if (pkgs.length === 1) return pkgs[0] + const pkg = merge(...pkgs) pkg.dependencies = sortByKey(pkg.dependencies) pkg.devDependencies = sortByKey(pkg.devDependencies) diff --git a/lib/prompts.js b/lib/prompts.js index f837e9c2..ac0afe92 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -3,12 +3,12 @@ const dbInfo = require('./dbInfo') module.exports = [ { name: 'name', - message: 'Project name', + message: 'Project name:', default: '{outFolder}' }, { name: 'front', - message: 'Choose frontend framework', + message: 'Frontend framework:', choices: [ { name: 'Next.js', value: 'next' }, { name: 'Nuxt.js', value: 'nuxt' }, @@ -19,18 +19,29 @@ module.exports = [ }, { name: 'mode', - message: 'Choose rendering mode', + message: 'Rendering mode:', type: 'list', choices: [ - { name: 'Universal (SSR / Static)', value: 'universal' }, + { name: 'Universal (SSR / SSG)', value: 'universal' }, { name: 'Single Page App', value: 'spa' } ], default: 'universal', when: answers => answers.front === 'nuxt' }, + { + name: 'target', + message: 'Deployment target:', + type: 'list', + choices: [ + { name: 'Server (Node.js hosting)', value: 'server' }, + { name: 'Static (Static/JAMStack hosting)', value: 'static' } + ], + default: 'server', + when: answers => answers.front === 'nuxt' + }, { name: 'aspida', - message: 'Choose HTTP client of aspida', + message: 'HTTP client of aspida:', choices: [ { name: 'axios', value: 'axios' }, { name: 'fetch', value: 'fetch' } @@ -41,7 +52,7 @@ module.exports = [ }, { name: 'pm', - message: 'Choose the package manager', + message: 'Package manager:', choices: [ { name: 'Yarn', value: 'yarn' }, { name: 'Npm', value: 'npm' } @@ -51,7 +62,7 @@ module.exports = [ }, { name: 'daemon', - message: 'Choose the daemon process manager', + message: 'Daemon process manager:', choices: [ { name: 'None', value: 'none' }, { name: 'PM2', value: 'pm2' } @@ -61,7 +72,7 @@ module.exports = [ }, { name: 'dbType', - message: 'Choose the database type of TypeORM', + message: 'Database type of TypeORM:', choices: [ { name: 'None', value: 'none' }, { name: 'MySQL', value: 'mysql' }, diff --git a/lib/saofile.js b/lib/saofile.js index 7d1ed4d3..64d83db5 100644 --- a/lib/saofile.js +++ b/lib/saofile.js @@ -60,8 +60,8 @@ module.exports = { }, { type: 'add', - files: '**', - templateDir: resolve(__dirname, '../templates/common') + files: 'server/**', + templateDir: resolve(__dirname, '../templates') }, ...addedList, { @@ -84,6 +84,7 @@ module.exports = { this.gitInit() await this.npmInstall({ npmClient: this.answers.pm }) + await this.npmInstall({ npmClient: this.answers.pm, cwd: `${this.outDir}/server` }) spawn.sync(this.answers.pm, ['run', 'build:apis'], { cwd: this.outDir, diff --git a/package.json b/package.json index 0adab81a..e56f73cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-frourio-app", - "version": "0.8.0", + "version": "0.9.0", "description": "Create a frourio project in seconds", "author": "Solufa ", "license": "MIT", diff --git a/templates/aspida/next/axios/package.json b/templates/aspida/next/axios/package.json index f308a28d..bbc76ba2 100644 --- a/templates/aspida/next/axios/package.json +++ b/templates/aspida/next/axios/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@aspida/axios": "^0.8.0", + "@aspida/axios": "^0.9.3", "axios": "^0.19.2" } } diff --git a/templates/aspida/next/axios/utils/apiClient.ts b/templates/aspida/next/axios/utils/apiClient.ts deleted file mode 100644 index 0f00bc95..00000000 --- a/templates/aspida/next/axios/utils/apiClient.ts +++ /dev/null @@ -1,5 +0,0 @@ -import axios from 'axios' -import aspida from '@aspida/axios' -import api from '~/server/api/$api' - -export const apiClient = api(aspida(axios, { baseURL: process.env.BASE_URL })) diff --git a/templates/aspida/next/fetch/package.json b/templates/aspida/next/fetch/package.json index 8f0d9570..88b04abf 100644 --- a/templates/aspida/next/fetch/package.json +++ b/templates/aspida/next/fetch/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "@aspida/fetch": "^0.6.0" + "@aspida/fetch": "^0.7.3" } } diff --git a/templates/aspida/next/fetch/utils/apiClient.ts b/templates/aspida/next/fetch/utils/apiClient.ts deleted file mode 100644 index 4ff5dfd9..00000000 --- a/templates/aspida/next/fetch/utils/apiClient.ts +++ /dev/null @@ -1,4 +0,0 @@ -import aspida from '@aspida/fetch' -import api from '~/server/api/$api' - -export const apiClient = api(aspida(fetch, { baseURL: process.env.BASE_URL })) diff --git a/templates/aspida/nuxt/axios/nuxt.config.ts b/templates/aspida/nuxt/axios/nuxt.config.ts index f13a1a94..4b76c619 100644 --- a/templates/aspida/nuxt/axios/nuxt.config.ts +++ b/templates/aspida/nuxt/axios/nuxt.config.ts @@ -1,12 +1,19 @@ import { Configuration } from '@nuxt/types' -import dotenv from 'dotenv' - -dotenv.config() const config: Configuration = { + /* + ** Nuxt rendering mode + ** See https://nuxtjs.org/api/configuration-mode + */ mode: '<%= mode %>', + /* + ** Nuxt target + ** See https://nuxtjs.org/api/configuration-target + */ + target: '<%= target %>', /* ** Headers of the page + ** See https://nuxtjs.org/api/configuration-head */ head: { title: process.env.npm_package_name || '', @@ -31,15 +38,18 @@ const config: Configuration = { css: [], /* ** Plugins to load before mounting the App + ** https://nuxtjs.org/guide/plugins */ plugins: ['~/plugins/api'], /* - ** Nuxt.js dev-modules + ** Auto import components + ** See https://nuxtjs.org/api/configuration-components */ components: true, + /* + ** Nuxt.js dev-modules + */ buildModules: [ - // TODO: Remove when upgrading to nuxt 2.13+ - '@nuxt/components', '@nuxt/typescript-build', // Doc: https://github.com/nuxt-community/stylelint-module '@nuxtjs/stylelint-module' @@ -56,10 +66,11 @@ const config: Configuration = { ** See https://axios.nuxtjs.org/options */ axios: { - baseURL: `http://localhost:${process.env.SERVER_PORT}${process.env.BASE_PATH}` + baseURL: require('./aspida.config').baseURL }, /* ** Build configuration + ** See https://nuxtjs.org/api/configuration-build/ */ build: { /* diff --git a/templates/aspida/nuxt/axios/package.json b/templates/aspida/nuxt/axios/package.json index f308a28d..a973c2ac 100644 --- a/templates/aspida/nuxt/axios/package.json +++ b/templates/aspida/nuxt/axios/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@aspida/axios": "^0.8.0", - "axios": "^0.19.2" + "@aspida/axios": "^0.9.4", + "@nuxtjs/axios": "^5.11.0" } } diff --git a/templates/aspida/nuxt/fetch/nuxt.config.ts b/templates/aspida/nuxt/fetch/nuxt.config.ts index 9a8ed050..95524ce5 100644 --- a/templates/aspida/nuxt/fetch/nuxt.config.ts +++ b/templates/aspida/nuxt/fetch/nuxt.config.ts @@ -1,15 +1,19 @@ import { Configuration } from '@nuxt/types' -import dotenv from 'dotenv' - -dotenv.config() const config: Configuration = { - mode: 'universal', - env: { - BASE_URL: `http://localhost:${process.env.SERVER_PORT}${process.env.BASE_PATH}` - }, + /* + ** Nuxt rendering mode + ** See https://nuxtjs.org/api/configuration-mode + */ + mode: '<%= mode %>', + /* + ** Nuxt target + ** See https://nuxtjs.org/api/configuration-target + */ + target: '<%= target %>', /* ** Headers of the page + ** See https://nuxtjs.org/api/configuration-head */ head: { title: process.env.npm_package_name || '', @@ -34,15 +38,18 @@ const config: Configuration = { css: [], /* ** Plugins to load before mounting the App + ** https://nuxtjs.org/guide/plugins */ plugins: ['~/plugins/api'], /* - ** Nuxt.js dev-modules + ** Auto import components + ** See https://nuxtjs.org/api/configuration-components */ components: true, + /* + ** Nuxt.js dev-modules + */ buildModules: [ - // TODO: Remove when upgrading to nuxt 2.13+ - '@nuxt/components', '@nuxt/typescript-build', // Doc: https://github.com/nuxt-community/stylelint-module '@nuxtjs/stylelint-module' @@ -53,6 +60,7 @@ const config: Configuration = { modules: [], /* ** Build configuration + ** See https://nuxtjs.org/api/configuration-build/ */ build: { /* diff --git a/templates/aspida/nuxt/fetch/package.json b/templates/aspida/nuxt/fetch/package.json index 8f0d9570..5be13ed3 100644 --- a/templates/aspida/nuxt/fetch/package.json +++ b/templates/aspida/nuxt/fetch/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "@aspida/fetch": "^0.6.0" + "@aspida/fetch": "^0.7.4" } } diff --git a/templates/aspida/nuxt/fetch/plugins/api.ts b/templates/aspida/nuxt/fetch/plugins/api.ts index 259efc12..24e9fe10 100644 --- a/templates/aspida/nuxt/fetch/plugins/api.ts +++ b/templates/aspida/nuxt/fetch/plugins/api.ts @@ -20,7 +20,6 @@ declare module 'vuex/types/index' { } } -const plugin: Plugin = (_, inject) => - inject('api', api(aspida(fetch, { baseURL: process.env.BASE_URL }))) +const plugin: Plugin = (_, inject) => inject('api', api(aspida(fetch))) export default plugin diff --git a/templates/daemon/pm2/package.json b/templates/daemon/pm2/package.json index 749fb263..34e5c16f 100644 --- a/templates/daemon/pm2/package.json +++ b/templates/daemon/pm2/package.json @@ -1,12 +1,9 @@ { "scripts": { - "pm2:start": "pm2 start server/pm2.config.json --env production", - "pm2:stop": "pm2 stop server/pm2.config.json", - "pm2:delete": "pm2 delete server/pm2.config.json", - "pm2:logs": "pm2 logs", - "pm2:monit": "pm2 monit" - }, - "dependencies": { - "pm2": "^4.4.0" + "pm2:start": "cd server && node_modules/.bin/pm2 start pm2.config.json --env production", + "pm2:stop": "cd server && node_modules/.bin/pm2 stop pm2.config.json", + "pm2:delete": "cd server && node_modules/.bin/pm2 delete pm2.config.json", + "pm2:logs": "cd server && node_modules/.bin/pm2 logs", + "pm2:monit": "cd server && node_modules/.bin/pm2 monit" } } diff --git a/templates/daemon/pm2/server/pm2.config.json b/templates/daemon/pm2/server/pm2.config.json index be47ba10..047c4e43 100644 --- a/templates/daemon/pm2/server/pm2.config.json +++ b/templates/daemon/pm2/server/pm2.config.json @@ -1,6 +1,6 @@ { "name": "<%= name %>", - "script": "server/index.js", + "script": "index.js", "env_production": { "NODE_ENV": "production" } diff --git a/templates/database/.env b/templates/database/server/.env similarity index 85% rename from templates/database/.env rename to templates/database/server/.env index 16e54732..f1c16fad 100644 --- a/templates/database/.env +++ b/templates/database/server/.env @@ -1,5 +1,6 @@ SERVER_PORT=8080 BASE_PATH=/api +API_ORIGIN=http://localhost:8080 USER_ID=id USER_PASS=pass TYPEORM_HOST=localhost diff --git a/templates/database/server/service/tasks.ts b/templates/database/server/service/tasks.ts index 5e3d43ba..1e0cf7db 100644 --- a/templates/database/server/service/tasks.ts +++ b/templates/database/server/service/tasks.ts @@ -1,5 +1,5 @@ import { getRepository } from 'typeorm' -import { Task } from '~/server/entity/Task' +import { Task } from '$/entity/Task' const taskRepository = () => getRepository(Task) diff --git a/templates/front/next/.gitignore b/templates/front/next/.gitignore index d1fef9b3..df4e1439 100644 --- a/templates/front/next/.gitignore +++ b/templates/front/next/.gitignore @@ -1,7 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules +node_modules /.pnp .pnp.js diff --git a/templates/front/next/_package.json b/templates/front/next/_package.json index 12bd8e6c..17ced1e3 100644 --- a/templates/front/next/_package.json +++ b/templates/front/next/_package.json @@ -5,36 +5,30 @@ "scripts": { "dev": "run-p dev:*", "dev:front": "next dev", - "dev:server": "webpack --watch --mode=development --config server/webpack.config.js", + "dev:server": "cd server && node_modules/.bin/webpack --watch --mode=development", "dev:aspida": "aspida --watch", - "dev:frourio": "frourio --watch", + "dev:frourio": "cd server && node_modules/.bin/frourio --watch", "build": "npm run build:apis && run-p build:front build:server", "build:front": "next build", - "build:server": "webpack --mode=production --config server/webpack.config.js", + "build:server": "cd server && node_modules/.bin/webpack --mode=production", "build:apis": "cross-env NODE_ENV=production run-p build:aspida build:frourio", "build:aspida": "aspida --build", - "build:frourio": "frourio --build", + "build:frourio": "cd server && node_modules/.bin/frourio --build", + "install:server": "cd server && <%= pm %> install", "lint": "eslint --ext .ts,.js,.tsx --ignore-path .gitignore .", "lint:fix": "npm run lint -- --fix", "start": "run-p start:*", "start:front": "next start", - "start:server": "cross-env NODE_ENV=production node server/index.js", + "start:server": "cd server && cross-env NODE_ENV=production node index.js", "typecheck": "npm run build:apis && tsc --noEmit" }, "dependencies": { - "@aspida/axios": "^0.8.0", - "axios": "^0.19.2", "dotenv": "^8.2.0", - "frourio": "^0.10.1", "next": "9.4.4", - "passport": "^0.4.1", - "passport-trusted-header": "^1.1.0", "react": "16.13.1", "react-dom": "16.13.1" }, "devDependencies": { - "@types/node": "^14.0.11", - "@types/passport": "^1.0.3", "@types/react": "^16.9.35", "@typescript-eslint/eslint-plugin": "^3.2.0", "@typescript-eslint/parser": "^3.2.0", @@ -43,13 +37,9 @@ "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-react": "^7.20.0", - "nodemon-webpack-plugin": "^4.3.1", "npm-run-all": "^4.1.5", "prettier": "^2.0.5", "ts-loader": "^7.0.5", - "ts-node": "^8.10.2", - "tsconfig-paths-webpack-plugin": "^3.2.0", - "webpack-cli": "^3.3.11", - "webpack-node-externals": "^1.7.2" + "typescript": "^3.9.5" } } diff --git a/templates/front/next/aspida.config.js b/templates/front/next/aspida.config.js new file mode 100644 index 00000000..d90d24d2 --- /dev/null +++ b/templates/front/next/aspida.config.js @@ -0,0 +1,6 @@ +require('dotenv').config({ path: 'server/.env' }) + +module.exports = { + input: 'server/api', + baseURL: `${process.env.API_ORIGIN}${process.env.BASE_PATH}` +} diff --git a/templates/front/next/components/UserBanner.tsx b/templates/front/next/components/UserBanner.tsx index 08b01b8e..d50e6b2e 100644 --- a/templates/front/next/components/UserBanner.tsx +++ b/templates/front/next/components/UserBanner.tsx @@ -1,6 +1,6 @@ import { useState, useCallback, ChangeEvent } from 'react' import { apiClient } from '~/utils/apiClient' -import { UserInfo } from '~/server/types' +import { UserInfo } from '$/types' const UserBanner = () => { const [isLoggedIn, setIsLoggedIn] = useState(false) diff --git a/templates/front/next/next.config.js b/templates/front/next/next.config.js deleted file mode 100644 index 494dbda3..00000000 --- a/templates/front/next/next.config.js +++ /dev/null @@ -1,7 +0,0 @@ -require('dotenv').config() - -module.exports = { - env: { - BASE_URL: `http://localhost:${process.env.SERVER_PORT}${process.env.BASE_PATH}` - } -} diff --git a/templates/front/next/pages/index.tsx b/templates/front/next/pages/index.tsx index e09a5623..c8c77d36 100644 --- a/templates/front/next/pages/index.tsx +++ b/templates/front/next/pages/index.tsx @@ -1,7 +1,7 @@ import Head from 'next/head' import { useCallback, useState, FormEvent, ChangeEvent } from 'react' import { apiClient } from '~/utils/apiClient' -import { Task } from '~/server/types' +import { Task } from '$/types' import UserBanner from '~/components/UserBanner' type Props = { diff --git a/templates/front/next/utils/apiClient.ts b/templates/front/next/utils/apiClient.ts new file mode 100644 index 00000000..5aa72546 --- /dev/null +++ b/templates/front/next/utils/apiClient.ts @@ -0,0 +1,4 @@ +import aspida from '@aspida/<%= aspida %>' +import api from '~/server/api/$api' + +export const apiClient = api(aspida()) diff --git a/templates/front/none/_package.json b/templates/front/none/_package.json index c204d29b..34552f33 100644 --- a/templates/front/none/_package.json +++ b/templates/front/none/_package.json @@ -4,53 +4,36 @@ "private": true, "scripts": { "dev": "run-p dev:*", - "dev:server": "webpack --watch --mode=development --config server/webpack.config.js", - "dev:aspida": "aspida --watch", - "dev:frourio": "frourio --watch", - "build": "npm run build:apis && npm run build:server", - "build:server": "webpack --mode=production --config server/webpack.config.js", - "build:apis": "cross-env NODE_ENV=production run-p build:aspida build:frourio", - "build:aspida": "aspida --build", - "build:frourio": "frourio --build", - "lint": "eslint --ext .ts,.js,.tsx --ignore-path .gitignore .", + "dev:server": "cd server && node_modules/.bin/webpack --watch --mode=development", + "dev:frourio": "cd server && node_modules/.bin/frourio --watch", + "build": "npm run build:frourio && npm run build:server", + "build:server": "cd server && node_modules/.bin/webpack --mode=production", + "build:frourio": "cd server && node_modules/.bin/frourio --build", + "install:server": "cd server && <%= pm %> install", + "lint": "eslint --ext .ts,.js --ignore-path .gitignore .", "lint:fix": "npm run lint -- --fix", - "start": "cross-env NODE_ENV=production node server/index.js", - "typecheck": "npm run build:apis && tsc --noEmit" + "start": "cd server && cross-env NODE_ENV=production node index.js", + "typecheck": "npm run build:frourio && tsc --noEmit" }, "lint-staged": { - "*.js": "npm run lint" + "*.{js,ts}": "npm run lint" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, - "dependencies": { - "@aspida/axios": "^0.8.0", - "axios": "^0.19.2", - "dotenv": "^8.2.0", - "frourio": "^0.10.1", - "passport": "^0.4.1", - "passport-trusted-header": "^1.1.0" - }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^3.2.0", "@typescript-eslint/parser": "^3.2.0", - "@types/passport": "^1.0.3", "cross-env": "^7.0.2", "eslint": "^6.1.0", "eslint-config-prettier": "^6.10.0", "eslint-plugin-prettier": "^3.1.2", "husky": "^4.0.0", "lint-staged": "^10.0.0", - "nodemon-webpack-plugin": "^4.3.1", "npm-run-all": "^4.1.5", "prettier": "^1.19.1", - "ts-loader": "^7.0.5", - "ts-node": "^8.10.2", - "tsconfig-paths-webpack-plugin": "^3.2.0", - "webpack": "^4.43.0", - "webpack-cli": "^3.3.11", - "webpack-node-externals": "^1.7.2" + "typescript": "^3.9.5" } } diff --git a/templates/front/nuxt/README.md b/templates/front/nuxt/README.md new file mode 100644 index 00000000..0f64bb25 --- /dev/null +++ b/templates/front/nuxt/README.md @@ -0,0 +1,18 @@ +# <%= name %> + +## Build Setup + +```bash +# install dependencies +$ yarn install +$ yarn install:server + +# serve with hot reload at localhost:3000 +$ yarn dev + +# build for production and launch server +$ yarn build +$ yarn start +``` + +For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org). diff --git a/templates/front/nuxt/_package.json b/templates/front/nuxt/_package.json index 106c6640..b40aba25 100644 --- a/templates/front/nuxt/_package.json +++ b/templates/front/nuxt/_package.json @@ -5,26 +5,27 @@ "scripts": { "dev": "run-p dev:*", "dev:front": "nuxt-ts", - "dev:server": "webpack --watch --mode=development --config server/webpack.config.js", + "dev:server": "cd server && node_modules/.bin/webpack --watch --mode=development", "dev:aspida": "aspida --watch", - "dev:frourio": "frourio --watch", + "dev:frourio": "cd server && node_modules/.bin/frourio --watch", "build": "npm run build:apis && run-p build:front build:server", - "build:front": "nuxt-ts build", - "build:server": "webpack --mode=production --config server/webpack.config.js", + "build:front": "nuxt-ts build<% var exportFront = target === 'static' ? ' && nuxt-ts export' : '' %><%- exportFront %>", + "build:server": "cd server && node_modules/.bin/webpack --mode=production", "build:apis": "cross-env NODE_ENV=production run-p build:aspida build:frourio", "build:aspida": "aspida --build", - "build:frourio": "frourio --build", - "lint": "npm run lint:script && npm run lint:style", - "lint:script": "eslint --ext .ts,.js,.vue --ignore-path .gitignore .", - "lint:style": "stylelint \"**/*.{*(s)css,vue}\"", - "lint:fix": "npm run lint:script -- --fix && npm run lint:style -- --fix", + "build:frourio": "cd server && node_modules/.bin/frourio --build", + "install:server": "cd server && <%= pm %> install", + "lint": "npm run lint:js && npm run lint:style", + "lint:js": "eslint --ext .ts,.js,.vue --ignore-path .gitignore .", + "lint:style": "stylelint **/*.{vue,css} --ignore-path .gitignore", + "lint:fix": "npm run lint:js -- --fix && npm run lint:style -- --fix", "typecheck": "npm run build:apis && tsc --noEmit", "start": "run-p start:*", - "start:front": "nuxt-ts start", - "start:server": "cross-env NODE_ENV=production node server/index.js" + "start:front": "nuxt-ts <% var startFront = target === 'static' ? 'serve' : 'start' %><%= startFront %>", + "start:server": "cd server && cross-env NODE_ENV=production node index.js" }, "lint-staged": { - "*.{js,vue}": "yarn lint", + "*.{js,ts,vue}": "eslint", "*.{css,vue}": "stylelint" }, "husky": { @@ -33,22 +34,16 @@ } }, "dependencies": { - "@aspida/axios": "^0.8.0", - "@nuxt/typescript-runtime": "^0.4.8", - "@nuxtjs/axios": "^5.3.6", + "@nuxt/typescript-runtime": "^0.4.10", "dotenv": "^8.2.0", - "frourio": "^0.10.1", - "nuxt": "2.12.2", - "passport": "^0.4.1", - "passport-trusted-header": "^1.1.0" + "nuxt": "2.13.0" }, "devDependencies": { - "@nuxt/components": "^0.3.3", "@nuxt/typescript-build": "^1.0.3", - "@nuxtjs/eslint-config-typescript": "^1.0.0", - "@nuxtjs/eslint-module": "^1.0.0", - "@nuxtjs/stylelint-module": "^3.1.0", - "@types/passport": "^1.0.3", + "@nuxtjs/eslint-config": "^3.0.0", + "@nuxtjs/eslint-config-typescript": "^2.0.0", + "@nuxtjs/eslint-module": "^2.0.0", + "@nuxtjs/stylelint-module": "^4.0.0", "babel-eslint": "^10.0.1", "cross-env": "^7.0.2", "eslint": "^6.1.0", @@ -57,14 +52,10 @@ "eslint-plugin-prettier": "^3.1.2", "husky": "^4.0.0", "lint-staged": "^10.0.0", - "nodemon-webpack-plugin": "^4.3.1", "npm-run-all": "^4.1.5", "prettier": "^1.19.1", "stylelint": "^10.1.0", "ts-loader": "^7.0.5", - "ts-node": "^8.10.2", - "tsconfig-paths-webpack-plugin": "^3.2.0", - "typescript": "^3.9.5", - "webpack-cli": "^3.3.11" + "typescript": "^3.9.5" } } diff --git a/templates/front/nuxt/aspida.config.js b/templates/front/nuxt/aspida.config.js new file mode 100644 index 00000000..d90d24d2 --- /dev/null +++ b/templates/front/nuxt/aspida.config.js @@ -0,0 +1,6 @@ +require('dotenv').config({ path: 'server/.env' }) + +module.exports = { + input: 'server/api', + baseURL: `${process.env.API_ORIGIN}${process.env.BASE_PATH}` +} diff --git a/templates/front/nuxt/components/UserBanner.vue b/templates/front/nuxt/components/UserBanner.vue index 4a617002..8f266c8c 100644 --- a/templates/front/nuxt/components/UserBanner.vue +++ b/templates/front/nuxt/components/UserBanner.vue @@ -12,7 +12,7 @@