-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher J Baker
committed
Jul 12, 2024
1 parent
8d76372
commit 1d058b3
Showing
20 changed files
with
480 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18 | ||
20 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react-jsx" | ||
}, | ||
"extends": "../../tsconfig.react.json", | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react-jsx" | ||
}, | ||
"extends": "../../tsconfig.react.json", | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react-jsx" | ||
}, | ||
"extends": "../../tsconfig.react.json", | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "scripts", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"script": "NODE_OPTIONS=\"--no-warnings --import ./register.js\" node", | ||
"check-packages": "npm run script -- ./src/check-packages.ts", | ||
"typecheck": "tsc --noEmit", | ||
"eslint": "eslint .", | ||
"prettier": "prettier --check .", | ||
"depcheck": "depcheck .", | ||
"clean": "rm -rf tsconfig.tsbuildinfo dist" | ||
}, | ||
"dependencies": { | ||
"glob": "^11.0.0", | ||
"semver": "^7.6.2", | ||
"ts-node": "^10.9.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { register } from "node:module" | ||
import { pathToFileURL } from "node:url" | ||
|
||
register("ts-node/esm/transpile-only", pathToFileURL("./")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import semver from "semver" | ||
|
||
import project from "./lib/project.js" | ||
import workspaces, { Package } from "./lib/workspaces.js" | ||
|
||
for (const workspace of Object.values(workspaces)) { | ||
log(workspace, "Processing.") | ||
|
||
if ("private" in workspace) { | ||
if (workspace.private === false) { | ||
error(workspace, `Remove "private: false".`) | ||
} else { | ||
warn(workspace, `Private.`) | ||
} | ||
} | ||
|
||
if (!workspace.private && workspace.directory !== "legacy") { | ||
const nameSplit = workspace.name.match(/(?:@([^/]+)\/)?([^/]+)/) | ||
|
||
if (!nameSplit) { | ||
error( | ||
workspace, | ||
`Package name must be in the format @<namespace>/<package>.`, | ||
) | ||
} else { | ||
if (nameSplit[1] !== project.namespace) { | ||
error( | ||
workspace, | ||
`Package must be in the "${project.namespace}" namespace.`, | ||
) | ||
} | ||
|
||
if (nameSplit[2] !== workspace.directory) { | ||
error(workspace, `Package name and directory must match.`) | ||
} | ||
} | ||
} | ||
|
||
if (!semver.valid(workspace.version)) { | ||
error(workspace, `Invalid version: ${workspace.version}`) | ||
} | ||
|
||
if (workspace.dependencies) { | ||
for (const [name, range] of Object.entries(workspace.dependencies)) { | ||
if (workspaces[name]) { | ||
if (!semver.satisfies(workspaces[name].version, range)) { | ||
error(workspace, `Unsatisfiable package: ${name}@${range}`) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* eslint-disable no-console */ | ||
function log({ directory }: Package, message: string) { | ||
console.log(`${directory} - ${message}`) | ||
} | ||
|
||
function warn({ directory }: Package, message: string) { | ||
console.warn(`${directory} - ${message}`) | ||
} | ||
|
||
function error({ directory }: Package, message: string) { | ||
console.error(`${directory} - ${message}`) | ||
process.exitCode = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import fs from "node:fs" | ||
import path from "node:path" | ||
|
||
export const dirname = path.join(import.meta.dirname, "..", "..", "..", "..") | ||
|
||
const packagePath = path.join(dirname, "package.json") | ||
const packageContents = fs.readFileSync(packagePath, "utf-8") | ||
const packageData = JSON.parse(packageContents) | ||
|
||
export default packageData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from "node:fs" | ||
import path from "node:path" | ||
|
||
import { globSync } from "glob" | ||
|
||
import project, { dirname } from "./project.js" | ||
|
||
interface BarePackage { | ||
name: string | ||
private?: boolean | ||
version: string | ||
dependencies?: Record<string, string> | ||
devDependencies?: Record<string, string> | ||
} | ||
|
||
export interface Package extends BarePackage { | ||
dirname: string | ||
directory: string | ||
} | ||
|
||
const list = globSync(project.workspaces, { cwd: dirname }) | ||
.map((workspace) => { | ||
const split = workspace.split("/") | ||
const directory = split[split.length - 1] | ||
|
||
return { | ||
dirname: workspace, | ||
directory, | ||
pkgPath: path.join(dirname, workspace, "package.json"), | ||
} | ||
}) | ||
.filter(({ pkgPath }) => fs.existsSync(pkgPath)) | ||
.map(({ dirname, directory, pkgPath }) => ({ | ||
dirname, | ||
directory, | ||
...(JSON.parse(fs.readFileSync(pkgPath, "utf-8")) as BarePackage), | ||
})) | ||
|
||
const workspaces: Record<string, Package> = {} | ||
export default workspaces | ||
|
||
for (const pkg of list) { | ||
workspaces[pkg.name] = pkg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.node.json", | ||
"include": ["src"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"target": "ES2022", | ||
"lib": ["ES2022"] | ||
}, | ||
"ts-node": { | ||
"esm": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"target": "ES2020", | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"jsx": "react-jsx" | ||
} | ||
} |