Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@yarnpkg/types": "4.0.0",
"eslint": "9.11.0",
"husky": "9.1.6",
"lint-staged": "15.2.10",
Expand Down
52 changes: 50 additions & 2 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
module.exports = {
const { defineConfig } = require("@yarnpkg/types");

module.exports = defineConfig({
async constraints({ Yarn }) {
const rootWorkspace = Yarn.workspace({ cwd: "." });
if (rootWorkspace == null) {
Yarn.workspace().error("Didn't find a root workspace?!");
return;
}

// Use ESM everywhere.
for (const workspace of Yarn.workspaces()) {
workspace.set("type", "module");
}

// Set a consistent repository for all workspaces.
if (rootWorkspace.manifest.repository == null) {
rootWorkspace.error("Missing repository specification!");
}
for (const workspace of Yarn.workspaces()) {
if (workspace.cwd !== ".") {
workspace.set("repository.directory", workspace.cwd);
workspace.set(
"repository.type",
rootWorkspace.manifest.repository.type,
);
workspace.set("repository.url", rootWorkspace.manifest.repository.url);
} else {
workspace.unset("repository.directory");
}
}

// Expect each workspace to either have a license or be private.
for (const workspace of Yarn.workspaces()) {
if (workspace.manifest.license == null && !workspace.manifest.private) {
// Don't default since we want a human to make the call.
workspace.error("Missing license for non-private workspace!");
}
}

// Expect each workspace to specify a version, except for the root.
for (const workspace of Yarn.workspaces()) {
if (workspace.cwd !== ".") {
workspace.set("version", workspace.manifest.version ?? "0.0.1");
} else {
workspace.unset("version");
}
}

// Explicitly specify whether the workspace is private or not.
for (const workspace of Yarn.workspaces()) {
workspace.set("private", !!workspace.manifest.private);
}
},
};
});
12 changes: 11 additions & 1 deletion yarn.lock

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

Loading