This repository has been archived by the owner on Mar 4, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 427
Feat: Generate typescript package types and tests #449
Closed
Closed
Changes from 49 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
4a05248
typescript support using typescript-build
ChangJoo-Park 4bd4f08
Remove trailing comma
ChangJoo-Park 8dbe5ea
Merge branch 'master' into typescript
ChangJoo-Park e244e81
remove @types/node
ChangJoo-Park bf7e77c
Add default / ts-runtime for none server + ts
ChangJoo-Park bf36d5d
set lang="ts" when using typescript
ChangJoo-Park 764cfdb
Remove ts-node
ChangJoo-Park f06ceea
@nuxt/typescript-build version to 0.1.11
ChangJoo-Park 6d9431d
Update ts script tag
ChangJoo-Park a28343e
Add typescript nuxt cookbook when completed
ChangJoo-Park b5df795
Using tsconfig.json using always when selected ts
ChangJoo-Park 9c28d89
only suggestion jsconfig.json when js users
ChangJoo-Park 0f16c8e
fix typo
ChangJoo-Park abf30c7
using js by default
ChangJoo-Park 4d62b71
tsconfig / jsconfig settings
ChangJoo-Park 4f498f7
add closing tag for ts
ChangJoo-Park b68b79f
Delete package-lock.json
ChangJoo-Park d3df5d4
Update template/nuxt/pages/index.vue
ChangJoo-Park 2da1f54
support eslint when TypeScript.
ChangJoo-Park 97a6afd
set false tsRuntime when select TypeScript
ChangJoo-Park 309662c
support jest with typescript
ChangJoo-Park ffacdd1
Update saofile.js
ChangJoo-Park 8a81cad
Update template/tsconfig.json
ChangJoo-Park 4476bab
Merge branch 'master' into typescript
ChangJoo-Park 55c482a
Add language and runtime to prompts.js
ChangJoo-Park fa611c6
Update TypeScript relative package versions
ChangJoo-Park c26e961
@nuxt/core needs eslint-module
ChangJoo-Park ab8be4a
Update tsconfig.json
ChangJoo-Park 57461b2
Update README for TypeScript
ChangJoo-Park f2e66a7
Merge branch 'typescript' of https://github.com/ChangJoo-Park/create-…
ChangJoo-Park aaa09be
standardize generating typescript components
NickBolles fafe31b
generate nuxt.config.ts instead of nuxt.config.js if typescript runti…
NickBolles 1a428b6
Add ts files to lint-staged if typescript is on
NickBolles 1b4d80e
Remove unused imports
NickBolles 34ecbfd
remove unused imports
NickBolles 403abfd
standardize generating typescript components
NickBolles e0fd272
generate nuxt.config.ts instead of nuxt.config.js if typescript runti…
NickBolles 5935b7f
Add ts files to lint-staged if typescript is on
NickBolles 9d5a65e
Remove unused imports
NickBolles 8449d54
remove unused imports
NickBolles c266cbb
fix: only prompt for jsconfig.json if language is js
NickBolles c67001d
feat(typescript): add vue-shims.d.ts
NickBolles e67766d
fix: use _ to indicate unused vars and avoid lint issue
NickBolles 76dc688
feat(typescript): add jest typings if typescript is enabled
NickBolles 0f60127
fix: fix typescript generation for framevuerk, vuesax and vuetify
NickBolles 0ffd829
feat(typescript): add typescript files to eslint
NickBolles 84ed1a8
fix: always show jsconfig, but add hint for typescript
NickBolles 4568528
fix: sync up nuxt.config for js and ts
NickBolles 73a814b
test: fix typescript runtime test, reset snapshots
NickBolles 9a44125
style: fix linting issues
NickBolles c55e86d
fix: disable vue/no-parsing-error
NickBolles b7edfbe
fix: code stye for PR comments
NickBolles 0cc044a
Merge branch 'master' into typescript
NickBolles 0e0cc70
test: remove old snapshot file
NickBolles 109dc39
test: update snapshots and code style
NickBolles 2cf51a4
style: fix duplicate line break
NickBolles 430be0b
Merge branch 'master' of https://github.com/nuxt/create-nuxt-app into…
NickBolles 5dbe0e5
fix: merge to package.js instead of package.json
NickBolles 2c337d5
fix: merge issues
NickBolles 2dc48dd
update test snapshots
NickBolles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -7,9 +7,10 @@ const rootDir = __dirname | |
|
||
module.exports = { | ||
prompts: require('./prompts'), | ||
templateData () { | ||
templateData() { | ||
const typescript = this.answers.language.includes('ts') | ||
const tsRuntime = this.answers.runtime && this.answers.runtime.includes('ts-runtime') | ||
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') | ||
|
@@ -24,7 +25,18 @@ module.exports = { | |
const { cliOptions = {} } = this.sao.opts | ||
const edge = cliOptions.edge ? '-edge' : '' | ||
|
||
const ifTrue = (condition, content, elseContent) => condition ? content : elseContent || '' | ||
const generateComponent = (imports, componentOptions) => { | ||
return ` | ||
<script ${ifTrue(typescript, `lang="ts"`)}> | ||
${ifTrue(typescript, `import Vue from 'vue'`)} | ||
${ifTrue(!!imports, imports)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that is there are imports, a carriage return should be ensured between imports and export. |
||
export default ${ifTrue(typescript, 'Vue.extend(' + componentOptions + ')', componentOptions)} | ||
</script>` | ||
} | ||
|
||
return { | ||
generateComponent, | ||
typescript, | ||
tsRuntime, | ||
pwa, | ||
|
@@ -40,24 +52,30 @@ module.exports = { | |
dotenv | ||
} | ||
}, | ||
actions () { | ||
actions() { | ||
const validation = validate(this.answers.name) | ||
validation.warnings && validation.warnings.forEach((warn) => { | ||
console.warn('Warning:', warn) | ||
}) | ||
validation.errors && validation.errors.forEach((err) => { | ||
console.error('Error:', err) | ||
}) | ||
validation.warnings && | ||
validation.warnings.forEach((warn) => { | ||
console.warn('Warning:', warn) | ||
}) | ||
validation.errors && | ||
validation.errors.forEach((err) => { | ||
console.error('Error:', err) | ||
}) | ||
validation.errors && validation.errors.length && process.exit(1) | ||
|
||
const actions = [{ | ||
type: 'add', | ||
files: '**', | ||
templateDir: 'template/nuxt', | ||
filters: { | ||
'static/icon.png': 'features.includes("pwa")' | ||
const actions = [ | ||
{ | ||
type: 'add', | ||
files: '**', | ||
templateDir: 'template/nuxt', | ||
filters: { | ||
'static/icon.png': 'features.includes("pwa")', | ||
'nuxt.config.ts': 'runtime && runtime.includes("ts-runtime")', | ||
'nuxt.config.js': '!runtime || !runtime.includes("ts-runtime")' | ||
} | ||
} | ||
}] | ||
] | ||
|
||
if (this.answers.ui !== 'none') { | ||
actions.push({ | ||
|
@@ -107,6 +125,7 @@ module.exports = { | |
'_.prettierrc': 'linter.includes("prettier")', | ||
'_jsconfig.json': 'devTools.includes("jsconfig.json")', | ||
'tsconfig.json': 'language.includes("ts")', | ||
'vue-shims.d.ts': 'language.includes("ts")', | ||
'semantic.yml': 'devTools.includes("semantic-pull-requests")', | ||
'.env': 'features.includes("dotenv")', | ||
'_stylelint.config.js': 'linter.includes("stylelint")' | ||
|
@@ -129,7 +148,7 @@ module.exports = { | |
actions.push({ | ||
type: 'modify', | ||
files: 'package.json', | ||
handler (data) { | ||
handler(data) { | ||
delete data.scripts[''] | ||
delete data.dependencies[''] | ||
delete data.devDependencies[''] | ||
|
@@ -139,7 +158,7 @@ module.exports = { | |
|
||
return actions | ||
}, | ||
async completed () { | ||
async completed() { | ||
this.gitInit() | ||
|
||
await this.npmInstall({ npmClient: this.answers.pm }) | ||
|
@@ -161,7 +180,9 @@ module.exports = { | |
const cdMsg = isNewFolder ? chalk`\t{cyan cd ${relativeOutFolder}}\n` : '' | ||
const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run' | ||
|
||
console.log(chalk`\n🎉 {bold Successfully created project} {cyan ${this.answers.name}}\n`) | ||
console.log( | ||
chalk`\n🎉 {bold Successfully created project} {cyan ${this.answers.name}}\n` | ||
) | ||
|
||
console.log(chalk` {bold To get started:}\n`) | ||
console.log(chalk`${cdMsg}\t{cyan ${pmRun} dev}\n`) | ||
|
@@ -176,7 +197,9 @@ module.exports = { | |
} | ||
|
||
if (this.answers.language.includes('ts')) { | ||
console.log(chalk`\n {bold For TypeScript users.} \n\n See : https://typescript.nuxtjs.org/cookbook/components/`) | ||
console.log( | ||
chalk`\n {bold For TypeScript users.} \n\n See : https://typescript.nuxtjs.org/cookbook/components/` | ||
) | ||
} | ||
} | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,15 @@ | |
</div> | ||
</template> | ||
|
||
<%- generateComponent(` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like the |
||
import Logo from '~/components/Logo.vue' | ||
import VuesaxLogo from '~/components/VuesaxLogo.vue' | ||
`,`{ | ||
components: { | ||
Logo, | ||
VuesaxLogo | ||
} | ||
}`)%> | ||
<script> | ||
import Logo from '~/components/Logo.vue' | ||
import VuesaxLogo from '~/components/VuesaxLogo.vue' | ||
|
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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -86,6 +86,7 @@ module.exports = { | |||
/* | ||||
** Nuxt.js dev-modules | ||||
*/ | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think this carriage return is needed as it's not done for the other comments on top of properties.
Suggested change
|
||||
buildModules: [ | ||||
<%_ if (typescript) {_%> | ||||
'@nuxt/typescript-build', | ||||
|
@@ -180,7 +181,7 @@ module.exports = { | |||
/* | ||||
** You can extend webpack config here | ||||
*/ | ||||
extend (config, ctx) { | ||||
extend (_config, _ctx) { | ||||
} | ||||
} | ||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO Unnecessary change