@noldova/tools.pipelines 0.0.16 → 0.0.18

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
@@ -300,12 +300,34 @@ result.message; // "Looked for exact pins of @noldova/a, @noldova/b older than 0
300
300
  - When a released package needs another package as a peer at an exact version, it also moves the repository's exact pins of that package when older, and the description names the released package that needs each.
301
301
  - Then it follows the moved packages through the registries the repository's own npm configuration names, with `npm view` and without the host's credential variables, until nothing more moves: an exact pin, as a dependency or a dev dependency, older than the exact peer, optional or not, that a moved package's new version needs moves to that version; an exact pin whose version needs a moved package as a peer at another exact version moves to its first later version whose exact peers are the moved versions. The description names, for each, the package that required it. When a pin is newer than an exact peer a moved package needs, a moved package needs another at a version other than the one it moved to, or no later version of such a pin needs the moved versions, it leaves the repository as it is and names each such pin; that repository doesn't fail. Pins the moved packages don't force stay where they are, and so do the pins of the repository's own packages, which its own next release moves.
302
302
  - Before it relocks, it leaves a repository as it is when any tracked `package-lock.json` holds another package that needs one of the moved packages, as a peer, at another exact version, and names each such package and the version it needs; npm couldn't install the moved pins until that package accepts them.
303
+ - A lock folder whose `package.json` pins exactly a package one of the repository's own tracked `package.json` files names, while its lock holds no entry for it, as when the repository locks its own unpublished packages from its built archives, is relocked without asking a registry for that package: it, and each own package its manifest reaches by dependency or optional dependency, resolves from a stand-in archive that holds only a manifest with the tracked manifest's dependencies and optional dependencies on other packages and no peers, so npm installs no peer for an own package, as a lock made with `--legacy-peer-deps` holds none, which the folder's `package.json` names while npm runs and gives back after; the lock then leaves out every entry at or under an own package, and its root entry keeps the folder's pins, and the pull request names each such lock file. When more than one tracked `package.json` names such a package, or when that relock drops an entry the old lock marks as a peer and no moved package's locked entry names, as when the repository locks its own packages with their peers, it leaves the repository as it is and names them, without failing it.
303
304
  - After, it leaves the repository as it is, without chasing further, when a relocked lock file still holds a package whose exact peer differs from the version it locks, and names each.
304
305
  - When it moved any, it relocks every tracked `package-lock.json`: it removes from the file the entries of the moved packages, the entries nested under them and the entries that depend on them, by dependency, optional dependency or peer, keeps every other entry at its locked version unless a package npm resolves again needs it to change, and lets `npm install --package-lock-only --ignore-scripts` resolve what it removed, so a package the old lock keeps at an older version, with that version's exact peers, can't hold the moved pins back; it runs without the host's credential variables and, on Linux and macOS, stops an npm run longer than 5 minutes, which fails that repository; it then commits, pushes the branch `pipelines/update-<source>` and proposes it with the moved pins and the release's notes; a repository that pins none is left as it is.
305
306
  - When the branch exists, it replaces it only while the branch is at a commit of its own, with its title and the same committer; a branch with anyone else's commit is left as it is, and that repository fails, so nobody's work is lost.
306
307
  - It succeeds with one line for each repository, and fails, after trying every other repository, with the line of each that failed; an error in one repository, such as git failing, is that repository's line.
307
308
  - Given an output, it writes each repository's line there instead, as a success or a failure, as soon as that repository is done, so a run stopped partway still shows the repositories it finished; its result's message is then only the summary.
308
309
  - It removes its temporary folder whether it succeeds or fails, and makes it in the root its constructor is given, or in `os.tmpdir()`.
