@r_masseater/msch 0.54.0 → 0.57.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.
- package/README.md +18 -18
- package/dist/app-B22Gq0no.mjs +2120 -0
- package/dist/app-B22Gq0no.mjs.map +1 -0
- package/dist/cargo-inputs.d.mts +1 -1
- package/dist/cargo-inputs.mjs +5 -11
- package/dist/cargo-inputs.mjs.map +1 -1
- package/dist/changed.mjs +90 -19
- package/dist/changed.mjs.map +1 -1
- package/dist/cli.mjs +1361 -707
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +3 -2
- package/dist/config.mjs.map +1 -1
- package/dist/credential-broker-9FMyTp1H.mjs +44 -0
- package/dist/credential-broker-9FMyTp1H.mjs.map +1 -0
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-CWEkZVIC.mjs → define-lint-preset-DeLIlDuA.mjs} +7 -634
- package/dist/define-lint-preset-DeLIlDuA.mjs.map +1 -0
- package/dist/dependencies-B6p7x90y.mjs +215 -0
- package/dist/dependencies-B6p7x90y.mjs.map +1 -0
- package/dist/exits.mjs +4 -5
- package/dist/exits.mjs.map +1 -1
- package/dist/{ignored-directories-BTMTNuAx.mjs → ignored-directories-BgUqwuc4.mjs} +12 -3
- package/dist/ignored-directories-BgUqwuc4.mjs.map +1 -0
- package/dist/{index-BeH2yfX6.d.mts → index-Cwnhs7VE.d.mts} +4 -51
- package/dist/library.d.mts +18 -0
- package/dist/library.mjs +28 -0
- package/dist/library.mjs.map +1 -0
- package/dist/lint-rules.mjs +243 -40
- package/dist/lint-rules.mjs.map +1 -1
- package/dist/lint.d.mts +2 -2
- package/dist/lint.mjs +1 -1
- package/dist/locked-inputs-DMSoGCa-.mjs +20 -0
- package/dist/locked-inputs-DMSoGCa-.mjs.map +1 -0
- package/dist/locked-inputs.d.mts +2 -3
- package/dist/locked-inputs.mjs +1 -20
- package/dist/oxlint.mjs +28 -14
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{project-C4uzq7_4.mjs → pass-records-BCT1Ls9c.mjs} +38 -66
- package/dist/pass-records-BCT1Ls9c.mjs.map +1 -0
- package/dist/{problem-CzOlOb5f.mjs → problem-BoHYLMQT.mjs} +10 -6
- package/dist/problem-BoHYLMQT.mjs.map +1 -0
- package/dist/publish.mjs +634 -303
- package/dist/publish.mjs.map +1 -1
- package/dist/published-BNJdq0h1.mjs +510 -0
- package/dist/published-BNJdq0h1.mjs.map +1 -0
- package/dist/runtime-LT40e_l3.mjs +28 -0
- package/dist/runtime-LT40e_l3.mjs.map +1 -0
- package/dist/{syntax-3AJkpCcs.mjs → syntax-CTiXR0EJ.mjs} +13 -4
- package/dist/syntax-CTiXR0EJ.mjs.map +1 -0
- package/dist/{check-upstream-exits-DYxWDyHC.mjs → upstream-exits-DitN-yYH.mjs} +10 -92
- package/dist/upstream-exits-DitN-yYH.mjs.map +1 -0
- package/dist/wake.d.mts +1 -0
- package/dist/wake.mjs +25 -0
- package/dist/wake.mjs.map +1 -0
- package/dist/workspace-settings.mjs +69 -7
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +31 -22
- package/skills/{publishing → msch-publishing}/SKILL.md +8 -2
- package/skills/{repository-config → msch-repository-config}/SKILL.md +5 -2
- package/skills/{workspace-settings → msch-workspace-settings}/SKILL.md +4 -3
- package/dist/check-upstream-exits-DYxWDyHC.mjs.map +0 -1
- package/dist/define-lint-preset-CWEkZVIC.mjs.map +0 -1
- package/dist/dependencies-DCJv7YcW.mjs +0 -684
- package/dist/dependencies-DCJv7YcW.mjs.map +0 -1
- package/dist/ignored-directories-BTMTNuAx.mjs.map +0 -1
- package/dist/locked-inputs.mjs.map +0 -1
- package/dist/package-LeBO9czg.mjs +0 -144
- package/dist/package-LeBO9czg.mjs.map +0 -1
- package/dist/problem-CzOlOb5f.mjs.map +0 -1
- package/dist/project-C4uzq7_4.mjs.map +0 -1
- package/dist/reachable-Cc-255L3.mjs +0 -13
- package/dist/reachable-Cc-255L3.mjs.map +0 -1
- package/dist/runtime-DFsdNYI0.mjs +0 -29
- package/dist/runtime-DFsdNYI0.mjs.map +0 -1
- package/dist/syntax-3AJkpCcs.mjs.map +0 -1
package/dist/publish.mjs
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as runCli } from "./runtime-
|
|
3
|
-
import {
|
|
2
|
+
import { t as runCli } from "./runtime-LT40e_l3.mjs";
|
|
3
|
+
import { i as writeOutputs, n as actionsOidcToken, r as mask, t as BROKER } from "./credential-broker-9FMyTp1H.mjs";
|
|
4
|
+
import { Array, Config, Console, Effect, FileSystem, Option, Order, Path, Predicate, Record, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
4
5
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
5
6
|
import semver from "semver";
|
|
6
7
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
7
8
|
import { Base64 } from "effect/encoding";
|
|
8
|
-
|
|
9
|
-
const API = "https://api.github.com";
|
|
10
|
-
const HEADERS = {
|
|
11
|
-
accept: "application/vnd.github+json",
|
|
12
|
-
"user-agent": "masseater.dev",
|
|
13
|
-
"x-github-api-version": "2022-11-28"
|
|
14
|
-
};
|
|
15
|
-
const requestTo = Effect.fn("requestTo")(function* requestTo(method, path) {
|
|
16
|
-
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
17
|
-
const token = yield* Config.Redacted("GH_TOKEN").pipe(Config.orElse(() => Config.Redacted("GITHUB_TOKEN")));
|
|
18
|
-
return HttpClientRequest.make(method)(`${API}/repos/${repository}/${path}`).pipe(HttpClientRequest.bearerToken(Redacted.value(token)), HttpClientRequest.setHeaders(HEADERS));
|
|
19
|
-
});
|
|
20
|
-
const execute = Effect.fn("execute")(function* execute(request) {
|
|
21
|
-
const response = yield* (yield* HttpClient.HttpClient).execute(request);
|
|
22
|
-
return yield* HttpClientResponse.filterStatusOk(response);
|
|
23
|
-
});
|
|
24
|
-
Effect.fn("withBody")(function* withBody(method, path, body) {
|
|
25
|
-
const request = yield* requestTo(method, path);
|
|
26
|
-
const filled = yield* HttpClientRequest.bodyJson(request, body);
|
|
27
|
-
return yield* execute(filled);
|
|
28
|
-
});
|
|
9
|
+
import { arch, platform } from "node:os";
|
|
29
10
|
// ../github-workflow/src/shared/lib/process.ts
|
|
30
11
|
const SUCCESS = 0;
|
|
31
12
|
const taggedError$4 = Schema.TaggedError;
|
|
@@ -57,169 +38,126 @@ const collected = Effect.fn("collected")(function* collected({ command, args, en
|
|
|
57
38
|
code
|
|
58
39
|
};
|
|
59
40
|
});
|
|
60
|
-
const outputWith = (command) => collected(command).pipe(Effect.scoped, Effect.filterOrFail(({ code }) => code === SUCCESS, () => failed(command)), Effect.map(({ output }) => String.trim(output)));
|
|
41
|
+
const outputWith = (command) => collected(command).pipe(Effect.scoped, Effect.filterOrFail(({ code }) => code === SUCCESS, () => failed(command)), Effect.map(({ output }) => String$1.trim(output)));
|
|
61
42
|
/** @internal */
|
|
62
43
|
const succeeds = succeedsWith;
|
|
63
44
|
/** @internal */
|
|
64
45
|
const mustSucceed = mustSucceedWith;
|
|
65
46
|
/** @internal */
|
|
66
47
|
const outputOf = outputWith;
|
|
67
|
-
//
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const lines = pipe(Record.toEntries(entries), Array.map(([name, value]) => `${name}=${value}\n`), Array.join(""));
|
|
74
|
-
yield* fs.writeFileString(path, lines, { flag: "a" });
|
|
75
|
-
});
|
|
76
|
-
const outputsOf = (outputs) => appendTo("GITHUB_OUTPUT", outputs);
|
|
48
|
+
// src/features/publish-workspace/model/compat-manifest.ts
|
|
49
|
+
const PACKAGE_JSON_EXPORT = "./package.json";
|
|
50
|
+
const PATTERN$1 = "*";
|
|
51
|
+
const ROOT_EXPORT = ".";
|
|
52
|
+
const UNVERSIONED$2 = "0.0.0";
|
|
53
|
+
const VITE = "vite";
|
|
77
54
|
/** @internal */
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
yield* Console.log(`::error::${message}`);
|
|
82
|
-
return yield* WorkflowFailed.make({ message });
|
|
83
|
-
});
|
|
84
|
-
// src/features/publish-workspace/model/broker.ts
|
|
85
|
-
const BROKER = "https://credentials.masseater.dev/";
|
|
86
|
-
const AUDIENCE = "masseater-dev-credential-broker";
|
|
87
|
-
const IdToken = Schema.Struct({ value: Schema.String });
|
|
88
|
-
const Issued = Schema.Record(Schema.String, Schema.Unknown);
|
|
89
|
-
const oidcToken = Effect.fn("publish.oidc")(function* oidcToken(requestUrl, requestToken) {
|
|
90
|
-
const client = yield* HttpClient.HttpClient;
|
|
91
|
-
const request = HttpClientRequest.get(`${requestUrl}&audience=${AUDIENCE}`).pipe(HttpClientRequest.bearerToken(Redacted.value(requestToken)));
|
|
92
|
-
const response = yield* HttpClient.filterStatusOk(client).execute(request);
|
|
93
|
-
const { value } = yield* HttpClientResponse.schemaBodyJson(IdToken)(response);
|
|
94
|
-
yield* mask(value);
|
|
95
|
-
return value;
|
|
96
|
-
});
|
|
97
|
-
const issued = Effect.fn("publish.issued")(function* issued(oidc, { kind, field }) {
|
|
98
|
-
const client = yield* HttpClient.HttpClient;
|
|
99
|
-
const request = HttpClientRequest.post(`${BROKER}?only=${kind}`).pipe(HttpClientRequest.bearerToken(oidc));
|
|
100
|
-
const response = yield* HttpClient.filterStatusOk(client).execute(request);
|
|
101
|
-
const body = yield* HttpClientResponse.schemaBodyJson(Issued)(response);
|
|
102
|
-
const token = Option.filter(Option.fromNullishOr(body[field]), (value) => typeof value === "string" && value !== "");
|
|
103
|
-
yield* Effect.forEach(Option.toArray(token), mask, {
|
|
104
|
-
concurrency: 1,
|
|
105
|
-
discard: true
|
|
106
|
-
});
|
|
107
|
-
return token;
|
|
108
|
-
});
|
|
55
|
+
const VITE_PLUS = "vite-plus";
|
|
56
|
+
const TYPES = "types";
|
|
57
|
+
const taggedError$3 = Schema.TaggedError;
|
|
109
58
|
/** @internal */
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
// src/features/publish-workspace/model/manifest.ts
|
|
117
|
-
const MANIFEST_FILE$2 = "package.json";
|
|
118
|
-
const SCOPE = /^@[^/]+\//u;
|
|
119
|
-
const UNVERSIONED$1 = "0.0.0";
|
|
120
|
-
const ROOT = ".";
|
|
121
|
-
const Native = Schema.Struct({
|
|
59
|
+
var IncompatiblePackage = class extends taggedError$3()("IncompatiblePackage", { message: Schema.String }) {};
|
|
60
|
+
const Declared = Schema.Record(Schema.String, Schema.String);
|
|
61
|
+
const VitePlusManifestJson = Schema.fromJsonString(Schema.Struct({ dependencies: Schema.optionalKey(Declared) }));
|
|
62
|
+
const Bin = Schema.Union([Schema.String, Declared]);
|
|
63
|
+
const Native$1 = Schema.Struct({
|
|
122
64
|
binary: Schema.String,
|
|
123
65
|
targets: Schema.Array(Schema.String)
|
|
124
66
|
});
|
|
125
|
-
const
|
|
67
|
+
const Engines = Schema.Struct({ node: Schema.optionalKey(Schema.String) });
|
|
68
|
+
const PublishConfig$1 = Schema.Struct({
|
|
69
|
+
exports: Schema.optionalKey(Schema.Unknown),
|
|
70
|
+
bin: Schema.optionalKey(Bin)
|
|
71
|
+
});
|
|
72
|
+
/** @internal */
|
|
73
|
+
const CompatManifestJson = Schema.fromJsonString(Schema.Struct({
|
|
126
74
|
name: Schema.String,
|
|
127
75
|
version: Schema.String,
|
|
128
76
|
private: Schema.optionalKey(Schema.Boolean),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/** @internal */
|
|
143
|
-
const isRoot = (directory) => directory === ROOT;
|
|
144
|
-
/** @internal */
|
|
145
|
-
const tagOf = ({ directory, name, version }) => {
|
|
146
|
-
if (isRoot(directory)) return `v${version}`;
|
|
147
|
-
return `${releaseName({ name })}-v${version}`;
|
|
77
|
+
native: Schema.optionalKey(Native$1),
|
|
78
|
+
exports: Schema.optionalKey(Schema.Unknown),
|
|
79
|
+
bin: Schema.optionalKey(Bin),
|
|
80
|
+
dependencies: Schema.optionalKey(Declared),
|
|
81
|
+
optionalDependencies: Schema.optionalKey(Declared),
|
|
82
|
+
engines: Schema.optionalKey(Engines),
|
|
83
|
+
peerDependencies: Schema.optionalKey(Declared),
|
|
84
|
+
publishConfig: Schema.optionalKey(PublishConfig$1)
|
|
85
|
+
}));
|
|
86
|
+
const lowestOf = (range) => pipe(Option.fromNullishOr(semver.validRange(range)), Option.flatMap(() => Option.fromNullishOr(semver.minVersion(range))), Option.map(({ version }) => version));
|
|
87
|
+
const floorOf = (version) => {
|
|
88
|
+
if (semver.prerelease(version) !== null) return version;
|
|
89
|
+
return `~${String(semver.major(version))}.${String(semver.minor(version))}.0`;
|
|
148
90
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// src/features/publish-workspace/model/dependencies.ts
|
|
156
|
-
const WORKSPACE_PROTOCOL = "workspace:";
|
|
157
|
-
const READ_CONCURRENCY = 8;
|
|
158
|
-
/** @internal */
|
|
159
|
-
const onNpm = ({ directory, name, version }) => succeeds({
|
|
160
|
-
command: "npm",
|
|
161
|
-
args: [
|
|
162
|
-
"view",
|
|
163
|
-
`${name}@${version}`,
|
|
164
|
-
"version"
|
|
165
|
-
],
|
|
166
|
-
cwd: directory
|
|
91
|
+
const pinnedPeer = ([name, range]) => Option.match(lowestOf(range), {
|
|
92
|
+
onNone: () => [],
|
|
93
|
+
onSome: (version) => {
|
|
94
|
+
if (version === UNVERSIONED$2) return [[name, range]];
|
|
95
|
+
return [[name, floorOf(version)]];
|
|
96
|
+
}
|
|
167
97
|
});
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (Array.isReadonlyArrayEmpty(missing)) return Effect.void;
|
|
174
|
-
const names = pipe(missing, Array.map(({ directory, name, version }) => `${name}@${version} (${directory})`), Array.join(", "));
|
|
175
|
-
return Effect.fail(UnpublishedDependencies.make({ message: `${manifest.name} depends on versions that are not on npm yet. Publish them first: ${names}` }));
|
|
98
|
+
const floorPeers = (peers) => pipe(Record.toEntries(peers), Array.flatMap(pinnedPeer), Record.fromEntries);
|
|
99
|
+
const nodeFloorOf = (manifest) => pipe(Option.fromUndefinedOr(manifest.engines), Option.flatMap(({ node }) => Option.fromUndefinedOr(node)), Option.flatMap(lowestOf));
|
|
100
|
+
const withoutViteOfVitePlus = (peers) => {
|
|
101
|
+
if (Record.has(peers, "vite-plus")) return Record.remove(peers, VITE);
|
|
102
|
+
return peers;
|
|
176
103
|
};
|
|
177
104
|
/** @internal */
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const taggedError$1 = Schema.TaggedError;
|
|
105
|
+
const viteAliasOf = (vitePlusManifest) => pipe(Schema.decodeOption(VitePlusManifestJson)(vitePlusManifest), Option.flatMapNullishOr(({ dependencies }) => dependencies), Option.flatMap(Record.get(VITE)), Option.map((spec) => `${VITE}@${spec}`));
|
|
106
|
+
const casesOf = (manifest, floor) => {
|
|
107
|
+
const declared = withoutViteOfVitePlus(manifest.peerDependencies ?? {});
|
|
108
|
+
return [{
|
|
109
|
+
label: "floor",
|
|
110
|
+
node: floorOf(floor),
|
|
111
|
+
peers: floorPeers(declared)
|
|
112
|
+
}, {
|
|
113
|
+
label: "latest",
|
|
114
|
+
node: `^${String(semver.major(floor))}`,
|
|
115
|
+
peers: declared
|
|
116
|
+
}];
|
|
117
|
+
};
|
|
192
118
|
/** @internal */
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const PublishedExports = Schema.fromJsonString(Schema.Struct({
|
|
197
|
-
exports: AnyExports,
|
|
198
|
-
publishConfig: Schema.optionalKey(PublishConfig)
|
|
119
|
+
const compatCasesOf = (manifest) => pipe(nodeFloorOf(manifest), Option.match({
|
|
120
|
+
onNone: () => [],
|
|
121
|
+
onSome: (floor) => casesOf(manifest, floor)
|
|
199
122
|
}));
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
123
|
+
const isTypesOnly = (target) => Option.match(target, {
|
|
124
|
+
onNone: () => false,
|
|
125
|
+
onSome: (value) => Predicate.isReadonlyObject(value) && pipe(Record.keys(value), Array.every((key) => key === TYPES))
|
|
126
|
+
});
|
|
127
|
+
const subpathsOf = (exports) => {
|
|
128
|
+
if (Predicate.isString(exports)) return [ROOT_EXPORT];
|
|
129
|
+
if (Predicate.isReadonlyObject(exports)) {
|
|
130
|
+
const keys = Record.keys(exports);
|
|
131
|
+
if (pipe(keys, Array.every(String$1.startsWith(ROOT_EXPORT)))) return pipe(keys, Array.filter((key) => key !== PACKAGE_JSON_EXPORT && !String$1.includes(PATTERN$1)(key)), Array.filter((key) => !isTypesOnly(Record.get(exports, key))));
|
|
132
|
+
return [ROOT_EXPORT];
|
|
133
|
+
}
|
|
134
|
+
return [];
|
|
135
|
+
};
|
|
136
|
+
const specifierOf = (name, subpath) => {
|
|
137
|
+
if (subpath === ROOT_EXPORT) return name;
|
|
138
|
+
return `${name}${String$1.replace(ROOT_EXPORT, "")(subpath)}`;
|
|
139
|
+
};
|
|
140
|
+
const binFilesOf = (bin) => {
|
|
141
|
+
if (Predicate.isUndefined(bin)) return [];
|
|
142
|
+
if (Predicate.isString(bin)) return [bin];
|
|
143
|
+
return Record.values(bin);
|
|
203
144
|
};
|
|
204
145
|
/** @internal */
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return
|
|
146
|
+
const smokeTargetsOf = (manifest) => {
|
|
147
|
+
const published = Option.fromUndefinedOr(manifest.publishConfig);
|
|
148
|
+
const exports = pipe(published, Option.flatMap(({ exports: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.exports));
|
|
149
|
+
const bin = pipe(published, Option.flatMap(({ bin: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.bin));
|
|
150
|
+
return {
|
|
151
|
+
imports: pipe(subpathsOf(exports), Array.map((subpath) => specifierOf(manifest.name, subpath))),
|
|
152
|
+
bins: binFilesOf(bin)
|
|
153
|
+
};
|
|
210
154
|
};
|
|
211
|
-
const publishedExportsOf = (manifest) => pipe(Option.fromUndefinedOr(manifest.publishConfig), Option.flatMap((config) => Option.fromUndefinedOr(config.exports)), Option.orElse(() => Option.fromUndefinedOr(manifest.exports)), Option.getOrUndefined);
|
|
212
|
-
const missingMessage = (missing) => `The published exports point to files the build did not write: ${Array.join(missing, ", ")}`;
|
|
213
155
|
/** @internal */
|
|
214
|
-
const
|
|
156
|
+
const compatManifestIn = Effect.fn("compat.manifestIn")(function* compatManifestIn(directory) {
|
|
215
157
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
216
158
|
const path = yield* Path.Path;
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
return yield* pipe(missing, Array.match({
|
|
220
|
-
onEmpty: () => Effect.void,
|
|
221
|
-
onNonEmpty: (list) => Effect.fail(MissingExportTargets.make({ message: missingMessage(list) }))
|
|
222
|
-
}));
|
|
159
|
+
const text = yield* fileSystem.readFileString(path.join(directory, "package.json"));
|
|
160
|
+
return yield* Schema.decodeEffect(CompatManifestJson)(text);
|
|
223
161
|
});
|
|
224
162
|
// src/features/publish-workspace/model/platforms.ts
|
|
225
163
|
const RUNNERS = {
|
|
@@ -250,7 +188,7 @@ const buildsOf = (tasks) => runnersFor(tasks, BUILD);
|
|
|
250
188
|
/** @internal */
|
|
251
189
|
const checksOf = (tasks) => runnersFor(tasks, CHECK);
|
|
252
190
|
/** @internal */
|
|
253
|
-
const nativeTargetsOf = (targets) => pipe(targets, Array.flatMap((target) => pipe(Array.head(String.split(target, "-")), Option.flatMap((platform) => Record.get(NODE_PLATFORMS, platform)), Option.map((os) => ({
|
|
191
|
+
const nativeTargetsOf = (targets) => pipe(targets, Array.flatMap((target) => pipe(Array.head(String$1.split(target, "-")), Option.flatMap((platform) => Record.get(NODE_PLATFORMS, platform)), Option.map((os) => ({
|
|
254
192
|
target,
|
|
255
193
|
runner: RUNNERS[os]
|
|
256
194
|
})), Option.toArray)));
|
|
@@ -262,7 +200,7 @@ const libcOf = (parts) => pipe(Array.get(parts, ABI_INDEX), Option.flatMap((abi)
|
|
|
262
200
|
const nativeFileOf = ({ binary, target }) => `${binary}.${target}.node`;
|
|
263
201
|
/** @internal */
|
|
264
202
|
const nativeFields = (native) => {
|
|
265
|
-
const parts = String.split(native.target, "-");
|
|
203
|
+
const parts = String$1.split(native.target, "-");
|
|
266
204
|
const file = nativeFileOf(native);
|
|
267
205
|
return {
|
|
268
206
|
name: `${native.name}-${native.target}`,
|
|
@@ -276,6 +214,42 @@ const nativeFields = (native) => {
|
|
|
276
214
|
};
|
|
277
215
|
/** @internal */
|
|
278
216
|
const nativeReadme = ({ name, target }) => `# ${name}-${target}\n\nThe prebuilt ${target} native addon of [${name}](https://www.npmjs.com/package/${name}). Install ${name} instead; npm picks this package for your platform.\n`;
|
|
217
|
+
// src/features/publish-workspace/model/native-package.ts
|
|
218
|
+
const NPM_DIR = "npm";
|
|
219
|
+
const NATIVE_DIR = "native";
|
|
220
|
+
const MANIFEST_FILE$4 = "package.json";
|
|
221
|
+
const KEPT_FIELDS = [
|
|
222
|
+
"license",
|
|
223
|
+
"repository",
|
|
224
|
+
"homepage",
|
|
225
|
+
"bugs",
|
|
226
|
+
"engines"
|
|
227
|
+
];
|
|
228
|
+
/** @internal */
|
|
229
|
+
const PackageJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));
|
|
230
|
+
const keptFields = Effect.fn("publish.keptFields")(function* keptFields(directory) {
|
|
231
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
232
|
+
const path = yield* Path.Path;
|
|
233
|
+
const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$4));
|
|
234
|
+
const raw = yield* Schema.decodeEffect(PackageJson)(text);
|
|
235
|
+
return pipe(raw, Record.filter((_value, key) => Array.contains(KEPT_FIELDS, key)));
|
|
236
|
+
});
|
|
237
|
+
/** @internal */
|
|
238
|
+
const writeNative = Effect.fn("publish.writeNative")(function* writeNative(directory, native) {
|
|
239
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
240
|
+
const path = yield* Path.Path;
|
|
241
|
+
const kept = yield* keptFields(directory);
|
|
242
|
+
const target = path.resolve(directory, NPM_DIR, native.target);
|
|
243
|
+
const file = nativeFileOf(native);
|
|
244
|
+
yield* fileSystem.makeDirectory(target, { recursive: true });
|
|
245
|
+
yield* fileSystem.copyFile(path.join(directory, NATIVE_DIR, file), path.join(target, file));
|
|
246
|
+
const text = yield* Schema.encodeEffect(PackageJson)({
|
|
247
|
+
...kept,
|
|
248
|
+
...nativeFields(native)
|
|
249
|
+
});
|
|
250
|
+
yield* Effect.all([fileSystem.writeFileString(path.join(target, MANIFEST_FILE$4), text), fileSystem.writeFileString(path.join(target, "README.md"), nativeReadme(native))], { concurrency: "unbounded" });
|
|
251
|
+
return target;
|
|
252
|
+
});
|
|
279
253
|
// src/features/publish-workspace/model/widened-ranges.ts
|
|
280
254
|
const HOOK_FILE = "widen-ranges.mjs";
|
|
281
255
|
/** @internal */
|
|
@@ -299,169 +273,354 @@ const widenRangesEnv = Effect.fn("publish.widenRanges")(function* widenRangesEnv
|
|
|
299
273
|
yield* fileSystem.writeFileString(hook, WIDEN_RANGES);
|
|
300
274
|
return { pnpm_config_pnpmfile: hook };
|
|
301
275
|
});
|
|
302
|
-
// src/features/publish-workspace/model/
|
|
276
|
+
// src/features/publish-workspace/model/pack.ts
|
|
303
277
|
const TARBALL = "package.tgz";
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
]
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
name: Schema.String,
|
|
322
|
-
version: Schema.String
|
|
323
|
-
}));
|
|
324
|
-
const authEnv = Effect.fn("publish.authEnv")(function* authEnv() {
|
|
325
|
-
const token = yield* brokerCredential({
|
|
326
|
-
kind: "npm",
|
|
327
|
-
field: "npmToken"
|
|
278
|
+
/** @internal */
|
|
279
|
+
const pack = Effect.fn("publish.pack")(function* pack(directory) {
|
|
280
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
281
|
+
const path = yield* Path.Path;
|
|
282
|
+
const temporary = yield* fileSystem.makeTempDirectoryScoped();
|
|
283
|
+
const tarball = path.join(temporary, TARBALL);
|
|
284
|
+
const env = yield* widenRangesEnv(temporary);
|
|
285
|
+
yield* mustSucceed({
|
|
286
|
+
command: "vp",
|
|
287
|
+
args: [
|
|
288
|
+
"pm",
|
|
289
|
+
"pack",
|
|
290
|
+
"--out",
|
|
291
|
+
tarball
|
|
292
|
+
],
|
|
293
|
+
env,
|
|
294
|
+
cwd: directory
|
|
328
295
|
});
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
|
|
296
|
+
return tarball;
|
|
297
|
+
});
|
|
298
|
+
// src/features/publish-workspace/model/compat-native.ts
|
|
299
|
+
const HOST_PREFIX = `${platform()}-${arch()}-`;
|
|
300
|
+
const builtOf = (directory, manifest) => pipe(Option.fromUndefinedOr(manifest.native), Option.flatMap(({ binary, targets }) => pipe(targets, Array.findFirst(String$1.startsWith(HOST_PREFIX)), Option.map((target) => ({
|
|
301
|
+
directory,
|
|
302
|
+
manifest,
|
|
303
|
+
binary,
|
|
304
|
+
target
|
|
305
|
+
})))));
|
|
306
|
+
const packedNative = Effect.fn("compat.packedNative")(function* packedNative({ directory, manifest, binary, target }) {
|
|
307
|
+
const written = yield* writeNative(directory, {
|
|
308
|
+
name: manifest.name,
|
|
309
|
+
version: manifest.version,
|
|
310
|
+
binary,
|
|
311
|
+
target
|
|
332
312
|
});
|
|
313
|
+
const tarball = yield* pack(written);
|
|
314
|
+
return [[`${manifest.name}-${target}`, tarball]];
|
|
333
315
|
});
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
316
|
+
/** @internal */
|
|
317
|
+
const nativeTarballs = Effect.fn("compat.native")(function* nativeTarballs(directory, manifest) {
|
|
318
|
+
const none = [];
|
|
319
|
+
return yield* pipe(builtOf(directory, manifest), Option.match({
|
|
320
|
+
onNone: () => Effect.succeed(none),
|
|
321
|
+
onSome: packedNative
|
|
322
|
+
}));
|
|
323
|
+
});
|
|
324
|
+
// src/features/publish-workspace/model/compat-workspace.ts
|
|
325
|
+
const dependencyNamesOf = (manifest) => pipe([
|
|
326
|
+
manifest.dependencies,
|
|
327
|
+
manifest.peerDependencies,
|
|
328
|
+
manifest.optionalDependencies
|
|
329
|
+
], Array.flatMap((declared) => Record.keys(declared ?? {})));
|
|
330
|
+
const closureOf = (known, names, seen) => {
|
|
331
|
+
const [name, ...rest] = names;
|
|
332
|
+
if (Predicate.isUndefined(name)) return seen;
|
|
333
|
+
const found = Record.get(known, name);
|
|
334
|
+
const reached = pipe(seen, Array.some((item) => item.manifest.name === name));
|
|
335
|
+
if (Option.isNone(found) || reached) return closureOf(known, rest, seen);
|
|
336
|
+
const inner = closureOf(known, dependencyNamesOf(found.value.manifest), [...seen, found.value]);
|
|
337
|
+
return closureOf(known, rest, inner);
|
|
338
|
+
};
|
|
339
|
+
const workspacesBeside = Effect.fn("compat.workspaces")(function* workspacesBeside(directory) {
|
|
340
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
341
|
+
const path = yield* Path.Path;
|
|
342
|
+
const parent = path.dirname(path.resolve(directory));
|
|
343
|
+
const entries = yield* fileSystem.readDirectory(parent);
|
|
344
|
+
const found = yield* Effect.forEach(entries, (entry) => compatManifestIn(path.join(parent, entry)).pipe(Effect.map((manifest) => [{
|
|
345
|
+
directory: path.join(parent, entry),
|
|
346
|
+
manifest
|
|
347
|
+
}]), Effect.orElseSucceed(() => [])), { concurrency: 1 });
|
|
348
|
+
return pipe(Array.flatten(found), Array.map((workspace) => [workspace.manifest.name, workspace]), Record.fromEntries);
|
|
349
|
+
});
|
|
350
|
+
const builtTarball = Effect.fn("compat.pack")(function* builtTarball(directory) {
|
|
351
|
+
yield* mustSucceed({
|
|
341
352
|
command: "vp",
|
|
342
|
-
args: ["run",
|
|
353
|
+
args: ["run", "build"],
|
|
343
354
|
cwd: directory
|
|
344
|
-
}), {
|
|
345
|
-
concurrency: 1,
|
|
346
|
-
discard: true
|
|
347
355
|
});
|
|
348
|
-
yield*
|
|
356
|
+
return yield* pack(directory);
|
|
349
357
|
});
|
|
350
|
-
const
|
|
351
|
-
const
|
|
358
|
+
const tarballsOf = Effect.fn("compat.tarballs")(function* tarballsOf({ directory, manifest }) {
|
|
359
|
+
const tarball = yield* builtTarball(directory);
|
|
360
|
+
const natives = yield* nativeTarballs(directory, manifest);
|
|
361
|
+
return [...[[manifest.name, tarball]], ...natives];
|
|
362
|
+
});
|
|
363
|
+
/** @internal */
|
|
364
|
+
const workspaceTarballs = Effect.fn("compat.local")(function* workspaceTarballs(directory, manifest) {
|
|
365
|
+
const known = yield* workspacesBeside(directory);
|
|
366
|
+
const reached = closureOf(known, dependencyNamesOf(manifest), [{
|
|
367
|
+
directory,
|
|
368
|
+
manifest
|
|
369
|
+
}]);
|
|
370
|
+
const packed = yield* Effect.forEach(reached, tarballsOf, { concurrency: 1 });
|
|
371
|
+
return Record.fromEntries(Array.flatten(packed));
|
|
372
|
+
});
|
|
373
|
+
// src/features/publish-workspace/model/compat.ts
|
|
374
|
+
const MANIFEST_FILE$3 = "package.json";
|
|
375
|
+
const INSTALL_FLAGS = ["--no-audit", "--no-fund"];
|
|
376
|
+
const LOAD_FAILURE = String.raw`/ERR_(MODULE_NOT_FOUND|PACKAGE_|INVALID_PACKAGE|UNKNOWN_FILE|UNSUPPORTED_DIR|REQUIRE_ESM)|SyntaxError/u`;
|
|
377
|
+
const IMPORT_ONLY = "await import(process.argv[1])";
|
|
378
|
+
const SPAWN_CHECKED = `import { spawnSync } from "node:child_process"; const { stderr } = spawnSync(process.execPath, process.argv.slice(1), { encoding: "utf8", stdio: ["ignore", "ignore", "pipe"], timeout: 60000 }); if (${LOAD_FAILURE}.test(stderr)) { process.stderr.write(stderr); process.exit(1); }`;
|
|
379
|
+
const Versions$1 = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
380
|
+
const ConsumerJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));
|
|
381
|
+
const installedNode = Effect.fn("compat.node")(function* installedNode(directory, range) {
|
|
352
382
|
const path = yield* Path.Path;
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
383
|
+
yield* (yield* FileSystem.FileSystem).makeDirectory(directory, { recursive: true });
|
|
384
|
+
const listed = yield* outputOf({
|
|
385
|
+
command: "npm",
|
|
386
|
+
args: [
|
|
387
|
+
"view",
|
|
388
|
+
"node",
|
|
389
|
+
"versions",
|
|
390
|
+
"--json"
|
|
391
|
+
],
|
|
392
|
+
cwd: directory
|
|
393
|
+
});
|
|
394
|
+
const versions = yield* Schema.decodeEffect(Versions$1)(listed);
|
|
395
|
+
const version = yield* Effect.fromOption(Option.fromNullishOr(semver.maxSatisfying([...versions], range))).pipe(Effect.mapError(() => IncompatiblePackage.make({ message: `No Node.js release satisfies ${range}` })));
|
|
396
|
+
yield* mustSucceed({
|
|
397
|
+
command: "npm",
|
|
398
|
+
args: [
|
|
399
|
+
"install",
|
|
400
|
+
...INSTALL_FLAGS,
|
|
401
|
+
`node@${version}`
|
|
402
|
+
],
|
|
403
|
+
cwd: directory
|
|
404
|
+
});
|
|
405
|
+
return {
|
|
406
|
+
version,
|
|
407
|
+
binary: path.join(directory, "node_modules", "node", "bin", "node")
|
|
408
|
+
};
|
|
356
409
|
});
|
|
357
|
-
const
|
|
410
|
+
const fileEntries = (tarballs) => pipe(Record.toEntries(tarballs), Array.map(([name, file]) => [name, `file:${file}`]));
|
|
411
|
+
const siblingOverrides = (tarballs) => pipe(Record.keys(tarballs), Array.map((sibling) => [sibling, `$${sibling}`]));
|
|
412
|
+
const consumerJson = Effect.fn("compat.json")(function* consumerJson({ peers, tarballs }) {
|
|
413
|
+
const dependencies = Record.fromEntries([...Record.toEntries(peers), ...fileEntries(tarballs)]);
|
|
414
|
+
return yield* Schema.encodeEffect(ConsumerJson)({
|
|
415
|
+
private: true,
|
|
416
|
+
type: "module",
|
|
417
|
+
dependencies,
|
|
418
|
+
overrides: Record.fromEntries(siblingOverrides(tarballs))
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
const withViteOfVitePlus = Effect.fn("compat.vite")(function* withViteOfVitePlus(directory) {
|
|
358
422
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
359
423
|
const path = yield* Path.Path;
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
424
|
+
const text = yield* fileSystem.readFileString(path.join(directory, "node_modules", VITE_PLUS, MANIFEST_FILE$3));
|
|
425
|
+
yield* Option.match(viteAliasOf(text), {
|
|
426
|
+
onNone: () => Effect.void,
|
|
427
|
+
onSome: (alias) => mustSucceed({
|
|
428
|
+
command: "npm",
|
|
429
|
+
args: [
|
|
430
|
+
"install",
|
|
431
|
+
"--ignore-scripts",
|
|
432
|
+
"--force",
|
|
433
|
+
...INSTALL_FLAGS,
|
|
434
|
+
alias
|
|
435
|
+
],
|
|
436
|
+
cwd: directory
|
|
437
|
+
})
|
|
368
438
|
});
|
|
369
|
-
yield* Effect.all([fileSystem.writeFileString(path.join(target, MANIFEST_FILE), text), fileSystem.writeFileString(path.join(target, "README.md"), nativeReadme(native))], { concurrency: "unbounded" });
|
|
370
|
-
return target;
|
|
371
439
|
});
|
|
372
|
-
const
|
|
440
|
+
const installedConsumer = Effect.fn("compat.consumer")(function* installedConsumer(root, consumer) {
|
|
373
441
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
374
442
|
const path = yield* Path.Path;
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
version
|
|
380
|
-
})) {
|
|
381
|
-
yield* Console.log(`${name}@${version} is already published, skipping`);
|
|
382
|
-
return name;
|
|
383
|
-
}
|
|
443
|
+
const directory = path.join(root, "consumer");
|
|
444
|
+
yield* fileSystem.makeDirectory(directory, { recursive: true });
|
|
445
|
+
const text = yield* consumerJson(consumer);
|
|
446
|
+
yield* fileSystem.writeFileString(path.join(directory, MANIFEST_FILE$3), text);
|
|
384
447
|
yield* mustSucceed({
|
|
385
448
|
command: "npm",
|
|
386
449
|
args: [
|
|
387
|
-
"
|
|
388
|
-
"
|
|
389
|
-
...
|
|
450
|
+
"install",
|
|
451
|
+
"--ignore-scripts",
|
|
452
|
+
...INSTALL_FLAGS
|
|
390
453
|
],
|
|
391
|
-
|
|
392
|
-
cwd: target
|
|
454
|
+
cwd: directory
|
|
393
455
|
});
|
|
394
|
-
|
|
456
|
+
if (Record.has(consumer.peers, "vite-plus")) yield* withViteOfVitePlus(directory);
|
|
457
|
+
return directory;
|
|
395
458
|
});
|
|
396
|
-
const
|
|
459
|
+
const loadsCleanly = ({ runtime, consumer, args }) => mustSucceed({
|
|
460
|
+
command: runtime,
|
|
461
|
+
args: [
|
|
462
|
+
"--input-type=module",
|
|
463
|
+
"-e",
|
|
464
|
+
SPAWN_CHECKED,
|
|
465
|
+
"--",
|
|
466
|
+
...args
|
|
467
|
+
],
|
|
468
|
+
cwd: consumer
|
|
469
|
+
});
|
|
470
|
+
const smoke = Effect.fn("compat.smoke")(function* smoke(manifest, runtime, consumer) {
|
|
471
|
+
const path = yield* Path.Path;
|
|
472
|
+
const { imports, bins } = smokeTargetsOf(manifest);
|
|
473
|
+
const importer = [
|
|
474
|
+
"--input-type=module",
|
|
475
|
+
"-e",
|
|
476
|
+
IMPORT_ONLY
|
|
477
|
+
];
|
|
478
|
+
yield* Effect.forEach(imports, (specifier) => loadsCleanly({
|
|
479
|
+
runtime,
|
|
480
|
+
consumer,
|
|
481
|
+
args: [...importer, specifier]
|
|
482
|
+
}), {
|
|
483
|
+
concurrency: 1,
|
|
484
|
+
discard: true
|
|
485
|
+
});
|
|
486
|
+
yield* Effect.forEach(bins, (file) => loadsCleanly({
|
|
487
|
+
runtime,
|
|
488
|
+
consumer,
|
|
489
|
+
args: [path.join(consumer, "node_modules", manifest.name, file), "--help"]
|
|
490
|
+
}), {
|
|
491
|
+
concurrency: 1,
|
|
492
|
+
discard: true
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
const runCase = Effect.fn("compat.case")(function* runCase({ manifest, tarballs, compat }) {
|
|
397
496
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
497
|
+
const path = yield* Path.Path;
|
|
498
|
+
const root = yield* fileSystem.makeTempDirectoryScoped();
|
|
499
|
+
const runtime = yield* installedNode(path.join(root, "runtime"), compat.node);
|
|
500
|
+
const consumer = yield* installedConsumer(root, {
|
|
501
|
+
peers: compat.peers,
|
|
502
|
+
tarballs
|
|
404
503
|
});
|
|
405
|
-
|
|
504
|
+
const peers = pipe(Record.toEntries(compat.peers), Array.map(([name, range]) => `${name}@${range}`), Array.join(", "));
|
|
505
|
+
yield* Console.log(`${manifest.name} ${compat.label}: Node.js ${runtime.version}, peers ${peers}`);
|
|
506
|
+
yield* smoke(manifest, runtime.binary, consumer);
|
|
507
|
+
}, Effect.scoped);
|
|
508
|
+
/** @internal */
|
|
509
|
+
const checkCompat = Effect.fn("publish.compat")(function* checkCompat(directory) {
|
|
510
|
+
const manifest = yield* compatManifestIn(directory);
|
|
511
|
+
const cases = compatCasesOf(manifest);
|
|
512
|
+
if (Array.isReadonlyArrayEmpty(cases)) return yield* IncompatiblePackage.make({ message: `${manifest.name} declares no engines.node, so there is no supported Node.js range to check` });
|
|
513
|
+
const tarballs = yield* workspaceTarballs(directory, manifest);
|
|
514
|
+
return yield* Effect.forEach(cases, (compat) => runCase({
|
|
515
|
+
manifest,
|
|
516
|
+
tarballs,
|
|
517
|
+
compat
|
|
518
|
+
}), {
|
|
519
|
+
concurrency: 1,
|
|
520
|
+
discard: true
|
|
521
|
+
});
|
|
522
|
+
}, Effect.scoped);
|
|
523
|
+
// src/features/publish-workspace/model/manifest.ts
|
|
524
|
+
const MANIFEST_FILE$2 = "package.json";
|
|
525
|
+
const SCOPE = /^@[^/]+\//u;
|
|
526
|
+
const UNVERSIONED$1 = "0.0.0";
|
|
527
|
+
const ROOT = ".";
|
|
528
|
+
const Native = Schema.Struct({
|
|
529
|
+
binary: Schema.String,
|
|
530
|
+
targets: Schema.Array(Schema.String)
|
|
406
531
|
});
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
target
|
|
415
|
-
}), { concurrency: 1 });
|
|
416
|
-
const names = yield* Effect.forEach(written, (target) => publishNative(target, env), { concurrency: 1 });
|
|
417
|
-
yield* addOptionalDependencies(directory, names, manifest.version);
|
|
532
|
+
const ManifestSchema = Schema.Struct({
|
|
533
|
+
name: Schema.String,
|
|
534
|
+
version: Schema.String,
|
|
535
|
+
private: Schema.optionalKey(Schema.Boolean),
|
|
536
|
+
dependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
537
|
+
native: Schema.optionalKey(Native),
|
|
538
|
+
"size-limit": Schema.optionalKey(Schema.Unknown)
|
|
418
539
|
});
|
|
419
|
-
|
|
540
|
+
/** @internal */
|
|
541
|
+
const manifestIn = Effect.fn("publish.manifest")(function* manifestIn(directory) {
|
|
420
542
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
421
543
|
const path = yield* Path.Path;
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
const env = yield* widenRangesEnv(temporary);
|
|
425
|
-
yield* mustSucceed({
|
|
426
|
-
command: "vp",
|
|
427
|
-
args: [
|
|
428
|
-
"pm",
|
|
429
|
-
"pack",
|
|
430
|
-
"--out",
|
|
431
|
-
tarball
|
|
432
|
-
],
|
|
433
|
-
env,
|
|
434
|
-
cwd: directory
|
|
435
|
-
});
|
|
436
|
-
return tarball;
|
|
544
|
+
const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$2));
|
|
545
|
+
return yield* Schema.decodeEffect(Schema.fromJsonString(ManifestSchema))(text);
|
|
437
546
|
});
|
|
438
547
|
/** @internal */
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
548
|
+
const releaseName = ({ name }) => String$1.replace(SCOPE, "")(name);
|
|
549
|
+
/** @internal */
|
|
550
|
+
const isRoot = (directory) => directory === ROOT;
|
|
551
|
+
/** @internal */
|
|
552
|
+
const tagOf = ({ directory, name, version }) => {
|
|
553
|
+
if (isRoot(directory)) return `v${version}`;
|
|
554
|
+
return `${releaseName({ name })}-v${version}`;
|
|
555
|
+
};
|
|
556
|
+
/** @internal */
|
|
557
|
+
const environmentOf = (manifest) => `${releaseName(manifest)}-release`;
|
|
558
|
+
/** @internal */
|
|
559
|
+
const isVersioned = ({ version }) => version !== UNVERSIONED$1;
|
|
560
|
+
/** @internal */
|
|
561
|
+
const goesToNpm = (manifest) => !pipe(Option.fromUndefinedOr(manifest.private), Option.getOrElse(() => false));
|
|
562
|
+
// src/features/publish-workspace/model/dependencies.ts
|
|
563
|
+
const WORKSPACE_PROTOCOL = "workspace:";
|
|
564
|
+
const READ_CONCURRENCY = 8;
|
|
565
|
+
/** @internal */
|
|
566
|
+
const onNpm = ({ directory, name, version }) => succeeds({
|
|
567
|
+
command: "npm",
|
|
568
|
+
args: [
|
|
569
|
+
"view",
|
|
570
|
+
`${name}@${version}`,
|
|
571
|
+
"version"
|
|
572
|
+
],
|
|
573
|
+
cwd: directory
|
|
574
|
+
});
|
|
575
|
+
const taggedError$2 = Schema.TaggedError;
|
|
576
|
+
/** @internal */
|
|
577
|
+
var UnpublishedDependencies = class extends taggedError$2()("UnpublishedDependencies", { message: Schema.String }) {};
|
|
578
|
+
const workspaceDependencies = (manifest) => pipe(Option.fromUndefinedOr(manifest.dependencies), Option.map((dependencies) => pipe(dependencies, Record.filter(String$1.startsWith(WORKSPACE_PROTOCOL)), Record.keys)), Option.getOrElse(() => []));
|
|
579
|
+
const failWhenMissing = (missing, manifest) => {
|
|
580
|
+
if (Array.isReadonlyArrayEmpty(missing)) return Effect.void;
|
|
581
|
+
const names = pipe(missing, Array.map(({ directory, name, version }) => `${name}@${version} (${directory})`), Array.join(", "));
|
|
582
|
+
return Effect.fail(UnpublishedDependencies.make({ message: `${manifest.name} depends on versions that are not on npm yet. Publish them first: ${names}` }));
|
|
583
|
+
};
|
|
584
|
+
/** @internal */
|
|
585
|
+
const requirePublishedDependencies = Effect.fn("publish.dependencies")(function* requirePublishedDependencies({ manifest, workspaces }) {
|
|
586
|
+
const wanted = workspaceDependencies(manifest);
|
|
587
|
+
const siblings = yield* Effect.forEach(workspaces, (directory) => manifestIn(directory).pipe(Effect.map((found) => ({
|
|
442
588
|
directory,
|
|
443
|
-
...
|
|
444
|
-
}))
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
yield*
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
589
|
+
...found
|
|
590
|
+
}))), { concurrency: READ_CONCURRENCY });
|
|
591
|
+
const internal = pipe(siblings, Array.filter((sibling) => Array.contains(wanted, sibling.name) && goesToNpm(sibling)));
|
|
592
|
+
const missing = yield* Effect.filter(internal, (sibling) => onNpm(sibling).pipe(Effect.map((published) => !published)), { concurrency: READ_CONCURRENCY });
|
|
593
|
+
yield* failWhenMissing(missing, manifest);
|
|
594
|
+
});
|
|
595
|
+
// src/features/publish-workspace/model/broker.ts
|
|
596
|
+
const Issued = Schema.Record(Schema.String, Schema.Unknown);
|
|
597
|
+
const issued = Effect.fn("publish.issued")(function* issued(oidc, { kind, field }) {
|
|
598
|
+
const client = yield* HttpClient.HttpClient;
|
|
599
|
+
const request = HttpClientRequest.post(`${BROKER}?only=${kind}`).pipe(HttpClientRequest.bearerToken(oidc));
|
|
600
|
+
const response = yield* HttpClient.filterStatusOk(client).execute(request);
|
|
601
|
+
const body = yield* HttpClientResponse.schemaBodyJson(Issued)(response);
|
|
602
|
+
const token = Option.filter(Option.fromNullishOr(body[field]), (value) => typeof value === "string" && value !== "");
|
|
603
|
+
yield* Effect.forEach(Option.toArray(token), mask, {
|
|
604
|
+
concurrency: 1,
|
|
605
|
+
discard: true
|
|
458
606
|
});
|
|
459
|
-
|
|
607
|
+
return token;
|
|
608
|
+
});
|
|
609
|
+
/** @internal */
|
|
610
|
+
const brokerCredential = Effect.fn("publish.brokerCredential")(function* brokerCredential(credential) {
|
|
611
|
+
return yield* actionsOidcToken.pipe(Effect.flatMap(Option.match({
|
|
612
|
+
onNone: () => Effect.succeedNone,
|
|
613
|
+
onSome: (oidc) => issued(oidc, credential)
|
|
614
|
+
})), Effect.tapError(() => Console.log(`The credential broker gave no ${credential.field}`)), Effect.orElseSucceed(() => Option.none()));
|
|
615
|
+
});
|
|
460
616
|
// src/features/publish-workspace/model/provenance.ts
|
|
461
617
|
const ATTESTATIONS = "https://registry.npmjs.org/-/npm/v1/attestations/";
|
|
462
618
|
const SLSA = /slsa\.dev\/provenance/u;
|
|
463
619
|
const Digest = Schema.Struct({ gitCommit: Schema.String });
|
|
464
|
-
const Dependency = Schema.Struct({
|
|
620
|
+
const Dependency = Schema.Struct({
|
|
621
|
+
uri: Schema.String,
|
|
622
|
+
digest: Digest
|
|
623
|
+
});
|
|
465
624
|
const BuildDefinition = Schema.Struct({ resolvedDependencies: Schema.Array(Dependency) });
|
|
466
625
|
const Predicate$1 = Schema.Struct({ buildDefinition: BuildDefinition });
|
|
467
626
|
const Statement = Schema.fromJsonString(Schema.Struct({ predicate: Predicate$1 }));
|
|
@@ -472,19 +631,21 @@ const Attestation = Schema.Struct({
|
|
|
472
631
|
bundle: Bundle
|
|
473
632
|
});
|
|
474
633
|
const Attestations = Schema.Struct({ attestations: Schema.Array(Attestation) });
|
|
475
|
-
|
|
634
|
+
/** @internal */
|
|
635
|
+
const commitOf = (repository) => (payload) => pipe(Base64.decodeString(payload), Effect.fromResult, Effect.flatMap(Schema.decodeEffect(Statement)), Effect.map(({ predicate }) => pipe(Array.head(predicate.buildDefinition.resolvedDependencies), Option.filter(({ uri }) => String$1.includes(`github.com/${repository}@`)(uri)), Option.map(({ digest }) => digest.gitCommit))), Effect.orElseSucceed(() => Option.none()));
|
|
476
636
|
/** @internal */
|
|
477
637
|
const provenanceCommit = Effect.fn("publish.provenanceCommit")(function* provenanceCommit({ name, version }) {
|
|
478
638
|
const client = yield* HttpClient.HttpClient;
|
|
479
|
-
const
|
|
639
|
+
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
640
|
+
const url = `${ATTESTATIONS}${String$1.replace("/", "%2f")(name)}@${version}`;
|
|
480
641
|
const found = yield* HttpClient.filterStatusOk(client).get(url).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Attestations)), Effect.map(({ attestations }) => Array.findFirst(attestations, ({ predicateType }) => SLSA.test(predicateType))), Effect.orElseSucceed(() => Option.none()));
|
|
481
642
|
if (Option.isNone(found)) return Option.none();
|
|
482
|
-
return yield* commitOf(found.value.bundle.dsseEnvelope.payload);
|
|
643
|
+
return yield* commitOf(repository)(found.value.bundle.dsseEnvelope.payload);
|
|
483
644
|
});
|
|
484
645
|
// src/features/publish-workspace/model/tags.ts
|
|
485
646
|
const UNVERSIONED = "0.0.0";
|
|
486
647
|
const LOOKUP_CONCURRENCY = 4;
|
|
487
|
-
const Versions = Schema.
|
|
648
|
+
const Versions = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
488
649
|
/** @internal */
|
|
489
650
|
const tagged = Effect.fn("publish.tagged")(function* tagged(tag) {
|
|
490
651
|
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
@@ -608,11 +769,13 @@ const PlanSchema = Schema.Struct({
|
|
|
608
769
|
hook: Schema.Boolean
|
|
609
770
|
});
|
|
610
771
|
const AssetCount = Schema.fromJsonString(Schema.Finite);
|
|
772
|
+
/** @internal */
|
|
611
773
|
const graphTasks = outputOf({
|
|
612
774
|
command: "vp",
|
|
613
775
|
args: ["run", "--json"]
|
|
614
776
|
}).pipe(Effect.flatMap(Schema.decodeEffect(TaskGraph)), Effect.map(({ tasks }) => Record.values(tasks)));
|
|
615
777
|
const tasksIn = (tasks, directory) => pipe(tasks, Array.filter((task) => task.package === directory), Array.map(({ name }) => name));
|
|
778
|
+
/** @internal */
|
|
616
779
|
const workspacesOf = (tasks) => pipe(tasks, Array.map((task) => task.package), Array.dedupe);
|
|
617
780
|
const allTagged = Effect.fn("publish.allTagged")(function* allTagged(directory, manifest) {
|
|
618
781
|
if (!isVersioned(manifest)) return true;
|
|
@@ -626,7 +789,7 @@ const allTagged = Effect.fn("publish.allTagged")(function* allTagged(directory,
|
|
|
626
789
|
});
|
|
627
790
|
return current && Array.isReadonlyArrayEmpty(older);
|
|
628
791
|
});
|
|
629
|
-
const workspaceOf = (directory) => Path.Path.pipe(Effect.map((path) => String.replace(TRAILING_SLASH, "")(path.normalize(directory))));
|
|
792
|
+
const workspaceOf = (directory) => Path.Path.pipe(Effect.map((path) => String$1.replace(TRAILING_SLASH, "")(path.normalize(directory))));
|
|
630
793
|
/** @internal */
|
|
631
794
|
const released = Effect.fn("publish.released")(function* released(tag) {
|
|
632
795
|
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
@@ -720,6 +883,163 @@ const writePlan = Effect.fn("publish.writePlan")(function* writePlan(plan) {
|
|
|
720
883
|
yield* Effect.logInfo(encoded);
|
|
721
884
|
yield* writeOutputs({ plan: encoded });
|
|
722
885
|
});
|
|
886
|
+
// src/features/publish-workspace/model/compat-plan.ts
|
|
887
|
+
const Directories = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
888
|
+
const isChecked = Effect.fn("compat.isChecked")(function* isChecked(directory) {
|
|
889
|
+
const manifest = yield* compatManifestIn(directory);
|
|
890
|
+
return goesToNpm(manifest) && !Array.isReadonlyArrayEmpty(compatCasesOf(manifest));
|
|
891
|
+
});
|
|
892
|
+
/** @internal */
|
|
893
|
+
const writeCompatPlan = Effect.fn("publish.compatPlan")(function* writeCompatPlan() {
|
|
894
|
+
const graph = yield* graphTasks;
|
|
895
|
+
const checked = yield* Effect.filter(workspacesOf(graph), isChecked, { concurrency: 1 });
|
|
896
|
+
const encoded = yield* Schema.encodeEffect(Directories)(checked);
|
|
897
|
+
yield* Effect.logInfo(encoded);
|
|
898
|
+
yield* writeOutputs({ directories: encoded });
|
|
899
|
+
});
|
|
900
|
+
// src/features/publish-workspace/model/export-targets.ts
|
|
901
|
+
const PATTERN = "*";
|
|
902
|
+
const MANIFEST_FILE$1 = "package.json";
|
|
903
|
+
const taggedError$1 = Schema.TaggedError;
|
|
904
|
+
/** @internal */
|
|
905
|
+
var MissingExportTargets = class extends taggedError$1()("MissingExportTargets", { message: Schema.String }) {};
|
|
906
|
+
const AnyExports = Schema.optionalKey(Schema.Unknown);
|
|
907
|
+
const PublishConfig = Schema.Struct({ exports: AnyExports });
|
|
908
|
+
const PublishedExports = Schema.fromJsonString(Schema.Struct({
|
|
909
|
+
exports: AnyExports,
|
|
910
|
+
publishConfig: Schema.optionalKey(PublishConfig)
|
|
911
|
+
}));
|
|
912
|
+
const singleTarget = (target) => {
|
|
913
|
+
if (String$1.includes(PATTERN)(target)) return [];
|
|
914
|
+
return [target];
|
|
915
|
+
};
|
|
916
|
+
/** @internal */
|
|
917
|
+
const exportTargetsOf = (exports) => {
|
|
918
|
+
if (Predicate.isString(exports)) return singleTarget(exports);
|
|
919
|
+
if (Array.isArray(exports)) return pipe(exports, Array.flatMap((entry) => exportTargetsOf(entry)));
|
|
920
|
+
if (Predicate.isReadonlyObject(exports)) return pipe(Record.values(exports), Array.flatMap((entry) => exportTargetsOf(entry)));
|
|
921
|
+
return [];
|
|
922
|
+
};
|
|
923
|
+
const publishedExportsOf = (manifest) => pipe(Option.fromUndefinedOr(manifest.publishConfig), Option.flatMap((config) => Option.fromUndefinedOr(config.exports)), Option.orElse(() => Option.fromUndefinedOr(manifest.exports)), Option.getOrUndefined);
|
|
924
|
+
const missingMessage = (missing) => `The published exports point to files the build did not write: ${Array.join(missing, ", ")}`;
|
|
925
|
+
/** @internal */
|
|
926
|
+
const checkExportTargets = Effect.fn("publish.checkExportTargets")(function* checkExportTargets(directory) {
|
|
927
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
928
|
+
const path = yield* Path.Path;
|
|
929
|
+
const manifest = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$1)).pipe(Effect.flatMap(Schema.decodeEffect(PublishedExports)));
|
|
930
|
+
const missing = yield* Effect.filter(exportTargetsOf(publishedExportsOf(manifest)), (target) => Effect.map(fileSystem.exists(path.join(directory, target)), (found) => !found));
|
|
931
|
+
return yield* pipe(missing, Array.match({
|
|
932
|
+
onEmpty: () => Effect.void,
|
|
933
|
+
onNonEmpty: (list) => Effect.fail(MissingExportTargets.make({ message: missingMessage(list) }))
|
|
934
|
+
}));
|
|
935
|
+
});
|
|
936
|
+
// src/features/publish-workspace/model/npm.ts
|
|
937
|
+
const MANIFEST_FILE = "package.json";
|
|
938
|
+
const PUBLISH_FLAGS = [
|
|
939
|
+
"--provenance",
|
|
940
|
+
"--access",
|
|
941
|
+
"public"
|
|
942
|
+
];
|
|
943
|
+
const PlatformManifest = Schema.fromJsonString(Schema.Struct({
|
|
944
|
+
name: Schema.String,
|
|
945
|
+
version: Schema.String
|
|
946
|
+
}));
|
|
947
|
+
const authEnv = Effect.fn("publish.authEnv")(function* authEnv() {
|
|
948
|
+
const token = yield* brokerCredential({
|
|
949
|
+
kind: "npm",
|
|
950
|
+
field: "npmToken"
|
|
951
|
+
});
|
|
952
|
+
return Option.match(token, {
|
|
953
|
+
onNone: () => ({}),
|
|
954
|
+
onSome: (value) => ({ NODE_AUTH_TOKEN: value })
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
const verifyPackage = Effect.fn("publish.verify")(function* verifyPackage(directory, manifest) {
|
|
958
|
+
const tasks = [
|
|
959
|
+
"build",
|
|
960
|
+
"test",
|
|
961
|
+
...pipe(Option.fromUndefinedOr(manifest["size-limit"]), Option.map(() => "size"), Option.toArray)
|
|
962
|
+
];
|
|
963
|
+
yield* Effect.forEach(tasks, (task) => mustSucceed({
|
|
964
|
+
command: "vp",
|
|
965
|
+
args: ["run", task],
|
|
966
|
+
cwd: directory
|
|
967
|
+
}), {
|
|
968
|
+
concurrency: 1,
|
|
969
|
+
discard: true
|
|
970
|
+
});
|
|
971
|
+
yield* checkExportTargets(directory);
|
|
972
|
+
yield* checkCompat(directory);
|
|
973
|
+
});
|
|
974
|
+
const publishNative = Effect.fn("publish.publishNative")(function* publishNative(target, env) {
|
|
975
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
976
|
+
const path = yield* Path.Path;
|
|
977
|
+
const { name, version } = yield* fileSystem.readFileString(path.join(target, MANIFEST_FILE)).pipe(Effect.flatMap(Schema.decodeEffect(PlatformManifest)));
|
|
978
|
+
if (yield* onNpm({
|
|
979
|
+
directory: target,
|
|
980
|
+
name,
|
|
981
|
+
version
|
|
982
|
+
})) {
|
|
983
|
+
yield* Console.log(`${name}@${version} is already published, skipping`);
|
|
984
|
+
return name;
|
|
985
|
+
}
|
|
986
|
+
yield* mustSucceed({
|
|
987
|
+
command: "npm",
|
|
988
|
+
args: [
|
|
989
|
+
"publish",
|
|
990
|
+
".",
|
|
991
|
+
...PUBLISH_FLAGS
|
|
992
|
+
],
|
|
993
|
+
env,
|
|
994
|
+
cwd: target
|
|
995
|
+
});
|
|
996
|
+
return name;
|
|
997
|
+
});
|
|
998
|
+
const addOptionalDependencies = Effect.fn("publish.optionalDependencies")(function* addOptionalDependencies(directory, names, version) {
|
|
999
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
1000
|
+
const file = (yield* Path.Path).join(directory, MANIFEST_FILE);
|
|
1001
|
+
const manifest = yield* fileSystem.readFileString(file).pipe(Effect.flatMap(Schema.decodeEffect(PackageJson)));
|
|
1002
|
+
const optionalDependencies = pipe(names, Array.map((name) => [name, version]), Record.fromEntries);
|
|
1003
|
+
const updated = yield* Schema.encodeEffect(PackageJson)({
|
|
1004
|
+
...manifest,
|
|
1005
|
+
optionalDependencies
|
|
1006
|
+
});
|
|
1007
|
+
yield* fileSystem.writeFileString(file, updated);
|
|
1008
|
+
});
|
|
1009
|
+
const publishNatives = Effect.fn("publish.publishNatives")(function* publishNatives(directory, manifest, env) {
|
|
1010
|
+
if (Predicate.isUndefined(manifest.native)) return;
|
|
1011
|
+
const { binary, targets } = manifest.native;
|
|
1012
|
+
const written = yield* Effect.forEach(targets, (target) => writeNative(directory, {
|
|
1013
|
+
name: manifest.name,
|
|
1014
|
+
version: manifest.version,
|
|
1015
|
+
binary,
|
|
1016
|
+
target
|
|
1017
|
+
}), { concurrency: 1 });
|
|
1018
|
+
const names = yield* Effect.forEach(written, (target) => publishNative(target, env), { concurrency: 1 });
|
|
1019
|
+
yield* addOptionalDependencies(directory, names, manifest.version);
|
|
1020
|
+
});
|
|
1021
|
+
/** @internal */
|
|
1022
|
+
const publishToNpm = Effect.fn("publish.npm")(function* publishToNpm(directory) {
|
|
1023
|
+
const manifest = yield* manifestIn(directory);
|
|
1024
|
+
if (yield* onNpm({
|
|
1025
|
+
directory,
|
|
1026
|
+
...manifest
|
|
1027
|
+
})) return yield* Console.log(`${manifest.name}@${manifest.version} is already published`);
|
|
1028
|
+
yield* verifyPackage(directory, manifest);
|
|
1029
|
+
const env = yield* authEnv();
|
|
1030
|
+
yield* publishNatives(directory, manifest, env);
|
|
1031
|
+
const tarball = yield* pack(directory);
|
|
1032
|
+
return yield* mustSucceed({
|
|
1033
|
+
command: "npm",
|
|
1034
|
+
args: [
|
|
1035
|
+
"publish",
|
|
1036
|
+
tarball,
|
|
1037
|
+
...PUBLISH_FLAGS
|
|
1038
|
+
],
|
|
1039
|
+
env,
|
|
1040
|
+
cwd: directory
|
|
1041
|
+
});
|
|
1042
|
+
}, Effect.scoped);
|
|
723
1043
|
// src/features/publish-workspace/model/release.ts
|
|
724
1044
|
const ASSETS = "release-assets";
|
|
725
1045
|
const revisionOf = Effect.fn("publish.revision")(function* revisionOf(manifest) {
|
|
@@ -838,20 +1158,31 @@ const publishRelease = Effect.fn("publish.release")(function* publishRelease(dir
|
|
|
838
1158
|
});
|
|
839
1159
|
});
|
|
840
1160
|
// bin/msch-publish.ts
|
|
841
|
-
const Arguments = Schema.
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1161
|
+
const Arguments = Schema.Tuple([Schema.Literals([
|
|
1162
|
+
"plan",
|
|
1163
|
+
"npm",
|
|
1164
|
+
"release",
|
|
1165
|
+
"compat",
|
|
1166
|
+
"compat-plan"
|
|
1167
|
+
]), Schema.String]);
|
|
846
1168
|
const taggedError = Schema.TaggedError;
|
|
847
1169
|
var UsageError = class extends taggedError()("UsageError", { message: Schema.String }) {};
|
|
848
|
-
const USAGE = "usage: msch-publish <plan|npm|release> <workspace directory>";
|
|
1170
|
+
const USAGE = "usage: msch-publish <plan|npm|release|compat|compat-plan> <workspace directory>";
|
|
1171
|
+
const steps = {
|
|
1172
|
+
plan: Effect.fn("plan")(function* plan(directory) {
|
|
1173
|
+
return yield* planOf(directory).pipe(Effect.flatMap(writePlan));
|
|
1174
|
+
}),
|
|
1175
|
+
npm: publishToNpm,
|
|
1176
|
+
release: publishRelease,
|
|
1177
|
+
compat: checkCompat,
|
|
1178
|
+
"compat-plan": Effect.fn("compat-plan")(function* compatPlan() {
|
|
1179
|
+
return yield* writeCompatPlan();
|
|
1180
|
+
})
|
|
1181
|
+
};
|
|
849
1182
|
const publish = Effect.gen(function* publish() {
|
|
850
1183
|
const args = yield* (yield* Stdio.Stdio).args;
|
|
851
1184
|
const [step, directory] = yield* Schema.decodeUnknownEffect(Arguments)(args).pipe(Effect.mapError(() => UsageError.make({ message: USAGE })));
|
|
852
|
-
|
|
853
|
-
if (step === "npm") return yield* publishToNpm(directory);
|
|
854
|
-
return yield* publishRelease(directory);
|
|
1185
|
+
return yield* steps[step](directory);
|
|
855
1186
|
});
|
|
856
1187
|
runCli(publish);
|
|
857
1188
|
export {};
|