├── lib ├── package.json └── sourcemap-register.cjs ├── bun.lockb ├── DEVELOPMENT ├── .github └── workflows │ └── ci.yml ├── src ├── run.ts ├── replace_extension_toml.ts ├── utils.ts ├── utils_test.ts ├── replace_extension_toml_test.ts ├── version.ts ├── version_test.ts ├── github_test.ts ├── main.ts ├── edit_github_blob.ts └── github.ts ├── tsconfig.json ├── package.json ├── LICENSE ├── action.yml ├── README.md └── .gitignore /lib/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huacnlee/zed-extension-action/HEAD/bun.lockb -------------------------------------------------------------------------------- /DEVELOPMENT: -------------------------------------------------------------------------------- 1 | # Development Guide 2 | 3 | ## Getting Started 4 | 5 | ```bash 6 | bun install 7 | ``` 8 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v3 8 | - uses: oven-sh/setup-bun@v1 9 | with: 10 | bun-version: latest 11 | - name: Install dependencies 12 | run: bun install 13 | - name: Test 14 | run: | 15 | bun test 16 | -------------------------------------------------------------------------------- /src/run.ts: -------------------------------------------------------------------------------- 1 | import { setFailed } from "@actions/core"; 2 | import api from "./github"; 3 | import { UpgradeError } from "./replace_extension_toml"; 4 | import run from "./main"; 5 | 6 | run(api).catch((error) => { 7 | if (error instanceof UpgradeError) { 8 | console.warn("Skipping: %s", error.message); 9 | return; 10 | } 11 | setFailed(error.toString()); 12 | if (process.env.GITHUB_ACTIONS == undefined) { 13 | console.error(error.stack); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /src/replace_extension_toml.ts: -------------------------------------------------------------------------------- 1 | export class UpgradeError extends Error {} 2 | 3 | export function updateVersion( 4 | raw: string, 5 | extensionName: string, 6 | newVersion: string, 7 | ): string { 8 | let re = new RegExp( 9 | `(\\[${extensionName}\\]\\s+(.*\\s*))(version = ".+?")`, 10 | "gm", 11 | ); 12 | return raw.replace(re, `$1version = "${newVersion}"`); 13 | } 14 | 15 | export function removeRevisionLine(oldContent: string): string { 16 | return oldContent.replace(/^[ \t]*revision \d+ *\r?\n/m, ""); 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib", 4 | "rootDir": "./src", 5 | "module": "commonjs", 6 | "target": "esnext", 7 | "lib": ["es2015", "es2017", "es2020.string"], 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "noImplicitAny": true, 14 | "removeComments": false, 15 | "preserveConstEnums": true 16 | }, 17 | "include": ["src/**/*.ts"], 18 | "exclude": ["node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Prepare a commit message for a release with the given parameters. 3 | */ 4 | export function commitForRelease( 5 | messageTemplate: string, 6 | params: { [key: string]: string } = {}, 7 | ): string { 8 | return messageTemplate.replace( 9 | /\{\{(\w+)\}\}/gm, 10 | (m: string, key: string): string => { 11 | if (Object.hasOwnProperty.call(params, key)) { 12 | return params[key]; 13 | } 14 | return m; 15 | }, 16 | ); 17 | } 18 | 19 | export function getExtensionPath(extensionName: string): string { 20 | return `extensions/${extensionName}`; 21 | } 22 | -------------------------------------------------------------------------------- /src/utils_test.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from "bun:test"; 2 | import { commitForRelease } from "./utils"; 3 | 4 | test("commitForRelease", () => { 5 | expect( 6 | commitForRelease( 7 | "Hello world {{owner}}/{{repp}} {{tag}}\n\nhttps://github.com/{{owner}}/{{repp}}/releases/tag/{{tag}}", 8 | { 9 | owner: "huacnlee", 10 | repp: "zed-theme-macos-classic", 11 | tag: "v0.1.2", 12 | }, 13 | ), 14 | ).toEqual( 15 | "Hello world huacnlee/zed-theme-macos-classic v0.1.2\n\nhttps://github.com/huacnlee/zed-theme-macos-classic/releases/tag/v0.1.2", 16 | ); 17 | }); 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zed-extension-action", 3 | "module": "index.ts", 4 | "type": "module", 5 | "scripts": { 6 | "build": "rm -rf lib && ncc build src/run.ts -o lib --source-map", 7 | "pre-commit": "bun run build && git add lib/" 8 | }, 9 | "dependencies": { 10 | "@actions/core": "^1.10.1", 11 | "@actions/github": "^6.0.0", 12 | "@octokit/core": "^5.0.1", 13 | "@octokit/plugin-request-log": "^4.0.0", 14 | "@octokit/plugin-rest-endpoint-methods": "^10.2.0", 15 | "@vercel/ncc": "^0.38.1", 16 | "ncc": "", 17 | "pre-commit": "^1.2.2", 18 | "toml": "^3.0.0" 19 | }, 20 | "devDependencies": { 21 | "@types/bun": "latest" 22 | }, 23 | "peerDependencies": { 24 | "typescript": "^5.0.0" 25 | }, 26 | "pre-commit": ["pre-commit"] 27 | } 28 | -------------------------------------------------------------------------------- /src/replace_extension_toml_test.ts: -------------------------------------------------------------------------------- 1 | import { test, expect } from "bun:test"; 2 | import { updateVersion } from "./replace_extension_toml"; 3 | 4 | test("updateVersion", () => { 5 | let raw = ` 6 | [assembly] 7 | version = "0.0.1" 8 | submodule = "extensions/assembly" 9 | 10 | [beancount] 11 | submodule = "extensions/beancount" 12 | version = "0.0.1" 13 | `; 14 | 15 | expect(updateVersion(raw, "beancount", "0.1.2")).toEqual(` 16 | [assembly] 17 | version = "0.0.1" 18 | submodule = "extensions/assembly" 19 | 20 | [beancount] 21 | submodule = "extensions/beancount" 22 | version = "0.1.2" 23 | `); 24 | 25 | expect(updateVersion(raw, "assembly", "test")).toEqual(` 26 | [assembly] 27 | version = "test" 28 | submodule = "extensions/assembly" 29 | 30 | [beancount] 31 | submodule = "extensions/beancount" 32 | version = "0.0.1" 33 | `); 34 | }); 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Jason Lee. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/version.ts: -------------------------------------------------------------------------------- 1 | import { basename } from "path"; 2 | 3 | const RE = /([0-9]+)|([a-zA-Z]+)/g; 4 | 5 | function parse(ver: string): ReadonlyArray { 6 | const parts = []; 7 | for (const m of ver.matchAll(RE)) { 8 | parts.push(m[1] ? parseInt(m[1]) : m[2]); 9 | } 10 | if (parts[0] == "v") parts.shift(); 11 | return parts; 12 | } 13 | 14 | export function compare(v1: string, v2: string): -1 | 0 | 1 { 15 | const p1 = parse(v1); 16 | const p2 = parse(v2); 17 | const len = Math.min(p1.length, p2.length); 18 | for (let i = 0; i <= len; i++) { 19 | const n1 = p1[i] || 0; 20 | const n2 = p2[i] || 0; 21 | if (typeof n1 == typeof n2) { 22 | if (n1 < n2) return -1; 23 | if (n1 > n2) return 1; 24 | } else { 25 | return typeof n1 == "string" ? -1 : 1; 26 | } 27 | } 28 | return 0; 29 | } 30 | 31 | const ghDownloadRE = 32 | /^https:\/\/github.com\/[^/]+\/[^/]+\/releases\/download\/(.+)\/[^/]+$/; 33 | 34 | export function fromUrl(url: string): string { 35 | const downloadMatch = url.match(ghDownloadRE); 36 | if (downloadMatch) { 37 | return decodeURIComponent(downloadMatch[1]); 38 | } 39 | return basename(url).replace(/\.(tar\.gz|tgz|zip)$/, ""); 40 | } 41 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: bump-zed-extension 2 | description: "Bump Zed Extension after a new release" 3 | author: "@huacnlee" 4 | runs: 5 | using: node20 6 | main: "./lib/index.js" 7 | inputs: 8 | extension-name: 9 | description: The name of the Zed Extension (defaults to lower-cased repository name) 10 | extension-path: 11 | description: The path to the Zed Extension in zed/extensions repo (defaults to `extensions/`) 12 | tag: 13 | description: Git tag name to use for the extension update (defaults to the currently pushed tag) 14 | commit-message: 15 | description: The git commit message template to use when updating the formula 16 | default: | 17 | Update {{extensionName}} to v{{version}} 18 | 19 | Release notes: 20 | 21 | https://github.com/{{owner}}/{{repo}}/releases/tag/v{{version}} 22 | create-pullrequest: 23 | description: Set to a boolean value to either force or prohibit making a pull request to zed/extensions 24 | zed-extensions: 25 | description: The repository where the extension should be updated 26 | default: zed-industries/extensions 27 | push-to: 28 | description: An existing fork of the homebrew-tap repository where the edit should be pushed to (defaults to creating or reusing a personal fork) 29 | branding: 30 | icon: box 31 | color: orange 32 | -------------------------------------------------------------------------------- /src/version_test.ts: -------------------------------------------------------------------------------- 1 | import { expect, test } from "bun:test"; 2 | 3 | import { compare, fromUrl } from "./version"; 4 | 5 | test("fromUrl()", () => { 6 | const cases = new Map([ 7 | [ 8 | "https://github.com/me/myproject/archive/refs/tags/v1.2.3.tar.gz", 9 | "v1.2.3", 10 | ], 11 | [ 12 | "https://github.com/me/myproject/releases/download/v1.2.3/file.tgz", 13 | "v1.2.3", 14 | ], 15 | ["http://myproject.net/download/v1.2.3.tgz", "v1.2.3"], 16 | ["https://example.com/v1.2.3.zip", "v1.2.3"], 17 | [ 18 | "https://github.com/SmartThingsCommunity/smartthings-cli/releases/download/%40smartthings%2Fcli%401.7.0/smartthings-macos-arm64.tar.gz", 19 | "@smartthings/cli@1.7.0", 20 | ], 21 | [ 22 | "https://github.com/SmartThingsCommunity/smartthings-cli/releases/download/@smartthings/cli@1.7.0/smartthings-macos-x64.tar.gz", 23 | "@smartthings/cli@1.7.0", 24 | ], 25 | [ 26 | "https://github.com/orf/gping/archive/refs/tags/gping-v1.14.0.tar.gz", 27 | "gping-v1.14.0", 28 | ], 29 | ]); 30 | for (const item of cases) { 31 | expect(fromUrl(item[0])).toEqual(item[1]); 32 | } 33 | }); 34 | 35 | test("compare()", () => { 36 | expect(compare("v1.2.0", "v1.2.1")).toEqual(-1); 37 | expect(compare("v1.2.0", "v1.1.9.0")).toEqual(1); 38 | expect(compare("gping-v1.13", "gping-v1.14.0")).toEqual(-1); 39 | expect( 40 | compare("@smartthings/cli@1.7.0", "@smartthings/cli@1.7.0-rc2"), 41 | ).toEqual(1); 42 | expect(compare("@smartthings/cli@1.7.0", "@smartthings/cli@1.7.0")).toEqual( 43 | 0, 44 | ); 45 | expect(compare("@smartthings/cli@1.7.0", "@smartthings/cli@1.10.0")).toEqual( 46 | -1, 47 | ); 48 | }); 49 | -------------------------------------------------------------------------------- /src/github_test.ts: -------------------------------------------------------------------------------- 1 | import { test, expect, mock } from "bun:test"; 2 | import { resolveRef } from "./github"; 3 | 4 | // Mock API client 5 | const createMockAPI = () => ({ 6 | request: mock((endpoint: string, options: any) => { 7 | // Mock git refs lookup for tags only 8 | if (endpoint === "GET /repos/{owner}/{repo}/git/refs/{ref}") { 9 | if (options.ref === "tags/v1.0.0") { 10 | return Promise.resolve({ 11 | data: { object: { sha: "tag1234567890abcdef1234567890abcdef123456" } }, 12 | }); 13 | } 14 | if (options.ref === "tags/release-v2.0.0") { 15 | return Promise.resolve({ 16 | data: { object: { sha: "rel21234567890abcdef1234567890abcdef123456" } }, 17 | }); 18 | } 19 | return Promise.reject(new Error("Not found")); 20 | } 21 | 22 | return Promise.reject(new Error("Unexpected endpoint")); 23 | }), 24 | }); 25 | 26 | test("resolveRef - tag name", async () => { 27 | const api = createMockAPI() as any; 28 | const result = await resolveRef(api, "owner", "repo", "v1.0.0"); 29 | 30 | expect(result.sha).toBe("tag1234567890abcdef1234567890abcdef123456"); 31 | expect(result.type).toBe("tag"); 32 | }); 33 | 34 | test("resolveRef - full ref tags", async () => { 35 | const api = createMockAPI() as any; 36 | const result = await resolveRef(api, "owner", "repo", "refs/tags/release-v2.0.0"); 37 | 38 | expect(result.sha).toBe("rel21234567890abcdef1234567890abcdef123456"); 39 | expect(result.type).toBe("tag"); 40 | }); 41 | 42 | test("resolveRef - invalid tag", async () => { 43 | const api = createMockAPI() as any; 44 | 45 | expect(async () => { 46 | await resolveRef(api, "owner", "repo", "nonexistent-tag"); 47 | }).toThrow("Tag not found: nonexistent-tag"); 48 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zed Extensions GitHub Action 2 | 3 | This action for automatically bump Zed Extensions version after a release. 4 | 5 | ## Usage 6 | 7 | Create a `release.yml` file in `.github/workflows` directory with the following content: 8 | 9 | ```yml 10 | on: 11 | push: 12 | tags: 13 | - "v*" 14 | 15 | jobs: 16 | homebrew: 17 | name: Release Zed Extension 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: huacnlee/zed-extension-action@v2 21 | with: 22 | extension-name: your-extension-name 23 | # extension-path: extensions/${{ extension-name }} 24 | push-to: your-name/extensions 25 | env: 26 | # the personal access token should have "repo" & "workflow" scopes 27 | COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }} 28 | ``` 29 | 30 | ## Inputs 31 | 32 | | Name | Description | Required | Default | 33 | | ---------------- | ------------------------------------------------------------ | -------- | -------------------------------- | 34 | | `extension-name` | The name of your Zed extension. | `true` | - | 35 | | `extension-path` | If you have a different path, you can set it. | `false` | `extensions/${ extension-name }` | 36 | | `push-to` | The forked repository of the zed-industries/extensions repo. | `true` | - | 37 | | `tag` | Git tag name to use for the extension update | `false` | Currently pushed tag | 38 | 39 | ### Tag Support 40 | 41 | The `tag` parameter allows you to specify a specific git tag to use for the extension update: 42 | 43 | - **Tag names**: `v1.0.0` or `refs/tags/v1.0.0` 44 | 45 | When no `tag` parameter is provided, the action uses the currently pushed tag from the context. 46 | 47 | ### Examples 48 | 49 | **Using a specific tag:** 50 | 51 | ```yaml 52 | - uses: huacnlee/zed-extension-action@v2 53 | with: 54 | extension-name: your-extension-name 55 | tag: v1.2.3 56 | push-to: your-name/extensions 57 | ``` 58 | 59 | The `COMMITTER_TOKEN` is a personal access token with `repo` and `workflow` scopes. You can create one in your [GitHub settings](https://github.com/settings/tokens). 60 | 61 | ## How it works 62 | 63 | When a new tag is pushed, the action will: 64 | 65 | 1. Check if the tag is a valid version number. 66 | 2. Create a Pull Request with the new version to [Zed Extensions](https://github.com/zed-industries/extensions/pulls) repository. 67 | 3. Merge the Pull Request if it's approved, then the extension version will released. 68 | 69 | See example: https://github.com/zed-industries/extensions/pull/217 70 | 71 | ## License 72 | 73 | MIT 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore 2 | 3 | # Logs 4 | 5 | logs 6 | _.log 7 | npm-debug.log_ 8 | yarn-debug.log* 9 | yarn-error.log* 10 | lerna-debug.log* 11 | .pnpm-debug.log* 12 | 13 | # Caches 14 | 15 | .cache 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | 19 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 20 | 21 | # Runtime data 22 | 23 | pids 24 | _.pid 25 | _.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | 30 | lib-cov 31 | 32 | # Coverage directory used by tools like istanbul 33 | 34 | coverage 35 | *.lcov 36 | 37 | # nyc test coverage 38 | 39 | .nyc_output 40 | 41 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 42 | 43 | .grunt 44 | 45 | # Bower dependency directory (https://bower.io/) 46 | 47 | bower_components 48 | 49 | # node-waf configuration 50 | 51 | .lock-wscript 52 | 53 | # Compiled binary addons (https://nodejs.org/api/addons.html) 54 | 55 | build/Release 56 | 57 | # Dependency directories 58 | 59 | node_modules/ 60 | jspm_packages/ 61 | 62 | # Snowpack dependency directory (https://snowpack.dev/) 63 | 64 | web_modules/ 65 | 66 | # TypeScript cache 67 | 68 | *.tsbuildinfo 69 | 70 | # Optional npm cache directory 71 | 72 | .npm 73 | 74 | # Optional eslint cache 75 | 76 | .eslintcache 77 | 78 | # Optional stylelint cache 79 | 80 | .stylelintcache 81 | 82 | # Microbundle cache 83 | 84 | .rpt2_cache/ 85 | .rts2_cache_cjs/ 86 | .rts2_cache_es/ 87 | .rts2_cache_umd/ 88 | 89 | # Optional REPL history 90 | 91 | .node_repl_history 92 | 93 | # Output of 'npm pack' 94 | 95 | *.tgz 96 | 97 | # Yarn Integrity file 98 | 99 | .yarn-integrity 100 | 101 | # dotenv environment variable files 102 | 103 | .env 104 | .env.development.local 105 | .env.test.local 106 | .env.production.local 107 | .env.local 108 | 109 | # parcel-bundler cache (https://parceljs.org/) 110 | 111 | .parcel-cache 112 | 113 | # Next.js build output 114 | 115 | .next 116 | out 117 | 118 | # Nuxt.js build / generate output 119 | 120 | .nuxt 121 | dist 122 | 123 | # Gatsby files 124 | 125 | # Comment in the public line in if your project uses Gatsby and not Next.js 126 | 127 | # https://nextjs.org/blog/next-9-1#public-directory-support 128 | 129 | # public 130 | 131 | # vuepress build output 132 | 133 | .vuepress/dist 134 | 135 | # vuepress v2.x temp and cache directory 136 | 137 | .temp 138 | 139 | # Docusaurus cache and generated files 140 | 141 | .docusaurus 142 | 143 | # Serverless directories 144 | 145 | .serverless/ 146 | 147 | # FuseBox cache 148 | 149 | .fusebox/ 150 | 151 | # DynamoDB Local files 152 | 153 | .dynamodb/ 154 | 155 | # TernJS port file 156 | 157 | .tern-port 158 | 159 | # Stores VSCode versions used for testing VSCode extensions 160 | 161 | .vscode-test 162 | 163 | # yarn v2 164 | 165 | .yarn/cache 166 | .yarn/unplugged 167 | .yarn/build-state.yml 168 | .yarn/install-state.gz 169 | .pnp.* 170 | 171 | # IntelliJ based IDEs 172 | .idea 173 | 174 | # Finder (MacOS) folder config 175 | .DS_Store 176 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { getInput, getBooleanInput, isDebug } from "@actions/core"; 2 | import type { API } from "./github"; 3 | import { resolveRef } from "./github"; 4 | import editGitHubBlob from "./edit_github_blob"; 5 | import { EditOptions } from "./edit_github_blob"; 6 | import { removeRevisionLine, updateVersion } from "./replace_extension_toml"; 7 | import { context } from "@actions/github"; 8 | import { commitForRelease, getExtensionPath } from "./utils"; 9 | 10 | export default async function (api: (token: string) => API): Promise { 11 | const internalToken = 12 | process.env.GITHUB_TOKEN || process.env.COMMITTER_TOKEN || ""; 13 | const externalToken = process.env.COMMITTER_TOKEN || ""; 14 | 15 | const options = await prepareEdit(api(internalToken), api(externalToken)); 16 | const createdUrl = await editGitHubBlob(options); 17 | console.log(createdUrl); 18 | } 19 | 20 | export async function prepareEdit( 21 | sameRepoClient: API, 22 | crossRepoClient: API, 23 | ): Promise { 24 | // Get the tag to use 25 | const inputTag = getInput("tag"); 26 | let resolvedSha: string; 27 | let tagName: string; 28 | 29 | if (inputTag) { 30 | // Use the provided tag parameter 31 | tagName = inputTag; 32 | // Resolve the tag to get the commit SHA 33 | const resolved = await resolveRef( 34 | sameRepoClient, 35 | context.repo.owner, 36 | context.repo.repo, 37 | tagName, 38 | ); 39 | resolvedSha = resolved.sha; 40 | } else { 41 | // Fall back to context.ref and context.sha 42 | if (!context.ref.startsWith("refs/tags/")) { 43 | throw new Error(`invalid ref: ${context.ref}. Expected a tag reference when no tag is provided.`); 44 | } 45 | tagName = context.ref.replace("refs/tags/", ""); 46 | resolvedSha = context.sha; 47 | } 48 | 49 | const [owner, repo] = getInput("zed-extensions", { required: true }).split( 50 | "/", 51 | ); 52 | 53 | let pushTo: { owner: string; repo: string } | undefined; 54 | const pushToSpec = getInput("push-to"); 55 | if (pushToSpec) { 56 | const [pushToOwner, pushToRepo] = pushToSpec.split("/"); 57 | pushTo = { owner: pushToOwner, repo: pushToRepo }; 58 | } else if ( 59 | owner.toLowerCase() == context.repo.owner.toLowerCase() && 60 | repo.toLowerCase() == context.repo.repo.toLowerCase() 61 | ) { 62 | // If the homebrew-tap to update is the same repository that is running the Actions workflow, 63 | // explicitly set the same repository as the push-to target to skip any attempt of making a 64 | // fork of the repository. This is because a generated GITHUB_TOKEN would still appear as it 65 | // doesn't have permissions to push to homebrew-tap, even though it does. 66 | pushTo = context.repo; 67 | } 68 | const extensionName = 69 | getInput("extension-name") || context.repo.repo.toLowerCase(); 70 | const branch = getInput("base-branch"); 71 | const extensionPath = 72 | getInput("extension-path") || getExtensionPath(extensionName); 73 | const version = tagName.replace(/^v(\d)/, "$1"); 74 | 75 | const messageTemplate = getInput("commit-message", { required: true }); 76 | 77 | let makePR: boolean | undefined; 78 | if (getInput("create-pullrequest")) { 79 | makePR = getBooleanInput("create-pullrequest"); 80 | } 81 | 82 | const replacements = new Map(); 83 | replacements.set("version", version); 84 | 85 | if (isDebug()) { 86 | console.log("context", context); 87 | } 88 | 89 | const commitMessage = commitForRelease(messageTemplate, { 90 | owner: context.repo.owner, 91 | repo: context.repo.repo, 92 | extensionName, 93 | version, 94 | }); 95 | 96 | return { 97 | apiClient: crossRepoClient, 98 | owner, 99 | repo, 100 | branch, 101 | extensionPath, 102 | commitMessage, 103 | pushTo, 104 | makePR, 105 | submoduleCommitSha: resolvedSha, 106 | replace(oldContent: string) { 107 | return removeRevisionLine( 108 | updateVersion(oldContent, extensionName, version), 109 | ); 110 | }, 111 | }; 112 | } 113 | -------------------------------------------------------------------------------- /src/edit_github_blob.ts: -------------------------------------------------------------------------------- 1 | import type { API } from "./github"; 2 | import { basename } from "path"; 3 | import { updateRepo } from "./github"; 4 | 5 | // avoid importing @octokit/request-error to not have to keep it in sync in package.json 6 | interface RequestError { 7 | status: number; 8 | } 9 | 10 | async function retry( 11 | times: number, 12 | delay: number, 13 | fn: () => Promise, 14 | ): Promise { 15 | try { 16 | return await fn(); 17 | } catch (err) { 18 | if (times > 0) { 19 | return new Promise((resolve): void => { 20 | setTimeout(() => { 21 | resolve(retry(times - 1, delay, fn)); 22 | }, delay); 23 | }); 24 | } 25 | throw err; 26 | } 27 | } 28 | 29 | export type EditOptions = { 30 | owner: string; 31 | repo: string; 32 | extensionPath: string; 33 | branch?: string; 34 | apiClient: API; 35 | submoduleCommitSha: string; 36 | replace: (oldContent: string) => string; 37 | commitMessage?: string; 38 | pushTo?: { 39 | owner: string; 40 | repo: string; 41 | }; 42 | makePR?: boolean; 43 | }; 44 | 45 | export default async function (params: EditOptions): Promise { 46 | const baseRepo = { 47 | owner: params.owner, 48 | repo: params.repo, 49 | }; 50 | let headRepo = params.pushTo == null ? baseRepo : params.pushTo; 51 | const extensionPath = params.extensionPath; 52 | const api = params.apiClient.rest; 53 | 54 | const repoRes = await api.repos.get(baseRepo); 55 | const makeFork = 56 | params.pushTo == null && 57 | (repoRes.data.permissions == null || !repoRes.data.permissions.push); 58 | const inFork = 59 | makeFork || 60 | `${baseRepo.owner}/${baseRepo.repo}`.toLowerCase() != 61 | `${headRepo.owner}/${headRepo.repo}`.toLowerCase(); 62 | 63 | const baseBranch = params.branch 64 | ? params.branch 65 | : repoRes.data.default_branch; 66 | let headBranch = baseBranch; 67 | const branchRes = await api.repos.getBranch({ 68 | ...baseRepo, 69 | branch: baseBranch, 70 | }); 71 | const needsBranch = 72 | inFork || branchRes.data.protected || params.makePR === true; 73 | 74 | if (makeFork) { 75 | const res = await Promise.all([ 76 | api.repos.createFork(baseRepo), 77 | api.users.getAuthenticated(), 78 | ]); 79 | headRepo = { 80 | owner: res[1].data.login, 81 | repo: baseRepo.repo, 82 | }; 83 | } 84 | 85 | if (needsBranch) { 86 | const timestamp = Math.round(Date.now() / 1000); 87 | headBranch = `update-${basename(extensionPath)}-${timestamp}`; 88 | if (inFork) { 89 | try { 90 | await api.repos.mergeUpstream({ 91 | ...headRepo, 92 | branch: repoRes.data.default_branch, 93 | }); 94 | } catch (err) { 95 | if ((err as RequestError).status === 409) { 96 | // ignore 97 | } else { 98 | throw err; 99 | } 100 | } 101 | } 102 | await retry(makeFork ? 6 : 0, 5000, async () => { 103 | await api.git.createRef({ 104 | ...headRepo, 105 | ref: `refs/heads/${headBranch}`, 106 | sha: branchRes.data.commit.sha, 107 | }); 108 | }); 109 | } 110 | 111 | // Get extensions.toml data and replace to newContent 112 | const fileRes = await api.repos.getContent({ 113 | ...headRepo, 114 | path: "extensions.toml", 115 | ref: headBranch, 116 | }); 117 | const fileData = fileRes.data; 118 | if (Array.isArray(fileData)) { 119 | throw new Error(`expected 'extensions.toml' is a file, got a directory`); 120 | } 121 | const content = ("content" in fileData && fileData.content) || ""; 122 | const contentBuf = Buffer.from(content, "base64"); 123 | 124 | const oldContent = contentBuf.toString("utf8"); 125 | const newContent = params.replace(oldContent); 126 | if (newContent == oldContent) { 127 | throw new Error("no replacements ocurred"); 128 | } 129 | 130 | const commitMessage = params.commitMessage 131 | ? params.commitMessage 132 | : `Update ${extensionPath}`; 133 | 134 | await updateRepo({ 135 | octokit: params.apiClient, 136 | owner: headRepo.owner, 137 | repo: headRepo.repo, 138 | headBranch, 139 | newContent, 140 | commitMessage, 141 | submoduleNewSha: params.submoduleCommitSha, 142 | extensionPath, 143 | }); 144 | 145 | if (needsBranch && params.makePR !== false) { 146 | const parts = commitMessage.split("\n\n"); 147 | const title = parts[0]; 148 | const body = parts.slice(1).join("\n\n"); 149 | 150 | const prRes = await api.pulls.create({ 151 | ...baseRepo, 152 | base: baseBranch, 153 | head: `${headRepo.owner}:${headBranch}`, 154 | title, 155 | body, 156 | }); 157 | return prRes.data.html_url; 158 | } else { 159 | return ""; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/github.ts: -------------------------------------------------------------------------------- 1 | import { isDebug } from "@actions/core"; 2 | import { Octokit } from "@octokit/core"; 3 | import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods"; 4 | import { requestLog } from "@octokit/plugin-request-log"; 5 | 6 | const GitHub = Octokit.plugin(restEndpointMethods, requestLog).defaults({ 7 | baseUrl: "https://api.github.com", 8 | }); 9 | 10 | export type API = InstanceType; 11 | 12 | type fetch = (url: string, options: fetchOptions) => Promise; 13 | type fetchOptions = { 14 | method: string; 15 | body: string | null; 16 | }; 17 | 18 | export default function ( 19 | token: string, 20 | options?: { logRequests?: boolean; fetch?: fetch }, 21 | ): API { 22 | return new GitHub({ 23 | request: { fetch: options && options.fetch }, 24 | auth: `token ${token}`, 25 | log: { 26 | info(msg: string) { 27 | if (options && options.logRequests === false) return; 28 | return console.info(msg); 29 | }, 30 | debug(msg: string) { 31 | if (!isDebug()) return; 32 | return console.debug(msg); 33 | }, 34 | warn(msg: string) { 35 | return console.warn(msg); 36 | }, 37 | error(msg: string) { 38 | return console.error(msg); 39 | }, 40 | }, 41 | }); 42 | } 43 | 44 | /** 45 | * Resolve a git tag reference to its commit SHA 46 | * Handles tag names like "v1.0.0" or "refs/tags/v1.0.0" 47 | */ 48 | export async function resolveRef( 49 | octokit: API, 50 | owner: string, 51 | repo: string, 52 | tag: string, 53 | ): Promise<{ sha: string; type: 'tag' }> { 54 | // Handle full tag refs 55 | if (tag.startsWith('refs/tags/')) { 56 | const tagName = tag.replace('refs/tags/', ''); 57 | 58 | try { 59 | const { data } = await octokit.request("GET /repos/{owner}/{repo}/git/refs/{ref}", { 60 | owner, 61 | repo, 62 | ref: `tags/${tagName}`, 63 | }); 64 | return { sha: data.object.sha, type: 'tag' }; 65 | } catch (error) { 66 | throw new Error(`Tag not found: ${tag}`); 67 | } 68 | } 69 | 70 | // For bare tag names, look up as tag 71 | try { 72 | const { data } = await octokit.request("GET /repos/{owner}/{repo}/git/refs/{ref}", { 73 | owner, 74 | repo, 75 | ref: `tags/${tag}`, 76 | }); 77 | return { sha: data.object.sha, type: 'tag' }; 78 | } catch (error) { 79 | throw new Error(`Tag not found: ${tag}`); 80 | } 81 | } 82 | 83 | export async function createCommit( 84 | octokit: API, 85 | owner: string, 86 | repo: string, 87 | message: string, 88 | parentSha: string, 89 | treeSha: string, 90 | ): Promise { 91 | const { 92 | data: { sha }, 93 | } = await octokit.request("POST /repos/{owner}/{repo}/git/commits", { 94 | owner, 95 | repo, 96 | message, 97 | tree: treeSha, 98 | parents: [parentSha], 99 | }); 100 | 101 | return sha; 102 | } 103 | 104 | /** 105 | * Create or Update branch 106 | */ 107 | export async function createOrUpdateBranch( 108 | octokit: API, 109 | owner: string, 110 | repo: string, 111 | branch: string, 112 | newHead: string, 113 | ) { 114 | const branchExists = await octokit 115 | .request("GET /repos/{owner}/{repo}/branches/{branch}", { 116 | owner, 117 | repo, 118 | branch, 119 | }) 120 | .then( 121 | () => true, 122 | () => false, 123 | ); 124 | 125 | if (branchExists) { 126 | await octokit.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}", { 127 | owner, 128 | repo, 129 | sha: newHead, 130 | ref: `heads/${branch}`, 131 | }); 132 | } else { 133 | await octokit.request("POST /repos/{owner}/{repo}/git/refs", { 134 | owner, 135 | repo, 136 | sha: newHead, 137 | ref: `refs/heads/${branch}`, 138 | }); 139 | } 140 | } 141 | 142 | export async function updateRepo(options: { 143 | octokit: API; 144 | owner: string; 145 | repo: string; 146 | headBranch: string; 147 | newContent: string; 148 | commitMessage: string; 149 | extensionPath: string; 150 | submoduleNewSha: string; 151 | }) { 152 | const { 153 | octokit, 154 | owner, 155 | repo, 156 | headBranch, 157 | newContent, 158 | commitMessage, 159 | submoduleNewSha, 160 | extensionPath, 161 | } = options; 162 | 163 | const { data: branch } = await octokit.rest.repos.getBranch({ 164 | owner, 165 | repo, 166 | branch: headBranch, 167 | }); 168 | 169 | const parentSha = branch.commit.sha; 170 | console.log("parentSha", parentSha); 171 | 172 | const tree = await octokit.request("POST /repos/{owner}/{repo}/git/trees", { 173 | owner, 174 | repo, 175 | base_tree: parentSha, 176 | tree: [ 177 | { 178 | path: extensionPath, 179 | // The file mode; one of 100644 for file (blob), 100755 for executable (blob), 040000 for subdirectory (tree), 160000 for submodule (commit), or 120000 for a blob that specifies the path of a symlink. 180 | mode: "160000", 181 | type: "commit", 182 | sha: submoduleNewSha, 183 | }, 184 | { 185 | path: "extensions.toml", 186 | mode: "100644", 187 | type: "blob", 188 | content: newContent, 189 | }, 190 | ], 191 | }); 192 | const treeSha = tree.data.sha; 193 | console.log("treeSha", treeSha); 194 | 195 | // Commit 196 | const commitSha = await createCommit( 197 | octokit, 198 | owner, 199 | repo, 200 | commitMessage, 201 | parentSha, 202 | treeSha, 203 | ); 204 | 205 | await createOrUpdateBranch(octokit, owner, repo, headBranch, commitSha); 206 | } 207 | -------------------------------------------------------------------------------- /lib/sourcemap-register.cjs: -------------------------------------------------------------------------------- 1 | (()=>{var e={296:e=>{var r=Object.prototype.toString;var n=typeof Buffer!=="undefined"&&typeof Buffer.alloc==="function"&&typeof Buffer.allocUnsafe==="function"&&typeof Buffer.from==="function";function isArrayBuffer(e){return r.call(e).slice(8,-1)==="ArrayBuffer"}function fromArrayBuffer(e,r,t){r>>>=0;var o=e.byteLength-r;if(o<0){throw new RangeError("'offset' is out of bounds")}if(t===undefined){t=o}else{t>>>=0;if(t>o){throw new RangeError("'length' is out of bounds")}}return n?Buffer.from(e.slice(r,r+t)):new Buffer(new Uint8Array(e.slice(r,r+t)))}function fromString(e,r){if(typeof r!=="string"||r===""){r="utf8"}if(!Buffer.isEncoding(r)){throw new TypeError('"encoding" must be a valid string encoding')}return n?Buffer.from(e,r):new Buffer(e,r)}function bufferFrom(e,r,t){if(typeof e==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(e)){return fromArrayBuffer(e,r,t)}if(typeof e==="string"){return fromString(e,r)}return n?Buffer.from(e):new Buffer(e)}e.exports=bufferFrom},599:(e,r,n)=>{e=n.nmd(e);var t=n(927).SourceMapConsumer;var o=n(928);var i;try{i=n(896);if(!i.existsSync||!i.readFileSync){i=null}}catch(e){}var a=n(296);function dynamicRequire(e,r){return e.require(r)}var u=false;var s=false;var l=false;var c="auto";var p={};var f={};var g=/^data:application\/json[^,]+base64,/;var d=[];var h=[];function isInBrowser(){if(c==="browser")return true;if(c==="node")return false;return typeof window!=="undefined"&&typeof XMLHttpRequest==="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function hasGlobalProcessEventEmitter(){return typeof process==="object"&&process!==null&&typeof process.on==="function"}function globalProcessVersion(){if(typeof process==="object"&&process!==null){return process.version}else{return""}}function globalProcessStderr(){if(typeof process==="object"&&process!==null){return process.stderr}}function globalProcessExit(e){if(typeof process==="object"&&process!==null&&typeof process.exit==="function"){return process.exit(e)}}function handlerExec(e){return function(r){for(var n=0;n"}var n=this.getLineNumber();if(n!=null){r+=":"+n;var t=this.getColumnNumber();if(t){r+=":"+t}}}var o="";var i=this.getFunctionName();var a=true;var u=this.isConstructor();var s=!(this.isToplevel()||u);if(s){var l=this.getTypeName();if(l==="[object Object]"){l="null"}var c=this.getMethodName();if(i){if(l&&i.indexOf(l)!=0){o+=l+"."}o+=i;if(c&&i.indexOf("."+c)!=i.length-c.length-1){o+=" [as "+c+"]"}}else{o+=l+"."+(c||"")}}else if(u){o+="new "+(i||"")}else if(i){o+=i}else{o+=r;a=false}if(a){o+=" ("+r+")"}return o}function cloneCallSite(e){var r={};Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(n){r[n]=/^(?:is|get)/.test(n)?function(){return e[n].call(e)}:e[n]}));r.toString=CallSiteToString;return r}function wrapCallSite(e,r){if(r===undefined){r={nextPosition:null,curPosition:null}}if(e.isNative()){r.curPosition=null;return e}var n=e.getFileName()||e.getScriptNameOrSourceURL();if(n){var t=e.getLineNumber();var o=e.getColumnNumber()-1;var i=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;var a=i.test(globalProcessVersion())?0:62;if(t===1&&o>a&&!isInBrowser()&&!e.isEval()){o-=a}var u=mapSourcePosition({source:n,line:t,column:o});r.curPosition=u;e=cloneCallSite(e);var s=e.getFunctionName;e.getFunctionName=function(){if(r.nextPosition==null){return s()}return r.nextPosition.name||s()};e.getFileName=function(){return u.source};e.getLineNumber=function(){return u.line};e.getColumnNumber=function(){return u.column+1};e.getScriptNameOrSourceURL=function(){return u.source};return e}var l=e.isEval()&&e.getEvalOrigin();if(l){l=mapEvalOrigin(l);e=cloneCallSite(e);e.getEvalOrigin=function(){return l};return e}return e}function prepareStackTrace(e,r){if(l){p={};f={}}var n=e.name||"Error";var t=e.message||"";var o=n+": "+t;var i={nextPosition:null,curPosition:null};var a=[];for(var u=r.length-1;u>=0;u--){a.push("\n at "+wrapCallSite(r[u],i));i.nextPosition=i.curPosition}i.curPosition=i.nextPosition=null;return o+a.reverse().join("")}function getErrorSource(e){var r=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(e.stack);if(r){var n=r[1];var t=+r[2];var o=+r[3];var a=p[n];if(!a&&i&&i.existsSync(n)){try{a=i.readFileSync(n,"utf8")}catch(e){a=""}}if(a){var u=a.split(/(?:\r\n|\r|\n)/)[t-1];if(u){return n+":"+t+"\n"+u+"\n"+new Array(o).join(" ")+"^"}}}return null}function printErrorAndExit(e){var r=getErrorSource(e);var n=globalProcessStderr();if(n&&n._handle&&n._handle.setBlocking){n._handle.setBlocking(true)}if(r){console.error();console.error(r)}console.error(e.stack);globalProcessExit(1)}function shimEmitUncaughtException(){var e=process.emit;process.emit=function(r){if(r==="uncaughtException"){var n=arguments[1]&&arguments[1].stack;var t=this.listeners(r).length>0;if(n&&!t){return printErrorAndExit(arguments[1])}}return e.apply(this,arguments)}}var S=d.slice(0);var _=h.slice(0);r.wrapCallSite=wrapCallSite;r.getErrorSource=getErrorSource;r.mapSourcePosition=mapSourcePosition;r.retrieveSourceMap=v;r.install=function(r){r=r||{};if(r.environment){c=r.environment;if(["node","browser","auto"].indexOf(c)===-1){throw new Error("environment "+c+" was unknown. Available options are {auto, browser, node}")}}if(r.retrieveFile){if(r.overrideRetrieveFile){d.length=0}d.unshift(r.retrieveFile)}if(r.retrieveSourceMap){if(r.overrideRetrieveSourceMap){h.length=0}h.unshift(r.retrieveSourceMap)}if(r.hookRequire&&!isInBrowser()){var n=dynamicRequire(e,"module");var t=n.prototype._compile;if(!t.__sourceMapSupport){n.prototype._compile=function(e,r){p[r]=e;f[r]=undefined;return t.call(this,e,r)};n.prototype._compile.__sourceMapSupport=true}}if(!l){l="emptyCacheBetweenOperations"in r?r.emptyCacheBetweenOperations:false}if(!u){u=true;Error.prepareStackTrace=prepareStackTrace}if(!s){var o="handleUncaughtExceptions"in r?r.handleUncaughtExceptions:true;try{var i=dynamicRequire(e,"worker_threads");if(i.isMainThread===false){o=false}}catch(e){}if(o&&hasGlobalProcessEventEmitter()){s=true;shimEmitUncaughtException()}}};r.resetRetrieveHandlers=function(){d.length=0;h.length=0;d=S.slice(0);h=_.slice(0);v=handlerExec(h);m=handlerExec(d)}},517:(e,r,n)=>{var t=n(297);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(158);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},24:(e,r,n)=>{var t=n(297);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.P=MappingList},299:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(297);var i=n(197);var a=n(517).C;var u=n(818);var s=n(299).g;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}}),this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){v.source=l+_[1];l+=_[1];v.originalLine=i+_[2];i=v.originalLine;v.originalLine+=1;v.originalColumn=a+_[3];a=v.originalColumn;if(_.length>4){v.name=c+_[4];c+=_[4]}}m.push(v);if(typeof v.originalLine==="number"){h.push(v)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(h,o.compareByOriginalPositions);this.__originalMappings=h};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,a)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new a;this._names=new a;var u={line:-1,column:0};this._sections=i.map((function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(818);var o=n(297);var i=n(517).C;var a=n(24).P;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new a;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping((function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)}));e.sources.forEach((function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=new i;this._mappings.unsortedForEach((function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(a!=null){r.source=o.relative(a,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,r)}this.setSourceContent(r,t)}}),this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var a=0;var u=0;var s="";var l;var c;var p;var f;var g=this._mappings.toArray();for(var d=0,h=g.length;d0){if(!o.compareByGeneratedPositionsInflated(c,g[d-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);l+=t.encode(f-u);u=f;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.x=SourceMapGenerator},565:(e,r,n)=>{var t;var o=n(163).x;var i=n(297);var a=/(\r?\n)/;var u=10;var s="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[s]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var o=e.split(a);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[s]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL},927:(e,r,n)=>{n(163).x;r.SourceMapConsumer=n(684).SourceMapConsumer;n(565)},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}};var r={};function __webpack_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={id:n,loaded:false,exports:{}};var i=true;try{e[n](o,o.exports,__webpack_require__);i=false}finally{if(i)delete r[n]}o.loaded=true;return o.exports}(()=>{__webpack_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __webpack_require__!=="undefined")__webpack_require__.ab=__dirname+"/";var n={};__webpack_require__(599).install();module.exports=n})(); --------------------------------------------------------------------------------