@r_masseater/msch 0.54.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -9
- package/dist/cargo-inputs.mjs.map +1 -1
- package/dist/changed.mjs +90 -19
- package/dist/changed.mjs.map +1 -1
- package/dist/{check-upstream-exits-DYxWDyHC.mjs → check-upstream-exits-DsBS7bui.mjs} +2 -2
- package/dist/check-upstream-exits-DsBS7bui.mjs.map +1 -0
- package/dist/cli.mjs +469 -385
- 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-D8sFyowJ.mjs +105 -0
- package/dist/credential-broker-D8sFyowJ.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-DCJv7YcW.mjs → dependencies-CbvZost8.mjs} +11 -7
- package/dist/dependencies-CbvZost8.mjs.map +1 -0
- package/dist/exits.mjs +4 -5
- package/dist/exits.mjs.map +1 -1
- 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 +29 -14
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{package-LeBO9czg.mjs → package-DZbqpZfs.mjs} +6 -6
- package/dist/package-DZbqpZfs.mjs.map +1 -0
- package/dist/{problem-CzOlOb5f.mjs → problem-Q4Zyi4PR.mjs} +10 -6
- package/dist/problem-Q4Zyi4PR.mjs.map +1 -0
- package/dist/{project-C4uzq7_4.mjs → project-CIY_lNiT.mjs} +36 -14
- package/dist/project-CIY_lNiT.mjs.map +1 -0
- package/dist/publish.mjs +625 -338
- package/dist/publish.mjs.map +1 -1
- package/dist/runtime-LT40e_l3.mjs +28 -0
- package/dist/runtime-LT40e_l3.mjs.map +1 -0
- package/dist/{syntax-3AJkpCcs.mjs → syntax-BNRNY74H.mjs} +13 -4
- package/dist/syntax-BNRNY74H.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 +5 -5
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +29 -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.map +0 -1
- package/dist/locked-inputs.mjs.map +0 -1
- 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/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,225 +1,124 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as runCli } from "./runtime-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { t as runCli } from "./runtime-LT40e_l3.mjs";
|
|
3
|
+
import { a as mustSucceed, i as writeOutputs, n as actionsOidcToken, o as outputOf, r as mask, s as succeeds, t as BROKER } from "./credential-broker-D8sFyowJ.mjs";
|
|
4
|
+
import { Array, Config, Console, Effect, FileSystem, Option, Order, Path, Predicate, Record, Schema, Stdio, String as String$1, pipe } from "effect";
|
|
5
5
|
import semver from "semver";
|
|
6
6
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
7
7
|
import { Base64 } from "effect/encoding";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
});
|
|
29
|
-
// ../github-workflow/src/shared/lib/process.ts
|
|
30
|
-
const SUCCESS = 0;
|
|
31
|
-
const taggedError$4 = Schema.TaggedError;
|
|
32
|
-
var CommandFailed = class extends taggedError$4()("CommandFailed", { message: Schema.String }) {};
|
|
33
|
-
const failed = ({ command, args }) => CommandFailed.make({ message: `${command} ${Array.join(args, " ")} failed` });
|
|
34
|
-
const exitCodeOf = Effect.fn("exitCodeOf")(function* exitCodeOf({ command, args, env, cwd }) {
|
|
35
|
-
return yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make(command, args, {
|
|
36
|
-
cwd,
|
|
37
|
-
env,
|
|
38
|
-
extendEnv: true,
|
|
39
|
-
stdin: "ignore",
|
|
40
|
-
stdout: "inherit",
|
|
41
|
-
stderr: "inherit"
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
44
|
-
const succeedsWith = (command) => exitCodeOf(command).pipe(Effect.map((code) => code === SUCCESS));
|
|
45
|
-
const mustSucceedWith = (command) => succeedsWith(command).pipe(Effect.filterOrFail((passed) => passed, () => failed(command)), Effect.asVoid);
|
|
46
|
-
const collected = Effect.fn("collected")(function* collected({ command, args, env, cwd }) {
|
|
47
|
-
const handle = yield* ChildProcess.make(command, args, {
|
|
48
|
-
cwd,
|
|
49
|
-
env,
|
|
50
|
-
extendEnv: true,
|
|
51
|
-
stdin: "ignore",
|
|
52
|
-
stderr: "inherit"
|
|
53
|
-
});
|
|
54
|
-
const [output, code] = yield* Effect.all([handle.stdout.pipe(Stream.decodeText(), Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
|
|
55
|
-
return {
|
|
56
|
-
output,
|
|
57
|
-
code
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
const outputWith = (command) => collected(command).pipe(Effect.scoped, Effect.filterOrFail(({ code }) => code === SUCCESS, () => failed(command)), Effect.map(({ output }) => String.trim(output)));
|
|
61
|
-
/** @internal */
|
|
62
|
-
const succeeds = succeedsWith;
|
|
8
|
+
import { arch, platform } from "node:os";
|
|
9
|
+
// src/features/publish-workspace/model/compat-manifest.ts
|
|
10
|
+
const PACKAGE_JSON_EXPORT = "./package.json";
|
|
11
|
+
const PATTERN$1 = "*";
|
|
12
|
+
const ROOT_EXPORT = ".";
|
|
13
|
+
const UNVERSIONED$2 = "0.0.0";
|
|
14
|
+
const VITE = "vite";
|
|
63
15
|
/** @internal */
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const outputOf = outputWith;
|
|
67
|
-
// ../github-workflow/src/shared/lib/workflow.ts
|
|
16
|
+
const VITE_PLUS = "vite-plus";
|
|
17
|
+
const TYPES = "types";
|
|
68
18
|
const taggedError$3 = Schema.TaggedError;
|
|
69
|
-
var WorkflowFailed = class extends taggedError$3()("WorkflowFailed", { message: Schema.String }) {};
|
|
70
|
-
const appendTo = (variable, entries) => Effect.gen(function* appended() {
|
|
71
|
-
const path = yield* Config.String(variable);
|
|
72
|
-
const fs = yield* FileSystem.FileSystem;
|
|
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);
|
|
77
19
|
/** @internal */
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
});
|
|
109
|
-
/** @internal */
|
|
110
|
-
const brokerCredential = Effect.fn("publish.brokerCredential")(function* brokerCredential(credential) {
|
|
111
|
-
const requestUrl = yield* Config.option(Config.String("ACTIONS_ID_TOKEN_REQUEST_URL"));
|
|
112
|
-
const requestToken = yield* Config.option(Config.Redacted("ACTIONS_ID_TOKEN_REQUEST_TOKEN"));
|
|
113
|
-
if (Option.isNone(requestUrl) || Option.isNone(requestToken)) return Option.none();
|
|
114
|
-
return yield* oidcToken(requestUrl.value, requestToken.value).pipe(Effect.flatMap((oidc) => issued(oidc, credential)), Effect.tapError(() => Console.log(`The credential broker gave no ${credential.field}`)), Effect.orElseSucceed(() => Option.none()));
|
|
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({
|
|
20
|
+
var IncompatiblePackage = class extends taggedError$3()("IncompatiblePackage", { message: Schema.String }) {};
|
|
21
|
+
const Declared = Schema.Record(Schema.String, Schema.String);
|
|
22
|
+
const VitePlusManifestJson = Schema.fromJsonString(Schema.Struct({ dependencies: Schema.optionalKey(Declared) }));
|
|
23
|
+
const Bin = Schema.Union([Schema.String, Declared]);
|
|
24
|
+
const Native$1 = Schema.Struct({
|
|
122
25
|
binary: Schema.String,
|
|
123
26
|
targets: Schema.Array(Schema.String)
|
|
124
27
|
});
|
|
125
|
-
const
|
|
28
|
+
const Engines = Schema.Struct({ node: Schema.optionalKey(Schema.String) });
|
|
29
|
+
const PublishConfig$1 = Schema.Struct({
|
|
30
|
+
exports: Schema.optionalKey(Schema.Unknown),
|
|
31
|
+
bin: Schema.optionalKey(Bin)
|
|
32
|
+
});
|
|
33
|
+
/** @internal */
|
|
34
|
+
const CompatManifestJson = Schema.fromJsonString(Schema.Struct({
|
|
126
35
|
name: Schema.String,
|
|
127
36
|
version: Schema.String,
|
|
128
37
|
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}`;
|
|
38
|
+
native: Schema.optionalKey(Native$1),
|
|
39
|
+
exports: Schema.optionalKey(Schema.Unknown),
|
|
40
|
+
bin: Schema.optionalKey(Bin),
|
|
41
|
+
dependencies: Schema.optionalKey(Declared),
|
|
42
|
+
optionalDependencies: Schema.optionalKey(Declared),
|
|
43
|
+
engines: Schema.optionalKey(Engines),
|
|
44
|
+
peerDependencies: Schema.optionalKey(Declared),
|
|
45
|
+
publishConfig: Schema.optionalKey(PublishConfig$1)
|
|
46
|
+
}));
|
|
47
|
+
const lowestOf = (range) => pipe(Option.fromNullishOr(semver.validRange(range)), Option.flatMap(() => Option.fromNullishOr(semver.minVersion(range))), Option.map(({ version }) => version));
|
|
48
|
+
const floorOf = (version) => {
|
|
49
|
+
if (semver.prerelease(version) !== null) return version;
|
|
50
|
+
return `~${String(semver.major(version))}.${String(semver.minor(version))}.0`;
|
|
148
51
|
};
|
|
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
|
|
52
|
+
const pinnedPeer = ([name, range]) => Option.match(lowestOf(range), {
|
|
53
|
+
onNone: () => [],
|
|
54
|
+
onSome: (version) => {
|
|
55
|
+
if (version === UNVERSIONED$2) return [[name, range]];
|
|
56
|
+
return [[name, floorOf(version)]];
|
|
57
|
+
}
|
|
167
58
|
});
|
|
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}` }));
|
|
59
|
+
const floorPeers = (peers) => pipe(Record.toEntries(peers), Array.flatMap(pinnedPeer), Record.fromEntries);
|
|
60
|
+
const nodeFloorOf = (manifest) => pipe(Option.fromUndefinedOr(manifest.engines), Option.flatMap(({ node }) => Option.fromUndefinedOr(node)), Option.flatMap(lowestOf));
|
|
61
|
+
const withoutViteOfVitePlus = (peers) => {
|
|
62
|
+
if (Record.has(peers, "vite-plus")) return Record.remove(peers, VITE);
|
|
63
|
+
return peers;
|
|
176
64
|
};
|
|
177
65
|
/** @internal */
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const taggedError$1 = Schema.TaggedError;
|
|
66
|
+
const viteAliasOf = (vitePlusManifest) => pipe(Schema.decodeOption(VitePlusManifestJson)(vitePlusManifest), Option.flatMapNullishOr(({ dependencies }) => dependencies), Option.flatMap(Record.get(VITE)), Option.map((spec) => `${VITE}@${spec}`));
|
|
67
|
+
const casesOf = (manifest, floor) => {
|
|
68
|
+
const declared = withoutViteOfVitePlus(manifest.peerDependencies ?? {});
|
|
69
|
+
return [{
|
|
70
|
+
label: "floor",
|
|
71
|
+
node: floorOf(floor),
|
|
72
|
+
peers: floorPeers(declared)
|
|
73
|
+
}, {
|
|
74
|
+
label: "latest",
|
|
75
|
+
node: `^${String(semver.major(floor))}`,
|
|
76
|
+
peers: declared
|
|
77
|
+
}];
|
|
78
|
+
};
|
|
192
79
|
/** @internal */
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const PublishedExports = Schema.fromJsonString(Schema.Struct({
|
|
197
|
-
exports: AnyExports,
|
|
198
|
-
publishConfig: Schema.optionalKey(PublishConfig)
|
|
80
|
+
const compatCasesOf = (manifest) => pipe(nodeFloorOf(manifest), Option.match({
|
|
81
|
+
onNone: () => [],
|
|
82
|
+
onSome: (floor) => casesOf(manifest, floor)
|
|
199
83
|
}));
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
84
|
+
const isTypesOnly = (target) => Option.match(target, {
|
|
85
|
+
onNone: () => false,
|
|
86
|
+
onSome: (value) => Predicate.isReadonlyObject(value) && pipe(Record.keys(value), Array.every((key) => key === TYPES))
|
|
87
|
+
});
|
|
88
|
+
const subpathsOf = (exports) => {
|
|
89
|
+
if (Predicate.isString(exports)) return [ROOT_EXPORT];
|
|
90
|
+
if (Predicate.isReadonlyObject(exports)) {
|
|
91
|
+
const keys = Record.keys(exports);
|
|
92
|
+
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))));
|
|
93
|
+
return [ROOT_EXPORT];
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
};
|
|
97
|
+
const specifierOf = (name, subpath) => {
|
|
98
|
+
if (subpath === ROOT_EXPORT) return name;
|
|
99
|
+
return `${name}${String$1.replace(ROOT_EXPORT, "")(subpath)}`;
|
|
100
|
+
};
|
|
101
|
+
const binFilesOf = (bin) => {
|
|
102
|
+
if (Predicate.isUndefined(bin)) return [];
|
|
103
|
+
if (Predicate.isString(bin)) return [bin];
|
|
104
|
+
return Record.values(bin);
|
|
203
105
|
};
|
|
204
106
|
/** @internal */
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return
|
|
107
|
+
const smokeTargetsOf = (manifest) => {
|
|
108
|
+
const published = Option.fromUndefinedOr(manifest.publishConfig);
|
|
109
|
+
const exports = pipe(published, Option.flatMap(({ exports: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.exports));
|
|
110
|
+
const bin = pipe(published, Option.flatMap(({ bin: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.bin));
|
|
111
|
+
return {
|
|
112
|
+
imports: pipe(subpathsOf(exports), Array.map((subpath) => specifierOf(manifest.name, subpath))),
|
|
113
|
+
bins: binFilesOf(bin)
|
|
114
|
+
};
|
|
210
115
|
};
|
|
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
116
|
/** @internal */
|
|
214
|
-
const
|
|
117
|
+
const compatManifestIn = Effect.fn("compat.manifestIn")(function* compatManifestIn(directory) {
|
|
215
118
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
216
119
|
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
|
-
}));
|
|
120
|
+
const text = yield* fileSystem.readFileString(path.join(directory, "package.json"));
|
|
121
|
+
return yield* Schema.decodeEffect(CompatManifestJson)(text);
|
|
223
122
|
});
|
|
224
123
|
// src/features/publish-workspace/model/platforms.ts
|
|
225
124
|
const RUNNERS = {
|
|
@@ -250,7 +149,7 @@ const buildsOf = (tasks) => runnersFor(tasks, BUILD);
|
|
|
250
149
|
/** @internal */
|
|
251
150
|
const checksOf = (tasks) => runnersFor(tasks, CHECK);
|
|
252
151
|
/** @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) => ({
|
|
152
|
+
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
153
|
target,
|
|
255
154
|
runner: RUNNERS[os]
|
|
256
155
|
})), Option.toArray)));
|
|
@@ -262,7 +161,7 @@ const libcOf = (parts) => pipe(Array.get(parts, ABI_INDEX), Option.flatMap((abi)
|
|
|
262
161
|
const nativeFileOf = ({ binary, target }) => `${binary}.${target}.node`;
|
|
263
162
|
/** @internal */
|
|
264
163
|
const nativeFields = (native) => {
|
|
265
|
-
const parts = String.split(native.target, "-");
|
|
164
|
+
const parts = String$1.split(native.target, "-");
|
|
266
165
|
const file = nativeFileOf(native);
|
|
267
166
|
return {
|
|
268
167
|
name: `${native.name}-${native.target}`,
|
|
@@ -276,6 +175,42 @@ const nativeFields = (native) => {
|
|
|
276
175
|
};
|
|
277
176
|
/** @internal */
|
|
278
177
|
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`;
|
|
178
|
+
// src/features/publish-workspace/model/native-package.ts
|
|
179
|
+
const NPM_DIR = "npm";
|
|
180
|
+
const NATIVE_DIR = "native";
|
|
181
|
+
const MANIFEST_FILE$4 = "package.json";
|
|
182
|
+
const KEPT_FIELDS = [
|
|
183
|
+
"license",
|
|
184
|
+
"repository",
|
|
185
|
+
"homepage",
|
|
186
|
+
"bugs",
|
|
187
|
+
"engines"
|
|
188
|
+
];
|
|
189
|
+
/** @internal */
|
|
190
|
+
const PackageJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));
|
|
191
|
+
const keptFields = Effect.fn("publish.keptFields")(function* keptFields(directory) {
|
|
192
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
193
|
+
const path = yield* Path.Path;
|
|
194
|
+
const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$4));
|
|
195
|
+
const raw = yield* Schema.decodeEffect(PackageJson)(text);
|
|
196
|
+
return pipe(raw, Record.filter((_value, key) => Array.contains(KEPT_FIELDS, key)));
|
|
197
|
+
});
|
|
198
|
+
/** @internal */
|
|
199
|
+
const writeNative = Effect.fn("publish.writeNative")(function* writeNative(directory, native) {
|
|
200
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
201
|
+
const path = yield* Path.Path;
|
|
202
|
+
const kept = yield* keptFields(directory);
|
|
203
|
+
const target = path.resolve(directory, NPM_DIR, native.target);
|
|
204
|
+
const file = nativeFileOf(native);
|
|
205
|
+
yield* fileSystem.makeDirectory(target, { recursive: true });
|
|
206
|
+
yield* fileSystem.copyFile(path.join(directory, NATIVE_DIR, file), path.join(target, file));
|
|
207
|
+
const text = yield* Schema.encodeEffect(PackageJson)({
|
|
208
|
+
...kept,
|
|
209
|
+
...nativeFields(native)
|
|
210
|
+
});
|
|
211
|
+
yield* Effect.all([fileSystem.writeFileString(path.join(target, MANIFEST_FILE$4), text), fileSystem.writeFileString(path.join(target, "README.md"), nativeReadme(native))], { concurrency: "unbounded" });
|
|
212
|
+
return target;
|
|
213
|
+
});
|
|
279
214
|
// src/features/publish-workspace/model/widened-ranges.ts
|
|
280
215
|
const HOOK_FILE = "widen-ranges.mjs";
|
|
281
216
|
/** @internal */
|
|
@@ -299,164 +234,346 @@ const widenRangesEnv = Effect.fn("publish.widenRanges")(function* widenRangesEnv
|
|
|
299
234
|
yield* fileSystem.writeFileString(hook, WIDEN_RANGES);
|
|
300
235
|
return { pnpm_config_pnpmfile: hook };
|
|
301
236
|
});
|
|
302
|
-
// src/features/publish-workspace/model/
|
|
237
|
+
// src/features/publish-workspace/model/pack.ts
|
|
303
238
|
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"
|
|
239
|
+
/** @internal */
|
|
240
|
+
const pack = Effect.fn("publish.pack")(function* pack(directory) {
|
|
241
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
242
|
+
const path = yield* Path.Path;
|
|
243
|
+
const temporary = yield* fileSystem.makeTempDirectoryScoped();
|
|
244
|
+
const tarball = path.join(temporary, TARBALL);
|
|
245
|
+
const env = yield* widenRangesEnv(temporary);
|
|
246
|
+
yield* mustSucceed({
|
|
247
|
+
command: "vp",
|
|
248
|
+
args: [
|
|
249
|
+
"pm",
|
|
250
|
+
"pack",
|
|
251
|
+
"--out",
|
|
252
|
+
tarball
|
|
253
|
+
],
|
|
254
|
+
env,
|
|
255
|
+
cwd: directory
|
|
328
256
|
});
|
|
329
|
-
return
|
|
330
|
-
|
|
331
|
-
|
|
257
|
+
return tarball;
|
|
258
|
+
});
|
|
259
|
+
// src/features/publish-workspace/model/compat-native.ts
|
|
260
|
+
const HOST_PREFIX = `${platform()}-${arch()}-`;
|
|
261
|
+
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) => ({
|
|
262
|
+
directory,
|
|
263
|
+
manifest,
|
|
264
|
+
binary,
|
|
265
|
+
target
|
|
266
|
+
})))));
|
|
267
|
+
const packedNative = Effect.fn("compat.packedNative")(function* packedNative({ directory, manifest, binary, target }) {
|
|
268
|
+
const written = yield* writeNative(directory, {
|
|
269
|
+
name: manifest.name,
|
|
270
|
+
version: manifest.version,
|
|
271
|
+
binary,
|
|
272
|
+
target
|
|
332
273
|
});
|
|
274
|
+
const tarball = yield* pack(written);
|
|
275
|
+
return [[`${manifest.name}-${target}`, tarball]];
|
|
333
276
|
});
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
277
|
+
/** @internal */
|
|
278
|
+
const nativeTarballs = Effect.fn("compat.native")(function* nativeTarballs(directory, manifest) {
|
|
279
|
+
const none = [];
|
|
280
|
+
return yield* pipe(builtOf(directory, manifest), Option.match({
|
|
281
|
+
onNone: () => Effect.succeed(none),
|
|
282
|
+
onSome: packedNative
|
|
283
|
+
}));
|
|
284
|
+
});
|
|
285
|
+
// src/features/publish-workspace/model/compat-workspace.ts
|
|
286
|
+
const dependencyNamesOf = (manifest) => pipe([
|
|
287
|
+
manifest.dependencies,
|
|
288
|
+
manifest.peerDependencies,
|
|
289
|
+
manifest.optionalDependencies
|
|
290
|
+
], Array.flatMap((declared) => Record.keys(declared ?? {})));
|
|
291
|
+
const closureOf = (known, names, seen) => {
|
|
292
|
+
const [name, ...rest] = names;
|
|
293
|
+
if (Predicate.isUndefined(name)) return seen;
|
|
294
|
+
const found = Record.get(known, name);
|
|
295
|
+
const reached = pipe(seen, Array.some((item) => item.manifest.name === name));
|
|
296
|
+
if (Option.isNone(found) || reached) return closureOf(known, rest, seen);
|
|
297
|
+
const inner = closureOf(known, dependencyNamesOf(found.value.manifest), [...seen, found.value]);
|
|
298
|
+
return closureOf(known, rest, inner);
|
|
299
|
+
};
|
|
300
|
+
const workspacesBeside = Effect.fn("compat.workspaces")(function* workspacesBeside(directory) {
|
|
301
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
302
|
+
const path = yield* Path.Path;
|
|
303
|
+
const parent = path.dirname(path.resolve(directory));
|
|
304
|
+
const entries = yield* fileSystem.readDirectory(parent);
|
|
305
|
+
const found = yield* Effect.forEach(entries, (entry) => compatManifestIn(path.join(parent, entry)).pipe(Effect.map((manifest) => [{
|
|
306
|
+
directory: path.join(parent, entry),
|
|
307
|
+
manifest
|
|
308
|
+
}]), Effect.orElseSucceed(() => [])), { concurrency: 1 });
|
|
309
|
+
return pipe(Array.flatten(found), Array.map((workspace) => [workspace.manifest.name, workspace]), Record.fromEntries);
|
|
310
|
+
});
|
|
311
|
+
const builtTarball = Effect.fn("compat.pack")(function* builtTarball(directory) {
|
|
312
|
+
yield* mustSucceed({
|
|
341
313
|
command: "vp",
|
|
342
|
-
args: ["run",
|
|
314
|
+
args: ["run", "build"],
|
|
343
315
|
cwd: directory
|
|
344
|
-
}), {
|
|
345
|
-
concurrency: 1,
|
|
346
|
-
discard: true
|
|
347
316
|
});
|
|
348
|
-
yield*
|
|
317
|
+
return yield* pack(directory);
|
|
349
318
|
});
|
|
350
|
-
const
|
|
351
|
-
const
|
|
319
|
+
const tarballsOf = Effect.fn("compat.tarballs")(function* tarballsOf({ directory, manifest }) {
|
|
320
|
+
const tarball = yield* builtTarball(directory);
|
|
321
|
+
const natives = yield* nativeTarballs(directory, manifest);
|
|
322
|
+
return [...[[manifest.name, tarball]], ...natives];
|
|
323
|
+
});
|
|
324
|
+
/** @internal */
|
|
325
|
+
const workspaceTarballs = Effect.fn("compat.local")(function* workspaceTarballs(directory, manifest) {
|
|
326
|
+
const known = yield* workspacesBeside(directory);
|
|
327
|
+
const reached = closureOf(known, dependencyNamesOf(manifest), [{
|
|
328
|
+
directory,
|
|
329
|
+
manifest
|
|
330
|
+
}]);
|
|
331
|
+
const packed = yield* Effect.forEach(reached, tarballsOf, { concurrency: 1 });
|
|
332
|
+
return Record.fromEntries(Array.flatten(packed));
|
|
333
|
+
});
|
|
334
|
+
// src/features/publish-workspace/model/compat.ts
|
|
335
|
+
const MANIFEST_FILE$3 = "package.json";
|
|
336
|
+
const INSTALL_FLAGS = ["--no-audit", "--no-fund"];
|
|
337
|
+
const LOAD_FAILURE = String.raw`/ERR_(MODULE_NOT_FOUND|PACKAGE_|INVALID_PACKAGE|UNKNOWN_FILE|UNSUPPORTED_DIR|REQUIRE_ESM)|SyntaxError/u`;
|
|
338
|
+
const IMPORT_ONLY = "await import(process.argv[1])";
|
|
339
|
+
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); }`;
|
|
340
|
+
const Versions$1 = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
341
|
+
const ConsumerJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));
|
|
342
|
+
const installedNode = Effect.fn("compat.node")(function* installedNode(directory, range) {
|
|
352
343
|
const path = yield* Path.Path;
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
344
|
+
yield* (yield* FileSystem.FileSystem).makeDirectory(directory, { recursive: true });
|
|
345
|
+
const listed = yield* outputOf({
|
|
346
|
+
command: "npm",
|
|
347
|
+
args: [
|
|
348
|
+
"view",
|
|
349
|
+
"node",
|
|
350
|
+
"versions",
|
|
351
|
+
"--json"
|
|
352
|
+
],
|
|
353
|
+
cwd: directory
|
|
354
|
+
});
|
|
355
|
+
const versions = yield* Schema.decodeEffect(Versions$1)(listed);
|
|
356
|
+
const version = yield* Effect.fromOption(Option.fromNullishOr(semver.maxSatisfying([...versions], range))).pipe(Effect.mapError(() => IncompatiblePackage.make({ message: `No Node.js release satisfies ${range}` })));
|
|
357
|
+
yield* mustSucceed({
|
|
358
|
+
command: "npm",
|
|
359
|
+
args: [
|
|
360
|
+
"install",
|
|
361
|
+
...INSTALL_FLAGS,
|
|
362
|
+
`node@${version}`
|
|
363
|
+
],
|
|
364
|
+
cwd: directory
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
version,
|
|
368
|
+
binary: path.join(directory, "node_modules", "node", "bin", "node")
|
|
369
|
+
};
|
|
356
370
|
});
|
|
357
|
-
const
|
|
371
|
+
const fileEntries = (tarballs) => pipe(Record.toEntries(tarballs), Array.map(([name, file]) => [name, `file:${file}`]));
|
|
372
|
+
const siblingOverrides = (tarballs) => pipe(Record.keys(tarballs), Array.map((sibling) => [sibling, `$${sibling}`]));
|
|
373
|
+
const consumerJson = Effect.fn("compat.json")(function* consumerJson({ peers, tarballs }) {
|
|
374
|
+
const dependencies = Record.fromEntries([...Record.toEntries(peers), ...fileEntries(tarballs)]);
|
|
375
|
+
return yield* Schema.encodeEffect(ConsumerJson)({
|
|
376
|
+
private: true,
|
|
377
|
+
type: "module",
|
|
378
|
+
dependencies,
|
|
379
|
+
overrides: Record.fromEntries(siblingOverrides(tarballs))
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
const withViteOfVitePlus = Effect.fn("compat.vite")(function* withViteOfVitePlus(directory) {
|
|
358
383
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
359
384
|
const path = yield* Path.Path;
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
385
|
+
const text = yield* fileSystem.readFileString(path.join(directory, "node_modules", VITE_PLUS, MANIFEST_FILE$3));
|
|
386
|
+
yield* Option.match(viteAliasOf(text), {
|
|
387
|
+
onNone: () => Effect.void,
|
|
388
|
+
onSome: (alias) => mustSucceed({
|
|
389
|
+
command: "npm",
|
|
390
|
+
args: [
|
|
391
|
+
"install",
|
|
392
|
+
"--ignore-scripts",
|
|
393
|
+
"--force",
|
|
394
|
+
...INSTALL_FLAGS,
|
|
395
|
+
alias
|
|
396
|
+
],
|
|
397
|
+
cwd: directory
|
|
398
|
+
})
|
|
368
399
|
});
|
|
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
400
|
});
|
|
372
|
-
const
|
|
401
|
+
const installedConsumer = Effect.fn("compat.consumer")(function* installedConsumer(root, consumer) {
|
|
373
402
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
374
403
|
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
|
-
}
|
|
404
|
+
const directory = path.join(root, "consumer");
|
|
405
|
+
yield* fileSystem.makeDirectory(directory, { recursive: true });
|
|
406
|
+
const text = yield* consumerJson(consumer);
|
|
407
|
+
yield* fileSystem.writeFileString(path.join(directory, MANIFEST_FILE$3), text);
|
|
384
408
|
yield* mustSucceed({
|
|
385
409
|
command: "npm",
|
|
386
410
|
args: [
|
|
387
|
-
"
|
|
388
|
-
"
|
|
389
|
-
...
|
|
411
|
+
"install",
|
|
412
|
+
"--ignore-scripts",
|
|
413
|
+
...INSTALL_FLAGS
|
|
390
414
|
],
|
|
391
|
-
|
|
392
|
-
cwd: target
|
|
415
|
+
cwd: directory
|
|
393
416
|
});
|
|
394
|
-
|
|
417
|
+
if (Record.has(consumer.peers, "vite-plus")) yield* withViteOfVitePlus(directory);
|
|
418
|
+
return directory;
|
|
395
419
|
});
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
420
|
+
const loadsCleanly = ({ runtime, consumer, args }) => mustSucceed({
|
|
421
|
+
command: runtime,
|
|
422
|
+
args: [
|
|
423
|
+
"--input-type=module",
|
|
424
|
+
"-e",
|
|
425
|
+
SPAWN_CHECKED,
|
|
426
|
+
"--",
|
|
427
|
+
...args
|
|
428
|
+
],
|
|
429
|
+
cwd: consumer
|
|
430
|
+
});
|
|
431
|
+
const smoke = Effect.fn("compat.smoke")(function* smoke(manifest, runtime, consumer) {
|
|
432
|
+
const path = yield* Path.Path;
|
|
433
|
+
const { imports, bins } = smokeTargetsOf(manifest);
|
|
434
|
+
const importer = [
|
|
435
|
+
"--input-type=module",
|
|
436
|
+
"-e",
|
|
437
|
+
IMPORT_ONLY
|
|
438
|
+
];
|
|
439
|
+
yield* Effect.forEach(imports, (specifier) => loadsCleanly({
|
|
440
|
+
runtime,
|
|
441
|
+
consumer,
|
|
442
|
+
args: [...importer, specifier]
|
|
443
|
+
}), {
|
|
444
|
+
concurrency: 1,
|
|
445
|
+
discard: true
|
|
446
|
+
});
|
|
447
|
+
yield* Effect.forEach(bins, (file) => loadsCleanly({
|
|
448
|
+
runtime,
|
|
449
|
+
consumer,
|
|
450
|
+
args: [path.join(consumer, "node_modules", manifest.name, file), "--help"]
|
|
451
|
+
}), {
|
|
452
|
+
concurrency: 1,
|
|
453
|
+
discard: true
|
|
404
454
|
});
|
|
405
|
-
yield* fileSystem.writeFileString(file, updated);
|
|
406
455
|
});
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
})
|
|
416
|
-
const
|
|
417
|
-
yield*
|
|
456
|
+
const runCase = Effect.fn("compat.case")(function* runCase({ manifest, tarballs, compat }) {
|
|
457
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
458
|
+
const path = yield* Path.Path;
|
|
459
|
+
const root = yield* fileSystem.makeTempDirectoryScoped();
|
|
460
|
+
const runtime = yield* installedNode(path.join(root, "runtime"), compat.node);
|
|
461
|
+
const consumer = yield* installedConsumer(root, {
|
|
462
|
+
peers: compat.peers,
|
|
463
|
+
tarballs
|
|
464
|
+
});
|
|
465
|
+
const peers = pipe(Record.toEntries(compat.peers), Array.map(([name, range]) => `${name}@${range}`), Array.join(", "));
|
|
466
|
+
yield* Console.log(`${manifest.name} ${compat.label}: Node.js ${runtime.version}, peers ${peers}`);
|
|
467
|
+
yield* smoke(manifest, runtime.binary, consumer);
|
|
468
|
+
}, Effect.scoped);
|
|
469
|
+
/** @internal */
|
|
470
|
+
const checkCompat = Effect.fn("publish.compat")(function* checkCompat(directory) {
|
|
471
|
+
const manifest = yield* compatManifestIn(directory);
|
|
472
|
+
const cases = compatCasesOf(manifest);
|
|
473
|
+
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` });
|
|
474
|
+
const tarballs = yield* workspaceTarballs(directory, manifest);
|
|
475
|
+
return yield* Effect.forEach(cases, (compat) => runCase({
|
|
476
|
+
manifest,
|
|
477
|
+
tarballs,
|
|
478
|
+
compat
|
|
479
|
+
}), {
|
|
480
|
+
concurrency: 1,
|
|
481
|
+
discard: true
|
|
482
|
+
});
|
|
483
|
+
}, Effect.scoped);
|
|
484
|
+
// src/features/publish-workspace/model/manifest.ts
|
|
485
|
+
const MANIFEST_FILE$2 = "package.json";
|
|
486
|
+
const SCOPE = /^@[^/]+\//u;
|
|
487
|
+
const UNVERSIONED$1 = "0.0.0";
|
|
488
|
+
const ROOT = ".";
|
|
489
|
+
const Native = Schema.Struct({
|
|
490
|
+
binary: Schema.String,
|
|
491
|
+
targets: Schema.Array(Schema.String)
|
|
418
492
|
});
|
|
419
|
-
const
|
|
493
|
+
const ManifestSchema = Schema.Struct({
|
|
494
|
+
name: Schema.String,
|
|
495
|
+
version: Schema.String,
|
|
496
|
+
private: Schema.optionalKey(Schema.Boolean),
|
|
497
|
+
dependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
498
|
+
native: Schema.optionalKey(Native),
|
|
499
|
+
"size-limit": Schema.optionalKey(Schema.Unknown)
|
|
500
|
+
});
|
|
501
|
+
/** @internal */
|
|
502
|
+
const manifestIn = Effect.fn("publish.manifest")(function* manifestIn(directory) {
|
|
420
503
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
421
504
|
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;
|
|
505
|
+
const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$2));
|
|
506
|
+
return yield* Schema.decodeEffect(Schema.fromJsonString(ManifestSchema))(text);
|
|
437
507
|
});
|
|
438
508
|
/** @internal */
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
509
|
+
const releaseName = ({ name }) => String$1.replace(SCOPE, "")(name);
|
|
510
|
+
/** @internal */
|
|
511
|
+
const isRoot = (directory) => directory === ROOT;
|
|
512
|
+
/** @internal */
|
|
513
|
+
const tagOf = ({ directory, name, version }) => {
|
|
514
|
+
if (isRoot(directory)) return `v${version}`;
|
|
515
|
+
return `${releaseName({ name })}-v${version}`;
|
|
516
|
+
};
|
|
517
|
+
/** @internal */
|
|
518
|
+
const environmentOf = (manifest) => `${releaseName(manifest)}-release`;
|
|
519
|
+
/** @internal */
|
|
520
|
+
const isVersioned = ({ version }) => version !== UNVERSIONED$1;
|
|
521
|
+
/** @internal */
|
|
522
|
+
const goesToNpm = (manifest) => !pipe(Option.fromUndefinedOr(manifest.private), Option.getOrElse(() => false));
|
|
523
|
+
// src/features/publish-workspace/model/dependencies.ts
|
|
524
|
+
const WORKSPACE_PROTOCOL = "workspace:";
|
|
525
|
+
const READ_CONCURRENCY = 8;
|
|
526
|
+
/** @internal */
|
|
527
|
+
const onNpm = ({ directory, name, version }) => succeeds({
|
|
528
|
+
command: "npm",
|
|
529
|
+
args: [
|
|
530
|
+
"view",
|
|
531
|
+
`${name}@${version}`,
|
|
532
|
+
"version"
|
|
533
|
+
],
|
|
534
|
+
cwd: directory
|
|
535
|
+
});
|
|
536
|
+
const taggedError$2 = Schema.TaggedError;
|
|
537
|
+
/** @internal */
|
|
538
|
+
var UnpublishedDependencies = class extends taggedError$2()("UnpublishedDependencies", { message: Schema.String }) {};
|
|
539
|
+
const workspaceDependencies = (manifest) => pipe(Option.fromUndefinedOr(manifest.dependencies), Option.map((dependencies) => pipe(dependencies, Record.filter(String$1.startsWith(WORKSPACE_PROTOCOL)), Record.keys)), Option.getOrElse(() => []));
|
|
540
|
+
const failWhenMissing = (missing, manifest) => {
|
|
541
|
+
if (Array.isReadonlyArrayEmpty(missing)) return Effect.void;
|
|
542
|
+
const names = pipe(missing, Array.map(({ directory, name, version }) => `${name}@${version} (${directory})`), Array.join(", "));
|
|
543
|
+
return Effect.fail(UnpublishedDependencies.make({ message: `${manifest.name} depends on versions that are not on npm yet. Publish them first: ${names}` }));
|
|
544
|
+
};
|
|
545
|
+
/** @internal */
|
|
546
|
+
const requirePublishedDependencies = Effect.fn("publish.dependencies")(function* requirePublishedDependencies({ manifest, workspaces }) {
|
|
547
|
+
const wanted = workspaceDependencies(manifest);
|
|
548
|
+
const siblings = yield* Effect.forEach(workspaces, (directory) => manifestIn(directory).pipe(Effect.map((found) => ({
|
|
442
549
|
directory,
|
|
443
|
-
...
|
|
444
|
-
}))
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
yield*
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
550
|
+
...found
|
|
551
|
+
}))), { concurrency: READ_CONCURRENCY });
|
|
552
|
+
const internal = pipe(siblings, Array.filter((sibling) => Array.contains(wanted, sibling.name) && goesToNpm(sibling)));
|
|
553
|
+
const missing = yield* Effect.filter(internal, (sibling) => onNpm(sibling).pipe(Effect.map((published) => !published)), { concurrency: READ_CONCURRENCY });
|
|
554
|
+
yield* failWhenMissing(missing, manifest);
|
|
555
|
+
});
|
|
556
|
+
// src/features/publish-workspace/model/broker.ts
|
|
557
|
+
const Issued = Schema.Record(Schema.String, Schema.Unknown);
|
|
558
|
+
const issued = Effect.fn("publish.issued")(function* issued(oidc, { kind, field }) {
|
|
559
|
+
const client = yield* HttpClient.HttpClient;
|
|
560
|
+
const request = HttpClientRequest.post(`${BROKER}?only=${kind}`).pipe(HttpClientRequest.bearerToken(oidc));
|
|
561
|
+
const response = yield* HttpClient.filterStatusOk(client).execute(request);
|
|
562
|
+
const body = yield* HttpClientResponse.schemaBodyJson(Issued)(response);
|
|
563
|
+
const token = Option.filter(Option.fromNullishOr(body[field]), (value) => typeof value === "string" && value !== "");
|
|
564
|
+
yield* Effect.forEach(Option.toArray(token), mask, {
|
|
565
|
+
concurrency: 1,
|
|
566
|
+
discard: true
|
|
458
567
|
});
|
|
459
|
-
|
|
568
|
+
return token;
|
|
569
|
+
});
|
|
570
|
+
/** @internal */
|
|
571
|
+
const brokerCredential = Effect.fn("publish.brokerCredential")(function* brokerCredential(credential) {
|
|
572
|
+
return yield* actionsOidcToken.pipe(Effect.flatMap(Option.match({
|
|
573
|
+
onNone: () => Effect.succeedNone,
|
|
574
|
+
onSome: (oidc) => issued(oidc, credential)
|
|
575
|
+
})), Effect.tapError(() => Console.log(`The credential broker gave no ${credential.field}`)), Effect.orElseSucceed(() => Option.none()));
|
|
576
|
+
});
|
|
460
577
|
// src/features/publish-workspace/model/provenance.ts
|
|
461
578
|
const ATTESTATIONS = "https://registry.npmjs.org/-/npm/v1/attestations/";
|
|
462
579
|
const SLSA = /slsa\.dev\/provenance/u;
|
|
@@ -476,7 +593,7 @@ const commitOf = (payload) => pipe(Base64.decodeString(payload), Effect.fromResu
|
|
|
476
593
|
/** @internal */
|
|
477
594
|
const provenanceCommit = Effect.fn("publish.provenanceCommit")(function* provenanceCommit({ name, version }) {
|
|
478
595
|
const client = yield* HttpClient.HttpClient;
|
|
479
|
-
const url = `${ATTESTATIONS}${String.replace("/", "%2f")(name)}@${version}`;
|
|
596
|
+
const url = `${ATTESTATIONS}${String$1.replace("/", "%2f")(name)}@${version}`;
|
|
480
597
|
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
598
|
if (Option.isNone(found)) return Option.none();
|
|
482
599
|
return yield* commitOf(found.value.bundle.dsseEnvelope.payload);
|
|
@@ -484,7 +601,7 @@ const provenanceCommit = Effect.fn("publish.provenanceCommit")(function* provena
|
|
|
484
601
|
// src/features/publish-workspace/model/tags.ts
|
|
485
602
|
const UNVERSIONED = "0.0.0";
|
|
486
603
|
const LOOKUP_CONCURRENCY = 4;
|
|
487
|
-
const Versions = Schema.
|
|
604
|
+
const Versions = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
488
605
|
/** @internal */
|
|
489
606
|
const tagged = Effect.fn("publish.tagged")(function* tagged(tag) {
|
|
490
607
|
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
@@ -608,11 +725,13 @@ const PlanSchema = Schema.Struct({
|
|
|
608
725
|
hook: Schema.Boolean
|
|
609
726
|
});
|
|
610
727
|
const AssetCount = Schema.fromJsonString(Schema.Finite);
|
|
728
|
+
/** @internal */
|
|
611
729
|
const graphTasks = outputOf({
|
|
612
730
|
command: "vp",
|
|
613
731
|
args: ["run", "--json"]
|
|
614
732
|
}).pipe(Effect.flatMap(Schema.decodeEffect(TaskGraph)), Effect.map(({ tasks }) => Record.values(tasks)));
|
|
615
733
|
const tasksIn = (tasks, directory) => pipe(tasks, Array.filter((task) => task.package === directory), Array.map(({ name }) => name));
|
|
734
|
+
/** @internal */
|
|
616
735
|
const workspacesOf = (tasks) => pipe(tasks, Array.map((task) => task.package), Array.dedupe);
|
|
617
736
|
const allTagged = Effect.fn("publish.allTagged")(function* allTagged(directory, manifest) {
|
|
618
737
|
if (!isVersioned(manifest)) return true;
|
|
@@ -626,7 +745,7 @@ const allTagged = Effect.fn("publish.allTagged")(function* allTagged(directory,
|
|
|
626
745
|
});
|
|
627
746
|
return current && Array.isReadonlyArrayEmpty(older);
|
|
628
747
|
});
|
|
629
|
-
const workspaceOf = (directory) => Path.Path.pipe(Effect.map((path) => String.replace(TRAILING_SLASH, "")(path.normalize(directory))));
|
|
748
|
+
const workspaceOf = (directory) => Path.Path.pipe(Effect.map((path) => String$1.replace(TRAILING_SLASH, "")(path.normalize(directory))));
|
|
630
749
|
/** @internal */
|
|
631
750
|
const released = Effect.fn("publish.released")(function* released(tag) {
|
|
632
751
|
const repository = yield* Config.String("GITHUB_REPOSITORY");
|
|
@@ -720,6 +839,163 @@ const writePlan = Effect.fn("publish.writePlan")(function* writePlan(plan) {
|
|
|
720
839
|
yield* Effect.logInfo(encoded);
|
|
721
840
|
yield* writeOutputs({ plan: encoded });
|
|
722
841
|
});
|
|
842
|
+
// src/features/publish-workspace/model/compat-plan.ts
|
|
843
|
+
const Directories = Schema.String.pipe(Schema.Array, Schema.fromJsonString);
|
|
844
|
+
const isChecked = Effect.fn("compat.isChecked")(function* isChecked(directory) {
|
|
845
|
+
const manifest = yield* compatManifestIn(directory);
|
|
846
|
+
return goesToNpm(manifest) && !Array.isReadonlyArrayEmpty(compatCasesOf(manifest));
|
|
847
|
+
});
|
|
848
|
+
/** @internal */
|
|
849
|
+
const writeCompatPlan = Effect.fn("publish.compatPlan")(function* writeCompatPlan() {
|
|
850
|
+
const graph = yield* graphTasks;
|
|
851
|
+
const checked = yield* Effect.filter(workspacesOf(graph), isChecked, { concurrency: 1 });
|
|
852
|
+
const encoded = yield* Schema.encodeEffect(Directories)(checked);
|
|
853
|
+
yield* Effect.logInfo(encoded);
|
|
854
|
+
yield* writeOutputs({ directories: encoded });
|
|
855
|
+
});
|
|
856
|
+
// src/features/publish-workspace/model/export-targets.ts
|
|
857
|
+
const PATTERN = "*";
|
|
858
|
+
const MANIFEST_FILE$1 = "package.json";
|
|
859
|
+
const taggedError$1 = Schema.TaggedError;
|
|
860
|
+
/** @internal */
|
|
861
|
+
var MissingExportTargets = class extends taggedError$1()("MissingExportTargets", { message: Schema.String }) {};
|
|
862
|
+
const AnyExports = Schema.optionalKey(Schema.Unknown);
|
|
863
|
+
const PublishConfig = Schema.Struct({ exports: AnyExports });
|
|
864
|
+
const PublishedExports = Schema.fromJsonString(Schema.Struct({
|
|
865
|
+
exports: AnyExports,
|
|
866
|
+
publishConfig: Schema.optionalKey(PublishConfig)
|
|
867
|
+
}));
|
|
868
|
+
const singleTarget = (target) => {
|
|
869
|
+
if (String$1.includes(PATTERN)(target)) return [];
|
|
870
|
+
return [target];
|
|
871
|
+
};
|
|
872
|
+
/** @internal */
|
|
873
|
+
const exportTargetsOf = (exports) => {
|
|
874
|
+
if (Predicate.isString(exports)) return singleTarget(exports);
|
|
875
|
+
if (Array.isArray(exports)) return pipe(exports, Array.flatMap((entry) => exportTargetsOf(entry)));
|
|
876
|
+
if (Predicate.isReadonlyObject(exports)) return pipe(Record.values(exports), Array.flatMap((entry) => exportTargetsOf(entry)));
|
|
877
|
+
return [];
|
|
878
|
+
};
|
|
879
|
+
const publishedExportsOf = (manifest) => pipe(Option.fromUndefinedOr(manifest.publishConfig), Option.flatMap((config) => Option.fromUndefinedOr(config.exports)), Option.orElse(() => Option.fromUndefinedOr(manifest.exports)), Option.getOrUndefined);
|
|
880
|
+
const missingMessage = (missing) => `The published exports point to files the build did not write: ${Array.join(missing, ", ")}`;
|
|
881
|
+
/** @internal */
|
|
882
|
+
const checkExportTargets = Effect.fn("publish.checkExportTargets")(function* checkExportTargets(directory) {
|
|
883
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
884
|
+
const path = yield* Path.Path;
|
|
885
|
+
const manifest = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE$1)).pipe(Effect.flatMap(Schema.decodeEffect(PublishedExports)));
|
|
886
|
+
const missing = yield* Effect.filter(exportTargetsOf(publishedExportsOf(manifest)), (target) => Effect.map(fileSystem.exists(path.join(directory, target)), (found) => !found));
|
|
887
|
+
return yield* pipe(missing, Array.match({
|
|
888
|
+
onEmpty: () => Effect.void,
|
|
889
|
+
onNonEmpty: (list) => Effect.fail(MissingExportTargets.make({ message: missingMessage(list) }))
|
|
890
|
+
}));
|
|
891
|
+
});
|
|
892
|
+
// src/features/publish-workspace/model/npm.ts
|
|
893
|
+
const MANIFEST_FILE = "package.json";
|
|
894
|
+
const PUBLISH_FLAGS = [
|
|
895
|
+
"--provenance",
|
|
896
|
+
"--access",
|
|
897
|
+
"public"
|
|
898
|
+
];
|
|
899
|
+
const PlatformManifest = Schema.fromJsonString(Schema.Struct({
|
|
900
|
+
name: Schema.String,
|
|
901
|
+
version: Schema.String
|
|
902
|
+
}));
|
|
903
|
+
const authEnv = Effect.fn("publish.authEnv")(function* authEnv() {
|
|
904
|
+
const token = yield* brokerCredential({
|
|
905
|
+
kind: "npm",
|
|
906
|
+
field: "npmToken"
|
|
907
|
+
});
|
|
908
|
+
return Option.match(token, {
|
|
909
|
+
onNone: () => ({}),
|
|
910
|
+
onSome: (value) => ({ NODE_AUTH_TOKEN: value })
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
const verifyPackage = Effect.fn("publish.verify")(function* verifyPackage(directory, manifest) {
|
|
914
|
+
const tasks = [
|
|
915
|
+
"build",
|
|
916
|
+
"test",
|
|
917
|
+
...pipe(Option.fromUndefinedOr(manifest["size-limit"]), Option.map(() => "size"), Option.toArray)
|
|
918
|
+
];
|
|
919
|
+
yield* Effect.forEach(tasks, (task) => mustSucceed({
|
|
920
|
+
command: "vp",
|
|
921
|
+
args: ["run", task],
|
|
922
|
+
cwd: directory
|
|
923
|
+
}), {
|
|
924
|
+
concurrency: 1,
|
|
925
|
+
discard: true
|
|
926
|
+
});
|
|
927
|
+
yield* checkExportTargets(directory);
|
|
928
|
+
yield* checkCompat(directory);
|
|
929
|
+
});
|
|
930
|
+
const publishNative = Effect.fn("publish.publishNative")(function* publishNative(target, env) {
|
|
931
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
932
|
+
const path = yield* Path.Path;
|
|
933
|
+
const { name, version } = yield* fileSystem.readFileString(path.join(target, MANIFEST_FILE)).pipe(Effect.flatMap(Schema.decodeEffect(PlatformManifest)));
|
|
934
|
+
if (yield* onNpm({
|
|
935
|
+
directory: target,
|
|
936
|
+
name,
|
|
937
|
+
version
|
|
938
|
+
})) {
|
|
939
|
+
yield* Console.log(`${name}@${version} is already published, skipping`);
|
|
940
|
+
return name;
|
|
941
|
+
}
|
|
942
|
+
yield* mustSucceed({
|
|
943
|
+
command: "npm",
|
|
944
|
+
args: [
|
|
945
|
+
"publish",
|
|
946
|
+
".",
|
|
947
|
+
...PUBLISH_FLAGS
|
|
948
|
+
],
|
|
949
|
+
env,
|
|
950
|
+
cwd: target
|
|
951
|
+
});
|
|
952
|
+
return name;
|
|
953
|
+
});
|
|
954
|
+
const addOptionalDependencies = Effect.fn("publish.optionalDependencies")(function* addOptionalDependencies(directory, names, version) {
|
|
955
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
956
|
+
const file = (yield* Path.Path).join(directory, MANIFEST_FILE);
|
|
957
|
+
const manifest = yield* fileSystem.readFileString(file).pipe(Effect.flatMap(Schema.decodeEffect(PackageJson)));
|
|
958
|
+
const optionalDependencies = pipe(names, Array.map((name) => [name, version]), Record.fromEntries);
|
|
959
|
+
const updated = yield* Schema.encodeEffect(PackageJson)({
|
|
960
|
+
...manifest,
|
|
961
|
+
optionalDependencies
|
|
962
|
+
});
|
|
963
|
+
yield* fileSystem.writeFileString(file, updated);
|
|
964
|
+
});
|
|
965
|
+
const publishNatives = Effect.fn("publish.publishNatives")(function* publishNatives(directory, manifest, env) {
|
|
966
|
+
if (Predicate.isUndefined(manifest.native)) return;
|
|
967
|
+
const { binary, targets } = manifest.native;
|
|
968
|
+
const written = yield* Effect.forEach(targets, (target) => writeNative(directory, {
|
|
969
|
+
name: manifest.name,
|
|
970
|
+
version: manifest.version,
|
|
971
|
+
binary,
|
|
972
|
+
target
|
|
973
|
+
}), { concurrency: 1 });
|
|
974
|
+
const names = yield* Effect.forEach(written, (target) => publishNative(target, env), { concurrency: 1 });
|
|
975
|
+
yield* addOptionalDependencies(directory, names, manifest.version);
|
|
976
|
+
});
|
|
977
|
+
/** @internal */
|
|
978
|
+
const publishToNpm = Effect.fn("publish.npm")(function* publishToNpm(directory) {
|
|
979
|
+
const manifest = yield* manifestIn(directory);
|
|
980
|
+
if (yield* onNpm({
|
|
981
|
+
directory,
|
|
982
|
+
...manifest
|
|
983
|
+
})) return yield* Console.log(`${manifest.name}@${manifest.version} is already published`);
|
|
984
|
+
yield* verifyPackage(directory, manifest);
|
|
985
|
+
const env = yield* authEnv();
|
|
986
|
+
yield* publishNatives(directory, manifest, env);
|
|
987
|
+
const tarball = yield* pack(directory);
|
|
988
|
+
return yield* mustSucceed({
|
|
989
|
+
command: "npm",
|
|
990
|
+
args: [
|
|
991
|
+
"publish",
|
|
992
|
+
tarball,
|
|
993
|
+
...PUBLISH_FLAGS
|
|
994
|
+
],
|
|
995
|
+
env,
|
|
996
|
+
cwd: directory
|
|
997
|
+
});
|
|
998
|
+
}, Effect.scoped);
|
|
723
999
|
// src/features/publish-workspace/model/release.ts
|
|
724
1000
|
const ASSETS = "release-assets";
|
|
725
1001
|
const revisionOf = Effect.fn("publish.revision")(function* revisionOf(manifest) {
|
|
@@ -838,20 +1114,31 @@ const publishRelease = Effect.fn("publish.release")(function* publishRelease(dir
|
|
|
838
1114
|
});
|
|
839
1115
|
});
|
|
840
1116
|
// bin/msch-publish.ts
|
|
841
|
-
const Arguments = Schema.
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1117
|
+
const Arguments = Schema.Tuple([Schema.Literals([
|
|
1118
|
+
"plan",
|
|
1119
|
+
"npm",
|
|
1120
|
+
"release",
|
|
1121
|
+
"compat",
|
|
1122
|
+
"compat-plan"
|
|
1123
|
+
]), Schema.String]);
|
|
846
1124
|
const taggedError = Schema.TaggedError;
|
|
847
1125
|
var UsageError = class extends taggedError()("UsageError", { message: Schema.String }) {};
|
|
848
|
-
const USAGE = "usage: msch-publish <plan|npm|release> <workspace directory>";
|
|
1126
|
+
const USAGE = "usage: msch-publish <plan|npm|release|compat|compat-plan> <workspace directory>";
|
|
1127
|
+
const steps = {
|
|
1128
|
+
plan: Effect.fn("plan")(function* plan(directory) {
|
|
1129
|
+
return yield* planOf(directory).pipe(Effect.flatMap(writePlan));
|
|
1130
|
+
}),
|
|
1131
|
+
npm: publishToNpm,
|
|
1132
|
+
release: publishRelease,
|
|
1133
|
+
compat: checkCompat,
|
|
1134
|
+
"compat-plan": Effect.fn("compat-plan")(function* compatPlan() {
|
|
1135
|
+
return yield* writeCompatPlan();
|
|
1136
|
+
})
|
|
1137
|
+
};
|
|
849
1138
|
const publish = Effect.gen(function* publish() {
|
|
850
1139
|
const args = yield* (yield* Stdio.Stdio).args;
|
|
851
1140
|
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);
|
|
1141
|
+
return yield* steps[step](directory);
|
|
855
1142
|
});
|
|
856
1143
|
runCli(publish);
|
|
857
1144
|
export {};
|