-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyarn.config.cjs
44 lines (39 loc) · 1.5 KB
/
yarn.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// @ts-check
/** @type {import('@yarnpkg/types')} */
const { defineConfig } = require('@yarnpkg/types')
/**
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Context} Context
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Workspace} Workspace
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Dependency} Dependency
*/
/**
* Enforces required manifest fields for workspaces.
*
* @param {Context} context
* @param {Record<string, string | ((workspace: Workspace) => string)>} fields
*/
function enforceFieldsOnAllWorkspaces({ Yarn }, fields) {
for (const workspace of Yarn.workspaces()) {
if (workspace.manifest.private) continue
for (const [key, value] of Object.entries(fields)) {
workspace.set(key, typeof value === 'function' ? value(workspace) : value)
}
}
}
module.exports = defineConfig({
async constraints(ctx) {
enforceFieldsOnAllWorkspaces(ctx, {
license: 'MIT',
'repository.type': 'git',
'repository.url': 'https://github.com/noahnu/nodejs-tools.git',
'repository.directory': (workspace) => workspace.cwd,
'publishConfig.registry': 'https://registry.npmjs.org/',
'publishConfig.access': 'public',
'author.name': 'noahnu',
'author.email': '[email protected]',
'author.url': 'https://noahnu.com',
'scripts.clean': 'run workspace:clean "$(pwd)"',
'scripts.prepack': 'run workspace:build "$(pwd)"',
})
},
})