@gjuchault/typescript-library-starter
Advanced tools
Comparing version 5.2.3 to 5.2.4
@@ -5,2 +5,3 @@ { | ||
"words": [ | ||
"bahmutov", | ||
"degit", | ||
@@ -7,0 +8,0 @@ "esbuild", |
{ | ||
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", | ||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json", | ||
"files": { | ||
"ignore": ["build", "node_modules", "coverage"] | ||
"ignore": ["build", "node_modules", "coverage", "package.json"] | ||
}, | ||
@@ -9,3 +9,3 @@ "linter": { | ||
"all": true, | ||
"nursery": { | ||
"correctness": { | ||
"noNodejsModules": "off" | ||
@@ -12,0 +12,0 @@ } |
@@ -1,13 +0,1 @@ | ||
import { createRequire as createRequire98bf2e8e3d1d4bb49c4318ba23de34e5 } from 'module'; | ||
import { fileURLToPath as fileURLToPath98bf2e8e3d1d4bb49c4318ba23de34e5 } from 'url'; | ||
import { dirname as dirname98bf2e8e3d1d4bb49c4318ba23de34e5 } from 'path'; | ||
// using var here to allow subsequent override by authors of this | ||
// library that would be using the same ESM trick | ||
var require = createRequire98bf2e8e3d1d4bb49c4318ba23de34e5(import.meta.url); | ||
var __filename = fileURLToPath98bf2e8e3d1d4bb49c4318ba23de34e5(import.meta.url); | ||
var __dirname = dirname98bf2e8e3d1d4bb49c4318ba23de34e5(__filename); | ||
// src/bar.ts | ||
@@ -14,0 +2,0 @@ function bar() { |
@@ -1,2 +0,2 @@ | ||
## [5.2.3](https://github.com/gjuchault/typescript-library-starter/compare/v5.2.2...v5.2.3) (2024-05-28) | ||
## [5.2.4](https://github.com/gjuchault/typescript-library-starter/compare/v5.2.3...v5.2.4) (2024-12-27) | ||
@@ -6,2 +6,2 @@ | ||
* ci and upgrade packages; use node run ([6cf8122](https://github.com/gjuchault/typescript-library-starter/commit/6cf812249b358eb0689cb1d47e51f42a88677584)) | ||
* **scripts:** fix new lint issues ([1e6e74e](https://github.com/gjuchault/typescript-library-starter/commit/1e6e74e4938f2e10fa3f6d4c6f6b31d76abefd61)) |
{ | ||
"name": "@gjuchault/typescript-library-starter", | ||
"version": "5.2.3", | ||
"version": "5.2.4", | ||
"description": "Yet another typescript library starter template", | ||
@@ -20,8 +20,8 @@ "keywords": [ | ||
"engines": { | ||
"node": "^22.0.0", | ||
"npm": "^10.5.1" | ||
"node": "^23.5.0", | ||
"npm": "^10.9.2" | ||
}, | ||
"volta": { | ||
"node": "22.0.0", | ||
"npm": "10.5.1" | ||
"node": "23.5.0", | ||
"npm": "10.9.2" | ||
}, | ||
@@ -32,15 +32,12 @@ "publishConfig": { | ||
"scripts": { | ||
"setup": "node --import=@nitrogql/esbuild-register ./scripts/setup.ts", | ||
"build": "node --run clean && node --run type:dts && node --run type:extract && node --run build:src", | ||
"build:src": "node --import=@nitrogql/esbuild-register ./scripts/build.ts", | ||
"setup": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/setup.ts", | ||
"build": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/build.ts", | ||
"clean": "rimraf build coverage", | ||
"type:dts": "tsc --emitDeclarationOnly --project tsconfig.build.json", | ||
"type:extract": "api-extractor run && rimraf --glob \"./build/*\" && mv trimmed.d.ts build/index.d.ts", | ||
"type:check": "tsc --noEmit", | ||
"lint": "biome check . --apply-unsafe", | ||
"lint": "biome check . --write --unsafe", | ||
"lint:check": "biome ci .", | ||
"test": "node --import=@nitrogql/esbuild-register --test \"src/**/*.test.ts\"", | ||
"test:watch": "node --import=@nitrogql/esbuild-register --watch --test \"src/**/*.test.ts\"", | ||
"test:coverage": "NODE_V8_COVERAGE=./coverage c8 -r html node --import=@nitrogql/esbuild-register --experimental-test-coverage --test \"src/**/*.test.ts\"", | ||
"test:setup": "node --import=@nitrogql/esbuild-register ./scripts/test-setup.ts", | ||
"test": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/test.ts test", | ||
"test:watch": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/test.ts test:watch", | ||
"test:coverage": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/test.ts test:coverage", | ||
"test:setup": "node --disable-warning=ExperimentalWarning --experimental-strip-types ./scripts/test-setup.ts", | ||
"spell:check": "cspell \"{README.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md,.github/*.md,src/**/*.ts}\"", | ||
@@ -51,25 +48,22 @@ "cz": "cz", | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.7.3", | ||
"@microsoft/api-extractor": "^7.45.1", | ||
"@nitrogql/esbuild-register": "^1.7.0", | ||
"@biomejs/biome": "^1.9.4", | ||
"@microsoft/api-extractor": "^7.48.1", | ||
"@ryansonshine/commitizen": "^4.2.8", | ||
"@ryansonshine/cz-conventional-changelog": "^3.3.4", | ||
"@semantic-release/changelog": "^6.0.3", | ||
"@semantic-release/commit-analyzer": "^12.0.0", | ||
"@semantic-release/github": "^10.0.5", | ||
"@semantic-release/commit-analyzer": "^13.0.0", | ||
"@semantic-release/github": "^11.0.1", | ||
"@semantic-release/npm": "^12.0.1", | ||
"@semantic-release/release-notes-generator": "^13.0.0", | ||
"@types/node": "^20.12.12", | ||
"@semantic-release/release-notes-generator": "^14.0.2", | ||
"@types/node": "^22.10.2", | ||
"@types/prompts": "^2.4.9", | ||
"c8": "^9.1.0", | ||
"cspell": "^8.8.3", | ||
"esbuild": "^0.21.4", | ||
"esbuild-register": "^3.5.0", | ||
"c8": "^10.1.3", | ||
"cspell": "^8.17.1", | ||
"esbuild": "^0.24.2", | ||
"prompts": "^2.4.2", | ||
"rimraf": "^5.0.7", | ||
"semantic-release": "^23.1.1", | ||
"rimraf": "^6.0.1", | ||
"semantic-release": "^24.2.0", | ||
"slugify": "^1.6.6", | ||
"tsx": "^4.11.0", | ||
"typescript": "^5.4.5" | ||
"typescript": "^5.7.2" | ||
} | ||
} |
@@ -45,5 +45,3 @@ # TypeScript Library Starter | ||
- `clean`: removes the `build/` directory | ||
- `type:dts`: only generates `d.ts` | ||
- `type:check`: only runs type checking | ||
- `type:build`: only generates ESM | ||
- `type:check`: runs type checking | ||
@@ -67,4 +65,2 @@ ### Tests | ||
- `format`: runs Prettier with automatic fixing | ||
- `format:check`: runs Prettier without automatic fixing (used in CI) | ||
- `lint`: runs Biome with automatic fixing | ||
@@ -71,0 +67,0 @@ - `lint:check`: runs Biome without automatic fixing (used in CI) |
@@ -1,13 +0,64 @@ | ||
import { randomUUID } from "node:crypto"; | ||
import { execFile as execFileSync } from "node:child_process"; | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
import url from "node:url"; | ||
import { promisify } from "node:util"; | ||
import { build as esbuild } from "esbuild"; | ||
import { rimraf } from "rimraf"; | ||
const execFile = promisify(execFileSync); | ||
const srcPath = path.join(process.cwd(), "src"); | ||
const buildPath = path.join(process.cwd(), "build"); | ||
async function build() { | ||
const buildId = randomUUID().replace(/-/g, ""); | ||
async function clear(): Promise<void> { | ||
const time = Date.now(); | ||
return await esbuild({ | ||
await fs.rm(buildPath, { recursive: true, force: true }); | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
// biome-ignore lint/suspicious/noConsoleLog: script file | ||
console.log(`🚀 cleared in ${Date.now() - time}ms`); | ||
} | ||
async function buildDts(): Promise<void> { | ||
const time = Date.now(); | ||
const { stderr } = await execFile("tsc", [ | ||
"--emitDeclarationOnly", | ||
"--project", | ||
"tsconfig.build.json", | ||
]); | ||
if (stderr) { | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
console.error(stderr); | ||
} | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
// biome-ignore lint/suspicious/noConsoleLog: script file | ||
console.log(`🚀 built definitions files in ${Date.now() - time} ms`); | ||
} | ||
async function extractDts(): Promise<void> { | ||
const time = Date.now(); | ||
const { stderr } = await execFile("api-extractor", ["run"]); | ||
if (stderr) { | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
console.error(stderr); | ||
} | ||
await rimraf("./build/*", { glob: true }); | ||
await fs.rename("trimmed.d.ts", "build/index.d.ts"); | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
// biome-ignore lint/suspicious/noConsoleLog: script file | ||
console.log(`🚀 extracted definitions files in ${Date.now() - time} ms`); | ||
} | ||
async function build(): Promise<void> { | ||
const time = Date.now(); | ||
await esbuild({ | ||
platform: "node", | ||
@@ -21,23 +72,15 @@ target: "node21", | ||
entryPoints: [path.join(srcPath, "index.ts")], | ||
banner: { | ||
js: ` | ||
import { createRequire as createRequire${buildId} } from 'module'; | ||
import { fileURLToPath as fileURLToPath${buildId} } from 'url'; | ||
import { dirname as dirname${buildId} } from 'path'; | ||
// using var here to allow subsequent override by authors of this | ||
// library that would be using the same ESM trick | ||
var require = createRequire${buildId}(import.meta.url); | ||
var __filename = fileURLToPath${buildId}(import.meta.url); | ||
var __dirname = dirname${buildId}(__filename); | ||
`, | ||
}, | ||
outdir: buildPath, | ||
}); | ||
// biome-ignore lint/suspicious/noConsole: script file | ||
// biome-ignore lint/suspicious/noConsoleLog: script file | ||
console.log(`🚀 bundled in ${Date.now() - time}ms`); | ||
} | ||
if (import.meta.url.startsWith("file:")) { | ||
if (process.argv[1] === url.fileURLToPath(import.meta.url)) { | ||
await build(); | ||
} | ||
if (process.argv[1] === import.meta.filename) { | ||
await clear(); | ||
await buildDts(); | ||
await extractDts(); | ||
await build(); | ||
} |
@@ -85,2 +85,14 @@ import childProcess from "node:child_process"; | ||
const packageNameRegexp = /Typescript Library Starter/; | ||
const packageSlugRegexp = /typescript-library-starter/; | ||
const testSetupRegexp = /, test-setup/i; | ||
const packageDescriptionRegexp = /[^\n]+"description[^\n]+\n/; | ||
const packageKeywordsRegexp = /[^\n]+"keywords[^\]]+\],\n/; | ||
const packageHomepageRegexp = /[^\n]+"homepage[^\n]+\n/; | ||
const packageBugsRegexp = /[^\n]+"bugs[^\n]+\n/; | ||
const packageAuthorRegexp = /[^\n]+"author[^\n]+\n/; | ||
const packageRepositoryRegexp = /[^\n]+"repository[^\n]+\n/; | ||
const packageSetupRegexp = /[^\n]+"setup[^\n]+\n/; | ||
const packageTestSetupRegexp = /[^\n]+"test:setup[^\n]+\n/; | ||
async function applyPackageName({ | ||
@@ -112,6 +124,6 @@ packageName, | ||
new Map<string | RegExp, string>([ | ||
[/Typescript Library Starter/, packageName], | ||
[/typescript-library-starter/, packageSlug], | ||
[packageNameRegexp, packageName], | ||
[packageSlugRegexp, packageSlug], | ||
[setupAction, ""], | ||
[/, test-setup/i, ""], | ||
[testSetupRegexp, ""], | ||
]), | ||
@@ -183,10 +195,10 @@ ), | ||
["@gjuchault/typescript-library-starter", packageName], | ||
[/[^\n]+"description[^\n]+\n/, ""], | ||
[/[^\n]+"keywords[^\]]+\],\n/, ""], | ||
[/[^\n]+"homepage[^\n]+\n/, ""], | ||
[/[^\n]+"bugs[^\n]+\n/, ""], | ||
[/[^\n]+"author[^\n]+\n/, ""], | ||
[/[^\n]+"repository[^\n]+\n/, ""], | ||
[/[^\n]+"setup[^\n]+\n/, ""], | ||
[/[^\n]+"test:setup[^\n]+\n/, ""], | ||
[packageDescriptionRegexp, ""], | ||
[packageKeywordsRegexp, ""], | ||
[packageHomepageRegexp, ""], | ||
[packageBugsRegexp, ""], | ||
[packageAuthorRegexp, ""], | ||
[packageRepositoryRegexp, ""], | ||
[packageSetupRegexp, ""], | ||
[packageTestSetupRegexp, ""], | ||
]), | ||
@@ -249,6 +261,4 @@ ), | ||
if (import.meta.url.startsWith("file:")) { | ||
if (process.argv[1] === url.fileURLToPath(import.meta.url)) { | ||
await setup(); | ||
} | ||
if (process.argv[1] === import.meta.filename) { | ||
await setup(); | ||
} |
import childProcess from "node:child_process"; | ||
import url from "node:url"; | ||
import { promisify } from "node:util"; | ||
import { run } from "./setup"; | ||
import { run } from "./setup.ts"; | ||
@@ -14,3 +13,3 @@ const exec = promisify(childProcess.exec); | ||
if (!gitEmail.trim().length) { | ||
if (gitEmail.trim().length === 0) { | ||
await exec("git config --global user.email actions@github.com"); | ||
@@ -63,6 +62,4 @@ await exec("git config --global user.name GithubActions"); | ||
if (import.meta.url.startsWith("file:")) { | ||
if (process.argv[1] === url.fileURLToPath(import.meta.url)) { | ||
await testSetup(); | ||
} | ||
if (process.argv[1] === import.meta.filename) { | ||
await testSetup(); | ||
} |
import { equal } from "node:assert/strict"; | ||
import { describe, it } from "node:test"; | ||
import { foobar } from "../index.js"; | ||
import { foobar } from "../index.ts"; | ||
@@ -6,0 +6,0 @@ await describe("foobar()", async () => { |
@@ -1,3 +0,3 @@ | ||
import { bar } from "./bar.js"; | ||
import { foo } from "./foo.js"; | ||
import { bar } from "./bar.ts"; | ||
import { foo } from "./foo.ts"; | ||
@@ -4,0 +4,0 @@ export function foobar(a: number, b: number) { |
@@ -19,4 +19,6 @@ { | ||
"declaration": true, | ||
"resolveJsonModule": true | ||
"resolveJsonModule": true, | ||
"emitDeclarationOnly": true, | ||
"allowImportingTsExtensions": true | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
34338
19
31
652
1
78