Skip to content

Commit

Permalink
Organize scripts and MRL
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson committed Jul 18, 2024
1 parent 9b2b745 commit a4099f9
Show file tree
Hide file tree
Showing 60 changed files with 270 additions and 209 deletions.
2 changes: 2 additions & 0 deletions .changeset/famous-suns-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
104 changes: 53 additions & 51 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,33 @@ import * as child_process from "node:child_process";
const LATEST_TYPESCRIPT_DEP = "^5.5.2";

const DELETE_SCRIPT_ENTRY = { options: [undefined], fixValue: undefined };

//
// BEGIN MUTUALLY EXCLUSIVE GROUPS
//

// Packages in this section MUST only belong to one (or none) of these
// three groups:
// - nonStandardPackages
// - legacyPackages
// - esmOnlyPackages
//
// Packages in none of these groups are treated as esm + cjs
// but not legacy

const nonStandardPackages = [
"@osdk/e2e.generated.1.1.x",
"@osdk/e2e.sandbox.todoapp",
"@osdk/examples.*",
"@osdk/foundry-sdk-generator",
"@osdk/monorepo.*", // internal monorepo packages
"@osdk/e2e.sandbox.*", // sandboxes for manual e2e testing
"@osdk/e2e.generated.*", // generated sdks for e2e testing
"@osdk/shared.client", // hand written package that only exposes a symbol
"@osdk/create-app.template.*", // template packages for create-app
"@osdk/tests.*",
];

