forked from nuxt/typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pooya parsa
committed
May 10, 2019
0 parents
commit bd215fa
Showing
30 changed files
with
9,978 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node | ||
steps: | ||
# Checkout repository | ||
- checkout | ||
|
||
# Restore cache | ||
- restore_cache: | ||
key: yarn-cache-{{ checksum "yarn.lock" }} | ||
|
||
# Install dependencies | ||
- run: | ||
name: Install Dependencies | ||
command: NODE_ENV=dev yarn | ||
|
||
# Keep cache | ||
- save_cache: | ||
key: yarn-cache-{{ checksum "yarn.lock" }} | ||
paths: | ||
- "node_modules" | ||
|
||
# Lint | ||
- run: | ||
name: Lint | ||
command: yarn lint | ||
|
||
# Tests | ||
# - run: | ||
# name: Tests | ||
# command: yarn jest | ||
|
||
# Coverage | ||
- run: | ||
name: Coverage | ||
command: yarn codecov |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
.nuxt | ||
coverage |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
root: true, | ||
parserOptions: { | ||
parser: 'babel-eslint', | ||
sourceType: 'module' | ||
}, | ||
extends: [ | ||
'@nuxtjs' | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
*.iml | ||
.idea | ||
*.log | ||
.nuxt | ||
.vscode | ||
.DS_Store | ||
coverage | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Nuxt Typescript | ||
|
||
|
||
|
||
## 📑 License | ||
|
||
[MIT License](./LICENSE) | ||
|
||
Copyright (c) Nuxt.js Team |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
|
||
expand: true, | ||
|
||
forceExit: true, | ||
|
||
setupFilesAfterEnv: ['./test/utils/setup'], | ||
|
||
coverageDirectory: './coverage', | ||
|
||
collectCoverageFrom: [ | ||
'**/packages/*/src/**/*.js' | ||
], | ||
|
||
transformIgnorePatterns: [ | ||
'node_modules/(?!(@nuxt|nuxt))' | ||
], | ||
|
||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
'^.+\\.js$': 'babel-jest', | ||
'^.+\\.vue$': 'vue-jest' | ||
}, | ||
|
||
moduleFileExtensions: [ | ||
'ts', | ||
'js', | ||
'json' | ||
] | ||
} | ||
#!/usr/bin/env node |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "independent", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"conventionalCommits": true, | ||
"exact": true, | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"command": { | ||
"publish": { | ||
"npmClient": "npm" | ||
}, | ||
"init": { | ||
"exact": true | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"scripts": { | ||
"nuxt-ts": "node ./packages/nuxt-ts/bin/nuxt-ts.js", | ||
"lint": "eslint packages", | ||
"test": "yarn lint" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "latest", | ||
"@babel/preset-env": "latest", | ||
"@nuxtjs/eslint-config": "latest", | ||
"babel-eslint": "latest", | ||
"babel-jest": "latest", | ||
"codecov": "latest", | ||
"core-js": "2", | ||
"eslint": "latest", | ||
"eslint-config-standard": "latest", | ||
"eslint-plugin-import": "latest", | ||
"eslint-plugin-jest": "latest", | ||
"eslint-plugin-node": "latest", | ||
"eslint-plugin-promise": "latest", | ||
"eslint-plugin-standard": "latest", | ||
"eslint-plugin-vue": "latest", | ||
"jest": "^24.8.0", | ||
"nuxt-edge": "^2.7.0-25953129.a88e8b60" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path') | ||
const { getNuxtBin, getRootdirFromArgv, registerTSNode, setupTSConfig } = require('..') | ||
|
||
async function main() { | ||
const rootDir = getRootdirFromArgv() | ||
const tsConfigPath = path.resolve(rootDir, 'tsconfig.json') | ||
|
||
await setupTSConfig(tsConfigPath) | ||
|
||
registerTSNode(tsConfigPath) | ||
|
||
require(getNuxtBin()) | ||
} | ||
|
||
main().catch((error) => { | ||
require('consola').error(error) | ||
process.exit(1) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
...require('./utils'), | ||
registerTSNode: require('./register'), | ||
setupTSConfig: require('./setup') | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { register } = require('ts-node') | ||
|
||
function registerTSNode(tsconfigPath) { | ||
// https://github.com/TypeStrong/ts-node | ||
register({ | ||
project: tsconfigPath, | ||
compilerOptions: { | ||
module: 'commonjs' | ||
} | ||
}) | ||
} | ||
|
||
module.exports = registerTSNode |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { exists, readFile, writeJSON } = require('fs-extra') | ||
const consola = require('consola') | ||
const defaultTsJsonConfig = require('./tsconfig') | ||
|
||
async function setupTSConfig(tsConfigPath) { | ||
let contents = '' | ||
|
||
if (await exists(tsConfigPath)) { | ||
contents = await readFile(tsConfigPath, 'utf-8') | ||
} | ||
|
||
if (!contents || contents === '{}') { | ||
consola.info(`Generating ${tsConfigPath.replace(process.cwd(), '')}`) | ||
await writeJSON(tsConfigPath, defaultTsJsonConfig, { spaces: 2 }) | ||
} | ||
} | ||
|
||
module.exports = setupTSConfig |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
compilerOptions: { | ||
target: 'esnext', | ||
module: 'esnext', | ||
moduleResolution: 'node', | ||
lib: [ | ||
'esnext', | ||
'esnext.asynciterable', | ||
'dom' | ||
], | ||
esModuleInterop: true, | ||
experimentalDecorators: true, | ||
allowJs: true, | ||
sourceMap: true, | ||
strict: true, | ||
noImplicitAny: false, | ||
noEmit: true, | ||
baseUrl: '.', | ||
paths: { | ||
'~/*': [ | ||
'./*' | ||
], | ||
'@/*': [ | ||
'./*' | ||
] | ||
}, | ||
types: [ | ||
'@types/node', | ||
'@nuxt/vue-app' | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const path = require('path') | ||
|
||
function getNuxtBin() { | ||
const binPath = [ | ||
'nuxt-edge/bin/nuxt.js', | ||
'nuxt/bin/nuxt.js', | ||
'nuxt-start-edge/bin/nuxt.js', | ||
'nuxt-start/bin/nuxt.js' | ||
] | ||
|
||
for (const bin of binPath) { | ||
try { | ||
return require.resolve(bin) | ||
} catch {} | ||
} | ||
} | ||
|
||
function getRootdirFromArgv() { | ||
const validCommands = ['dev', 'build', 'generate', 'start'] | ||
|
||
let rootDir = process.argv[2] | ||
if (validCommands.includes(rootDir)) { | ||
rootDir = process.argv[3] | ||
} | ||
if (!rootDir) { | ||
rootDir = '.' | ||
} | ||
|
||
return path.resolve(process.cwd(), rootDir) | ||
} | ||
|
||
module.exports = { | ||
getNuxtBin, | ||
getRootdirFromArgv | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "nuxt-ts", | ||
"version": "0.0.0", | ||
"repository": "nuxt/typescript", | ||
"license": "MIT", | ||
"files": [ | ||
"bin", | ||
"lib" | ||
], | ||
"main": "lib/index.js", | ||
"dependencies": { | ||
"consola": "^2.6.1", | ||
"fs-extra": "^7.0.1", | ||
"ts-node": "^8.1.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = function () { | ||
// TODO: Migrate from packages/webpack/src/config/base.js | ||
// if (_typescript.build && buildOptions.typescript && buildOptions.typescript.ignoreNotFoundWarnings) { | ||
// filters.push( | ||
// warn => warn.name === 'ModuleDependencyWarning' && | ||
// /export .* was not found in /.test(warn.message) | ||
// ) | ||
// } | ||
|
||
// TODO: Migrate from packages/webpack/src/config/client.js | ||
// TypeScript type checker | ||
// Only performs once per client compilation and only if `ts-loader` checker is not used (transpileOnly: true) | ||
// if (_typescript.build && buildOptions.typescript && buildOptions.typescript.typeCheck && !this.isModern && this.loaders.ts.transpileOnly) { | ||
// const ForkTsCheckerWebpackPlugin = require(this.buildContext.nuxt.resolver.resolveModule('fork-ts-checker-webpack-plugin')) | ||
// plugins.push(new ForkTsCheckerWebpackPlugin(Object.assign({ | ||
// vue: true, | ||
// tsconfig: path.resolve(rootDir, 'tsconfig.json'), | ||
// tslint: false, // We recommend using ESLint so we set this option to `false` by default | ||
// formatter: 'codeframe', | ||
// logger: consola | ||
// }, buildOptions.typescript.typeCheck))) | ||
// } | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@nuxt/typescript", | ||
"version": "0.0.0", | ||
"repository": "nuxt/typescript", | ||
"license": "MIT", | ||
"files": [ | ||
"lib" | ||
], | ||
"dependencies": { | ||
"@types/babel__core": "^7.1.1", | ||
"@types/chokidar": "^2.1.3", | ||
"@types/compression": "^0.0.36", | ||
"@types/etag": "^1.8.0", | ||
"@types/express": "^4.16.1", | ||
"@types/html-minifier": "^3.5.3", | ||
"@types/node": "^11.13.10", | ||
"@types/optimize-css-assets-webpack-plugin": "^1.3.4", | ||
"@types/serve-static": "^1.13.2", | ||
"@types/terser-webpack-plugin": "^1.2.1", | ||
"@types/webpack": "^4.4.31", | ||
"@types/webpack-bundle-analyzer": "^2.13.1", | ||
"@types/webpack-dev-middleware": "^2.0.2", | ||
"@types/webpack-hot-middleware": "^2.16.5", | ||
"consola": "^2.6.1", | ||
"fork-ts-checker-webpack-plugin": "^1.3.1", | ||
"fs-extra": "^7.0.1", | ||
"ts-loader": "^6.0.0", | ||
"typescript": "^3.4.5", | ||
"vue-property-decorator": "^8.1.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=8.6.0" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<Nuxt /> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Vue } from 'vue-property-decorator' | ||
@Component({ | ||
middleware: 'test' | ||
}) | ||
export default class DefaultLayout extends Vue {} | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export default () => {} |
Oops, something went wrong.