310
+ - It first checks out every repository and asks the host's `startRelockAsync` whether each relocks itself, giving the checkout's head commit and the release as a request: the source, the version, the commit, the released packages and the peers they pin; the host starts each such relock, so they run together. Then it finishes the repositories in order.
311
+ When the host answered `null`, it moves and relocks in the checkout as above.
312
+ Otherwise it reads with the host's `readRelockAsync` what the repository's relock step wrote: a repository's line, which becomes that repository's line, or the commit it ran at, the moved pins, the lock lines and the files that changed, which it writes into the checkout, each one a tracked `package.json` or `package-lock.json`, before it commits, pushes and proposes as above; a file that is neither, a relock of another commit than the checkout's, and a failure the host answers fail that repository.
313
+
314
+ ### The relock step
315
+
316
+ `relock <repository> <request> <result file> [<lock file>=<npm script>...]` runs in a dependent's own checkout, at the commit the dependents step names, after the dependent prepared it as its own build does, such as installing and building its packages.
317
+ It moves the pins and relocks as the dependents step does in its checkout, with the dependent's own npm configuration and credentials, and writes the result to the file, without committing or pushing anything.
318
+
319
+ ```ts
320
+ import { Npm, ProcessRunner, RelockStep } from "@noldova/tools.pipelines";
321
+
322
+ const processRunner = new ProcessRunner();
323
+ const step = new RelockStep(processRunner, new Npm(processRunner, process.cwd()), process.cwd());
324
+ const result = await step.runAsync(["noldova-com/example", request, "relock.json", "app/package-lock.json=lock:app"]);
325
+ result.message; // "noldova-com/example: moved 2 pins and wrote the 4 files that changed into the result."
326
+ ```
327
+
328
+ - `<repository>` is the dependent's full name, which starts each line; `<request>` is the release as the dependents step sends it.
329
+ - Each `<lock file>=<npm script>` relocks that tracked lock file with `npm run <npm script>` at the checkout's root instead, after its moved entries are removed as above, for a lock the repository makes its own way, such as one that takes the repository's own packages from its build; such a lock skips the stand-in archives. A script name is letters, digits and `:`, `.`, `_` and `-`; a lock file named twice, or a value without both parts, fails the step before it changes anything, and so does a wrong number of values.
330
+ - The result file holds JSON: the repository's line and whether it succeeded, when the repository is left as it is or fails, or the checkout's head commit, the moved pins, the lock lines and the text of each tracked `package.json` and `package-lock.json` that changed. A lock script for a lock file the repository doesn't track, a failed lock or script run, and an error, such as npm failing, are a failed line in the file; the step itself still succeeds, so the release's dependents step reports them.
309
331
 
310
332
  ### The pins step
311
333
 
