@r_masseater/msch 0.31.0 → 0.34.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 -49
- package/dist/{cli-contract-kyLbx4PX.mjs → cli-contract-mzluqQvf.mjs} +2 -2
- package/dist/{cli-contract-kyLbx4PX.mjs.map → cli-contract-mzluqQvf.mjs.map} +1 -1
- package/dist/cli.mjs +11531 -2476
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +28 -0
- package/dist/config.mjs +192 -0
- package/dist/config.mjs.map +1 -0
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{lint-preset-CSUe9lcG.mjs → define-lint-preset-X-_KpO1E.mjs} +50 -20
- package/dist/define-lint-preset-X-_KpO1E.mjs.map +1 -0
- package/dist/{index-y3tq-lW5.d.mts → index-BOXkKig9.d.mts} +2 -1
- package/dist/index-C02uoL59.d.mts +41 -0
- package/dist/lint-rules.mjs +96 -8
- package/dist/lint-rules.mjs.map +1 -1
- package/dist/lint.d.mts +1 -1
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +2 -2
- package/dist/oxlint.mjs.map +1 -1
- package/dist/{workspace-DuBjvDMC.mjs → package-DU5r3bvx.mjs} +388 -359
- package/dist/package-DU5r3bvx.mjs.map +1 -0
- package/dist/{repository-files-B11FFAIk.mjs → repository-files-R0NW0NE9.mjs} +33 -2
- package/dist/repository-files-R0NW0NE9.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +2 -38
- package/dist/workspace-settings.mjs +71 -57
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +23 -5
- package/skills/msch-checks/SKILL.md +31 -5
- package/skills/repository-config/SKILL.md +88 -0
- package/skills/workspace-settings/SKILL.md +62 -0
- package/dist/lint-preset-CSUe9lcG.mjs.map +0 -1
- package/dist/repository-files-B11FFAIk.mjs.map +0 -1
- package/dist/workspace-DuBjvDMC.mjs.map +0 -1
|
@@ -1,276 +1,9 @@
|
|
|
1
|
-
import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-
|
|
1
|
+
import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-R0NW0NE9.mjs";
|
|
2
2
|
import { Array, Effect, Match, Option, Order, Predicate, Record, Schema, String as String$1, pipe } from "effect";
|
|
3
3
|
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const PackageManifest = Schema.Struct({
|
|
8
|
-
name: Schema.optional(Schema.String),
|
|
9
|
-
dependencies: DependencyMap,
|
|
10
|
-
devDependencies: DependencyMap,
|
|
11
|
-
peerDependencies: DependencyMap,
|
|
12
|
-
exports: Schema.optional(Schema.Unknown),
|
|
13
|
-
types: Schema.optional(Schema.String),
|
|
14
|
-
typings: Schema.optional(Schema.String),
|
|
15
|
-
main: Schema.optional(Schema.String)
|
|
16
|
-
});
|
|
17
|
-
const MANIFEST_FILE$1 = "package.json";
|
|
18
|
-
const WORKSPACE_PROTOCOL = "workspace:";
|
|
19
|
-
const ROOT_SUBPATH$1 = ".";
|
|
20
|
-
const SUBPATH_PREFIX = "./";
|
|
21
|
-
const WILDCARD = "*";
|
|
22
|
-
const TYPES_CONDITION = "types";
|
|
23
|
-
const TYPES_SCOPE = "@types/";
|
|
24
|
-
const TYPES_SCOPE_SEPARATOR = "__";
|
|
25
|
-
const CONDITION_DEPTH_LIMIT = 8;
|
|
26
|
-
const ROOT_DEPTH = 0;
|
|
27
|
-
const DEPTH_STEP = 1;
|
|
28
|
-
const DECLARATIONS_SUFFIX = /\.d\.[cm]?ts$|\.[cm]?tsx?$/u;
|
|
29
|
-
const SCRIPT_SUFFIX = /\.(?<module>[cm]?)js$/u;
|
|
30
|
-
const readManifest = Effect.fn("readManifest")(function* readManifest(directory) {
|
|
31
|
-
const files = yield* RepositoryFiles;
|
|
32
|
-
const manifestText = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
|
|
33
|
-
const text = yield* Effect.fromOption(manifestText);
|
|
34
|
-
return yield* Schema.decodeEffect(Schema.fromJsonString(PackageManifest))(text);
|
|
35
|
-
}, Effect.option);
|
|
36
|
-
const conditionsOf = (held) => {
|
|
37
|
-
if (!Predicate.isObject(held)) return [];
|
|
38
|
-
return Record.toEntries(held);
|
|
39
|
-
};
|
|
40
|
-
const typesConditionIn = (held, depth) => {
|
|
41
|
-
if (depth > CONDITION_DEPTH_LIMIT) return Option.none();
|
|
42
|
-
const entries = conditionsOf(held);
|
|
43
|
-
const declared = Array.findFirst(entries, ([condition, target]) => Option.liftPredicate(target, (candidate) => condition === TYPES_CONDITION && Predicate.isString(candidate))).pipe(Option.filter(Predicate.isString));
|
|
44
|
-
return Option.orElse(declared, () => Array.findFirst(entries, ([, nested]) => typesConditionIn(nested, depth + DEPTH_STEP)));
|
|
45
|
-
};
|
|
46
|
-
const anyConditionIn = (held, depth) => {
|
|
47
|
-
if (Predicate.isString(held)) return Option.some(held);
|
|
48
|
-
if (depth > CONDITION_DEPTH_LIMIT) return Option.none();
|
|
49
|
-
return Array.findFirst(conditionsOf(held), ([, nested]) => anyConditionIn(nested, depth + DEPTH_STEP));
|
|
50
|
-
};
|
|
51
|
-
const targetPathsOf = (target) => Array.getSomes([typesConditionIn(target, ROOT_DEPTH), anyConditionIn(target, ROOT_DEPTH)]);
|
|
52
|
-
const subpathTargetsOf = (exportsField) => {
|
|
53
|
-
if (Predicate.isString(exportsField)) return [{
|
|
54
|
-
subpath: ROOT_SUBPATH$1,
|
|
55
|
-
target: exportsField
|
|
56
|
-
}];
|
|
57
|
-
const entries = conditionsOf(exportsField);
|
|
58
|
-
if (!pipe(entries, Array.some(([subpath]) => String$1.startsWith(ROOT_SUBPATH$1)(subpath)))) return Array.match(entries, {
|
|
59
|
-
onEmpty: () => [],
|
|
60
|
-
onNonEmpty: () => [{
|
|
61
|
-
subpath: ROOT_SUBPATH$1,
|
|
62
|
-
target: exportsField
|
|
63
|
-
}]
|
|
64
|
-
});
|
|
65
|
-
return pipe(entries, Array.filter(([subpath]) => subpath === ROOT_SUBPATH$1 || String$1.startsWith(SUBPATH_PREFIX)(subpath)), Array.filter(([subpath]) => !String$1.includes(WILDCARD)(subpath)), Array.map(([subpath, target]) => ({
|
|
66
|
-
subpath,
|
|
67
|
-
target
|
|
68
|
-
})));
|
|
69
|
-
};
|
|
70
|
-
const declarationsCandidateFor = (entryPath) => {
|
|
71
|
-
if (DECLARATIONS_SUFFIX.test(entryPath)) return Option.some(entryPath);
|
|
72
|
-
if (!SCRIPT_SUFFIX.test(entryPath)) return Option.none();
|
|
73
|
-
return Option.some(String$1.replace(SCRIPT_SUFFIX, ".d.$<module>ts")(entryPath));
|
|
74
|
-
};
|
|
75
|
-
const firstDeclarationsAmong = Effect.fn("firstDeclarationsAmong")(function* firstDeclarations(directory, entryPaths) {
|
|
76
|
-
const files = yield* RepositoryFiles;
|
|
77
|
-
const candidates = Array.getSomes(pipe(entryPaths, Array.map((entryPath) => declarationsCandidateFor(entryPath))));
|
|
78
|
-
const existing = yield* Effect.filter(pipe(candidates, Array.map((candidate) => files.join(directory, candidate))), (candidate) => files.exists(candidate));
|
|
79
|
-
return yield* Option.match(Array.head(existing), {
|
|
80
|
-
onNone: () => Effect.succeedNone,
|
|
81
|
-
onSome: (candidate) => files.realPath(candidate).pipe(Effect.asSome)
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
const importNameOf = (packageName) => {
|
|
85
|
-
if (!String$1.startsWith(TYPES_SCOPE)(packageName)) return packageName;
|
|
86
|
-
const unscoped = String$1.slice(7)(packageName);
|
|
87
|
-
if (!String$1.includes(TYPES_SCOPE_SEPARATOR)(unscoped)) return unscoped;
|
|
88
|
-
return `@${String$1.replace(TYPES_SCOPE_SEPARATOR, "/")(unscoped)}`;
|
|
89
|
-
};
|
|
90
|
-
const specifierFor = (packageName, subpath) => {
|
|
91
|
-
const importName = importNameOf(packageName);
|
|
92
|
-
if (subpath === ROOT_SUBPATH$1) return importName;
|
|
93
|
-
return `${importName}/${String$1.slice(2)(subpath)}`;
|
|
94
|
-
};
|
|
95
|
-
const rootEntryPaths = (manifest) => Array.getSomes([
|
|
96
|
-
Option.fromUndefinedOr(manifest.types),
|
|
97
|
-
Option.fromUndefinedOr(manifest.typings),
|
|
98
|
-
Option.fromUndefinedOr(manifest.main)
|
|
99
|
-
]);
|
|
100
|
-
const subpathEntriesOf = Effect.fn("subpathEntriesOf")(function* subpathEntriesOf(packageName, directory, manifest) {
|
|
101
|
-
const found = yield* Effect.forEach(subpathTargetsOf(manifest.exports), ({ subpath, target }) => firstDeclarationsAmong(directory, targetPathsOf(target)).pipe(Effect.map(Option.map((declarationsPath) => ({
|
|
102
|
-
packageName,
|
|
103
|
-
specifier: specifierFor(packageName, subpath),
|
|
104
|
-
declarationsPath
|
|
105
|
-
})))));
|
|
106
|
-
return Array.getSomes(found);
|
|
107
|
-
});
|
|
108
|
-
const entriesOfDependency = Effect.fn("entriesOfDependency")(function* entriesOfDependency(packageName, directory) {
|
|
109
|
-
const manifest = yield* readManifest(directory);
|
|
110
|
-
if (Option.isNone(manifest)) return [];
|
|
111
|
-
const subpathEntries = yield* subpathEntriesOf(packageName, directory, manifest.value);
|
|
112
|
-
const rootSpecifier = specifierFor(packageName, ROOT_SUBPATH$1);
|
|
113
|
-
if (pipe(subpathEntries, Array.some((entry) => entry.specifier === rootSpecifier))) return subpathEntries;
|
|
114
|
-
return [...(yield* firstDeclarationsAmong(directory, rootEntryPaths(manifest.value))).pipe(Option.map((declarationsPath) => ({
|
|
115
|
-
packageName,
|
|
116
|
-
specifier: rootSpecifier,
|
|
117
|
-
declarationsPath
|
|
118
|
-
})), Option.toArray), ...subpathEntries];
|
|
119
|
-
});
|
|
120
|
-
const declaredDependencies = (manifest) => pipe(Record.toEntries({
|
|
121
|
-
...manifest.dependencies,
|
|
122
|
-
...manifest.devDependencies,
|
|
123
|
-
...manifest.peerDependencies
|
|
124
|
-
}), Array.filter(([, range]) => !String$1.startsWith(WORKSPACE_PROTOCOL)(range)), Array.map(([packageName]) => packageName));
|
|
125
|
-
const workspaceDependencies = (manifest) => pipe(Record.toEntries({
|
|
126
|
-
...manifest.dependencies,
|
|
127
|
-
...manifest.devDependencies
|
|
128
|
-
}), Array.filter(([, range]) => String$1.startsWith(WORKSPACE_PROTOCOL)(range)), Array.map(([packageName]) => packageName));
|
|
129
|
-
const entryOrder = Order.mapInput(Order.String, (entry) => entry.specifier);
|
|
130
|
-
const dependencyEntries = Effect.fn("dependencyEntries")(function* dependencyEntries(packageDirectory) {
|
|
131
|
-
const files = yield* RepositoryFiles;
|
|
132
|
-
const manifest = yield* readManifest(packageDirectory);
|
|
133
|
-
if (Option.isNone(manifest)) return [];
|
|
134
|
-
const entries = yield* Effect.forEach(declaredDependencies(manifest.value), (packageName) => entriesOfDependency(packageName, files.join(packageDirectory, NODE_MODULES, packageName)));
|
|
135
|
-
return Array.sort(Array.dedupeWith(entries.flat(), (left, right) => left.specifier === right.specifier), entryOrder);
|
|
136
|
-
});
|
|
137
|
-
// src/entities/package/model/public-entries.ts
|
|
138
|
-
const SOURCE = /\.[cm]?tsx?$/u;
|
|
139
|
-
const BUILT = /\.(?:d\.)?[cm]?[jt]s$/u;
|
|
140
|
-
const DECLARATION = ".d.";
|
|
141
|
-
const SEPARATOR$3 = "/";
|
|
142
|
-
const ROOT_SUBPATH = ".";
|
|
143
|
-
const BIN_LABEL = "bin";
|
|
144
|
-
const targetsIn = (held) => {
|
|
145
|
-
if (Predicate.isString(held)) return [held];
|
|
146
|
-
if (!Predicate.isObject(held)) return [];
|
|
147
|
-
return pipe(Record.values(held), Array.flatMap(targetsIn));
|
|
148
|
-
};
|
|
149
|
-
const subpathsOf = (exportsField) => {
|
|
150
|
-
if (!Predicate.isObject(exportsField)) return [[ROOT_SUBPATH, exportsField]];
|
|
151
|
-
const entries = Record.toEntries(exportsField);
|
|
152
|
-
if (pipe(entries, Array.some(([key]) => String$1.startsWith(ROOT_SUBPATH)(key)))) return entries;
|
|
153
|
-
return [[ROOT_SUBPATH, exportsField]];
|
|
154
|
-
};
|
|
155
|
-
const binsOf = (manifest) => {
|
|
156
|
-
if (Predicate.isString(manifest.bin)) {
|
|
157
|
-
const name = Option.getOrElse(Option.fromUndefinedOr(manifest.name), () => "");
|
|
158
|
-
return [[`${BIN_LABEL} ${name}`, manifest.bin]];
|
|
159
|
-
}
|
|
160
|
-
if (!Predicate.isObject(manifest.bin)) return [];
|
|
161
|
-
return pipe(Record.toEntries(manifest.bin), Array.map(([name, target]) => [`${BIN_LABEL} ${name}`, target]));
|
|
162
|
-
};
|
|
163
|
-
const baseNameOf = (target) => pipe(String$1.split(target, SEPARATOR$3), Array.last, Option.getOrElse(() => target), String$1.replace(BUILT, ""));
|
|
164
|
-
const sourceOf = ({ join, packEntries }) => (target) => {
|
|
165
|
-
if (SOURCE.test(target) && !String$1.includes(DECLARATION)(target)) return Option.some(join(target));
|
|
166
|
-
const name = baseNameOf(target);
|
|
167
|
-
return pipe(packEntries, Array.findFirst((entry) => entry.name === name), Option.map((entry) => entry.source));
|
|
168
|
-
};
|
|
169
|
-
const publicEntriesOf = (lookup) => pipe([...subpathsOf(lookup.manifest.exports), ...binsOf(lookup.manifest)], Array.flatMap(([label, held]) => pipe(targetsIn(held), Array.map(sourceOf(lookup)), Array.getSomes, Array.map((source) => ({
|
|
170
|
-
label,
|
|
171
|
-
source
|
|
172
|
-
})))), Array.dedupeWith((left, right) => left.label === right.label && left.source === right.source));
|
|
173
|
-
const EntryManifestFields = Schema.Struct({
|
|
174
|
-
name: Schema.optional(Schema.String),
|
|
175
|
-
exports: Schema.optional(Schema.Unknown),
|
|
176
|
-
bin: Schema.optional(Schema.Unknown)
|
|
177
|
-
});
|
|
178
|
-
const EntryManifestJson = Schema.fromJsonString(EntryManifestFields);
|
|
179
|
-
// src/entities/package/model/published.ts
|
|
180
|
-
const CONFIG_FILE$1 = "vite.config.ts";
|
|
181
|
-
const SEPARATOR$2 = "/";
|
|
182
|
-
const READ_CONCURRENCY$2 = 16;
|
|
183
|
-
const SOURCE_EXTENSION = /\.[cm]?tsx?$/u;
|
|
184
|
-
const UNIT_BYTES = [
|
|
185
|
-
["B", 1],
|
|
186
|
-
["kB", 1e3],
|
|
187
|
-
["MB", 1e6]
|
|
188
|
-
];
|
|
189
|
-
const SizeText = Schema.TemplateLiteralParser([
|
|
190
|
-
Schema.Finite,
|
|
191
|
-
" ",
|
|
192
|
-
Schema.Literals([
|
|
193
|
-
"B",
|
|
194
|
-
"kB",
|
|
195
|
-
"MB"
|
|
196
|
-
])
|
|
197
|
-
]);
|
|
198
|
-
const PackEntry = Schema.Union([
|
|
199
|
-
Schema.String,
|
|
200
|
-
Schema.Array(Schema.String),
|
|
201
|
-
Schema.Record(Schema.String, Schema.String)
|
|
202
|
-
]);
|
|
203
|
-
const PackSettings = Schema.Struct({ entry: Schema.optional(PackEntry) });
|
|
204
|
-
const PackList = Schema.Union([PackSettings, Schema.Array(PackSettings)]);
|
|
205
|
-
const isEntryList = Schema.is(Schema.Array(Schema.String));
|
|
206
|
-
const WorkspaceConfig = Schema.Struct({
|
|
207
|
-
msch: Schema.Struct({ publish: Schema.Struct({ installSize: SizeText }) }),
|
|
208
|
-
pack: Schema.optional(PackList)
|
|
209
|
-
});
|
|
210
|
-
const PublicManifest = Schema.Struct({ private: Schema.optional(Schema.Literal(false)) });
|
|
211
|
-
const taggedError$1 = Schema.TaggedError;
|
|
212
|
-
var WorkspaceConfigUnreadable = class extends taggedError$1()("WorkspaceConfigUnreadable", { file: Schema.String }) {};
|
|
213
|
-
const bytesPer = (unit) => pipe(UNIT_BYTES, Array.findFirst(([name]) => name === unit), Option.map(([, bytes]) => bytes), Option.getOrElse(() => NaN));
|
|
214
|
-
const nameOf = (source) => pipe(String$1.split(source, SEPARATOR$2), Array.last, Option.getOrElse(() => source), String$1.replace(SOURCE_EXTENSION, ""));
|
|
215
|
-
const entriesOf = (entry) => {
|
|
216
|
-
if (Predicate.isString(entry)) return [{
|
|
217
|
-
name: nameOf(entry),
|
|
218
|
-
source: entry
|
|
219
|
-
}];
|
|
220
|
-
if (isEntryList(entry)) return pipe(entry, Array.map((source) => ({
|
|
221
|
-
name: nameOf(source),
|
|
222
|
-
source
|
|
223
|
-
})));
|
|
224
|
-
return pipe(Record.toEntries(entry), Array.map(([name, source]) => ({
|
|
225
|
-
name,
|
|
226
|
-
source
|
|
227
|
-
})));
|
|
228
|
-
};
|
|
229
|
-
const packEntriesOf = (pack) => pipe(Option.fromUndefinedOr(pack), Option.map(Array.ensure), Option.getOrElse(() => []), Array.flatMap((setting) => pipe(Option.fromUndefinedOr(setting.entry), Option.match({
|
|
230
|
-
onNone: () => [],
|
|
231
|
-
onSome: entriesOf
|
|
232
|
-
}))));
|
|
233
|
-
const settingsIn = Effect.fn("settingsIn")(function* settingsIn(file) {
|
|
234
|
-
const config = yield* Effect.tryPromise({
|
|
235
|
-
try: () => resolveConfigFromFile(file),
|
|
236
|
-
catch: () => WorkspaceConfigUnreadable.make({ file })
|
|
237
|
-
}).pipe(Effect.option);
|
|
238
|
-
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(WorkspaceConfig)));
|
|
239
|
-
});
|
|
240
|
-
const isPublicPackage = Effect.fn("isPublicPackage")(function* isPublicPackage(directory) {
|
|
241
|
-
const files = yield* RepositoryFiles;
|
|
242
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
|
|
243
|
-
return Option.exists(text, (found) => Option.isSome(Schema.decodeOption(Schema.fromJsonString(PublicManifest))(found)));
|
|
244
|
-
});
|
|
245
|
-
const workspaceOf = (directory, configFile, join) => ({ msch, pack }) => {
|
|
246
|
-
const [amount, , unit] = msch.publish.installSize;
|
|
247
|
-
return {
|
|
248
|
-
directory,
|
|
249
|
-
configFile,
|
|
250
|
-
installSize: `${amount} ${unit}`,
|
|
251
|
-
installBudget: amount * bytesPer(unit),
|
|
252
|
-
packEntries: pipe(packEntriesOf(pack), Array.map((entry) => ({
|
|
253
|
-
name: entry.name,
|
|
254
|
-
source: join(entry.source)
|
|
255
|
-
})))
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
const publishedIn = Effect.fn("publishedIn")(function* publishedIn(root, configName) {
|
|
259
|
-
const files = yield* RepositoryFiles;
|
|
260
|
-
const configFile = files.join(root, configName);
|
|
261
|
-
const directory = files.dirname(configFile);
|
|
262
|
-
if (!(yield* isPublicPackage(directory))) return Option.none();
|
|
263
|
-
const settings = yield* settingsIn(configFile);
|
|
264
|
-
return pipe(settings, Option.map(workspaceOf(directory, configFile, (source) => files.join(directory, source))));
|
|
265
|
-
});
|
|
266
|
-
/** @internal */
|
|
267
|
-
const publishedWorkspaces = Effect.fn("publishedWorkspaces")(function* publishedWorkspaces(root) {
|
|
268
|
-
const files = yield* RepositoryFiles;
|
|
269
|
-
const names = yield* files.listedFiles(root);
|
|
270
|
-
const configs = pipe(names, Array.filter((name) => files.basename(name) === CONFIG_FILE$1 && String$1.includes(SEPARATOR$2)(name)));
|
|
271
|
-
const found = yield* Effect.forEach(configs, (name) => publishedIn(root, name), { concurrency: READ_CONCURRENCY$2 });
|
|
272
|
-
return Array.getSomes(found);
|
|
273
|
-
});
|
|
4
|
+
import { readWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-reader";
|
|
5
|
+
import { findWorkspaceProjectsNoCheck } from "@pnpm/workspace.projects-reader";
|
|
6
|
+
import { readWantedLockfile } from "@pnpm/lockfile.fs";
|
|
274
7
|
// src/entities/workspace/model/config-literal.ts
|
|
275
8
|
const WRAPPERS = [
|
|
276
9
|
"TSAsExpression",
|
|
@@ -376,9 +109,9 @@ const stringsIn = (node) => {
|
|
|
376
109
|
};
|
|
377
110
|
// src/entities/workspace/model/workspace-config-source.ts
|
|
378
111
|
const SINGLE = 1;
|
|
379
|
-
const CONFIG_FILE = "vite.config.ts";
|
|
380
|
-
const taggedError = Schema.TaggedError;
|
|
381
|
-
var WorkspaceSettingsInvalid = class extends taggedError()("WorkspaceSettingsInvalid", {
|
|
112
|
+
const CONFIG_FILE$1 = "vite.config.ts";
|
|
113
|
+
const taggedError$3 = Schema.TaggedError;
|
|
114
|
+
var WorkspaceSettingsInvalid = class extends taggedError$3()("WorkspaceSettingsInvalid", {
|
|
382
115
|
file: Schema.String,
|
|
383
116
|
message: Schema.String
|
|
384
117
|
}) {};
|
|
@@ -413,7 +146,7 @@ const programOf = Effect.fn("programOf")(function* programOf(file, text) {
|
|
|
413
146
|
});
|
|
414
147
|
const workspaceConfigOf = Effect.fn("workspaceConfigOf")(function* workspaceConfigOf(root, directory) {
|
|
415
148
|
const files = yield* RepositoryFiles;
|
|
416
|
-
const file = files.join(root, directory, CONFIG_FILE);
|
|
149
|
+
const file = files.join(root, directory, CONFIG_FILE$1);
|
|
417
150
|
const text = yield* files.readFile(file);
|
|
418
151
|
if (Option.isNone(text)) return Option.none();
|
|
419
152
|
const program = yield* programOf(file, text.value);
|
|
@@ -464,105 +197,401 @@ const runTasksOf = Effect.fn("runTasksOf")(function* runTasksOf(root, directory)
|
|
|
464
197
|
tasks: tasksIn(program)
|
|
465
198
|
})));
|
|
466
199
|
});
|
|
467
|
-
// src/entities/workspace/model/workspace-
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
200
|
+
// src/entities/workspace/model/workspace-unreadable.ts
|
|
201
|
+
const taggedError$2 = Schema.TaggedError;
|
|
202
|
+
var WorkspaceUnreadable = class extends taggedError$2()("WorkspaceUnreadable", {
|
|
203
|
+
root: Schema.String,
|
|
204
|
+
reason: Schema.String
|
|
205
|
+
}) {};
|
|
206
|
+
// src/entities/workspace/model/workspace-manifest.ts
|
|
207
|
+
/** @internal */
|
|
208
|
+
const workspaceManifest = (root) => Effect.tryPromise({
|
|
209
|
+
try: () => readWorkspaceManifest(root),
|
|
210
|
+
catch: (cause) => WorkspaceUnreadable.make({
|
|
211
|
+
root,
|
|
212
|
+
reason: String(cause)
|
|
213
|
+
})
|
|
214
|
+
}).pipe(Effect.map(Option.fromUndefinedOr), Effect.orElseSucceed(() => Option.none()));
|
|
215
|
+
// src/entities/workspace/model/workspace-projects.ts
|
|
216
|
+
const byDirectory = Order.mapInput(String$1.Order, ({ directory }) => directory);
|
|
217
|
+
const projectsMatching = (root, patterns) => Effect.tryPromise({
|
|
218
|
+
try: () => findWorkspaceProjectsNoCheck(root, { patterns: [...patterns] }),
|
|
219
|
+
catch: (cause) => WorkspaceUnreadable.make({
|
|
220
|
+
root,
|
|
221
|
+
reason: String(cause)
|
|
222
|
+
})
|
|
223
|
+
}).pipe(Effect.orElseSucceed(() => []));
|
|
224
|
+
/** @internal */
|
|
225
|
+
const workspaceProjects = Effect.fn("workspaceProjects")(function* workspaceProjects(root) {
|
|
226
|
+
const files = yield* RepositoryFiles;
|
|
227
|
+
const manifest = yield* workspaceManifest(root);
|
|
228
|
+
const patterns = pipe(manifest, Option.flatMap(({ packages }) => Option.fromNullishOr(packages)), Option.getOrElse(() => []));
|
|
229
|
+
if (!Array.isReadonlyArrayNonEmpty(patterns)) return [];
|
|
230
|
+
const projects = yield* projectsMatching(root, patterns);
|
|
231
|
+
const found = pipe(projects, Array.map(({ rootDir, manifest: own }) => ({
|
|
232
|
+
directory: files.relative(root, rootDir),
|
|
233
|
+
packageName: Option.fromUndefinedOr(own.name),
|
|
234
|
+
published: own.private !== true,
|
|
235
|
+
keywords: Option.getOrElse(Option.fromUndefinedOr(own.keywords), () => []),
|
|
236
|
+
files: Option.fromUndefinedOr(own.files)
|
|
237
|
+
})), Array.filter(({ directory }) => String$1.isNonEmpty(directory)));
|
|
238
|
+
return Array.sort(found, byDirectory);
|
|
239
|
+
});
|
|
240
|
+
/** @internal */
|
|
241
|
+
const workspaceDirectories = Effect.fn("workspaceDirectories")(function* workspaceDirectories(root) {
|
|
242
|
+
const projects = yield* workspaceProjects(root);
|
|
243
|
+
return pipe(projects, Array.map(({ directory }) => directory));
|
|
244
|
+
});
|
|
245
|
+
// src/entities/workspace/model/workspace-patterns.ts
|
|
246
|
+
const SEPARATOR$2 = "/";
|
|
247
|
+
const NEGATION = "!";
|
|
248
|
+
const RELATIVE = "./";
|
|
249
|
+
const withoutRelative = (target) => {
|
|
250
|
+
if (String$1.startsWith(RELATIVE)(target)) return String$1.slice(2)(target);
|
|
251
|
+
return target;
|
|
252
|
+
};
|
|
253
|
+
const prefixed = (directory) => (pattern) => {
|
|
254
|
+
if (String$1.startsWith(NEGATION)(pattern)) return `${NEGATION}${directory}${SEPARATOR$2}${String$1.slice(1)(pattern)}`;
|
|
255
|
+
return `${directory}${SEPARATOR$2}${withoutRelative(pattern)}`;
|
|
256
|
+
};
|
|
257
|
+
// src/entities/workspace/model/workspace-names.ts
|
|
258
|
+
const ALTERNATIVE = "|";
|
|
259
|
+
const SCOPE = /^@[^/]+\//u;
|
|
260
|
+
const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
|
|
261
|
+
/** @internal */
|
|
262
|
+
const patternOf = (names) => {
|
|
263
|
+
const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
|
|
264
|
+
return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
|
|
265
|
+
};
|
|
266
|
+
const namedIn = (basename) => ({ directory, packageName }) => {
|
|
267
|
+
const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
|
|
268
|
+
return {
|
|
269
|
+
directory,
|
|
270
|
+
names: pipe([
|
|
271
|
+
Option.some(directory),
|
|
272
|
+
Option.some(basename(directory)),
|
|
273
|
+
packageName,
|
|
274
|
+
unscoped
|
|
275
|
+
], Array.getSomes, Array.dedupe),
|
|
276
|
+
packageName
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/** @internal */
|
|
280
|
+
const namedWorkspaces = Effect.fn("namedWorkspaces")(function* namedWorkspaces(root) {
|
|
281
|
+
const files = yield* RepositoryFiles;
|
|
282
|
+
const projects = yield* workspaceProjects(root);
|
|
283
|
+
return pipe(projects, Array.map(namedIn((directory) => files.basename(directory))));
|
|
284
|
+
});
|
|
285
|
+
// src/entities/workspace/model/deploy-entries.ts
|
|
286
|
+
const MAIN_KEY = "main";
|
|
287
|
+
const READ_CONCURRENCY$1 = 16;
|
|
288
|
+
const SCRIPT = /\.[cm]?tsx?$/u;
|
|
289
|
+
const SKIPPED = /\.test\.|\.d\.[cm]?ts$/u;
|
|
290
|
+
const ALCHEMY_IMPORT = /from\s+["'](?:alchemy|@alchemy\.run)(?:\/[^"']*)?["']/u;
|
|
291
|
+
const MAIN_PROPERTY = /\bmain\s*:/u;
|
|
292
|
+
const decodeKey = Schema.decodeUnknownOption(KeySchema);
|
|
293
|
+
const isMainProperty = (node) => node["type"] === "Property" && pipe(decodeKey(node["key"]), Option.exists((key) => keyName(key) === MAIN_KEY));
|
|
294
|
+
const mainTargetsIn = (node) => {
|
|
295
|
+
if (Predicate.isReadonlyObject(node) && isMainProperty(node)) return pipe(stringsIn(node["value"]), Array.head, Option.map(({ text }) => text), Option.toArray);
|
|
296
|
+
return pipe(childrenOf(node), Array.flatMap(mainTargetsIn));
|
|
297
|
+
};
|
|
298
|
+
const declaredIn = Effect.fn("declaredIn")(function* declaredIn(root, file) {
|
|
299
|
+
const files = yield* RepositoryFiles;
|
|
300
|
+
const text = yield* files.readFile(files.join(root, file));
|
|
301
|
+
if (Option.isNone(text) || !ALCHEMY_IMPORT.test(text.value) || !MAIN_PROPERTY.test(text.value)) return [];
|
|
302
|
+
const parsed = yield* Effect.promise(() => parse(file, text.value, { lang: "ts" }));
|
|
303
|
+
return pipe(mainTargetsIn(parsed.program), Array.map((target) => files.join(files.dirname(file), target)));
|
|
304
|
+
});
|
|
305
|
+
const deployEntries = Effect.fn("deployEntries")(function* deployEntries(root) {
|
|
306
|
+
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
307
|
+
const declaring = pipe(listed, Array.filter((file) => SCRIPT.test(file) && !SKIPPED.test(file)));
|
|
308
|
+
const found = yield* Effect.forEach(declaring, (file) => declaredIn(root, file), { concurrency: READ_CONCURRENCY$1 });
|
|
309
|
+
return pipe(Array.flatten(found), Array.filter((file) => Array.contains(listed, file)), Array.dedupe);
|
|
310
|
+
});
|
|
311
|
+
// src/entities/workspace/model/lockfile-unreadable.ts
|
|
312
|
+
const taggedError$1 = Schema.TaggedError;
|
|
313
|
+
var LockfileUnreadable = class extends taggedError$1()("LockfileUnreadable", {
|
|
314
|
+
root: Schema.String,
|
|
315
|
+
reason: Schema.String
|
|
316
|
+
}) {};
|
|
317
|
+
// src/entities/workspace/model/locked-packages.ts
|
|
318
|
+
/** @internal */
|
|
319
|
+
const lockedPackages = (root) => Effect.tryPromise({
|
|
320
|
+
try: () => readWantedLockfile(root, { ignoreIncompatible: false }),
|
|
321
|
+
catch: (cause) => LockfileUnreadable.make({
|
|
322
|
+
root,
|
|
323
|
+
reason: String(cause)
|
|
324
|
+
})
|
|
325
|
+
}).pipe(Effect.map((lockfile) => pipe(Option.fromNullishOr(lockfile), Option.flatMap(({ packages }) => Option.fromUndefinedOr(packages)), Option.map(Record.keys))));
|
|
326
|
+
// src/entities/package/model/dependencies.ts
|
|
327
|
+
const DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));
|
|
328
|
+
const PackageManifest = Schema.Struct({
|
|
329
|
+
name: Schema.optional(Schema.String),
|
|
330
|
+
dependencies: DependencyMap,
|
|
331
|
+
devDependencies: DependencyMap,
|
|
332
|
+
peerDependencies: DependencyMap,
|
|
333
|
+
exports: Schema.optional(Schema.Unknown),
|
|
334
|
+
types: Schema.optional(Schema.String),
|
|
335
|
+
typings: Schema.optional(Schema.String),
|
|
336
|
+
main: Schema.optional(Schema.String)
|
|
337
|
+
});
|
|
338
|
+
const MANIFEST_FILE = "package.json";
|
|
339
|
+
const WORKSPACE_PROTOCOL = "workspace:";
|
|
340
|
+
const ROOT_SUBPATH$1 = ".";
|
|
341
|
+
const SUBPATH_PREFIX = "./";
|
|
342
|
+
const WILDCARD = "*";
|
|
343
|
+
const TYPES_CONDITION = "types";
|
|
344
|
+
const TYPES_SCOPE = "@types/";
|
|
345
|
+
const TYPES_SCOPE_SEPARATOR = "__";
|
|
346
|
+
const CONDITION_DEPTH_LIMIT = 8;
|
|
347
|
+
const ROOT_DEPTH = 0;
|
|
348
|
+
const DEPTH_STEP = 1;
|
|
349
|
+
const DECLARATIONS_SUFFIX = /\.d\.[cm]?ts$|\.[cm]?tsx?$/u;
|
|
350
|
+
const SCRIPT_SUFFIX = /\.(?<module>[cm]?)js$/u;
|
|
351
|
+
const readManifest = Effect.fn("readManifest")(function* readManifest(directory) {
|
|
352
|
+
const files = yield* RepositoryFiles;
|
|
353
|
+
const manifestText = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
354
|
+
const text = yield* Effect.fromOption(manifestText);
|
|
355
|
+
return yield* Schema.decodeEffect(Schema.fromJsonString(PackageManifest))(text);
|
|
356
|
+
}, Effect.option);
|
|
357
|
+
const conditionsOf = (held) => {
|
|
358
|
+
if (!Predicate.isObject(held)) return [];
|
|
359
|
+
return Record.toEntries(held);
|
|
360
|
+
};
|
|
361
|
+
const typesConditionIn = (held, depth) => {
|
|
362
|
+
if (depth > CONDITION_DEPTH_LIMIT) return Option.none();
|
|
363
|
+
const entries = conditionsOf(held);
|
|
364
|
+
const declared = Array.findFirst(entries, ([condition, target]) => Option.liftPredicate(target, (candidate) => condition === TYPES_CONDITION && Predicate.isString(candidate))).pipe(Option.filter(Predicate.isString));
|
|
365
|
+
return Option.orElse(declared, () => Array.findFirst(entries, ([, nested]) => typesConditionIn(nested, depth + DEPTH_STEP)));
|
|
366
|
+
};
|
|
367
|
+
const anyConditionIn = (held, depth) => {
|
|
368
|
+
if (Predicate.isString(held)) return Option.some(held);
|
|
369
|
+
if (depth > CONDITION_DEPTH_LIMIT) return Option.none();
|
|
370
|
+
return Array.findFirst(conditionsOf(held), ([, nested]) => anyConditionIn(nested, depth + DEPTH_STEP));
|
|
371
|
+
};
|
|
372
|
+
const targetPathsOf = (target) => Array.getSomes([typesConditionIn(target, ROOT_DEPTH), anyConditionIn(target, ROOT_DEPTH)]);
|
|
373
|
+
const subpathTargetsOf = (exportsField) => {
|
|
374
|
+
if (Predicate.isString(exportsField)) return [{
|
|
375
|
+
subpath: ROOT_SUBPATH$1,
|
|
376
|
+
target: exportsField
|
|
377
|
+
}];
|
|
378
|
+
const entries = conditionsOf(exportsField);
|
|
379
|
+
if (!pipe(entries, Array.some(([subpath]) => String$1.startsWith(ROOT_SUBPATH$1)(subpath)))) return Array.match(entries, {
|
|
380
|
+
onEmpty: () => [],
|
|
381
|
+
onNonEmpty: () => [{
|
|
382
|
+
subpath: ROOT_SUBPATH$1,
|
|
383
|
+
target: exportsField
|
|
384
|
+
}]
|
|
385
|
+
});
|
|
386
|
+
return pipe(entries, Array.filter(([subpath]) => subpath === ROOT_SUBPATH$1 || String$1.startsWith(SUBPATH_PREFIX)(subpath)), Array.filter(([subpath]) => !String$1.includes(WILDCARD)(subpath)), Array.map(([subpath, target]) => ({
|
|
387
|
+
subpath,
|
|
388
|
+
target
|
|
389
|
+
})));
|
|
390
|
+
};
|
|
391
|
+
const declarationsCandidateFor = (entryPath) => {
|
|
392
|
+
if (DECLARATIONS_SUFFIX.test(entryPath)) return Option.some(entryPath);
|
|
393
|
+
if (!SCRIPT_SUFFIX.test(entryPath)) return Option.none();
|
|
394
|
+
return Option.some(String$1.replace(SCRIPT_SUFFIX, ".d.$<module>ts")(entryPath));
|
|
395
|
+
};
|
|
396
|
+
const firstDeclarationsAmong = Effect.fn("firstDeclarationsAmong")(function* firstDeclarations(directory, entryPaths) {
|
|
397
|
+
const files = yield* RepositoryFiles;
|
|
398
|
+
const candidates = Array.getSomes(pipe(entryPaths, Array.map((entryPath) => declarationsCandidateFor(entryPath))));
|
|
399
|
+
const existing = yield* Effect.filter(pipe(candidates, Array.map((candidate) => files.join(directory, candidate))), (candidate) => files.exists(candidate));
|
|
400
|
+
return yield* Option.match(Array.head(existing), {
|
|
401
|
+
onNone: () => Effect.succeedNone,
|
|
402
|
+
onSome: (candidate) => files.realPath(candidate).pipe(Effect.asSome)
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
const importNameOf = (packageName) => {
|
|
406
|
+
if (!String$1.startsWith(TYPES_SCOPE)(packageName)) return packageName;
|
|
407
|
+
const unscoped = String$1.slice(7)(packageName);
|
|
408
|
+
if (!String$1.includes(TYPES_SCOPE_SEPARATOR)(unscoped)) return unscoped;
|
|
409
|
+
return `@${String$1.replace(TYPES_SCOPE_SEPARATOR, "/")(unscoped)}`;
|
|
476
410
|
};
|
|
477
|
-
const
|
|
478
|
-
const
|
|
479
|
-
|
|
411
|
+
const specifierFor = (packageName, subpath) => {
|
|
412
|
+
const importName = importNameOf(packageName);
|
|
413
|
+
if (subpath === ROOT_SUBPATH$1) return importName;
|
|
414
|
+
return `${importName}/${String$1.slice(2)(subpath)}`;
|
|
480
415
|
};
|
|
481
|
-
|
|
482
|
-
|
|
416
|
+
const rootEntryPaths = (manifest) => Array.getSomes([
|
|
417
|
+
Option.fromUndefinedOr(manifest.types),
|
|
418
|
+
Option.fromUndefinedOr(manifest.typings),
|
|
419
|
+
Option.fromUndefinedOr(manifest.main)
|
|
420
|
+
]);
|
|
421
|
+
const subpathEntriesOf = Effect.fn("subpathEntriesOf")(function* subpathEntriesOf(packageName, directory, manifest) {
|
|
422
|
+
const found = yield* Effect.forEach(subpathTargetsOf(manifest.exports), ({ subpath, target }) => firstDeclarationsAmong(directory, targetPathsOf(target)).pipe(Effect.map(Option.map((declarationsPath) => ({
|
|
423
|
+
packageName,
|
|
424
|
+
specifier: specifierFor(packageName, subpath),
|
|
425
|
+
declarationsPath
|
|
426
|
+
})))), { concurrency: 1 });
|
|
427
|
+
return Array.getSomes(found);
|
|
428
|
+
});
|
|
429
|
+
const entriesOfDependency = Effect.fn("entriesOfDependency")(function* entriesOfDependency(packageName, directory) {
|
|
430
|
+
const manifest = yield* readManifest(directory);
|
|
431
|
+
if (Option.isNone(manifest)) return [];
|
|
432
|
+
const subpathEntries = yield* subpathEntriesOf(packageName, directory, manifest.value);
|
|
433
|
+
const rootSpecifier = specifierFor(packageName, ROOT_SUBPATH$1);
|
|
434
|
+
if (pipe(subpathEntries, Array.some((entry) => entry.specifier === rootSpecifier))) return subpathEntries;
|
|
435
|
+
return [...(yield* firstDeclarationsAmong(directory, rootEntryPaths(manifest.value))).pipe(Option.map((declarationsPath) => ({
|
|
436
|
+
packageName,
|
|
437
|
+
specifier: rootSpecifier,
|
|
438
|
+
declarationsPath
|
|
439
|
+
})), Option.toArray), ...subpathEntries];
|
|
440
|
+
});
|
|
441
|
+
const declaredDependencies = (manifest) => pipe(Record.toEntries({
|
|
442
|
+
...manifest.dependencies,
|
|
443
|
+
...manifest.devDependencies,
|
|
444
|
+
...manifest.peerDependencies
|
|
445
|
+
}), Array.filter(([, range]) => !String$1.startsWith(WORKSPACE_PROTOCOL)(range)), Array.map(([packageName]) => packageName));
|
|
446
|
+
const workspaceDependencies = (manifest) => pipe(Record.toEntries({
|
|
447
|
+
...manifest.dependencies,
|
|
448
|
+
...manifest.devDependencies
|
|
449
|
+
}), Array.filter(([, range]) => String$1.startsWith(WORKSPACE_PROTOCOL)(range)), Array.map(([packageName]) => packageName));
|
|
450
|
+
const entryOrder = Order.mapInput(Order.String, (entry) => entry.specifier);
|
|
451
|
+
const dependencyEntries = Effect.fn("dependencyEntries")(function* dependencyEntries(packageDirectory) {
|
|
483
452
|
const files = yield* RepositoryFiles;
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const directories = pipe(manifests, Array.map((manifest) => files.dirname(manifest)));
|
|
489
|
-
return Array.sort(directories, String$1.Order);
|
|
453
|
+
const manifest = yield* readManifest(packageDirectory);
|
|
454
|
+
if (Option.isNone(manifest)) return [];
|
|
455
|
+
const entries = yield* Effect.forEach(declaredDependencies(manifest.value), (packageName) => entriesOfDependency(packageName, files.join(packageDirectory, NODE_MODULES, packageName)), { concurrency: 1 });
|
|
456
|
+
return Array.sort(Array.dedupeWith(entries.flat(), (left, right) => left.specifier === right.specifier), entryOrder);
|
|
490
457
|
});
|
|
491
|
-
// src/entities/
|
|
458
|
+
// src/entities/package/model/public-entries.ts
|
|
459
|
+
const SOURCE = /\.[cm]?tsx?$/u;
|
|
460
|
+
const BUILT = /\.(?:d\.)?[cm]?[jt]s$/u;
|
|
461
|
+
const DECLARATION = ".d.";
|
|
492
462
|
const SEPARATOR$1 = "/";
|
|
493
|
-
const
|
|
494
|
-
const
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
497
|
-
return
|
|
463
|
+
const ROOT_SUBPATH = ".";
|
|
464
|
+
const BIN_LABEL = "bin";
|
|
465
|
+
const targetsIn = (held) => {
|
|
466
|
+
if (Predicate.isString(held)) return [held];
|
|
467
|
+
if (!Predicate.isObject(held)) return [];
|
|
468
|
+
return pipe(Record.values(held), Array.flatMap(targetsIn));
|
|
498
469
|
};
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
|
|
470
|
+
const subpathsOf = (exportsField) => {
|
|
471
|
+
if (!Predicate.isObject(exportsField)) return [[ROOT_SUBPATH, exportsField]];
|
|
472
|
+
const entries = Record.toEntries(exportsField);
|
|
473
|
+
if (pipe(entries, Array.some(([key]) => String$1.startsWith(ROOT_SUBPATH)(key)))) return entries;
|
|
474
|
+
return [[ROOT_SUBPATH, exportsField]];
|
|
502
475
|
};
|
|
503
|
-
|
|
476
|
+
const binsOf = (manifest) => {
|
|
477
|
+
if (Predicate.isString(manifest.bin)) {
|
|
478
|
+
const name = Option.getOrElse(Option.fromUndefinedOr(manifest.name), () => "");
|
|
479
|
+
return [[`${BIN_LABEL} ${name}`, manifest.bin]];
|
|
480
|
+
}
|
|
481
|
+
if (!Predicate.isObject(manifest.bin)) return [];
|
|
482
|
+
return pipe(Record.toEntries(manifest.bin), Array.map(([name, target]) => [`${BIN_LABEL} ${name}`, target]));
|
|
483
|
+
};
|
|
484
|
+
const baseNameOf = (target) => pipe(String$1.split(target, SEPARATOR$1), Array.last, Option.getOrElse(() => target), String$1.replace(BUILT, ""));
|
|
485
|
+
const sourceOf = ({ join, packEntries }) => (target) => {
|
|
486
|
+
if (SOURCE.test(target) && !String$1.includes(DECLARATION)(target)) return Option.some(join(target));
|
|
487
|
+
const name = baseNameOf(target);
|
|
488
|
+
return pipe(packEntries, Array.findFirst((entry) => entry.name === name), Option.map((entry) => entry.source));
|
|
489
|
+
};
|
|
490
|
+
const publicEntriesOf = (lookup) => pipe([...subpathsOf(lookup.manifest.exports), ...binsOf(lookup.manifest)], Array.flatMap(([label, held]) => pipe(targetsIn(held), Array.map(sourceOf(lookup)), Array.getSomes, Array.map((source) => ({
|
|
491
|
+
label,
|
|
492
|
+
source
|
|
493
|
+
})))), Array.dedupeWith((left, right) => left.label === right.label && left.source === right.source));
|
|
494
|
+
const EntryManifestFields = Schema.Struct({
|
|
495
|
+
name: Schema.optional(Schema.String),
|
|
496
|
+
exports: Schema.optional(Schema.Unknown),
|
|
497
|
+
bin: Schema.optional(Schema.Unknown)
|
|
498
|
+
});
|
|
499
|
+
const EntryManifestJson = Schema.fromJsonString(EntryManifestFields);
|
|
500
|
+
// src/entities/package/model/published.ts
|
|
501
|
+
const CONFIG_FILE = "vite.config.ts";
|
|
504
502
|
const SEPARATOR = "/";
|
|
505
|
-
const
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
503
|
+
const READ_CONCURRENCY = 16;
|
|
504
|
+
const SOURCE_EXTENSION = /\.[cm]?tsx?$/u;
|
|
505
|
+
const UNIT_BYTES = [
|
|
506
|
+
["B", 1],
|
|
507
|
+
["kB", 1e3],
|
|
508
|
+
["MB", 1e6]
|
|
509
|
+
];
|
|
510
|
+
const SizeText = Schema.TemplateLiteralParser([
|
|
511
|
+
Schema.Finite,
|
|
512
|
+
" ",
|
|
513
|
+
Schema.Literals([
|
|
514
|
+
"B",
|
|
515
|
+
"kB",
|
|
516
|
+
"MB"
|
|
517
|
+
])
|
|
518
|
+
]);
|
|
519
|
+
const PackEntry = Schema.Union([
|
|
520
|
+
Schema.String,
|
|
521
|
+
Schema.Array(Schema.String),
|
|
522
|
+
Schema.Record(Schema.String, Schema.String)
|
|
523
|
+
]);
|
|
524
|
+
const PackSettings = Schema.Struct({ entry: Schema.optional(PackEntry) });
|
|
525
|
+
const PackList = Schema.Union([PackSettings, Schema.Array(PackSettings)]);
|
|
526
|
+
const isEntryList = Schema.is(Schema.Array(Schema.String));
|
|
527
|
+
const WorkspaceConfig = Schema.Struct({
|
|
528
|
+
msch: Schema.Struct({ publish: Schema.Struct({ installSize: SizeText }) }),
|
|
529
|
+
pack: Schema.optional(PackList)
|
|
530
|
+
});
|
|
531
|
+
const PublicManifest = Schema.Struct({ private: Schema.optional(Schema.Literal(false)) });
|
|
532
|
+
const taggedError = Schema.TaggedError;
|
|
533
|
+
var WorkspaceConfigUnreadable = class extends taggedError()("WorkspaceConfigUnreadable", { file: Schema.String }) {};
|
|
534
|
+
const bytesPer = (unit) => pipe(UNIT_BYTES, Array.findFirst(([name]) => name === unit), Option.map(([, bytes]) => bytes), Option.getOrElse(() => NaN));
|
|
535
|
+
const nameOf = (source) => pipe(String$1.split(source, SEPARATOR), Array.last, Option.getOrElse(() => source), String$1.replace(SOURCE_EXTENSION, ""));
|
|
536
|
+
const entriesOf = (entry) => {
|
|
537
|
+
if (Predicate.isString(entry)) return [{
|
|
538
|
+
name: nameOf(entry),
|
|
539
|
+
source: entry
|
|
540
|
+
}];
|
|
541
|
+
if (isEntryList(entry)) return pipe(entry, Array.map((source) => ({
|
|
542
|
+
name: nameOf(source),
|
|
543
|
+
source
|
|
544
|
+
})));
|
|
545
|
+
return pipe(Record.toEntries(entry), Array.map(([name, source]) => ({
|
|
546
|
+
name,
|
|
547
|
+
source
|
|
548
|
+
})));
|
|
514
549
|
};
|
|
515
|
-
const
|
|
516
|
-
|
|
550
|
+
const packEntriesOf = (pack) => pipe(Option.fromUndefinedOr(pack), Option.map(Array.ensure), Option.getOrElse(() => []), Array.flatMap((setting) => pipe(Option.fromUndefinedOr(setting.entry), Option.match({
|
|
551
|
+
onNone: () => [],
|
|
552
|
+
onSome: entriesOf
|
|
553
|
+
}))));
|
|
554
|
+
const settingsIn = Effect.fn("settingsIn")(function* settingsIn(file) {
|
|
555
|
+
const config = yield* Effect.tryPromise({
|
|
556
|
+
try: () => resolveConfigFromFile(file),
|
|
557
|
+
catch: () => WorkspaceConfigUnreadable.make({ file })
|
|
558
|
+
}).pipe(Effect.option);
|
|
559
|
+
return pipe(config, Option.flatMap(Schema.decodeUnknownOption(WorkspaceConfig)));
|
|
560
|
+
});
|
|
561
|
+
const isPublicPackage = Effect.fn("isPublicPackage")(function* isPublicPackage(directory) {
|
|
517
562
|
const files = yield* RepositoryFiles;
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
563
|
+
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
564
|
+
return Option.exists(text, (found) => Option.isSome(Schema.decodeOption(Schema.fromJsonString(PublicManifest))(found)));
|
|
565
|
+
});
|
|
566
|
+
const workspaceOf = (directory, configFile, join) => ({ msch, pack }) => {
|
|
567
|
+
const [amount, , unit] = msch.publish.installSize;
|
|
522
568
|
return {
|
|
523
569
|
directory,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
570
|
+
configFile,
|
|
571
|
+
installSize: `${amount} ${unit}`,
|
|
572
|
+
installBudget: amount * bytesPer(unit),
|
|
573
|
+
packEntries: pipe(packEntriesOf(pack), Array.map((entry) => ({
|
|
574
|
+
name: entry.name,
|
|
575
|
+
source: join(entry.source)
|
|
576
|
+
})))
|
|
531
577
|
};
|
|
532
|
-
});
|
|
533
|
-
/** @internal */
|
|
534
|
-
const namedWorkspaces = Effect.fn("namedWorkspaces")(function* namedWorkspaces(root) {
|
|
535
|
-
const files = yield* RepositoryFiles;
|
|
536
|
-
const listed = yield* files.listedFiles(root);
|
|
537
|
-
const manifests = pipe(listed, Array.filter((name) => String$1.includes(SEPARATOR)(name) && files.basename(name) === "package.json"));
|
|
538
|
-
return yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$1 });
|
|
539
|
-
});
|
|
540
|
-
// src/entities/workspace/model/deploy-entries.ts
|
|
541
|
-
const MAIN_KEY = "main";
|
|
542
|
-
const READ_CONCURRENCY = 16;
|
|
543
|
-
const SCRIPT = /\.[cm]?tsx?$/u;
|
|
544
|
-
const SKIPPED = /\.test\.|\.d\.[cm]?ts$/u;
|
|
545
|
-
const ALCHEMY_IMPORT = /from\s+["'](?:alchemy|@alchemy\.run)(?:\/[^"']*)?["']/u;
|
|
546
|
-
const MAIN_PROPERTY = /\bmain\s*:/u;
|
|
547
|
-
const decodeKey = Schema.decodeUnknownOption(KeySchema);
|
|
548
|
-
const isMainProperty = (node) => node["type"] === "Property" && pipe(decodeKey(node["key"]), Option.exists((key) => keyName(key) === MAIN_KEY));
|
|
549
|
-
const mainTargetsIn = (node) => {
|
|
550
|
-
if (Predicate.isReadonlyObject(node) && isMainProperty(node)) return pipe(stringsIn(node["value"]), Array.head, Option.map(({ text }) => text), Option.toArray);
|
|
551
|
-
return pipe(childrenOf(node), Array.flatMap(mainTargetsIn));
|
|
552
578
|
};
|
|
553
|
-
const
|
|
579
|
+
const publishedIn = Effect.fn("publishedIn")(function* publishedIn(root, configName) {
|
|
554
580
|
const files = yield* RepositoryFiles;
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
581
|
+
const configFile = files.join(root, configName);
|
|
582
|
+
const directory = files.dirname(configFile);
|
|
583
|
+
if (!(yield* isPublicPackage(directory))) return Option.none();
|
|
584
|
+
const settings = yield* settingsIn(configFile);
|
|
585
|
+
return pipe(settings, Option.map(workspaceOf(directory, configFile, (source) => files.join(directory, source))));
|
|
559
586
|
});
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
const
|
|
563
|
-
const
|
|
564
|
-
|
|
587
|
+
/** @internal */
|
|
588
|
+
const publishedWorkspaces = Effect.fn("publishedWorkspaces")(function* publishedWorkspaces(root) {
|
|
589
|
+
const files = yield* RepositoryFiles;
|
|
590
|
+
const names = yield* files.listedFiles(root);
|
|
591
|
+
const configs = pipe(names, Array.filter((name) => files.basename(name) === CONFIG_FILE && String$1.includes(SEPARATOR)(name)));
|
|
592
|
+
const found = yield* Effect.forEach(configs, (name) => publishedIn(root, name), { concurrency: READ_CONCURRENCY });
|
|
593
|
+
return Array.getSomes(found);
|
|
565
594
|
});
|
|
566
|
-
export {
|
|
595
|
+
export { usedFrom as A, definesTask as C, merged as D, literalSettings as E, literalOf as F, nestedValues as I, propertyValue as L, KeySchema as M, childrenOf as N, programOf as O, keyName as P, stringsIn as R, VERIFY_TASK as S, tasksOf as T, workspaceProjects as _, publicEntriesOf as a, NO_TASKS as b, readManifest as c, deployEntries as d, namedWorkspaces as f, workspaceDirectories as g, withoutRelative as h, EntryManifestJson as i, workspaceConfigOf as j, settingsInvalid as k, workspaceDependencies as l, prefixed as m, entriesOf as n, MANIFEST_FILE as o, patternOf as p, publishedWorkspaces as r, dependencyEntries as s, PackEntry as t, lockedPackages as u, workspaceManifest as v, hasVerifyTask as w, RUN_TASKS as x, runTasksOf as y };
|
|
567
596
|
|
|
568
|
-
//# sourceMappingURL=
|
|
597
|
+
//# sourceMappingURL=package-DU5r3bvx.mjs.map
|