@qlover/fe-release 2.1.5 → 2.1.6

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/README.md CHANGED
@@ -1,122 +1,149 @@
1
1
  # Fe-release
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@qlover/fe-release.svg)](https://www.npmjs.com/package/@qlover/fe-release)
4
- [![license](https://img.shields.io/npm/l/@qlover/fe-release.svg)](https://github.com/your-repo/fe-release/blob/main/LICENSE)
5
-
6
- A professional front-end release automation tool built on top of [@changesets/cli](https://github.com/changesets/changesets), providing enhanced workflows for automated PR management and release processes.
7
-
8
- ## 📚 Table of Contents
9
-
10
- - [Features](#features)
11
- - [Installation](#installation)
12
- - [Quick Start](#quick-start)
13
- - [Usage](#usage)
14
- - [Configuration](#configuration)
15
- - [Workflows](#workflows)
16
- - [Plugin System](#plugin-system)
17
- - [API Reference](#api-reference)
18
- - [Troubleshooting](#troubleshooting)
19
- - [Contributing](#contributing)
20
- - [License](#license)
21
-
22
- ## ✨ Features
23
-
24
- - **Automated Version Management**
25
- - Powered by `@changesets/cli` for reliable version control
26
- - Automatic version bumping based on changes
27
- - Configurable version increment strategies
28
-
29
- - **Flexible Release Workflows**
30
- - Manual release process for direct control
31
- - PR-based automated release workflow (GitHub)
32
- - Customizable release strategies
33
-
34
- - **GitHub Integration**
35
- - Automated PR creation and management
36
- - Smart PR labeling system
37
- - Automated release notes generation
38
- - GitHub Actions integration
39
-
40
- - **Workspace Support**
41
- - First-class monorepo support
42
- - Multi-package release coordination
43
- - Dependency graph awareness
44
- - Selective package publishing
45
-
46
- - **Extensive Configuration**
47
- - Rich CLI options
48
- - Configurable via `fe-config.json`
49
- - Environment variable support
50
- - Plugin system for customization
51
-
52
- ## 🚀 Installation
4
+ [![license](https://img.shields.io/npm/l/@qlover/fe-release.svg)](https://github.com/qlover/fe-release/blob/main/LICENSE)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/qlover/fe-release/pulls)
6
+
7
+ 一个基于 [@changesets/cli](https://github.com/changesets/changesets) 构建的专业前端发布自动化工具,提供增强的工作流程,用于自动化 PR 管理和发布流程。
8
+
9
+ ## 📚 目录
10
+
11
+ - [特性](#特性)
12
+ - [安装](#安装)
13
+ - [快速开始](#快速开始)
14
+ - [使用方法](#使用方法)
15
+ - [配置](#配置)
16
+ - [工作流程](#工作流程)
17
+ - [常见问题](#常见问题)
18
+ - [贡献指南](#贡献指南)
19
+ - [许可证](#许可证)
20
+
21
+ ## ✨ 特性
22
+
23
+ - **自动化版本管理**
24
+
25
+ - 基于 `@changesets/cli` 的可靠版本控制
26
+ - 根据变更自动进行版本更新
27
+ - 可配置的版本递增策略
28
+ - 支持语义化版本(Semantic Versioning)
29
+
30
+ - **灵活的发布工作流**
31
+
32
+ - 手动发布流程,提供直接控制
33
+ - 基于 PR 的自动化发布工作流(GitHub)
34
+ - 可自定义的发布策略
35
+ - 支持多环境发布(开发、测试、生产)
36
+
37
+ - **GitHub 集成**
38
+
39
+ - 自动化 PR 创建和管理
40
+ - 智能 PR 标签系统
41
+ - 自动生成发布说明
42
+ - GitHub Actions 集成
43
+ - 支持自动合并和冲突解决
44
+
45
+ - **工作区支持**
46
+
47
+ - 一流的 monorepo 支持
48
+ - 多包发布协调
49
+ - 依赖图感知
50
+ - 选择性包发布
51
+ - 支持私有包发布
52
+
53
+ - **丰富的配置选项**
54
+ - 丰富的 CLI 选项
55
+ - 通过 `fe-config.json` 配置
56
+ - 环境变量支持
57
+ - 插件系统支持自定义扩展
58
+
59
+ ## 🚀 安装
53
60
 
54
61
  ```bash
55
- # Using npm
56
- npm install @qlover/fe-release
62
+ # 使用 npm
63
+ npm install @qlover/fe-release --save-dev
57
64
 
58
- # Using yarn
59
- yarn add @qlover/fe-release
65
+ # 使用 yarn
66
+ yarn add @qlover/fe-release --dev
60
67
 
61
- # Using pnpm
62
- pnpm add @qlover/fe-release
68
+ # 使用 pnpm
69
+ pnpm add @qlover/fe-release -D
63
70
  ```
64
71
 
65
- ## 🏃 Quick Start
72
+ ## 🏃 快速开始
73
+
74
+ 1. **基础发布**
66
75
 
67
- 1. **Basic Release**
68
76
  ```bash
69
- # Create a release PR
77
+ # 创建发布 PR
70
78
  fe-release -P
71
79
 
72
- # Perform a dry run
80
+ # 预览发布(不实际执行)
73
81
  fe-release --dry-run
82
+
83
+ # 指定版本类型发布
84
+ fe-release --changelog.increment=major
74
85
  ```
75
86
 
76
- 2. **Workspace Release**
87
+ 2. **工作区发布**
88
+
77
89
  ```bash
78
- # Release multiple packages
90
+ # 发布多个包
79
91
  fe-release --workspaces.change-labels=pkg1,pkg2 -P
92
+
93
+ # 指定发布目录
94
+ fe-release --publish-path=packages/core
80
95
  ```
81
96
 
82
- ## 💻 Usage
97
+ 3. **环境发布**
98
+
99
+ ```bash
100
+ # 发布到测试环境
101
+ fe-release --env=test -P
102
+
103
+ # 发布到生产环境
104
+ fe-release --env=prod -P
105
+ ```
83
106
 
84
- ### Command Line Interface
107
+ ## 💻 使用方法
108
+
109
+ ### 命令行接口
85
110
 
86
111
  ```bash
87
112
  fe-release [options]
88
113
  ```
89
114
 
90
- #### Core Options
115
+ #### 核心选项
91
116
 
92
- | Option | Description | Default |
93
- |--------|-------------|---------|
94
- | `-v, --version` | Output version | - |
95
- | `-d, --dry-run` | Preview without making changes | `false` |
96
- | `-V, --verbose` | Show detailed logs | `false` |
97
- | `-p, --publish-path` | Package publish path | - |
98
- | `-P, --githubPR.release-PR` | Create release PR | `false` |
117
+ | 选项 | 描述 | 默认值 |
118
+ | --------------------------- | ------------------------ | ------- |
119
+ | `-v, --version` | 显示版本号 | - |
120
+ | `-d, --dry-run` | 预览模式,不实际执行更改 | `false` |
121
+ | `-V, --verbose` | 显示详细日志 | `false` |
122
+ | `-p, --publish-path` | 包发布路径 | - |
123
+ | `-P, --githubPR.release-PR` | 创建发布 PR | `false` |
124
+ | `--env` | 发布环境 | `prod` |
99
125
 
100
- #### Advanced Options
126
+ #### 高级选项
101
127
 
102
- | Option | Description | Default |
103
- |--------|-------------|---------|
104
- | `-b, --branch-name` | Release branch template | `release-${pkgName}-${tagName}` |
105
- | `-s, --source-branch` | Source branch | `master` |
106
- | `-i, --changelog.increment` | Version increment type | `patch` |
107
- | `--changelog.skip` | Skip changelog generation | `false` |
108
- | `--packages-directories` | Changed package directories | - |
109
- | `-l, --workspaces.change-labels` | Change labels | - |
128
+ | 选项 | 描述 | 默认值 |
129
+ | -------------------------------- | ---------------- | ------------------------------- |
130
+ | `-b, --branch-name` | 发布分支模板 | `release-${pkgName}-${tagName}` |
131
+ | `-s, --source-branch` | 源分支 | `master` |
132
+ | `-i, --changelog.increment` | 版本递增类型 | `patch` |
133
+ | `--changelog.skip` | 跳过更新日志生成 | `false` |
134
+ | `--packages-directories` | 变更包目录 | - |
135
+ | `-l, --workspaces.change-labels` | 变更标签 | - |
110
136
 
111
- ## ⚙️ Configuration
137
+ ## ⚙️ 配置
112
138
 
113
- ### Environment Variables
139
+ ### 环境变量
114
140
 
115
- | Variable | Description | Default |
116
- |----------|-------------|---------|
117
- | `FE_RELEASE` | Enable/disable release | `true` |
118
- | `FE_RELEASE_BRANCH` | Source branch | - |
119
- | `FE_RELEASE_ENV` | Release environment | - |
141
+ | 变量 | 描述 | 默认值 |
142
+ | ------------------- | ------------- | ------ |
143
+ | `FE_RELEASE` | 启用/禁用发布 | `true` |
144
+ | `FE_RELEASE_BRANCH` | 源分支 | - |
145
+ | `FE_RELEASE_ENV` | 发布环境 | - |
146
+ | `FE_RELEASE_TOKEN` | GitHub Token | - |
120
147
 
121
148
  ### fe-config.json
122
149
 
@@ -128,109 +155,123 @@ fe-release [options]
128
155
  "autoMergeType": "squash",
129
156
  "branchName": "release-${pkgName}-${tagName}",
130
157
  "PRTitle": "[${pkgName} Release] Branch:${branch}, Tag:${tagName}, Env:${env}",
158
+ "PRBody": "This PR includes version bump to ${tagName}",
131
159
  "packagesDirectories": ["packages/*"],
132
- "maxWorkspace": 3,
133
- "multiWorkspaceSeparator": "_",
134
- "workspaceVersionSeparator": "@"
160
+ "githubPR": {
161
+ "commitArgs": ["--no-verify"],
162
+ "pushChangedLabels": true,
163
+ "releaseName": "Release ${name} v${version}",
164
+ "commitMessage": "chore(tag): ${name} v${version}"
165
+ },
166
+ "changelog": {
167
+ "gitChangelogOptions": {
168
+ "types": [
169
+ { "type": "feat", "section": "#### ✨ Features", "hidden": false },
170
+ { "type": "fix", "section": "#### 🐞 Bug Fixes", "hidden": false },
171
+ { "type": "chore", "section": "#### 🔧 Chores", "hidden": true },
172
+ {
173
+ "type": "docs",
174
+ "section": "#### 📝 Documentation",
175
+ "hidden": false
176
+ },
177
+ {
178
+ "type": "refactor",
179
+ "section": "#### ♻️ Refactors",
180
+ "hidden": false
181
+ },
182
+ { "type": "perf", "section": "#### 🚀 Performance", "hidden": false },
183
+ { "type": "test", "section": "#### 🚨 Tests", "hidden": true },
184
+ { "type": "style", "section": "#### 🎨 Styles", "hidden": true },
185
+ { "type": "ci", "section": "#### 🔄 CI", "hidden": true },
186
+ { "type": "build", "section": "#### 🚧 Build", "hidden": false },
187
+ { "type": "revert", "section": "#### ⏪ Reverts", "hidden": true },
188
+ { "type": "release", "section": "#### 🔖 Releases", "hidden": true }
189
+ ]
190
+ }
191
+ }
135
192
  }
136
193
  }
137
194
  ```
138
195
 
139
- #### Configuration Options
140
-
141
- | Option | Description | Default |
142
- |--------|-------------|---------|
143
- | `publishPath` | Package publish directory | - |
144
- | `autoMergeReleasePR` | Auto-merge release PRs | `false` |
145
- | `autoMergeType` | Merge strategy | `squash` |
146
- | `branchName` | Branch name template | `release-${pkgName}-${tagName}` |
147
- | `PRTitle` | PR title template | See above |
148
- | `maxWorkspace` | Max workspaces per release | `3` |
196
+ ## 🔄 工作流程
149
197
 
150
- ## 🔄 Workflows
151
-
152
- ### Manual Release Flow
198
+ ### 手动发布流程
153
199
 
154
200
  ```mermaid
155
201
  graph LR
156
- A[Code Changes] --> B[Run fe-release]
157
- B --> C[Version Update]
158
- C --> D[Changelog Gen]
159
- D --> E[Git Tag]
160
- E --> F[NPM Publish]
161
- F --> G[GitHub Release]
202
+ A[代码变更] --> B[运行 fe-release]
203
+ B --> C[版本更新]
204
+ C --> D[生成更新日志]
205
+ D --> E[创建 Git 标签]
206
+ E --> F[发布到 NPM]
207
+ F --> G[创建 GitHub Release]
162
208
  ```
163
209
 
164
- ### PR-based Release Flow (GitHub)
210
+ ### PR 发布流程(GitHub
165
211
 
166
212
  ```mermaid
167
213
  graph LR
168
- A[PR Created] --> B[Auto Label]
169
- B --> C[Release PR]
170
- C --> D[Version + Changelog]
171
- D --> E[CI Release]
172
- E --> F[Publish + Tag]
214
+ A[创建 PR] --> B[自动添加标签]
215
+ B --> C[创建发布 PR]
216
+ C --> D[更新版本和日志]
217
+ D --> E[CI 发布]
218
+ E --> F[发布和打标签]
173
219
  ```
174
220
 
175
- ## 🔌 Plugin System
221
+ ## 🔍 常见问题
176
222
 
177
- ### Built-in Plugins
223
+ ### 常见问题
178
224
 
179
- - **GithubPR**: Handles GitHub PR automation
180
- - **Workspaces**: Manages workspace releases
181
- - **Changelog**: Generates changelogs
225
+ 1. **发布被跳过**
182
226
 
183
- ### Custom Plugin Example
227
+ ```bash
228
+ Error: Skip Release
229
+ ```
184
230
 
185
- ```typescript
186
- import { Plugin } from '@qlover/fe-release';
231
+ 解决方案:
187
232
 
188
- class CustomPlugin extends Plugin {
189
- async apply(context) {
190
- // Plugin logic
191
- }
192
- }
193
- ```
233
+ - 检查 `FE_RELEASE` 环境变量
234
+ - 确认是否有需要发布的变更
235
+ - 验证包版本是否需要更新
194
236
 
195
- ## 🔍 Troubleshooting
237
+ 2. **PR 创建失败**
196
238
 
197
- ### Common Issues
239
+ - 验证 GitHub token 权限
240
+ - 检查仓库访问权限
241
+ - 确认分支是否存在
242
+ - 检查 PR 标题格式
198
243
 
199
- 1. **Release Skipped**
200
- ```bash
201
- Error: Skip Release
202
- ```
203
- Solution: Check `FE_RELEASE` environment variable
244
+ 3. **发布失败**
245
+ - 确认 npm 登录状态
246
+ - 检查包名是否重复
247
+ - 验证版本号是否合法
248
+ - 检查网络连接
204
249
 
205
- 2. **PR Creation Failed**
206
- - Verify GitHub token permissions
207
- - Check repository access
208
- - Validate branch existence
250
+ ### 调试模式
209
251
 
210
- ### Debug Mode
252
+ 启用详细日志:
211
253
 
212
- Enable verbose logging:
213
254
  ```bash
214
255
  fe-release -V
215
256
  ```
216
257
 
217
- ## 🤝 Contributing
258
+ ## 🤝 贡献指南
218
259
 
219
- 1. Fork the repository
220
- 2. Create your feature branch
221
- 3. Commit your changes
222
- 4. Push to the branch
223
- 5. Create a Pull Request
260
+ 1. Fork 本仓库
261
+ 2. 创建特性分支
262
+ 3. 提交变更
263
+ 4. 推送到分支
264
+ 5. 创建 Pull Request
224
265
 
225
- ## 📄 License
266
+ ## 📄 许可证
226
267
 
227
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
268
+ 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
228
269
 
229
- ## 🙏 Acknowledgments
270
+ ## 🙏 致谢
230
271
 
231
- - [@changesets/cli](https://github.com/changesets/changesets) team
232
- - All contributors to this project
272
+ - [@changesets/cli](https://github.com/changesets/changesets) 团队
273
+ - 所有项目贡献者
233
274
 
234
275
  ---
235
276
 
236
- For more information, please visit our [documentation](https://your-docs-url.com).
277
+ 更多信息,请访问我们的[文档](https://qlover.github.io/fe-release)
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- "use strict";var e=require("commander"),r=require("semver"),o=require("./index.cjs");require("@qlover/scripts-context"),require("@qlover/env-loader"),require("@qlover/fe-corekit"),require("@octokit/rest"),require("node:path"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...i}=function(){const a=new e.Command;return a.version("2.1.5","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!t.includes(e)&&!r.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${t.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",n).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",n),a.parse(),o.reduceOptions(a.opts(),"shared")}(),{dryRun:s,verbose:h,...c}=a,p=Object.assign(i,{});await new o.ReleaseTask({dryRun:s,verbose:h,options:p,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
2
+ "use strict";var e=require("commander"),r=require("semver"),o=require("./index.cjs");require("@qlover/scripts-context"),require("@qlover/env-loader"),require("@qlover/fe-corekit"),require("@octokit/rest"),require("node:path"),require("find-workspaces"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("2.1.6","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!t.includes(e)&&!r.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${t.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",n).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",n),i.parse(),o.reduceOptions(i.opts(),"shared")}(),{dryRun:s,verbose:h,...c}=i,p=Object.assign(a,{});await new o.ReleaseTask({dryRun:s,verbose:h,options:p,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"fs";import"path";import"node:module";import"node:url";import"p-limit";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.1.5","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!n.includes(e)&&!o.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${n.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",i).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",i),t.parse(),r(t.opts(),"shared")}(),{dryRun:h,verbose:p,...c}=a,l=Object.assign(s,{});await new t({dryRun:h,verbose:p,options:l,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
2
+ import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"find-workspaces";import"fs";import"path";import"node:module";import"node:url";import"p-limit";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.1.6","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!n.includes(e)&&!o.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${n.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",i).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",i),t.parse(),r(t.opts(),"shared")}(),{dryRun:h,verbose:p,...c}=a,l=Object.assign(s,{});await new t({dryRun:h,verbose:p,options:l,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t,e,r,n,o,i,s,a,c,u,h,l,g,f,p,m,d,y,b,v,w,R,x,k,_,P,C,$,N,j,E,T,B,O,S,A,L,U,F,W,M,G,H,I,D,q,z,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,bt,vt,wt,Rt,xt,kt,_t,Pt,Ct,$t,Nt,jt,Et,Tt,Bt,Ot,St,At,Lt,Ut,Ft,Wt,Mt,Gt,Ht,It,Dt=require("@qlover/scripts-context"),qt=require("@qlover/env-loader"),zt=require("@qlover/fe-corekit"),Vt=require("@octokit/rest"),Jt=require("node:path"),Yt=require("fs"),Kt=require("path"),Qt=require("node:module"),Xt=require("node:url"),Zt=require("p-limit"),te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ee(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function re(){if(e)return t;return e=1,t=function(){this.__data__=[],this.size=0}}function ne(){if(n)return r;return n=1,r=function(t,e){return t===e||t!=t&&e!=e}}function oe(){if(i)return o;i=1;var t=ne();return o=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ie(){if(a)return s;a=1;var t=oe(),e=Array.prototype.splice;return s=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function se(){if(u)return c;u=1;var t=oe();return c=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ae(){if(l)return h;l=1;var t=oe();return h=function(e){return t(this.__data__,e)>-1}}function ce(){if(f)return g;f=1;var t=oe();return g=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this}}function ue(){if(m)return p;m=1;var t=re(),e=ie(),r=se(),n=ae(),o=ce();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,p=i}function he(){if(y)return d;y=1;var t=ue();return d=function(){this.__data__=new t,this.size=0}}function le(){if(v)return b;return v=1,b=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function ge(){if(R)return w;return R=1,w=function(t){return this.__data__.get(t)}}function fe(){if(k)return x;return k=1,x=function(t){return this.__data__.has(t)}}function pe(){if(P)return _;P=1;var t="object"==typeof te&&te&&te.Object===Object&&te;return _=t}function me(){if($)return C;$=1;var t=pe(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return C=r}function de(){if(j)return N;j=1;var t=me().Symbol;return N=t}function ye(){if(T)return E;T=1;var t=de(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return E=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}function be(){if(O)return B;O=1;var t=Object.prototype.toString;return B=function(e){return t.call(e)}}function ve(){if(A)return S;A=1;var t=de(),e=ye(),r=be(),n=t?t.toStringTag:void 0;return S=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function we(){if(U)return L;return U=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Re(){if(W)return F;W=1;var t=ve(),e=we();return F=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function xe(){if(G)return M;G=1;var t=me()["__core-js_shared__"];return M=t}function ke(){if(I)return H;I=1;var t,e=xe(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return H=function(t){return!!r&&r in t}}function _e(){if(q)return D;q=1;var t=Function.prototype.toString;return D=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Pe(){if(V)return z;V=1;var t=Re(),e=ke(),r=we(),n=_e(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return z=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function Ce(){if(Y)return J;return Y=1,J=function(t,e){return null==t?void 0:t[e]}}function $e(){if(Q)return K;Q=1;var t=Pe(),e=Ce();return K=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Ne(){if(Z)return X;Z=1;var t=$e()(me(),"Map");return X=t}function je(){if(et)return tt;et=1;var t=$e()(Object,"create");return tt=t}function Ee(){if(nt)return rt;nt=1;var t=je();return rt=function(){this.__data__=t?t(null):{},this.size=0}}function Te(){if(it)return ot;return it=1,ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Be(){if(at)return st;at=1;var t=je(),e=Object.prototype.hasOwnProperty;return st=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function Oe(){if(ut)return ct;ut=1;var t=je(),e=Object.prototype.hasOwnProperty;return ct=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Se(){if(lt)return ht;lt=1;var t=je();return ht=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Ae(){if(ft)return gt;ft=1;var t=Ee(),e=Te(),r=Be(),n=Oe(),o=Se();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,gt=i}function Le(){if(mt)return pt;mt=1;var t=Ae(),e=ue(),r=Ne();return pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ue(){if(yt)return dt;return yt=1,dt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Fe(){if(vt)return bt;vt=1;var t=Ue();return bt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function We(){if(Rt)return wt;Rt=1;var t=Fe();return wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Me(){if(kt)return xt;kt=1;var t=Fe();return xt=function(e){return t(this,e).get(e)}}function Ge(){if(Pt)return _t;Pt=1;var t=Fe();return _t=function(e){return t(this,e).has(e)}}function He(){if($t)return Ct;$t=1;var t=Fe();return Ct=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}function Ie(){if(jt)return Nt;jt=1;var t=Le(),e=We(),r=Me(),n=Ge(),o=He();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Nt=i}function De(){if(Tt)return Et;Tt=1;var t=ue(),e=Ne(),r=Ie();return Et=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}function qe(){if(Ot)return Bt;Ot=1;var t=ue(),e=he(),r=le(),n=ge(),o=fe(),i=De();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Bt=s}function ze(){if(At)return St;At=1;var t=$e(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return St=e}function Ve(){if(Ut)return Lt;Ut=1;var t=ze();return Lt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Je(){if(Wt)return Ft;Wt=1;var t=Ve(),e=ne();return Ft=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Ye(){if(Gt)return Mt;return Gt=1,Mt=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function Ke(){if(It)return Ht;It=1;var t=Ye()();return Ht=t}var Qe,Xe,Ze,tr,er,rr,nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,br,vr,wr,Rr,xr,kr,_r,Pr,Cr,$r,Nr,jr,Er={exports:{}};function Tr(){return Qe||(Qe=1,function(t,e){var r=me(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}}(Er,Er.exports)),Er.exports}function Br(){if(Ze)return Xe;Ze=1;var t=me().Uint8Array;return Xe=t}function Or(){if(er)return tr;er=1;var t=Br();return tr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Sr(){if(nr)return rr;nr=1;var t=Or();return rr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Ar(){if(ir)return or;return ir=1,or=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Lr(){if(ar)return sr;ar=1;var t=we(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return sr=r}function Ur(){if(ur)return cr;return ur=1,cr=function(t,e){return function(r){return t(e(r))}}}function Fr(){if(lr)return hr;lr=1;var t=Ur()(Object.getPrototypeOf,Object);return hr=t}function Wr(){if(fr)return gr;fr=1;var t=Object.prototype;return gr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Mr(){if(mr)return pr;mr=1;var t=Lr(),e=Fr(),r=Wr();return pr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Gr(){if(yr)return dr;return yr=1,dr=function(t){return null!=t&&"object"==typeof t}}function Hr(){if(vr)return br;vr=1;var t=ve(),e=Gr();return br=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Ir(){if(Rr)return wr;Rr=1;var t=Hr(),e=Gr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return wr=i}function Dr(){if(kr)return xr;kr=1;var t=Array.isArray;return xr=t}function qr(){if(Pr)return _r;Pr=1;return _r=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function zr(){if($r)return Cr;$r=1;var t=Re(),e=qr();return Cr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Vr(){if(jr)return Nr;jr=1;var t=zr(),e=Gr();return Nr=function(r){return e(r)&&t(r)}}var Jr,Yr,Kr,Qr,Xr,Zr,tn,en,rn,nn={exports:{}};function on(){if(Yr)return Jr;return Yr=1,Jr=function(){return!1}}function sn(){return Kr||(Kr=1,function(t,e){var r=me(),n=on(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(nn,nn.exports)),nn.exports}function an(){if(Xr)return Qr;Xr=1;var t=ve(),e=Fr(),r=Gr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Qr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function cn(){if(tn)return Zr;tn=1;var t=ve(),e=qr(),r=Gr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,Zr=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function un(){if(rn)return en;return rn=1,en=function(t){return function(e){return t(e)}}}var hn,ln,gn,fn,pn,mn,dn,yn,bn,vn,wn,Rn,xn,kn,_n,Pn,Cn,$n,Nn,jn,En,Tn,Bn,On,Sn,An,Ln,Un,Fn,Wn,Mn,Gn,Hn,In,Dn,qn,zn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io={exports:{}};function so(){return hn||(hn=1,function(t,e){var r=pe(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=s}(io,io.exports)),io.exports}function ao(){if(gn)return ln;gn=1;var t=cn(),e=un(),r=so(),n=r&&r.isTypedArray,o=n?e(n):t;return ln=o}function co(){if(pn)return fn;return pn=1,fn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function uo(){if(dn)return mn;dn=1;var t=Ve(),e=ne(),r=Object.prototype.hasOwnProperty;return mn=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function ho(){if(bn)return yn;bn=1;var t=uo(),e=Ve();return yn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function lo(){if(wn)return vn;return wn=1,vn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function go(){if(xn)return Rn;xn=1;var t=/^(?:0|[1-9]\d*)$/;return Rn=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function fo(){if(_n)return kn;_n=1;var t=lo(),e=Ir(),r=Dr(),n=sn(),o=go(),i=ao(),s=Object.prototype.hasOwnProperty;return kn=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function po(){if(Cn)return Pn;return Cn=1,Pn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function mo(){if(Nn)return $n;Nn=1;var t=we(),e=Wr(),r=po(),n=Object.prototype.hasOwnProperty;return $n=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function yo(){if(En)return jn;En=1;var t=fo(),e=mo(),r=zr();return jn=function(n){return r(n)?t(n,!0):e(n)}}function bo(){if(Bn)return Tn;Bn=1;var t=ho(),e=yo();return Tn=function(r){return t(r,e(r))}}function vo(){if(Sn)return On;Sn=1;var t=Je(),e=Tr(),r=Sr(),n=Ar(),o=Mr(),i=Ir(),s=Dr(),a=Vr(),c=sn(),u=Re(),h=we(),l=an(),g=ao(),f=co(),p=bo();return On=function(m,d,y,b,v,w,R){var x=f(m,y),k=f(d,y),_=R.get(k);if(_)t(m,y,_);else{var P=w?w(x,k,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(k),N=!$&&c(k),j=!$&&!N&&g(k);P=k,$||N||j?s(x)?P=x:a(x)?P=n(x):N?(C=!1,P=e(k,!0)):j?(C=!1,P=r(k,!0)):P=[]:l(k)||i(k)?(P=x,i(x)?P=p(x):h(x)&&!u(x)||(P=o(k))):C=!1}C&&(R.set(k,P),v(P,k,b,w,R),R.delete(k)),t(m,y,P)}}}function wo(){if(Ln)return An;Ln=1;var t=qe(),e=Je(),r=Ke(),n=vo(),o=we(),i=yo(),s=co();return An=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},An}function Ro(){if(Fn)return Un;return Fn=1,Un=function(t){return t}}function xo(){if(Mn)return Wn;return Mn=1,Wn=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}}function ko(){if(Hn)return Gn;Hn=1;var t=xo(),e=Math.max;return Gn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},Gn}function _o(){if(Dn)return In;return Dn=1,In=function(t){return function(){return t}}}function Po(){if(zn)return qn;zn=1;var t=_o(),e=ze();return qn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:Ro()}function Co(){if(Jn)return Vn;Jn=1;var t=Date.now;return Vn=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Vn}function $o(){if(Kn)return Yn;Kn=1;var t=Po(),e=Co()(t);return Yn=e}function No(){if(Xn)return Qn;Xn=1;var t=Ro(),e=ko(),r=$o();return Qn=function(n,o){return r(e(n,o,t),n+"")}}function jo(){if(to)return Zn;to=1;var t=ne(),e=zr(),r=go(),n=we();return Zn=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)}}function Eo(){if(ro)return eo;ro=1;var t=No(),e=jo();return eo=function(r){return t((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var c=n[o];c&&r(t,c,o,s)}return t}))}}function To(){if(oo)return no;oo=1;var t=wo(),e=Eo()((function(e,r,n){t(e,r,n)}));return no=e}var Bo,Oo,So,Ao,Lo,Uo,Fo,Wo,Mo,Go,Ho,Io,Do,qo,zo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri=ee(To());function ni(){if(Oo)return Bo;Oo=1;var t=ve(),e=Gr();return Bo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function oi(){if(Ao)return So;Ao=1;var t=Dr(),e=ni(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return So=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function ii(){if(Uo)return Lo;Uo=1;var t=Ie();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,Lo=e}function si(){if(Wo)return Fo;Wo=1;var t=ii();return Fo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function ai(){if(Go)return Mo;Go=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=si()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return Mo=r}function ci(){if(Io)return Ho;return Io=1,Ho=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}}function ui(){if(qo)return Do;qo=1;var t=de(),e=ci(),r=Dr(),n=ni(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Do=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Do}function hi(){if(Vo)return zo;Vo=1;var t=ui();return zo=function(e){return null==e?"":t(e)}}function li(){if(Yo)return Jo;Yo=1;var t=Dr(),e=oi(),r=ai(),n=hi();return Jo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function gi(){if(Qo)return Ko;Qo=1;var t=ni();return Ko=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function fi(){if(Zo)return Xo;Zo=1;var t=li(),e=gi();return Xo=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0},Xo}function pi(){if(ei)return ti;ei=1;var t=fi();return ti=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o},ti}var mi=ee(pi());const di="package.json",yi=[".env.local",".env"];class bi extends Dt.FeScriptContext{_env;shared;constructor(t){super(t),this._env=qt.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||yi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ri(this.options,t)}getConfig(t,e){return mi(this.options,t,e)}setShared(t){this.shared=ri(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?mi(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function vi(t,...e){return[t,...e]}const wi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class Ri{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...wi,...r}}getReleaseBranchName(t,e,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.debug("Release Branch template is:",n),this.shell.format(n,{pkgName:t,releaseName:t,tagName:e,...r})}getBatchReleaseBranchName(t,e,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}getReleaseBranchParams(t,e){const r=this.getReleaseTagName(t),n=this.getReleaseName(t);return{tagName:r,releaseBranch:t.length>1?this.getBatchReleaseBranchName(n,r,e,t.length):this.getReleaseBranchName(n,r,e)}}getPRTitle(t,e){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...e,tagName:t.tagName,pkgName:t.releaseBranch})}getPRBody(t,e,r){const n=this.config.PRBody,o=t.length>1?t.map((t=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",t))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,s=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class xi{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new Vt.Octokit(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var ki,_i;function Pi(){if(_i)return ki;_i=1;var t=ve(),e=Dr(),r=Gr();return ki=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Ci=ee(Pi());class $i{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName],r=mi(this.context.shared,this.pluginName);return e||t?ri({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ni extends $i{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&Ci(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class ji{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Ei{static readJson(t){const e=Yt.readFileSync(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||Kt.join(e,o),n=n||Ei.readJson(Kt.join(r,di)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Ti extends $i{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new ji({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>Jt.resolve(t.root)===Jt.resolve(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Jt.join(t.root,di)),void this.setCurrentWorkspace(t,[t])}const[n,...o]=e;this.workspacesList=o,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}getPackages(){const t=this.context.shared.packagesDirectories;return Array.isArray(t)?t:[]}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}async getWorkspaces(){const t=this.getPackages();this.logger.debug("packages",t);const e=await this.getChangedPackages(t,this.getConfig("changeLabels"));this.setConfig({packages:t,changedPaths:e}),this.logger.debug("changedPaths",e);const r=e.map((t=>Ei.toWorkspace({path:t},this.context.rootPath)));return r}}function Bi(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Oi(t){return t.startsWith(".")?Jt.parse(t).name:t}async function Si(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(Jt.join(process.cwd(),t))).default}catch{const r=Qt.createRequire(process.cwd());e=(await import(Xt.pathToFileURL(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Oi(t),e]}async function Ai(t,e,r=5){const n=Zt(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Si(e);return Bi(n,t,...r)}return Bi(e,t,...r)})(e,...r)))));return Promise.all(o)}const Li="- ${message}${prRef}\n",Ui="%H%n%s%n%b%n----------------------";class Fi{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Li}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class Wi{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Ui,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Fi).formatFlatCommits(t,{types:r},this.shell)}}const Mi=[vi(Ti),vi(class extends $i{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return Kt.join(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return Kt.join(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Yt.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Ei.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Ei.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new Wi(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=Kt.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);Yt.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Yt.writeFileSync(o,s,"utf-8")}},{}),vi(class extends Ni{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new xi(this.context),this.releaseParams=new Ri(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];var Gi,Hi,Ii,Di;function qi(){if(Hi)return Gi;Hi=1;var t=uo(),e=li(),r=go(),n=we(),o=gi();return Gi=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i},Gi}function zi(){if(Di)return Ii;Di=1;var t=qi();return Ii=function(e,r,n){return null==e?e:t(e,r,n)},Ii}var Vi=ee(zi());exports.Plugin=$i,exports.ReleaseContext=bi,exports.ReleaseLabel=ji,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(t={},e=new zt.AsyncExecutor,r=Mi){this.executor=e,this.defaultTuples=r,this.context=new bi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Ai(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Ti&&t.setReleaseTask(this),this.executor.use(t)})),e}async run(){return this.executor.exec(this.context,(t=>Promise.resolve(t)))}async exec(t){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(t),this.run()}},exports.factory=Bi,exports.load=Si,exports.loaderPluginsFromPluginTuples=Ai,exports.reduceOptions=function(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Vi(t,r,n):Vi(t,e?`${e}.${r}`:r,n),t)),{})},exports.tuple=vi;
1
+ "use strict";var t,e,r,n,o,i,s,a,c,u,h,l,g,f,p,m,d,y,v,b,w,R,x,k,_,P,C,$,N,j,E,T,B,O,S,A,L,W,U,F,M,G,H,I,q,D,z,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,vt,bt,wt,Rt,xt,kt,_t,Pt,Ct,$t,Nt,jt,Et,Tt,Bt,Ot,St,At,Lt,Wt,Ut,Ft,Mt,Gt,Ht,It,qt=require("@qlover/scripts-context"),Dt=require("@qlover/env-loader"),zt=require("@qlover/fe-corekit"),Vt=require("@octokit/rest"),Jt=require("node:path"),Yt=require("find-workspaces"),Kt=require("fs"),Qt=require("path"),Xt=require("node:module"),Zt=require("node:url"),te=require("p-limit"),ee="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function re(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ne(){if(e)return t;return e=1,t=function(){this.__data__=[],this.size=0}}function oe(){if(n)return r;return n=1,r=function(t,e){return t===e||t!=t&&e!=e}}function ie(){if(i)return o;i=1;var t=oe();return o=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function se(){if(a)return s;a=1;var t=ie(),e=Array.prototype.splice;return s=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function ae(){if(u)return c;u=1;var t=ie();return c=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ce(){if(l)return h;l=1;var t=ie();return h=function(e){return t(this.__data__,e)>-1}}function ue(){if(f)return g;f=1;var t=ie();return g=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this}}function he(){if(m)return p;m=1;var t=ne(),e=se(),r=ae(),n=ce(),o=ue();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,p=i}function le(){if(y)return d;y=1;var t=he();return d=function(){this.__data__=new t,this.size=0}}function ge(){if(b)return v;return b=1,v=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function fe(){if(R)return w;return R=1,w=function(t){return this.__data__.get(t)}}function pe(){if(k)return x;return k=1,x=function(t){return this.__data__.has(t)}}function me(){if(P)return _;P=1;var t="object"==typeof ee&&ee&&ee.Object===Object&&ee;return _=t}function de(){if($)return C;$=1;var t=me(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return C=r}function ye(){if(j)return N;j=1;var t=de().Symbol;return N=t}function ve(){if(T)return E;T=1;var t=ye(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return E=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}function be(){if(O)return B;O=1;var t=Object.prototype.toString;return B=function(e){return t.call(e)}}function we(){if(A)return S;A=1;var t=ye(),e=ve(),r=be(),n=t?t.toStringTag:void 0;return S=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Re(){if(W)return L;return W=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function xe(){if(F)return U;F=1;var t=we(),e=Re();return U=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function ke(){if(G)return M;G=1;var t=de()["__core-js_shared__"];return M=t}function _e(){if(I)return H;I=1;var t,e=ke(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return H=function(t){return!!r&&r in t}}function Pe(){if(D)return q;D=1;var t=Function.prototype.toString;return q=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Ce(){if(V)return z;V=1;var t=xe(),e=_e(),r=Re(),n=Pe(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return z=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function $e(){if(Y)return J;return Y=1,J=function(t,e){return null==t?void 0:t[e]}}function Ne(){if(Q)return K;Q=1;var t=Ce(),e=$e();return K=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function je(){if(Z)return X;Z=1;var t=Ne()(de(),"Map");return X=t}function Ee(){if(et)return tt;et=1;var t=Ne()(Object,"create");return tt=t}function Te(){if(nt)return rt;nt=1;var t=Ee();return rt=function(){this.__data__=t?t(null):{},this.size=0}}function Be(){if(it)return ot;return it=1,ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Oe(){if(at)return st;at=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return st=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function Se(){if(ut)return ct;ut=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return ct=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Ae(){if(lt)return ht;lt=1;var t=Ee();return ht=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Le(){if(ft)return gt;ft=1;var t=Te(),e=Be(),r=Oe(),n=Se(),o=Ae();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,gt=i}function We(){if(mt)return pt;mt=1;var t=Le(),e=he(),r=je();return pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ue(){if(yt)return dt;return yt=1,dt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Fe(){if(bt)return vt;bt=1;var t=Ue();return vt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Me(){if(Rt)return wt;Rt=1;var t=Fe();return wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Ge(){if(kt)return xt;kt=1;var t=Fe();return xt=function(e){return t(this,e).get(e)}}function He(){if(Pt)return _t;Pt=1;var t=Fe();return _t=function(e){return t(this,e).has(e)}}function Ie(){if($t)return Ct;$t=1;var t=Fe();return Ct=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}function qe(){if(jt)return Nt;jt=1;var t=We(),e=Me(),r=Ge(),n=He(),o=Ie();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Nt=i}function De(){if(Tt)return Et;Tt=1;var t=he(),e=je(),r=qe();return Et=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}function ze(){if(Ot)return Bt;Ot=1;var t=he(),e=le(),r=ge(),n=fe(),o=pe(),i=De();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Bt=s}function Ve(){if(At)return St;At=1;var t=Ne(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return St=e}function Je(){if(Wt)return Lt;Wt=1;var t=Ve();return Lt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ye(){if(Ft)return Ut;Ft=1;var t=Je(),e=oe();return Ut=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Ke(){if(Gt)return Mt;return Gt=1,Mt=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function Qe(){if(It)return Ht;It=1;var t=Ke()();return Ht=t}var Xe,Ze,tr,er,rr,nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,vr,br,wr,Rr,xr,kr,_r,Pr,Cr,$r,Nr,jr,Er,Tr={exports:{}};function Br(){return Xe||(Xe=1,function(t,e){var r=de(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}}(Tr,Tr.exports)),Tr.exports}function Or(){if(tr)return Ze;tr=1;var t=de().Uint8Array;return Ze=t}function Sr(){if(rr)return er;rr=1;var t=Or();return er=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Ar(){if(or)return nr;or=1;var t=Sr();return nr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Lr(){if(sr)return ir;return sr=1,ir=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Wr(){if(cr)return ar;cr=1;var t=Re(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return ar=r}function Ur(){if(hr)return ur;return hr=1,ur=function(t,e){return function(r){return t(e(r))}}}function Fr(){if(gr)return lr;gr=1;var t=Ur()(Object.getPrototypeOf,Object);return lr=t}function Mr(){if(pr)return fr;pr=1;var t=Object.prototype;return fr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Gr(){if(dr)return mr;dr=1;var t=Wr(),e=Fr(),r=Mr();return mr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Hr(){if(vr)return yr;return vr=1,yr=function(t){return null!=t&&"object"==typeof t}}function Ir(){if(wr)return br;wr=1;var t=we(),e=Hr();return br=function(r){return e(r)&&"[object Arguments]"==t(r)}}function qr(){if(xr)return Rr;xr=1;var t=Ir(),e=Hr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return Rr=i}function Dr(){if(_r)return kr;_r=1;var t=Array.isArray;return kr=t}function zr(){if(Cr)return Pr;Cr=1;return Pr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Vr(){if(Nr)return $r;Nr=1;var t=xe(),e=zr();return $r=function(r){return null!=r&&e(r.length)&&!t(r)}}function Jr(){if(Er)return jr;Er=1;var t=Vr(),e=Hr();return jr=function(r){return e(r)&&t(r)}}var Yr,Kr,Qr,Xr,Zr,tn,en,rn,nn,on={exports:{}};function sn(){if(Kr)return Yr;return Kr=1,Yr=function(){return!1}}function an(){return Qr||(Qr=1,function(t,e){var r=de(),n=sn(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(on,on.exports)),on.exports}function cn(){if(Zr)return Xr;Zr=1;var t=we(),e=Fr(),r=Hr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Xr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function un(){if(en)return tn;en=1;var t=we(),e=zr(),r=Hr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,tn=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function hn(){if(nn)return rn;return nn=1,rn=function(t){return function(e){return t(e)}}}var ln,gn,fn,pn,mn,dn,yn,vn,bn,wn,Rn,xn,kn,_n,Pn,Cn,$n,Nn,jn,En,Tn,Bn,On,Sn,An,Ln,Wn,Un,Fn,Mn,Gn,Hn,In,qn,Dn,zn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,so={exports:{}};function ao(){return ln||(ln=1,function(t,e){var r=me(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=s}(so,so.exports)),so.exports}function co(){if(fn)return gn;fn=1;var t=un(),e=hn(),r=ao(),n=r&&r.isTypedArray,o=n?e(n):t;return gn=o}function uo(){if(mn)return pn;return mn=1,pn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function ho(){if(yn)return dn;yn=1;var t=Je(),e=oe(),r=Object.prototype.hasOwnProperty;return dn=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function lo(){if(bn)return vn;bn=1;var t=ho(),e=Je();return vn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function go(){if(Rn)return wn;return Rn=1,wn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function fo(){if(kn)return xn;kn=1;var t=/^(?:0|[1-9]\d*)$/;return xn=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function po(){if(Pn)return _n;Pn=1;var t=go(),e=qr(),r=Dr(),n=an(),o=fo(),i=co(),s=Object.prototype.hasOwnProperty;return _n=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function mo(){if($n)return Cn;return $n=1,Cn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function yo(){if(jn)return Nn;jn=1;var t=Re(),e=Mr(),r=mo(),n=Object.prototype.hasOwnProperty;return Nn=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function vo(){if(Tn)return En;Tn=1;var t=po(),e=yo(),r=Vr();return En=function(n){return r(n)?t(n,!0):e(n)}}function bo(){if(On)return Bn;On=1;var t=lo(),e=vo();return Bn=function(r){return t(r,e(r))}}function wo(){if(An)return Sn;An=1;var t=Ye(),e=Br(),r=Ar(),n=Lr(),o=Gr(),i=qr(),s=Dr(),a=Jr(),c=an(),u=xe(),h=Re(),l=cn(),g=co(),f=uo(),p=bo();return Sn=function(m,d,y,v,b,w,R){var x=f(m,y),k=f(d,y),_=R.get(k);if(_)t(m,y,_);else{var P=w?w(x,k,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(k),N=!$&&c(k),j=!$&&!N&&g(k);P=k,$||N||j?s(x)?P=x:a(x)?P=n(x):N?(C=!1,P=e(k,!0)):j?(C=!1,P=r(k,!0)):P=[]:l(k)||i(k)?(P=x,i(x)?P=p(x):h(x)&&!u(x)||(P=o(k))):C=!1}C&&(R.set(k,P),b(P,k,v,w,R),R.delete(k)),t(m,y,P)}}}function Ro(){if(Wn)return Ln;Wn=1;var t=ze(),e=Ye(),r=Qe(),n=wo(),o=Re(),i=vo(),s=uo();return Ln=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},Ln}function xo(){if(Fn)return Un;return Fn=1,Un=function(t){return t}}function ko(){if(Gn)return Mn;return Gn=1,Mn=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}}function _o(){if(In)return Hn;In=1;var t=ko(),e=Math.max;return Hn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},Hn}function Po(){if(Dn)return qn;return Dn=1,qn=function(t){return function(){return t}}}function Co(){if(Vn)return zn;Vn=1;var t=Po(),e=Ve();return zn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:xo()}function $o(){if(Yn)return Jn;Yn=1;var t=Date.now;return Jn=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Jn}function No(){if(Qn)return Kn;Qn=1;var t=Co(),e=$o()(t);return Kn=e}function jo(){if(Zn)return Xn;Zn=1;var t=xo(),e=_o(),r=No();return Xn=function(n,o){return r(e(n,o,t),n+"")}}function Eo(){if(eo)return to;eo=1;var t=oe(),e=Vr(),r=fo(),n=Re();return to=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)}}function To(){if(no)return ro;no=1;var t=jo(),e=Eo();return ro=function(r){return t((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var c=n[o];c&&r(t,c,o,s)}return t}))}}function Bo(){if(io)return oo;io=1;var t=Ro(),e=To()((function(e,r,n){t(e,r,n)}));return oo=e}var Oo,So,Ao,Lo,Wo,Uo,Fo,Mo,Go,Ho,Io,qo,Do,zo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni=re(Bo());function oi(){if(So)return Oo;So=1;var t=we(),e=Hr();return Oo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function ii(){if(Lo)return Ao;Lo=1;var t=Dr(),e=oi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ao=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function si(){if(Uo)return Wo;Uo=1;var t=qe();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,Wo=e}function ai(){if(Mo)return Fo;Mo=1;var t=si();return Fo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function ci(){if(Ho)return Go;Ho=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=ai()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return Go=r}function ui(){if(qo)return Io;return qo=1,Io=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}}function hi(){if(zo)return Do;zo=1;var t=ye(),e=ui(),r=Dr(),n=oi(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Do=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Do}function li(){if(Jo)return Vo;Jo=1;var t=hi();return Vo=function(e){return null==e?"":t(e)}}function gi(){if(Ko)return Yo;Ko=1;var t=Dr(),e=ii(),r=ci(),n=li();return Yo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function fi(){if(Xo)return Qo;Xo=1;var t=oi();return Qo=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function pi(){if(ti)return Zo;ti=1;var t=gi(),e=fi();return Zo=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0},Zo}function mi(){if(ri)return ei;ri=1;var t=pi();return ei=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o},ei}var di=re(mi());const yi="package.json",vi=[".env.local",".env"];class bi extends qt.FeScriptContext{_env;shared;constructor(t){super(t),this._env=Dt.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||vi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ni(this.options,t)}getConfig(t,e){return di(this.options,t,e)}setShared(t){this.shared=ni(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?di(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function wi(t,...e){return[t,...e]}const Ri={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class xi{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Ri,...r}}getReleaseBranchName(t,e,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.debug("Release Branch template is:",n),this.shell.format(n,{pkgName:t,releaseName:t,tagName:e,...r})}getBatchReleaseBranchName(t,e,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}getReleaseBranchParams(t,e){const r=this.getReleaseTagName(t),n=this.getReleaseName(t);return{tagName:r,releaseBranch:t.length>1?this.getBatchReleaseBranchName(n,r,e,t.length):this.getReleaseBranchName(n,r,e)}}getPRTitle(t,e){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...e,tagName:t.tagName,pkgName:t.releaseBranch})}getPRBody(t,e,r){const n=this.config.PRBody,o=t.length>1?t.map((t=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",t))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,s=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class ki{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new Vt.Octokit(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var _i,Pi;function Ci(){if(Pi)return _i;Pi=1;var t=we(),e=Dr(),r=Hr();return _i=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var $i=re(Ci());class Ni{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName],r=di(this.context.shared,this.pluginName);return e||t?ni({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class ji extends Ni{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&$i(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Ei{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Ti{static readJson(t){const e=Kt.readFileSync(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||Qt.join(e,o),n=n||Ti.readJson(Qt.join(r,yi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Bi extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Ei({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>Jt.resolve(t).startsWith(Jt.resolve(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>Jt.resolve(t.root)===Jt.resolve(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Jt.join(t.root,yi)),void this.setCurrentWorkspace(t,[t])}const[n,...o]=e;this.workspacesList=o,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>Ti.toWorkspace({path:e},t)));return(Yt.findWorkspaces(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:Jt.relative(t,e.location),root:Jt.resolve(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function Oi(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Si(t){return t.startsWith(".")?Jt.parse(t).name:t}async function Ai(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(Jt.join(process.cwd(),t))).default}catch{const r=Xt.createRequire(process.cwd());e=(await import(Zt.pathToFileURL(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Si(t),e]}async function Li(t,e,r=5){const n=te(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Ai(e);return Oi(n,t,...r)}return Oi(e,t,...r)})(e,...r)))));return Promise.all(o)}const Wi="- ${message}${prRef}\n",Ui="%H%n%s%n%b%n----------------------";class Fi{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Wi}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class Mi{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Ui,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Fi).formatFlatCommits(t,{types:r},this.shell)}}const Gi=[wi(Bi),wi(class extends Ni{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return Qt.join(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return Qt.join(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Kt.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Ti.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Ti.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new Mi(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=Qt.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);Kt.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Kt.writeFileSync(o,s,"utf-8")}},{}),wi(class extends ji{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new ki(this.context),this.releaseParams=new xi(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];var Hi,Ii,qi,Di;function zi(){if(Ii)return Hi;Ii=1;var t=ho(),e=gi(),r=fo(),n=Re(),o=fi();return Hi=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i},Hi}function Vi(){if(Di)return qi;Di=1;var t=zi();return qi=function(e,r,n){return null==e?e:t(e,r,n)},qi}var Ji=re(Vi());exports.Plugin=Ni,exports.ReleaseContext=bi,exports.ReleaseLabel=Ei,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(t={},e=new zt.AsyncExecutor,r=Gi){this.executor=e,this.defaultTuples=r,this.context=new bi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Li(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Bi&&t.setReleaseTask(this),this.executor.use(t)})),e}async run(){return this.executor.exec(this.context,(t=>Promise.resolve(t)))}async exec(t){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(t),this.run()}},exports.factory=Oi,exports.load=Ai,exports.loaderPluginsFromPluginTuples=Li,exports.reduceOptions=function(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Ji(t,r,n):Ji(t,e?`${e}.${r}`:r,n),t)),{})},exports.tuple=wi;
package/dist/index.d.ts CHANGED
@@ -53,6 +53,11 @@ interface WorkspacesProps {
53
53
  * @private
54
54
  */
55
55
  packages?: string[];
56
+ /**
57
+ * All project packages mapping
58
+ * @private
59
+ */
60
+ projectWorkspaces?: WorkspaceValue[];
56
61
  }
57
62
  interface WorkspaceValue {
58
63
  name: string;
@@ -71,14 +76,17 @@ interface WorkspaceValue {
71
76
  packageJson: PackageJson;
72
77
  /**
73
78
  * The tag name of the workspace
79
+ * @private
74
80
  */
75
81
  tagName?: string;
76
82
  /**
77
83
  * The last tag name of the workspace
84
+ * @private
78
85
  */
79
86
  lastTag?: string;
80
87
  /**
81
88
  * The changelog of the workspace
89
+ * @private
82
90
  */
83
91
  changelog?: string;
84
92
  }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{FeScriptContext as t}from"@qlover/scripts-context";import{Env as e}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-corekit";import{Octokit as n}from"@octokit/rest";import{resolve as o,join as i,parse as s}from"node:path";import{readFileSync as a,existsSync as c,writeFileSync as u}from"fs";import{join as h}from"path";import{createRequire as l}from"node:module";import{pathToFileURL as g}from"node:url";import f from"p-limit";var p,m,d,y,b,v,w,R,k,x,_,P,C,$,N,j,E,B,T,O,A,S,L,U,W,F,M,G,H,I,D,z,q,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,bt,vt,wt,Rt,kt,xt,_t,Pt,Ct,$t,Nt,jt,Et,Bt,Tt,Ot,At,St,Lt,Ut,Wt,Ft,Mt,Gt,Ht,It,Dt,zt,qt,Vt,Jt,Yt,Kt,Qt,Xt,Zt,te,ee,re,ne,oe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ie(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function se(){if(m)return p;return m=1,p=function(){this.__data__=[],this.size=0}}function ae(){if(y)return d;return y=1,d=function(t,e){return t===e||t!=t&&e!=e}}function ce(){if(v)return b;v=1;var t=ae();return b=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ue(){if(R)return w;R=1;var t=ce(),e=Array.prototype.splice;return w=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function he(){if(x)return k;x=1;var t=ce();return k=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function le(){if(P)return _;P=1;var t=ce();return _=function(e){return t(this.__data__,e)>-1}}function ge(){if($)return C;$=1;var t=ce();return C=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this}}function fe(){if(j)return N;j=1;var t=se(),e=ue(),r=he(),n=le(),o=ge();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,N=i}function pe(){if(B)return E;B=1;var t=fe();return E=function(){this.__data__=new t,this.size=0}}function me(){if(O)return T;return O=1,T=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function de(){if(S)return A;return S=1,A=function(t){return this.__data__.get(t)}}function ye(){if(U)return L;return U=1,L=function(t){return this.__data__.has(t)}}function be(){if(F)return W;F=1;var t="object"==typeof oe&&oe&&oe.Object===Object&&oe;return W=t}function ve(){if(G)return M;G=1;var t=be(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return M=r}function we(){if(I)return H;I=1;var t=ve().Symbol;return H=t}function Re(){if(z)return D;z=1;var t=we(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return D=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}function ke(){if(V)return q;V=1;var t=Object.prototype.toString;return q=function(e){return t.call(e)}}function xe(){if(Y)return J;Y=1;var t=we(),e=Re(),r=ke(),n=t?t.toStringTag:void 0;return J=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function _e(){if(Q)return K;return Q=1,K=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Pe(){if(Z)return X;Z=1;var t=xe(),e=_e();return X=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Ce(){if(et)return tt;et=1;var t=ve()["__core-js_shared__"];return tt=t}function $e(){if(nt)return rt;nt=1;var t,e=Ce(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return rt=function(t){return!!r&&r in t}}function Ne(){if(it)return ot;it=1;var t=Function.prototype.toString;return ot=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function je(){if(at)return st;at=1;var t=Pe(),e=$e(),r=_e(),n=Ne(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return st=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function Ee(){if(ut)return ct;return ut=1,ct=function(t,e){return null==t?void 0:t[e]}}function Be(){if(lt)return ht;lt=1;var t=je(),e=Ee();return ht=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Te(){if(ft)return gt;ft=1;var t=Be()(ve(),"Map");return gt=t}function Oe(){if(mt)return pt;mt=1;var t=Be()(Object,"create");return pt=t}function Ae(){if(yt)return dt;yt=1;var t=Oe();return dt=function(){this.__data__=t?t(null):{},this.size=0}}function Se(){if(vt)return bt;return vt=1,bt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Le(){if(Rt)return wt;Rt=1;var t=Oe(),e=Object.prototype.hasOwnProperty;return wt=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function Ue(){if(xt)return kt;xt=1;var t=Oe(),e=Object.prototype.hasOwnProperty;return kt=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function We(){if(Pt)return _t;Pt=1;var t=Oe();return _t=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Fe(){if($t)return Ct;$t=1;var t=Ae(),e=Se(),r=Le(),n=Ue(),o=We();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Ct=i}function Me(){if(jt)return Nt;jt=1;var t=Fe(),e=fe(),r=Te();return Nt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ge(){if(Bt)return Et;return Bt=1,Et=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function He(){if(Ot)return Tt;Ot=1;var t=Ge();return Tt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Ie(){if(St)return At;St=1;var t=He();return At=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function De(){if(Ut)return Lt;Ut=1;var t=He();return Lt=function(e){return t(this,e).get(e)}}function ze(){if(Ft)return Wt;Ft=1;var t=He();return Wt=function(e){return t(this,e).has(e)}}function qe(){if(Gt)return Mt;Gt=1;var t=He();return Mt=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}function Ve(){if(It)return Ht;It=1;var t=Me(),e=Ie(),r=De(),n=ze(),o=qe();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Ht=i}function Je(){if(zt)return Dt;zt=1;var t=fe(),e=Te(),r=Ve();return Dt=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}function Ye(){if(Vt)return qt;Vt=1;var t=fe(),e=pe(),r=me(),n=de(),o=ye(),i=Je();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,qt=s}function Ke(){if(Yt)return Jt;Yt=1;var t=Be(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Jt=e}function Qe(){if(Qt)return Kt;Qt=1;var t=Ke();return Kt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Xe(){if(Zt)return Xt;Zt=1;var t=Qe(),e=ae();return Xt=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Ze(){if(ee)return te;return ee=1,te=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function tr(){if(ne)return re;ne=1;var t=Ze()();return re=t}var er,rr,nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,br,vr,wr,Rr,kr,xr,_r,Pr,Cr,$r,Nr,jr,Er,Br,Tr,Or,Ar={exports:{}};function Sr(){return er||(er=1,t=Ar,e=Ar.exports,r=ve(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}),Ar.exports;var t,e,r,n,o,i,s}function Lr(){if(nr)return rr;nr=1;var t=ve().Uint8Array;return rr=t}function Ur(){if(ir)return or;ir=1;var t=Lr();return or=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Wr(){if(ar)return sr;ar=1;var t=Ur();return sr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Fr(){if(ur)return cr;return ur=1,cr=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Mr(){if(lr)return hr;lr=1;var t=_e(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return hr=r}function Gr(){if(fr)return gr;return fr=1,gr=function(t,e){return function(r){return t(e(r))}}}function Hr(){if(mr)return pr;mr=1;var t=Gr()(Object.getPrototypeOf,Object);return pr=t}function Ir(){if(yr)return dr;yr=1;var t=Object.prototype;return dr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Dr(){if(vr)return br;vr=1;var t=Mr(),e=Hr(),r=Ir();return br=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function zr(){if(Rr)return wr;return Rr=1,wr=function(t){return null!=t&&"object"==typeof t}}function qr(){if(xr)return kr;xr=1;var t=xe(),e=zr();return kr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Vr(){if(Pr)return _r;Pr=1;var t=qr(),e=zr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return _r=i}function Jr(){if($r)return Cr;$r=1;var t=Array.isArray;return Cr=t}function Yr(){if(jr)return Nr;jr=1;return Nr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Kr(){if(Br)return Er;Br=1;var t=Pe(),e=Yr();return Er=function(r){return null!=r&&e(r.length)&&!t(r)}}function Qr(){if(Or)return Tr;Or=1;var t=Kr(),e=zr();return Tr=function(r){return e(r)&&t(r)}}var Xr,Zr,tn,en,rn,nn,on,sn,an,cn={exports:{}};function un(){if(Zr)return Xr;return Zr=1,Xr=function(){return!1}}function hn(){return tn||(tn=1,function(t,e){var r=ve(),n=un(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(cn,cn.exports)),cn.exports}function ln(){if(rn)return en;rn=1;var t=xe(),e=Hr(),r=zr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return en=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function gn(){if(on)return nn;on=1;var t=xe(),e=Yr(),r=zr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,nn=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function fn(){if(an)return sn;return an=1,sn=function(t){return function(e){return t(e)}}}var pn,mn,dn,yn,bn,vn,wn,Rn,kn,xn,_n,Pn,Cn,$n,Nn,jn,En,Bn,Tn,On,An,Sn,Ln,Un,Wn,Fn,Mn,Gn,Hn,In,Dn,zn,qn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,so,ao,co,uo={exports:{}};function ho(){return pn||(pn=1,t=uo,e=uo.exports,r=be(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=s),uo.exports;var t,e,r,n,o,i,s}function lo(){if(dn)return mn;dn=1;var t=gn(),e=fn(),r=ho(),n=r&&r.isTypedArray,o=n?e(n):t;return mn=o}function go(){if(bn)return yn;return bn=1,yn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function fo(){if(wn)return vn;wn=1;var t=Qe(),e=ae(),r=Object.prototype.hasOwnProperty;return vn=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function po(){if(kn)return Rn;kn=1;var t=fo(),e=Qe();return Rn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function mo(){if(_n)return xn;return _n=1,xn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function yo(){if(Cn)return Pn;Cn=1;var t=/^(?:0|[1-9]\d*)$/;return Pn=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function bo(){if(Nn)return $n;Nn=1;var t=mo(),e=Vr(),r=Jr(),n=hn(),o=yo(),i=lo(),s=Object.prototype.hasOwnProperty;return $n=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function vo(){if(En)return jn;return En=1,jn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function wo(){if(Tn)return Bn;Tn=1;var t=_e(),e=Ir(),r=vo(),n=Object.prototype.hasOwnProperty;return Bn=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function Ro(){if(An)return On;An=1;var t=bo(),e=wo(),r=Kr();return On=function(n){return r(n)?t(n,!0):e(n)}}function ko(){if(Ln)return Sn;Ln=1;var t=po(),e=Ro();return Sn=function(r){return t(r,e(r))}}function xo(){if(Wn)return Un;Wn=1;var t=Xe(),e=Sr(),r=Wr(),n=Fr(),o=Dr(),i=Vr(),s=Jr(),a=Qr(),c=hn(),u=Pe(),h=_e(),l=ln(),g=lo(),f=go(),p=ko();return Un=function(m,d,y,b,v,w,R){var k=f(m,y),x=f(d,y),_=R.get(x);if(_)t(m,y,_);else{var P=w?w(k,x,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(x),N=!$&&c(x),j=!$&&!N&&g(x);P=x,$||N||j?s(k)?P=k:a(k)?P=n(k):N?(C=!1,P=e(x,!0)):j?(C=!1,P=r(x,!0)):P=[]:l(x)||i(x)?(P=k,i(k)?P=p(k):h(k)&&!u(k)||(P=o(x))):C=!1}C&&(R.set(x,P),v(P,x,b,w,R),R.delete(x)),t(m,y,P)}}}function _o(){if(Mn)return Fn;Mn=1;var t=Ye(),e=Xe(),r=tr(),n=xo(),o=_e(),i=Ro(),s=go();return Fn=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},Fn}function Po(){if(Hn)return Gn;return Hn=1,Gn=function(t){return t}}function Co(){if(Dn)return In;return Dn=1,In=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}}function $o(){if(qn)return zn;qn=1;var t=Co(),e=Math.max;return zn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},zn}function No(){if(Jn)return Vn;return Jn=1,Vn=function(t){return function(){return t}}}function jo(){if(Kn)return Yn;Kn=1;var t=No(),e=Ke();return Yn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:Po()}function Eo(){if(Xn)return Qn;Xn=1;var t=Date.now;return Qn=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Qn}function Bo(){if(to)return Zn;to=1;var t=jo(),e=Eo()(t);return Zn=e}function To(){if(ro)return eo;ro=1;var t=Po(),e=$o(),r=Bo();return eo=function(n,o){return r(e(n,o,t),n+"")}}function Oo(){if(oo)return no;oo=1;var t=ae(),e=Kr(),r=yo(),n=_e();return no=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)}}function Ao(){if(so)return io;so=1;var t=To(),e=Oo();return io=function(r){return t((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var c=n[o];c&&r(t,c,o,s)}return t}))}}function So(){if(co)return ao;co=1;var t=_o(),e=Ao()((function(e,r,n){t(e,r,n)}));return ao=e}var Lo,Uo,Wo,Fo,Mo,Go,Ho,Io,Do,zo,qo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni,oi,ii,si=ie(So());function ai(){if(Uo)return Lo;Uo=1;var t=xe(),e=zr();return Lo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function ci(){if(Fo)return Wo;Fo=1;var t=Jr(),e=ai(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Wo=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function ui(){if(Go)return Mo;Go=1;var t=Ve();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,Mo=e}function hi(){if(Io)return Ho;Io=1;var t=ui();return Ho=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function li(){if(zo)return Do;zo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=hi()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return Do=r}function gi(){if(Vo)return qo;return Vo=1,qo=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}}function fi(){if(Yo)return Jo;Yo=1;var t=we(),e=gi(),r=Jr(),n=ai(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Jo=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Jo}function pi(){if(Qo)return Ko;Qo=1;var t=fi();return Ko=function(e){return null==e?"":t(e)}}function mi(){if(Zo)return Xo;Zo=1;var t=Jr(),e=ci(),r=li(),n=pi();return Xo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function di(){if(ei)return ti;ei=1;var t=ai();return ti=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function yi(){if(ni)return ri;ni=1;var t=mi(),e=di();return ri=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0}}function bi(){if(ii)return oi;ii=1;var t=yi();return oi=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var vi=ie(bi());const wi="package.json",Ri=[".env.local",".env"];class ki extends t{_env;shared;constructor(t){super(t),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||Ri}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=si(this.options,t)}getConfig(t,e){return vi(this.options,t,e)}setShared(t){this.shared=si(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?vi(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function xi(t,...e){return[t,...e]}const _i={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class Pi{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={..._i,...r}}getReleaseBranchName(t,e,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.debug("Release Branch template is:",n),this.shell.format(n,{pkgName:t,releaseName:t,tagName:e,...r})}getBatchReleaseBranchName(t,e,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}getReleaseBranchParams(t,e){const r=this.getReleaseTagName(t),n=this.getReleaseName(t);return{tagName:r,releaseBranch:t.length>1?this.getBatchReleaseBranchName(n,r,e,t.length):this.getReleaseBranchName(n,r,e)}}getPRTitle(t,e){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...e,tagName:t.tagName,pkgName:t.releaseBranch})}getPRBody(t,e,r){const n=this.config.PRBody,o=t.length>1?t.map((t=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",t))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,s=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class Ci{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new n(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var $i,Ni;function ji(){if(Ni)return $i;Ni=1;var t=xe(),e=Jr(),r=zr();return $i=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Ei=ie(ji());class Bi{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName],r=vi(this.context.shared,this.pluginName);return e||t?si({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ti extends Bi{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&Ei(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Oi{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Ai{static readJson(t){const e=a(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||h(e,o),n=n||Ai.readJson(h(r,wi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Si extends Bi{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Oi({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>o(t.root)===o(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,i(t.root,wi)),void this.setCurrentWorkspace(t,[t])}const[n,...s]=e;this.workspacesList=s,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}getPackages(){const t=this.context.shared.packagesDirectories;return Array.isArray(t)?t:[]}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}async getWorkspaces(){const t=this.getPackages();this.logger.debug("packages",t);const e=await this.getChangedPackages(t,this.getConfig("changeLabels"));this.setConfig({packages:t,changedPaths:e}),this.logger.debug("changedPaths",e);return e.map((t=>Ai.toWorkspace({path:t},this.context.rootPath)))}}function Li(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Ui(t){return t.startsWith(".")?s(t).name:t}async function Wi(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(i(process.cwd(),t))).default}catch{const r=l(process.cwd());e=(await import(g(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Ui(t),e]}async function Fi(t,e,r=5){const n=f(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Wi(e);return Li(n,t,...r)}return Li(e,t,...r)})(e,...r)))));return Promise.all(o)}const Mi="- ${message}${prRef}\n",Gi="%H%n%s%n%b%n----------------------";class Hi{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Mi}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class Ii{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Gi,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Hi).formatFlatCommits(t,{types:r},this.shell)}}const Di=[xi(Si),xi(class extends Bi{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return h(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return h(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!c(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Ai.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Ai.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new Ii(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=h(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);c(o)?this.logger.info(`Changeset ${n} already exists`):u(o,s,"utf-8")}},{}),xi(class extends Ti{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new Ci(this.context),this.releaseParams=new Pi(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];class zi{executor;defaultTuples;context;constructor(t={},e=new r,n=Di){this.executor=e,this.defaultTuples=n,this.context=new ki(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Fi(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Si&&t.setReleaseTask(this),this.executor.use(t)})),e}async run(){return this.executor.exec(this.context,(t=>Promise.resolve(t)))}async exec(t){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(t),this.run()}}var qi,Vi,Ji,Yi;function Ki(){if(Vi)return qi;Vi=1;var t=fo(),e=mi(),r=yo(),n=_e(),o=di();return qi=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i}}function Qi(){if(Yi)return Ji;Yi=1;var t=Ki();return Ji=function(e,r,n){return null==e?e:t(e,r,n)}}var Xi=ie(Qi());function Zi(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Xi(t,r,n):Xi(t,e?`${e}.${r}`:r,n),t)),{})}export{Bi as Plugin,ki as ReleaseContext,Oi as ReleaseLabel,zi as ReleaseTask,Li as factory,Wi as load,Fi as loaderPluginsFromPluginTuples,Zi as reduceOptions,xi as tuple};
1
+ import{FeScriptContext as t}from"@qlover/scripts-context";import{Env as e}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-corekit";import{Octokit as n}from"@octokit/rest";import{resolve as o,join as i,relative as s,parse as a}from"node:path";import{findWorkspaces as c}from"find-workspaces";import{readFileSync as u,existsSync as h,writeFileSync as l}from"fs";import{join as g}from"path";import{createRequire as f}from"node:module";import{pathToFileURL as p}from"node:url";import m from"p-limit";var d,y,b,v,w,R,k,x,_,P,C,$,N,j,E,B,T,O,A,S,L,W,U,F,M,G,H,I,D,z,q,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,bt,vt,wt,Rt,kt,xt,_t,Pt,Ct,$t,Nt,jt,Et,Bt,Tt,Ot,At,St,Lt,Wt,Ut,Ft,Mt,Gt,Ht,It,Dt,zt,qt,Vt,Jt,Yt,Kt,Qt,Xt,Zt,te,ee,re,ne,oe,ie,se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ce(){if(y)return d;return y=1,d=function(){this.__data__=[],this.size=0}}function ue(){if(v)return b;return v=1,b=function(t,e){return t===e||t!=t&&e!=e}}function he(){if(R)return w;R=1;var t=ue();return w=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function le(){if(x)return k;x=1;var t=he(),e=Array.prototype.splice;return k=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function ge(){if(P)return _;P=1;var t=he();return _=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function fe(){if($)return C;$=1;var t=he();return C=function(e){return t(this.__data__,e)>-1}}function pe(){if(j)return N;j=1;var t=he();return N=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this}}function me(){if(B)return E;B=1;var t=ce(),e=le(),r=ge(),n=fe(),o=pe();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,E=i}function de(){if(O)return T;O=1;var t=me();return T=function(){this.__data__=new t,this.size=0}}function ye(){if(S)return A;return S=1,A=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function be(){if(W)return L;return W=1,L=function(t){return this.__data__.get(t)}}function ve(){if(F)return U;return F=1,U=function(t){return this.__data__.has(t)}}function we(){if(G)return M;G=1;var t="object"==typeof se&&se&&se.Object===Object&&se;return M=t}function Re(){if(I)return H;I=1;var t=we(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return H=r}function ke(){if(z)return D;z=1;var t=Re().Symbol;return D=t}function xe(){if(V)return q;V=1;var t=ke(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return q=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}function _e(){if(Y)return J;Y=1;var t=Object.prototype.toString;return J=function(e){return t.call(e)}}function Pe(){if(Q)return K;Q=1;var t=ke(),e=xe(),r=_e(),n=t?t.toStringTag:void 0;return K=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Ce(){if(Z)return X;return Z=1,X=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function $e(){if(et)return tt;et=1;var t=Pe(),e=Ce();return tt=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Ne(){if(nt)return rt;nt=1;var t=Re()["__core-js_shared__"];return rt=t}function je(){if(it)return ot;it=1;var t,e=Ne(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return ot=function(t){return!!r&&r in t}}function Ee(){if(at)return st;at=1;var t=Function.prototype.toString;return st=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Be(){if(ut)return ct;ut=1;var t=$e(),e=je(),r=Ce(),n=Ee(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ct=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function Te(){if(lt)return ht;return lt=1,ht=function(t,e){return null==t?void 0:t[e]}}function Oe(){if(ft)return gt;ft=1;var t=Be(),e=Te();return gt=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Ae(){if(mt)return pt;mt=1;var t=Oe()(Re(),"Map");return pt=t}function Se(){if(yt)return dt;yt=1;var t=Oe()(Object,"create");return dt=t}function Le(){if(vt)return bt;vt=1;var t=Se();return bt=function(){this.__data__=t?t(null):{},this.size=0}}function We(){if(Rt)return wt;return Rt=1,wt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Ue(){if(xt)return kt;xt=1;var t=Se(),e=Object.prototype.hasOwnProperty;return kt=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function Fe(){if(Pt)return _t;Pt=1;var t=Se(),e=Object.prototype.hasOwnProperty;return _t=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Me(){if($t)return Ct;$t=1;var t=Se();return Ct=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Ge(){if(jt)return Nt;jt=1;var t=Le(),e=We(),r=Ue(),n=Fe(),o=Me();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Nt=i}function He(){if(Bt)return Et;Bt=1;var t=Ge(),e=me(),r=Ae();return Et=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ie(){if(Ot)return Tt;return Ot=1,Tt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function De(){if(St)return At;St=1;var t=Ie();return At=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function ze(){if(Wt)return Lt;Wt=1;var t=De();return Lt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function qe(){if(Ft)return Ut;Ft=1;var t=De();return Ut=function(e){return t(this,e).get(e)}}function Ve(){if(Gt)return Mt;Gt=1;var t=De();return Mt=function(e){return t(this,e).has(e)}}function Je(){if(It)return Ht;It=1;var t=De();return Ht=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}function Ye(){if(zt)return Dt;zt=1;var t=He(),e=ze(),r=qe(),n=Ve(),o=Je();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Dt=i}function Ke(){if(Vt)return qt;Vt=1;var t=me(),e=Ae(),r=Ye();return qt=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}function Qe(){if(Yt)return Jt;Yt=1;var t=me(),e=de(),r=ye(),n=be(),o=ve(),i=Ke();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Jt=s}function Xe(){if(Qt)return Kt;Qt=1;var t=Oe(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Kt=e}function Ze(){if(Zt)return Xt;Zt=1;var t=Xe();return Xt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function tr(){if(ee)return te;ee=1;var t=Ze(),e=ue();return te=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function er(){if(ne)return re;return ne=1,re=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function rr(){if(ie)return oe;ie=1;var t=er()();return oe=t}var nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,br,vr,wr,Rr,kr,xr,_r,Pr,Cr,$r,Nr,jr,Er,Br,Tr,Or,Ar,Sr,Lr={exports:{}};function Wr(){return nr||(nr=1,t=Lr,e=Lr.exports,r=Re(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}),Lr.exports;var t,e,r,n,o,i,s}function Ur(){if(ir)return or;ir=1;var t=Re().Uint8Array;return or=t}function Fr(){if(ar)return sr;ar=1;var t=Ur();return sr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Mr(){if(ur)return cr;ur=1;var t=Fr();return cr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Gr(){if(lr)return hr;return lr=1,hr=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Hr(){if(fr)return gr;fr=1;var t=Ce(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return gr=r}function Ir(){if(mr)return pr;return mr=1,pr=function(t,e){return function(r){return t(e(r))}}}function Dr(){if(yr)return dr;yr=1;var t=Ir()(Object.getPrototypeOf,Object);return dr=t}function zr(){if(vr)return br;vr=1;var t=Object.prototype;return br=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function qr(){if(Rr)return wr;Rr=1;var t=Hr(),e=Dr(),r=zr();return wr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Vr(){if(xr)return kr;return xr=1,kr=function(t){return null!=t&&"object"==typeof t}}function Jr(){if(Pr)return _r;Pr=1;var t=Pe(),e=Vr();return _r=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Yr(){if($r)return Cr;$r=1;var t=Jr(),e=Vr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return Cr=i}function Kr(){if(jr)return Nr;jr=1;var t=Array.isArray;return Nr=t}function Qr(){if(Br)return Er;Br=1;return Er=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Xr(){if(Or)return Tr;Or=1;var t=$e(),e=Qr();return Tr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Zr(){if(Sr)return Ar;Sr=1;var t=Xr(),e=Vr();return Ar=function(r){return e(r)&&t(r)}}var tn,en,rn,nn,on,sn,an,cn,un,hn={exports:{}};function ln(){if(en)return tn;return en=1,tn=function(){return!1}}function gn(){return rn||(rn=1,function(t,e){var r=Re(),n=ln(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(hn,hn.exports)),hn.exports}function fn(){if(on)return nn;on=1;var t=Pe(),e=Dr(),r=Vr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return nn=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function pn(){if(an)return sn;an=1;var t=Pe(),e=Qr(),r=Vr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,sn=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function mn(){if(un)return cn;return un=1,cn=function(t){return function(e){return t(e)}}}var dn,yn,bn,vn,wn,Rn,kn,xn,_n,Pn,Cn,$n,Nn,jn,En,Bn,Tn,On,An,Sn,Ln,Wn,Un,Fn,Mn,Gn,Hn,In,Dn,zn,qn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,so,ao,co,uo,ho,lo={exports:{}};function go(){return dn||(dn=1,t=lo,e=lo.exports,r=we(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=s),lo.exports;var t,e,r,n,o,i,s}function fo(){if(bn)return yn;bn=1;var t=pn(),e=mn(),r=go(),n=r&&r.isTypedArray,o=n?e(n):t;return yn=o}function po(){if(wn)return vn;return wn=1,vn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function mo(){if(kn)return Rn;kn=1;var t=Ze(),e=ue(),r=Object.prototype.hasOwnProperty;return Rn=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function yo(){if(_n)return xn;_n=1;var t=mo(),e=Ze();return xn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function bo(){if(Cn)return Pn;return Cn=1,Pn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function vo(){if(Nn)return $n;Nn=1;var t=/^(?:0|[1-9]\d*)$/;return $n=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function wo(){if(En)return jn;En=1;var t=bo(),e=Yr(),r=Kr(),n=gn(),o=vo(),i=fo(),s=Object.prototype.hasOwnProperty;return jn=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function Ro(){if(Tn)return Bn;return Tn=1,Bn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function ko(){if(An)return On;An=1;var t=Ce(),e=zr(),r=Ro(),n=Object.prototype.hasOwnProperty;return On=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function xo(){if(Ln)return Sn;Ln=1;var t=wo(),e=ko(),r=Xr();return Sn=function(n){return r(n)?t(n,!0):e(n)}}function _o(){if(Un)return Wn;Un=1;var t=yo(),e=xo();return Wn=function(r){return t(r,e(r))}}function Po(){if(Mn)return Fn;Mn=1;var t=tr(),e=Wr(),r=Mr(),n=Gr(),o=qr(),i=Yr(),s=Kr(),a=Zr(),c=gn(),u=$e(),h=Ce(),l=fn(),g=fo(),f=po(),p=_o();return Fn=function(m,d,y,b,v,w,R){var k=f(m,y),x=f(d,y),_=R.get(x);if(_)t(m,y,_);else{var P=w?w(k,x,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(x),N=!$&&c(x),j=!$&&!N&&g(x);P=x,$||N||j?s(k)?P=k:a(k)?P=n(k):N?(C=!1,P=e(x,!0)):j?(C=!1,P=r(x,!0)):P=[]:l(x)||i(x)?(P=k,i(k)?P=p(k):h(k)&&!u(k)||(P=o(x))):C=!1}C&&(R.set(x,P),v(P,x,b,w,R),R.delete(x)),t(m,y,P)}}}function Co(){if(Hn)return Gn;Hn=1;var t=Qe(),e=tr(),r=rr(),n=Po(),o=Ce(),i=xo(),s=po();return Gn=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},Gn}function $o(){if(Dn)return In;return Dn=1,In=function(t){return t}}function No(){if(qn)return zn;return qn=1,zn=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}}function jo(){if(Jn)return Vn;Jn=1;var t=No(),e=Math.max;return Vn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(i.length-n,0),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},Vn}function Eo(){if(Kn)return Yn;return Kn=1,Yn=function(t){return function(){return t}}}function Bo(){if(Xn)return Qn;Xn=1;var t=Eo(),e=Xe();return Qn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:$o()}function To(){if(to)return Zn;to=1;var t=Date.now;return Zn=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Zn}function Oo(){if(ro)return eo;ro=1;var t=Bo(),e=To()(t);return eo=e}function Ao(){if(oo)return no;oo=1;var t=$o(),e=jo(),r=Oo();return no=function(n,o){return r(e(n,o,t),n+"")}}function So(){if(so)return io;so=1;var t=ue(),e=Xr(),r=vo(),n=Ce();return io=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)}}function Lo(){if(co)return ao;co=1;var t=Ao(),e=So();return ao=function(r){return t((function(t,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var c=n[o];c&&r(t,c,o,s)}return t}))}}function Wo(){if(ho)return uo;ho=1;var t=Co(),e=Lo()((function(e,r,n){t(e,r,n)}));return uo=e}var Uo,Fo,Mo,Go,Ho,Io,Do,zo,qo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni,oi,ii,si,ai,ci=ae(Wo());function ui(){if(Fo)return Uo;Fo=1;var t=Pe(),e=Vr();return Uo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function hi(){if(Go)return Mo;Go=1;var t=Kr(),e=ui(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Mo=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function li(){if(Io)return Ho;Io=1;var t=Ye();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,Ho=e}function gi(){if(zo)return Do;zo=1;var t=li();return Do=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function fi(){if(Vo)return qo;Vo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=gi()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return qo=r}function pi(){if(Yo)return Jo;return Yo=1,Jo=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}}function mi(){if(Qo)return Ko;Qo=1;var t=ke(),e=pi(),r=Kr(),n=ui(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Ko=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Ko}function di(){if(Zo)return Xo;Zo=1;var t=mi();return Xo=function(e){return null==e?"":t(e)}}function yi(){if(ei)return ti;ei=1;var t=Kr(),e=hi(),r=fi(),n=di();return ti=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function bi(){if(ni)return ri;ni=1;var t=ui();return ri=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function vi(){if(ii)return oi;ii=1;var t=yi(),e=bi();return oi=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0}}function wi(){if(ai)return si;ai=1;var t=vi();return si=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var Ri=ae(wi());const ki="package.json",xi=[".env.local",".env"];class _i extends t{_env;shared;constructor(t){super(t),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||xi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ci(this.options,t)}getConfig(t,e){return Ri(this.options,t,e)}setShared(t){this.shared=ci(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?Ri(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function Pi(t,...e){return[t,...e]}const Ci={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class $i{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Ci,...r}}getReleaseBranchName(t,e,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.debug("Release Branch template is:",n),this.shell.format(n,{pkgName:t,releaseName:t,tagName:e,...r})}getBatchReleaseBranchName(t,e,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}getReleaseBranchParams(t,e){const r=this.getReleaseTagName(t),n=this.getReleaseName(t);return{tagName:r,releaseBranch:t.length>1?this.getBatchReleaseBranchName(n,r,e,t.length):this.getReleaseBranchName(n,r,e)}}getPRTitle(t,e){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...e,tagName:t.tagName,pkgName:t.releaseBranch})}getPRBody(t,e,r){const n=this.config.PRBody,o=t.length>1?t.map((t=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",t))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,s=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class Ni{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new n(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var ji,Ei;function Bi(){if(Ei)return ji;Ei=1;var t=Pe(),e=Kr(),r=Vr();return ji=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Ti=ae(Bi());class Oi{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName],r=Ri(this.context.shared,this.pluginName);return e||t?ci({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ai extends Oi{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&Ti(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Si{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Li{static readJson(t){const e=u(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||g(e,o),n=n||Li.readJson(g(r,ki)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Wi extends Oi{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Si({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>o(t).startsWith(o(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>o(t.root)===o(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,i(t.root,ki)),void this.setCurrentWorkspace(t,[t])}const[n,...s]=e;this.workspacesList=s,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>Li.toWorkspace({path:e},t)));return(c(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:s(t,e.location),root:o(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function Ui(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Fi(t){return t.startsWith(".")?a(t).name:t}async function Mi(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(i(process.cwd(),t))).default}catch{const r=f(process.cwd());e=(await import(p(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Fi(t),e]}async function Gi(t,e,r=5){const n=m(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Mi(e);return Ui(n,t,...r)}return Ui(e,t,...r)})(e,...r)))));return Promise.all(o)}const Hi="- ${message}${prRef}\n",Ii="%H%n%s%n%b%n----------------------";class Di{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Hi}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class zi{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Ii,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Di).formatFlatCommits(t,{types:r},this.shell)}}const qi=[Pi(Wi),Pi(class extends Oi{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return g(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return g(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!h(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Li.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Li.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new zi(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=g(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);h(o)?this.logger.info(`Changeset ${n} already exists`):l(o,s,"utf-8")}},{}),Pi(class extends Ai{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new Ni(this.context),this.releaseParams=new $i(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];class Vi{executor;defaultTuples;context;constructor(t={},e=new r,n=qi){this.executor=e,this.defaultTuples=n,this.context=new _i(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Gi(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Wi&&t.setReleaseTask(this),this.executor.use(t)})),e}async run(){return this.executor.exec(this.context,(t=>Promise.resolve(t)))}async exec(t){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(t),this.run()}}var Ji,Yi,Ki,Qi;function Xi(){if(Yi)return Ji;Yi=1;var t=mo(),e=yi(),r=vo(),n=Ce(),o=bi();return Ji=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i}}function Zi(){if(Qi)return Ki;Qi=1;var t=Xi();return Ki=function(e,r,n){return null==e?e:t(e,r,n)}}var ts=ae(Zi());function es(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?ts(t,r,n):ts(t,e?`${e}.${r}`:r,n),t)),{})}export{Oi as Plugin,_i as ReleaseContext,Si as ReleaseLabel,Vi as ReleaseTask,Ui as factory,Mi as load,Gi as loaderPluginsFromPluginTuples,es as reduceOptions,Pi as tuple};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qlover/fe-release",
3
3
  "description": "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.",
4
- "version": "2.1.5",
4
+ "version": "2.1.6",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
@@ -53,11 +53,12 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@octokit/rest": "^21.0.2",
56
+ "find-workspaces": "^0.3.1",
56
57
  "lodash": "^4.17.21",
57
58
  "@qlover/env-loader": "0.3.0",
58
- "@qlover/logger": "0.1.1",
59
+ "@qlover/fe-corekit": "1.3.1",
59
60
  "@qlover/scripts-context": "0.2.1",
60
- "@qlover/fe-corekit": "1.3.1"
61
+ "@qlover/logger": "0.1.1"
61
62
  },
62
63
  "scripts": {
63
64
  "build": "rollup -c",