@intellectual-frontiers/libraries 0.2.1 → 0.4.1

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.
Files changed (56) hide show
  1. package/LICENSE +75 -21
  2. package/dist/affected.d.ts +15 -2
  3. package/dist/affected.js +51 -20
  4. package/dist/dev.d.ts +83 -0
  5. package/dist/dev.js +359 -0
  6. package/dist/family.d.ts +58 -0
  7. package/dist/family.js +125 -0
  8. package/dist/generate-ontology.js +4 -0
  9. package/dist/generate-workflows.js +2 -10
  10. package/dist/install-bun.js +19 -14
  11. package/dist/libraries.d.ts +8 -0
  12. package/dist/libraries.js +24 -3
  13. package/dist/license/standard.d.ts +46 -0
  14. package/dist/license/standard.js +43 -0
  15. package/dist/license/third-party.d.ts +25 -0
  16. package/dist/license/third-party.js +71 -0
  17. package/dist/license.d.ts +61 -0
  18. package/dist/license.js +204 -0
  19. package/dist/link.d.ts +12 -0
  20. package/dist/link.js +98 -0
  21. package/dist/pack-library.d.ts +2 -0
  22. package/dist/pack-library.js +21 -3
  23. package/dist/pins.d.ts +34 -7
  24. package/dist/pins.js +36 -9
  25. package/dist/plan.d.ts +28 -0
  26. package/dist/plan.js +135 -0
  27. package/dist/readme.d.ts +59 -0
  28. package/dist/readme.js +272 -0
  29. package/dist/releasing.d.ts +176 -0
  30. package/dist/releasing.js +680 -0
  31. package/dist/versions.js +4 -7
  32. package/dist/workflows/definitions.d.ts +33 -30
  33. package/dist/workflows/definitions.js +201 -278
  34. package/dist/workflows/model.d.ts +19 -3
  35. package/dist/workflows/render.js +10 -2
  36. package/package.json +44 -14
  37. package/src/affected.ts +56 -17
  38. package/src/dev.ts +379 -0
  39. package/src/family.ts +144 -0
  40. package/src/generate-ontology.ts +4 -0
  41. package/src/generate-workflows.ts +3 -11
  42. package/src/install-bun.ts +16 -13
  43. package/src/libraries.ts +27 -3
  44. package/src/license/standard.ts +67 -0
  45. package/src/license/third-party.ts +87 -0
  46. package/src/license.ts +222 -0
  47. package/src/link.ts +97 -0
  48. package/src/pack-library.ts +21 -3
  49. package/src/pins.ts +55 -10
  50. package/src/plan.ts +143 -0
  51. package/src/readme.ts +278 -0
  52. package/src/releasing.ts +735 -0
  53. package/src/versions.ts +3 -7
  54. package/src/workflows/definitions.ts +262 -397
  55. package/src/workflows/model.ts +15 -3
  56. package/src/workflows/render.ts +10 -2
@@ -85,20 +85,29 @@ export type Permissions = Readonly<
85
85
  /** The branches, paths and tags a push or a pull request is run for; none is every one. */
86
86
  export type Filter = { readonly branches?: readonly string[]; readonly paths?: readonly string[]; readonly tags?: readonly string[] };
87
87
 
88
+ /** A question a run by hand asks: a yes or no with its default. */
89
+ export type DispatchInput = { readonly description: string; readonly type: "boolean"; readonly default: boolean };
90
+
91
+ /** What starts a generated workflow: pushes, pull requests, dispatch and schedule. */
88
92
  export type Triggers = {
89
93
  readonly push?: Filter;
90
94
  readonly pullRequest?: Filter;
91
- /** Run by hand from the Actions page. */
92
- readonly workflowDispatch?: true;
95
+ /** Run by hand from the Actions page, with the inputs it asks for (true asks for none). */
96
+ readonly workflowDispatch?: true | { readonly inputs: Readonly<Record<string, DispatchInput>> };
93
97
  /** Called by another workflow. */
94
98
  readonly workflowCall?: true;
95
99
  };
