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 22 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
35 changes: 33 additions & 2 deletions saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 @@ -72,6 +82,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 Expand Up @@ -123,10 +143,13 @@ module.exports = {
choices: [
{ name: 'jsconfig.json (Recommended for VS Code)', value: 'jsconfig.json' }
],
default: []
default: [],
when: answers => answers.language === 'js'
}
],
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 @@ -139,6 +162,8 @@ module.exports = {
const edge = cliOptions.edge ? '-edge' : ''

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

actions.push({
type: 'add',
files: '**',
Expand All @@ -213,7 +239,8 @@ module.exports = {
filters: {
'_.eslintrc.js': 'linter.includes("eslint")',
'.prettierrc': 'linter.includes("prettier")',
'jsconfig.json': 'devTools.includes("jsconfig.json")'
'jsconfig.json': 'language.includes("js") && devTools.includes("jsconfig.json")',
'tsconfig.json': 'language.includes("ts")'
}
})

Expand Down Expand Up @@ -274,5 +301,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 @@ -49,6 +56,9 @@
<%_ } else { _%>
"nuxt": "^2.0.0",
<%_ } _%>
<%_ if (tsRuntime) { _%>
"@nuxt/typescript-runtime": "^0.1.3",
<%_ } _%>
<%_ if (server !== 'none') { _%>
"cross-env": "^5.2.0",
<%_ } _%>
Expand Down Expand Up @@ -111,6 +121,9 @@
<%_ if (server !== 'none') { _%>
"nodemon": "^1.18.9",
<%_ } _%>
<%_ if (typescript) { _%>
"@nuxt/typescript-build": "^0.1.11",
<%_ } _%>
<%_ if (ui === 'tailwind') { _%>
"@nuxtjs/tailwindcss": "^1.0.0",
<%_ } else if (ui === 'vuetify') { _%>
Expand All @@ -119,8 +132,12 @@
"framevuerk-builder": "^2.0.2",
<%_ } _%>
<%_ if (eslint) { _%>
<%_ if (typescript) { _%>
"@nuxtjs/eslint-config-typescript": "^0.1.2",
<%_ } else { _%>
"@nuxtjs/eslint-config": "^1.0.1",
"@nuxtjs/eslint-module": "^1.0.0",
<%_ } _%>
"babel-eslint": "^10.0.1",
"eslint": "^6.1.0",
"eslint-plugin-nuxt": ">=0.4.2",
Expand All @@ -141,6 +158,9 @@
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"vue-jest": "^4.0.0-0",
<%_ if (typescript) { _%>
"ts-jest": "^24.0.2",
<%_ } _%>
<%_ } else if (test === 'ava') { _%>
"ava": "^2.2.0",
"babel-plugin-module-resolver": "^3.2.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
9 changes: 9 additions & 0 deletions template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ module.exports = {
/*
** Nuxt.js dev-modules
*/

kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
buildModules: [
<%_ if (typescript) {_%>
'@nuxt/typescript-build',
<%_ } _%>
<%_ if (eslint) { _%>
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module',
ChangJoo-Park marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -165,7 +169,12 @@ module.exports = {
/*
** You can extend webpack config here
*/
<%_ if (eslint) { _%>
extend (/* config, ctx */) {
}
<%_ } else { _%>
extend (config, ctx) {
}
<%_ }_%>
kevinmarrec marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
34 changes: 34 additions & 0 deletions template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "esnext",
ChangJoo-Park marked this conversation as resolved.
Show resolved Hide resolved
"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"
ChangJoo-Park marked this conversation as resolved.
Show resolved Hide resolved
]
}