@reelout/yarn 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -3
- package/src/PLUGIN_NAME.ts +4 -0
- package/src/index.ts +5 -0
- package/src/yarn.ts +264 -0
- package/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @reelout/yarn
|
|
2
|
+
|
|
3
|
+
Yarn integration for [ReelOut](https://github.com/reelout/reelout). The plugin
|
|
4
|
+
resolves Yarn workspaces (Classic and Berry), updates package manifests and
|
|
5
|
+
internal dependency ranges, and publishes packages with the active Yarn
|
|
6
|
+
version.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
This plugin is **opt-in**: the `reelout` CLI does not include it through
|
|
11
|
+
`@reelout/config`. Install it and register it in your configuration to publish
|
|
12
|
+
Yarn workspaces.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @reelout/yarn
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
This ESM-only package requires Node.js `>=24.15`.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Add the plugin to the `plugins` array of your configuration:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
export default {
|
|
26
|
+
plugins: [
|
|
27
|
+
'@reelout/core/analyzer',
|
|
28
|
+
'@reelout/core/builder',
|
|
29
|
+
'@reelout/core/changelog',
|
|
30
|
+
'@reelout/npm',
|
|
31
|
+
'@reelout/yarn',
|
|
32
|
+
'@reelout/cargo',
|
|
33
|
+
'@reelout/git',
|
|
34
|
+
'@reelout/github',
|
|
35
|
+
'@reelout/gitlab',
|
|
36
|
+
],
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The plugin activates only when Yarn (Classic or Berry) is the active package
|
|
41
|
+
manager of the workspace and stays inactive otherwise, so non-Yarn repositories
|
|
42
|
+
run it without side effects. When it activates, the npm plugin stays inactive
|
|
43
|
+
instead, so packages publish through Yarn. The plugin accepts `workspace`,
|
|
44
|
+
`access`, `provenance`, and `stage` options.
|
|
45
|
+
|
|
46
|
+
Yarn releases authenticate with registry credentials only: an `NPM_TOKEN`
|
|
47
|
+
environment variable, ambient `.npmrc` authentication (Yarn Classic), or
|
|
48
|
+
`.yarnrc.yml` credentials (Yarn Berry). The registry offers no OIDC exchange
|
|
49
|
+
for Yarn, so OIDC identity tokens are not used.
|
|
50
|
+
|
|
51
|
+
The `stage` option controls staged publishing: `true` stages every package
|
|
52
|
+
for later approval instead of publishing it immediately, `false` publishes
|
|
53
|
+
directly and fails when the registry requires staging, and the default
|
|
54
|
+
publishes directly but falls back to staging a package when the registry
|
|
55
|
+
rejects its direct publish with `E_STAGE_REQUIRED`. The fallback runs per
|
|
56
|
+
package and only for the public npm registry; when packages were staged, the
|
|
57
|
+
run ends with a warning that lists them alongside the `yarn npm stage list`
|
|
58
|
+
and `yarn npm stage approve <stage-id>` commands. Approving a staged
|
|
59
|
+
publication requires an interactive 2FA prompt, so it stays a manual step.
|
|
60
|
+
Yarn Classic cannot stage and fails when staging is requested.
|
|
61
|
+
|
|
62
|
+
By default, the plugin enables provenance only when `package.json` defines a
|
|
63
|
+
valid `repository` that matches the current Git remote and the repository is
|
|
64
|
+
public. Provenance attestations require Yarn Berry; Yarn Classic publishes
|
|
65
|
+
without them.
|
|
66
|
+
|
|
67
|
+
Before publishing, the plugin verifies that the registry credentials grant
|
|
68
|
+
publish permission for each scheduled package. It checks existing packages
|
|
69
|
+
against their maintainers, new scoped packages against the user or
|
|
70
|
+
organization owning the scope, and remaining scoped packages through npm
|
|
71
|
+
collaborator and team permissions. A missing permission fails the release
|
|
72
|
+
before anything is published; inconclusive checks only warn.
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
The package exposes a thin surface: the `yarn` plugin (default export)
|
|
77
|
+
configured through `PluginOptions`, plus the `PLUGIN_NAME` constant
|
|
78
|
+
(`@reelout/yarn`). Workspace resolution, probing, and publishing utilities
|
|
79
|
+
live in [`@reelout/npm`](https://www.npmjs.com/package/@reelout/npm), which
|
|
80
|
+
this plugin shares with the npm plugin.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [Getting started](https://github.com/reelout/reelout/blob/main/docs/01-getting-started.md)
|
|
85
|
+
- [Configuration](https://github.com/reelout/reelout/blob/main/docs/02-config.md)
|
|
86
|
+
- [API reference](https://reelout.overview.vercel.app/)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { filterPackages, formatError, normalizeWorkspace, sortPackages } from "@reelout/core";
|
|
2
|
+
import { bumpPackageDependencies, hasPackageManifest, inspectPackageManager, isCompleteReleasePlan, loadPackages, probeReleasePlan, publishPlans, resolveGitRepositoryFromPackage, resolveProvenance, resolveWorkspaceMembers, verifyAuth, verifyPublishAccess } from "@reelout/npm";
|
|
3
|
+
import { colors } from "consola/utils";
|
|
4
|
+
// package.json
|
|
5
|
+
var version = "0.0.0";
|
|
6
|
+
// src/PLUGIN_NAME.ts
|
|
7
|
+
var PLUGIN_NAME = "@reelout/yarn";
|
|
8
|
+
// src/yarn.ts
|
|
9
|
+
/**
|
|
10
|
+
* Built-in plugin that discovers Yarn workspace packages, updates package manifests, and publishes packages with Yarn Classic or Yarn Berry.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* **Lifecycle Stages:**
|
|
14
|
+
* - `configure`: Leaves the plugin inactive when the working directory holds
|
|
15
|
+
* no root `package.json` or the workspace is not managed by Yarn.
|
|
16
|
+
* Otherwise resolves and attaches Git repository metadata from root
|
|
17
|
+
* package configuration, then verifies registry authentication,
|
|
18
|
+
* failing in strict mode or skipping the publish phase when no
|
|
19
|
+
* credentials exist.
|
|
20
|
+
* - `discover`: Skips discovery when the plugin is inactive. Discovers
|
|
21
|
+
* workspace member packages, filters them against the `filter` patterns,
|
|
22
|
+
* and loads package metadata into context.
|
|
23
|
+
* - `write`: Skips manifest updates when the plugin is inactive. Bumps
|
|
24
|
+
* internal workspace dependency versions in `package.json` files (skipped
|
|
25
|
+
* in dry-run).
|
|
26
|
+
* - `publish`: Verifies each publishable package's publish permission
|
|
27
|
+
* against its resolved registry, failing when access is definitively
|
|
28
|
+
* missing and warning when it cannot be confirmed. Then authenticates
|
|
29
|
+
* and probes each publishable package version before publishing,
|
|
30
|
+
* skipping versions the registry already holds with identical content
|
|
31
|
+
* (syncing their dist-tags) and failing on different or unverifiable
|
|
32
|
+
* content. Publishes non-private packages with Yarn, enabling provenance
|
|
33
|
+
* when the manifest repository is valid, matches the context repository,
|
|
34
|
+
* and is public. Falls back to staged publishing when the registry
|
|
35
|
+
* rejects a direct publish with a staged-publishing requirement and the
|
|
36
|
+
* `stage` option does not disable the fallback, summarizing the staged
|
|
37
|
+
* publications at the end. Skips entirely when no Yarn workspace was
|
|
38
|
+
* found, another package manager is active, or configure-stage
|
|
39
|
+
* verification found no registry authentication.
|
|
40
|
+
*
|
|
41
|
+
* @param options Configuration options for Yarn workspace discovery and publishing behavior.
|
|
42
|
+
* @returns A release plugin configured for Yarn workspace management and package publication.
|
|
43
|
+
*/
|
|
44
|
+
var yarn = (options = {}) => {
|
|
45
|
+
let inactive = false;
|
|
46
|
+
let publishSkipped = false;
|
|
47
|
+
return {
|
|
48
|
+
name: PLUGIN_NAME,
|
|
49
|
+
version,
|
|
50
|
+
configure: async (context, next) => {
|
|
51
|
+
if (!await hasPackageManifest(context.cwd)) {
|
|
52
|
+
context.logger.debug(`Yarn workspace could not be found at "${context.cwd}".`);
|
|
53
|
+
return next(context);
|
|
54
|
+
}
|
|
55
|
+
const packageManager = await inspectPackageManager(context.cwd, { env: context.env });
|
|
56
|
+
if (!packageManager.isYarn) {
|
|
57
|
+
inactive = true;
|
|
58
|
+
context.logger.debug(`Yarn plugin is inactive: "${packageManager.name}" is the active package manager.`);
|
|
59
|
+
return next(context);
|
|
60
|
+
}
|
|
61
|
+
context.repository = await resolveGitRepositoryFromPackage(context.cwd) ?? context.repository;
|
|
62
|
+
if (await verifyAuth(context, packageManager) === "none") {
|
|
63
|
+
if (context.strict) throw new Error("NPM_TOKEN is required for Yarn authentication in strict mode.");
|
|
64
|
+
publishSkipped = true;
|
|
65
|
+
context.logger.warn(colors.yellow("Packages will not be published: NPM_TOKEN is required for Yarn authentication."));
|
|
66
|
+
}
|
|
67
|
+
return next(context);
|
|
68
|
+
},
|
|
69
|
+
discover: async (context, next) => {
|
|
70
|
+
if (inactive || !await hasPackageManifest(context.cwd)) return next(context);
|
|
71
|
+
const packages = [];
|
|
72
|
+
const workspace = normalizeWorkspace(context.cwd, options.workspace);
|
|
73
|
+
workspace.members ??= await resolveWorkspaceMembers(context.cwd);
|
|
74
|
+
for (const result of await loadPackages(context.cwd, workspace)) if (result.status === "fulfilled") packages.push({
|
|
75
|
+
...result.value,
|
|
76
|
+
provider: PLUGIN_NAME
|
|
77
|
+
});
|
|
78
|
+
else context.logger.warn(colors.yellow(`Package could not be loaded: ${formatError(result.reason)}`));
|
|
79
|
+
context.packages = sortPackages(filterPackages(context.packages.concat(packages), context.filter));
|
|
80
|
+
return next(context);
|
|
81
|
+
},
|
|
82
|
+
write: async (context, next) => {
|
|
83
|
+
if (inactive || !await hasPackageManifest(context.cwd)) return next(context);
|
|
84
|
+
if (context.dryRun) context.logger.debug("[DRY RUN] Package files will not be updated.");
|
|
85
|
+
else await bumpPackageDependencies(context.cwd, context.plans.filter((plan) => plan.package.provider === PLUGIN_NAME));
|
|
86
|
+
return next(context);
|
|
87
|
+
},
|
|
88
|
+
publish: async (context, next) => {
|
|
89
|
+
if (inactive) {
|
|
90
|
+
context.logger.debug("Yarn plugin is inactive: another package manager is active.");
|
|
91
|
+
return next(context);
|
|
92
|
+
}
|
|
93
|
+
if (!await hasPackageManifest(context.cwd)) {
|
|
94
|
+
context.logger.debug("Yarn publishing was skipped: no Yarn workspace was found.");
|
|
95
|
+
return next(context);
|
|
96
|
+
}
|
|
97
|
+
if (publishSkipped) {
|
|
98
|
+
context.logger.debug("Yarn publishing was skipped: no registry authentication was found.");
|
|
99
|
+
return next(context);
|
|
100
|
+
}
|
|
101
|
+
const provenance = await resolveProvenance(context, options.provenance);
|
|
102
|
+
const publishable = context.plans.filter((plan) => isCompleteReleasePlan(plan, PLUGIN_NAME));
|
|
103
|
+
const packageManager = publishable.length > 0 ? await inspectPackageManager(context.cwd, { env: context.env }) : void 0;
|
|
104
|
+
const skipped = /* @__PURE__ */ new Set();
|
|
105
|
+
if (packageManager) {
|
|
106
|
+
await verifyPublishAccess(context, publishable, packageManager, PLUGIN_NAME);
|
|
107
|
+
for (const plan of publishable) await probeReleasePlan(context, plan, packageManager, skipped);
|
|
108
|
+
}
|
|
109
|
+
const publishOptions = {
|
|
110
|
+
dryRun: context.dryRun,
|
|
111
|
+
tag: context.releaseChannel,
|
|
112
|
+
access: options.access,
|
|
113
|
+
provenance,
|
|
114
|
+
stage: options.stage
|
|
115
|
+
};
|
|
116
|
+
const staged = await publishPlans(context, PLUGIN_NAME, packageManager, publishOptions, skipped);
|
|
117
|
+
if (packageManager !== void 0 && staged.length > 0) {
|
|
118
|
+
const targets = staged.map((plan) => `"${plan.package.name}@${plan.release.version}"`).join(", ");
|
|
119
|
+
context.logger.warn(colors.yellow(`Packages were staged instead of published: ${targets}. Review the staged publications with "yarn npm stage list" and finish the release with "yarn npm stage approve <stage-id>".`));
|
|
120
|
+
}
|
|
121
|
+
return next(context);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export { PLUGIN_NAME, yarn as default };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/PLUGIN_NAME.ts","../src/yarn.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nexport const PLUGIN_NAME = '@reelout/yarn'\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n filterPackages,\n formatError,\n normalizeWorkspace,\n sortPackages,\n type Package,\n type ReleasePlan,\n type ReleasePlugin,\n type Workspace,\n} from '@reelout/core'\nimport {\n bumpPackageDependencies,\n hasPackageManifest,\n inspectPackageManager,\n isCompleteReleasePlan,\n loadPackages,\n probeReleasePlan,\n publishPlans,\n resolveGitRepositoryFromPackage,\n resolveProvenance,\n resolveWorkspaceMembers,\n verifyAuth,\n verifyPublishAccess,\n type PublishAccess,\n type PublishPackageOptions,\n} from '@reelout/npm'\nimport { colors } from 'consola/utils'\nimport { version } from '../package.json'\nimport { PLUGIN_NAME } from './PLUGIN_NAME'\n\nexport { PLUGIN_NAME }\n\nexport interface PluginOptions {\n workspace?: Partial<Workspace>\n access?: PublishAccess | null | undefined\n provenance?: boolean | undefined\n stage?: boolean | undefined\n}\n\n/**\n * Built-in plugin that discovers Yarn workspace packages, updates package manifests, and publishes packages with Yarn Classic or Yarn Berry.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `configure`: Leaves the plugin inactive when the working directory holds\n * no root `package.json` or the workspace is not managed by Yarn.\n * Otherwise resolves and attaches Git repository metadata from root\n * package configuration, then verifies registry authentication,\n * failing in strict mode or skipping the publish phase when no\n * credentials exist.\n * - `discover`: Skips discovery when the plugin is inactive. Discovers\n * workspace member packages, filters them against the `filter` patterns,\n * and loads package metadata into context.\n * - `write`: Skips manifest updates when the plugin is inactive. Bumps\n * internal workspace dependency versions in `package.json` files (skipped\n * in dry-run).\n * - `publish`: Verifies each publishable package's publish permission\n * against its resolved registry, failing when access is definitively\n * missing and warning when it cannot be confirmed. Then authenticates\n * and probes each publishable package version before publishing,\n * skipping versions the registry already holds with identical content\n * (syncing their dist-tags) and failing on different or unverifiable\n * content. Publishes non-private packages with Yarn, enabling provenance\n * when the manifest repository is valid, matches the context repository,\n * and is public. Falls back to staged publishing when the registry\n * rejects a direct publish with a staged-publishing requirement and the\n * `stage` option does not disable the fallback, summarizing the staged\n * publications at the end. Skips entirely when no Yarn workspace was\n * found, another package manager is active, or configure-stage\n * verification found no registry authentication.\n *\n * @param options Configuration options for Yarn workspace discovery and publishing behavior.\n * @returns A release plugin configured for Yarn workspace management and package publication.\n */\nconst yarn = (options: PluginOptions = {}): ReleasePlugin => {\n let inactive = false\n\n let publishSkipped = false\n\n return {\n name: PLUGIN_NAME,\n version,\n configure: async (context, next) => {\n if (!(await hasPackageManifest(context.cwd))) {\n context.logger.debug(\n `Yarn workspace could not be found at \"${context.cwd}\".`\n )\n\n return next(context)\n }\n\n const packageManager = await inspectPackageManager(context.cwd, {\n env: context.env,\n })\n\n if (!packageManager.isYarn) {\n inactive = true\n\n context.logger.debug(\n `Yarn plugin is inactive: \"${packageManager.name}\" is the active package manager.`\n )\n\n return next(context)\n }\n\n const repo = await resolveGitRepositoryFromPackage(context.cwd)\n context.repository = repo ?? context.repository\n\n const authKind = await verifyAuth(context, packageManager)\n\n if (authKind === 'none') {\n if (context.strict) {\n throw new Error(\n 'NPM_TOKEN is required for Yarn authentication in strict mode.'\n )\n }\n\n publishSkipped = true\n\n context.logger.warn(\n colors.yellow(\n 'Packages will not be published: NPM_TOKEN is required for Yarn authentication.'\n )\n )\n }\n\n return next(context)\n },\n discover: async (context, next) => {\n if (inactive || !(await hasPackageManifest(context.cwd))) {\n return next(context)\n }\n\n const packages: Package[] = []\n\n const workspace = normalizeWorkspace(context.cwd, options.workspace)\n\n workspace.members ??= await resolveWorkspaceMembers(context.cwd)\n\n for (const result of await loadPackages(context.cwd, workspace)) {\n if (result.status === 'fulfilled') {\n packages.push({\n ...result.value,\n provider: PLUGIN_NAME,\n })\n } else {\n context.logger.warn(\n colors.yellow(\n `Package could not be loaded: ${formatError(result.reason)}`\n )\n )\n }\n }\n\n context.packages = sortPackages(\n filterPackages(context.packages.concat(packages), context.filter)\n )\n\n return next(context)\n },\n write: async (context, next) => {\n if (inactive || !(await hasPackageManifest(context.cwd))) {\n return next(context)\n }\n\n if (context.dryRun) {\n context.logger.debug('[DRY RUN] Package files will not be updated.')\n } else {\n await bumpPackageDependencies(\n context.cwd,\n context.plans.filter((plan) => plan.package.provider === PLUGIN_NAME)\n )\n }\n\n return next(context)\n },\n publish: async (context, next) => {\n if (inactive) {\n context.logger.debug(\n 'Yarn plugin is inactive: another package manager is active.'\n )\n\n return next(context)\n }\n\n if (!(await hasPackageManifest(context.cwd))) {\n context.logger.debug(\n 'Yarn publishing was skipped: no Yarn workspace was found.'\n )\n\n return next(context)\n }\n\n if (publishSkipped) {\n context.logger.debug(\n 'Yarn publishing was skipped: no registry authentication was found.'\n )\n\n return next(context)\n }\n\n const provenance = await resolveProvenance(context, options.provenance)\n\n const publishable = context.plans.filter((plan) =>\n isCompleteReleasePlan(plan, PLUGIN_NAME)\n )\n\n const packageManager =\n publishable.length > 0\n ? await inspectPackageManager(context.cwd, { env: context.env })\n : undefined\n\n const skipped = new Set<ReleasePlan>()\n\n if (packageManager) {\n await verifyPublishAccess(\n context,\n publishable,\n packageManager,\n PLUGIN_NAME\n )\n\n for (const plan of publishable) {\n await probeReleasePlan(context, plan, packageManager, skipped)\n }\n }\n\n const publishOptions: PublishPackageOptions = {\n dryRun: context.dryRun,\n tag: context.releaseChannel,\n access: options.access,\n provenance,\n stage: options.stage,\n }\n\n const staged = await publishPlans(\n context,\n PLUGIN_NAME,\n packageManager,\n publishOptions,\n skipped\n )\n\n if (packageManager !== undefined && staged.length > 0) {\n const targets = staged\n .map((plan) => `\"${plan.package.name}@${plan.release.version}\"`)\n .join(', ')\n\n context.logger.warn(\n colors.yellow(\n `Packages were staged instead of published: ${targets}. Review the staged publications with \"yarn npm stage list\" and finish the release with \"yarn npm stage approve <stage-id>\".`\n )\n )\n }\n\n return next(context)\n },\n }\n}\n\nexport default yarn\n"],"mappings":";;;;;;AAGA,IAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0E3B,IAAM,QAAQ,UAAyB,CAAC,MAAqB;CAC3D,IAAI,WAAW;CAEf,IAAI,iBAAiB;CAErB,OAAO;EACL,MAAM;EACN;EACA,WAAW,OAAO,SAAS,SAAS;GAClC,IAAI,CAAE,MAAM,mBAAmB,QAAQ,GAAG,GAAI;IAC5C,QAAQ,OAAO,MACb,yCAAyC,QAAQ,IAAI,GACvD;IAEA,OAAO,KAAK,OAAO;GACrB;GAEA,MA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-1,7 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reelout/yarn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Yarn plugin for discovering workspaces, updating manifests and dependency ranges, and publishing packages with Yarn Classic and Yarn Berry.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/reelout/reelout.git",
|
|
8
|
+
"directory": "packages/yarn"
|
|
9
|
+
},
|
|
4
10
|
"license": "MIT",
|
|
5
11
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
12
|
+
"imports": {},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": {
|
|
15
|
+
"default": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
".": {
|
|
18
|
+
"module": "./src/index.ts",
|
|
19
|
+
"development": "./src/index.ts",
|
|
20
|
+
"types": "./src/index.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./*": {
|
|
24
|
+
"module": "./src/*.ts",
|
|
25
|
+
"development": "./src/*.ts",
|
|
26
|
+
"types": "./src/*.ts",
|
|
27
|
+
"default": "./dist/*.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"./dist",
|
|
32
|
+
"./src"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@reelout/core": "^0.13.0",
|
|
36
|
+
"@reelout/github": "^0.8.0",
|
|
37
|
+
"@reelout/npm": "^0.14.0",
|
|
38
|
+
"consola": "^3.4.2"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=24.15"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "vite build --ssr --sourcemap",
|
|
45
|
+
"dev": "vite build --ssr --watch"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/index.ts
ADDED
package/src/yarn.ts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
filterPackages,
|
|
6
|
+
formatError,
|
|
7
|
+
normalizeWorkspace,
|
|
8
|
+
sortPackages,
|
|
9
|
+
type Package,
|
|
10
|
+
type ReleasePlan,
|
|
11
|
+
type ReleasePlugin,
|
|
12
|
+
type Workspace,
|
|
13
|
+
} from '@reelout/core'
|
|
14
|
+
import {
|
|
15
|
+
bumpPackageDependencies,
|
|
16
|
+
hasPackageManifest,
|
|
17
|
+
inspectPackageManager,
|
|
18
|
+
isCompleteReleasePlan,
|
|
19
|
+
loadPackages,
|
|
20
|
+
probeReleasePlan,
|
|
21
|
+
publishPlans,
|
|
22
|
+
resolveGitRepositoryFromPackage,
|
|
23
|
+
resolveProvenance,
|
|
24
|
+
resolveWorkspaceMembers,
|
|
25
|
+
verifyAuth,
|
|
26
|
+
verifyPublishAccess,
|
|
27
|
+
type PublishAccess,
|
|
28
|
+
type PublishPackageOptions,
|
|
29
|
+
} from '@reelout/npm'
|
|
30
|
+
import { colors } from 'consola/utils'
|
|
31
|
+
import { version } from '../package.json'
|
|
32
|
+
import { PLUGIN_NAME } from './PLUGIN_NAME'
|
|
33
|
+
|
|
34
|
+
export { PLUGIN_NAME }
|
|
35
|
+
|
|
36
|
+
export interface PluginOptions {
|
|
37
|
+
workspace?: Partial<Workspace>
|
|
38
|
+
access?: PublishAccess | null | undefined
|
|
39
|
+
provenance?: boolean | undefined
|
|
40
|
+
stage?: boolean | undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Built-in plugin that discovers Yarn workspace packages, updates package manifests, and publishes packages with Yarn Classic or Yarn Berry.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* **Lifecycle Stages:**
|
|
48
|
+
* - `configure`: Leaves the plugin inactive when the working directory holds
|
|
49
|
+
* no root `package.json` or the workspace is not managed by Yarn.
|
|
50
|
+
* Otherwise resolves and attaches Git repository metadata from root
|
|
51
|
+
* package configuration, then verifies registry authentication,
|
|
52
|
+
* failing in strict mode or skipping the publish phase when no
|
|
53
|
+
* credentials exist.
|
|
54
|
+
* - `discover`: Skips discovery when the plugin is inactive. Discovers
|
|
55
|
+
* workspace member packages, filters them against the `filter` patterns,
|
|
56
|
+
* and loads package metadata into context.
|
|
57
|
+
* - `write`: Skips manifest updates when the plugin is inactive. Bumps
|
|
58
|
+
* internal workspace dependency versions in `package.json` files (skipped
|
|
59
|
+
* in dry-run).
|
|
60
|
+
* - `publish`: Verifies each publishable package's publish permission
|
|
61
|
+
* against its resolved registry, failing when access is definitively
|
|
62
|
+
* missing and warning when it cannot be confirmed. Then authenticates
|
|
63
|
+
* and probes each publishable package version before publishing,
|
|
64
|
+
* skipping versions the registry already holds with identical content
|
|
65
|
+
* (syncing their dist-tags) and failing on different or unverifiable
|
|
66
|
+
* content. Publishes non-private packages with Yarn, enabling provenance
|
|
67
|
+
* when the manifest repository is valid, matches the context repository,
|
|
68
|
+
* and is public. Falls back to staged publishing when the registry
|
|
69
|
+
* rejects a direct publish with a staged-publishing requirement and the
|
|
70
|
+
* `stage` option does not disable the fallback, summarizing the staged
|
|
71
|
+
* publications at the end. Skips entirely when no Yarn workspace was
|
|
72
|
+
* found, another package manager is active, or configure-stage
|
|
73
|
+
* verification found no registry authentication.
|
|
74
|
+
*
|
|
75
|
+
* @param options Configuration options for Yarn workspace discovery and publishing behavior.
|
|
76
|
+
* @returns A release plugin configured for Yarn workspace management and package publication.
|
|
77
|
+
*/
|
|
78
|
+
const yarn = (options: PluginOptions = {}): ReleasePlugin => {
|
|
79
|
+
let inactive = false
|
|
80
|
+
|
|
81
|
+
let publishSkipped = false
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
name: PLUGIN_NAME,
|
|
85
|
+
version,
|
|
86
|
+
configure: async (context, next) => {
|
|
87
|
+
if (!(await hasPackageManifest(context.cwd))) {
|
|
88
|
+
context.logger.debug(
|
|
89
|
+
`Yarn workspace could not be found at "${context.cwd}".`
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return next(context)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const packageManager = await inspectPackageManager(context.cwd, {
|
|
96
|
+
env: context.env,
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
if (!packageManager.isYarn) {
|
|
100
|
+
inactive = true
|
|
101
|
+
|
|
102
|
+
context.logger.debug(
|
|
103
|
+
`Yarn plugin is inactive: "${packageManager.name}" is the active package manager.`
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return next(context)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const repo = await resolveGitRepositoryFromPackage(context.cwd)
|
|
110
|
+
context.repository = repo ?? context.repository
|
|
111
|
+
|
|
112
|
+
const authKind = await verifyAuth(context, packageManager)
|
|
113
|
+
|
|
114
|
+
if (authKind === 'none') {
|
|
115
|
+
if (context.strict) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
'NPM_TOKEN is required for Yarn authentication in strict mode.'
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
publishSkipped = true
|
|
122
|
+
|
|
123
|
+
context.logger.warn(
|
|
124
|
+
colors.yellow(
|
|
125
|
+
'Packages will not be published: NPM_TOKEN is required for Yarn authentication.'
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return next(context)
|
|
131
|
+
},
|
|
132
|
+
discover: async (context, next) => {
|
|
133
|
+
if (inactive || !(await hasPackageManifest(context.cwd))) {
|
|
134
|
+
return next(context)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const packages: Package[] = []
|
|
138
|
+
|
|
139
|
+
const workspace = normalizeWorkspace(context.cwd, options.workspace)
|
|
140
|
+
|
|
141
|
+
workspace.members ??= await resolveWorkspaceMembers(context.cwd)
|
|
142
|
+
|
|
143
|
+
for (const result of await loadPackages(context.cwd, workspace)) {
|
|
144
|
+
if (result.status === 'fulfilled') {
|
|
145
|
+
packages.push({
|
|
146
|
+
...result.value,
|
|
147
|
+
provider: PLUGIN_NAME,
|
|
148
|
+
})
|
|
149
|
+
} else {
|
|
150
|
+
context.logger.warn(
|
|
151
|
+
colors.yellow(
|
|
152
|
+
`Package could not be loaded: ${formatError(result.reason)}`
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
context.packages = sortPackages(
|
|
159
|
+
filterPackages(context.packages.concat(packages), context.filter)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return next(context)
|
|
163
|
+
},
|
|
164
|
+
write: async (context, next) => {
|
|
165
|
+
if (inactive || !(await hasPackageManifest(context.cwd))) {
|
|
166
|
+
return next(context)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (context.dryRun) {
|
|
170
|
+
context.logger.debug('[DRY RUN] Package files will not be updated.')
|
|
171
|
+
} else {
|
|
172
|
+
await bumpPackageDependencies(
|
|
173
|
+
context.cwd,
|
|
174
|
+
context.plans.filter((plan) => plan.package.provider === PLUGIN_NAME)
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return next(context)
|
|
179
|
+
},
|
|
180
|
+
publish: async (context, next) => {
|
|
181
|
+
if (inactive) {
|
|
182
|
+
context.logger.debug(
|
|
183
|
+
'Yarn plugin is inactive: another package manager is active.'
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
return next(context)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!(await hasPackageManifest(context.cwd))) {
|
|
190
|
+
context.logger.debug(
|
|
191
|
+
'Yarn publishing was skipped: no Yarn workspace was found.'
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return next(context)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (publishSkipped) {
|
|
198
|
+
context.logger.debug(
|
|
199
|
+
'Yarn publishing was skipped: no registry authentication was found.'
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
return next(context)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const provenance = await resolveProvenance(context, options.provenance)
|
|
206
|
+
|
|
207
|
+
const publishable = context.plans.filter((plan) =>
|
|
208
|
+
isCompleteReleasePlan(plan, PLUGIN_NAME)
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
const packageManager =
|
|
212
|
+
publishable.length > 0
|
|
213
|
+
? await inspectPackageManager(context.cwd, { env: context.env })
|
|
214
|
+
: undefined
|
|
215
|
+
|
|
216
|
+
const skipped = new Set<ReleasePlan>()
|
|
217
|
+
|
|
218
|
+
if (packageManager) {
|
|
219
|
+
await verifyPublishAccess(
|
|
220
|
+
context,
|
|
221
|
+
publishable,
|
|
222
|
+
packageManager,
|
|
223
|
+
PLUGIN_NAME
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
for (const plan of publishable) {
|
|
227
|
+
await probeReleasePlan(context, plan, packageManager, skipped)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const publishOptions: PublishPackageOptions = {
|
|
232
|
+
dryRun: context.dryRun,
|
|
233
|
+
tag: context.releaseChannel,
|
|
234
|
+
access: options.access,
|
|
235
|
+
provenance,
|
|
236
|
+
stage: options.stage,
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const staged = await publishPlans(
|
|
240
|
+
context,
|
|
241
|
+
PLUGIN_NAME,
|
|
242
|
+
packageManager,
|
|
243
|
+
publishOptions,
|
|
244
|
+
skipped
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
if (packageManager !== undefined && staged.length > 0) {
|
|
248
|
+
const targets = staged
|
|
249
|
+
.map((plan) => `"${plan.package.name}@${plan.release.version}"`)
|
|
250
|
+
.join(', ')
|
|
251
|
+
|
|
252
|
+
context.logger.warn(
|
|
253
|
+
colors.yellow(
|
|
254
|
+
`Packages were staged instead of published: ${targets}. Review the staged publications with "yarn npm stage list" and finish the release with "yarn npm stage approve <stage-id>".`
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return next(context)
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default yarn
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|