96
100
 
101
+ /** The cells of a matrix: the values of each axis, or an expression that gives the whole matrix (`expr("fromJSON(needs.plan.outputs.linux)")`), which a job reads from the output of another. */
102
+ export type Matrix = Readonly<Record<string, readonly (string | number)[]>> | Expr;
103
+
104
+ /** The matrix strategy of a job of a generated workflow. */
97
105
  export type Strategy = {
98
106
  readonly failFast?: boolean;
99
- readonly matrix: Readonly<Record<string, readonly (string | number)[]>>;
107
+ readonly matrix: Matrix;
100
108
  };
101
109
 
110
+ /** A job of a generated workflow. */
102
111
  export type Job = {
103
112
  readonly name?: string;
104
113
  readonly runsOn: Runner;
@@ -109,6 +118,8 @@ export type Job = {
109
118
  readonly permissions?: Permissions;
110
119
  readonly environment?: { readonly name: string; readonly url?: string };
111
120
  readonly env?: Readonly<Record<string, Scalar>>;
121
+ /** What the job gives the jobs that need it, by name: an expression of its steps' outputs. */
122
+ readonly outputs?: Readonly<Record<string, Expr>>;
112
123
  readonly strategy?: Strategy;
113
124
  readonly steps: readonly [Step, ...Step[]];
114
125
  /** A comment written above the job. */
@@ -118,6 +129,7 @@ export type Job = {
118
129
  /** A job, written as a function so that its steps are read as a non-empty tuple. */
119
130
  export const job = (j: Job): Job => j;
120
131
 
132
+ /** A generated workflow: its name, triggers, permissions and jobs. */
121
133
  export type Workflow = {
122
134
  /** The file's name without its directory and extension: `data` is `.github/workflows/data.auto.yml`. */
123
135
  readonly file: string;
@@ -126,10 +126,12 @@ function jobLines(id: string, j: Job): string[] {
126
126
  if (j.environment.url !== undefined) out.push(...entry("url", j.environment.url, 6));
127
127
  }
128
128
  out.push(...mapping("env", j.env, 4));
129
+ out.push(...mapping("outputs", j.outputs, 4));
129
130
  if (j.strategy !== undefined) {
130
131
  out.push(" strategy:");
131
132
  if (j.strategy.failFast !== undefined) out.push(...entry("fail-fast", j.strategy.failFast, 6));
132
- out.push(" matrix:", ...Object.entries(j.strategy.matrix).flatMap(([k, v]) => flowList(k, v, 8)));
133
+ const m = j.strategy.matrix;
134
+ out.push(...(typeof m === "string" ? entry("matrix", m, 6) : [" matrix:", ...Object.entries(m).flatMap(([k, v]) => flowList(k, v, 8))]));
133
135
  }
134
136
  out.push(" steps:", ...j.steps.flatMap((s) => step(s, 6)));
135
137
  return out;
@@ -141,7 +143,13 @@ export function renderWorkflow(w: Workflow): string {
141
143
  if (w.comment !== undefined) out.push(...comment(w.comment, 0));
142
144
  out.push("on:");
143
145
  out.push(...filter("push", w.on.push, 2), ...filter("pull_request", w.on.pullRequest, 2));
144
- if (w.on.workflowDispatch === true) out.push(" workflow_dispatch:");
146
+ const dispatch = w.on.workflowDispatch;
147
+ if (dispatch === true) out.push(" workflow_dispatch:");
148
+ else if (dispatch !== undefined) {
149
+ out.push(" workflow_dispatch:", " inputs:");
150
+ for (const [k, v] of Object.entries(dispatch.inputs))
151
+ out.push(` ${key(k)}:`, ...entry("description", v.description, 8), ...entry("type", v.type, 8), ...entry("default", v.default, 8));
152
+ }
145
153
  if (w.on.workflowCall === true) out.push(" workflow_call:");
146
154
  out.push("");
147
155
  if (w.permissions !== undefined) out.push(...permissions(w.permissions, 0), "");