@yukiakai/actions-git 1.0.2 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/{index.d.cts → public.d.ts} +1 -3
- package/dist/{index.js → public.js} +1 -1
- package/package.json +77 -72
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -34
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Yuki Akai
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yuki Akai
|
|
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.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ExecOptions } from '@actions/exec';
|
|
2
2
|
|
|
3
|
-
type GitExecOptions = Omit<ExecOptions, 'cwd'>;
|
|
4
|
-
type GitInspectableOptions = Omit<GitExecOptions, 'ignoreReturnCode'>;
|
|
5
3
|
interface GitExecResult {
|
|
6
4
|
exitCode: number;
|
|
7
5
|
}
|
|
@@ -31,4 +29,4 @@ declare class GitClient {
|
|
|
31
29
|
private branchExists;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
export { GitClient, type
|
|
32
|
+
export { GitClient, type GitOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exec as
|
|
1
|
+
import{exec as a}from"@actions/exec";var i=class{constructor(t){this.options=t}get repoUrl(){let{repo:t,token:e}=this.options;return`https://x-access-token:${e}@github.com/${t}.git`}async execGitRaw(t,e){return{exitCode:await a("git",t,e)}}async execGit(t,e){return await this.execGitRaw(t,{cwd:this.options.cwd,...e})}async execGitInspectable(t,e){return await this.execGit(t,{...e,ignoreReturnCode:!0})}async clone(){let{branch:t,cwd:e}=this.options;(await this.execGitRaw(["clone","--depth=1","--branch",t,this.repoUrl,e],{ignoreReturnCode:!0})).exitCode!==0&&await this.execGitRaw(["clone",this.repoUrl,e])}async wipe(t){await this.execGit(["rm","-r","-f","--ignore-unmatch",...t]),await this.execGit(["clean","-fdx","--",...t])}async setup(){await this.execGit(["config","user.name","github-actions[bot]"]),await this.execGit(["config","user.email","github-actions[bot]@users.noreply.github.com"])}async checkout(){let{branch:t}=this.options;await this.branchExists(t)?await this.execGit(["checkout",t]):(await this.execGit(["checkout","--orphan",t]),await this.wipe(["."]))}async pullRebase(){let{branch:t}=this.options;await this.execGit(["pull","--rebase","origin",t])}async commit(t){await this.execGit(["commit","-m",t])}async add(t){await this.execGit(["add",...t])}async push(){let{branch:t}=this.options;await this.execGit(["push","origin",t])}async hasChanges(){let t=await this.execGitInspectable(["diff","--cached","--quiet"]);if(t.exitCode===0)return!1;if(t.exitCode===1)return!0;throw new Error(`git diff failed with exit code ${t.exitCode}`)}async branchExists(t){let e=await this.execGitInspectable(["ls-remote","--exit-code","--heads","origin",t]);if(e.exitCode===0)return!0;if(e.exitCode===2)return!1;throw new Error(`Failed to check remote branch "${t}" (exit code ${e.exitCode})`)}};export{i as GitClient};
|
package/package.json
CHANGED
|
@@ -1,72 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@yukiakai/actions-git",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Lightweight Git client for GitHub Actions and CI workflows.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"types": "./dist/
|
|
8
|
-
"exports": {
|
|
9
|
-
"types": "./dist/
|
|
10
|
-
"import": "./dist/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"format": "prettier --
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"url": "https://github.com/yukiakai212/actions-git.js
|
|
50
|
-
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@yukiakai/actions-git",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Lightweight Git client for GitHub Actions and CI workflows.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/public.js",
|
|
7
|
+
"types": "./dist/public.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/public.d.ts",
|
|
10
|
+
"import": "./dist/public.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "npx vitest run --reporter verbose --coverage",
|
|
14
|
+
"format": "prettier --write **/*.{js,ts,json}",
|
|
15
|
+
"format:check": "prettier --check **/*.{js,ts,json}",
|
|
16
|
+
"lint": "eslint src/**/*.ts",
|
|
17
|
+
"typecheck:workspace": "tsc -p tsconfig.workspace.json",
|
|
18
|
+
"generate:types": "npx type-export-builder generate -p src/_public.ts",
|
|
19
|
+
"build": "npx tsup",
|
|
20
|
+
"build:public": "npm run generate:types && npx tsup --config tsup.public.config.ts",
|
|
21
|
+
"docs": "npx typedoc",
|
|
22
|
+
"prepare:artifact": "tsx workspace/release/prepareArtifact.ts",
|
|
23
|
+
"prepare": "is-ci || husky"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/*",
|
|
27
|
+
"CHANGELOG.md"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"actions",
|
|
31
|
+
"git",
|
|
32
|
+
"CI",
|
|
33
|
+
"typescript"
|
|
34
|
+
],
|
|
35
|
+
"author": "Yuki_akai",
|
|
36
|
+
"homepage": "https://github.com/yukiakai212/actions-git.js",
|
|
37
|
+
"funding": "https://github.com/sponsors/yukiakai212",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">= 16"
|
|
40
|
+
},
|
|
41
|
+
"maintainers": [
|
|
42
|
+
{
|
|
43
|
+
"name": "Yuki_akai",
|
|
44
|
+
"homepage": "https://github.com/yukiakai212"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/yukiakai212/actions-git.js.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/yukiakai212/actions-git.js/issues"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@changesets/cli": "^2.29.8",
|
|
57
|
+
"@eslint/js": "^9.30.1",
|
|
58
|
+
"@types/node": "^24.0.10",
|
|
59
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
60
|
+
"@yukiakai/artifact": "^1.0.1",
|
|
61
|
+
"dotenv": "^17.0.1",
|
|
62
|
+
"eslint": "^9.30.0",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"is-ci": "^4.1.0",
|
|
65
|
+
"prettier": "^3.6.2",
|
|
66
|
+
"tsup": "^8.5.1",
|
|
67
|
+
"tsx": "^4.20.3",
|
|
68
|
+
"type-export-builder": "^1.1.0",
|
|
69
|
+
"typedoc": "^0.28.9",
|
|
70
|
+
"typescript": "^5.8.3",
|
|
71
|
+
"typescript-eslint": "^8.35.1",
|
|
72
|
+
"vitest": "^4.0.15"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@actions/exec": "^3.0.0"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var u=(i,t)=>{for(var e in t)n(i,e,{get:t[e],enumerable:!0})},l=(i,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!x.call(i,s)&&s!==e&&n(i,s,{get:()=>t[s],enumerable:!(o=p(t,s))||o.enumerable});return i};var w=i=>l(n({},"__esModule",{value:!0}),i);var d={};u(d,{GitClient:()=>r});module.exports=w(d);var a=require("@actions/exec"),r=class{constructor(t){this.options=t}get repoUrl(){let{repo:t,token:e}=this.options;return`https://x-access-token:${e}@github.com/${t}.git`}async execGitRaw(t,e){return{exitCode:await(0,a.exec)("git",t,e)}}async execGit(t,e){return await this.execGitRaw(t,{cwd:this.options.cwd,...e})}async execGitInspectable(t,e){return await this.execGit(t,{...e,ignoreReturnCode:!0})}async clone(){let{branch:t,cwd:e}=this.options;(await this.execGitRaw(["clone","--depth=1","--branch",t,this.repoUrl,e],{ignoreReturnCode:!0})).exitCode!==0&&await this.execGitRaw(["clone",this.repoUrl,e])}async wipe(t){await this.execGit(["rm","-r","-f","--ignore-unmatch",...t]),await this.execGit(["clean","-fdx","--",...t])}async setup(){await this.execGit(["config","user.name","github-actions[bot]"]),await this.execGit(["config","user.email","github-actions[bot]@users.noreply.github.com"])}async checkout(){let{branch:t}=this.options;await this.branchExists(t)?await this.execGit(["checkout",t]):(await this.execGit(["checkout","--orphan",t]),await this.wipe(["."]))}async pullRebase(){let{branch:t}=this.options;await this.execGit(["pull","--rebase","origin",t])}async commit(t){await this.execGit(["commit","-m",t])}async add(t){await this.execGit(["add",...t])}async push(){let{branch:t}=this.options;await this.execGit(["push","origin",t])}async hasChanges(){let t=await this.execGitInspectable(["diff","--cached","--quiet"]);if(t.exitCode===0)return!1;if(t.exitCode===1)return!0;throw new Error(`git diff failed with exit code ${t.exitCode}`)}async branchExists(t){let e=await this.execGitInspectable(["ls-remote","--exit-code","--heads","origin",t]);if(e.exitCode===0)return!0;if(e.exitCode===2)return!1;throw new Error(`Failed to check remote branch "${t}" (exit code ${e.exitCode})`)}};0&&(module.exports={GitClient});
|
package/dist/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ExecOptions } from '@actions/exec';
|
|
2
|
-
|
|
3
|
-
type GitExecOptions = Omit<ExecOptions, 'cwd'>;
|
|
4
|
-
type GitInspectableOptions = Omit<GitExecOptions, 'ignoreReturnCode'>;
|
|
5
|
-
interface GitExecResult {
|
|
6
|
-
exitCode: number;
|
|
7
|
-
}
|
|
8
|
-
interface GitOptions {
|
|
9
|
-
cwd: string;
|
|
10
|
-
repo: string;
|
|
11
|
-
branch: string;
|
|
12
|
-
token: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare class GitClient {
|
|
16
|
-
private options;
|
|
17
|
-
constructor(options: GitOptions);
|
|
18
|
-
private get repoUrl();
|
|
19
|
-
protected execGitRaw(args: string[], options?: ExecOptions): Promise<GitExecResult>;
|
|
20
|
-
private execGit;
|
|
21
|
-
private execGitInspectable;
|
|
22
|
-
clone(): Promise<void>;
|
|
23
|
-
wipe(pattern: string[]): Promise<void>;
|
|
24
|
-
setup(): Promise<void>;
|
|
25
|
-
checkout(): Promise<void>;
|
|
26
|
-
pullRebase(): Promise<void>;
|
|
27
|
-
commit(message: string): Promise<void>;
|
|
28
|
-
add(pattern: string[]): Promise<void>;
|
|
29
|
-
push(): Promise<void>;
|
|
30
|
-
hasChanges(): Promise<boolean>;
|
|
31
|
-
private branchExists;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { GitClient, type GitExecOptions, type GitExecResult, type GitInspectableOptions, type GitOptions };
|