Template script to setup TypeScript development environment

This commit is contained in:
soulehshaikh99 2021-08-14 01:02:38 +05:30
parent c3635c281d
commit bdf783c662

View File

@ -22,17 +22,17 @@ const projectRoot = argv[2] || path.join(__dirname, "..")
// Add deps to pkg.json // Add deps to pkg.json
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8")) const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, { packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
"svelte-check": "^1.0.0", "svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0", "svelte-preprocess": "^4.0.0",
"@rollup/plugin-typescript": "^8.0.0", "@rollup/plugin-typescript": "^8.0.0",
"typescript": "^4.0.0", "typescript": "^4.0.0",
"tslib": "^2.0.0", "tslib": "^2.0.0",
"@tsconfig/svelte": "^1.0.0" "@tsconfig/svelte": "^2.0.0"
}) })
// Add script for checking // Add script for checking
packageJSON.scripts = Object.assign(packageJSON.scripts, { packageJSON.scripts = Object.assign(packageJSON.scripts, {
"validate": "svelte-check" "check": "svelte-check --tsconfig ./tsconfig.json"
}) })
// Write the package JSON // Write the package JSON
@ -85,6 +85,10 @@ const tsconfig = `{
const tsconfigPath = path.join(projectRoot, "tsconfig.json") const tsconfigPath = path.join(projectRoot, "tsconfig.json")
fs.writeFileSync(tsconfigPath, tsconfig) fs.writeFileSync(tsconfigPath, tsconfig)
// Add global.d.ts
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
// Delete this script, but not during testing // Delete this script, but not during testing
if (!argv[2]) { if (!argv[2]) {
// Remove the script // Remove the script