Add template tsconfigs for users to extend from (#4439)
* Add tsconfig templates to extend from * Add changeset * Right order for assign parameters * Add tsconfigs to export map
This commit is contained in:
parent
fcc36ac908
commit
77ce6be30c
33 changed files with 119 additions and 343 deletions
6
.changeset/healthy-kangaroos-smoke.md
Normal file
6
.changeset/healthy-kangaroos-smoke.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'astro': patch
|
||||
'create-astro': patch
|
||||
---
|
||||
|
||||
Add tsconfig templates for users to extend from
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Needed for TypeScript intellisense in the template inside Vue files
|
||||
"jsx": "preserve",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
"jsx": "preserve"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
// Preact specific settings
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
"jsxImportSource": "preact"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
// Solid specific settings
|
||||
"jsx": "preserve",
|
||||
"jsxImportSource": "solid-js",
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Needed for TypeScript intellisense in the template inside Vue files
|
||||
"jsx": "preserve",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
"jsx": "preserve"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig();
|
||||
export default defineConfig({});
|
||||
|
|
|
@ -1,18 +1,3 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
// Preact specific settings
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Add type definitions for our Astro runtime.
|
||||
"types": ["astro/client"]
|
||||
}
|
||||
"extends": "astro/tsconfigs/base"
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
"./client": "./client.d.ts",
|
||||
"./client-base": "./client-base.d.ts",
|
||||
"./astro-jsx": "./astro-jsx.d.ts",
|
||||
"./tsconfigs/*.json": "./tsconfigs/*",
|
||||
"./tsconfigs/*": "./tsconfigs/*.json",
|
||||
"./jsx/*": "./dist/jsx/*",
|
||||
"./jsx-runtime": "./dist/jsx-runtime/index.js",
|
||||
"./config": "./config.mjs",
|
||||
|
@ -65,6 +67,7 @@
|
|||
},
|
||||
"files": [
|
||||
"components",
|
||||
"tsconfigs",
|
||||
"dist",
|
||||
"astro.js",
|
||||
"config.d.ts",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
|
@ -9,11 +10,11 @@
|
|||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
// Astro directly run TypeScript code, no transpilation needed.
|
||||
"noEmit": true,
|
||||
// Enable strict type checking.
|
||||
"strict": true,
|
||||
// Error when a value import is only used as a type.
|
||||
"importsNotUsedAsValues": "error"
|
||||
// Report an error when importing a file using a casing different from the casing on disk.
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
// Properly support importing CJS modules in ESM
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
9
packages/astro/tsconfigs/strict.json
Normal file
9
packages/astro/tsconfigs/strict.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
// Error when a value import is only used as a type.
|
||||
"importsNotUsedAsValues": "error"
|
||||
}
|
||||
}
|
|
@ -1,20 +1,7 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./strict.json",
|
||||
"compilerOptions": {
|
||||
// Enable top-level await, and other modern ESM features.
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
// Enable node-style module resolution, for things like npm package imports.
|
||||
"moduleResolution": "node",
|
||||
// Enable JSON imports.
|
||||
"resolveJsonModule": true,
|
||||
// Enable stricter transpilation for better output.
|
||||
"isolatedModules": true,
|
||||
// Astro will directly run your TypeScript code, no transpilation needed.
|
||||
"noEmit": true,
|
||||
// Enable strict type checking.
|
||||
"strict": true,
|
||||
// Error when a value import is only used as a type.
|
||||
"importsNotUsedAsValues": "error",
|
||||
// Report errors for fallthrough cases in switch statements
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
// Force functions designed to override their parent class to be specified as `override`.
|
||||
|
@ -28,6 +15,10 @@
|
|||
// Force the usage of the indexed syntax to access fields declared using an index signature.
|
||||
"noUncheckedIndexedAccess": true,
|
||||
// Report an error when the value `undefined` is given to an optional property that doesn't specify `undefined` as a valid value.
|
||||
"exactOptionalPropertyTypes": true
|
||||
"exactOptionalPropertyTypes": true,
|
||||
// Report an error for unreachable code instead of just a warning.
|
||||
"allowUnreachableCode": false,
|
||||
// Report an error for unused labels instead of just a warning.
|
||||
"allowUnusedLabels": false
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"chalk": "^5.0.1",
|
||||
"comment-json": "^4.2.3",
|
||||
"degit": "^2.8.4",
|
||||
"execa": "^6.1.0",
|
||||
"kleur": "^4.1.4",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint no-console: 'off' */
|
||||
import { assign, parse, stringify } from 'comment-json';
|
||||
import degit from 'degit';
|
||||
import { execa, execaCommand } from 'execa';
|
||||
import fs from 'fs';
|
||||
|
@ -7,7 +8,6 @@ import ora from 'ora';
|
|||
import os from 'os';
|
||||
import path from 'path';
|
||||
import prompts from 'prompts';
|
||||
import url from 'url';
|
||||
import detectPackageManager from 'which-pm-runs';
|
||||
import yargs from 'yargs-parser';
|
||||
import { loadWithRocketGradient, rocketAscii } from './gradient.js';
|
||||
|
@ -117,6 +117,7 @@ export async function main() {
|
|||
const hash = args.commit ? `#${args.commit}` : '';
|
||||
|
||||
// Don't touch the template name if a GitHub repo was provided, ex: `--template cassidoo/shopify-react-astro`
|
||||
const isThirdParty = options.template.includes('/');
|
||||
const templateTarget = options.template.includes('/')
|
||||
? options.template
|
||||
: `withastro/astro/examples/${options.template}#latest`;
|
||||
|
@ -308,7 +309,7 @@ export async function main() {
|
|||
{
|
||||
title: 'Strictest',
|
||||
description: 'Enable all typechecking rules',
|
||||
value: 'stricter',
|
||||
value: 'strictest',
|
||||
},
|
||||
{
|
||||
title: 'I prefer not to use TypeScript',
|
||||
|
@ -335,7 +336,7 @@ export async function main() {
|
|||
console.log(` Astro supports TypeScript inside of ".astro" component scripts, so`);
|
||||
console.log(` we still need to create some TypeScript-related files in your project.`);
|
||||
console.log(` You can safely ignore these files, but don't delete them!`);
|
||||
console.log(dim(' (ex: tsconfig.json, src/types.d.ts)'));
|
||||
console.log(dim(' (ex: tsconfig.json, src/env.d.ts)'));
|
||||
console.log(``);
|
||||
tsResponse.typescript = 'default';
|
||||
await wait(300);
|
||||
|
@ -344,14 +345,34 @@ export async function main() {
|
|||
ora().info(dim(`--dry-run enabled, skipping.`));
|
||||
} else if (tsResponse.typescript) {
|
||||
if (tsResponse.typescript !== 'default') {
|
||||
fs.copyFileSync(
|
||||
path.join(
|
||||
url.fileURLToPath(new URL('..', import.meta.url)),
|
||||
'tsconfigs',
|
||||
`tsconfig.${tsResponse.typescript}.json`
|
||||
),
|
||||
path.join(cwd, 'tsconfig.json')
|
||||
);
|
||||
const templateTSConfigPath = path.join(cwd, 'tsconfig.json');
|
||||
fs.readFile(templateTSConfigPath, (err, data) => {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
// If the template doesn't have a tsconfig.json, let's add one instead
|
||||
fs.writeFileSync(
|
||||
templateTSConfigPath,
|
||||
stringify({ extends: `astro/tsconfigs/${tsResponse.typescript}` }, null, 2)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const templateTSConfig = parse(data.toString());
|
||||
|
||||
if (templateTSConfig && typeof templateTSConfig === 'object') {
|
||||
const result = assign(templateTSConfig, {
|
||||
extends: `astro/tsconfigs/${tsResponse.typescript}`,
|
||||
});
|
||||
|
||||
fs.writeFileSync(templateTSConfigPath, stringify(result, null, 2));
|
||||
} else {
|
||||
console.log(
|
||||
yellow(
|
||||
"There was an error applying the requested TypeScript settings. This could be because the template's tsconfig.json is malformed"
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
ora().succeed('TypeScript settings applied!');
|
||||
}
|
||||
|
|
|
@ -2108,6 +2108,7 @@ importers:
|
|||
astro-scripts: workspace:*
|
||||
chai: ^4.3.6
|
||||
chalk: ^5.0.1
|
||||
comment-json: ^4.2.3
|
||||
degit: ^2.8.4
|
||||
execa: ^6.1.0
|
||||
kleur: ^4.1.4
|
||||
|
@ -2119,6 +2120,7 @@ importers:
|
|||
yargs-parser: ^21.0.1
|
||||
dependencies:
|
||||
chalk: 5.0.1
|
||||
comment-json: 4.2.3
|
||||
degit: 2.8.4
|
||||
execa: 6.1.0
|
||||
kleur: 4.1.5
|
||||
|
@ -9479,6 +9481,10 @@ packages:
|
|||
resolution: {integrity: sha512-sNRaPGh9nnmdC8Zf+pT3UqP8rnWj5Hf9wiFGsX3wUQ2yVSIhO2ShFwCoceIPpB41QF6i2OEmrHmCo36xronCVA==}
|
||||
dev: false
|
||||
|
||||
/array-timsort/1.0.3:
|
||||
resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==}
|
||||
dev: false
|
||||
|
||||
/array-union/2.1.0:
|
||||
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -10050,6 +10056,17 @@ packages:
|
|||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
dev: true
|
||||
|
||||
/comment-json/4.2.3:
|
||||
resolution: {integrity: sha512-SsxdiOf064DWoZLH799Ata6u7iV658A11PlWtZATDlXPpKGJnbJZ5Z24ybixAi+LUUqJ/GKowAejtC5GFUG7Tw==}
|
||||
engines: {node: '>= 6'}
|
||||
dependencies:
|
||||
array-timsort: 1.0.3
|
||||
core-util-is: 1.0.3
|
||||
esprima: 4.0.1
|
||||
has-own-prop: 2.0.0
|
||||
repeat-string: 1.6.1
|
||||
dev: false
|
||||
|
||||
/common-ancestor-path/1.0.1:
|
||||
resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==}
|
||||
dev: false
|
||||
|
@ -11784,6 +11801,11 @@ packages:
|
|||
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
/has-own-prop/2.0.0:
|
||||
resolution: {integrity: sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/has-package-exports/1.3.0:
|
||||
resolution: {integrity: sha512-e9OeXPQnmPhYoJ63lXC4wWe34TxEGZDZ3OQX9XRqp2VwsfLl3bQBy7VehLnd34g3ef8CmYlBLGqEMKXuz8YazQ==}
|
||||
dependencies:
|
||||
|
@ -15141,6 +15163,11 @@ packages:
|
|||
unified: 10.1.2
|
||||
dev: true
|
||||
|
||||
/repeat-string/1.6.1:
|
||||
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
|
||||
engines: {node: '>=0.10'}
|
||||
dev: false
|
||||
|
||||
/require-directory/2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
|
Loading…
Reference in a new issue