From 80bbe09a03ed4803a271a64af004cf037b843189 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:15:15 +0900 Subject: [PATCH 1/8] chore: add `.editorconfig` and update VSCode settings for consistent formatting Signed-off-by: Sora Morimoto --- .editorconfig | 9 +++++++++ .vscode/extensions.json | 4 +++- .vscode/settings.json | 11 +++++++++-- bases/bun.json | 8 +++----- bases/create-react-app.json | 8 +++++--- bases/cypress.json | 9 +++++++-- bases/deno.json | 2 -- bases/docusaurus.json | 15 +++++++++++---- bases/ember.json | 21 ++++----------------- bases/next.json | 18 ++++++++++++++---- bases/node10.json | 6 +++--- bases/node12.json | 9 ++++++--- bases/node14.json | 6 +++--- bases/node16.json | 6 +++--- bases/node17.json | 5 +++-- bases/node18.json | 7 +++---- bases/node19.json | 7 +++---- bases/node20.json | 6 +++--- bases/node21.json | 6 +++--- bases/node22.json | 9 ++++++--- bases/node23.json | 10 +++++++--- bases/node24.json | 2 -- bases/nuxt.json | 3 +-- bases/qjsengine.json | 7 ++++--- bases/react-native.json | 5 ++++- bases/remix.json | 12 ++++++++---- bases/strictest.json | 2 -- bases/svelte.json | 2 -- bases/vite-react.json | 9 +++++---- readme-extras/node-ts.md | 5 ++++- template/README.md | 6 +++--- test/index.ts | 2 +- test/tsconfig.json | 4 +++- 33 files changed, 141 insertions(+), 100 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c6c8b36 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 74baffc..09cf720 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,5 @@ { - "recommendations": ["denoland.vscode-deno"] + "recommendations": [ + "denoland.vscode-deno" + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 90342a9..9196d1d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,14 @@ { - "cSpell.words": ["Deno"], - "deno.enable": true, + "[json][jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" + }, + "cSpell.words": [ + "Deno" + ], + "files.associations": { + "*.json": "jsonc" } } diff --git a/bases/bun.json b/bases/bun.json index ec7d09a..0eddf00 100644 --- a/bases/bun.json +++ b/bases/bun.json @@ -3,29 +3,27 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Bun", "docs": "https://bun.com/docs/typescript", - "compilerOptions": { // Environment setup & latest features - "lib": ["ESNext"], + "lib": [ + "ESNext" + ], "target": "ESNext", "module": "Preserve", "moduleDetection": "force", "jsx": "react-jsx", "allowJs": true, - // Bundler mode "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "noEmit": true, - // Best practices "strict": true, "skipLibCheck": true, "noFallthroughCasesInSwitch": true, "noUncheckedIndexedAccess": true, "noImplicitOverride": true, - // Some stricter flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, diff --git a/bases/create-react-app.json b/bases/create-react-app.json index 8879567..5c2890e 100644 --- a/bases/create-react-app.json +++ b/bases/create-react-app.json @@ -2,13 +2,15 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Create React App", "_version": "2.0.0", - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "module": "esnext", "moduleResolution": "bundler", "target": "es2015", - "allowJs": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, diff --git a/bases/cypress.json b/bases/cypress.json index 223fc97..be2868d 100644 --- a/bases/cypress.json +++ b/bases/cypress.json @@ -3,7 +3,12 @@ "display": "Cypress", "compilerOptions": { "target": "es5", - "lib": ["es5", "dom"], - "types": ["cypress"] + "lib": [ + "es5", + "dom" + ], + "types": [ + "cypress" + ] } } diff --git a/bases/deno.json b/bases/deno.json index 79eca85..3a0d4b2 100644 --- a/bases/deno.json +++ b/bases/deno.json @@ -1,10 +1,8 @@ { // This is based on https://deno.land/manual/getting_started/typescript#custom-typescript-compiler-options // then the defaults are removed. - "$schema": "https://www.schemastore.org/tsconfig", "display": "Deno", - "compilerOptions": { "jsx": "react", "lib": [], diff --git a/bases/docusaurus.json b/bases/docusaurus.json index 7fcee4d..abbcb2c 100644 --- a/bases/docusaurus.json +++ b/bases/docusaurus.json @@ -3,19 +3,26 @@ "display": "Docusaurus v2", "docs": "https://v2.docusaurus.io/docs/typescript-support", "_version": "2.0.0", - "compilerOptions": { "allowJs": true, "esModuleInterop": true, "jsx": "react", - "lib": ["dom"], + "lib": [ + "dom" + ], "module": "esnext", "moduleResolution": "bundler", "noEmit": true, - "types": ["node", "@docusaurus/module-type-aliases", "@docusaurus/theme-classic"], + "types": [ + "node", + "@docusaurus/module-type-aliases", + "@docusaurus/theme-classic" + ], "baseUrl": ".", "paths": { - "@site/*": ["./*"] + "@site/*": [ + "./*" + ] }, "skipLibCheck": true } diff --git a/bases/ember.json b/bases/ember.json index 497cf30..d9cdff7 100644 --- a/bases/ember.json +++ b/bases/ember.json @@ -3,8 +3,7 @@ "display": "Ember", "docs": "https://guides.emberjs.com/release/typescript/", "_version": "3.0.0", - "_deprecated": true, - + "_deprecated": true, // This is the base config used by Ember apps and addons. When actually used // via Ember CLI (e.g. ember-cli-typescript's blueprint), it additionally has // `compilerOptions.baseUrl`, `compilerOptions.paths`, and `include` set. @@ -12,11 +11,9 @@ "target": "es2023", "module": "esnext", "moduleResolution": "bundler", - // We don't want to include types dependencies in our compiled output, so tell TypeScript // to enforce using `import type` instead of `import` for Types. "verbatimModuleSyntax": true, - // Trying to check Ember apps and addons with `allowJs: true` is a recipe // for many unresolveable type errors, because with *considerable* extra // configuration it ends up including many files which are *not* valid and @@ -24,20 +21,17 @@ // valid Node-resolveable locations and may not have TS-ready types. This // will likely improve over time "allowJs": false, - // Practically, it is *nearly* impossible to have every type-checked // package in your dependency graph to have compatible types. - // Good stewards of the ecosystem may opt to set this to false and try to + // Good stewards of the ecosystem may opt to set this to false and try to // fix packages with failures, but for most people, the error information // is inactionable noise. "skipLibCheck": true, - // --- TS for SemVer Types compatibility // Strictness settings -- you should *not* change these: Ember code is not // guaranteed to type check with these set to looser values. "strict": true, "noUncheckedIndexedAccess": true, - // Interop: this is viral and will require anyone downstream of your package // to *also* set them to true. However, this represents the way that // bundlers actually work, and is future-compatible with the closest module @@ -47,14 +41,11 @@ // intentionally leave `esModuleInterop` unset, so that it gets whatever TS // provides as the default for the currently-specified `module` mode. "allowSyntheticDefaultImports": true, - // --- Lint-style rules - // TypeScript also supplies some lint-style checks; nearly all of them are // better handled by ESLint with the `@typescript-eslint`. This one is more // like a safety check, though, so we leave it on. "noPropertyAccessFromIndexSignature": true, - // --- Compilation/integration settings // Setting `noEmitOnError` here allows tools trying to respect the tsconfig // to still emit code without breaking on errors. @@ -63,29 +54,25 @@ // This helps hasten development by allowing devs to prototype before coming // to a decision on what they want their types to be. "noEmitOnError": false, - // We use Babel for emitting runtime code, because it's very important that // we always and only use the same transpiler for non-stable features, in // particular decorators. If you were to change this to `true`, it could // lead to accidentally generating code with `tsc` instead of Babel, and // could thereby result in broken code at runtime. "noEmit": true, - // Ember makes heavy use of decorators; TS does not support them at all // without this flag. "experimentalDecorators": true, - // We don't use TS for compilation, so we can disable these. // Library authors should set declaration and declarationMap to true, however "declaration": false, "declarationMap": false, "inlineSourceMap": false, "inlineSources": false, - // Don't implicitly pull in declarations from `@types` packages unless we // actually import from them AND the package in question doesn't bring its - // own types. - // + // own types. + // // You may wish to override this e.g. with `"types": ["ember-source/types"]` "types": [] } diff --git a/bases/next.json b/bases/next.json index ec09451..824f072 100644 --- a/bases/next.json +++ b/bases/next.json @@ -2,9 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Next.js", "_version": "2.0.0", - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -22,6 +25,13 @@ } ] }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] } diff --git a/bases/node10.json b/bases/node10.json index 09fdb40..6b904ae 100644 --- a/bases/node10.json +++ b/bases/node10.json @@ -1,12 +1,12 @@ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 10", - "compilerOptions": { - "lib": ["es2018"], + "lib": [ + "es2018" + ], "module": "commonjs", "target": "es2018", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node12.json b/bases/node12.json index 0f9848d..283b4ae 100644 --- a/bases/node12.json +++ b/bases/node12.json @@ -2,12 +2,15 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 12", "_version": "12.1.0", - "compilerOptions": { - "lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"], + "lib": [ + "es2019", + "es2020.promise", + "es2020.bigint", + "es2020.string" + ], "module": "node16", "target": "es2019", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node14.json b/bases/node14.json index d096fc6..fd61e06 100644 --- a/bases/node14.json +++ b/bases/node14.json @@ -2,12 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 14", "_version": "14.1.0", - "compilerOptions": { - "lib": ["es2020"], + "lib": [ + "es2020" + ], "module": "node16", "target": "es2020", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node16.json b/bases/node16.json index 3fcb84e..eea09c9 100644 --- a/bases/node16.json +++ b/bases/node16.json @@ -2,12 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 16", "_version": "16.1.0", - "compilerOptions": { - "lib": ["es2021"], + "lib": [ + "es2021" + ], "module": "node16", "target": "es2021", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node17.json b/bases/node17.json index df6358b..b8f692d 100644 --- a/bases/node17.json +++ b/bases/node17.json @@ -3,10 +3,11 @@ "display": "Node 17", "_version": "17.1.0", "compilerOptions": { - "lib": ["es2022"], + "lib": [ + "es2022" + ], "module": "node16", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node18.json b/bases/node18.json index 987b10f..fc72f6f 100644 --- a/bases/node18.json +++ b/bases/node18.json @@ -1,14 +1,13 @@ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 18", - "_version": "18.2.0", - "compilerOptions": { - "lib": ["es2023"], + "lib": [ + "es2023" + ], "module": "node16", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node19.json b/bases/node19.json index d80f479..5917651 100644 --- a/bases/node19.json +++ b/bases/node19.json @@ -1,14 +1,13 @@ { "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 19", - "_version": "19.1.0", - "compilerOptions": { - "lib": ["es2023"], + "lib": [ + "es2023" + ], "module": "node16", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node20.json b/bases/node20.json index 8ca9d26..6584e00 100644 --- a/bases/node20.json +++ b/bases/node20.json @@ -2,12 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 20", "_version": "20.1.0", - "compilerOptions": { - "lib": ["es2023"], + "lib": [ + "es2023" + ], "module": "nodenext", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node21.json b/bases/node21.json index 02c94a9..231bee7 100644 --- a/bases/node21.json +++ b/bases/node21.json @@ -2,12 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 21", "_version": "21.0.0", - "compilerOptions": { - "lib": ["es2023"], + "lib": [ + "es2023" + ], "module": "nodenext", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node22.json b/bases/node22.json index 11b642f..ee3d2be 100644 --- a/bases/node22.json +++ b/bases/node22.json @@ -2,12 +2,15 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 22", "_version": "22.0.0", - "compilerOptions": { - "lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator"], + "lib": [ + "es2024", + "ESNext.Array", + "ESNext.Collection", + "ESNext.Iterator" + ], "module": "nodenext", "target": "es2022", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node23.json b/bases/node23.json index cf5377d..4932c8d 100644 --- a/bases/node23.json +++ b/bases/node23.json @@ -2,12 +2,16 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 23", "_version": "23.0.0", - "compilerOptions": { - "lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator", "ESNext.Promise"], + "lib": [ + "es2024", + "ESNext.Array", + "ESNext.Collection", + "ESNext.Iterator", + "ESNext.Promise" + ], "module": "nodenext", "target": "es2024", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/node24.json b/bases/node24.json index f386a38..ea192e4 100644 --- a/bases/node24.json +++ b/bases/node24.json @@ -2,7 +2,6 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Node 24", "_version": "24.0.0", - "compilerOptions": { "lib": [ "es2024", @@ -13,7 +12,6 @@ ], "module": "nodenext", "target": "es2024", - "strict": true, "esModuleInterop": true, "skipLibCheck": true, diff --git a/bases/nuxt.json b/bases/nuxt.json index 876fcf8..9fece9c 100644 --- a/bases/nuxt.json +++ b/bases/nuxt.json @@ -2,7 +2,6 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Nuxt", "_version": "2.0.0", - "compilerOptions": { "target": "esnext", "module": "esnext", @@ -33,7 +32,7 @@ }, "exclude": [ "node_modules", - ".nuxt", + ".nuxt", "dist" ] } diff --git a/bases/qjsengine.json b/bases/qjsengine.json index 1e26fcd..4140165 100644 --- a/bases/qjsengine.json +++ b/bases/qjsengine.json @@ -1,15 +1,16 @@ { - // https://doc.qt.io/qt-5/qjsengine.html + // https://doc.qt.io/qt-5/qjsengine.html "$schema": "https://www.schemastore.org/tsconfig", "display": "QJSEngine", - "compilerOptions": { // Technically QTJSEngine supportes ES2016, however there are issues with // arrow functions where in certain contexts "this" does not exist. // Targeting ES5 instead fixes these issues by binding this to a variable // and closing over that instead. "target": "ES5", - "lib": ["ES2016"], + "lib": [ + "ES2016" + ], "module": "none", "esModuleInterop": false, "strict": true diff --git a/bases/react-native.json b/bases/react-native.json index cec059c..a534d36 100644 --- a/bases/react-native.json +++ b/bases/react-native.json @@ -5,7 +5,10 @@ "compilerOptions": { "target": "esnext", "module": "commonjs", - "types": ["react-native", "jest"], + "types": [ + "react-native", + "jest" + ], "lib": [ "es2019", "es2020.bigint", diff --git a/bases/remix.json b/bases/remix.json index 3d0e74e..3640667 100644 --- a/bases/remix.json +++ b/bases/remix.json @@ -2,9 +2,12 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Remix", "_version": "2.0.0", - "compilerOptions": { - "lib": ["dom", "dom.iterable", "es2019"], + "lib": [ + "dom", + "dom.iterable", + "es2019" + ], "isolatedModules": true, "esModuleInterop": true, "jsx": "react-jsx", @@ -16,9 +19,10 @@ "allowJs": true, "baseUrl": ".", "paths": { - "~/*": ["./app/*"] + "~/*": [ + "./app/*" + ] }, - // Remix takes care of building everything in `remix build`. "noEmit": true } diff --git a/bases/strictest.json b/bases/strictest.json index 090c390..2704006 100644 --- a/bases/strictest.json +++ b/bases/strictest.json @@ -11,9 +11,7 @@ "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, - "isolatedModules": true, - "esModuleInterop": true, "skipLibCheck": true }, diff --git a/bases/svelte.json b/bases/svelte.json index 2f9c578..2e74d1b 100644 --- a/bases/svelte.json +++ b/bases/svelte.json @@ -2,7 +2,6 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Svelte", "_version": "5.0.0", - "compilerOptions": { "module": "esnext", "moduleResolution": "bundler", @@ -17,7 +16,6 @@ enable source maps by default. */ "sourceMap": true, - "strict": true, "esModuleInterop": true, "skipLibCheck": true diff --git a/bases/vite-react.json b/bases/vite-react.json index c5a3997..08583e8 100644 --- a/bases/vite-react.json +++ b/bases/vite-react.json @@ -2,15 +2,17 @@ "$schema": "https://www.schemastore.org/tsconfig", "display": "Vite React", "_version": "7.0.0", - "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2022", "useDefineForClassFields": true, - "lib": ["ES2022", "DOM", "DOM.Iterable"], + "lib": [ + "ES2022", + "DOM", + "DOM.Iterable" + ], "module": "ESNext", "skipLibCheck": true, - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, @@ -18,7 +20,6 @@ "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", - /* Linting */ "strict": true, "noUnusedLocals": true, diff --git a/readme-extras/node-ts.md b/readme-extras/node-ts.md index 993508c..40e6880 100644 --- a/readme-extras/node-ts.md +++ b/readme-extras/node-ts.md @@ -4,6 +4,9 @@ This file is meant to be used in conjunction with other Node.js configurations, ```json { - "extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"] + "extends": [ + "@tsconfig/node22/tsconfig.json", + "@tsconfig/node-ts/tsconfig.json" + ] } ``` diff --git a/template/README.md b/template/README.md index ea42fae..b1dc6d3 100644 --- a/template/README.md +++ b/template/README.md @@ -12,10 +12,10 @@ Add to your `tsconfig.json`: ```json "extends": "@tsconfig/[filename]/tsconfig.json" ``` -[readme-extra] ---- -The `tsconfig.json`: +## [readme-extra] + +The `tsconfig.json`: ```jsonc [tsconfig] diff --git a/test/index.ts b/test/index.ts index eb171b6..accefce 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1 +1 @@ -console.log("Hello World") +console.log("Hello World"); diff --git a/test/tsconfig.json b/test/tsconfig.json index 5ba4af4..69f1ddc 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,3 +1,5 @@ { - "extends": ["@tsconfig/bases/node-lts"] + "extends": [ + "@tsconfig/bases/node-lts" + ] } From 44513e970d8762774d9df9d8b666019299feb9a1 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:24:18 +0900 Subject: [PATCH 2/8] chore: add `deno.json` and `deno.lock` for Deno v2 Signed-off-by: Sora Morimoto --- deno.json | 8 + deno.lock | 45 ++++ scripts/create-npm-packages.ts | 276 +++++++++++++++---------- scripts/deploy-changed-npm-packages.ts | 73 ++++--- scripts/generate-lts.ts | 36 ++-- scripts/generate-recommend.ts | 44 ++-- scripts/update-markdown-readme.ts | 79 +++---- 7 files changed, 360 insertions(+), 201 deletions(-) create mode 100644 deno.json create mode 100644 deno.lock diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..994ecf2 --- /dev/null +++ b/deno.json @@ -0,0 +1,8 @@ +{ + "imports": { + "@std/collections": "jsr:@std/collections", + "@std/jsonc": "jsr:@std/jsonc", + "@std/path": "jsr:@std/path", + "@std/semver": "jsr:@std/semver" + } +} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..7b05934 --- /dev/null +++ b/deno.lock @@ -0,0 +1,45 @@ +{ + "version": "5", + "specifiers": { + "jsr:@std/collections@*": "1.1.3", + "jsr:@std/internal@^1.0.12": "1.0.12", + "jsr:@std/json@^1.0.2": "1.0.2", + "jsr:@std/jsonc@*": "1.0.2", + "jsr:@std/path@*": "1.1.4", + "jsr:@std/semver@*": "1.0.7" + }, + "jsr": { + "@std/collections@1.1.3": { + "integrity": "bf8b0818886df6a32b64c7d3b037a425111f28278d69fd0995aeb62777c986b0" + }, + "@std/internal@1.0.12": { + "integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027" + }, + "@std/json@1.0.2": { + "integrity": "d9e5497801c15fb679f55a2c01c7794ad7a5dfda4dd1bebab5e409cb5e0d34d4" + }, + "@std/jsonc@1.0.2": { + "integrity": "909605dae3af22bd75b1cbda8d64a32cf1fd2cf6efa3f9e224aba6d22c0f44c7", + "dependencies": [ + "jsr:@std/json" + ] + }, + "@std/path@1.1.4": { + "integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/semver@1.0.7": { + "integrity": "7d5f65391762dc4358abde80fc3354086ddb40101f140295e60f290c138887d0" + } + }, + "workspace": { + "dependencies": [ + "jsr:@std/collections@*", + "jsr:@std/jsonc@*", + "jsr:@std/path@*", + "jsr:@std/semver@*" + ] + } +} diff --git a/scripts/create-npm-packages.ts b/scripts/create-npm-packages.ts index 20aac43..1929c03 100644 --- a/scripts/create-npm-packages.ts +++ b/scripts/create-npm-packages.ts @@ -1,221 +1,277 @@ -import * as path from "https://deno.land/std/path/mod.ts"; -import stripJsonComments from "https://esm.sh/strip-json-comments"; +import { parse as parseJsonc } from "@std/jsonc"; +import * as path from "@std/path"; for await (const tsconfigEntry of Deno.readDir("bases")) { - if (!tsconfigEntry.isFile) continue - - const tsconfigFilePath = path.join("bases", tsconfigEntry.name) - const name = path.basename(tsconfigEntry.name).replace(".json", "") + if (!tsconfigEntry.isFile) continue; + + const tsconfigFilePath = path.join("bases", tsconfigEntry.name); + const name = path.basename(tsconfigEntry.name).replace(".json", ""); // Make the folder - const packagePath = path.join("packages", name) - Deno.mkdirSync(packagePath, { recursive: true }) + const packagePath = path.join("packages", name); + await Deno.mkdir(packagePath, { recursive: true }); // Copy over the template files - const templateDir = "./template" + const templateDir = "./template"; for await (const templateFile of Deno.readDir(templateDir)) { - if (!templateFile.isFile) continue - if (templateFile.name === "README-combined.md") continue // README-combined.md is only for the combined bases - const templatedFile = path.join(templateDir, templateFile.name) - Deno.copyFileSync(templatedFile, path.join(packagePath, templateFile.name)) + if (!templateFile.isFile) continue; + if (templateFile.name === "README-combined.md") continue; // README-combined.md is only for the combined bases + const templatedFile = path.join(templateDir, templateFile.name); + await Deno.copyFile( + templatedFile, + path.join(packagePath, templateFile.name), + ); } - + // Copy the create a tsconfig.json from the base json - const newPackageTSConfigPath = path.join(packagePath, "tsconfig.json") - Deno.copyFileSync(tsconfigFilePath, newPackageTSConfigPath) - - const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath) - const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText)) + const newPackageTSConfigPath = path.join(packagePath, "tsconfig.json"); + await Deno.copyFile(tsconfigFilePath, newPackageTSConfigPath); -// Drop `display` field in tsconfig.json for npm package - await Deno.writeTextFile(newPackageTSConfigPath, tsconfigText.replace(/\s*"display.*/,'')) + const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath); + const tsconfigJSON = parseJsonc(tsconfigText) as { + display: string; + _version?: string; + }; + + // Drop `display` field in tsconfig.json for npm package + await Deno.writeTextFile( + newPackageTSConfigPath, + tsconfigText.replace(/\s*"display.*/, ""), + ); // Edit the package.json - const packageText = await Deno.readTextFile(path.join(packagePath, "package.json")) - const packageJSON = JSON.parse(packageText) - packageJSON.name = `@tsconfig/${name}` - packageJSON.description = `A base TSConfig for working with ${tsconfigJSON.display}.` - packageJSON.keywords = ["tsconfig", name] + const packageText = await Deno.readTextFile( + path.join(packagePath, "package.json"), + ); + const packageJSON = JSON.parse(packageText); + packageJSON.name = `@tsconfig/${name}`; + packageJSON.description = + `A base TSConfig for working with ${tsconfigJSON.display}.`; + packageJSON.keywords = ["tsconfig", name]; // Do some string replacements in the other templated files - const replaceTextIn = ["README.md"] + const replaceTextIn = ["README.md"]; for (const filenameToEdit of replaceTextIn) { - const fileToEdit = path.join(packagePath, filenameToEdit) - - const defaultTitle = `A base TSConfig for working with ${tsconfigJSON.display}` - const title = name !== "recommended" ? defaultTitle : "The recommended base for a TSConfig" - - let packageText = await Deno.readTextFile(fileToEdit) - packageText = packageText.replace(/\[filename\]/g, name) - .replace(/\[display_title\]/g, title) - .replace(/\[tsconfig\]/g, Deno.readTextFileSync(newPackageTSConfigPath)) - + const fileToEdit = path.join(packagePath, filenameToEdit); + + const defaultTitle = + `A base TSConfig for working with ${tsconfigJSON.display}`; + const title = name !== "recommended" + ? defaultTitle + : "The recommended base for a TSConfig"; + + let packageText = await Deno.readTextFile(fileToEdit); + packageText = packageText + .replace(/\[filename\]/g, name) + .replace(/\[display_title\]/g, title) + .replace( + /\[tsconfig\]/g, + await Deno.readTextFile(newPackageTSConfigPath), + ); + // Inject readme-extra if any try { - const readmeExtra = (await Deno.readTextFile(path.join("readme-extras", `${name}.md`))).trim() - - if (readmeExtra) - packageText = packageText.replace(/\[readme-extra\]/g, `\n${readmeExtra}\n`) - } catch (error) { - // NOOP, there is no extra readme + const readmeExtra = ( + await Deno.readTextFile(path.join("readme-extras", `${name}.md`)) + ).trim(); + + if (readmeExtra) { + packageText = packageText.replace( + /\[readme-extra\]/g, + `\n${readmeExtra}\n`, + ); + } + } catch (_error) { + // NOOP, there is no extra readme // console.log(error) } - + // Remove readme-extra placeholders if any - packageText = packageText.replace(/\[readme-extra\]/g, '') + packageText = packageText.replace(/\[readme-extra\]/g, ""); - await Deno.writeTextFile(fileToEdit, packageText) - }; + await Deno.writeTextFile(fileToEdit, packageText); + } // Bump the last version of the number from npm, // or use the _version in tsconfig if it's higher, // or default to 1.0.0 - let version = tsconfigJSON._version || "1.0.0" + let version = tsconfigJSON._version || "1.0.0"; try { - const npmResponse = await fetch(`https://registry.npmjs.org/${packageJSON.name}`) - const npmPackage = await npmResponse.json() + const npmResponse = await fetch( + `https://registry.npmjs.org/${packageJSON.name}`, + ); + const npmPackage = await npmResponse.json(); const semverMarkers = npmPackage["dist-tags"].latest.split("."); - const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}`; + const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${ + Number(semverMarkers[2]) + 1 + }`; if (isBumpedVersionHigher(version, bumpedVersion)) { version = bumpedVersion; } - } catch (error) { - // NOOP, this is for the first deploy + } catch (_error) { + // NOOP, this is for the first deploy // console.log(error) } - - packageJSON.version = version - await Deno.writeTextFile(path.join(packagePath, "package.json"), JSON.stringify(packageJSON, null, " ")) + + packageJSON.version = version; + await Deno.writeTextFile( + path.join(packagePath, "package.json"), + JSON.stringify(packageJSON, null, " "), + ); console.log("Built:", tsconfigEntry.name); } -await buildTsconfigBases() +await buildTsconfigBases(); -function isBumpedVersionHigher (packageJSONVersion: string, bumpedVersion: string) { - const semverMarkersPackageJSON = packageJSONVersion.split('.') - const semverMarkersBumped = bumpedVersion.split('.') +function isBumpedVersionHigher( + packageJSONVersion: string, + bumpedVersion: string, +) { + const semverMarkersPackageJSON = packageJSONVersion.split("."); + const semverMarkersBumped = bumpedVersion.split("."); for (let i = 0; i < 3; i++) { if (Number(semverMarkersPackageJSON[i]) > Number(semverMarkersBumped[i])) { - return false + return false; } } - return true + return true; } // build @tsconfig/bases catch all package async function buildTsconfigBases() { - const name = "bases" + const name = "bases"; // Make the folder - const packagePath = path.join("packages", name) - Deno.mkdirSync(packagePath, { recursive: true }) + const packagePath = path.join("packages", name); + await Deno.mkdir(packagePath, { recursive: true }); // Copy over the template files - const templateDir = "./template" + const templateDir = "./template"; for await (const templateFile of Deno.readDir(templateDir)) { - if (!templateFile.isFile) continue - if (templateFile.name === "README.md") continue - const templatedFile = path.join(templateDir, templateFile.name) - Deno.copyFileSync( + if (!templateFile.isFile) continue; + if (templateFile.name === "README.md") continue; + const templatedFile = path.join(templateDir, templateFile.name); + await Deno.copyFile( templatedFile, path.join( packagePath, - templateFile.name === "README-combined.md" ? "README.md" : templateFile.name, + templateFile.name === "README-combined.md" + ? "README.md" + : templateFile.name, ), - ) + ); } - const exportsOverride = {} + const exportsOverride: Record<`./${string}`, string> = {}; // Copy the tsconfig.json files from all bases for await (const tsconfigEntry of Deno.readDir("bases")) { - if (!tsconfigEntry.isFile) continue + if (!tsconfigEntry.isFile) continue; // remove extension - const name = tsconfigEntry.name.replace(/\.json$/, "") + const name = tsconfigEntry.name.replace(/\.json$/, ""); - const finalTsconfigFile = `${name}.tsconfig.json` + const finalTsconfigFile = `${name}.tsconfig.json`; // add entry to package.json exports - exportsOverride[`./${name}`] = `./${finalTsconfigFile}` + exportsOverride[`./${name}`] = `./${finalTsconfigFile}`; - const tsconfigFilePath = path.join("bases", tsconfigEntry.name) + const tsconfigFilePath = path.join("bases", tsconfigEntry.name); - const newPackageTSConfigPath = path.join(packagePath, finalTsconfigFile) + const newPackageTSConfigPath = path.join(packagePath, finalTsconfigFile); - Deno.copyFileSync(tsconfigFilePath, newPackageTSConfigPath) + await Deno.copyFile(tsconfigFilePath, newPackageTSConfigPath); - const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath) + const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath); // Drop `display` field in tsconfig.json for npm package - await Deno.writeTextFile(newPackageTSConfigPath, tsconfigText.replace(/\s*"display.*/, "")) + await Deno.writeTextFile( + newPackageTSConfigPath, + tsconfigText.replace(/\s*"display.*/, ""), + ); } - const tsconfigJSON = { display: "Bases" } + const tsconfigJSON: { display: string; _version?: string } = { + display: "Bases", + }; // Edit the package.json - const packageText = await Deno.readTextFile(path.join(packagePath, "package.json")) - const packageJSON = JSON.parse(packageText) - packageJSON.name = `@tsconfig/${name}` - packageJSON.description = `Combined tsconfig bases.` - packageJSON.keywords = ["tsconfig", name, "combined"] - packageJSON.exports = exportsOverride + const packageText = await Deno.readTextFile( + path.join(packagePath, "package.json"), + ); + const packageJSON = JSON.parse(packageText); + packageJSON.name = `@tsconfig/${name}`; + packageJSON.description = `Combined tsconfig bases.`; + packageJSON.keywords = ["tsconfig", name, "combined"]; + packageJSON.exports = exportsOverride; // Do some string replacements in the other templated files - const replaceTextIn = ["README.md"] + const replaceTextIn = ["README.md"]; for (const filenameToEdit of replaceTextIn) { - const fileToEdit = path.join(packagePath, filenameToEdit) + const fileToEdit = path.join(packagePath, filenameToEdit); - const defaultTitle = `A base TSConfig for working with ${tsconfigJSON.display}` - const title = name !== "recommended" ? defaultTitle : "The recommended base for a TSConfig" + const defaultTitle = + `A base TSConfig for working with ${tsconfigJSON.display}`; + const title = defaultTitle; - let packageText = await Deno.readTextFile(fileToEdit) - packageText = packageText.replace(/\[filename\]/g, name).replace(/\[display_title\]/g, title) + let packageText = await Deno.readTextFile(fileToEdit); + packageText = packageText + .replace(/\[filename\]/g, name) + .replace(/\[display_title\]/g, title); // Inject readme-extra if any try { - const readmeExtra = (await Deno.readTextFile(path.join("readme-extras", `${name}.md`))).trim() + const readmeExtra = ( + await Deno.readTextFile(path.join("readme-extras", `${name}.md`)) + ).trim(); if (readmeExtra) { - packageText = packageText.replace(/\[readme-extra\]/g, `\n${readmeExtra}\n`) + packageText = packageText.replace( + /\[readme-extra\]/g, + `\n${readmeExtra}\n`, + ); } - } catch (error) { + } catch (_error) { // NOOP, there is no extra readme // console.log(error) } // Remove readme-extra placeholders if any - packageText = packageText.replace(/\[readme-extra\]/g, "") + packageText = packageText.replace(/\[readme-extra\]/g, ""); - await Deno.writeTextFile(fileToEdit, packageText) + await Deno.writeTextFile(fileToEdit, packageText); } // Bump the last version of the number from npm, // or use the _version in tsconfig if it's higher, // or default to 1.0.0 - let version = tsconfigJSON._version || "1.0.0" + let version = tsconfigJSON._version || "1.0.0"; try { - const npmResponse = await fetch(`https://registry.npmjs.org/${packageJSON.name}`) - const npmPackage = await npmResponse.json() + const npmResponse = await fetch( + `https://registry.npmjs.org/${packageJSON.name}`, + ); + const npmPackage = await npmResponse.json(); - const semverMarkers = npmPackage["dist-tags"].latest.split(".") - const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}` + const semverMarkers = npmPackage["dist-tags"].latest.split("."); + const bumpedVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${ + Number(semverMarkers[2]) + 1 + }`; if (isBumpedVersionHigher(version, bumpedVersion)) { - version = bumpedVersion + version = bumpedVersion; } - } catch (error) { + } catch (_error) { // NOOP, this is for the first deploy // console.log(error) } - packageJSON.version = version + packageJSON.version = version; await Deno.writeTextFile( path.join(packagePath, "package.json"), JSON.stringify(packageJSON, null, " "), - ) + ); - console.log("Built:", "bases") + console.log("Built:", "bases"); } diff --git a/scripts/deploy-changed-npm-packages.ts b/scripts/deploy-changed-npm-packages.ts index 22166ca..5048bfa 100644 --- a/scripts/deploy-changed-npm-packages.ts +++ b/scripts/deploy-changed-npm-packages.ts @@ -1,57 +1,78 @@ -import * as path from "https://deno.land/std@0.164.0/path/mod.ts"; -import * as bufio from "https://deno.land/std@0.164.0/io/buffer.ts"; +import * as path from "@std/path"; // Loop through generated packages, deploying versions for anything which has a different tsconfig -const uploaded = [] +const uploaded = []; -for (const dirEntry of Deno.readDirSync("packages")) { - if (dirEntry.name === 'bases') continue // @tsconfig/bases package is special, it doesn't have a single tsconfig entry, it will be deployed separately +for await (const dirEntry of Deno.readDir("packages")) { + if (dirEntry.name === "bases") continue; // @tsconfig/bases package is special, it doesn't have a single tsconfig entry, it will be deployed separately - const localTsconfigPath = path.join("packages", dirEntry.name, "tsconfig.json"); - const newTSConfig = Deno.readTextFileSync(localTsconfigPath); + const localTsconfigPath = path.join( + "packages", + dirEntry.name, + "tsconfig.json", + ); + const newTSConfig = await Deno.readTextFile(localTsconfigPath); let upload = false; try { - const unpkgURL = `https://unpkg.com/@tsconfig/${dirEntry.name}/tsconfig.json`; + const unpkgURL = + `https://unpkg.com/@tsconfig/${dirEntry.name}/tsconfig.json`; const currentJSONReq = await fetch(unpkgURL); const currentJSONTxt = await currentJSONReq.text(); upload = currentJSONTxt !== newTSConfig; - } catch (error) { + } catch (_error) { // Not here, definitely needs to be uploaded upload = true; } if (upload) { - const process = Deno.run({ - cmd: ["npm", "publish", "--provenance", "--access", "public"], + const token = Deno.env.get("NODE_AUTH_TOKEN"); + if (!token) throw new Error("NODE_AUTH_TOKEN is required"); + + const cmd = new Deno.Command("npm", { + args: ["publish", "--provenance", "--access", "public"], stdout: "piped", + stderr: "piped", cwd: path.join("packages", dirEntry.name), - env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! }, + env: { NODE_AUTH_TOKEN: token }, }); - for await (const line of bufio.readLines(process.stdout!)) { - console.warn(line); + const output = await cmd.output(); + const stdoutText = new TextDecoder().decode(output.stdout); + const stderrText = new TextDecoder().decode(output.stderr); + if (stdoutText.trim()) console.warn(stdoutText.trimEnd()); + if (stderrText.trim()) console.warn(stderrText.trimEnd()); + if (!output.success) { + throw new Error(`npm publish failed for ${dirEntry.name}`); } - uploaded.push(dirEntry.name) + uploaded.push(dirEntry.name); } } if (uploaded.length) { // If there's any uploads, we need to update the combined package too - const process = Deno.run({ - cmd: ["npm", "publish", "--provenance", "--access", "public"], - stdout: "piped", - cwd: path.join("packages", "bases"), - env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! }, - }); + const token = Deno.env.get("NODE_AUTH_TOKEN"); + if (!token) throw new Error("NODE_AUTH_TOKEN is required"); - for await (const line of bufio.readLines(process.stdout!)) { - console.warn(line); - } + const cmd = new Deno.Command("npm", { + args: ["publish", "--provenance", "--access", "public"], + stdout: "piped", + stderr: "piped", + cwd: path.join("packages", "bases"), + env: { NODE_AUTH_TOKEN: token }, + }); + const output = await cmd.output(); + const stdoutText = new TextDecoder().decode(output.stdout); + const stderrText = new TextDecoder().decode(output.stderr); + if (stdoutText.trim()) console.warn(stdoutText.trimEnd()); + if (stderrText.trim()) console.warn(stderrText.trimEnd()); + if (!output.success) { + throw new Error("npm publish failed for bases"); + } - console.log("Uploaded: ", uploaded.join(", ")) + console.log("Uploaded: ", uploaded.join(", ")); } else { - console.log("No uploads") + console.log("No uploads"); } diff --git a/scripts/generate-lts.ts b/scripts/generate-lts.ts index 228430b..ca0f80b 100644 --- a/scripts/generate-lts.ts +++ b/scripts/generate-lts.ts @@ -1,8 +1,10 @@ // deno run --allow-read --allow-write --allow-net scripts/generate-lts.ts // -import { gt } from "https://deno.land/std@0.192.0/semver/gt.ts"; -import { parse } from "https://deno.land/std@0.192.0/semver/parse.ts"; +import { deepMerge } from "@std/collections"; +import { parse as parseJsonc } from "@std/jsonc"; +import * as path from "@std/path"; +import { greaterThan, parse } from "@std/semver"; interface NodeReleaseMetadata { version: string; @@ -18,42 +20,44 @@ interface NodeReleaseMetadata { security: boolean; } -type Tsconfig = Record; +type Tsconfig = Record; const versionRegex = /v(\d+)\.(\d+)\.(\d+)/; -const releasesResponse = await fetch("https://nodejs.org/download/release/index.json"); +const releasesResponse = await fetch( + "https://nodejs.org/download/release/index.json", +); const releasesJson = (await releasesResponse.json()) as NodeReleaseMetadata[]; const lts = releasesJson .filter((r) => r.lts) .reduce( - (prevValue, currValue) => (gt(parse(currValue.version), parse(prevValue.version)) ? currValue : prevValue), + (prevValue, currValue) => + greaterThan(parse(currValue.version), parse(prevValue.version)) + ? currValue + : prevValue, { - version: "v0.0.0" - } + version: "v0.0.0", + }, ); const baseMajorVersion = (lts.version.match(versionRegex) || [])[1]; const base = `node${baseMajorVersion}`; const versioned = { $schema: "https://www.schemastore.org/tsconfig", display: `Node LTS (${baseMajorVersion})`, - _version: lts.version.substring(lts.version.indexOf("v") + 1) + _version: lts.version.substring(lts.version.indexOf("v") + 1), }; -import * as path from "https://deno.land/std/path/mod.ts"; -import stripJsonComments from "https://esm.sh/strip-json-comments"; -import { deepMerge } from "https://deno.land/std/collections/deep_merge.ts"; +const packageText = await Deno.readTextFile( + path.join(Deno.cwd(), "bases", `${base}.json`), +); -const packageText = await Deno.readTextFile(path.join(Deno.cwd(), "bases", `${base}.json`)); - -const parsed = JSON.parse(stripJsonComments(packageText)) as Tsconfig; +const parsed = parseJsonc(packageText) as Tsconfig; // This is to get the _version property to show up directly under the display property const parsedAndOrdered = deepMerge(versioned, parsed); parsedAndOrdered.display = versioned.display; -const serializedConfig = - "// This file was autogenerated by a script\n" + +const serializedConfig = "// This file was autogenerated by a script\n" + `// Equivalent to a config of: ${base}\n` + JSON.stringify(parsedAndOrdered, null, " ") + "\n"; diff --git a/scripts/generate-recommend.ts b/scripts/generate-recommend.ts index c89cb49..99fc916 100644 --- a/scripts/generate-recommend.ts +++ b/scripts/generate-recommend.ts @@ -1,28 +1,46 @@ -import stripJsonComments from "https://esm.sh/strip-json-comments"; -import * as bufio from "https://deno.land/std@0.164.0/io/buffer.ts"; -import * as path from "https://deno.land/std/path/mod.ts"; +import { parse as parseJsonc } from "@std/jsonc"; +import * as path from "@std/path"; const tsconfigStorage = await Deno.makeTempDir({ prefix: "tsconfig" }); // Generate a tsconfig -const p = await Deno.run({ cmd: ["npx", "-p", "typescript", "tsc", "--init"], stdout: "piped", cwd: tsconfigStorage }); -for await (const line of bufio.readLines(p.stdout!)) { - console.warn(line); +const cmd = new Deno.Command("npx", { + args: ["-p", "typescript", "tsc", "--init"], + stdout: "piped", + stderr: "piped", + cwd: tsconfigStorage, +}); + +const output = await cmd.output(); +const stdoutText = new TextDecoder().decode(output.stdout); +const stderrText = new TextDecoder().decode(output.stderr); + +for (const line of stdoutText.split("\n")) { + if (line) console.warn(line); +} +for (const line of stderrText.split("\n")) { + if (line) console.warn(line); +} +if (!output.success) { + throw new Error("Failed to generate tsconfig via npx tsc --init"); } -let packageText = await Deno.readTextFile(path.join(tsconfigStorage, "tsconfig.json")); -// This will strip comments -const parsed = JSON.parse(stripJsonComments(packageText)); +const packageText = await Deno.readTextFile( + path.join(tsconfigStorage, "tsconfig.json"), +); +const parsed = parseJsonc(packageText) as Record; // `display` field will be dropped at generating npm package, so prevent the order from being last in the JSON file parsed.display = "Recommended"; -parsed["$schema"] = "https://www.schemastore.org/tsconfig"; +parsed.$schema = "https://www.schemastore.org/tsconfig"; -const result = JSON.stringify(parsed, null, " "); +const result = JSON.stringify(parsed, null, 2); -const npmResponse = await fetch(`https://unpkg.com/@tsconfig/svelte/tsconfig.json`); +const npmResponse = await fetch( + `https://unpkg.com/@tsconfig/svelte/tsconfig.json`, +); const npmPackage = await npmResponse.text(); if (npmPackage !== result) { - Deno.writeTextFile("bases/recommended.json", result); + await Deno.writeTextFile("bases/recommended.json", `${result}\n`); } diff --git a/scripts/update-markdown-readme.ts b/scripts/update-markdown-readme.ts index 64c2eae..864682f 100644 --- a/scripts/update-markdown-readme.ts +++ b/scripts/update-markdown-readme.ts @@ -1,28 +1,32 @@ // deno run --allow-read --allow-write scripts/update-markdown-readme.ts // -import * as path from "https://deno.land/std/path/mod.ts"; -import stripJsonComments from "https://esm.sh/strip-json-comments"; -const readme = await Deno.readTextFileSync("./README.md") -let center = "" +import { parse as parseJsonc } from "@std/jsonc"; +import * as path from "@std/path"; -const paths = [] +const readme = await Deno.readTextFile("./README.md"); +let center = ""; + +const paths = []; for await (const tsconfigEntry of Deno.readDir("bases")) { - if (!tsconfigEntry.isFile) continue - paths.push(tsconfigEntry.name) + if (!tsconfigEntry.isFile) continue; + paths.push(tsconfigEntry.name); } -const sortedPaths = paths.sort((l, r) => l.localeCompare(r)).filter(r => !r.includes("recommended")) -const basePaths = ["recommended.json", ...sortedPaths] +const sortedPaths = paths + .sort((l, r) => l.localeCompare(r)) + .filter((r) => !r.includes("recommended")); +const basePaths = ["recommended.json", ...sortedPaths]; for (const base of basePaths) { - if (base === "esm.json") continue - const tsconfigFilePath = path.join("bases", base) - const name = path.basename(base).replace(".json", "") - - const tsconfigText = await Deno.readTextFile(tsconfigFilePath) - const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText)) + if (base === "esm.json") continue; + const tsconfigFilePath = path.join("bases", base); + const name = path.basename(base).replace(".json", ""); + + const tsconfigText = await Deno.readTextFile(tsconfigFilePath); + const tsconfigJSON = parseJsonc(tsconfigText) as { display: string }; - center += `### ${tsconfigJSON.display} tsconfig.json\n` + center += + `### ${tsconfigJSON.display} tsconfig.json\n`; center += ` Install: @@ -32,10 +36,14 @@ npm install --save-dev @tsconfig/${name} yarn add --dev @tsconfig/${name} \`\`\` -` +`; - const hasReadmeExtra = await Deno.stat(`./readme-extras/${name}.md`).then(() => true).catch(() => false) - const readmeExtra = hasReadmeExtra ? (await Deno.readTextFile(`./readme-extras/${name}.md`)).trim() : "" + const hasReadmeExtra = await Deno.stat(`./readme-extras/${name}.md`) + .then(() => true) + .catch(() => false); + const readmeExtra = hasReadmeExtra + ? (await Deno.readTextFile(`./readme-extras/${name}.md`)).trim() + : ""; const defaultInstructions = `Add to your \`tsconfig.json\`: @@ -43,24 +51,23 @@ yarn add --dev @tsconfig/${name} "extends": "@tsconfig/${name}/tsconfig.json" \`\`\` -` - - if (readmeExtra) { - if (!readmeExtra.includes("extends")) { - center += defaultInstructions + "\n" - } +`; - center += `\n${readmeExtra}\n\n` - - } else { - center += defaultInstructions + if (readmeExtra) { + if (!readmeExtra.includes("extends")) { + center += `${defaultInstructions}\n`; } -}; -const startMarker ="" -const start = readme.split(startMarker)[0] -const endMarker ="" -const end = readme.split(endMarker)[1] -const newREADME = start + startMarker + "\n" + center + "\n" + endMarker + end + center += `\n${readmeExtra}\n\n`; + } else { + center += defaultInstructions; + } +} + +const startMarker = ""; +const start = readme.split(startMarker)[0]; +const endMarker = ""; +const end = readme.split(endMarker)[1]; +const newREADME = `${start}${startMarker}\n${center}\n${endMarker}${end}`; -await Deno.writeTextFileSync("./README.md", newREADME) +await Deno.writeTextFile("./README.md", newREADME); From 6763054af1df737e1495a2ec73fee4d04fca5bde Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:25:10 +0900 Subject: [PATCH 3/8] chore: replace pnpm with npm in test script, and add package-lock.json Signed-off-by: Sora Morimoto --- test/package-lock.json | 56 ++++++++++++++++++++++++++++++++++++++++++ test/package.json | 3 +-- test/pnpm-lock.yaml | 42 ------------------------------- 3 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 test/package-lock.json delete mode 100644 test/pnpm-lock.yaml diff --git a/test/package-lock.json b/test/package-lock.json new file mode 100644 index 0000000..8f247b2 --- /dev/null +++ b/test/package-lock.json @@ -0,0 +1,56 @@ +{ + "name": "test-bases", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "test-bases", + "devDependencies": { + "@tsconfig/bases": "file:../packages/bases", + "@types/node": "^24.2.1", + "typescript": "^5.9.2" + } + }, + "../packages/bases": { + "name": "@tsconfig/bases", + "version": "1.0.17", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/bases": { + "resolved": "../packages/bases", + "link": true + }, + "node_modules/@types/node": { + "version": "24.10.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.4.tgz", + "integrity": "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/test/package.json b/test/package.json index 52ef9fe..e6909ab 100644 --- a/test/package.json +++ b/test/package.json @@ -3,9 +3,8 @@ "scripts": { "test": "tsc --noEmit" }, - "packageManager": "pnpm@10.12.4", "devDependencies": { - "@tsconfig/bases": "link:../packages/bases", + "@tsconfig/bases": "file:../packages/bases", "@types/node": "^24.2.1", "typescript": "^5.9.2" } diff --git a/test/pnpm-lock.yaml b/test/pnpm-lock.yaml deleted file mode 100644 index cdcec73..0000000 --- a/test/pnpm-lock.yaml +++ /dev/null @@ -1,42 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: - devDependencies: - '@tsconfig/bases': - specifier: link:../packages/bases - version: link:../packages/bases - '@types/node': - specifier: ^24.2.1 - version: 24.2.1 - typescript: - specifier: ^5.9.2 - version: 5.9.2 - -packages: - - '@types/node@24.2.1': - resolution: {integrity: sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ==} - - typescript@5.9.2: - resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==} - engines: {node: '>=14.17'} - hasBin: true - - undici-types@7.10.0: - resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==} - -snapshots: - - '@types/node@24.2.1': - dependencies: - undici-types: 7.10.0 - - typescript@5.9.2: {} - - undici-types@7.10.0: {} From 86fd4cce59e7fc0568eaecb7bc9b98978fa559d1 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:25:40 +0900 Subject: [PATCH 4/8] chore: update CI Signed-off-by: Sora Morimoto --- .github/workflows/CI.yml | 18 ++++++++++-------- .github/workflows/deploy.yml | 8 +++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 54bfaf1..dad290a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,23 +9,25 @@ jobs: steps: - name: Checkout tree - uses: actions/checkout@v3 + uses: actions/checkout@v6 - - name: Set-up Deno - uses: denoland/setup-deno@v1 + - name: Set-up Node.js + uses: actions/setup-node@v6 with: - deno-version: v1.x + node-version: lts/* + + - name: Set-up Deno + uses: denoland/setup-deno@v2 # Build all the packages - name: Create packages for TSConfig JSONs run: deno run --allow-read --allow-write --allow-net scripts/create-npm-packages.ts - name: Test - working-directory: test/ + working-directory: test run: | - corepack enable - pnpm install - pnpm test + npm install + npm run test - name: Update the README run: deno run --allow-read --allow-write --allow-net scripts/update-markdown-readme.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 09ea14d..6761cf5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,18 +18,16 @@ jobs: steps: - name: Checkout tree - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set-up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v6 with: node-version: lts/* registry-url: https://registry.npmjs.org - name: Set-up Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x + uses: denoland/setup-deno@v2 # Build all the packages - name: Create packages for TSConfig JSONs From ce19dd3c2da5e29c04fb6395116dd79f350c89bc Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:31:00 +0900 Subject: [PATCH 5/8] fix: update TypeScript configuration notes to reflect removal of `baseUrl` in TypeScript 7 Signed-off-by: Sora Morimoto --- README.md | 13 ++++++++----- bases/docusaurus.json | 1 - bases/ember.json | 3 ++- bases/nuxt.json | 1 - bases/remix.json | 1 - readme-extras/docusaurus.md | 2 +- readme-extras/ember.md | 2 +- readme-extras/nuxt.md | 2 +- readme-extras/remix.md | 2 +- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 65fcd9a..f497382 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ Add to your `tsconfig.json`: -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). ### Ember tsconfig.json @@ -156,7 +156,7 @@ Add to your `tsconfig.json`: -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). ### Next.js tsconfig.json @@ -204,7 +204,10 @@ This file is meant to be used in conjunction with other Node.js configurations, ```json { - "extends": ["@tsconfig/node22/tsconfig.json", "@tsconfig/node-ts/tsconfig.json"] + "extends": [ + "@tsconfig/node22/tsconfig.json", + "@tsconfig/node-ts/tsconfig.json" + ] } ``` @@ -405,7 +408,7 @@ Add to your `tsconfig.json`: -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). ### QJSEngine tsconfig.json @@ -454,7 +457,7 @@ Add to your `tsconfig.json`: -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). ### Strictest tsconfig.json diff --git a/bases/docusaurus.json b/bases/docusaurus.json index abbcb2c..03fcf1c 100644 --- a/bases/docusaurus.json +++ b/bases/docusaurus.json @@ -18,7 +18,6 @@ "@docusaurus/module-type-aliases", "@docusaurus/theme-classic" ], - "baseUrl": ".", "paths": { "@site/*": [ "./*" diff --git a/bases/ember.json b/bases/ember.json index d9cdff7..1558d7d 100644 --- a/bases/ember.json +++ b/bases/ember.json @@ -6,7 +6,8 @@ "_deprecated": true, // This is the base config used by Ember apps and addons. When actually used // via Ember CLI (e.g. ember-cli-typescript's blueprint), it additionally has - // `compilerOptions.baseUrl`, `compilerOptions.paths`, and `include` set. + // `compilerOptions.paths` and `include` set. + // Note: `baseUrl` was removed in TypeScript 7.0. Use `paths` instead. "compilerOptions": { "target": "es2023", "module": "esnext", diff --git a/bases/nuxt.json b/bases/nuxt.json index 9fece9c..17d61f9 100644 --- a/bases/nuxt.json +++ b/bases/nuxt.json @@ -16,7 +16,6 @@ "sourceMap": true, "strict": true, "noEmit": true, - "baseUrl": ".", "paths": { "~/*": [ "./*" diff --git a/bases/remix.json b/bases/remix.json index 3640667..4c96f17 100644 --- a/bases/remix.json +++ b/bases/remix.json @@ -17,7 +17,6 @@ "target": "es2019", "strict": true, "allowJs": true, - "baseUrl": ".", "paths": { "~/*": [ "./app/*" diff --git a/readme-extras/docusaurus.md b/readme-extras/docusaurus.md index a566513..dbdad56 100644 --- a/readme-extras/docusaurus.md +++ b/readme-extras/docusaurus.md @@ -1 +1 @@ -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). diff --git a/readme-extras/ember.md b/readme-extras/ember.md index a566513..dbdad56 100644 --- a/readme-extras/ember.md +++ b/readme-extras/ember.md @@ -1 +1 @@ -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). diff --git a/readme-extras/nuxt.md b/readme-extras/nuxt.md index a566513..dbdad56 100644 --- a/readme-extras/nuxt.md +++ b/readme-extras/nuxt.md @@ -1 +1 @@ -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). diff --git a/readme-extras/remix.md b/readme-extras/remix.md index a566513..dbdad56 100644 --- a/readme-extras/remix.md +++ b/readme-extras/remix.md @@ -1 +1 @@ -> **NOTE**: You may need to add `"baseUrl": "."` to your `tsconfig.json` to support proper file resolution. +> **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). From 9c2670250b80592e509bc703ccac76a23d843b28 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:31:49 +0900 Subject: [PATCH 6/8] chore: `deno run --allow-run --allow-read --allow-write --allow-net scripts/generate-recommend.ts` Signed-off-by: Sora Morimoto --- bases/recommended.json | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bases/recommended.json b/bases/recommended.json index 3e3fac6..b2d9dc3 100644 --- a/bases/recommended.json +++ b/bases/recommended.json @@ -1,10 +1,19 @@ { "compilerOptions": { - "target": "es2016", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, + "module": "nodenext", + "target": "esnext", + "types": [], + "sourceMap": true, + "declaration": true, + "declarationMap": true, + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, "strict": true, + "jsx": "react-jsx", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", "skipLibCheck": true }, "display": "Recommended", From 13594082a252f0c3e94138ab7a06db83a3a9d70f Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:41:37 +0900 Subject: [PATCH 7/8] chore: add `_version` field to generated `recommended.json` config Signed-off-by: Sora Morimoto --- bases/recommended.json | 7 ++++--- scripts/generate-recommend.ts | 15 +++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bases/recommended.json b/bases/recommended.json index b2d9dc3..f3c9a14 100644 --- a/bases/recommended.json +++ b/bases/recommended.json @@ -1,4 +1,7 @@ { + "$schema": "https://www.schemastore.org/tsconfig", + "display": "Recommended", + "_version": "2.0.0", "compilerOptions": { "module": "nodenext", "target": "esnext", @@ -15,7 +18,5 @@ "noUncheckedSideEffectImports": true, "moduleDetection": "force", "skipLibCheck": true - }, - "display": "Recommended", - "$schema": "https://www.schemastore.org/tsconfig" + } } diff --git a/scripts/generate-recommend.ts b/scripts/generate-recommend.ts index 99fc916..356db17 100644 --- a/scripts/generate-recommend.ts +++ b/scripts/generate-recommend.ts @@ -1,3 +1,4 @@ +import { deepMerge } from "@std/collections"; import { parse as parseJsonc } from "@std/jsonc"; import * as path from "@std/path"; @@ -30,11 +31,17 @@ const packageText = await Deno.readTextFile( ); const parsed = parseJsonc(packageText) as Record; -// `display` field will be dropped at generating npm package, so prevent the order from being last in the JSON file -parsed.display = "Recommended"; -parsed.$schema = "https://www.schemastore.org/tsconfig"; +const versioned = { + $schema: "https://www.schemastore.org/tsconfig", + display: "Recommended", + _version: "2.0.0", +}; -const result = JSON.stringify(parsed, null, 2); +// This is to get the _version property to show up directly under the display property +const parsedAndOrdered = deepMerge(versioned, parsed); +parsedAndOrdered.display = versioned.display; + +const result = JSON.stringify(parsedAndOrdered, null, 2); const npmResponse = await fetch( `https://unpkg.com/@tsconfig/svelte/tsconfig.json`, From 3b9346a3257a6b2fdf78cd6c054dfe25ae6e5287 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 26 Dec 2025 22:56:09 +0900 Subject: [PATCH 8/8] chore: update TypeScript configuration files to use `.jsonc` extension Signed-off-by: Sora Morimoto --- .vscode/settings.json | 5 +- README.md | 60 +++++++++---------- bases/{bun.json => bun.jsonc} | 0 ...-react-app.json => create-react-app.jsonc} | 0 bases/{cypress.json => cypress.jsonc} | 0 bases/{deno.json => deno.jsonc} | 0 bases/{docusaurus.json => docusaurus.jsonc} | 0 bases/{ember.json => ember.jsonc} | 0 bases/{next.json => next.jsonc} | 0 bases/{node-lts.json => node-lts.jsonc} | 0 bases/{node-ts.json => node-ts.jsonc} | 0 bases/{node10.json => node10.jsonc} | 0 bases/{node12.json => node12.jsonc} | 0 bases/{node14.json => node14.jsonc} | 0 bases/{node16.json => node16.jsonc} | 0 bases/{node17.json => node17.jsonc} | 0 bases/{node18.json => node18.jsonc} | 0 bases/{node19.json => node19.jsonc} | 0 bases/{node20.json => node20.jsonc} | 0 bases/{node21.json => node21.jsonc} | 0 bases/{node22.json => node22.jsonc} | 0 bases/{node23.json => node23.jsonc} | 0 bases/{node24.json => node24.jsonc} | 0 bases/{nuxt.json => nuxt.jsonc} | 0 bases/{qjsengine.json => qjsengine.jsonc} | 0 .../{react-native.json => react-native.jsonc} | 0 bases/{recommended.json => recommended.jsonc} | 0 bases/{remix.json => remix.jsonc} | 0 bases/{strictest.json => strictest.jsonc} | 0 bases/{svelte.json => svelte.jsonc} | 0 bases/{taro.json => taro.jsonc} | 0 bases/{vite-react.json => vite-react.jsonc} | 0 scripts/create-npm-packages.ts | 4 +- scripts/generate-lts.ts | 4 +- scripts/generate-recommend.ts | 2 +- scripts/update-markdown-readme.ts | 6 +- 36 files changed, 39 insertions(+), 42 deletions(-) rename bases/{bun.json => bun.jsonc} (100%) rename bases/{create-react-app.json => create-react-app.jsonc} (100%) rename bases/{cypress.json => cypress.jsonc} (100%) rename bases/{deno.json => deno.jsonc} (100%) rename bases/{docusaurus.json => docusaurus.jsonc} (100%) rename bases/{ember.json => ember.jsonc} (100%) rename bases/{next.json => next.jsonc} (100%) rename bases/{node-lts.json => node-lts.jsonc} (100%) rename bases/{node-ts.json => node-ts.jsonc} (100%) rename bases/{node10.json => node10.jsonc} (100%) rename bases/{node12.json => node12.jsonc} (100%) rename bases/{node14.json => node14.jsonc} (100%) rename bases/{node16.json => node16.jsonc} (100%) rename bases/{node17.json => node17.jsonc} (100%) rename bases/{node18.json => node18.jsonc} (100%) rename bases/{node19.json => node19.jsonc} (100%) rename bases/{node20.json => node20.jsonc} (100%) rename bases/{node21.json => node21.jsonc} (100%) rename bases/{node22.json => node22.jsonc} (100%) rename bases/{node23.json => node23.jsonc} (100%) rename bases/{node24.json => node24.jsonc} (100%) rename bases/{nuxt.json => nuxt.jsonc} (100%) rename bases/{qjsengine.json => qjsengine.jsonc} (100%) rename bases/{react-native.json => react-native.jsonc} (100%) rename bases/{recommended.json => recommended.jsonc} (100%) rename bases/{remix.json => remix.jsonc} (100%) rename bases/{strictest.json => strictest.jsonc} (100%) rename bases/{svelte.json => svelte.jsonc} (100%) rename bases/{taro.json => taro.jsonc} (100%) rename bases/{vite-react.json => vite-react.jsonc} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9196d1d..e7c6cb6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,8 +7,5 @@ }, "cSpell.words": [ "Deno" - ], - "files.associations": { - "*.json": "jsonc" - } + ] } diff --git a/README.md b/README.md index f497382..8175dec 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ We target the latest stable version of TypeScript, note that because we want to ### Available TSConfigs -### Recommended tsconfig.json +### Recommended tsconfig.json Install: @@ -60,7 +60,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/recommended/tsconfig.json" ``` -### Bun tsconfig.json +### Bun tsconfig.json Install: @@ -75,7 +75,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/bun/tsconfig.json" ``` -### Create React App tsconfig.json +### Create React App tsconfig.json Install: @@ -90,7 +90,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/create-react-app/tsconfig.json" ``` -### Cypress tsconfig.json +### Cypress tsconfig.json Install: @@ -105,7 +105,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/cypress/tsconfig.json" ``` -### Deno tsconfig.json +### Deno tsconfig.json Install: @@ -120,7 +120,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/deno/tsconfig.json" ``` -### Docusaurus v2 tsconfig.json +### Docusaurus v2 tsconfig.json Install: @@ -139,7 +139,7 @@ Add to your `tsconfig.json`: > **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). -### Ember tsconfig.json +### Ember tsconfig.json Install: @@ -158,7 +158,7 @@ Add to your `tsconfig.json`: > **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). -### Next.js tsconfig.json +### Next.js tsconfig.json Install: @@ -173,7 +173,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/next/tsconfig.json" ``` -### Node LTS (24) tsconfig.json +### Node LTS (24) tsconfig.json Install: @@ -188,7 +188,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node-lts/tsconfig.json" ``` -### Node with TypeScript (TS >=5.8 ONLY) tsconfig.json +### Node with TypeScript (TS >=5.8 ONLY) tsconfig.json Install: @@ -211,7 +211,7 @@ This file is meant to be used in conjunction with other Node.js configurations, } ``` -### Node 10 tsconfig.json +### Node 10 tsconfig.json Install: @@ -226,7 +226,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node10/tsconfig.json" ``` -### Node 12 tsconfig.json +### Node 12 tsconfig.json Install: @@ -241,7 +241,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node12/tsconfig.json" ``` -### Node 14 tsconfig.json +### Node 14 tsconfig.json Install: @@ -256,7 +256,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node14/tsconfig.json" ``` -### Node 16 tsconfig.json +### Node 16 tsconfig.json Install: @@ -271,7 +271,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node16/tsconfig.json" ``` -### Node 17 tsconfig.json +### Node 17 tsconfig.json Install: @@ -286,7 +286,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node17/tsconfig.json" ``` -### Node 18 tsconfig.json +### Node 18 tsconfig.json Install: @@ -301,7 +301,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node18/tsconfig.json" ``` -### Node 19 tsconfig.json +### Node 19 tsconfig.json Install: @@ -316,7 +316,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node19/tsconfig.json" ``` -### Node 20 tsconfig.json +### Node 20 tsconfig.json Install: @@ -331,7 +331,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node20/tsconfig.json" ``` -### Node 21 tsconfig.json +### Node 21 tsconfig.json Install: @@ -346,7 +346,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node21/tsconfig.json" ``` -### Node 22 tsconfig.json +### Node 22 tsconfig.json Install: @@ -361,7 +361,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node22/tsconfig.json" ``` -### Node 23 tsconfig.json +### Node 23 tsconfig.json Install: @@ -376,7 +376,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node23/tsconfig.json" ``` -### Node 24 tsconfig.json +### Node 24 tsconfig.json Install: @@ -391,7 +391,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/node24/tsconfig.json" ``` -### Nuxt tsconfig.json +### Nuxt tsconfig.json Install: @@ -410,7 +410,7 @@ Add to your `tsconfig.json`: > **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). -### QJSEngine tsconfig.json +### QJSEngine tsconfig.json Install: @@ -425,7 +425,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/qjsengine/tsconfig.json" ``` -### React Native tsconfig.json +### React Native tsconfig.json Install: @@ -440,7 +440,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/react-native/tsconfig.json" ``` -### Remix tsconfig.json +### Remix tsconfig.json Install: @@ -459,7 +459,7 @@ Add to your `tsconfig.json`: > **NOTE**: TypeScript 7 removes `baseUrl`. If you previously added `"baseUrl": "."` for module resolution, use `paths` instead (for example: `"paths": { "*": ["./*"] }`). -### Strictest tsconfig.json +### Strictest tsconfig.json Install: @@ -474,7 +474,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/strictest/tsconfig.json" ``` -### Svelte tsconfig.json +### Svelte tsconfig.json Install: @@ -493,7 +493,7 @@ Add to your `tsconfig.json`: > **NOTE**: After `@tsconfig/svelte@2.0.0`, you should add `/// ` to a `d.ts` or a `index.ts`(entry) file to prevent typescript error. -### Taro tsconfig.json +### Taro tsconfig.json Install: @@ -508,7 +508,7 @@ Add to your `tsconfig.json`: "extends": "@tsconfig/taro/tsconfig.json" ``` -### Vite React tsconfig.json +### Vite React tsconfig.json Install: diff --git a/bases/bun.json b/bases/bun.jsonc similarity index 100% rename from bases/bun.json rename to bases/bun.jsonc diff --git a/bases/create-react-app.json b/bases/create-react-app.jsonc similarity index 100% rename from bases/create-react-app.json rename to bases/create-react-app.jsonc diff --git a/bases/cypress.json b/bases/cypress.jsonc similarity index 100% rename from bases/cypress.json rename to bases/cypress.jsonc diff --git a/bases/deno.json b/bases/deno.jsonc similarity index 100% rename from bases/deno.json rename to bases/deno.jsonc diff --git a/bases/docusaurus.json b/bases/docusaurus.jsonc similarity index 100% rename from bases/docusaurus.json rename to bases/docusaurus.jsonc diff --git a/bases/ember.json b/bases/ember.jsonc similarity index 100% rename from bases/ember.json rename to bases/ember.jsonc diff --git a/bases/next.json b/bases/next.jsonc similarity index 100% rename from bases/next.json rename to bases/next.jsonc diff --git a/bases/node-lts.json b/bases/node-lts.jsonc similarity index 100% rename from bases/node-lts.json rename to bases/node-lts.jsonc diff --git a/bases/node-ts.json b/bases/node-ts.jsonc similarity index 100% rename from bases/node-ts.json rename to bases/node-ts.jsonc diff --git a/bases/node10.json b/bases/node10.jsonc similarity index 100% rename from bases/node10.json rename to bases/node10.jsonc diff --git a/bases/node12.json b/bases/node12.jsonc similarity index 100% rename from bases/node12.json rename to bases/node12.jsonc diff --git a/bases/node14.json b/bases/node14.jsonc similarity index 100% rename from bases/node14.json rename to bases/node14.jsonc diff --git a/bases/node16.json b/bases/node16.jsonc similarity index 100% rename from bases/node16.json rename to bases/node16.jsonc diff --git a/bases/node17.json b/bases/node17.jsonc similarity index 100% rename from bases/node17.json rename to bases/node17.jsonc diff --git a/bases/node18.json b/bases/node18.jsonc similarity index 100% rename from bases/node18.json rename to bases/node18.jsonc diff --git a/bases/node19.json b/bases/node19.jsonc similarity index 100% rename from bases/node19.json rename to bases/node19.jsonc diff --git a/bases/node20.json b/bases/node20.jsonc similarity index 100% rename from bases/node20.json rename to bases/node20.jsonc diff --git a/bases/node21.json b/bases/node21.jsonc similarity index 100% rename from bases/node21.json rename to bases/node21.jsonc diff --git a/bases/node22.json b/bases/node22.jsonc similarity index 100% rename from bases/node22.json rename to bases/node22.jsonc diff --git a/bases/node23.json b/bases/node23.jsonc similarity index 100% rename from bases/node23.json rename to bases/node23.jsonc diff --git a/bases/node24.json b/bases/node24.jsonc similarity index 100% rename from bases/node24.json rename to bases/node24.jsonc diff --git a/bases/nuxt.json b/bases/nuxt.jsonc similarity index 100% rename from bases/nuxt.json rename to bases/nuxt.jsonc diff --git a/bases/qjsengine.json b/bases/qjsengine.jsonc similarity index 100% rename from bases/qjsengine.json rename to bases/qjsengine.jsonc diff --git a/bases/react-native.json b/bases/react-native.jsonc similarity index 100% rename from bases/react-native.json rename to bases/react-native.jsonc diff --git a/bases/recommended.json b/bases/recommended.jsonc similarity index 100% rename from bases/recommended.json rename to bases/recommended.jsonc diff --git a/bases/remix.json b/bases/remix.jsonc similarity index 100% rename from bases/remix.json rename to bases/remix.jsonc diff --git a/bases/strictest.json b/bases/strictest.jsonc similarity index 100% rename from bases/strictest.json rename to bases/strictest.jsonc diff --git a/bases/svelte.json b/bases/svelte.jsonc similarity index 100% rename from bases/svelte.json rename to bases/svelte.jsonc diff --git a/bases/taro.json b/bases/taro.jsonc similarity index 100% rename from bases/taro.json rename to bases/taro.jsonc diff --git a/bases/vite-react.json b/bases/vite-react.jsonc similarity index 100% rename from bases/vite-react.json rename to bases/vite-react.jsonc diff --git a/scripts/create-npm-packages.ts b/scripts/create-npm-packages.ts index 1929c03..ae7baa6 100644 --- a/scripts/create-npm-packages.ts +++ b/scripts/create-npm-packages.ts @@ -5,7 +5,7 @@ for await (const tsconfigEntry of Deno.readDir("bases")) { if (!tsconfigEntry.isFile) continue; const tsconfigFilePath = path.join("bases", tsconfigEntry.name); - const name = path.basename(tsconfigEntry.name).replace(".json", ""); + const { name } = path.parse(tsconfigEntry.name); // Make the folder const packagePath = path.join("packages", name); @@ -172,7 +172,7 @@ async function buildTsconfigBases() { if (!tsconfigEntry.isFile) continue; // remove extension - const name = tsconfigEntry.name.replace(/\.json$/, ""); + const { name } = path.parse(tsconfigEntry.name); const finalTsconfigFile = `${name}.tsconfig.json`; diff --git a/scripts/generate-lts.ts b/scripts/generate-lts.ts index ca0f80b..26622bf 100644 --- a/scripts/generate-lts.ts +++ b/scripts/generate-lts.ts @@ -48,7 +48,7 @@ const versioned = { }; const packageText = await Deno.readTextFile( - path.join(Deno.cwd(), "bases", `${base}.json`), + path.join(Deno.cwd(), "bases", `${base}.jsonc`), ); const parsed = parseJsonc(packageText) as Tsconfig; @@ -62,5 +62,5 @@ const serializedConfig = "// This file was autogenerated by a script\n" + JSON.stringify(parsedAndOrdered, null, " ") + "\n"; -const filePath = path.join(Deno.cwd(), "bases/node-lts.json"); +const filePath = path.join(Deno.cwd(), "bases/node-lts.jsonc"); Deno.writeTextFile(filePath, serializedConfig); diff --git a/scripts/generate-recommend.ts b/scripts/generate-recommend.ts index 356db17..1c61143 100644 --- a/scripts/generate-recommend.ts +++ b/scripts/generate-recommend.ts @@ -49,5 +49,5 @@ const npmResponse = await fetch( const npmPackage = await npmResponse.text(); if (npmPackage !== result) { - await Deno.writeTextFile("bases/recommended.json", `${result}\n`); + await Deno.writeTextFile("bases/recommended.jsonc", `${result}\n`); } diff --git a/scripts/update-markdown-readme.ts b/scripts/update-markdown-readme.ts index 864682f..c38bf84 100644 --- a/scripts/update-markdown-readme.ts +++ b/scripts/update-markdown-readme.ts @@ -16,11 +16,11 @@ for await (const tsconfigEntry of Deno.readDir("bases")) { const sortedPaths = paths .sort((l, r) => l.localeCompare(r)) .filter((r) => !r.includes("recommended")); -const basePaths = ["recommended.json", ...sortedPaths]; +const basePaths = ["recommended.jsonc", ...sortedPaths]; for (const base of basePaths) { - if (base === "esm.json") continue; + if (base === "esm.jsonc") continue; const tsconfigFilePath = path.join("bases", base); - const name = path.basename(base).replace(".json", ""); + const { name } = path.parse(base); const tsconfigText = await Deno.readTextFile(tsconfigFilePath); const tsconfigJSON = parseJsonc(tsconfigText) as { display: string };