Skip to content

Commit

Permalink
Merge pull request #258 from yinm/remove-display-field
Browse files Browse the repository at this point in the history
Drop `display` field
  • Loading branch information
orta authored Mar 27, 2024
2 parents b02260d + 15ede8e commit be6b3bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions bases/recommended.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Recommended"
"display": "Recommended",
"$schema": "https://json.schemastore.org/tsconfig"
}
5 changes: 4 additions & 1 deletion scripts/create-npm-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ for await (const tsconfigEntry of Deno.readDir("bases")) {
const tsconfigText = await Deno.readTextFile(newPackageTSConfigPath)
const tsconfigJSON = JSON.parse(stripJsonComments(tsconfigText))

// 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)
Expand All @@ -44,7 +47,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(tsconfigFilePath))
.replace(/\[tsconfig\]/g, Deno.readTextFileSync(newPackageTSConfigPath))

// Inject readme-extra if any
try {
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate-recommend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stripJsonComments from "https://esm.sh/strip-json-comments";
import * as bufio from "https://deno.land/std/io/buffer.ts";
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";

const tsconfigStorage = await Deno.makeTempDir({ prefix: "tsconfig" });
Expand All @@ -14,9 +14,9 @@ let packageText = await Deno.readTextFile(path.join(tsconfigStorage, "tsconfig.j
// This will strip comments
const parsed = JSON.parse(stripJsonComments(packageText));

parsed["$schema"] = "https://json.schemastore.org/tsconfig";
// `display` field will be dropped at generating npm package, so prevent the order from being last in the JSON file
parsed.display = "Recommended";
parsed.compilerOptions.target = "ES2015";
parsed["$schema"] = "https://json.schemastore.org/tsconfig";

const result = JSON.stringify(parsed, null, " ");

Expand Down

0 comments on commit be6b3bb

Please sign in to comment.