@noldova/tools.pipelines.github 0.0.2 → 0.0.4

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,7 +1,7 @@
1
1
  # @noldova/tools.pipelines.github
2
2
 
3
3
  Runs the steps of `@noldova/tools.pipelines` on GitHub Actions.
4
- This version holds `pipelines`, the command line a workflow calls, with the source, archive, publish, nightly, prune and tag steps, and the prune and tag steps' access to GitHub's REST API.
4
+ This version holds `pipelines`, the command line a workflow calls, with the source, archive, publish, nightly, prune, tag, toolchain, line-endings, unchanged, reproducible and dependents steps, and the prune, tag and dependents steps' access to GitHub.
5
5
 
6
6
  ## Install
7
7
 
@@ -16,7 +16,7 @@ npm install @noldova/tools.pipelines.github
16
16
  A job installs the package at an exact version, without install scripts, and calls `pipelines` with a step's name and values in the checkout:
17
17
 
18
18
  ```yaml
19
- - run: npm install --global --ignore-scripts @noldova/tools.pipelines.github@0.0.2
19
+ - run: npm install --global --ignore-scripts @noldova/tools.pipelines.github@0.0.4
20
20
  - run: pipelines source "$VERSION" "$COMMIT"
21
21
  - id: nightly
22
22
  run: |
@@ -32,8 +32,14 @@ A job installs the package at an exact version, without install scripts, and cal
32
32
  | `nightly` | `<commit> <registry>` |
33
33
  | `prune` | `<version> <commit> <scope> <registry> <keep-versions>` |
34
34
  | `tag` | `<version> <commit>` |
35
+ | `toolchain` | `<node-version> [<npm-version>]` |
36
+ | `line-endings` | none |
37
+ | `unchanged` | none |
38
+ | `reproducible` | `<folder>` |
39
+ | `dependents` | `<version> <commit>` |
35
40
 
36
41
  `@noldova/tools.pipelines`'s README says what each step checks and does.
42
+ The reproducible and dependents steps make their temporary folders in `RUNNER_TEMP`, which the runner empties after each job, cancelled ones included.
37
43
 
38
44
  - A step that succeeds writes its message to standard output and exits with code `0`; an empty message, such as the nightly step's when nothing changed, writes nothing.
39
45
  - A step that fails writes its message as one error annotation, which the run's summary shows, and exits with code `1`; so does a first value that names no step, with the usage line of every step.
@@ -70,6 +76,39 @@ The job needs `permissions: packages: write`, and, since the step deletes, an en
70
76
  The step fails, naming the variable, when one is missing or empty, and with the request, the status and GitHub's message for an answer it doesn't expect, such as GitHub refusing to delete a package's last version.
71
77
  A 404 to a delete counts as a version already deleted only when GitHub's list no longer has it; otherwise the step fails.
72
78
 
79
+ ### The dependents step
80
+
81
+ `pipelines dependents <version> <commit>` proposes a release to the repositories that pin its packages, each in a pull request from the branch `pipelines/update-<repository>`, where `<repository>` is the releasing repository's name.
82
+ It runs in a checkout of the released commit, and reads `GITHUB_API_URL`, `GITHUB_SERVER_URL` and `GITHUB_REPOSITORY`, which GitHub Actions sets, and `GITHUB_TOKEN`, which the workflow passes in:
83
+
84
+ ```yaml
85
+ - env:
86
+ GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
87
+ GIT_AUTHOR_NAME: example[bot]
88
+ GIT_AUTHOR_EMAIL: 1+example[bot]@users.noreply.github.com
89
+ GIT_COMMITTER_NAME: example[bot]
90
+ GIT_COMMITTER_EMAIL: 1+example[bot]@users.noreply.github.com
91
+ run: pipelines dependents "$VERSION" "$COMMIT"
92
+ ```
93
+
94
+ - The token is a GitHub App installation's: the repositories the installation is given are the ones the step checks, except the releasing repository and archived ones.
95
+ It needs to write their contents, pull requests and issues, and is never written anywhere: git gets it through its environment, not its command line.
96
+ - The workflow sets the commits' author and committer, such as the App's bot account, through git's environment.
97
+ - npm refreshes each repository's lock files from the registries that repository names, without `GITHUB_TOKEN`; one that needs a token to read gets it from the workflow, as for an install.
98
+ - The release notes are the section of the pull request whose merge commit is the commit, headed `Release notes for <version>`; without one, the proposal has none.
99
+ - When the branch exists, the step replaces it, with `--force-with-lease`, only while it is at a commit of the step's own; then it updates the open pull request and its issue. Otherwise it opens an issue and a pull request that closes it, against the repository's default branch.
100
+ - The step fails, naming the variable, when one is missing or empty; it fails for a repository, after trying every other, with git's exit code and error output, or with the request, the status and GitHub's message for an answer it doesn't expect.
101
+
102
+ ### When GitHub is briefly unavailable
103
+
104
+ The prune, tag and dependents steps send a request again, up to two more times, waiting 5 and then 15 seconds, when GitHub answers 502, 503 or 504, doesn't answer within a minute, or the connection fails.
105
+ A failing answer with a `Retry-After` header of up to 60 seconds is sent again too, after that wait, such as a 403 for a rate limit.
106
+ Any other answer comes back at once, such as a 403 or 404 without that header, or any answer with a longer `Retry-After`.
107
+ The last answer, timeout or failed connection is what the step reports, naming the request.
108
+ These retries count per request, and nothing bounds a step's requests together, so the job's `timeout-minutes` is the bound; since a request can be sent twice, a rerun is safe.
109
+
110
+ A create or delete that GitHub carried out but whose answer was lost is sent again, and is done, not a failure: the tag step finds the tag at the commit after GitHub refuses the second create, and the prune step reports the version as already deleted after a 404 and a new list without it.
111
+
73
112
  ### From code
74
113
 
75
114
  ```ts
package/api/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- import type { IRegistryHost, IStepOutput, ITagHost, StepResult } from "@noldova/tools.pipelines";
9
+ import type { IRegistryHost, IStepOutput, ITagHost, IUpdateHost, ProcessRunner, StepResult } from "@noldova/tools.pipelines";
10
10
 
11
11
  /**
12
12
  * Writes a step's messages as a GitHub Actions job reads them: a success to
@@ -77,6 +77,13 @@ export declare class GitHubStepOutput implements IStepOutput {
77
77
  * `https://api.github.com`, and `GITHUB_TOKEN`, a token that may delete the
78
78
  * packages, with `packages: write`, which the workflow passes in. It sends
79
79
  * the token only to that API and never writes it anywhere.
80
+ *
81
+ * A request GitHub answers 502, 503 or 504, doesn't answer within the
82
+ * timeout, or loses the connection of, is sent again up to two more times,
83
+ * after 5 and then 15 seconds. A failing answer with a `Retry-After` header
84
+ * of up to 60 seconds is too, after that wait; one with a longer
85
+ * `Retry-After` is not, whatever its status. The last answer, timeout or
86
+ * lost connection is what the call gives.
80
87
  */
