@savvy-web/silk-effects 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -60
- package/index.d.ts +149 -276
- package/index.js +178 -153
- package/package.json +3 -3
- package/tsdoc-metadata.json +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
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, TopologicalSorter, WorkspaceDiscovery, WorkspaceRoot } from "workspaces-effect";
|
|
3
|
+
import { PackageManagerDetector, PublishConfig, PublishTarget, PublishabilityDetector, PublishabilityDetectorLive, TopologicalSorter, WorkspaceDiscovery, WorkspaceRoot } from "workspaces-effect";
|
|
4
4
|
import { parse } from "jsonc-effect";
|
|
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}`;
|
|
@@ -72,30 +63,6 @@ class WorkspaceAnalysisError extends Data.TaggedError("WorkspaceAnalysisError")
|
|
|
72
63
|
return `Workspace analysis failed at ${this.root}: ${this.reason}`;
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
|
-
const PublishProtocol = Schema.Literal("npm", "jsr");
|
|
76
|
-
const AuthStrategy = Schema.Literal("oidc", "token");
|
|
77
|
-
const PublishTargetObject = Schema.Struct({
|
|
78
|
-
protocol: Schema.optionalWith(PublishProtocol, {
|
|
79
|
-
default: ()=>"npm"
|
|
80
|
-
}),
|
|
81
|
-
registry: Schema.optional(Schema.String),
|
|
82
|
-
directory: Schema.optional(Schema.String),
|
|
83
|
-
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
84
|
-
provenance: Schema.optional(Schema.Boolean),
|
|
85
|
-
tag: Schema.optional(Schema.String)
|
|
86
|
-
});
|
|
87
|
-
const PublishTargetShorthand = Schema.Literal("npm", "github", "jsr");
|
|
88
|
-
const PublishTarget = Schema.Union(PublishTargetShorthand, Schema.String.pipe(Schema.filter((s)=>s.startsWith("https://"))), PublishTargetObject);
|
|
89
|
-
const ResolvedTarget = Schema.Struct({
|
|
90
|
-
protocol: PublishProtocol,
|
|
91
|
-
registry: Schema.NullOr(Schema.String),
|
|
92
|
-
directory: Schema.String,
|
|
93
|
-
access: Schema.Literal("public", "restricted"),
|
|
94
|
-
provenance: Schema.Boolean,
|
|
95
|
-
tag: Schema.String,
|
|
96
|
-
auth: AuthStrategy,
|
|
97
|
-
tokenEnv: Schema.NullOr(Schema.String)
|
|
98
|
-
});
|
|
99
66
|
class ToolCommand {
|
|
100
67
|
command;
|
|
101
68
|
constructor(command){
|
|
@@ -457,7 +424,7 @@ const SnapshotConfig = Schema.Struct({
|
|
|
457
424
|
useCalculatedVersion: Schema.optional(Schema.Boolean),
|
|
458
425
|
prereleaseTemplate: Schema.optional(Schema.String)
|
|
459
426
|
});
|
|
460
|
-
const
|
|
427
|
+
const ChangesetConfigFile = Schema.Struct({
|
|
461
428
|
changelog: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.Unknown), Schema.Literal(false))),
|
|
462
429
|
commit: Schema.optional(Schema.Union(Schema.Boolean, Schema.String, Schema.Array(Schema.Unknown))),
|
|
463
430
|
fixed: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
@@ -472,7 +439,7 @@ const ChangesetConfig = Schema.Struct({
|
|
|
472
439
|
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional(Schema.Boolean),
|
|
473
440
|
snapshot: Schema.optional(SnapshotConfig)
|
|
474
441
|
});
|
|
475
|
-
const
|
|
442
|
+
const SilkChangesetConfigFile = Schema.extend(ChangesetConfigFile, Schema.Struct({
|
|
476
443
|
_isSilk: Schema.optionalWith(Schema.Boolean, {
|
|
477
444
|
default: ()=>true
|
|
478
445
|
})
|
|
@@ -501,13 +468,26 @@ function WorkspaceAnalysisSchemas_type_of(obj) {
|
|
|
501
468
|
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
502
469
|
}
|
|
503
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
|
+
});
|
|
504
483
|
class SilkPublishConfig extends PublishConfig.extend("SilkPublishConfig")({
|
|
505
484
|
targets: Schema.optional(Schema.Array(Schema.Union(PublishTargetShorthand, PublishTargetObject)))
|
|
506
485
|
}) {
|
|
507
486
|
}
|
|
508
487
|
const KNOWN_REGISTRIES = {
|
|
509
488
|
npm: "https://registry.npmjs.org/",
|
|
510
|
-
github: "https://npm.pkg.github.com/"
|
|
489
|
+
github: "https://npm.pkg.github.com/",
|
|
490
|
+
jsr: "https://jsr.io/"
|
|
511
491
|
};
|
|
512
492
|
const WorkspaceVersion = Schema.Struct({
|
|
513
493
|
current: Schema.String
|
|
@@ -520,7 +500,7 @@ class AnalyzedWorkspace extends Schema.TaggedClass()("AnalyzedWorkspace", {
|
|
|
520
500
|
root: Schema.Boolean,
|
|
521
501
|
publishConfig: Schema.NullOr(SilkPublishConfig),
|
|
522
502
|
publishable: Schema.Boolean,
|
|
523
|
-
targets: Schema.Array(
|
|
503
|
+
targets: Schema.Array(PublishTarget),
|
|
524
504
|
versioned: Schema.Boolean,
|
|
525
505
|
tagged: Schema.Boolean,
|
|
526
506
|
released: Schema.Boolean,
|
|
@@ -546,7 +526,6 @@ class AnalyzedWorkspace extends Schema.TaggedClass()("AnalyzedWorkspace", {
|
|
|
546
526
|
return this.targets.some((t)=>t.registry === registry);
|
|
547
527
|
}
|
|
548
528
|
hasTarget(shorthand) {
|
|
549
|
-
if ("jsr" === shorthand) return this.targets.some((t)=>"jsr" === t.protocol);
|
|
550
529
|
const registry = KNOWN_REGISTRIES[shorthand];
|
|
551
530
|
return void 0 !== registry && this.publishesTo(registry);
|
|
552
531
|
}
|
|
@@ -602,7 +581,7 @@ class WorkspaceAnalysis extends Schema.TaggedClass()("WorkspaceAnalysis", {
|
|
|
602
581
|
runtime: Schema.Literal("node", "bun"),
|
|
603
582
|
packageManager: PackageManagerInfo,
|
|
604
583
|
workspaces: Schema.Array(AnalyzedWorkspace),
|
|
605
|
-
changesetConfig: Schema.NullOr(Schema.Union(
|
|
584
|
+
changesetConfig: Schema.NullOr(Schema.Union(SilkChangesetConfigFile, ChangesetConfigFile)),
|
|
606
585
|
versioning: Schema.NullOr(VersioningStrategyResult),
|
|
607
586
|
tagStrategy: Schema.NullOr(TagStrategyType)
|
|
608
587
|
}) {
|
|
@@ -754,11 +733,11 @@ const ChangesetConfigReaderLive = Layer.effect(ChangesetConfigReader, Effect.gen
|
|
|
754
733
|
})
|
|
755
734
|
});
|
|
756
735
|
const rawConfig = parsed;
|
|
757
|
-
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({
|
|
758
737
|
path: configPath,
|
|
759
738
|
reason: `Schema decode failed: ${String(cause)}`
|
|
760
739
|
})));
|
|
761
|
-
return yield* Schema.decodeUnknown(
|
|
740
|
+
return yield* Schema.decodeUnknown(ChangesetConfigFile)(parsed).pipe(Effect.mapError((cause)=>new ChangesetConfigError({
|
|
762
741
|
path: configPath,
|
|
763
742
|
reason: `Schema decode failed: ${String(cause)}`
|
|
764
743
|
})));
|
|
@@ -768,6 +747,52 @@ const ChangesetConfigReaderLive = Layer.effect(ChangesetConfigReader, Effect.gen
|
|
|
768
747
|
read
|
|
769
748
|
};
|
|
770
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
|
+
}));
|
|
771
796
|
class ConfigDiscovery extends Context.Tag("@savvy-web/silk-effects/ConfigDiscovery")() {
|
|
772
797
|
}
|
|
773
798
|
function safeExists(fs, path) {
|
|
@@ -919,116 +944,120 @@ const ManagedSectionLive = Layer.effect(ManagedSection, Effect.gen(function*() {
|
|
|
919
944
|
check
|
|
920
945
|
};
|
|
921
946
|
}));
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
return
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
...DEFAULTS,
|
|
955
|
-
protocol: "jsr",
|
|
956
|
-
registry: null,
|
|
957
|
-
auth: "oidc",
|
|
958
|
-
tokenEnv: null
|
|
959
|
-
});
|
|
960
|
-
if ("string" == typeof target && target.startsWith("https://")) return Effect.succeed({
|
|
961
|
-
...DEFAULTS,
|
|
962
|
-
protocol: "npm",
|
|
963
|
-
registry: target,
|
|
964
|
-
auth: "token",
|
|
965
|
-
tokenEnv: deriveTokenEnv(target)
|
|
966
|
-
});
|
|
967
|
-
if ("object" == typeof target && null !== target && !Array.isArray(target)) {
|
|
968
|
-
const obj = target;
|
|
969
|
-
const protocol = obj.protocol ?? "npm";
|
|
970
|
-
const registry = obj.registry ?? null;
|
|
971
|
-
const directory = obj.directory ?? DEFAULTS.directory;
|
|
972
|
-
const access = obj.access ?? DEFAULTS.access;
|
|
973
|
-
const provenance = obj.provenance ?? DEFAULTS.provenance;
|
|
974
|
-
const tag = obj.tag ?? DEFAULTS.tag;
|
|
975
|
-
let auth;
|
|
976
|
-
let tokenEnv;
|
|
977
|
-
if (null !== registry) try {
|
|
978
|
-
const hostname = new URL(registry).hostname;
|
|
979
|
-
if ("npm.pkg.github.com" === hostname) {
|
|
980
|
-
auth = "token";
|
|
981
|
-
tokenEnv = "GITHUB_TOKEN";
|
|
982
|
-
} else {
|
|
983
|
-
auth = "oidc";
|
|
984
|
-
tokenEnv = null;
|
|
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;
|
|
952
|
+
}
|
|
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
|
+
}));
|
|
985
979
|
}
|
|
986
|
-
|
|
987
|
-
auth = "oidc";
|
|
988
|
-
tokenEnv = null;
|
|
989
|
-
}
|
|
990
|
-
else {
|
|
991
|
-
auth = "oidc";
|
|
992
|
-
tokenEnv = null;
|
|
980
|
+
return results;
|
|
993
981
|
}
|
|
994
|
-
return
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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;
|
|
1003
1011
|
});
|
|
1004
1012
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
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
|
+
});
|
|
1016
1030
|
}
|
|
1017
|
-
});
|
|
1018
|
-
class SilkPublishabilityPlugin extends Context.Tag("@savvy-web/silk-effects/SilkPublishabilityPlugin")() {
|
|
1019
1031
|
}
|
|
1020
|
-
const
|
|
1021
|
-
|
|
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;
|
|
1022
1042
|
return {
|
|
1023
|
-
detect: (
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
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
|
+
})
|
|
1032
1061
|
};
|
|
1033
1062
|
}));
|
|
1034
1063
|
class TagStrategy extends Context.Tag("@savvy-web/silk-effects/TagStrategy")() {
|
|
@@ -1101,7 +1130,7 @@ function computeReleaseStatus(pkgName, isPrivate, isPublishable, config) {
|
|
|
1101
1130
|
tagged: false,
|
|
1102
1131
|
released: false
|
|
1103
1132
|
};
|
|
1104
|
-
if (config.ignore
|
|
1133
|
+
if ((config.ignore ?? []).some((p)=>ChangesetConfig.matches(pkgName, p))) return {
|
|
1105
1134
|
versioned: false,
|
|
1106
1135
|
tagged: false,
|
|
1107
1136
|
released: false
|
|
@@ -1136,7 +1165,6 @@ const SilkWorkspaceAnalyzerLive = Layer.effect(SilkWorkspaceAnalyzer, Effect.gen
|
|
|
1136
1165
|
const discovery = yield* WorkspaceDiscovery;
|
|
1137
1166
|
const sorter = yield* TopologicalSorter;
|
|
1138
1167
|
const pmDetector = yield* PackageManagerDetector;
|
|
1139
|
-
const publishability = yield* SilkPublishabilityPlugin;
|
|
1140
1168
|
const configReader = yield* ChangesetConfigReader;
|
|
1141
1169
|
const versioningStrategy = yield* VersioningStrategy;
|
|
1142
1170
|
const tagStrategy = yield* TagStrategy;
|
|
@@ -1168,10 +1196,7 @@ const SilkWorkspaceAnalyzerLive = Layer.effect(SilkWorkspaceAnalyzer, Effect.gen
|
|
|
1168
1196
|
const analyzedWorkspaces = [];
|
|
1169
1197
|
for (const pkg of sortedPackages){
|
|
1170
1198
|
const pkgJson = yield* readRawPkgJson(fs, pkg.packageJsonPath);
|
|
1171
|
-
const targets =
|
|
1172
|
-
root,
|
|
1173
|
-
reason: `Publishability detection failed for ${pkg.name}: ${String(err)}`
|
|
1174
|
-
})));
|
|
1199
|
+
const targets = SilkPublishability.detect(pkg.name, pkgJson);
|
|
1175
1200
|
const isPublishable = targets.length > 0;
|
|
1176
1201
|
const isRoot = "." === pkg.relativePath;
|
|
1177
1202
|
const { versioned, tagged, released } = computeReleaseStatus(pkg.name, pkg.private, isPublishable, changesetConfig);
|
|
@@ -1429,4 +1454,4 @@ const ToolDiscoveryLive = Layer.effect(ToolDiscovery, Effect.gen(function*() {
|
|
|
1429
1454
|
clearCache
|
|
1430
1455
|
};
|
|
1431
1456
|
}));
|
|
1432
|
-
export { AnalyzedWorkspace, BiomeSchemaSync, BiomeSchemaSyncLive, BiomeSyncError, ChangesetConfigError, ChangesetConfigReader, ChangesetConfigReaderLive, CheckResult, ConfigDiscovery, ConfigDiscoveryLive, ConfigNotFoundError, ManagedSection, ManagedSectionLive,
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/silk-effects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared Effect library for Silk Suite conventions",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/silk-effects",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"jsonc-effect": "^0.2.1",
|
|
31
31
|
"semver-effect": "^0.2.1",
|
|
32
|
-
"workspaces-effect": "^
|
|
33
|
-
"yaml-effect": "^0.
|
|
32
|
+
"workspaces-effect": "^1.1.0",
|
|
33
|
+
"yaml-effect": "^0.6.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@effect/platform": ">=0.96.0",
|