@simplysf/simply-cicd-core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/vcs/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuC,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAqB,EAAE,OAA2B;IACpF,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,iBAAiB,CAAC,IAAqB,EAAE,OAA2B;IAClF,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,oBAAoB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAc,6CAA6C,KAAK,GAAG,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,136 @@
1
+ /** The set of source-control-hosting platforms `simply-cicd` knows how to talk to. */
2
+ export type VcsProviderKind = 'gitlab' | 'github';
3
+ /** A repository/project, normalized across VCS platforms. */
4
+ export type VcsProject = {
5
+ id: number;
6
+ /**
7
+ * How this provider addresses the project in its own API: the numeric ID for GitLab,
8
+ * `owner/repo` for GitHub. Prefer this over `id` when passing a project to provider methods.
9
+ */
10
+ key: string;
11
+ name: string;
12
+ pathWithNamespace: string;
13
+ defaultBranch?: string;
14
+ archived: boolean;
15
+ empty: boolean;
16
+ isFork: boolean;
17
+ /** The raw, platform-specific API response this was derived from. */
18
+ raw: unknown;
19
+ };
20
+ /**
21
+ * A project as accepted by `VcsProvider` methods: either a normalized `VcsProject` or a bare
22
+ * provider-native key (a GitLab numeric ID, a GitHub `owner/repo`).
23
+ */
24
+ export type VcsProjectRef = string | number | Pick<VcsProject, 'key'>;
25
+ /** A branch, normalized across VCS platforms. */
26
+ export type VcsBranch = {
27
+ name: string;
28
+ raw: unknown;
29
+ };
30
+ /** The result of a file-content commit, normalized across VCS platforms. */
31
+ export type VcsCommit = {
32
+ id?: string;
33
+ raw: unknown;
34
+ };
35
+ /** A single commit as returned by a ref-to-ref comparison, normalized across VCS platforms. */
36
+ export type VcsCommitLogEntry = {
37
+ sha?: string;
38
+ message: string;
39
+ raw: unknown;
40
+ };
41
+ /**
42
+ * A merge/pull request, normalized across VCS platforms. `iid` is the number the platform shows
43
+ * users and accepts in its per-request endpoints — GitLab's `iid`, GitHub's PR `number`.
44
+ */
45
+ export type VcsMergeRequest = {
46
+ id: number;
47
+ iid: number;
48
+ title: string;
49
+ description?: string;
50
+ sourceBranch: string;
51
+ targetBranch: string;
52
+ webUrl?: string;
53
+ raw: unknown;
54
+ };
55
+ /** A project/repo-level CI variable, normalized across VCS platforms. */
56
+ export type VcsProjectVariable = {
57
+ key: string;
58
+ value: string;
59
+ raw: unknown;
60
+ };
61
+ /**
62
+ * What a platform calls a proposed change, for user-facing log and message text. GitLab says
63
+ * "merge request"/"MR"; GitHub says "pull request"/"PR".
64
+ */
65
+ export type VcsTerminology = {
66
+ changeRequest: string;
67
+ changeRequestShort: string;
68
+ /** What the platform calls the repo-scoped CI variables read by `getProjectVariables`. */
69
+ projectVariable: string;
70
+ };
71
+ /** The upstream repository identity, as read from the platform's own CI environment variables. */
72
+ export type VcsCiContext = {
73
+ projectPath?: string;
74
+ projectId?: string;
75
+ };
76
+ /** Everything a provider needs to talk to a specific instance of its platform. */
77
+ export type VcsProviderOptions = {
78
+ /** The instance hostname, e.g. `gitlab.com` or `github.com`. */
79
+ host?: string;
80
+ token: string;
81
+ /** Overrides the provider's derived API base URL. Rarely needed outside self-hosted instances. */
82
+ apiUrl?: string;
83
+ /**
84
+ * What kind of token `token` is, so the provider can pick the right auth header. Only GitLab
85
+ * distinguishes: a personal/project access token uses `PRIVATE-TOKEN`, a `CI_JOB_TOKEN` uses
86
+ * `JOB-TOKEN`. Defaults to `'personal'`. GitHub ignores this — a `GITHUB_TOKEN` and a PAT both
87
+ * authenticate the same way.
88
+ */
89
+ tokenKind?: 'personal' | 'job';
90
+ };
91
+ /**
92
+ * A source-control-hosting platform client, abstracted so that commands never encode one
93
+ * platform's API shape, URL scheme, or vocabulary.
94
+ */
95
+ export interface VcsProvider {
96
+ readonly kind: VcsProviderKind;
97
+ /** The platform's vocabulary, for composing user-facing text. */
98
+ readonly terminology: VcsTerminology;
99
+ /** The instance hostname this provider was built for. */
100
+ readonly host: string;
101
+ /** The API base URL this provider talks to, derived from the host unless overridden. */
102
+ readonly apiUrl: string;
103
+ /** Reads the upstream repository's identity from this platform's CI environment variables. */
104
+ getCiContext(): VcsCiContext;
105
+ /** Lists all projects/repos under a group/org, including subgroups where the platform has them. */
106
+ listProjects(groupId: string | number): Promise<VcsProject[]>;
107
+ /** Fetches the raw content of a file from a project at a given ref. */
108
+ getFileContent(project: VcsProjectRef, filePath: string, ref: string): Promise<string>;
109
+ /** Lists the commits reachable from `to` but not from `from` (e.g. between two tags/SHAs). */
110
+ compareRefs(project: VcsProjectRef, from: string, to: string): Promise<VcsCommitLogEntry[]>;
111
+ /** Returns whether a branch exists in a project. */
112
+ branchExists(project: VcsProjectRef, branchName: string): Promise<boolean>;
113
+ /** Creates a branch from a reference point (usually the project's default branch). */
114
+ createBranch(project: VcsProjectRef, branchName: string, ref: string): Promise<VcsBranch>;
115
+ /** Commits new content for a single file to a branch. */
116
+ commitFile(project: VcsProjectRef, branchName: string, commitMessage: string, filePath: string, content: string): Promise<VcsCommit>;
117
+ /** Finds an existing open merge/pull request with the given source and target branch, if any. */
118
+ findOpenMergeRequest(project: VcsProjectRef, sourceBranch: string, targetBranch: string): Promise<VcsMergeRequest | undefined>;
119
+ /** Creates a new merge/pull request. */
120
+ createMergeRequest(project: VcsProjectRef, sourceBranch: string, targetBranch: string, title: string, description: string, labels?: string[]): Promise<VcsMergeRequest>;
121
+ /** Updates an existing merge/pull request's title, description, and labels. */
122
+ updateMergeRequest(project: VcsProjectRef, mergeRequest: VcsMergeRequest, title: string, description: string, labels?: string[]): Promise<VcsMergeRequest>;
123
+ /** Fetches project/repo-level CI variables. Returns an empty array if unreadable. */
124
+ getProjectVariables(project: VcsProjectRef): Promise<VcsProjectVariable[]>;
125
+ /**
126
+ * Builds the browser URL for a merge/pull request, given the project's own web URL. The path
127
+ * differs per platform — GitLab nests it under `/-/merge_requests/`, GitHub under `/pull/`.
128
+ */
129
+ buildChangeRequestUrl(projectUrl: string, changeRequestIid: string | number): string;
130
+ /** Builds a token-authenticated remote URL suitable for push/tag operations (e.g. `git remote add`). */
131
+ buildAuthenticatedRemoteUrl(token: string, projectPath: string): string;
132
+ /** Builds a CI-job-token-authenticated remote URL suitable for a read-only `git clone`. */
133
+ buildCiCloneUrl(ciJobToken: string, projectPath: string): string;
134
+ }
135
+ /** Constructs a provider for one instance of a platform. */
136
+ export type VcsProviderFactory = (options: VcsProviderOptions) => VcsProvider;
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vcs/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
package/package.json ADDED
@@ -0,0 +1,130 @@
1
+ {
2
+ "name": "@simplysf/simply-cicd-core",
3
+ "description": "ALM issue linking (Jira, GitLab Issues) and VCS API clients (GitHub, GitLab) — the library layer behind @simplysf/simply-cicd, published separately for direct consumption (e.g. a bot or script) without the CLI framework",
4
+ "version": "0.2.0",
5
+ "author": "@ClayChipps",
6
+ "homepage": "https://github.com/SimplySF/simply-node",
7
+ "bugs": "https://github.com/SimplySF/simply-node/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/SimplySF/simply-node",
11
+ "directory": "packages/simply-cicd-core"
12
+ },
13
+ "engines": {
14
+ "node": ">=22.0.0"
15
+ },
16
+ "files": [
17
+ "/lib"
18
+ ],
19
+ "keywords": [
20
+ "force",
21
+ "salesforce",
22
+ "sfdx",
23
+ "salesforcedx",
24
+ "sfdx-plugin",
25
+ "sf-plugin",
26
+ "sf",
27
+ "cicd"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "main": "./lib/index.js",
31
+ "types": "./lib/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./lib/index.d.ts",
35
+ "default": "./lib/index.js"
36
+ }
37
+ },
38
+ "type": "module",
39
+ "dependencies": {},
40
+ "devDependencies": {
41
+ "@vitest/coverage-v8": "^4.1.10",
42
+ "vitest": "^4.1.10"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "wireit": {
48
+ "build": {
49
+ "dependencies": [
50
+ "compile",
51
+ "lint"
52
+ ]
53
+ },
54
+ "compile": {
55
+ "command": "tsc -p . --pretty --incremental",
56
+ "files": [
57
+ "src/**/*.ts",
58
+ "**/tsconfig.json",
59
+ "../../tsconfig.json"
60
+ ],
61
+ "output": [
62
+ "lib/**",
63
+ "*.tsbuildinfo"
64
+ ],
65
+ "clean": "if-file-deleted"
66
+ },
67
+ "format": {
68
+ "command": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
69
+ "files": [
70
+ "src/**/*.ts",
71
+ "test/**/*.ts",
72
+ ".prettier*"
73
+ ],
74
+ "output": []
75
+ },
76
+ "lint": {
77
+ "command": "eslint src test --color --cache --cache-location .eslintcache",
78
+ "files": [
79
+ "src/**/*.ts",
80
+ "test/**/*.ts",
81
+ "**/.eslint*",
82
+ "**/tsconfig.json",
83
+ "../../eslint.config.mjs",
84
+ "../../tsconfig.json"
85
+ ],
86
+ "output": []
87
+ },
88
+ "test": {
89
+ "dependencies": [
90
+ "test:compile",
91
+ "test:only",
92
+ "lint"
93
+ ]
94
+ },
95
+ "test:compile": {
96
+ "command": "tsc -p \"./test\" --pretty",
97
+ "files": [
98
+ "test/**/*.ts",
99
+ "**/tsconfig.json",
100
+ "../../tsconfig.json"
101
+ ],
102
+ "output": []
103
+ },
104
+ "test:only": {
105
+ "command": "vitest run --project simply-cicd-core",
106
+ "env": {
107
+ "FORCE_COLOR": "2"
108
+ },
109
+ "files": [
110
+ "test/**/*.ts",
111
+ "src/**/*.ts",
112
+ "**/tsconfig.json",
113
+ "../../tsconfig.json",
114
+ "vitest.config.ts"
115
+ ],
116
+ "output": []
117
+ }
118
+ },
119
+ "scripts": {
120
+ "build": "wireit",
121
+ "compile": "wireit",
122
+ "fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
123
+ "format": "wireit",
124
+ "lint": "wireit",
125
+ "test": "wireit",
126
+ "test:coverage": "vitest run --coverage --project simply-cicd-core",
127
+ "test:only": "wireit",
128
+ "test:watch": "vitest watch --project simply-cicd-core"
129
+ }
130
+ }