Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kbd><a href="./bases/ember.json">tsconfig.json</a></kbd>

Expand All @@ -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 <kbd><a href="./bases/next.json">tsconfig.json</a></kbd>

Expand Down Expand Up @@ -405,7 +405,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 <kbd><a href="./bases/qjsengine.json">tsconfig.json</a></kbd>

Expand Down Expand Up @@ -454,7 +454,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 <kbd><a href="./bases/strictest.json">tsconfig.json</a></kbd>

Expand Down
3 changes: 1 addition & 2 deletions bases/docusaurus.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"display": "Docusaurus v2",
"docs": "https://v2.docusaurus.io/docs/typescript-support",
"_version": "2.0.0",

"compilerOptions": {
"allowJs": true,
"esModuleInterop": true,
Expand All @@ -13,7 +13,6 @@
"moduleResolution": "bundler",
"noEmit": true,
"types": ["node", "@docusaurus/module-type-aliases", "@docusaurus/theme-classic"],
"baseUrl": ".",
"paths": {
"@site/*": ["./*"]
},
Expand Down
3 changes: 2 additions & 1 deletion bases/ember.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

// 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",
Expand Down
1 change: 0 additions & 1 deletion bases/nuxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"sourceMap": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
Expand Down
24 changes: 17 additions & 7 deletions bases/recommended.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"$schema": "https://www.schemastore.org/tsconfig",
"display": "Recommended",
"_version": "2.0.0",
"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",
"$schema": "https://www.schemastore.org/tsconfig"
}
}
1 change: 0 additions & 1 deletion bases/remix.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"target": "es2019",
"strict": true,
"allowJs": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
Expand Down
8 changes: 8 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
45 changes: 45 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion readme-extras/docusaurus.md
Original file line number Diff line number Diff line change
@@ -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": { "*": ["./*"] }`).
2 changes: 1 addition & 1 deletion readme-extras/ember.md
Original file line number Diff line number Diff line change
@@ -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": { "*": ["./*"] }`).
2 changes: 1 addition & 1 deletion readme-extras/nuxt.md
Original file line number Diff line number Diff line change
@@ -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": { "*": ["./*"] }`).
2 changes: 1 addition & 1 deletion readme-extras/remix.md
Original file line number Diff line number Diff line change
@@ -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": { "*": ["./*"] }`).
24 changes: 12 additions & 12 deletions scripts/create-npm-packages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
Expand All @@ -9,23 +9,23 @@ for await (const tsconfigEntry of Deno.readDir("bases")) {

// Make the folder
const packagePath = path.join("packages", name)
Deno.mkdirSync(packagePath, { recursive: true })
await Deno.mkdir(packagePath, { recursive: true })

// Copy over the template files
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))
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)
await Deno.copyFile(tsconfigFilePath, newPackageTSConfigPath)

const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath)
const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText))
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.*/,''))
Expand All @@ -48,7 +48,7 @@ for await (const tsconfigEntry of Deno.readDir("bases")) {
let packageText = await Deno.readTextFile(fileToEdit)
packageText = packageText.replace(/\[filename\]/g, name)
.replace(/\[display_title\]/g, title)
.replace(/\[tsconfig\]/g, Deno.readTextFileSync(newPackageTSConfigPath))
.replace(/\[tsconfig\]/g, await Deno.readTextFile(newPackageTSConfigPath))

// Inject readme-extra if any
try {
Expand Down Expand Up @@ -111,15 +111,15 @@ async function buildTsconfigBases() {

// Make the folder
const packagePath = path.join("packages", name)
Deno.mkdirSync(packagePath, { recursive: true })
await Deno.mkdir(packagePath, { recursive: true })

// Copy over the template files
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(
await Deno.copyFile(
templatedFile,
path.join(
packagePath,
Expand All @@ -146,7 +146,7 @@ async function buildTsconfigBases() {

const newPackageTSConfigPath = path.join(packagePath, finalTsconfigFile)

Deno.copyFileSync(tsconfigFilePath, newPackageTSConfigPath)
await Deno.copyFile(tsconfigFilePath, newPackageTSConfigPath)

const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath)

Expand Down
29 changes: 13 additions & 16 deletions scripts/deploy-changed-npm-packages.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
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 = []

for (const dirEntry of Deno.readDirSync("packages")) {
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 newTSConfig = await Deno.readTextFile(localTsconfigPath);

let upload = false;
try {
Expand All @@ -22,33 +21,31 @@ for (const dirEntry of Deno.readDirSync("packages")) {
}

if (upload) {
const process = Deno.run({
cmd: ["npm", "publish", "--provenance", "--access", "public"],
const cmd = new Deno.Command("npm", {
args: ["publish", "--provenance", "--access", "public"],
stdout: "piped",
cwd: path.join("packages", dirEntry.name),
env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! },
});

for await (const line of bufio.readLines(process.stdout!)) {
console.warn(line);
}
const output = await cmd.output();
if (!output.success) throw new Error(`Failed to publish ${dirEntry.name}`)
console.warn(new TextDecoder().decode(output.stdout));

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"],
const cmd = new Deno.Command("npm", {
args: ["publish", "--provenance", "--access", "public"],
stdout: "piped",
cwd: path.join("packages", "bases"),
env: { NODE_AUTH_TOKEN: Deno.env.get("NODE_AUTH_TOKEN")! },
});

for await (const line of bufio.readLines(process.stdout!)) {
console.warn(line);
}
const output = await cmd.output();
if (!output.success) throw new Error("Failed to publish bases")
console.warn(new TextDecoder().decode(output.stdout));


console.log("Uploaded: ", uploaded.join(", "))
Expand Down
Loading