// Any package that is in the dependency chain of `legacy-client` needs to be in this list
// Any package that is in the dependency chain of `legacy-client` needs to be in this list so
// that we are sure to generate them in a backwards compatible way. This can be changed
// at next major.
const legacyPackages = [
"@osdk/api",
"@osdk/gateway",
Expand All @@ -58,8 +73,10 @@ const esmOnlyPackages = [
"@osdk/cli",
"@osdk/client.*",
"@osdk/client",
"@osdk/create-app.template-packager",
"@osdk/create-app.*",
"@osdk/create-app",
"@osdk/e2e.generated.catchall",
"@osdk/e2e.sandbox.catchall",
"@osdk/example-generator",
"@osdk/foundry.*",
"@osdk/foundry",
Expand All @@ -75,11 +92,24 @@ const esmOnlyPackages = [
// "@osdk/examples.*", but they have their own config cause they are nonstandard
];

//
// END MUTUALLY EXCLUSIVE GROUPS
//

// Packages that should have the `check-api` task installed
const checkApiPackages = [
"@osdk/client",
"@osdk/client.api",
];

// Packages that should be private
const privatePackages = [
"@osdk/client.test.ontology",
"@osdk/e2e.*",
"@osdk/monorepo.*",
"@osdk/tool.*",
];

/**
* We don't want to allow `workspace:^` in our dependencies because our current release branch
* strategy only allows for patch changes in the release branch and minors elsewhere.
Expand Down Expand Up @@ -210,8 +240,6 @@ function getTsconfigOptions(baseTsconfigPath, opts) {
* @param {{
* legacy: boolean,
* esmOnly?: boolean,
* packageDepth: number,
* type: "library" | "example",
* customTsconfigExcludes?: string[],
* tsVersion?: "^5.5.2"|"^4.9.5",
* skipTsconfigReferences?: boolean
Expand All @@ -228,9 +256,6 @@ function standardPackageRules(shared, options) {
throw "singlePackageName only makes sense for legacy packages";
}

const pathToWorkspaceRoot = "../".repeat(options.packageDepth)
.slice(0, -1); // drop trailing slash

return [
disallowWorkspaceCaret({ ...shared }),

Expand Down Expand Up @@ -291,19 +316,16 @@ function standardPackageRules(shared, options) {
scripts: {
clean: "rm -rf lib dist types build tsconfig.tsbuildinfo",
"check-spelling": "cspell --quiet .",
"check-attw":
`${pathToWorkspaceRoot}/scripts/build_common/check-attw.sh ${
options.esmOnly ? "esm" : "both"
}`,
"check-attw": `monorepo.tool.attw ${
options.esmOnly ? "esm" : "both"
}`,
lint: "eslint . && dprint check --config $(find-up dprint.json)",
"fix-lint":
"eslint . --fix && dprint fmt --config $(find-up dprint.json)",
transpile:
"find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
typecheck:
`find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ${pathToWorkspaceRoot}/scripts/build_common/typecheck.sh ${
options.esmOnly ? "esm" : "both"
}`,
transpile: "monorepo.tool.transpile",
typecheck: `monorepo.tool.typecheck ${
options.esmOnly ? "esm" : "both"
}`,
},
},
}),
Expand Down Expand Up @@ -432,14 +454,8 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
`,
},
}),
...standardPackageRules({
includePackages: ["@osdk/create-app.template.*"],
}, {
legacy: false,
packageDepth: 2,
type: "example",
esmOnly: true,
}),

// Fall through case for none of the mutual exclusive groups
...standardPackageRules({
excludePackages: [
...nonStandardPackages,
Expand All @@ -448,8 +464,6 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
],
}, {
legacy: false,
packageDepth: 2,
type: "library",
tsVersion: LATEST_TYPESCRIPT_DEP,
}),

Expand All @@ -458,17 +472,13 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
}, {
legacy: false,
esmOnly: true,
packageDepth: 2,
type: "library",
tsVersion: LATEST_TYPESCRIPT_DEP,
}),

...standardPackageRules({
includePackages: ["@osdk/foundry-sdk-generator"],
}, {
legacy: false,
packageDepth: 2,
type: "library",
tsVersion: LATEST_TYPESCRIPT_DEP,
esmOnly: true,
customTsconfigExcludes: [
Expand All @@ -483,35 +493,18 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
includePackages: [pkg],
}, {
legacy: true,
packageDepth: 2,
type: "library",
tsVersion: LATEST_TYPESCRIPT_DEP,
singlePackageName: pkg,
})
)
),

...standardPackageRules({
includePackages: [
"@osdk/e2e.generated.catchall",
"@osdk/e2e.sandbox.catchall",
],
excludePackages: ["@osdk/e2e.generated.1.1.x"],
}, {
esmOnly: true,
legacy: false,
packageDepth: 2,
type: "example",
}),

// most packages can use the newest typescript, but we enforce that @osdk/example.one.dot.one uses TS4.9
// so that we get build-time checking to make sure we don't regress v1.1 clients using an older Typescript.
...standardPackageRules({
includePackages: ["@osdk/e2e.generated.1.1.x"],
}, {
legacy: false,
packageDepth: 2,
type: "example",
tsVersion: "^4.9.5",
skipTsconfigReferences: true,
}),
Expand Down Expand Up @@ -571,6 +564,15 @@ package you do so at your own risk.
},
}),

packageEntry({
includePackages: privatePackages,
options: {
entries: {
private: true,
},
},
}),

alphabeticalDependencies({ includeWorkspaceRoot: true }),
alphabeticalScripts({ includeWorkspaceRoot: true }),

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"@monorepolint/core": "0.5.0-beta.10",
"@monorepolint/rules": "0.5.0-beta.10",
"@osdk/monorepo.cspell": "workspace:~",
"@osdk/monorepo.tool.attw": "workspace:~",
"@osdk/monorepo.tool.transpile": "workspace:~",
"@osdk/monorepo.tool.typecheck": "workspace:~",
"@osdk/monorepo.tsconfig": "workspace:~",
"@osdk/monorepo.tsup": "workspace:~",
"@types/lint-staged": "^13.3.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh both",
"check-attw": "monorepo.tool.attw both",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"test": "vitest run --pool=forks",
"test:watch": "vitest",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"transpile": "monorepo.tool.transpile",
"transpileWatch": "tsup --watch",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh both"
"typecheck": "monorepo.tool.typecheck both"
},
"dependencies": {
"@osdk/gateway": "workspace:~",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli.cmd.typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@arethetypeswrong/cli": "^0.15.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli.common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"consola": "^3.2.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"test": "vitest run --pool=forks",
"test:watch": "vitest",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"transpile": "monorepo.tool.transpile",
"transpileWatch": "tsup --watch",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@arethetypeswrong/cli": "^0.15.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/client.api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"scripts": {
"api-docs": "api-documenter markdown -i build/api-extractor --output-folder api-docs",
"check-api": "api-extractor run --verbose --local",
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@osdk/api": "workspace:~"
Expand Down
6 changes: 3 additions & 3 deletions packages/client.test.ontology/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"codegen": "node ./generateMockOntology.js",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@osdk/client.api": "workspace:*"
Expand Down
6 changes: 3 additions & 3 deletions packages/client.unstable.osw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"conjure-lite": "^0.4.4"
Expand Down
6 changes: 3 additions & 3 deletions packages/client.unstable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
}
},
"scripts": {
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"transpile": "monorepo.tool.transpile",
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"conjure-lite": "^0.4.4"
Expand Down
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
},
"scripts": {
"check-api": "api-extractor run --verbose --local",
"check-attw": "../../scripts/build_common/check-attw.sh esm",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"test": "vitest run --pool=forks",
"test:watch": "vitest",
"transpile": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.js' -or -name '*.js.map' -or -name '*.cjs' -or -name '*.cjs.map' \\) -delete && tsup",
"transpile": "monorepo.tool.transpile",
"transpileWatch": "tsup --watch",
"typecheck": "find . \\( -path build/cjs -or -path build/esm -or -path build/browser \\) -type f \\( -name '*.ts' -or -name '*.ts.map' -or -name '*.cts' -or -name '*.cts.map' \\) -delete && ../../scripts/build_common/typecheck.sh esm"
"typecheck": "monorepo.tool.typecheck esm"
},
"dependencies": {
"@osdk/api": "workspace:~",
Expand Down
Loading

0 comments on commit a4099f9

Please sign in to comment.