Skip to content
Open
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 .depcheckrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@lavamoat/allow-scripts",
"@lavamoat/preinstall-always-fail",
"@types/*",
"@yarnpkg/types",
"prettier-plugin-packagejson",
"@swc/cli",
"@swc/core",
Expand Down
940 changes: 0 additions & 940 deletions .yarn/releases/yarn-4.14.1.cjs

This file was deleted.

944 changes: 944 additions & 0 deletions .yarn/releases/yarn-4.17.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js'

yarnPath: .yarn/releases/yarn-4.14.1.cjs
yarnPath: .yarn/releases/yarn-4.17.1.cjs

# Configure the NPM minimal age gate to 3 days, meaning packages must be at
# least 3 days old to be installed.
Expand Down
27 changes: 0 additions & 27 deletions constraints.pro

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@types/unzipper": "^0",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"@yarnpkg/types": "^4.0.0",
"depcheck": "^1.4.3",
"eslint": "^8.44.0",
"eslint-config-prettier": "^10.1.8",
Expand All @@ -78,7 +79,7 @@
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1"
},
"packageManager": "yarn@4.14.1",
"packageManager": "yarn@4.17.1",
"engines": {
"node": ">=22.18.0"
},
Expand Down
81 changes: 81 additions & 0 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* @ts-check */

// This file is used to define, among other configuration, rules that Yarn will
// execute when you run `yarn constraints`. These rules primarily check the
// manifest of the package to ensure it follows a standard format.

/** @type {import('@yarnpkg/types')} */
const { defineConfig } = require('@yarnpkg/types');

/**
* Aliases for the Yarn type definitions, to make the code more readable.
*
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Yarn} Yarn
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Workspace} Workspace
*/

module.exports = defineConfig({
async constraints({ Yarn }) {
for (const workspace of Yarn.workspaces()) {
// All packages must have a name.
expectWorkspaceField(workspace, 'name');

// All packages must have a description that does not end in a period.
expectWorkspaceDescription(workspace);

// All packages must specify a minimum Node version of 22.18, which is
// needed to run `.mts` scripts directly.
workspace.set('engines.node', '>=22.18.0');

// If a dependency is listed under "dependencies", it should not be
// listed under "devDependencies".
for (const dependency of Yarn.dependencies({ workspace })) {
if (dependency.type !== 'devDependencies') {
continue;
}

const isAlsoDependency = Yarn.dependencies({
workspace,
ident: dependency.ident,
}).some((other) => other.type === 'dependencies');

if (isAlsoDependency) {
workspace.unset(`devDependencies.${dependency.ident}`);
}
}
}
},
});

/**
* Expect that the workspace has the given field, and that it is not null or an
* empty string. If the field is not present, this will log an error, and
* cause the constraint to fail.
*
* @param {Workspace} workspace - The workspace to check.
* @param {string} fieldName - The field to check.
*/
function expectWorkspaceField(workspace, fieldName) {
const value = workspace.manifest[fieldName];
if (value === undefined || value === null || value === '') {
workspace.error(`Missing required field \`${fieldName}\`.`);
}
}

/**
* Expect that the workspace has a description, and that it is a non-empty
* string. If the description is not present, or is null, this will log an
* error, and cause the constraint to fail.
*
* This will also verify that the description does not end with a period.
*
* @param {Workspace} workspace - The workspace to check.
*/
function expectWorkspaceDescription(workspace) {
expectWorkspaceField(workspace, 'description');

const { description } = workspace.manifest;
if (typeof description === 'string' && description.endsWith('.')) {
workspace.set('description', description.slice(0, -1));
}
}
23 changes: 20 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Manual changes might be lost - proceed with caution!

__metadata:
version: 9
version: 10
cacheKey: 10

"@aashutoshrathi/word-wrap@npm:^1.2.3":
Expand Down Expand Up @@ -1040,6 +1040,7 @@ __metadata:
"@types/unzipper": "npm:^0"
"@typescript-eslint/eslint-plugin": "npm:^5.43.0"
"@typescript-eslint/parser": "npm:^5.43.0"
"@yarnpkg/types": "npm:^4.0.0"
axios: "npm:^0.24.0"
csv-parse: "npm:5.6.0"
depcheck: "npm:^1.4.3"
Expand Down Expand Up @@ -2242,6 +2243,15 @@ __metadata:
languageName: node
linkType: hard

"@yarnpkg/types@npm:^4.0.0":
version: 4.0.1
resolution: "@yarnpkg/types@npm:4.0.1"
dependencies:
tslib: "npm:^2.4.0"
checksum: 10/f391763cd955356e9aad551b29e8de7bbf68a6c8992af7cdc950ccf53f8aff6695ad81aa4c8a8e7c582786a840a4f30617732e2cb49f4109b971a9242c31c9fc
languageName: node
linkType: hard

"abbrev@npm:1, abbrev@npm:^1.0.0":
version: 1.1.1
resolution: "abbrev@npm:1.1.1"
Expand Down Expand Up @@ -7316,14 +7326,14 @@ __metadata:

"resolve@patch:resolve@npm%3A^1.18.1#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.20.0#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.22.1#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin<compat/resolve>":
version: 1.22.4
resolution: "resolve@patch:resolve@npm%3A1.22.4#optional!builtin<compat/resolve>::version=1.22.4&hash=c3c19d"
resolution: "resolve@patch:resolve@npm%3A1.22.4#optional!builtin<compat/resolve>::version=1.22.4&hash=9bd1a5"
dependencies:
is-core-module: "npm:^2.13.0"
path-parse: "npm:^1.0.7"
supports-preserve-symlinks-flag: "npm:^1.0.0"
bin:
resolve: bin/resolve
checksum: 10/13262490c7b0ac54f6397f1d45ee139ebd2e431781e2ff0d9c27bf41648a349a90bc23a3ab2768f0f821efdd2cba08fb85f21288fc0cc01718c03557fbd285bc
checksum: 10/7deeb9b1d998fef4afbb6eacf7f530449caea9c968a92ac83767f53f11ecf81d128f235d56ba5cfc8915e69125919a4ffb5582ed8bceebc3435141203797f67c
languageName: node
linkType: hard

Expand Down Expand Up @@ -8204,6 +8214,13 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.4.0":
version: 2.9.1
resolution: "tslib@npm:2.9.1"
checksum: 10/20aa8c3282c88f8dd1bf0a62c5b1aa03b35998cbc6db4780f6e84d593ba4ffe232bd967916c6e0f96b9e5d719dade9e329d1b2cfede31043481d8fd13f10ca5f
languageName: node
linkType: hard

"tsutils@npm:^3.21.0":
version: 3.21.0
resolution: "tsutils@npm:3.21.0"
Expand Down
Loading