Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add typescript support using typescript-build #328

Merged
merged 50 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4a05248
typescript support using typescript-build
ChangJoo-Park Aug 21, 2019
4bd4f08
Remove trailing comma
ChangJoo-Park Aug 21, 2019
8dbe5ea
Merge branch 'master' into typescript
ChangJoo-Park Aug 28, 2019
e244e81
remove @types/node
ChangJoo-Park Aug 29, 2019
bf7e77c
Add default / ts-runtime for none server + ts
ChangJoo-Park Aug 29, 2019
bf36d5d
set lang="ts" when using typescript
ChangJoo-Park Aug 29, 2019
764cfdb
Remove ts-node
ChangJoo-Park Aug 29, 2019
f06ceea
@nuxt/typescript-build version to 0.1.11
ChangJoo-Park Aug 30, 2019
6d9431d
Update ts script tag
ChangJoo-Park Aug 30, 2019
a28343e
Add typescript nuxt cookbook when completed
ChangJoo-Park Aug 30, 2019
b5df795
Using tsconfig.json using always when selected ts
ChangJoo-Park Aug 30, 2019
9c28d89
only suggestion jsconfig.json when js users
ChangJoo-Park Aug 30, 2019
0f16c8e
fix typo
ChangJoo-Park Aug 30, 2019
abf30c7
using js by default
ChangJoo-Park Aug 30, 2019
4d62b71
tsconfig / jsconfig settings
ChangJoo-Park Aug 30, 2019
4f498f7
add closing tag for ts
ChangJoo-Park Aug 30, 2019
b68b79f
Delete package-lock.json
ChangJoo-Park Aug 30, 2019
d3df5d4
Update template/nuxt/pages/index.vue
ChangJoo-Park Aug 30, 2019
2da1f54
support eslint when TypeScript.
ChangJoo-Park Aug 30, 2019
97a6afd
set false tsRuntime when select TypeScript
ChangJoo-Park Aug 30, 2019
309662c
support jest with typescript
ChangJoo-Park Aug 30, 2019
ffacdd1
Update saofile.js
ChangJoo-Park Sep 2, 2019
8a81cad
Update template/tsconfig.json
ChangJoo-Park Sep 4, 2019
4476bab
Merge branch 'master' into typescript
ChangJoo-Park Oct 23, 2019
55c482a
Add language and runtime to prompts.js
ChangJoo-Park Oct 23, 2019
fa611c6
Update TypeScript relative package versions
ChangJoo-Park Oct 23, 2019
c26e961
@nuxt/core needs eslint-module
ChangJoo-Park Oct 23, 2019
ab8be4a
Update tsconfig.json
ChangJoo-Park Oct 24, 2019
57461b2
Update README for TypeScript
ChangJoo-Park Oct 24, 2019
f2e66a7
Merge branch 'typescript' of https://github.com/ChangJoo-Park/create-…
ChangJoo-Park Oct 24, 2019
3cc40d0
Install eslint-module when eslint && !typesciprt
ChangJoo-Park Nov 7, 2019
8560a10
Merge branch 'master' into typescript
ChangJoo-Park Nov 13, 2019
2619c95
Merge branch 'master' into typescript
kevinmarrec Dec 1, 2019
10cb365
Update template/_package.json
ChangJoo-Park Dec 4, 2019
336bf12
Update template/_package.json
ChangJoo-Park Dec 4, 2019
3ddb25a
Update template/_package.json
ChangJoo-Park Dec 4, 2019
804aec1
Update template/_package.json
ChangJoo-Park Dec 4, 2019
e6ae902
Update template/tsconfig.json
ChangJoo-Park Jan 16, 2020
34e0dab
Merge branch 'master' into typescript
ChangJoo-Park Jan 16, 2020
0b15a8a
Update template/_package.json
ChangJoo-Park Jan 21, 2020
ef8093f
Update template/_package.json
ChangJoo-Park Jan 21, 2020
e51f33c
Merge branch 'master' into typescript
ChangJoo-Park Jan 21, 2020
7d71f38
Update template/_package.json
ChangJoo-Park Jan 21, 2020
b000f62
Merge branch 'master' into typescript
ChangJoo-Park Jan 31, 2020
2fc953e
Update .eslintignore
ChangJoo-Park Jan 31, 2020
aa80ab1
Merge branch 'master' into typescript
ChangJoo-Park Feb 5, 2020
1339a99
Merge branch 'master' into typescript
ChangJoo-Park Mar 5, 2020
34f1751
Update template/nuxt/nuxt.config.js
kevinmarrec Mar 5, 2020
1fcee07
Update template/nuxt/nuxt.config.js
kevinmarrec Mar 5, 2020
da217ca
bump some packages versions
kevinmarrec Mar 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_*.js
template/nuxt/pages/index.vue
template/frameworks/iview/pages/index.vue
template/frameworks/jest/jest.config.js
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ yarn create nuxt-app <my-project>
1. Choose the package manager
- Yarn
- Npm
1. Choose programming language
- JavaScript
- TypeScript
1. Choose your favorite UI framework:
- None (feel free to add one later)
- [Ant Design Vue](https://github.com/vueComponent/ant-design-vue)
Expand All @@ -58,6 +61,9 @@ yarn create nuxt-app <my-project>
- [Hapi](https://github.com/hapijs/hapi)
- [Koa](https://github.com/koajs/koa)
- [Micro](https://github.com/zeit/micro)
1. Choose the runtime for TypeScript (if you choose TypeScript)
- Default
- [@nuxt/typescript-runtime](https://github.com/nuxt/typescript)
1. Choose Nuxt.js modules:
- [Axios](https://github.com/nuxt-community/axios-module)
- [Progressive Web App (PWA) Support](https://github.com/nuxt-community/pwa-module)
Expand Down
20 changes: 20 additions & 0 deletions prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ module.exports = [
default: '{gitUser.name}',
store: true
},
{
name: 'language',
message: 'Choose programming language',
choices: [
{ name: 'JavaScript', value: 'js' },
{ name: 'TypeScript', value: 'ts' }
],
type: 'list',
default: 'js'
},
{
name: 'pm',
message: 'Choose the package manager',
Expand Down Expand Up @@ -66,6 +76,16 @@ module.exports = [
],
default: 'none'
},
{
name: 'runtime',
message: 'Choose the runtime for TypeScript',
type: 'list',
choices: [
{ name: 'Default', value: 'none' },
{ name: '@nuxt/typescript-runtime', value: 'ts-runtime' }
],
when: answers => answers.language === 'ts' && answers.server === 'none'
},
{
name: 'features',
message: 'Choose Nuxt.js modules',
Expand Down
10 changes: 10 additions & 0 deletions saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const rootDir = __dirname
module.exports = {
prompts: require('./prompts'),
templateData () {
const typescript = this.answers.language.includes('ts')
const tsRuntime = this.answers.runtime && this.answers.runtime.includes('ts-runtime')
const pwa = this.answers.features.includes('pwa')
const eslint = this.answers.linter.includes('eslint')
const prettier = this.answers.linter.includes('prettier')
Expand All @@ -23,6 +25,8 @@ module.exports = {
const edge = cliOptions.edge ? '-edge' : ''

return {
typescript,
tsRuntime,
pwa,
eslint,
prettier,
Expand Down Expand Up @@ -87,6 +91,7 @@ module.exports = {
patterns: files
})
}

actions.push({
type: 'add',
files: '**',
Expand All @@ -101,6 +106,7 @@ module.exports = {
'_.eslintrc.js': 'linter.includes("eslint")',
'_.prettierrc': 'linter.includes("prettier")',
'_jsconfig.json': 'devTools.includes("jsconfig.json")',
'tsconfig.json': 'language.includes("ts")',
'semantic.yml': 'devTools.includes("semantic-pull-requests")',
'.env': 'features.includes("dotenv")',
'_stylelint.config.js': 'linter.includes("stylelint")'
Expand Down Expand Up @@ -168,5 +174,9 @@ module.exports = {
console.log(chalk` {bold To test:}\n`)
console.log(chalk`${cdMsg}\t{cyan ${pmRun} test}\n`)
}

if (this.answers.language.includes('ts')) {
console.log(chalk`\n {bold For TypeScript users.} \n\n See : https://typescript.nuxtjs.org/cookbook/components/`)
}
}
}
6 changes: 6 additions & 0 deletions template/_.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ module.exports = {
use: true
},
<%_ } _%>
<%_ if (!typescript) { _%>
parserOptions: {
parser: 'babel-eslint'
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
},
<%_ } _%>
extends: [
<%_ if (typescript) { _%>
'@nuxtjs/eslint-config-typescript',
<%_ } else {_%>
'@nuxtjs',
<%_ } _%>
<%_ if (prettier) { _%>
'prettier',
'prettier/vue',
Expand Down
20 changes: 20 additions & 0 deletions template/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
"private": true,
"scripts": {
<%_ if (server === 'none') { _%>
<%_ if (tsRuntime) { _%>
"dev": "nuxt-ts",
"build": "nuxt-ts build",
"generate": "nuxt-ts generate",
"start": "nuxt-ts start",
<%_ } else { _%>
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
<%_ } _%>
<%_ } else if (server === 'adonis') { _%>
"serve:dev": "<%= pmRun %> dev",
"dev": "nodemon --watch app --watch bootstrap --watch config --watch .env -x node server.js",
Expand Down Expand Up @@ -58,6 +65,9 @@
<%_ } else { _%>
"nuxt": "^2.0.0",
<%_ } _%>
<%_ if (tsRuntime) { _%>
"@nuxt/typescript-runtime": "^0.3.8",
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
<%_ } _%>
<%_ if (server !== 'none') { _%>
"cross-env": "^5.2.0",
<%_ } _%>
Expand Down Expand Up @@ -125,6 +135,9 @@
<%_ if (server !== 'none') { _%>
"nodemon": "^1.18.9",
<%_ } _%>
<%_ if (typescript) { _%>
"@nuxt/typescript-build": "^0.5.6",
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
<%_ } _%>
<%_ if (ui === 'tailwind') { _%>
"@nuxtjs/tailwindcss": "^1.0.0",
<%_ } else if (ui === 'vuetify') { _%>
Expand All @@ -133,7 +146,11 @@
"framevuerk-builder": "^2.0.2",
<%_ } _%>
<%_ if (eslint) { _%>
<%_ if (typescript) { _%>
"@nuxtjs/eslint-config-typescript": "^1.0.0",
<%_ } else { _%>
"@nuxtjs/eslint-config": "^2.0.0",
<%_ } _%>
"@nuxtjs/eslint-module": "^1.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^6.1.0",
Expand All @@ -159,6 +176,9 @@
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"vue-jest": "^4.0.0-0",
<%_ if (typescript) { _%>
"ts-jest": "^24.3.0",
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
<%_ } _%>
<%_ } else if (test === 'ava') { _%>
"ava": "^3.0.0",
"@ava/babel": "^1.0.0",
Expand Down
12 changes: 11 additions & 1 deletion template/frameworks/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ module.exports = {
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js'
},
moduleFileExtensions: ['js', 'vue', 'json'],
moduleFileExtensions: [
<%_ if (typescript) { _%>
'ts',
<%_ } _%>
'js',
'vue',
'json'
],
transform: {
<%_ if (typescript) { _%>
"^.+\\.ts$": "ts-jest",
<%_ } _%>
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
Expand Down
5 changes: 4 additions & 1 deletion template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ module.exports = {
** Nuxt.js dev-modules
*/
buildModules: [
<%_ if (eslint) { _%>
<%_ if (typescript) {_%>
'@nuxt/typescript-build',
<%_ } _%>
<%_ if (eslint && !typescript) { _%>
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
ChangJoo-Park marked this conversation as resolved.
Show resolved Hide resolved
<%_ } _%>
Expand Down
13 changes: 13 additions & 0 deletions template/nuxt/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
</div>
</template>

<%_ if (typescript) { _%>
<script lang="ts">
ChangJoo-Park marked this conversation as resolved.
Show resolved Hide resolved
import Vue from 'vue'
import Logo from '~/components/Logo.vue'

export default Vue.extend({
components: {
Logo
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
}
})
</script>
<%_ } else { _%>
<script>
import Logo from '~/components/Logo.vue'

Expand All @@ -37,6 +49,7 @@ export default {
}
}
</script>
<%_ } _%>

<style>
<%_ if (ui === 'tailwind') { _%>
Expand Down
36 changes: 36 additions & 0 deletions template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/types"
]
},
"exclude": [
"node_modules",
".nuxt",
"dist"
]
}