81
88
  export declare class GitHubPackages implements IRegistryHost {
82
89
  /**
@@ -91,6 +98,10 @@ export declare class GitHubPackages implements IRegistryHost {
91
98
  * @param environment The environment variables, such as `process.env`.
92
99
  * @param timeoutMilliseconds How long it waits for each answer of the API.
93
100
  * Omitted, it waits a minute.
101
+ * @param waitAsync How it waits before sending a request again, given the
102
+ * milliseconds. Omitted, it uses a timer.
103
+ * @param createSignal How it makes the signal that ends each attempt, given
104
+ * the timeout. Omitted, the signal is `AbortSignal.timeout`'s.
94
105
  * @example
95
106
  * ```ts
96
107
  * import { GitHubPackages } from "@noldova/tools.pipelines.github";
@@ -99,7 +110,7 @@ export declare class GitHubPackages implements IRegistryHost {
99
110
  * packages.registry; // "https://npm.pkg.github.com/"
100
111
  * ```
101
112
  */
102
- public constructor(environment: Readonly<Record<string, string | undefined>>, timeoutMilliseconds?: number);
113
+ public constructor(environment: Readonly<Record<string, string | undefined>>, timeoutMilliseconds?: number, waitAsync?: (milliseconds: number) => Promise<void>, createSignal?: (timeoutMilliseconds: number) => AbortSignal);
103
114
 
104
115
  /**
105
116
  * Lists every version of a package, reading GitHub's list a hundred at a
@@ -113,12 +124,10 @@ export declare class GitHubPackages implements IRegistryHost {
113
124
  * of the two environment variables is missing or empty, naming it; or
114
125
  * when GitHub answers with another status than 200, such as 404 for a
115
126
  * package it doesn't have or can't show, with the request, the status and
116
- * GitHub's message. It rejects with `JsonException`, from
117
- * `@noldova/context.json`, for an answer that is not a JSON list of
118
- * versions, each with a whole-number `id` and a `name` text, with a
119
- * `DOMException` named `TimeoutError` when GitHub doesn't answer within
120
- * the timeout, and with the error `fetch` gives when GitHub can't be
121
- * reached.
127
+ * GitHub's message; or when the last attempt times out or loses its
128
+ * connection, with the request and the reason. It rejects with
129
+ * `JsonException`, from `@noldova/context.json`, for an answer that is not
130
+ * a JSON list of versions, each with a whole-number `id` and a `name` text.
122
131
  * @example
123
132
  * ```ts
124
133
  * import { GitHubPackages } from "@noldova/tools.pipelines.github";
@@ -136,7 +145,8 @@ export declare class GitHubPackages implements IRegistryHost {
136
145
  * @param version The version's text, as the list gave it.
137
146
  * @returns A promise of `true` when GitHub deleted the version, `false`
138
147
  * when the list has no such version, or GitHub answers 404 and a new list
139
- * no longer has it, as after another run deleted it, or a failed
148
+ * no longer has it, as after another run or an earlier attempt whose answer
149
+ * was lost deleted it, or a failed
140
150
  * {@link StepResult} as {@link GitHubPackages.readVersionsAsync} gives
141
151
  * one, when GitHub answers 404 and a new list still has the version, or
142
152
  * when GitHub answers the delete with another status than 204, such as
@@ -164,6 +174,13 @@ export declare class GitHubPackages implements IRegistryHost {
164
174
  * such as `noldova-com/tools`; and `GITHUB_TOKEN`, a token that may write
165
175
  * the repository's contents, such as the job's own. It sends the token only
166
176
  * to that API and never writes it anywhere.
177
+ *
178
+ * A request GitHub answers 502, 503 or 504, doesn't answer within the
179
+ * timeout, or loses the connection of, is sent again up to two more times,
180
+ * after 5 and then 15 seconds. A failing answer with a `Retry-After` header
181
+ * of up to 60 seconds is too, after that wait; one with a longer
182
+ * `Retry-After` is not, whatever its status. The last answer, timeout or
183
+ * lost connection is what the call gives.
167
184
  */
168
185
  export declare class GitHubTags implements ITagHost {
169
186
  /**
@@ -172,6 +189,10 @@ export declare class GitHubTags implements ITagHost {
172
189
  * @param environment The environment variables, such as `process.env`.
173
190
  * @param timeoutMilliseconds How long it waits for each answer of the API.
174
191
  * Omitted, it waits a minute.
192
+ * @param waitAsync How it waits before sending a request again, given the
193
+ * milliseconds. Omitted, it uses a timer.
194
+ * @param createSignal How it makes the signal that ends each attempt, given
195
+ * the timeout. Omitted, the signal is `AbortSignal.timeout`'s.
175
196
  * @example
176
197
  * ```ts
177
198
  * import { GitHubTags } from "@noldova/tools.pipelines.github";
@@ -179,7 +200,7 @@ export declare class GitHubTags implements ITagHost {
179
200
  * const tags = new GitHubTags(process.env);
180
201
  * ```
181
202
  */
182
- public constructor(environment: Readonly<Record<string, string | undefined>>, timeoutMilliseconds?: number);
203
+ public constructor(environment: Readonly<Record<string, string | undefined>>, timeoutMilliseconds?: number, waitAsync?: (milliseconds: number) => Promise<void>, createSignal?: (timeoutMilliseconds: number) => AbortSignal);
183
204
 
184
205
  /**
185
206
  * Reads the commit a tag points to, following an annotated tag to its
@@ -192,11 +213,13 @@ export declare class GitHubTags implements ITagHost {
192
213
  * to something other than a commit, such as a tree; or when GitHub answers
193
214
  * with another status, with the request, the status and GitHub's message,
194
215
  * such as `GitHub answered GET repos/noldova-com/tools/git/ref/tags/v0.0.4
195
- * with 403: Resource not accessible by integration`. It rejects with
196
- * `JsonException`, from `@noldova/context.json`, for an answer that is not
197
- * the JSON GitHub documents, with a `DOMException` named `TimeoutError`
198
- * when GitHub doesn't answer within the timeout, and with the error `fetch`
199
- * gives when GitHub can't be reached.
216
+ * with 403: Resource not accessible by integration`; or when the last
217
+ * attempt times out or loses its connection, with the request and the
218
+ * reason, such as `GitHub gave no answer to GET
219
+ * repos/noldova-com/tools/git/ref/tags/v0.0.4: The operation was aborted
220
+ * due to timeout`. It rejects with `JsonException`, from
221
+ * `@noldova/context.json`, for an answer that is not the JSON GitHub
222
+ * documents.
200
223
  * @example
201
224
  * ```ts
202
225
  * import { GitHubTags } from "@noldova/tools.pipelines.github";
@@ -214,7 +237,8 @@ export declare class GitHubTags implements ITagHost {
214
237
  * @param commit The commit's full id.
215
238
  * @returns A promise of `true` when GitHub created the tag, or `false` when
216
239
  * GitHub refuses it as unprocessable, status 422, and reading the tag then
217
- * finds it, such as one another run made. Otherwise it is a failed
240
+ * finds it, such as one another run made, or an earlier attempt whose
241
+ * answer was lost. Otherwise it is a failed
218
242
  * {@link StepResult}, as {@link GitHubTags.readTagAsync} gives one: with the
219
243
  * 422's message when reading finds no tag, and with the read's failure when
220
244
  * the read fails. It rejects as {@link GitHubTags.readTagAsync} does.
@@ -228,6 +252,136 @@ export declare class GitHubTags implements ITagHost {
228
252
  public createTagAsync(tag: string, commit: string): Promise<boolean | StepResult>;
229
253
  }
230
254
 
255
+ /**
256
+ * The {@link IUpdateHost} on GitHub Actions: it reaches the repositories the
257
+ * job's token may, which for a GitHub App's installation token are the
258
+ * repositories the App is installed on. It reads `GITHUB_API_URL`,
259
+ * `GITHUB_SERVER_URL`, `GITHUB_REPOSITORY`, the repository that released, and
260
+ * `GITHUB_TOKEN`, the token, which needs read and write access to contents,
261
+ * issues and pull requests in every repository it updates.
262
+ *
263
+ * Git gets the token only through its environment, as an `AUTHORIZATION`
264
+ * header for the server, never in a command line or a URL; the commits'
265
+ * author and committer are what git's own variables, such as
266
+ * `GIT_AUTHOR_NAME`, name. Requests to the API are retried as
267
+ * {@link GitHubTags}' are.
268
+ */
269
+ export declare class GitHubUpdates implements IUpdateHost {
270
+ /**
271
+ * Creates the host over an environment, which it reads at each call.
272
+ *
273
+ * @param environment The environment variables, such as `process.env`.
274
+ * @param processRunner What runs git. Omitted, a new {@link ProcessRunner}.
275
+ * @param timeoutMilliseconds How long it waits for each answer of the API.
276
+ * Omitted, it waits a minute.
277
+ * @param waitAsync How it waits before sending a request again, given the
278
+ * milliseconds. Omitted, it uses a timer.
279
+ * @param createSignal How it makes the signal that ends each attempt, given
280
+ * the timeout. Omitted, the signal is `AbortSignal.timeout`'s.
281
+ * @example
282
+ * ```ts
283
+ * import { GitHubUpdates } from "@noldova/tools.pipelines.github";
284
+ *
285
+ * const updates = new GitHubUpdates(process.env);
286
+ * ```
287
+ */
288
+ public constructor(environment: Readonly<Record<string, string | undefined>>, processRunner?: ProcessRunner, timeoutMilliseconds?: number, waitAsync?: (milliseconds: number) => Promise<void>, createSignal?: (timeoutMilliseconds: number) => AbortSignal);
289
+
290
+ /**
291
+ * The variable that holds the token, `["GITHUB_TOKEN"]`, which npm doesn't
292
+ * get when the step refreshes lock files.
293
+ */
294
+ public readonly credentialVariables: readonly string[];
295
+
296
+ /**
297
+ * Reads the name of the repository that released, after its owner.
298
+ *
299
+ * @returns The name, such as `tools` for
300
+ * `noldova-com/tools`, or a failed {@link StepResult} naming the
301
+ * first of the four environment variables that is missing or empty.
302
+ */
303
+ public readSourceName(): string | StepResult;
304
+
305
+ /**
306
+ * Lists the repositories the token reaches, through
307
+ * `installation/repositories`, page by page, leaving out archived ones and
308
+ * the one that released.
309
+ *
310
+ * @returns A promise of their full names, sorted, or a failed
311
+ * {@link StepResult}: for a missing variable, or with the request, the
312
+ * status and GitHub's message when GitHub refuses, such as when the token
313
+ * isn't an installation's.
314
+ */
315
+ public listRepositoriesAsync(): Promise<readonly string[] | StepResult>;
316
+
317
+ /**
318
+ * Reads the release notes from the pull request that merged the commit:
319
+ * its section whose heading is `Release notes for <version>`, at any
320
+ * heading level, up to the next heading of that level or higher.
321
+ *
322
+ * @param version The version.
323
+ * @param commit The commit.
324
+ * @returns A promise of the section, `""` when no pull request lists the
325
+ * commit as its merge commit or its description has no such section, or a failed
326
+ * {@link StepResult}.
327
+ */
328
+ public readReleaseNotesAsync(version: string, commit: string): Promise<string | StepResult>;
329
+
330
+ /**
331
+ * Clones the repository's default branch, one commit deep, into the
332
+ * directory.
333
+ *
334
+ * @param repository The repository's full name.
335
+ * @param directory The directory, which doesn't exist yet.
336
+ * @returns A promise of `null` once cloned, or a failed {@link StepResult}
337
+ * with git's exit code and error output.
338
+ */
339
+ public checkOutAsync(repository: string, directory: string): Promise<StepResult | null>;
340
+
341
+ /**
342
+ * Finds the branch with `git ls-remote` and fetches its commit, one commit
343
+ * deep, into the clone.
344
+ *
345
+ * @param repository The repository's full name.
346
+ * @param directory The clone's directory.
347
+ * @param branch The branch.
348
+ * @returns A promise of the commit's full id, `null` when the repository
349
+ * has no such branch, or a failed {@link StepResult} with git's exit code
350
+ * and error output.
351
+ */
352
+ public fetchBranchAsync(repository: string, directory: string, branch: string): Promise<string | null | StepResult>;
353
+
354
+ /**
355
+ * Pushes the clone's `HEAD` to the branch: with `replaced` `null`, a plain
356
+ * push, which git refuses over a branch that holds other commits; with a
357
+ * commit, `--force-with-lease` on that commit, which git refuses once the
358
+ * branch has moved from it.
359
+ *
360
+ * @param repository The repository's full name.
361
+ * @param directory The clone's directory.
362
+ * @param branch The branch.
363
+ * @param replaced The commit the branch must still be at, or `null`.
364
+ * @returns A promise of `null` once pushed, or a failed {@link StepResult}
365
+ * with git's exit code and error output.
366
+ */
367
+ public pushAsync(repository: string, directory: string, branch: string, replaced: string | null): Promise<StepResult | null>;
368
+
369
+ /**
370
+ * Opens an issue with the title and a pull request from the branch into the
371
+ * default branch whose description ends with `Closes #<issue>`, or, when a
372
+ * pull request from the branch is open, gives it and the issue its
373
+ * description names the title, and the pull request the description.
374
+ *
375
+ * @param repository The repository's full name.
376
+ * @param branch The pushed branch.
377
+ * @param title The title.
378
+ * @param body The description, before its linked issue.
379
+ * @returns A promise of the pull request's address, or a failed
380
+ * {@link StepResult} with the request, the status and GitHub's message.
381
+ */
382
+ public proposeAsync(repository: string, branch: string, title: string, body: string): Promise<string | StepResult>;
383
+ }
384
+
231
385
  /**
232
386
  * The `pipelines` command line a GitHub Actions workflow calls: it runs the
233
387
  * source, archive, publish, nightly, prune and tag steps of
package/api/index.js CHANGED
@@ -8,5 +8,6 @@
8
8
  export { GitHubPackages } from "../services/github-packages.js";
9
9
  export { GitHubStepOutput } from "../services/github-step-output.js";
10
10
  export { GitHubTags } from "../services/github-tags.js";
11
+ export { GitHubUpdates } from "../services/github-updates.js";
11
12
  export { PipelinesProgram } from "../services/pipelines-program.js";
12
13
  //# sourceMappingURL=index.js.map
package/api/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -14,13 +14,15 @@ export class GitHubAnswer {
14
14
  status;
15
15
  statusText;
16
16
  contentType;
17
+ retryAfter;
17
18
  text;
18
- constructor(method, resource, status, statusText, contentType, text) {
19
+ constructor(method, resource, status, statusText, contentType, retryAfter, text) {
19
20
  this.method = method;
20
21
  this.resource = resource;
21
22
  this.status = status;
22
23
  this.statusText = statusText;
23
24
  this.contentType = contentType;
25
+ this.retryAfter = retryAfter;
24
26
  this.text = text;
25
27
  }
26
28
  readBody() {
@@ -44,6 +46,14 @@ export class GitHubAnswer {
44
46
  return text;
45
47
  return this.readBody().readOptionalString(Resources.messageField) ?? text;
46
48
  }
49
+ readRetryMilliseconds(unavailableMilliseconds) {
50
+ if (this.status < Resources.firstFailureStatus)
51
+ return null;
52
+ if (!Resources.retryAfterPattern.test(this.retryAfter))
53
+ return Resources.unavailableStatuses.includes(this.status) ? unavailableMilliseconds : null;
54
+ const seconds = Number(this.retryAfter);
55
+ return seconds <= Resources.retryAfterMaxSeconds ? seconds * Resources.millisecondsPerSecond : null;
56
+ }
47
57
  toFailure() {
48
58
  return StepResult.failed(Resources.formatApiFailed(this.method, this.resource, this.status, this.readMessage()));
49
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"github-answer.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/models/github-answer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,C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UAAU,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC;YACzG,OAAO,IAAI,CAAC;QAEd,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC;IAC5E,CAAC;IAEM,SAAS;QACd,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnH,CAAC;CACF"}
1
+ {"version":3,"file":"github-answer.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/models/github-answer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,YAAY;IACP,MAAM,CAAS;IACf,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,WAAW,CAAS;IACpB,UAAU,CAAS;IACnB,IAAI,CAAS;IAE7B,YAAmB,MAAc,EAAE,QAAgB,EAAE,MAAc,EAAE,UAAkB,EAAE,WAAmB,EAAE,UAAkB,EAAE,IAAY;QAC5I,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAA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AAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YACpD,OAAO,SAAS,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;QAE9F,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAExC,OAAO,OAAO,IAAI,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC;IACtG,CAAC;IAEM,SAAS;QACd,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noldova/tools.pipelines.github",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "api/index.js",
6
6
  "types": "api/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@noldova/context.json": "0.0.3",
26
- "@noldova/tools.pipelines": "0.0.2"
26
+ "@noldova/tools.pipelines": "0.0.4"
27
27
  },
28
- "gitHead": "88191d48b554e81284f6c9662fd1752a861b4f28"
28
+ "gitHead": "8b73b47be62290320cce3676c43fb7db771892c9"
29
29
  }
package/resources.js CHANGED
@@ -7,10 +7,41 @@
7
7
  */
8
8
  export class Resources {
9
9
  static acceptHeader = "Accept";
10
+ static archivedField = "archived";
11
+ static bodyField = "body";
12
+ static defaultBranchField = "default_branch";
13
+ static fullNameField = "full_name";
14
+ static gitCloneValues = ["clone", "--quiet", "--depth", "1", "--no-tags", "--"];
15
+ static gitConfigCount = "1";
16
+ static gitConfigCountVariable = "GIT_CONFIG_COUNT";
17
+ static gitConfigKeyVariable = "GIT_CONFIG_KEY_0";
18
+ static gitConfigValueVariable = "GIT_CONFIG_VALUE_0";
19
+ static gitProgram = "git";
20
+ static gitFetchValues = ["fetch", "--quiet", "--depth", "1", "--no-tags"];
21
+ static gitListRemoteValues = ["ls-remote", "--exit-code", "--heads"];
22
+ static gitNoMatchExitCode = 2;
23
+ static gitOptionsEnd = "--";
24
+ static gitPushValues = ["push", "--quiet"];
25
+ static gitReferenceSeparatorPattern = /\s/;
26
+ static gitTerminalPromptOff = "0";
27
+ static gitTerminalPromptVariable = "GIT_TERMINAL_PROMPT";
28
+ static headingPattern = /^#{1,6}\s/;
29
+ static htmlUrlField = "html_url";
30
+ static lineBreakPattern = /\r?\n/;
31
+ static linkedIssuePattern = /^Closes #([0-9]+)$/m;
32
+ static mergeCommitField = "merge_commit_sha";
33
+ static notHashPattern = /[^#]/;
34
+ static numberField = "number";
35
+ static repositoriesField = "repositories";
36
+ static repositoriesPageSize = 100;
37
+ static repositorySeparator = "/";
38
+ static serverUrlVariable = "GITHUB_SERVER_URL";
39
+ static updateMethod = "PATCH";
10
40
  static annotatedTagType = "tag";
11
41
  static annotationEscapes = [["%", "%25"], ["\r", "%0D"], ["\n", "%0A"]];
12
42
  static answerNotJson = "GitHub's answer is not JSON.";
13
43
  static apiMediaType = "application/vnd.github+json";
44
+ static apiRetryMilliseconds = [5_000, 15_000];
14
45
  static apiTimeoutMilliseconds = 60_000;
15
46
  static apiUrlVariable = "GITHUB_API_URL";
16
47
  static apiVersion = "2022-11-28";
@@ -22,6 +53,7 @@ export class Resources {
22
53
  static createMethod = "POST";
23
54
  static deletedStatus = 204;
24
55
  static deleteMethod = "DELETE";
56
+ static firstFailureStatus = 400;
25
57
  static foundStatus = 200;
26
58
  static idField = "id";
27
59
  static itemsField = "items";
@@ -30,6 +62,7 @@ export class Resources {
30
62
  static jsonObjectStart = "{";
31
63
  static lineSeparator = "\n";
32
64
  static messageField = "message";
65
+ static millisecondsPerSecond = 1_000;
33
66
  static nameField = "name";
34
67
  static notFoundStatus = 404;
35
68
  static objectField = "object";
@@ -39,9 +72,15 @@ export class Resources {
39
72
  static readMethod = "GET";
40
73
  static referencesPath = "git/refs";
41
74
  static repositoryVariable = "GITHUB_REPOSITORY";
75
+ static retryAfterHeader = "Retry-After";
76
+ static retryAfterMaxSeconds = 60;
77
+ static retryAfterPattern = /^[0-9]+$/;
78
+ static runnerTemporaryVariable = "RUNNER_TEMP";
42
79
  static shaField = "sha";
80
+ static timeoutErrorName = "TimeoutError";
43
81
  static tokenVariable = "GITHUB_TOKEN";
44
82
  static typeField = "type";
83
+ static unavailableStatuses = [502, 503, 504];
45
84
  static unprocessableStatus = 422;
46
85
  static versionsPageSize = 100;
47
86
  static formatErrorAnnotation(message) {
@@ -51,6 +90,64 @@ export class Resources {
51
90
  static formatVariableMissing(name) {
52
91
  return `The environment variable ${name} is not set; the tag step needs it to reach GitHub.`;
53
92
  }
93
+ static formatDependentsVariableMissing(name) {
94
+ return `The environment variable ${name} is not set; the dependents step needs it to reach GitHub.`;
95
+ }
96
+ static formatInstallationRepositoriesPage(page) {
97
+ return `installation/repositories?per_page=${Resources.repositoriesPageSize}&page=${page}`;
98
+ }
99
+ static formatCommitPullsResource(repository, commit) {
100
+ return Resources.formatResource(repository, `commits/${commit}/pulls`);
101
+ }
102
+ static formatOpenPullsResource(repository, owner, branch) {
103
+ return Resources.formatResource(repository, `pulls?state=open&head=${encodeURIComponent(`${owner}:${branch}`)}`);
104
+ }
105
+ static formatPullsResource(repository) {
106
+ return Resources.formatResource(repository, "pulls");
107
+ }
108
+ static formatPullResource(repository, number) {
109
+ return Resources.formatResource(repository, `pulls/${number}`);
110
+ }
111
+ static formatIssuesResource(repository) {
112
+ return Resources.formatResource(repository, "issues");
113
+ }
114
+ static formatIssueResource(repository, number) {
115
+ return Resources.formatResource(repository, `issues/${number}`);
116
+ }
117
+ static formatRepositoryResource(repository) {
118
+ return `repos/${repository}`;
119
+ }
120
+ static formatIssueBody(branch) {
121
+ return `A release moved packages this repository pins exactly; the pull request from \`${branch}\` moves the pins.`;
122
+ }
123
+ static formatProposalBody(body, issue) {
124
+ return issue === undefined ? body : [body, "", "## Linked issue", "", `Closes #${issue}`].join(Resources.lineSeparator);
125
+ }
126
+ static formatCloneUrl(serverUrl, repository) {
127
+ return `${serverUrl}/${repository}.git`;
128
+ }
129
+ static formatPushReference(branch) {
130
+ return `HEAD:${Resources.formatBranchReference(branch)}`;
131
+ }
132
+ static formatBranchReference(branch) {
133
+ return `refs/heads/${branch}`;
134
+ }
135
+ static formatForceWithLease(branch, commit) {
136
+ return `--force-with-lease=${Resources.formatBranchReference(branch)}:${commit}`;
137
+ }
138
+ static formatExtraHeaderKey(serverUrl) {
139
+ return `http.${serverUrl}/.extraheader`;
140
+ }
141
+ static formatBasicAuthorization(token) {
142
+ return `AUTHORIZATION: basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`;
143
+ }
144
+ static formatGitFailed(values, exitCode, errorOutput) {
145
+ const detail = errorOutput.split(Resources.lineBreakPattern).map(t => t.trim()).filter(t => t.length > 0).join(" ");
146
+ return `git ${values[0]} exited with code ${exitCode}${detail.length === 0 ? "." : `: ${detail}`}`;
147
+ }
148
+ static createNotesHeadingPattern(version) {
149
+ return new RegExp(`^#{1,6}\\s+Release notes for ${version.replaceAll(".", "\\.")}\\s*$`, "i");
150
+ }
54
151
  static formatPruneVariableMissing(name) {
55
152
  return `The environment variable ${name} is not set; the prune step needs it to reach GitHub.`;
56
153
  }
@@ -87,6 +184,9 @@ export class Resources {
87
184
  static formatApiFailed(method, resource, status, message) {
88
185
  return `GitHub answered ${method} ${resource} with ${status}: ${message}`;
89
186
  }
187
+ static formatApiUnanswered(method, resource, reason) {
188
+ return `GitHub gave no answer to ${method} ${resource}: ${reason}`;
189
+ }
90
190
  static formatTagTargetInvalid(tag, type) {
91
191
  return `${tag} points to a ${type}, not a commit.`;
92
192
  }
package/resources.js.map CHANGED
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mB,CAAC,KAAa;QAC7C,OAAO,UAAU,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,QAAgB,EAAE,MAAc,EAAE,OAAe;QAC7F,OAAO,mBAAmB,MAAM,IAAI,QAAQ,SAAS,MAAM,KAAK,OAAO,EAAE,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,mBAAmB,CAAC,MAAc,EAAE,QAAgB,EAAE,MAAc;QAChF,OAAO,4BAA4B,MAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;IACrE,CAAC;IAEM,MAAM,CAAC,sBAAsB,CAAC,GAAW,EAAE,IAAY;QAC5D,OAAO,GAAG,GAAG,gBAAgB,IAAI,iBAAiB,CAAC;IACrD,CAAC;CACF"}
@@ -5,30 +5,59 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import { StepResult } from "@noldova/tools.pipelines";
8
9
  import { GitHubAnswer } from "../models/github-answer.js";
9
10
  import { Resources } from "../resources.js";
10
11
  export class GitHubApi {
11
12
  apiUrl;
12
13
  token;
13
14
  timeoutMilliseconds;
14
- constructor(apiUrl, token, timeoutMilliseconds) {
15
+ waitAsync;
16
+ createSignal;
17
+ constructor(apiUrl, token, timeoutMilliseconds, waitAsync, createSignal) {
15
18
  this.apiUrl = apiUrl;
16
19
  this.token = token;
17
20
  this.timeoutMilliseconds = timeoutMilliseconds;
21
+ this.waitAsync = waitAsync;
22
+ this.createSignal = createSignal;
23
+ }
24
+ static createTimeoutSignal(timeoutMilliseconds) {
25
+ return AbortSignal.timeout(timeoutMilliseconds);
18
26
  }
19
27
  async requestAsync(method, resource, body) {
20
- const response = await fetch(`${this.apiUrl}/${resource}`, {
21
- method,
22
- headers: {
23
- [Resources.acceptHeader]: Resources.apiMediaType,
24
- [Resources.authorizationHeader]: Resources.formatAuthorization(this.token),
25
- [Resources.apiVersionHeader]: Resources.apiVersion,
26
- ...(body === undefined ? {} : { [Resources.contentTypeHeader]: Resources.jsonContentType })
27
- },
28
- signal: AbortSignal.timeout(this.timeoutMilliseconds),
29
- ...(body === undefined ? {} : { body: JSON.stringify(body) })
30
- });
31
- return new GitHubAnswer(method, resource, response.status, response.statusText, response.headers.get(Resources.contentTypeHeader) ?? "", await response.text());
28
+ for (const retryMilliseconds of Resources.apiRetryMilliseconds) {
29
+ const answer = await this.sendAsync(method, resource, body);
30
+ const waitMilliseconds = answer instanceof StepResult ? retryMilliseconds : answer.readRetryMilliseconds(retryMilliseconds);
31
+ if (waitMilliseconds === null)
32
+ return answer;
33
+ await this.waitAsync(waitMilliseconds);
34
+ }
35
+ return await this.sendAsync(method, resource, body);
36
+ }
37
+ async sendAsync(method, resource, body) {
38
+ try {
39
+ const response = await fetch(`${this.apiUrl}/${resource}`, {
40
+ method,
41
+ headers: {
42
+ [Resources.acceptHeader]: Resources.apiMediaType,
43
+ [Resources.authorizationHeader]: Resources.formatAuthorization(this.token),
44
+ [Resources.apiVersionHeader]: Resources.apiVersion,
45
+ ...(body === undefined ? {} : { [Resources.contentTypeHeader]: Resources.jsonContentType })
46
+ },
47
+ signal: this.createSignal(this.timeoutMilliseconds),
48
+ ...(body === undefined ? {} : { body: JSON.stringify(body) })
49
+ });
50
+ const headers = response.headers;
51
+ return new GitHubAnswer(method, resource, response.status, response.statusText, headers.get(Resources.contentTypeHeader) ?? "", headers.get(Resources.retryAfterHeader) ?? "", await response.text());
52
+ }
53
+ catch (error) {
54
+ if (!GitHubApi.isUnanswered(error))
55
+ throw error;
56
+ return StepResult.failed(Resources.formatApiUnanswered(method, resource, (error.cause instanceof Error ? error.cause.message : "") || error.message));
57
+ }
58
+ }
59
+ static isUnanswered(error) {
60
+ return (error instanceof DOMException && error.name === Resources.timeoutErrorName) || (error instanceof TypeError && error.cause instanceof Error);
32
61
  }
33
62
  }
34
63
  //# sourceMappingURL=github-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-api.js","sourceRoot":"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,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;YAEjC,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACxM,CAAC;QACD,OAAO,KAAc,EAAE,CAAC;YACtB,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC;gBAChC,MAAM,KAAK,CAAC;YAEd,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACxJ,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,KAAc;QACxC,OAAO,CAAC,KAAK,YAAY,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,YAAY,SAAS,IAAI,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC;IACtJ,CAAC;CACF"}
@@ -5,17 +5,22 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import { setTimeout as delayAsync } from "node:timers/promises";
8
9
  import { StepResult } from "@noldova/tools.pipelines";
9
10
  import { Resources } from "../resources.js";
10
11
  import { GitHubApi } from "./github-api.js";
11
12
  export class GitHubPackages {
12
13
  environment;
13
14
  timeoutMilliseconds;
15
+ waitAsync;
16
+ createSignal;
14
17
  versionIds = new Map();
15
18
  registry = Resources.packagesRegistry;
16
- constructor(environment, timeoutMilliseconds = Resources.apiTimeoutMilliseconds) {
19
+ constructor(environment, timeoutMilliseconds = Resources.apiTimeoutMilliseconds, waitAsync = delayAsync, createSignal = GitHubApi.createTimeoutSignal) {
17
20
  this.environment = environment;
18
21
  this.timeoutMilliseconds = timeoutMilliseconds;
22
+ this.waitAsync = waitAsync;
23
+ this.createSignal = createSignal;
19
24
  }
20
25
  async readVersionsAsync(packageName) {
21
26
  const target = this.readTarget(packageName);
@@ -36,6 +41,8 @@ export class GitHubPackages {
36
41
  return false;
37
42
  const [api, resource] = target;
38
43
  const answer = await api.requestAsync(Resources.deleteMethod, Resources.formatVersionResource(resource, id));
44
+ if (answer instanceof StepResult)
45
+ return answer;
39
46
  if (answer.status === Resources.deletedStatus) {
40
47
  ids.delete(version);
41
48
  return true;
@@ -51,6 +58,8 @@ export class GitHubPackages {
51
58
  const ids = new Map();
52
59
  for (let page = 1;; page++) {
53
60
  const answer = await api.requestAsync(Resources.readMethod, Resources.formatVersionsPage(resource, page));
61
+ if (answer instanceof StepResult)
62
+ return answer;
54
63
  if (answer.status !== Resources.foundStatus)
55
64
  return answer.toFailure();
56
65
  const items = answer.readItems();
@@ -68,7 +77,7 @@ export class GitHubPackages {
68
77
  const missing = [Resources.apiUrlVariable, Resources.tokenVariable].find(t => this.readVariable(t).length === 0);
69
78
  if (missing !== undefined)
70
79
  return StepResult.failed(Resources.formatPruneVariableMissing(missing));
71
- const api = new GitHubApi(this.readVariable(Resources.apiUrlVariable), this.readVariable(Resources.tokenVariable), this.timeoutMilliseconds);
80
+ const api = new GitHubApi(this.readVariable(Resources.apiUrlVariable), this.readVariable(Resources.tokenVariable), this.timeoutMilliseconds, this.waitAsync, this.createSignal);
72
81
  return [api, Resources.formatVersionsResource(packageName)];
73
82
  }
74
83
  readVariable(name) {
@@ -1 +1 @@
1
- {"version":3,"file":"github-packages.js","sourceRoot":"","sources":["../../../../src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,aAAa,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAE7I,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACF"}
1
+ {"version":3,"file":"github-packages.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/github-packages.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAsB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,cAAc;IACR,WAAW,CAA+C;IAC1D,mBAAmB,CAAS;IAC5B,SAAS,CAA0C;IACnD,YAAY,CAA+C;IAC3D,UAAU,GAAqC,IAAI,GAAG,EAAE,CAAC;IAE1D,QAAQ,GAAW,SAAS,CAAC,gBAAgB,CAAC;IAE9D,YAAmB,WAAyD,EAAE,mBAAmB,GAAW,SAAS,CAAC,sBAAsB,EAAE,SAAS,GAA4C,UAAU,EAAE,YAAY,GAAiD,SAAS,CAAC,mBAAmB;QACvS,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,WAAmB;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,MAAM,YAAY,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AAC,CAAC;QAEtC,OAAO,GAAG,CAAC;IACb,CAAC;IAEO,UAAU,CAAC,WAAmB;QACpC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC;YACjD,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC;QAE1E,MAAM,OAAO,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;QACjH,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;QAE1E,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAEhL,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACF"}
@@ -5,6 +5,7 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
+ import { setTimeout as delayAsync } from "node:timers/promises";
8
9
  import { StepResult } from "@noldova/tools.pipelines";
9
10
  import { GitHubAnswer } from "../models/github-answer.js";
10
11
  import { GitHubConnection } from "../models/github-connection.js";
@@ -13,15 +14,21 @@ import { GitHubApi } from "./github-api.js";
13
14
  export class GitHubTags {
14
15
  environment;
15
16
  timeoutMilliseconds;
16
- constructor(environment, timeoutMilliseconds = Resources.apiTimeoutMilliseconds) {
17
+ waitAsync;
18
+ createSignal;
19
+ constructor(environment, timeoutMilliseconds = Resources.apiTimeoutMilliseconds, waitAsync = delayAsync, createSignal = GitHubApi.createTimeoutSignal) {
17
20
  this.environment = environment;
18
21
  this.timeoutMilliseconds = timeoutMilliseconds;
22
+ this.waitAsync = waitAsync;
23
+ this.createSignal = createSignal;
19
24
  }
20
25
  async readTagAsync(tag) {
21
26
  const connection = this.readConnection();
22
27
  if (connection instanceof StepResult)
23
28
  return connection;
24
29
  const reference = await this.requestAsync(connection, Resources.readMethod, Resources.formatTagReferencePath(tag));
30
+ if (reference instanceof StepResult)
31
+ return reference;
25
32
  if (reference.status === Resources.notFoundStatus)
26
33
  return "";
27
34
  if (reference.status !== Resources.foundStatus)
@@ -29,6 +36,8 @@ export class GitHubTags {
29
36
  let target = reference.readBody().readObject(Resources.objectField);
30
37
  while (target.readString(Resources.typeField) === Resources.annotatedTagType) {
31
38
  const tagObject = await this.requestAsync(connection, Resources.readMethod, Resources.formatTagObjectPath(target.readString(Resources.shaField)));
39
+ if (tagObject instanceof StepResult)
40
+ return tagObject;
32
41
  if (tagObject.status !== Resources.foundStatus)
33
42
  return tagObject.toFailure();
34
43
  target = tagObject.readBody().readObject(Resources.objectField);
@@ -43,6 +52,8 @@ export class GitHubTags {
43
52
  if (connection instanceof StepResult)
44
53
  return connection;
45
54
  const answer = await this.requestAsync(connection, Resources.createMethod, Resources.referencesPath, { ref: Resources.formatTagReference(tag), sha: commit });
55
+ if (answer instanceof StepResult)
56
+ return answer;
46
57
  if (answer.status === Resources.createdStatus)
47
58
  return true;
48
59
  if (answer.status !== Resources.unprocessableStatus)
@@ -62,7 +73,7 @@ export class GitHubTags {
62
73
  return this.environment[name] ?? "";
63
74
  }
64
75
  async requestAsync(connection, method, path, body) {
65
- return new GitHubApi(connection.apiUrl, connection.token, this.timeoutMilliseconds).requestAsync(method, Resources.formatResource(connection.repository, path), body);
76
+ return new GitHubApi(connection.apiUrl, connection.token, this.timeoutMilliseconds, this.waitAsync, this.createSignal).requestAsync(method, Resources.formatResource(connection.repository, path), body);
66
77
  }
67
78
  }
68
79
  //# sourceMappingURL=github-tags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-tags.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/github-tags.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAiB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,UAAU;IACJ,WAAW,CAA+C;IAC1D,mBAAmB,CAAS;IAE7C,YAAmB,WAAyD,EAAE,mBAAmB,GAAW,SAAS,CAAC,sBAAsB;QAC1I,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,GAAW;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACzC,IAAI,UAAU,YAAY,UAAU;YAClC,OAAO,UAAU,CAAC;QAEpB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;QACnH,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,cAAc;YAC/C,OAAO,EAAE,CAAC;QACZ,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,WAA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vB,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;QAErE,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IACxK,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,UAA4B,EAAE,MAAc,EAAE,IAAY,EAAE,IAAuC;QAC5H,OAAO,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3M,CAAC;CACF"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { setTimeout as delayAsync } from "node:timers/promises";
9
+ import { ProcessRunner, StepResult } from "@noldova/tools.pipelines";
10
+ import { GitHubAnswer } from "../models/github-answer.js";
11
+ import { Resources } from "../resources.js";
12
+ import { GitHubApi } from "./github-api.js";
13
+ export class GitHubUpdates {
14
+ environment;
15
+ processRunner;
16
+ timeoutMilliseconds;
17
+ waitAsync;
18
+ createSignal;
19
+ credentialVariables = [Resources.tokenVariable];
20
+ constructor(environment, processRunner = new ProcessRunner(), timeoutMilliseconds = Resources.apiTimeoutMilliseconds, waitAsync = delayAsync, createSignal = GitHubApi.createTimeoutSignal) {
21
+ this.environment = environment;
22
+ this.processRunner = processRunner;
23
+ this.timeoutMilliseconds = timeoutMilliseconds;
24
+ this.waitAsync = waitAsync;
25
+ this.createSignal = createSignal;
26
+ }
27
+ readSourceName() {
28
+ const missing = this.findMissingVariable();
29
+ if (missing !== null)
30
+ return missing;
31
+ const repository = this.readVariable(Resources.repositoryVariable);
32
+ return repository.slice(repository.indexOf(Resources.repositorySeparator) + 1);
33
+ }
34
+ async listRepositoriesAsync() {
35
+ const missing = this.findMissingVariable();
36
+ if (missing !== null)
37
+ return missing;
38
+ const source = this.readVariable(Resources.repositoryVariable).toLowerCase();
39
+ const repositories = [];
40
+ for (let page = 1;; page++) {
41
+ const answer = await this.requestAsync(Resources.readMethod, Resources.formatInstallationRepositoriesPage(page));
42
+ if (answer instanceof StepResult)
43
+ return answer;
44
+ if (answer.status !== Resources.foundStatus)
45
+ return answer.toFailure();
46
+ const items = answer.readBody().readObjectArray(Resources.repositoriesField);
47
+ for (const item of items) {
48
+ const name = item.readString(Resources.fullNameField);
49
+ if (!item.readBoolean(Resources.archivedField) && name.toLowerCase() !== source)
50
+ repositories.push(name);
51
+ }
52
+ if (items.length < Resources.repositoriesPageSize)
53
+ break;
54
+ }
55
+ return repositories.sort();
56
+ }
57
+ async readReleaseNotesAsync(version, commit) {
58
+ const missing = this.findMissingVariable();
59
+ if (missing !== null)
60
+ return missing;
61
+ const answer = await this.requestAsync(Resources.readMethod, Resources.formatCommitPullsResource(this.readVariable(Resources.repositoryVariable), commit));
62
+ if (answer instanceof StepResult)
63
+ return answer;
64
+ if (answer.status !== Resources.foundStatus)
65
+ return answer.toFailure();
66
+ const pull = answer.readItems().find(t => t.readNullableString(Resources.mergeCommitField) === commit);
67
+ return pull === undefined ? "" : GitHubUpdates.findNotes(pull.readNullableString(Resources.bodyField) ?? "", version);
68
+ }
69
+ async checkOutAsync(repository, directory) {
70
+ const missing = this.findMissingVariable();
71
+ if (missing !== null)
72
+ return missing;
73
+ return await this.runGitAsync([...Resources.gitCloneValues, this.formatCloneUrl(repository), directory], process.cwd());
74
+ }
75
+ async fetchBranchAsync(repository, directory, branch) {
76
+ const missing = this.findMissingVariable();
77
+ if (missing !== null)
78
+ return missing;
79
+ const url = this.formatCloneUrl(repository);
80
+ const values = [...Resources.gitListRemoteValues, Resources.gitOptionsEnd, url, Resources.formatBranchReference(branch)];
81
+ const listed = await this.processRunner.runAsync(Resources.gitProgram, values, directory, this.createGitEnvironment());
82
+ if (listed.exitCode === Resources.gitNoMatchExitCode)
83
+ return null;
84
+ if (!listed.isSuccessful)
85
+ return GitHubUpdates.failGit(values, listed.exitCode, listed.errorOutput);
86
+ const commit = listed.output.slice(0, listed.output.search(Resources.gitReferenceSeparatorPattern));
87
+ const fetched = await this.runGitAsync([...Resources.gitFetchValues, Resources.gitOptionsEnd, url, commit], directory);
88
+ return fetched ?? commit;
89
+ }
90
+ async pushAsync(repository, directory, branch, replaced) {
91
+ const missing = this.findMissingVariable();
92
+ if (missing !== null)
93
+ return missing;
94
+ const lease = replaced === null ? [] : [Resources.formatForceWithLease(branch, replaced)];
95
+ const values = [...Resources.gitPushValues, ...lease, Resources.gitOptionsEnd, this.formatCloneUrl(repository), Resources.formatPushReference(branch)];
96
+ return await this.runGitAsync(values, directory);
97
+ }
98
+ async proposeAsync(repository, branch, title, body) {
99
+ const missing = this.findMissingVariable();
100
+ if (missing !== null)
101
+ return missing;
102
+ const owner = repository.slice(0, repository.indexOf(Resources.repositorySeparator));
103
+ const open = await this.requestAsync(Resources.readMethod, Resources.formatOpenPullsResource(repository, owner, branch));
104
+ if (open instanceof StepResult)
105
+ return open;
106
+ if (open.status !== Resources.foundStatus)
107
+ return open.toFailure();
108
+ const existing = open.readItems()[0];
109
+ if (existing !== undefined) {
110
+ const issue = Resources.linkedIssuePattern.exec(existing.readNullableString(Resources.bodyField) ?? "")?.[1];
111
+ if (issue !== undefined) {
112
+ const renamed = await this.requestAsync(Resources.updateMethod, Resources.formatIssueResource(repository, issue), { title });
113
+ if (renamed instanceof StepResult)
114
+ return renamed;
115
+ if (renamed.status !== Resources.foundStatus)
116
+ return renamed.toFailure();
117
+ }
118
+ const number = String(existing.readInteger(Resources.numberField));
119
+ const updated = await this.requestAsync(Resources.updateMethod, Resources.formatPullResource(repository, number), { title, body: Resources.formatProposalBody(body, issue) });
120
+ if (updated instanceof StepResult)
121
+ return updated;
122
+ return updated.status === Resources.foundStatus ? updated.readBody().readString(Resources.htmlUrlField) : updated.toFailure();
123
+ }
124
+ const target = await this.requestAsync(Resources.readMethod, Resources.formatRepositoryResource(repository));
125
+ if (target instanceof StepResult)
126
+ return target;
127
+ if (target.status !== Resources.foundStatus)
128
+ return target.toFailure();
129
+ const issue = await this.requestAsync(Resources.createMethod, Resources.formatIssuesResource(repository), { title, body: Resources.formatIssueBody(branch) });
130
+ if (issue instanceof StepResult)
131
+ return issue;
132
+ if (issue.status !== Resources.createdStatus)
133
+ return issue.toFailure();
134
+ const number = String(issue.readBody().readInteger(Resources.numberField));
135
+ const base = target.readBody().readString(Resources.defaultBranchField);
136
+ const pull = await this.requestAsync(Resources.createMethod, Resources.formatPullsResource(repository), { title, head: branch, base, body: Resources.formatProposalBody(body, number) });
137
+ if (pull instanceof StepResult)
138
+ return pull;
139
+ return pull.status === Resources.createdStatus ? pull.readBody().readString(Resources.htmlUrlField) : pull.toFailure();
140
+ }
141
+ async runGitAsync(values, workingDirectory) {
142
+ const result = await this.processRunner.runAsync(Resources.gitProgram, values, workingDirectory, this.createGitEnvironment());
143
+ return result.isSuccessful ? null : GitHubUpdates.failGit(values, result.exitCode, result.errorOutput);
144
+ }
145
+ static failGit(values, exitCode, errorOutput) {
146
+ return StepResult.failed(Resources.formatGitFailed(values, exitCode, errorOutput));
147
+ }
148
+ createGitEnvironment() {
149
+ return {
150
+ [Resources.gitConfigCountVariable]: Resources.gitConfigCount,
151
+ [Resources.gitConfigKeyVariable]: Resources.formatExtraHeaderKey(this.readVariable(Resources.serverUrlVariable)),
152
+ [Resources.gitConfigValueVariable]: Resources.formatBasicAuthorization(this.readVariable(Resources.tokenVariable)),
153
+ [Resources.gitTerminalPromptVariable]: Resources.gitTerminalPromptOff
154
+ };
155
+ }
156
+ formatCloneUrl(repository) {
157
+ return Resources.formatCloneUrl(this.readVariable(Resources.serverUrlVariable), repository);
158
+ }
159
+ findMissingVariable() {
160
+ const missing = [Resources.apiUrlVariable, Resources.serverUrlVariable, Resources.repositoryVariable, Resources.tokenVariable].find(t => this.readVariable(t).length === 0);
161
+ return missing === undefined ? null : StepResult.failed(Resources.formatDependentsVariableMissing(missing));
162
+ }
163
+ readVariable(name) {
164
+ return this.environment[name] ?? "";
165
+ }
166
+ async requestAsync(method, resource, body) {
167
+ const api = new GitHubApi(this.readVariable(Resources.apiUrlVariable), this.readVariable(Resources.tokenVariable), this.timeoutMilliseconds, this.waitAsync, this.createSignal);
168
+ return await api.requestAsync(method, resource, body);
169
+ }
170
+ static findNotes(body, version) {
171
+ const heading = Resources.createNotesHeadingPattern(version);
172
+ const section = [];
173
+ let level = 0;
174
+ for (const line of body.split(Resources.lineBreakPattern)) {
175
+ const lineLevel = GitHubUpdates.readHeadingLevel(line);
176
+ if (level === 0) {
177
+ if (heading.test(line)) {
178
+ level = lineLevel;
179
+ section.push(line);
180
+ }
181
+ }
182
+ else if (lineLevel > 0 && lineLevel <= level)
183
+ break;
184
+ else
185
+ section.push(line);
186
+ }
187
+ return section.join(Resources.lineSeparator).trim();
188
+ }
189
+ static readHeadingLevel(line) {
190
+ return Resources.headingPattern.test(line) ? line.search(Resources.notHashPattern) : 0;
191
+ }
192
+ }
193
+ //# sourceMappingURL=github-updates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-updates.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/github-updates.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,sBAAsB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,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;iBACI,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,IAAI,KAAK;gBAC1C,MAAM;;gBAEN,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;IACtD,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,IAAY;QAC1C,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;CACF"}
@@ -5,10 +5,11 @@
5
5
  * This source code is licensed under the license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
- import { ArchiveStep, CommandLine, Git, NightlyStep, Npm, ProcessRunner, PruneStep, PublishStep, SourceStep, TagStep, Tar } from "@noldova/tools.pipelines";
8
+ import { ArchiveStep, CommandLine, DependentsStep, Git, LineEndingsStep, NightlyStep, Npm, ProcessRunner, PruneStep, PublishStep, ReproducibleStep, SourceStep, TagStep, Tar, ToolchainStep, UnchangedStep } from "@noldova/tools.pipelines";
9
9
  import { Resources } from "../resources.js";
10
10
  import { GitHubPackages } from "./github-packages.js";
11
11
  import { GitHubTags } from "./github-tags.js";
12
+ import { GitHubUpdates } from "./github-updates.js";
12
13
  export class PipelinesProgram {
13
14
  output;
14
15
  constructor(output) {
@@ -19,7 +20,7 @@ export class PipelinesProgram {
19
20
  const git = new Git(processRunner, process.cwd());
20
21
  const npm = new Npm(processRunner, process.cwd());
21
22
  const archiveStep = new ArchiveStep(git, new Tar(processRunner));
22
- const steps = [new SourceStep(git), archiveStep, new PublishStep(archiveStep, npm), new NightlyStep(git, archiveStep, npm), new PruneStep(git, archiveStep, new GitHubPackages(process.env)), new TagStep(new GitHubTags(process.env))];
23
+ const steps = [new SourceStep(git), archiveStep, new PublishStep(archiveStep, npm), new NightlyStep(git, archiveStep, npm), new PruneStep(git, archiveStep, new GitHubPackages(process.env)), new TagStep(new GitHubTags(process.env)), new ToolchainStep(npm, process.version), new LineEndingsStep(git), new UnchangedStep(git), new ReproducibleStep(git, npm, process.env[Resources.runnerTemporaryVariable]), new DependentsStep(archiveStep, new GitHubUpdates(process.env, processRunner), processRunner, npm, process.env[Resources.runnerTemporaryVariable])];
23
24
  return new CommandLine(Resources.programName, steps, this.output).runAsync(values);
24
25
  }
25
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pipelines-program.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/pipelines-program.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAoB,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE9K,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAc;IAErC,YAAmB,MAAmB;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAyB;QAC7C,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAClD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAClD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;QACjE,MAAM,KAAK,GAAG,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,WAAW,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,IAAI,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,IAAI,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAExO,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrF,CAAC;CACF"}
1
+ {"version":3,"file":"pipelines-program.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/pipelines-program.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,EAAoB,eAAe,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE/P,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAc;IAErC,YAAmB,MAAmB;QACpC,IAAI,CAA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