package/api/index.d.ts CHANGED
@@ -874,6 +874,37 @@ export declare interface IUpdateHost {
874
874
  */
875
875
  readReleaseNotesAsync(version: string, commit: string): Promise<string | StepResult>;
876
876
 
877
+ /**
878
+ * Starts a repository's own relock, when the host can: the relock runs the
879
+ * {@link RelockStep} in a checkout of the commit, prepared as the
880
+ * repository's own build does, while the step goes on to the next
881
+ * repository.
882
+ *
883
+ * @param repository The repository's full name.
884
+ * @param commit The commit the relock checks out.
885
+ * @param request The release, which the relock step reads.
886
+ * @returns A promise of what names the started relock, for
887
+ * {@link readRelockAsync}, `null` when the repository doesn't relock itself
888
+ * and the step relocks it in its own checkout, or a failed
889
+ * {@link StepResult} that says why the host could not start it.
890
+ */
891
+ startRelockAsync(repository: string, commit: string, request: string): Promise<string | null | StepResult>;
892
+
893
+ /**
894
+ * Waits for a relock {@link startRelockAsync} started and reads what its
895
+ * relock step wrote. The host's waits for all the relocks of one step
896
+ * share one time limit, since every relock starts before the first is
897
+ * read.
898
+ *
899
+ * @param repository The repository's full name.
900
+ * @param run What {@link startRelockAsync} answered.
901
+ * @returns A promise of the relock step's result file, which
902
+ * {@link RelockedFiles.parse} reads, or a failed {@link StepResult} that
903
+ * says why the host could not read it, such as a relock that failed or
904
+ * didn't finish within the time limit.
905
+ */
906
+ readRelockAsync(repository: string, run: string): Promise<string | StepResult>;
907
+
877
908
  /**
878
909
  * Checks out a repository's default branch into a new directory, as a git
879
910
  * clone the step can commit in.
@@ -1674,6 +1705,27 @@ export declare class Npm {
1674
1705
  */
1675
1706
  public lockAsync(directory: string, hiddenVariables?: readonly string[]): Promise<ProcessResult>;
1676
1707
 
1708
+ /**
1709
+ * Runs a script of the directory's `package.json` with `npm run <script>`,
1710
+ * as the lock refresh runs npm: through `cmd.exe` on Windows, and stopped
1711
+ * after 5 minutes elsewhere.
1712
+ *
1713
+ * @param directory The directory whose `package.json` names the script.
1714
+ * @param script The script's name, such as `lock:app`.
1715
+ * @param hiddenVariables The environment variables npm doesn't get;
1716
+ * omitted, it gets them all.
1717
+ * @returns A promise of npm's exit code and of what it wrote; a script
1718
+ * that fails still resolves. It rejects with {@link ProcessException} if
1719
+ * the program cannot start.
1720
+ * @example
1721
+ * ```ts
1722
+ * import { Npm, ProcessRunner } from "@noldova/tools.pipelines";
1723
+ *
1724
+ * (await new Npm(new ProcessRunner(), process.cwd()).runScriptAsync(process.cwd(), "lock:app")).isSuccessful; // true when the script succeeds
1725
+ * ```
1726
+ */
1727
+ public runScriptAsync(directory: string, script: string, hiddenVariables?: readonly string[]): Promise<ProcessResult>;
1728
+
1677
1729
  /**
1678
1730
  * Views a field of a package or a version as JSON with `npm view <specifier>
1679
1731
  * <field> --json --prefer-online`, run in a directory, so the registries its
@@ -2637,11 +2689,33 @@ export declare class ReproducibleStep implements IStep {
2637
2689
  * a peer, and names each such package, since npm couldn't install the moved
2638
2690
  * pins until that package accepts them; after, it leaves it as it is,
2639
2691
  * without chasing further, when a relocked lock file still holds a
2640
- * package whose exact peer differs from the version it locks. When the branch
2692
+ * package whose exact peer differs from the version it locks. A lock folder
2693
+ * whose `package.json` pins exactly a package one of the repository's own
2694
+ * tracked manifests names, while its lock holds no entry for it, as when the
2695
+ * repository locks its own unpublished packages from its built archives, is
2696
+ * relocked without asking a registry for it: that package, and each own
2697
+ * package its manifest reaches by dependency or optional dependency, resolves
2698
+ * from a stand-in archive holding only a manifest with the tracked manifest's
2699
+ * dependencies and optional dependencies on other packages and no peers, so
2700
+ * npm installs no peer for an own package, as a lock made with
2701
+ * `--legacy-peer-deps` holds none; the
2702
+ * lock then leaves out every entry at or under an own package, and its root
2703
+ * entry keeps the folder's pins. When more than one tracked manifest names
2704
+ * such a package, or when that relock drops an entry the old lock marks as a
2705
+ * peer and no moved package's locked entry names, it leaves the repository as
2706
+ * it is and names them, without failing it. When the branch
2641
2707
  * exists, it replaces it only when the branch is at a commit of its own, made
2642
2708
  * by the same committer with its title, and otherwise fails that repository,
2643
2709
  * so nobody's commits are lost. A repository that pins none of them is left
2644
- * as it is.
2710
+ * as it is. It first checks out every repository and asks
2711
+ * {@link IUpdateHost.startRelockAsync} whether each relocks itself, starting
2712
+ * every such relock, and then finishes the repositories in order; for one
2713
+ * that relocks itself, it reads with {@link IUpdateHost.readRelockAsync} the
2714
+ * line the repository's {@link RelockStep} wrote, or the files it changed,
2715
+ * which it writes into its checkout, each a tracked `package.json` or
2716
+ * `package-lock.json`, and commits, pushes and proposes them as above; any
2717
+ * other file, and a relock of a commit other than the one it checked out,
2718
+ * fails that repository.
2645
2719
  */
2646
2720
  export declare class DependentsStep implements IStep {
2647
2721
  /**
@@ -2710,6 +2784,135 @@ export declare class DependentsStep implements IStep {
2710
2784
  public runAsync(values: readonly string[]): Promise<StepResult>;
2711
2785
  }
2712
2786
 
2787
+ /**
2788
+ * What a repository's own relock wrote: the commit it ran at, the moved pins, a line for each
2789
+ * relocked lock file, and the text of each tracked `package.json` and
2790
+ * `package-lock.json` that changed.
2791
+ */
2792
+ export declare class RelockedFiles {
2793
+ /**
2794
+ * The full id of the commit the relock ran at.
2795
+ */
2796
+ public readonly commit: string;
2797
+
2798
+ /**
2799
+ * The moved pins, each as the proposal's description lists it.
2800
+ */
2801
+ public readonly moves: readonly string[];
2802
+
2803
+ /**
2804
+ * A line for each relocked lock file, saying how it was relocked.
2805
+ */
2806
+ public readonly lockLines: readonly string[];
2807
+
2808
+ /**
2809
+ * The text of each file that changed, by its path in the repository.
2810
+ */
2811
+ public readonly files: Readonly<Record<string, string>>;
2812
+
2813
+ /**
2814
+ * Creates the result.
2815
+ *
2816
+ * @param commit The commit the relock ran at.
2817
+ * @param moves The moved pins.
2818
+ * @param lockLines The lock files' lines.
2819
+ * @param files The changed files' text, by path.
2820
+ */
2821
+ public constructor(commit: string, moves: readonly string[], lockLines: readonly string[], files: Readonly<Record<string, string>>);
2822
+
2823
+ /**
2824
+ * Writes a result, or a repository's line, as the JSON the relock step's
2825
+ * result file holds.
2826
+ *
2827
+ * @param relocked The result, or the line as a {@link StepResult}.
2828
+ * @returns The JSON.
2829
+ * @example
2830
+ * ```ts
2831
+ * import { RelockedFiles, StepResult } from "@noldova/tools.pipelines";
2832
+ *
2833
+ * RelockedFiles.format(StepResult.succeeded("noldova-com/example: pins none of them below 0.0.4."));
2834
+ * // {"isSuccessful":true,"message":"noldova-com/example: pins none of them below 0.0.4."}
2835
+ * ```
2836
+ */
2837
+ public static format(relocked: StepResult | RelockedFiles): string;
2838
+
2839
+ /**
2840
+ * Reads what {@link format} wrote.
2841
+ *
2842
+ * @param text The JSON.
2843
+ * @returns The result, or the repository's line as a {@link StepResult}
2844
+ * that succeeded or failed as it did. It throws when the text isn't such
2845
+ * JSON.
2846
+ */
2847
+ public static parse(text: string): StepResult | RelockedFiles;
2848
+ }
2849
+
2850
+ /**
2851
+ * The step a repository runs to relock itself for a release:
2852
+ * `relock <repository> <request> <result file> [<lock file>=<npm script>...]`.
2853
+ * Run in the repository's own checkout, prepared as its own build does, it
2854
+ * moves the pins and relocks as the {@link DependentsStep} does in its
2855
+ * checkout, with the repository's own npm configuration and credentials,
2856
+ * and writes the result file, which {@link RelockedFiles.parse} reads,
2857
+ * without committing or pushing. Each `<lock file>=<npm script>` relocks
2858
+ * that tracked lock file with {@link Npm.runScriptAsync} at the checkout's
2859
+ * root instead, after its moved entries are removed, and without stand-in
2860
+ * archives, for a lock the repository makes its own way.
2861
+ */
2862
+ export declare class RelockStep implements IStep {
2863
+ /**
2864
+ * The step's name, `"relock"`.
2865
+ */
2866
+ public readonly name: string;
2867
+
2868
+ /**
2869
+ * The values the step takes,
2870
+ * `"<repository> <request> <result file> [<lock file>=<npm script>...]"`.
2871
+ */
2872
+ public readonly usage: string;
2873
+
2874
+ /**
2875
+ * Creates the step.
2876
+ *
2877
+ * @param processRunner What runs git in the checkout.
2878
+ * @param npm What views packages, refreshes the lock files and runs the
2879
+ * lock scripts.
2880
+ * @param workingDirectory The checkout, which the result file's path is
2881
+ * relative to.
2882
+ * @example
2883
+ * ```ts
2884
+ * import { Npm, ProcessRunner, RelockStep } from "@noldova/tools.pipelines";
2885
+ *
2886
+ * const processRunner = new ProcessRunner();
2887
+ * const step = new RelockStep(processRunner, new Npm(processRunner, process.cwd()), process.cwd());
2888
+ * step.name; // "relock"
2889
+ * ```
2890
+ */
2891
+ public constructor(processRunner: ProcessRunner, npm: Npm, workingDirectory: string);
2892
+
2893
+ /**
2894
+ * Relocks the checkout and writes the result file.
2895
+ *
2896
+ * @param values The repository's full name, the release as the
2897
+ * {@link DependentsStep} sends it, the result file's path, and any lock
2898
+ * scripts.
2899
+ * @returns A promise of the result, which says how many pins moved and
2900
+ * files changed, or holds the repository's line. It fails, writing
2901
+ * nothing, for fewer than three values and for a lock script that isn't
2902
+ * `<lock file>=<npm script>`, with a script name of letters, digits and
2903
+ * `:`, `.`, `_` and `-`, or names a lock file twice; a lock script for an
2904
+ * untracked lock file, a failed relock and an error, such as npm failing,
2905
+ * are a failed line in the file, and the step succeeds. It throws when
2906
+ * the request isn't the release's JSON.
2907
+ * @example
2908
+ * ```ts
2909
+ * (await step.runAsync(["noldova-com/example", request, "relock.json", "app/package-lock.json=lock:app"])).message;
2910
+ * // noldova-com/example: moved 2 pins and wrote the 4 files that changed into the result.
2911
+ * ```
2912
+ */
2913
+ public runAsync(values: readonly string[]): Promise<StepResult>;
2914
+ }
2915
+
2713
2916
  /**
2714
2917
  * The step that moves the repositories that pin a shared repository's
2715
2918
  * workflows: `pins <version> <commit>`. Run from a clone of the shared
package/api/index.js CHANGED
@@ -14,6 +14,7 @@ export { BuildConfig } from "../models/build-config.js";
14
14
  export { BuildPackage } from "../models/build-package.js";
15
15
  export { PackageArchive } from "../models/package-archive.js";
16
16
  export { ProcessResult } from "../models/process-result.js";
17
+ export { RelockedFiles } from "../models/relocked-files.js";
17
18
  export { StepResult } from "../models/step-result.js";
18
19
  export { TrackedFile } from "../models/tracked-file.js";
19
20
  export { Version } from "../models/version.js";
@@ -30,6 +31,7 @@ export { PinsStep } from "../services/pins-step.js";
30
31
  export { ProcessRunner } from "../services/process-runner.js";
31
32
  export { PruneStep } from "../services/prune-step.js";
32
33
  export { PublishStep } from "../services/publish-step.js";
34
+ export { RelockStep } from "../services/relock-step.js";
33
35
  export { ReproducibleStep } from "../services/reproducible-step.js";
34
36
  export { SourceStep } from "../services/source-step.js";
35
37
  export { TagStep } from "../services/tag-step.js";
package/api/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;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AC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
@@ -5,6 +5,8 @@
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 { JsonReader } from "@noldova/context.json";
9
+ import { Resources } from "../resources.js";
8
10
  export class DependentsUpdate {
9
11
  source;
10
12
  version;
@@ -20,5 +22,23 @@ export class DependentsUpdate {
20
22
  this.peerPins = peerPins;
21
23
  this.notes = notes;
22
24
  }
25
+ static parseRequest(text) {
26
+ const reader = JsonReader.parse(text);
27
+ const peerPins = reader.readObjectArray(Resources.relockPeerPinsField).map(t => ({
28
+ packageName: t.readString(Resources.relockPackageNameField),
29
+ version: t.readString(Resources.relockVersionField),
30
+ reason: t.readNullableString(Resources.relockReasonField)
31
+ }));
32
+ return new DependentsUpdate(reader.readString(Resources.relockSourceField), reader.readString(Resources.relockVersionField), reader.readString(Resources.relockCommitField), reader.readStringArray(Resources.relockPackageNamesField), peerPins, "");
33
+ }
34
+ formatRequest() {
35
+ return JSON.stringify({
36
+ [Resources.relockSourceField]: this.source,
37
+ [Resources.relockVersionField]: this.version,
38
+ [Resources.relockCommitField]: this.commit,
39
+ [Resources.relockPackageNamesField]: this.packageNames,
40
+ [Resources.relockPeerPinsField]: this.peerPins.map(t => ({ [Resources.relockPackageNameField]: t.packageName, [Resources.relockVersionField]: t.version, [Resources.relockReasonField]: t.reason }))
41
+ });
42
+ }
23
43
  }
24
44
  //# sourceMappingURL=dependents-update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependents-update.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines/src/models/dependents-update.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,OAAO,gBAAgB;IACX,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,YAAY,CAAoB;IAChC,QAAQ,CAAuB;IAC/B,KAAK,CAAS;IAE9B,YAAmB,MAAc,EAAE,OAAe,EAAE,MAAc,EAAE,YAA+B,EAAE,QAA8B,EAAE,KAAa;QAChJ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
1
+ {"version":3,"file":"dependents-update.js","sourceRoot":"","s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AU,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,EACzK,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,MAAM;YAC1C,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,OAAO;YAC5C,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,MAAM;YAC1C,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,IAAI,CAAC,YAAY;YACtD,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;SACrM,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,37 @@
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 { JsonReader } from "@noldova/context.json";
9
+ import { Resources } from "../resources.js";
10
+ import { StepResult } from "./step-result.js";
11
+ export class RelockedFiles {
12
+ commit;
13
+ moves;
14
+ lockLines;
15
+ files;
16
+ constructor(commit, moves, lockLines, files) {
17
+ this.commit = commit;
18
+ this.moves = moves;
19
+ this.lockLines = lockLines;
20
+ this.files = files;
21
+ }
22
+ static format(relocked) {
23
+ return JSON.stringify(relocked instanceof StepResult
24
+ ? { [Resources.relockSucceededField]: relocked.isSuccessful, [Resources.relockMessageField]: relocked.message }
25
+ : { [Resources.relockCommitField]: relocked.commit, [Resources.relockMovesField]: relocked.moves, [Resources.relockLockLinesField]: relocked.lockLines, [Resources.relockFilesField]: relocked.files });
26
+ }
27
+ static parse(text) {
28
+ const reader = JsonReader.parse(text);
29
+ if (reader.hasField(Resources.relockMessageField)) {
30
+ const message = reader.readString(Resources.relockMessageField);
31
+ return reader.readBoolean(Resources.relockSucceededField) ? StepResult.succeeded(message) : StepResult.failed(message);
32
+ }
33
+ const files = reader.readObject(Resources.relockFilesField);
34
+ return new RelockedFiles(reader.readString(Resources.relockCommitField), reader.readStringArray(Resources.relockMovesField), reader.readStringArray(Resources.relockLockLinesField), Object.fromEntries(Object.keys(files.toJson()).map(t => [t, files.readString(t)])));
35
+ }
36
+ }
37
+ //# sourceMappingURL=relocked-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relocked-files.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines/src/models/relocked-files.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,aAAa;IACR,MAAM,CAAS;IACf,KAAK,CAAoB;IACzB,SAAS,CAAoB;IAC7B,KAAK,CAAmC;IAExD,YAAmB,MAAc,EAAE,KAAwB,EAAE,SAA4B,EAAE,KAAuC;QAChI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,MAA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CAAC,oBAAoB,CAAC,EACjL,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noldova/tools.pipelines",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "main": "api/index.js",
6
6
  "types": "api/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
21
  "dependencies": {
22
- "@noldova/context.exceptions": "0.0.5",
23
- "@noldova/context.json": "0.0.5"
22
+ "@noldova/context.exceptions": "0.0.6",
23
+ "@noldova/context.json": "0.0.6"
24
24
  },
25
- "gitHead": "aceb11f0f93043831dc35c76d6be580b62430928"
25
+ "gitHead": "5ff2cfba8457fea9cdab7364e34c2c3b7f436828"
26
26
  }
package/resources.js CHANGED
@@ -28,6 +28,23 @@ export class Resources {
28
28
  static dependentsFolderPrefix = "pipelines-dependents-";
29
29
  static dependentsStepName = "dependents";
30
30
  static dependentsStepUsage = "<version> <commit>";
31
+ static lockScriptPattern = /^[A-Za-z0-9][A-Za-z0-9:._-]*$/;
32
+ static lockScriptSeparator = "=";
33
+ static npmScriptValues = ["run"];
34
+ static relockCommitField = "commit";
35
+ static relockFilesField = "files";
36
+ static relockLockLinesField = "lockLines";
37
+ static relockMessageField = "message";
38
+ static relockMovesField = "moves";
39
+ static relockPackageNameField = "packageName";
40
+ static relockPackageNamesField = "packageNames";
41
+ static relockPeerPinsField = "peerPins";
42
+ static relockReasonField = "reason";
43
+ static relockSourceField = "source";
44
+ static relockStepName = "relock";
45
+ static relockStepUsage = "<repository> <request> <result file> [<lock file>=<npm script>...]";
46
+ static relockSucceededField = "isSuccessful";
47
+ static relockVersionField = "version";
31
48
  static dependabotFilePaths = [".github/dependabot.yml", ".github/dependabot.yaml"];
32
49
  static failureExitCode = 1;
33
50
  static exactVersionPattern = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/;
@@ -148,6 +165,14 @@ export class Resources {
148
165
  static unchangedStepUsage = "";
149
166
  static updateIssueSummary = "A release moved packages this repository pins exactly";
150
167
  static textEncoding = "utf8";
168
+ static lockedDependencyFields = ["dependencies", "devDependencies", "optionalDependencies"];
169
+ static standInArchiveExtension = ".tgz";
170
+ static standInEntryName = "package/package.json";
171
+ static standInFolderSuffix = "-own";
172
+ static standInVersion = "0.0.0";
173
+ static tarBlockSize = 512;
174
+ static tarChecksumOffset = 148;
175
+ static tarHeaderEncoding = "ascii";
151
176
  static usesPattern = /^([ \t]*(?:-[ \t]+)?uses:[ \t]*)([^@\s#]+)@([0-9a-f]{40})(?:[ \t]+#[ \t]*(\S+))?/gm;
152
177
  static workflowExtensions = [".yml", ".yaml"];
153
178
  static workflowsFolderPath = ".github/workflows";
@@ -546,6 +571,62 @@ export class Resources {
546
571
  static formatRepositoryUnmatched(repository, version, misses) {
547
572
  return `${repository}: left at its pins, which can't take what ${version} moves: ${misses.join("; ")}.`;
548
573
  }
574
+ static formatRepositoryOwnShared(repository, version, shared) {
575
+ return `${repository}: left at its pins for ${version}, since a lock folder pins its own unpublished packages and more than one tracked manifest names the same one: ${shared.join("; ")}.`;
576
+ }
577
+ static formatRepositoryPeersLost(repository, version, lockFilePath, keys) {
578
+ return `${repository}: left at its pins for ${version}, since relocking ${lockFilePath}, which installs no peer for the repository's own packages, would drop the peers it locks that no moved package names: ${keys.join(", ")}.`;
579
+ }
580
+ static formatOwnManifests(packageName, manifestPaths) {
581
+ return `${packageName} in ${manifestPaths.join(", ")}`;
582
+ }
583
+ static formatOwnLocked(lockFilePath, packageNames) {
584
+ return `\`${lockFilePath}\`: the repository's own ${packageNames.map(t => `\`${t}\``).join(", ")} locked from their tracked manifests, without asking the registry; their entries left out, and the root entry keeps the folder's pins`;
585
+ }
586
+ static formatLocked(lockFilePath) {
587
+ return `\`${lockFilePath}\`: the moved packages, the entries nested under them and the entries that depend on them resolved again with \`npm ${Resources.npmLockValues.join(Resources.valueSeparator)}\`; every other entry kept unless a resolved package needs it to change`;
588
+ }
589
+ static formatScriptLocked(lockFilePath, script) {
590
+ return `\`${lockFilePath}\`: the moved packages, the entries nested under them and the entries that depend on them resolved again with the repository's own \`npm ${Resources.npmScriptValues.join(Resources.valueSeparator)} ${script}\`, after the dependent prepared its checkout as its own build does`;
591
+ }
592
+ static formatLockScriptsUntracked(lockFilePaths) {
593
+ return `The lock scripts name lock files the repository doesn't track: ${lockFilePaths.join(", ")}.`;
594
+ }
595
+ static formatLockScriptFailed(lockFilePath, script, exitCode, errorOutput) {
596
+ return Resources.formatFailureLine(`Relocking ${lockFilePath}, npm ${Resources.npmScriptValues.join(Resources.valueSeparator)} ${script}, exited with code ${exitCode}`, errorOutput);
597
+ }
598
+ static formatLockScriptInvalid(value) {
599
+ return `${value} isn't a lock script: give each tracked lock file once, as <lock file>=<npm script>, such as app/package-lock.json=lock:app, with a script name of letters, digits and : . _ -.`;
600
+ }
601
+ static formatRelockWritten(repository, moveCount, fileCount) {
602
+ return `${repository}: moved ${moveCount} pins and wrote the ${fileCount} files that changed into the result.`;
603
+ }
604
+ static formatRelockedElsewhere(relocked, head) {
605
+ return `The repository's relock ran at ${relocked}, not at ${head}, the commit the step checked out and sent, so none of its files are taken.`;
606
+ }
607
+ static formatRelockedUntracked(filePaths) {
608
+ return `The repository's relock changed files that aren't its tracked package.json or package-lock.json files, so none are taken: ${filePaths.join(", ")}.`;
609
+ }
610
+ static formatWindowsNpmScriptValues(script) {
611
+ return ["/d", "/s", "/c", `npm.cmd ${Resources.npmScriptValues.join(Resources.valueSeparator)} ${script}`];
612
+ }
613
+ static formatTarHeaderFields(entryName, size) {
614
+ return [
615
+ [0, entryName],
616
+ [100, "0000644\0"],
617
+ [108, "0000000\0"],
618
+ [116, "0000000\0"],
619
+ [124, `${size.toString(8).padStart(11, "0")}\0`],
620
+ [136, "00000000000\0"],
621
+ [148, " "],
622
+ [156, "0"],
623
+ [257, "ustar\0"],
624
+ [263, "00"]
625
+ ];
626
+ }
627
+ static formatTarChecksum(checksum) {
628
+ return `${checksum.toString(8).padStart(6, "0")}\0 `;
629
+ }
549
630
  static formatRepositoryFailed(repository, message) {
550
631
  return `${repository}: ${message}`;
551
632
  }
@@ -567,14 +648,14 @@ export class Resources {
567
648
  static formatUpdateBranch(source) {
568
649
  return `pipelines/update-${source}`;
569
650
  }
570
- static formatUpdateBody(source, version, commit, moves, lockFilePaths, notes) {
651
+ static formatUpdateBody(source, version, commit, moves, lockLines, notes) {
571
652
  return [
572
653
  "## Summary",
573
654
  "",
574
655
  `${source} released ${version} from commit ${commit}; this moves every exact pin of its packages that was older.`,
575
656
  "",
576
657
  ...moves.map(t => `- ${t}`),
577
- ...lockFilePaths.map(t => `- \`${t}\`: the moved packages, the entries nested under them and the entries that depend on them resolved again with \`npm ${Resources.npmLockValues.join(Resources.valueSeparator)}\`; every other entry kept unless a resolved package needs it to change`),
658
+ ...lockLines.map(t => `- ${t}`),
578
659
  "",
579
660
  notes.length === 0 ? `The pull request that merged ${commit} has no "Release notes" section.` : notes
580
661
  ].join(Resources.lineSeparator);