@savvy-web/silk-effects 0.2.2 → 0.4.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 +120 -60
- package/index.d.ts +425 -241
- package/index.js +638 -204
- package/package.json +4 -4
- package/tsdoc-metadata.json +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Context, Data, Effect, Equal, Function, Hash, Layer, Option, Ref, Schema } from "effect";
|
|
1
|
+
import { Context, Data, Effect, Equal, Function, Hash, Layer, Option, Pretty, Ref, Schema } from "effect";
|
|
2
2
|
import { Command, CommandExecutor, FileSystem } from "@effect/platform";
|
|
3
|
+
import { PackageManagerDetector, PublishConfig, PublishTarget, PublishabilityDetector, PublishabilityDetectorLive, TopologicalSorter, WorkspaceDiscovery, WorkspaceRoot } from "workspaces-effect";
|
|
3
4
|
import { parse } from "jsonc-effect";
|
|
4
|
-
import {
|
|
5
|
+
import { isAbsolute, join } from "node:path";
|
|
5
6
|
class BiomeSyncError extends Data.TaggedError("BiomeSyncError") {
|
|
6
7
|
get message() {
|
|
7
8
|
return `Failed to sync biome schema in ${this.path}: ${this.reason}`;
|
|
@@ -17,11 +18,6 @@ class ConfigNotFoundError extends Data.TaggedError("ConfigNotFoundError") {
|
|
|
17
18
|
return `Config '${this.name}' not found. Searched: ${this.searchedPaths.join(", ")}`;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
class PublishConfigError extends Data.TaggedError("PublishConfigError") {
|
|
21
|
-
get message() {
|
|
22
|
-
return `Invalid publishConfig for ${this.packageName}: ${this.reason}`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
21
|
class SectionParseError extends Data.TaggedError("SectionParseError") {
|
|
26
22
|
get message() {
|
|
27
23
|
return `Failed to parse section in ${this.path}: ${this.reason}`;
|
|
@@ -42,11 +38,6 @@ class TagFormatError extends Data.TaggedError("TagFormatError") {
|
|
|
42
38
|
return `Failed to format tag for ${this.name}@${this.version}: ${this.reason}`;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
class TargetResolutionError extends Data.TaggedError("TargetResolutionError") {
|
|
46
|
-
get message() {
|
|
47
|
-
return `Failed to resolve publish target: ${this.reason}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
41
|
class ToolNotFoundError extends Data.TaggedError("ToolNotFoundError") {
|
|
51
42
|
get message() {
|
|
52
43
|
return `Tool not found: ${this.name} — ${this.reason}`;
|
|
@@ -67,30 +58,11 @@ class VersioningDetectionError extends Data.TaggedError("VersioningDetectionErro
|
|
|
67
58
|
return `Failed to detect versioning strategy: ${this.reason}`;
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
registry: Schema.optional(Schema.String),
|
|
77
|
-
directory: Schema.optional(Schema.String),
|
|
78
|
-
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
79
|
-
provenance: Schema.optional(Schema.Boolean),
|
|
80
|
-
tag: Schema.optional(Schema.String)
|
|
81
|
-
});
|
|
82
|
-
const PublishTargetShorthand = Schema.Literal("npm", "github", "jsr");
|
|
83
|
-
const PublishTarget = Schema.Union(PublishTargetShorthand, Schema.String.pipe(Schema.filter((s)=>s.startsWith("https://"))), PublishTargetObject);
|
|
84
|
-
const ResolvedTarget = Schema.Struct({
|
|
85
|
-
protocol: PublishProtocol,
|
|
86
|
-
registry: Schema.NullOr(Schema.String),
|
|
87
|
-
directory: Schema.String,
|
|
88
|
-
access: Schema.Literal("public", "restricted"),
|
|
89
|
-
provenance: Schema.Boolean,
|
|
90
|
-
tag: Schema.String,
|
|
91
|
-
auth: AuthStrategy,
|
|
92
|
-
tokenEnv: Schema.NullOr(Schema.String)
|
|
93
|
-
});
|
|
61
|
+
class WorkspaceAnalysisError extends Data.TaggedError("WorkspaceAnalysisError") {
|
|
62
|
+
get message() {
|
|
63
|
+
return `Workspace analysis failed at ${this.root}: ${this.reason}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
94
66
|
class ToolCommand {
|
|
95
67
|
command;
|
|
96
68
|
constructor(command){
|
|
@@ -122,9 +94,26 @@ const ToolSource = Schema.Literal("global", "local");
|
|
|
122
94
|
const VersionExtractor = Data.taggedEnum();
|
|
123
95
|
const ResolutionPolicy = Data.taggedEnum();
|
|
124
96
|
const SourceRequirement = Data.taggedEnum();
|
|
125
|
-
|
|
97
|
+
function _to_primitive(input, hint) {
|
|
98
|
+
if ("object" !== _type_of(input) || null === input) return input;
|
|
99
|
+
var prim = input[Symbol.toPrimitive];
|
|
100
|
+
if (void 0 !== prim) {
|
|
101
|
+
var res = prim.call(input, hint || "default");
|
|
102
|
+
if ("object" !== _type_of(res)) return res;
|
|
103
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
104
|
+
}
|
|
105
|
+
return ("string" === hint ? String : Number)(input);
|
|
106
|
+
}
|
|
107
|
+
function _to_property_key(arg) {
|
|
108
|
+
var key = _to_primitive(arg, "string");
|
|
109
|
+
return "symbol" === _type_of(key) ? key : String(key);
|
|
110
|
+
}
|
|
111
|
+
function _type_of(obj) {
|
|
112
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
113
|
+
}
|
|
114
|
+
let _computedKey, _computedKey1;
|
|
126
115
|
const PackageManager = Schema.Literal("npm", "pnpm", "yarn", "bun");
|
|
127
|
-
_computedKey = Equal.symbol, _computedKey1 = Hash.symbol;
|
|
116
|
+
_computedKey = _to_property_key(Equal.symbol), _computedKey1 = _to_property_key(Hash.symbol);
|
|
128
117
|
class ResolvedTool extends Schema.TaggedClass()("ResolvedTool", {
|
|
129
118
|
name: Schema.String,
|
|
130
119
|
source: ToolSource,
|
|
@@ -183,8 +172,25 @@ const CommentStyle = Schema.Literal("#", "//");
|
|
|
183
172
|
const SectionDiff = Data.taggedEnum();
|
|
184
173
|
const SyncResult = Data.taggedEnum();
|
|
185
174
|
const CheckResult = Data.taggedEnum();
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
function SectionBlock_to_primitive(input, hint) {
|
|
176
|
+
if ("object" !== SectionBlock_type_of(input) || null === input) return input;
|
|
177
|
+
var prim = input[Symbol.toPrimitive];
|
|
178
|
+
if (void 0 !== prim) {
|
|
179
|
+
var res = prim.call(input, hint || "default");
|
|
180
|
+
if ("object" !== SectionBlock_type_of(res)) return res;
|
|
181
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
182
|
+
}
|
|
183
|
+
return ("string" === hint ? String : Number)(input);
|
|
184
|
+
}
|
|
185
|
+
function SectionBlock_to_property_key(arg) {
|
|
186
|
+
var key = SectionBlock_to_primitive(arg, "string");
|
|
187
|
+
return "symbol" === SectionBlock_type_of(key) ? key : String(key);
|
|
188
|
+
}
|
|
189
|
+
function SectionBlock_type_of(obj) {
|
|
190
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
191
|
+
}
|
|
192
|
+
let SectionBlock_computedKey, SectionBlock_computedKey1;
|
|
193
|
+
SectionBlock_computedKey = SectionBlock_to_property_key(Equal.symbol), SectionBlock_computedKey1 = SectionBlock_to_property_key(Hash.symbol);
|
|
188
194
|
class SectionBlock extends Schema.TaggedClass()("SectionBlock", {
|
|
189
195
|
toolName: Schema.String,
|
|
190
196
|
commentStyle: CommentStyle,
|
|
@@ -239,8 +245,25 @@ class SectionBlock extends Schema.TaggedClass()("SectionBlock", {
|
|
|
239
245
|
return Hash.cached(this)(Hash.hash(this.normalized));
|
|
240
246
|
}
|
|
241
247
|
}
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
function SectionDefinition_to_primitive(input, hint) {
|
|
249
|
+
if ("object" !== SectionDefinition_type_of(input) || null === input) return input;
|
|
250
|
+
var prim = input[Symbol.toPrimitive];
|
|
251
|
+
if (void 0 !== prim) {
|
|
252
|
+
var res = prim.call(input, hint || "default");
|
|
253
|
+
if ("object" !== SectionDefinition_type_of(res)) return res;
|
|
254
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
255
|
+
}
|
|
256
|
+
return ("string" === hint ? String : Number)(input);
|
|
257
|
+
}
|
|
258
|
+
function SectionDefinition_to_property_key(arg) {
|
|
259
|
+
var key = SectionDefinition_to_primitive(arg, "string");
|
|
260
|
+
return "symbol" === SectionDefinition_type_of(key) ? key : String(key);
|
|
261
|
+
}
|
|
262
|
+
function SectionDefinition_type_of(obj) {
|
|
263
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
264
|
+
}
|
|
265
|
+
let SectionDefinition_computedKey, SectionDefinition_computedKey1;
|
|
266
|
+
SectionDefinition_computedKey = SectionDefinition_to_property_key(Equal.symbol), SectionDefinition_computedKey1 = SectionDefinition_to_property_key(Hash.symbol);
|
|
244
267
|
class SectionDefinition extends Schema.TaggedClass()("SectionDefinition", {
|
|
245
268
|
toolName: Schema.String,
|
|
246
269
|
commentStyle: Schema.optionalWith(CommentStyle, {
|
|
@@ -342,11 +365,28 @@ class ShellSectionDefinition extends Schema.TaggedClass()("ShellSectionDefinitio
|
|
|
342
365
|
return `# --- END ${this.toolName.toUpperCase()} MANAGED SECTION ---`;
|
|
343
366
|
}
|
|
344
367
|
}
|
|
345
|
-
|
|
368
|
+
function ToolDefinition_to_primitive(input, hint) {
|
|
369
|
+
if ("object" !== ToolDefinition_type_of(input) || null === input) return input;
|
|
370
|
+
var prim = input[Symbol.toPrimitive];
|
|
371
|
+
if (void 0 !== prim) {
|
|
372
|
+
var res = prim.call(input, hint || "default");
|
|
373
|
+
if ("object" !== ToolDefinition_type_of(res)) return res;
|
|
374
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
375
|
+
}
|
|
376
|
+
return ("string" === hint ? String : Number)(input);
|
|
377
|
+
}
|
|
378
|
+
function ToolDefinition_to_property_key(arg) {
|
|
379
|
+
var key = ToolDefinition_to_primitive(arg, "string");
|
|
380
|
+
return "symbol" === ToolDefinition_type_of(key) ? key : String(key);
|
|
381
|
+
}
|
|
382
|
+
function ToolDefinition_type_of(obj) {
|
|
383
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
384
|
+
}
|
|
385
|
+
let ToolDefinition_computedKey, ToolDefinition_computedKey1;
|
|
346
386
|
const NameSchema = Schema.Struct({
|
|
347
387
|
name: Schema.String
|
|
348
388
|
});
|
|
349
|
-
ToolDefinition_computedKey = Equal.symbol, ToolDefinition_computedKey1 = Hash.symbol;
|
|
389
|
+
ToolDefinition_computedKey = ToolDefinition_to_property_key(Equal.symbol), ToolDefinition_computedKey1 = ToolDefinition_to_property_key(Hash.symbol);
|
|
350
390
|
class ToolDefinition {
|
|
351
391
|
_tag = "ToolDefinition";
|
|
352
392
|
name;
|
|
@@ -375,6 +415,216 @@ class ToolDefinition {
|
|
|
375
415
|
return Hash.cached(this)(Hash.hash(this.name));
|
|
376
416
|
}
|
|
377
417
|
}
|
|
418
|
+
const TagStrategyType = Schema.Literal("single", "scoped");
|
|
419
|
+
const PrivatePackagesConfig = Schema.Union(Schema.Struct({
|
|
420
|
+
tag: Schema.optional(Schema.Boolean),
|
|
421
|
+
version: Schema.optional(Schema.Boolean)
|
|
422
|
+
}), Schema.Literal(false));
|
|
423
|
+
const SnapshotConfig = Schema.Struct({
|
|
424
|
+
useCalculatedVersion: Schema.optional(Schema.Boolean),
|
|
425
|
+
prereleaseTemplate: Schema.optional(Schema.String)
|
|
426
|
+
});
|
|
427
|
+
const ChangesetConfigFile = Schema.Struct({
|
|
428
|
+
changelog: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.Unknown), Schema.Literal(false))),
|
|
429
|
+
commit: Schema.optional(Schema.Union(Schema.Boolean, Schema.String, Schema.Array(Schema.Unknown))),
|
|
430
|
+
fixed: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
431
|
+
linked: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
432
|
+
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
433
|
+
baseBranch: Schema.optional(Schema.String),
|
|
434
|
+
updateInternalDependencies: Schema.optional(Schema.Literal("patch", "minor", "major")),
|
|
435
|
+
ignore: Schema.optional(Schema.Array(Schema.String)),
|
|
436
|
+
privatePackages: Schema.optional(PrivatePackagesConfig),
|
|
437
|
+
prettier: Schema.optional(Schema.Boolean),
|
|
438
|
+
changedFilePatterns: Schema.optional(Schema.Array(Schema.String)),
|
|
439
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional(Schema.Boolean),
|
|
440
|
+
snapshot: Schema.optional(SnapshotConfig)
|
|
441
|
+
});
|
|
442
|
+
const SilkChangesetConfigFile = Schema.extend(ChangesetConfigFile, Schema.Struct({
|
|
443
|
+
_isSilk: Schema.optionalWith(Schema.Boolean, {
|
|
444
|
+
default: ()=>true
|
|
445
|
+
})
|
|
446
|
+
}));
|
|
447
|
+
const VersioningStrategyType = Schema.Literal("single", "fixed-group", "independent");
|
|
448
|
+
const VersioningStrategyResult = Schema.Struct({
|
|
449
|
+
type: VersioningStrategyType,
|
|
450
|
+
fixedGroups: Schema.Array(Schema.Array(Schema.String)),
|
|
451
|
+
publishablePackages: Schema.Array(Schema.String)
|
|
452
|
+
});
|
|
453
|
+
function WorkspaceAnalysisSchemas_to_primitive(input, hint) {
|
|
454
|
+
if ("object" !== WorkspaceAnalysisSchemas_type_of(input) || null === input) return input;
|
|
455
|
+
var prim = input[Symbol.toPrimitive];
|
|
456
|
+
if (void 0 !== prim) {
|
|
457
|
+
var res = prim.call(input, hint || "default");
|
|
458
|
+
if ("object" !== WorkspaceAnalysisSchemas_type_of(res)) return res;
|
|
459
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
460
|
+
}
|
|
461
|
+
return ("string" === hint ? String : Number)(input);
|
|
462
|
+
}
|
|
463
|
+
function WorkspaceAnalysisSchemas_to_property_key(arg) {
|
|
464
|
+
var key = WorkspaceAnalysisSchemas_to_primitive(arg, "string");
|
|
465
|
+
return "symbol" === WorkspaceAnalysisSchemas_type_of(key) ? key : String(key);
|
|
466
|
+
}
|
|
467
|
+
function WorkspaceAnalysisSchemas_type_of(obj) {
|
|
468
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
469
|
+
}
|
|
470
|
+
let WorkspaceAnalysisSchemas_computedKey, WorkspaceAnalysisSchemas_computedKey1, _computedKey2, _computedKey3;
|
|
471
|
+
const PublishProtocol = Schema.Literal("npm", "jsr");
|
|
472
|
+
const PublishTargetShorthand = Schema.Literal("npm", "github", "jsr");
|
|
473
|
+
const PublishTargetObject = Schema.Struct({
|
|
474
|
+
protocol: Schema.optionalWith(PublishProtocol, {
|
|
475
|
+
default: ()=>"npm"
|
|
476
|
+
}),
|
|
477
|
+
registry: Schema.optional(Schema.String),
|
|
478
|
+
directory: Schema.optional(Schema.String),
|
|
479
|
+
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
480
|
+
provenance: Schema.optional(Schema.Boolean),
|
|
481
|
+
tag: Schema.optional(Schema.String)
|
|
482
|
+
});
|
|
483
|
+
class SilkPublishConfig extends PublishConfig.extend("SilkPublishConfig")({
|
|
484
|
+
targets: Schema.optional(Schema.Array(Schema.Union(PublishTargetShorthand, PublishTargetObject)))
|
|
485
|
+
}) {
|
|
486
|
+
}
|
|
487
|
+
const KNOWN_REGISTRIES = {
|
|
488
|
+
npm: "https://registry.npmjs.org/",
|
|
489
|
+
github: "https://npm.pkg.github.com/",
|
|
490
|
+
jsr: "https://jsr.io/"
|
|
491
|
+
};
|
|
492
|
+
const WorkspaceVersion = Schema.Struct({
|
|
493
|
+
current: Schema.String
|
|
494
|
+
});
|
|
495
|
+
WorkspaceAnalysisSchemas_computedKey = WorkspaceAnalysisSchemas_to_property_key(Equal.symbol), WorkspaceAnalysisSchemas_computedKey1 = WorkspaceAnalysisSchemas_to_property_key(Hash.symbol);
|
|
496
|
+
class AnalyzedWorkspace extends Schema.TaggedClass()("AnalyzedWorkspace", {
|
|
497
|
+
name: Schema.String,
|
|
498
|
+
version: WorkspaceVersion,
|
|
499
|
+
path: Schema.String,
|
|
500
|
+
root: Schema.Boolean,
|
|
501
|
+
publishConfig: Schema.NullOr(SilkPublishConfig),
|
|
502
|
+
publishable: Schema.Boolean,
|
|
503
|
+
targets: Schema.Array(PublishTarget),
|
|
504
|
+
versioned: Schema.Boolean,
|
|
505
|
+
tagged: Schema.Boolean,
|
|
506
|
+
released: Schema.Boolean,
|
|
507
|
+
linked: Schema.Array(Schema.suspend(()=>AnalyzedWorkspace)),
|
|
508
|
+
fixed: Schema.Array(Schema.suspend(()=>AnalyzedWorkspace))
|
|
509
|
+
}) {
|
|
510
|
+
get isRoot() {
|
|
511
|
+
return this.root;
|
|
512
|
+
}
|
|
513
|
+
get isPublishable() {
|
|
514
|
+
return this.publishable;
|
|
515
|
+
}
|
|
516
|
+
get isReleasable() {
|
|
517
|
+
return this.released;
|
|
518
|
+
}
|
|
519
|
+
get isFixed() {
|
|
520
|
+
return this.fixed.length > 0;
|
|
521
|
+
}
|
|
522
|
+
get isLinked() {
|
|
523
|
+
return this.linked.length > 0;
|
|
524
|
+
}
|
|
525
|
+
publishesTo(registry) {
|
|
526
|
+
return this.targets.some((t)=>t.registry === registry);
|
|
527
|
+
}
|
|
528
|
+
hasTarget(shorthand) {
|
|
529
|
+
const registry = KNOWN_REGISTRIES[shorthand];
|
|
530
|
+
return void 0 !== registry && this.publishesTo(registry);
|
|
531
|
+
}
|
|
532
|
+
targetFor(registry) {
|
|
533
|
+
const found = this.targets.find((t)=>t.registry === registry);
|
|
534
|
+
return found ? Option.some(found) : Option.none();
|
|
535
|
+
}
|
|
536
|
+
[WorkspaceAnalysisSchemas_computedKey](that) {
|
|
537
|
+
if (!(that instanceof AnalyzedWorkspace)) return false;
|
|
538
|
+
return this.name === that.name && this.path === that.path;
|
|
539
|
+
}
|
|
540
|
+
[WorkspaceAnalysisSchemas_computedKey1]() {
|
|
541
|
+
return Hash.cached(this)(Hash.combine(Hash.hash(this.name))(Hash.hash(this.path)));
|
|
542
|
+
}
|
|
543
|
+
toString() {
|
|
544
|
+
return `${this.name}@${this.version.current}`;
|
|
545
|
+
}
|
|
546
|
+
toJSON() {
|
|
547
|
+
return {
|
|
548
|
+
_tag: "AnalyzedWorkspace",
|
|
549
|
+
name: this.name,
|
|
550
|
+
version: this.version,
|
|
551
|
+
path: this.path,
|
|
552
|
+
root: this.root,
|
|
553
|
+
publishable: this.publishable,
|
|
554
|
+
targets: this.targets,
|
|
555
|
+
versioned: this.versioned,
|
|
556
|
+
tagged: this.tagged,
|
|
557
|
+
released: this.released
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
static publishable(workspaces) {
|
|
561
|
+
return workspaces.filter((w)=>w.publishable);
|
|
562
|
+
}
|
|
563
|
+
static releasable(workspaces) {
|
|
564
|
+
return workspaces.filter((w)=>w.released);
|
|
565
|
+
}
|
|
566
|
+
static findByName;
|
|
567
|
+
static pretty;
|
|
568
|
+
}
|
|
569
|
+
AnalyzedWorkspace.findByName = Function.dual(2, (workspaces, name)=>{
|
|
570
|
+
const found = workspaces.find((w)=>w.name === name);
|
|
571
|
+
return found ? Option.some(found) : Option.none();
|
|
572
|
+
});
|
|
573
|
+
AnalyzedWorkspace.pretty = Pretty.make(AnalyzedWorkspace);
|
|
574
|
+
const PackageManagerInfo = Schema.Struct({
|
|
575
|
+
type: Schema.Literal("npm", "pnpm", "yarn", "bun"),
|
|
576
|
+
version: Schema.optional(Schema.String)
|
|
577
|
+
});
|
|
578
|
+
_computedKey2 = WorkspaceAnalysisSchemas_to_property_key(Equal.symbol), _computedKey3 = WorkspaceAnalysisSchemas_to_property_key(Hash.symbol);
|
|
579
|
+
class WorkspaceAnalysis extends Schema.TaggedClass()("WorkspaceAnalysis", {
|
|
580
|
+
root: Schema.String,
|
|
581
|
+
runtime: Schema.Literal("node", "bun"),
|
|
582
|
+
packageManager: PackageManagerInfo,
|
|
583
|
+
workspaces: Schema.Array(AnalyzedWorkspace),
|
|
584
|
+
changesetConfig: Schema.NullOr(Schema.Union(SilkChangesetConfigFile, ChangesetConfigFile)),
|
|
585
|
+
versioning: Schema.NullOr(VersioningStrategyResult),
|
|
586
|
+
tagStrategy: Schema.NullOr(TagStrategyType)
|
|
587
|
+
}) {
|
|
588
|
+
findWorkspace(name) {
|
|
589
|
+
const found = this.workspaces.find((w)=>w.name === name);
|
|
590
|
+
return found ? Option.some(found) : Option.none();
|
|
591
|
+
}
|
|
592
|
+
get rootWorkspace() {
|
|
593
|
+
const root = this.workspaces.find((w)=>w.root);
|
|
594
|
+
return root ? Option.some(root) : Option.none();
|
|
595
|
+
}
|
|
596
|
+
get publishableWorkspaces() {
|
|
597
|
+
return this.workspaces.filter((w)=>w.publishable);
|
|
598
|
+
}
|
|
599
|
+
get versionedWorkspaces() {
|
|
600
|
+
return this.workspaces.filter((w)=>w.versioned);
|
|
601
|
+
}
|
|
602
|
+
get taggedWorkspaces() {
|
|
603
|
+
return this.workspaces.filter((w)=>w.tagged);
|
|
604
|
+
}
|
|
605
|
+
get releasableWorkspaces() {
|
|
606
|
+
return this.workspaces.filter((w)=>w.released);
|
|
607
|
+
}
|
|
608
|
+
get isSilk() {
|
|
609
|
+
if (null == this.changesetConfig) return false;
|
|
610
|
+
return "_isSilk" in this.changesetConfig && true === this.changesetConfig._isSilk;
|
|
611
|
+
}
|
|
612
|
+
get hasChangesets() {
|
|
613
|
+
return null != this.changesetConfig;
|
|
614
|
+
}
|
|
615
|
+
[_computedKey2](that) {
|
|
616
|
+
if (!(that instanceof WorkspaceAnalysis)) return false;
|
|
617
|
+
return this.root === that.root;
|
|
618
|
+
}
|
|
619
|
+
[_computedKey3]() {
|
|
620
|
+
return Hash.cached(this)(Hash.hash(this.root));
|
|
621
|
+
}
|
|
622
|
+
toString() {
|
|
623
|
+
return `WorkspaceAnalysis(${this.root}, ${this.workspaces.length} workspaces)`;
|
|
624
|
+
}
|
|
625
|
+
static pretty;
|
|
626
|
+
}
|
|
627
|
+
WorkspaceAnalysis.pretty = Pretty.make(WorkspaceAnalysis);
|
|
378
628
|
function extractSemver(version) {
|
|
379
629
|
return version.replace(/^[\^~>=<v]+/, "");
|
|
380
630
|
}
|
|
@@ -450,27 +700,6 @@ const BiomeSchemaSyncLive = Layer.effect(BiomeSchemaSync, Effect.gen(function*()
|
|
|
450
700
|
check: (version, options)=>run(version, options, false)
|
|
451
701
|
};
|
|
452
702
|
}));
|
|
453
|
-
const ChangesetConfig = Schema.Struct({
|
|
454
|
-
changelog: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.Unknown))),
|
|
455
|
-
commit: Schema.optional(Schema.Boolean),
|
|
456
|
-
fixed: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
457
|
-
linked: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
458
|
-
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
459
|
-
baseBranch: Schema.optional(Schema.String),
|
|
460
|
-
updateInternalDependencies: Schema.optional(Schema.Literal("patch", "minor", "major")),
|
|
461
|
-
ignore: Schema.optional(Schema.Array(Schema.String))
|
|
462
|
-
});
|
|
463
|
-
const SilkChangesetConfig = Schema.extend(ChangesetConfig, Schema.Struct({
|
|
464
|
-
_isSilk: Schema.optionalWith(Schema.Boolean, {
|
|
465
|
-
default: ()=>true
|
|
466
|
-
})
|
|
467
|
-
}));
|
|
468
|
-
const VersioningStrategyType = Schema.Literal("single", "fixed-group", "independent");
|
|
469
|
-
Schema.Struct({
|
|
470
|
-
type: VersioningStrategyType,
|
|
471
|
-
fixedGroups: Schema.Array(Schema.Array(Schema.String)),
|
|
472
|
-
publishablePackages: Schema.Array(Schema.String)
|
|
473
|
-
});
|
|
474
703
|
const SILK_CHANGELOG_MARKER = "@savvy-web/changesets";
|
|
475
704
|
function isSilkChangelog(changelog) {
|
|
476
705
|
if ("string" == typeof changelog) return changelog.includes(SILK_CHANGELOG_MARKER);
|
|
@@ -504,11 +733,11 @@ const ChangesetConfigReaderLive = Layer.effect(ChangesetConfigReader, Effect.gen
|
|
|
504
733
|
})
|
|
505
734
|
});
|
|
506
735
|
const rawConfig = parsed;
|
|
507
|
-
if (isSilkChangelog(rawConfig.changelog)) return yield* Schema.decodeUnknown(
|
|
736
|
+
if (isSilkChangelog(rawConfig.changelog)) return yield* Schema.decodeUnknown(SilkChangesetConfigFile)(parsed).pipe(Effect.mapError((cause)=>new ChangesetConfigError({
|
|
508
737
|
path: configPath,
|
|
509
738
|
reason: `Schema decode failed: ${String(cause)}`
|
|
510
739
|
})));
|
|
511
|
-
return yield* Schema.decodeUnknown(
|
|
740
|
+
return yield* Schema.decodeUnknown(ChangesetConfigFile)(parsed).pipe(Effect.mapError((cause)=>new ChangesetConfigError({
|
|
512
741
|
path: configPath,
|
|
513
742
|
reason: `Schema decode failed: ${String(cause)}`
|
|
514
743
|
})));
|
|
@@ -518,6 +747,52 @@ const ChangesetConfigReaderLive = Layer.effect(ChangesetConfigReader, Effect.gen
|
|
|
518
747
|
read
|
|
519
748
|
};
|
|
520
749
|
}));
|
|
750
|
+
class ChangesetConfig extends Context.Tag("@savvy-web/silk-effects/ChangesetConfig")() {
|
|
751
|
+
static matches(name, pattern) {
|
|
752
|
+
if (pattern.endsWith("/*")) {
|
|
753
|
+
const prefix = pattern.slice(0, -1);
|
|
754
|
+
return name.startsWith(prefix);
|
|
755
|
+
}
|
|
756
|
+
return name === pattern;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
const isSilk = (cfg)=>"_isSilk" in cfg && true === cfg._isSilk;
|
|
760
|
+
const ChangesetConfigLive = Layer.effect(ChangesetConfig, Effect.gen(function*() {
|
|
761
|
+
const reader = yield* ChangesetConfigReader;
|
|
762
|
+
const cache = new Map();
|
|
763
|
+
const read = (root)=>Effect.gen(function*() {
|
|
764
|
+
const hit = cache.get(root);
|
|
765
|
+
if (void 0 !== hit) return hit;
|
|
766
|
+
const result = yield* reader.read(root).pipe(Effect.option);
|
|
767
|
+
cache.set(root, result);
|
|
768
|
+
return result;
|
|
769
|
+
});
|
|
770
|
+
return {
|
|
771
|
+
mode: (root)=>read(root).pipe(Effect.map(Option.match({
|
|
772
|
+
onNone: ()=>"none",
|
|
773
|
+
onSome: (cfg)=>isSilk(cfg) ? "silk" : "vanilla"
|
|
774
|
+
}))),
|
|
775
|
+
versionPrivate: (root)=>read(root).pipe(Effect.map(Option.match({
|
|
776
|
+
onNone: ()=>false,
|
|
777
|
+
onSome: (cfg)=>{
|
|
778
|
+
const pp = cfg.privatePackages;
|
|
779
|
+
return void 0 !== pp && false !== pp && true === pp.version;
|
|
780
|
+
}
|
|
781
|
+
}))),
|
|
782
|
+
ignorePatterns: (root)=>read(root).pipe(Effect.map(Option.match({
|
|
783
|
+
onNone: ()=>[],
|
|
784
|
+
onSome: (cfg)=>cfg.ignore ?? []
|
|
785
|
+
}))),
|
|
786
|
+
isIgnored: (name, root)=>read(root).pipe(Effect.map(Option.match({
|
|
787
|
+
onNone: ()=>false,
|
|
788
|
+
onSome: (cfg)=>(cfg.ignore ?? []).some((p)=>ChangesetConfig.matches(name, p))
|
|
789
|
+
}))),
|
|
790
|
+
fixed: (root)=>read(root).pipe(Effect.map(Option.match({
|
|
791
|
+
onNone: ()=>[],
|
|
792
|
+
onSome: (cfg)=>cfg.fixed ?? []
|
|
793
|
+
})))
|
|
794
|
+
};
|
|
795
|
+
}));
|
|
521
796
|
class ConfigDiscovery extends Context.Tag("@savvy-web/silk-effects/ConfigDiscovery")() {
|
|
522
797
|
}
|
|
523
798
|
function safeExists(fs, path) {
|
|
@@ -669,116 +944,120 @@ const ManagedSectionLive = Layer.effect(ManagedSection, Effect.gen(function*() {
|
|
|
669
944
|
check
|
|
670
945
|
};
|
|
671
946
|
}));
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
provenance: false,
|
|
678
|
-
tag: "latest"
|
|
679
|
-
};
|
|
680
|
-
function deriveTokenEnv(registryUrl) {
|
|
681
|
-
try {
|
|
682
|
-
const hostname = new URL(registryUrl).hostname;
|
|
683
|
-
return `NPM_TOKEN_${hostname.replace(/\./g, "_").toUpperCase()}`;
|
|
684
|
-
} catch {
|
|
685
|
-
return "NPM_TOKEN";
|
|
947
|
+
const NPM_DEFAULT = "https://registry.npmjs.org/";
|
|
948
|
+
class SilkPublishability {
|
|
949
|
+
static resolveTargetAccess(target, parentAccess) {
|
|
950
|
+
if ("string" == typeof target) return parentAccess;
|
|
951
|
+
return target.access ?? parentAccess;
|
|
686
952
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
registry: target,
|
|
714
|
-
auth: "token",
|
|
715
|
-
tokenEnv: deriveTokenEnv(target)
|
|
716
|
-
});
|
|
717
|
-
if ("object" == typeof target && null !== target && !Array.isArray(target)) {
|
|
718
|
-
const obj = target;
|
|
719
|
-
const protocol = obj.protocol ?? "npm";
|
|
720
|
-
const registry = obj.registry ?? null;
|
|
721
|
-
const directory = obj.directory ?? DEFAULTS.directory;
|
|
722
|
-
const access = obj.access ?? DEFAULTS.access;
|
|
723
|
-
const provenance = obj.provenance ?? DEFAULTS.provenance;
|
|
724
|
-
const tag = obj.tag ?? DEFAULTS.tag;
|
|
725
|
-
let auth;
|
|
726
|
-
let tokenEnv;
|
|
727
|
-
if (null !== registry) try {
|
|
728
|
-
const hostname = new URL(registry).hostname;
|
|
729
|
-
if ("npm.pkg.github.com" === hostname) {
|
|
730
|
-
auth = "token";
|
|
731
|
-
tokenEnv = "GITHUB_TOKEN";
|
|
732
|
-
} else {
|
|
733
|
-
auth = "oidc";
|
|
734
|
-
tokenEnv = null;
|
|
953
|
+
static expandShorthand(target, parentRegistry) {
|
|
954
|
+
if ("npm" === target) return NPM_DEFAULT;
|
|
955
|
+
if ("github" === target) return "https://npm.pkg.github.com/";
|
|
956
|
+
if ("jsr" === target) return "https://jsr.io/";
|
|
957
|
+
if (target.startsWith("https://") || target.startsWith("http://")) return target;
|
|
958
|
+
return parentRegistry ?? NPM_DEFAULT;
|
|
959
|
+
}
|
|
960
|
+
static detect(pkgName, raw) {
|
|
961
|
+
const pc = raw.publishConfig;
|
|
962
|
+
if (pc?.targets && pc.targets.length > 0) {
|
|
963
|
+
const results = [];
|
|
964
|
+
for (const target of pc.targets){
|
|
965
|
+
const access = SilkPublishability.resolveTargetAccess(target, pc.access);
|
|
966
|
+
if ("public" !== access && "restricted" !== access) continue;
|
|
967
|
+
const registry = "string" == typeof target ? SilkPublishability.expandShorthand(target, pc.registry) : target.registry ?? pc.registry ?? NPM_DEFAULT;
|
|
968
|
+
const directory = "string" == typeof target ? pc.directory ?? "." : target.directory ?? pc.directory ?? ".";
|
|
969
|
+
const provenance = "string" == typeof target ? void 0 : target.provenance;
|
|
970
|
+
results.push(new PublishTarget({
|
|
971
|
+
name: pkgName,
|
|
972
|
+
registry,
|
|
973
|
+
directory,
|
|
974
|
+
access,
|
|
975
|
+
...void 0 !== provenance ? {
|
|
976
|
+
provenance
|
|
977
|
+
} : {}
|
|
978
|
+
}));
|
|
735
979
|
}
|
|
736
|
-
|
|
737
|
-
auth = "oidc";
|
|
738
|
-
tokenEnv = null;
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
auth = "oidc";
|
|
742
|
-
tokenEnv = null;
|
|
980
|
+
return results;
|
|
743
981
|
}
|
|
744
|
-
return
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
982
|
+
if (pc && ("public" === pc.access || "restricted" === pc.access)) return [
|
|
983
|
+
new PublishTarget({
|
|
984
|
+
name: pkgName,
|
|
985
|
+
registry: pc.registry ?? NPM_DEFAULT,
|
|
986
|
+
directory: pc.directory ?? ".",
|
|
987
|
+
access: pc.access
|
|
988
|
+
})
|
|
989
|
+
];
|
|
990
|
+
if (true !== raw.private) return [
|
|
991
|
+
new PublishTarget({
|
|
992
|
+
name: pkgName,
|
|
993
|
+
registry: pc?.registry ?? NPM_DEFAULT,
|
|
994
|
+
directory: pc?.directory ?? ".",
|
|
995
|
+
access: pc?.access ?? "public"
|
|
996
|
+
})
|
|
997
|
+
];
|
|
998
|
+
return [];
|
|
999
|
+
}
|
|
1000
|
+
static resolveTargets(pkg, root) {
|
|
1001
|
+
return Effect.gen(function*() {
|
|
1002
|
+
const detector = yield* PublishabilityDetector;
|
|
1003
|
+
const fs = yield* FileSystem.FileSystem;
|
|
1004
|
+
const targets = yield* detector.detect(pkg, root);
|
|
1005
|
+
const kept = [];
|
|
1006
|
+
for (const t of targets){
|
|
1007
|
+
const dir = isAbsolute(t.directory) ? t.directory : join(pkg.path, t.directory);
|
|
1008
|
+
if (!(yield* isTargetPrivate(fs, dir))) kept.push(t);
|
|
1009
|
+
}
|
|
1010
|
+
return kept;
|
|
753
1011
|
});
|
|
754
1012
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
1013
|
+
static listPublishable(root) {
|
|
1014
|
+
return Effect.gen(function*() {
|
|
1015
|
+
const discovery = yield* WorkspaceDiscovery;
|
|
1016
|
+
const detector = yield* PublishabilityDetector;
|
|
1017
|
+
const packages = yield* discovery.listPackages().pipe(Effect.orDie);
|
|
1018
|
+
const out = [];
|
|
1019
|
+
for (const pkg of packages){
|
|
1020
|
+
const targets = yield* detector.detect(pkg, root);
|
|
1021
|
+
if (targets.length > 0) out.push({
|
|
1022
|
+
name: pkg.name,
|
|
1023
|
+
version: pkg.version,
|
|
1024
|
+
path: pkg.path,
|
|
1025
|
+
targetCount: targets.length
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
return out;
|
|
1029
|
+
});
|
|
766
1030
|
}
|
|
767
|
-
});
|
|
768
|
-
class SilkPublishabilityPlugin extends Context.Tag("@savvy-web/silk-effects/SilkPublishabilityPlugin")() {
|
|
769
1031
|
}
|
|
770
|
-
const
|
|
771
|
-
|
|
1032
|
+
const isTargetPrivate = (fs, targetDir)=>fs.readFileString(join(targetDir, "package.json")).pipe(Effect.flatMap((content)=>Effect["try"]({
|
|
1033
|
+
try: ()=>true === JSON.parse(content).private,
|
|
1034
|
+
catch: ()=>new Error("invalid package.json")
|
|
1035
|
+
})), Effect.orElseSucceed(()=>false));
|
|
1036
|
+
const readRaw = (fs, packageJsonPath)=>fs.readFileString(packageJsonPath).pipe(Effect.flatMap((content)=>Effect["try"]({
|
|
1037
|
+
try: ()=>JSON.parse(content),
|
|
1038
|
+
catch: ()=>new Error("invalid package.json")
|
|
1039
|
+
})), Effect.orElseSucceed(()=>null));
|
|
1040
|
+
const SilkPublishabilityDetectorLive = Layer.effect(PublishabilityDetector, Effect.gen(function*() {
|
|
1041
|
+
const fs = yield* FileSystem.FileSystem;
|
|
772
1042
|
return {
|
|
773
|
-
detect: (
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
1043
|
+
detect: (pkg, _root)=>readRaw(fs, pkg.packageJsonPath).pipe(Effect.map((raw)=>raw ? SilkPublishability.detect(pkg.name, raw) : []))
|
|
1044
|
+
};
|
|
1045
|
+
}));
|
|
1046
|
+
const PublishabilityDetectorAdaptiveLive = Layer.effect(PublishabilityDetector, Effect.gen(function*() {
|
|
1047
|
+
const fs = yield* FileSystem.FileSystem;
|
|
1048
|
+
const config = yield* ChangesetConfig;
|
|
1049
|
+
const vanilla = yield* Effect.provide(PublishabilityDetector, PublishabilityDetectorLive);
|
|
1050
|
+
return {
|
|
1051
|
+
detect: (pkg, root)=>Effect.gen(function*() {
|
|
1052
|
+
if (yield* config.isIgnored(pkg.name, root)) return [];
|
|
1053
|
+
const mode = yield* config.mode(root);
|
|
1054
|
+
if ("none" === mode) return [];
|
|
1055
|
+
if ("silk" === mode) {
|
|
1056
|
+
const raw = yield* readRaw(fs, pkg.packageJsonPath);
|
|
1057
|
+
return raw ? SilkPublishability.detect(pkg.name, raw) : [];
|
|
1058
|
+
}
|
|
1059
|
+
return yield* vanilla.detect(pkg, root);
|
|
1060
|
+
})
|
|
782
1061
|
};
|
|
783
1062
|
}));
|
|
784
1063
|
class TagStrategy extends Context.Tag("@savvy-web/silk-effects/TagStrategy")() {
|
|
@@ -799,6 +1078,195 @@ const TagStrategyLive = Layer.succeed(TagStrategy, TagStrategy.of({
|
|
|
799
1078
|
return Effect.succeed(`${name}@${version}`);
|
|
800
1079
|
}
|
|
801
1080
|
}));
|
|
1081
|
+
class VersioningStrategy extends Context.Tag("@savvy-web/silk-effects/VersioningStrategy")() {
|
|
1082
|
+
}
|
|
1083
|
+
const VersioningStrategyLive = Layer.effect(VersioningStrategy, Effect.gen(function*() {
|
|
1084
|
+
const configReader = yield* ChangesetConfigReader;
|
|
1085
|
+
const detect = (publishablePackages, root)=>Effect.gen(function*() {
|
|
1086
|
+
const config = yield* configReader.read(root).pipe(Effect.orElseSucceed(()=>({
|
|
1087
|
+
fixed: [],
|
|
1088
|
+
linked: []
|
|
1089
|
+
})));
|
|
1090
|
+
const fixed = config.fixed ?? [];
|
|
1091
|
+
const packages = [
|
|
1092
|
+
...publishablePackages
|
|
1093
|
+
];
|
|
1094
|
+
if (packages.length <= 1) return {
|
|
1095
|
+
type: "single",
|
|
1096
|
+
fixedGroups: fixed,
|
|
1097
|
+
publishablePackages: packages
|
|
1098
|
+
};
|
|
1099
|
+
const containingGroup = fixed.find((group)=>packages.every((pkg)=>group.includes(pkg)));
|
|
1100
|
+
if (void 0 !== containingGroup) return {
|
|
1101
|
+
type: "fixed-group",
|
|
1102
|
+
fixedGroups: fixed,
|
|
1103
|
+
publishablePackages: packages
|
|
1104
|
+
};
|
|
1105
|
+
return {
|
|
1106
|
+
type: "independent",
|
|
1107
|
+
fixedGroups: fixed,
|
|
1108
|
+
publishablePackages: packages
|
|
1109
|
+
};
|
|
1110
|
+
});
|
|
1111
|
+
return {
|
|
1112
|
+
detect
|
|
1113
|
+
};
|
|
1114
|
+
}));
|
|
1115
|
+
class SilkWorkspaceAnalyzer extends Context.Tag("@savvy-web/silk-effects/SilkWorkspaceAnalyzer")() {
|
|
1116
|
+
}
|
|
1117
|
+
const readRawPkgJson = (fs, packageJsonPath)=>fs.readFileString(packageJsonPath).pipe(Effect.flatMap((content)=>Effect["try"]({
|
|
1118
|
+
try: ()=>JSON.parse(content),
|
|
1119
|
+
catch: ()=>new WorkspaceAnalysisError({
|
|
1120
|
+
root: packageJsonPath,
|
|
1121
|
+
reason: "Invalid JSON in package.json"
|
|
1122
|
+
})
|
|
1123
|
+
})), Effect.mapError((err)=>err instanceof WorkspaceAnalysisError ? err : new WorkspaceAnalysisError({
|
|
1124
|
+
root: packageJsonPath,
|
|
1125
|
+
reason: `Failed to read package.json: ${String(err)}`
|
|
1126
|
+
})));
|
|
1127
|
+
function computeReleaseStatus(pkgName, isPrivate, isPublishable, config) {
|
|
1128
|
+
if (null == config) return {
|
|
1129
|
+
versioned: false,
|
|
1130
|
+
tagged: false,
|
|
1131
|
+
released: false
|
|
1132
|
+
};
|
|
1133
|
+
if ((config.ignore ?? []).some((p)=>ChangesetConfig.matches(pkgName, p))) return {
|
|
1134
|
+
versioned: false,
|
|
1135
|
+
tagged: false,
|
|
1136
|
+
released: false
|
|
1137
|
+
};
|
|
1138
|
+
if (!isPrivate || isPublishable) return {
|
|
1139
|
+
versioned: true,
|
|
1140
|
+
tagged: true,
|
|
1141
|
+
released: true
|
|
1142
|
+
};
|
|
1143
|
+
const pp = config.privatePackages;
|
|
1144
|
+
if (void 0 === pp) return {
|
|
1145
|
+
versioned: false,
|
|
1146
|
+
tagged: false,
|
|
1147
|
+
released: false
|
|
1148
|
+
};
|
|
1149
|
+
if (false === pp) return {
|
|
1150
|
+
versioned: false,
|
|
1151
|
+
tagged: false,
|
|
1152
|
+
released: false
|
|
1153
|
+
};
|
|
1154
|
+
const versioned = true === pp.version;
|
|
1155
|
+
const tagged = true === pp.tag;
|
|
1156
|
+
const released = versioned && tagged;
|
|
1157
|
+
return {
|
|
1158
|
+
versioned,
|
|
1159
|
+
tagged,
|
|
1160
|
+
released
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
const SilkWorkspaceAnalyzerLive = Layer.effect(SilkWorkspaceAnalyzer, Effect.gen(function*() {
|
|
1164
|
+
const fs = yield* FileSystem.FileSystem;
|
|
1165
|
+
const discovery = yield* WorkspaceDiscovery;
|
|
1166
|
+
const sorter = yield* TopologicalSorter;
|
|
1167
|
+
const pmDetector = yield* PackageManagerDetector;
|
|
1168
|
+
const configReader = yield* ChangesetConfigReader;
|
|
1169
|
+
const versioningStrategy = yield* VersioningStrategy;
|
|
1170
|
+
const tagStrategy = yield* TagStrategy;
|
|
1171
|
+
const analyze = (root)=>Effect.gen(function*() {
|
|
1172
|
+
const pm = yield* pmDetector.detect(root).pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1173
|
+
root,
|
|
1174
|
+
reason: `Package manager detection failed: ${String(err)}`
|
|
1175
|
+
})));
|
|
1176
|
+
const packages = yield* discovery.listPackages().pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1177
|
+
root,
|
|
1178
|
+
reason: `Workspace discovery failed: ${String(err)}`
|
|
1179
|
+
})));
|
|
1180
|
+
const topoOrder = yield* sorter.sort().pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1181
|
+
root,
|
|
1182
|
+
reason: `Cyclic dependency detected: ${String(err)}`
|
|
1183
|
+
})));
|
|
1184
|
+
const packagesByName = new Map(packages.map((p)=>[
|
|
1185
|
+
p.name,
|
|
1186
|
+
p
|
|
1187
|
+
]));
|
|
1188
|
+
const sortedPackages = topoOrder.flatMap((name)=>{
|
|
1189
|
+
const pkg = packagesByName.get(name);
|
|
1190
|
+
return pkg ? [
|
|
1191
|
+
pkg
|
|
1192
|
+
] : [];
|
|
1193
|
+
});
|
|
1194
|
+
const changesetConfigOption = yield* configReader.read(root).pipe(Effect.option);
|
|
1195
|
+
const changesetConfig = Option.getOrNull(changesetConfigOption);
|
|
1196
|
+
const analyzedWorkspaces = [];
|
|
1197
|
+
for (const pkg of sortedPackages){
|
|
1198
|
+
const pkgJson = yield* readRawPkgJson(fs, pkg.packageJsonPath);
|
|
1199
|
+
const targets = SilkPublishability.detect(pkg.name, pkgJson);
|
|
1200
|
+
const isPublishable = targets.length > 0;
|
|
1201
|
+
const isRoot = "." === pkg.relativePath;
|
|
1202
|
+
const { versioned, tagged, released } = computeReleaseStatus(pkg.name, pkg.private, isPublishable, changesetConfig);
|
|
1203
|
+
const analyzed = new AnalyzedWorkspace({
|
|
1204
|
+
name: pkg.name,
|
|
1205
|
+
version: {
|
|
1206
|
+
current: pkg.version
|
|
1207
|
+
},
|
|
1208
|
+
path: pkg.path,
|
|
1209
|
+
root: isRoot,
|
|
1210
|
+
publishConfig: null,
|
|
1211
|
+
publishable: isPublishable,
|
|
1212
|
+
targets: [
|
|
1213
|
+
...targets
|
|
1214
|
+
],
|
|
1215
|
+
versioned,
|
|
1216
|
+
tagged,
|
|
1217
|
+
released,
|
|
1218
|
+
linked: [],
|
|
1219
|
+
fixed: []
|
|
1220
|
+
});
|
|
1221
|
+
analyzedWorkspaces.push(analyzed);
|
|
1222
|
+
}
|
|
1223
|
+
if (changesetConfig) {
|
|
1224
|
+
const fixedGroups = changesetConfig.fixed ?? [];
|
|
1225
|
+
const linkedGroups = changesetConfig.linked ?? [];
|
|
1226
|
+
const fixedByName = new Map();
|
|
1227
|
+
for (const group of fixedGroups){
|
|
1228
|
+
const members = analyzedWorkspaces.filter((w)=>group.includes(w.name));
|
|
1229
|
+
for (const member of members)fixedByName.set(member.name, members.filter((m)=>m !== member));
|
|
1230
|
+
}
|
|
1231
|
+
const linkedByName = new Map();
|
|
1232
|
+
for (const group of linkedGroups){
|
|
1233
|
+
const members = analyzedWorkspaces.filter((w)=>group.includes(w.name));
|
|
1234
|
+
for (const member of members)linkedByName.set(member.name, members.filter((m)=>m !== member));
|
|
1235
|
+
}
|
|
1236
|
+
for(let i = 0; i < analyzedWorkspaces.length; i++){
|
|
1237
|
+
const ws = analyzedWorkspaces[i];
|
|
1238
|
+
const fixedRefs = fixedByName.get(ws.name) ?? [];
|
|
1239
|
+
const linkedRefs = linkedByName.get(ws.name) ?? [];
|
|
1240
|
+
if (fixedRefs.length > 0 || linkedRefs.length > 0) analyzedWorkspaces[i] = new AnalyzedWorkspace({
|
|
1241
|
+
...ws,
|
|
1242
|
+
fixed: fixedRefs,
|
|
1243
|
+
linked: linkedRefs
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const publishableNames = analyzedWorkspaces.filter((w)=>w.publishable).map((w)=>w.name);
|
|
1248
|
+
const versioning = yield* versioningStrategy.detect(publishableNames, root).pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1249
|
+
root,
|
|
1250
|
+
reason: `Versioning strategy detection failed: ${String(err)}`
|
|
1251
|
+
})));
|
|
1252
|
+
const tagStrategyType = yield* tagStrategy.determine(versioning);
|
|
1253
|
+
return new WorkspaceAnalysis({
|
|
1254
|
+
root,
|
|
1255
|
+
runtime: pm.runtime,
|
|
1256
|
+
packageManager: {
|
|
1257
|
+
type: pm.type,
|
|
1258
|
+
version: pm.version
|
|
1259
|
+
},
|
|
1260
|
+
workspaces: analyzedWorkspaces,
|
|
1261
|
+
changesetConfig,
|
|
1262
|
+
versioning,
|
|
1263
|
+
tagStrategy: tagStrategyType
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
return {
|
|
1267
|
+
analyze
|
|
1268
|
+
};
|
|
1269
|
+
}));
|
|
802
1270
|
class ToolDiscovery extends Context.Tag("@savvy-web/silk-effects/ToolDiscovery")() {
|
|
803
1271
|
}
|
|
804
1272
|
function pmExecArgs(pmType, name) {
|
|
@@ -986,38 +1454,4 @@ const ToolDiscoveryLive = Layer.effect(ToolDiscovery, Effect.gen(function*() {
|
|
|
986
1454
|
clearCache
|
|
987
1455
|
};
|
|
988
1456
|
}));
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
const VersioningStrategyLive = Layer.effect(VersioningStrategy, Effect.gen(function*() {
|
|
992
|
-
const configReader = yield* ChangesetConfigReader;
|
|
993
|
-
const detect = (publishablePackages, root)=>Effect.gen(function*() {
|
|
994
|
-
const config = yield* configReader.read(root).pipe(Effect.orElseSucceed(()=>({
|
|
995
|
-
fixed: [],
|
|
996
|
-
linked: []
|
|
997
|
-
})));
|
|
998
|
-
const fixed = config.fixed ?? [];
|
|
999
|
-
const packages = [
|
|
1000
|
-
...publishablePackages
|
|
1001
|
-
];
|
|
1002
|
-
if (packages.length <= 1) return {
|
|
1003
|
-
type: "single",
|
|
1004
|
-
fixedGroups: fixed,
|
|
1005
|
-
publishablePackages: packages
|
|
1006
|
-
};
|
|
1007
|
-
const containingGroup = fixed.find((group)=>packages.every((pkg)=>group.includes(pkg)));
|
|
1008
|
-
if (void 0 !== containingGroup) return {
|
|
1009
|
-
type: "fixed-group",
|
|
1010
|
-
fixedGroups: fixed,
|
|
1011
|
-
publishablePackages: packages
|
|
1012
|
-
};
|
|
1013
|
-
return {
|
|
1014
|
-
type: "independent",
|
|
1015
|
-
fixedGroups: fixed,
|
|
1016
|
-
publishablePackages: packages
|
|
1017
|
-
};
|
|
1018
|
-
});
|
|
1019
|
-
return {
|
|
1020
|
-
detect
|
|
1021
|
-
};
|
|
1022
|
-
}));
|
|
1023
|
-
export { BiomeSchemaSync, BiomeSchemaSyncLive, BiomeSyncError, ChangesetConfigError, ChangesetConfigReader, ChangesetConfigReaderLive, CheckResult, ConfigDiscovery, ConfigDiscoveryLive, ConfigNotFoundError, ManagedSection, ManagedSectionLive, PublishConfigError, PublishTarget as PublishTargetSchema, PublishTargetShorthand as PublishTargetShorthandSchema, ResolutionPolicy, ResolvedTarget as ResolvedTargetSchema, ResolvedTool, SectionBlock, SectionDefinition, SectionDiff, SectionParseError, SectionValidationError, SectionWriteError, ShellSectionDefinition, SilkPublishabilityPlugin, SilkPublishabilityPluginLive, SourceRequirement, SyncResult, TagFormatError, TagStrategy, TagStrategyLive, TargetResolutionError, TargetResolver, TargetResolverLive, ToolCommand, ToolDefinition, ToolDiscovery, ToolDiscoveryLive, ToolNotFoundError, ToolResolutionError, ToolSource, ToolVersionMismatchError, VersionExtractor, VersioningDetectionError, VersioningStrategy, VersioningStrategyLive, buildSchemaUrl, extractSemver };
|
|
1457
|
+
export { AnalyzedWorkspace, BiomeSchemaSync, BiomeSchemaSyncLive, BiomeSyncError, ChangesetConfig, ChangesetConfigError, ChangesetConfigLive, ChangesetConfigReader, ChangesetConfigReaderLive, CheckResult, ConfigDiscovery, ConfigDiscoveryLive, ConfigNotFoundError, ManagedSection, ManagedSectionLive, PublishabilityDetectorAdaptiveLive, ResolutionPolicy, ResolvedTool, SectionBlock, SectionDefinition, SectionDiff, SectionParseError, SectionValidationError, SectionWriteError, ShellSectionDefinition, SilkPublishConfig, SilkPublishability, SilkPublishabilityDetectorLive, SilkWorkspaceAnalyzer, SilkWorkspaceAnalyzerLive, SourceRequirement, SyncResult, TagFormatError, TagStrategy, TagStrategyLive, ToolCommand, ToolDefinition, ToolDiscovery, ToolDiscoveryLive, ToolNotFoundError, ToolResolutionError, ToolSource, ToolVersionMismatchError, VersionExtractor, VersioningDetectionError, VersioningStrategy, VersioningStrategyLive, WorkspaceAnalysis, WorkspaceAnalysisError, buildSchemaUrl, extractSemver };
|