@savvy-web/silk-effects 0.2.2 → 0.3.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/index.d.ts +316 -5
- package/index.js +475 -66
- package/package.json +3 -3
- package/tsdoc-metadata.json +1 -1
package/index.d.ts
CHANGED
|
@@ -18,15 +18,76 @@ import { Equal } from 'effect';
|
|
|
18
18
|
import { FileSystem } from '@effect/platform';
|
|
19
19
|
import { Hash } from 'effect';
|
|
20
20
|
import { Layer } from 'effect';
|
|
21
|
+
import { Option } from 'effect';
|
|
21
22
|
import { PackageManagerDetector } from 'workspaces-effect';
|
|
22
23
|
import type { PlatformError } from '@effect/platform/Error';
|
|
24
|
+
import { PublishConfig } from 'workspaces-effect';
|
|
23
25
|
import { Schema } from 'effect';
|
|
24
26
|
import type { Stream } from 'effect';
|
|
27
|
+
import { TopologicalSorter } from 'workspaces-effect';
|
|
25
28
|
import { Unify } from 'effect/Unify';
|
|
26
29
|
import { VoidIfEmpty } from 'effect/Types';
|
|
30
|
+
import { WorkspaceDiscovery } from 'workspaces-effect';
|
|
27
31
|
import { WorkspaceRoot } from 'workspaces-effect';
|
|
28
32
|
import { YieldableError } from 'effect/Cause';
|
|
29
33
|
|
|
34
|
+
/**
|
|
35
|
+
* A fully analyzed workspace with publish targets, versioning status,
|
|
36
|
+
* and release group membership.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.2.0
|
|
39
|
+
*/
|
|
40
|
+
export declare class AnalyzedWorkspace extends AnalyzedWorkspace_base {
|
|
41
|
+
get isRoot(): boolean;
|
|
42
|
+
get isPublishable(): boolean;
|
|
43
|
+
get isReleasable(): boolean;
|
|
44
|
+
get isFixed(): boolean;
|
|
45
|
+
get isLinked(): boolean;
|
|
46
|
+
publishesTo(registry: string): boolean;
|
|
47
|
+
hasTarget(shorthand: "npm" | "github" | "jsr"): boolean;
|
|
48
|
+
targetFor(registry: string): Option.Option<ResolvedTarget>;
|
|
49
|
+
[Equal.symbol](that: Equal.Equal): boolean;
|
|
50
|
+
[Hash.symbol](): number;
|
|
51
|
+
toString(): string;
|
|
52
|
+
toJSON(): unknown;
|
|
53
|
+
static publishable(workspaces: ReadonlyArray<AnalyzedWorkspace>): ReadonlyArray<AnalyzedWorkspace>;
|
|
54
|
+
static releasable(workspaces: ReadonlyArray<AnalyzedWorkspace>): ReadonlyArray<AnalyzedWorkspace>;
|
|
55
|
+
static findByName: {
|
|
56
|
+
(name: string): (workspaces: ReadonlyArray<AnalyzedWorkspace>) => Option.Option<AnalyzedWorkspace>;
|
|
57
|
+
(workspaces: ReadonlyArray<AnalyzedWorkspace>, name: string): Option.Option<AnalyzedWorkspace>;
|
|
58
|
+
};
|
|
59
|
+
/** Pretty-print an AnalyzedWorkspace instance. */
|
|
60
|
+
static pretty: (self: AnalyzedWorkspace) => string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare const AnalyzedWorkspace_base: Schema.TaggedClass<AnalyzedWorkspace, "AnalyzedWorkspace", {
|
|
64
|
+
readonly _tag: Schema.tag<"AnalyzedWorkspace">;
|
|
65
|
+
} & {
|
|
66
|
+
name: typeof Schema.String;
|
|
67
|
+
version: Schema.Struct<{
|
|
68
|
+
current: typeof Schema.String;
|
|
69
|
+
}>;
|
|
70
|
+
path: typeof Schema.String;
|
|
71
|
+
root: typeof Schema.Boolean;
|
|
72
|
+
publishConfig: Schema.NullOr<typeof SilkPublishConfig>;
|
|
73
|
+
publishable: typeof Schema.Boolean;
|
|
74
|
+
targets: Schema.Array$<Schema.Struct<{
|
|
75
|
+
protocol: Schema.Literal<["npm", "jsr"]>;
|
|
76
|
+
registry: Schema.NullOr<typeof Schema.String>;
|
|
77
|
+
directory: typeof Schema.String;
|
|
78
|
+
access: Schema.Literal<["public", "restricted"]>;
|
|
79
|
+
provenance: typeof Schema.Boolean;
|
|
80
|
+
tag: typeof Schema.String;
|
|
81
|
+
auth: Schema.Literal<["oidc", "token"]>;
|
|
82
|
+
tokenEnv: Schema.NullOr<typeof Schema.String>;
|
|
83
|
+
}>>;
|
|
84
|
+
versioned: typeof Schema.Boolean;
|
|
85
|
+
tagged: typeof Schema.Boolean;
|
|
86
|
+
released: typeof Schema.Boolean;
|
|
87
|
+
linked: Schema.Array$<Schema.suspend<unknown, unknown, unknown>>;
|
|
88
|
+
fixed: Schema.Array$<Schema.suspend<unknown, unknown, unknown>>;
|
|
89
|
+
}>;
|
|
90
|
+
|
|
30
91
|
/**
|
|
31
92
|
* Authentication strategy used to obtain publish credentials.
|
|
32
93
|
*
|
|
@@ -178,7 +239,7 @@ export declare type BiomeSyncResult = typeof BiomeSyncResult.Type;
|
|
|
178
239
|
export declare function buildSchemaUrl(version: string): string;
|
|
179
240
|
|
|
180
241
|
/**
|
|
181
|
-
* Standard changesets configuration matching the `@changesets/
|
|
242
|
+
* Standard changesets configuration matching the `@changesets/config@3.1.1` spec.
|
|
182
243
|
*
|
|
183
244
|
* @remarks
|
|
184
245
|
* Represents the parsed `.changeset/config.json` file. All fields are optional
|
|
@@ -188,14 +249,25 @@ export declare function buildSchemaUrl(version: string): string;
|
|
|
188
249
|
* @since 0.1.0
|
|
189
250
|
*/
|
|
190
251
|
export declare const ChangesetConfig: Schema.Struct<{
|
|
191
|
-
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
192
|
-
commit: Schema.optional<typeof Schema.Boolean
|
|
252
|
+
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>, Schema.Literal<[false]>]>>;
|
|
253
|
+
commit: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
193
254
|
fixed: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
194
255
|
linked: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
195
256
|
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
196
257
|
baseBranch: Schema.optional<typeof Schema.String>;
|
|
197
258
|
updateInternalDependencies: Schema.optional<Schema.Literal<["patch", "minor", "major"]>>;
|
|
198
259
|
ignore: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
260
|
+
privatePackages: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
261
|
+
tag: Schema.optional<typeof Schema.Boolean>;
|
|
262
|
+
version: Schema.optional<typeof Schema.Boolean>;
|
|
263
|
+
}>, Schema.Literal<[false]>]>>;
|
|
264
|
+
prettier: Schema.optional<typeof Schema.Boolean>;
|
|
265
|
+
changedFilePatterns: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
266
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional<typeof Schema.Boolean>;
|
|
267
|
+
snapshot: Schema.optional<Schema.Struct<{
|
|
268
|
+
useCalculatedVersion: Schema.optional<typeof Schema.Boolean>;
|
|
269
|
+
prereleaseTemplate: Schema.optional<typeof Schema.String>;
|
|
270
|
+
}>>;
|
|
199
271
|
}>;
|
|
200
272
|
|
|
201
273
|
/** @since 0.1.0 */
|
|
@@ -1025,14 +1097,25 @@ declare const ShellSectionDefinition_base: Schema.TaggedClass<ShellSectionDefini
|
|
|
1025
1097
|
* @since 0.1.0
|
|
1026
1098
|
*/
|
|
1027
1099
|
export declare const SilkChangesetConfig: Schema.extend<Schema.Struct<{
|
|
1028
|
-
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
1029
|
-
commit: Schema.optional<typeof Schema.Boolean
|
|
1100
|
+
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>, Schema.Literal<[false]>]>>;
|
|
1101
|
+
commit: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
1030
1102
|
fixed: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
1031
1103
|
linked: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
1032
1104
|
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
1033
1105
|
baseBranch: Schema.optional<typeof Schema.String>;
|
|
1034
1106
|
updateInternalDependencies: Schema.optional<Schema.Literal<["patch", "minor", "major"]>>;
|
|
1035
1107
|
ignore: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
1108
|
+
privatePackages: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
1109
|
+
tag: Schema.optional<typeof Schema.Boolean>;
|
|
1110
|
+
version: Schema.optional<typeof Schema.Boolean>;
|
|
1111
|
+
}>, Schema.Literal<[false]>]>>;
|
|
1112
|
+
prettier: Schema.optional<typeof Schema.Boolean>;
|
|
1113
|
+
changedFilePatterns: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
1114
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional<typeof Schema.Boolean>;
|
|
1115
|
+
snapshot: Schema.optional<Schema.Struct<{
|
|
1116
|
+
useCalculatedVersion: Schema.optional<typeof Schema.Boolean>;
|
|
1117
|
+
prereleaseTemplate: Schema.optional<typeof Schema.String>;
|
|
1118
|
+
}>>;
|
|
1036
1119
|
}>, Schema.Struct<{
|
|
1037
1120
|
_isSilk: Schema.optionalWith<typeof Schema.Boolean, {
|
|
1038
1121
|
default: () => true;
|
|
@@ -1094,6 +1177,128 @@ declare const SilkPublishabilityPlugin_base: Context.TagClass<SilkPublishability
|
|
|
1094
1177
|
*/
|
|
1095
1178
|
export declare const SilkPublishabilityPluginLive: Layer.Layer<SilkPublishabilityPlugin, never, TargetResolver>;
|
|
1096
1179
|
|
|
1180
|
+
/**
|
|
1181
|
+
* Silk-extended publishConfig schema.
|
|
1182
|
+
*
|
|
1183
|
+
* @remarks
|
|
1184
|
+
* Extends the base PublishConfig from workspaces-effect (which covers npm
|
|
1185
|
+
* standard fields: access, registry, directory, tag, linkDirectory) with the
|
|
1186
|
+
* Silk `targets` extension for multi-registry publishing.
|
|
1187
|
+
*
|
|
1188
|
+
* @since 0.2.0
|
|
1189
|
+
*/
|
|
1190
|
+
export declare class SilkPublishConfig extends SilkPublishConfig_base {
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
declare const SilkPublishConfig_base: Schema.Class<SilkPublishConfig, {
|
|
1194
|
+
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
1195
|
+
registry: Schema.optional<typeof Schema.String>;
|
|
1196
|
+
directory: Schema.optional<typeof Schema.String>;
|
|
1197
|
+
tag: Schema.optional<typeof Schema.String>;
|
|
1198
|
+
linkDirectory: Schema.optional<typeof Schema.Boolean>;
|
|
1199
|
+
} & {
|
|
1200
|
+
targets: Schema.optional<Schema.Array$<Schema.Union<[Schema.Literal<["npm", "github", "jsr"]>, Schema.Struct<{
|
|
1201
|
+
protocol: Schema.optionalWith<Schema.Literal<["npm", "jsr"]>, {
|
|
1202
|
+
default: () => "npm";
|
|
1203
|
+
}>;
|
|
1204
|
+
registry: Schema.optional<typeof Schema.String>;
|
|
1205
|
+
directory: Schema.optional<typeof Schema.String>;
|
|
1206
|
+
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
1207
|
+
provenance: Schema.optional<typeof Schema.Boolean>;
|
|
1208
|
+
tag: Schema.optional<typeof Schema.String>;
|
|
1209
|
+
}>]>>>;
|
|
1210
|
+
}, {} & {
|
|
1211
|
+
readonly access?: "public" | "restricted" | undefined;
|
|
1212
|
+
readonly directory?: string | undefined;
|
|
1213
|
+
readonly linkDirectory?: boolean | undefined;
|
|
1214
|
+
readonly registry?: string | undefined;
|
|
1215
|
+
readonly tag?: string | undefined;
|
|
1216
|
+
} & {} & {
|
|
1217
|
+
readonly targets?: readonly ("github" | "jsr" | "npm" | {
|
|
1218
|
+
readonly access?: "public" | "restricted" | undefined;
|
|
1219
|
+
readonly directory?: string | undefined;
|
|
1220
|
+
readonly protocol?: "jsr" | "npm" | undefined;
|
|
1221
|
+
readonly provenance?: boolean | undefined;
|
|
1222
|
+
readonly registry?: string | undefined;
|
|
1223
|
+
readonly tag?: string | undefined;
|
|
1224
|
+
})[] | undefined;
|
|
1225
|
+
}, never, {
|
|
1226
|
+
readonly access?: "public" | "restricted" | undefined;
|
|
1227
|
+
} & {
|
|
1228
|
+
readonly directory?: string | undefined;
|
|
1229
|
+
} & {
|
|
1230
|
+
readonly linkDirectory?: boolean | undefined;
|
|
1231
|
+
} & {
|
|
1232
|
+
readonly registry?: string | undefined;
|
|
1233
|
+
} & {
|
|
1234
|
+
readonly tag?: string | undefined;
|
|
1235
|
+
} & {
|
|
1236
|
+
readonly targets?: readonly ("github" | "jsr" | "npm" | {
|
|
1237
|
+
readonly protocol: "jsr" | "npm";
|
|
1238
|
+
readonly registry?: string | undefined;
|
|
1239
|
+
readonly directory?: string | undefined;
|
|
1240
|
+
readonly access?: "public" | "restricted" | undefined;
|
|
1241
|
+
readonly provenance?: boolean | undefined;
|
|
1242
|
+
readonly tag?: string | undefined;
|
|
1243
|
+
})[] | undefined;
|
|
1244
|
+
}, PublishConfig, {}>;
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Service that performs a full workspace analysis — discovering packages,
|
|
1248
|
+
* detecting publishability, computing versioning/tag strategies, and
|
|
1249
|
+
* wiring up fixed/linked release groups.
|
|
1250
|
+
*
|
|
1251
|
+
* @remarks
|
|
1252
|
+
* Orchestrates {@link WorkspaceDiscovery}, {@link PackageManagerDetector},
|
|
1253
|
+
* {@link SilkPublishabilityPlugin}, {@link ChangesetConfigReader},
|
|
1254
|
+
* {@link VersioningStrategy}, and {@link TagStrategy} to produce a
|
|
1255
|
+
* complete {@link WorkspaceAnalysis} for a given workspace root.
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```typescript
|
|
1259
|
+
* const result = await Effect.runPromise(
|
|
1260
|
+
* Effect.gen(function* () {
|
|
1261
|
+
* const analyzer = yield* SilkWorkspaceAnalyzer;
|
|
1262
|
+
* return yield* analyzer.analyze("/path/to/monorepo");
|
|
1263
|
+
* }).pipe(
|
|
1264
|
+
* Effect.provide(SilkWorkspaceAnalyzerLive),
|
|
1265
|
+
* // ... provide all transitive layers
|
|
1266
|
+
* )
|
|
1267
|
+
* );
|
|
1268
|
+
* ```
|
|
1269
|
+
*
|
|
1270
|
+
* @since 0.2.0
|
|
1271
|
+
*/
|
|
1272
|
+
export declare class SilkWorkspaceAnalyzer extends SilkWorkspaceAnalyzer_base {
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
declare const SilkWorkspaceAnalyzer_base: Context.TagClass<SilkWorkspaceAnalyzer, "@savvy-web/silk-effects/SilkWorkspaceAnalyzer", {
|
|
1276
|
+
/**
|
|
1277
|
+
* Analyze a workspace root and produce a full {@link WorkspaceAnalysis}.
|
|
1278
|
+
*
|
|
1279
|
+
* @param root - Absolute path to the workspace root directory. Must match
|
|
1280
|
+
* the root that the `WorkspaceRoot` layer was initialised with. The analyzer
|
|
1281
|
+
* is single-root by design — build a fresh layer per workspace root.
|
|
1282
|
+
* @returns An `Effect` that succeeds with a {@link WorkspaceAnalysis}, or
|
|
1283
|
+
* fails with {@link WorkspaceAnalysisError}.
|
|
1284
|
+
*
|
|
1285
|
+
* @since 0.2.0
|
|
1286
|
+
*/
|
|
1287
|
+
readonly analyze: (root: string) => Effect.Effect<WorkspaceAnalysis, WorkspaceAnalysisError>;
|
|
1288
|
+
}>;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Live implementation of {@link SilkWorkspaceAnalyzer}.
|
|
1292
|
+
*
|
|
1293
|
+
* @remarks
|
|
1294
|
+
* Requires {@link WorkspaceDiscovery}, {@link PackageManagerDetector},
|
|
1295
|
+
* {@link SilkPublishabilityPlugin}, {@link ChangesetConfigReader},
|
|
1296
|
+
* {@link VersioningStrategy}, and {@link TagStrategy}.
|
|
1297
|
+
*
|
|
1298
|
+
* @since 0.2.0
|
|
1299
|
+
*/
|
|
1300
|
+
export declare const SilkWorkspaceAnalyzerLive: Layer.Layer<SilkWorkspaceAnalyzer, never, FileSystem.FileSystem | WorkspaceDiscovery | TopologicalSorter | PackageManagerDetector | SilkPublishabilityPlugin | ChangesetConfigReader | VersioningStrategy | TagStrategy>;
|
|
1301
|
+
|
|
1097
1302
|
/** @since 0.2.0 */
|
|
1098
1303
|
export declare type SourceRequirement = Data.TaggedEnum<SourceRequirementDefinition>;
|
|
1099
1304
|
|
|
@@ -1782,4 +1987,110 @@ export declare const VersioningStrategyType: Schema.Literal<["single", "fixed-gr
|
|
|
1782
1987
|
/** @since 0.1.0 */
|
|
1783
1988
|
export declare type VersioningStrategyType = typeof VersioningStrategyType.Type;
|
|
1784
1989
|
|
|
1990
|
+
/**
|
|
1991
|
+
* Full workspace analysis result containing all analyzed workspaces
|
|
1992
|
+
* and project-level configuration.
|
|
1993
|
+
*
|
|
1994
|
+
* @since 0.2.0
|
|
1995
|
+
*/
|
|
1996
|
+
export declare class WorkspaceAnalysis extends WorkspaceAnalysis_base {
|
|
1997
|
+
findWorkspace(name: string): Option.Option<AnalyzedWorkspace>;
|
|
1998
|
+
get rootWorkspace(): Option.Option<AnalyzedWorkspace>;
|
|
1999
|
+
get publishableWorkspaces(): ReadonlyArray<AnalyzedWorkspace>;
|
|
2000
|
+
get versionedWorkspaces(): ReadonlyArray<AnalyzedWorkspace>;
|
|
2001
|
+
get taggedWorkspaces(): ReadonlyArray<AnalyzedWorkspace>;
|
|
2002
|
+
get releasableWorkspaces(): ReadonlyArray<AnalyzedWorkspace>;
|
|
2003
|
+
get isSilk(): boolean;
|
|
2004
|
+
get hasChangesets(): boolean;
|
|
2005
|
+
[Equal.symbol](that: Equal.Equal): boolean;
|
|
2006
|
+
[Hash.symbol](): number;
|
|
2007
|
+
toString(): string;
|
|
2008
|
+
/** Pretty-print a WorkspaceAnalysis instance. */
|
|
2009
|
+
static pretty: (self: WorkspaceAnalysis) => string;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
declare const WorkspaceAnalysis_base: Schema.TaggedClass<WorkspaceAnalysis, "WorkspaceAnalysis", {
|
|
2013
|
+
readonly _tag: Schema.tag<"WorkspaceAnalysis">;
|
|
2014
|
+
} & {
|
|
2015
|
+
root: typeof Schema.String;
|
|
2016
|
+
runtime: Schema.Literal<["node", "bun"]>;
|
|
2017
|
+
packageManager: Schema.Struct<{
|
|
2018
|
+
type: Schema.Literal<["npm", "pnpm", "yarn", "bun"]>;
|
|
2019
|
+
version: Schema.optional<typeof Schema.String>;
|
|
2020
|
+
}>;
|
|
2021
|
+
workspaces: Schema.Array$<typeof AnalyzedWorkspace>;
|
|
2022
|
+
changesetConfig: Schema.NullOr<Schema.Union<[Schema.extend<Schema.Struct<{
|
|
2023
|
+
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>, Schema.Literal<[false]>]>>;
|
|
2024
|
+
commit: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
2025
|
+
fixed: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
2026
|
+
linked: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
2027
|
+
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
2028
|
+
baseBranch: Schema.optional<typeof Schema.String>;
|
|
2029
|
+
updateInternalDependencies: Schema.optional<Schema.Literal<["patch", "minor", "major"]>>;
|
|
2030
|
+
ignore: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
2031
|
+
privatePackages: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
2032
|
+
tag: Schema.optional<typeof Schema.Boolean>;
|
|
2033
|
+
version: Schema.optional<typeof Schema.Boolean>;
|
|
2034
|
+
}>, Schema.Literal<[false]>]>>;
|
|
2035
|
+
prettier: Schema.optional<typeof Schema.Boolean>;
|
|
2036
|
+
changedFilePatterns: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
2037
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional<typeof Schema.Boolean>;
|
|
2038
|
+
snapshot: Schema.optional<Schema.Struct<{
|
|
2039
|
+
useCalculatedVersion: Schema.optional<typeof Schema.Boolean>;
|
|
2040
|
+
prereleaseTemplate: Schema.optional<typeof Schema.String>;
|
|
2041
|
+
}>>;
|
|
2042
|
+
}>, Schema.Struct<{
|
|
2043
|
+
_isSilk: Schema.optionalWith<typeof Schema.Boolean, {
|
|
2044
|
+
default: () => true;
|
|
2045
|
+
}>;
|
|
2046
|
+
}>>, Schema.Struct<{
|
|
2047
|
+
changelog: Schema.optional<Schema.Union<[typeof Schema.String, Schema.Array$<typeof Schema.Unknown>, Schema.Literal<[false]>]>>;
|
|
2048
|
+
commit: Schema.optional<Schema.Union<[typeof Schema.Boolean, typeof Schema.String, Schema.Array$<typeof Schema.Unknown>]>>;
|
|
2049
|
+
fixed: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
2050
|
+
linked: Schema.optional<Schema.Array$<Schema.Array$<typeof Schema.String>>>;
|
|
2051
|
+
access: Schema.optional<Schema.Literal<["public", "restricted"]>>;
|
|
2052
|
+
baseBranch: Schema.optional<typeof Schema.String>;
|
|
2053
|
+
updateInternalDependencies: Schema.optional<Schema.Literal<["patch", "minor", "major"]>>;
|
|
2054
|
+
ignore: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
2055
|
+
privatePackages: Schema.optional<Schema.Union<[Schema.Struct<{
|
|
2056
|
+
tag: Schema.optional<typeof Schema.Boolean>;
|
|
2057
|
+
version: Schema.optional<typeof Schema.Boolean>;
|
|
2058
|
+
}>, Schema.Literal<[false]>]>>;
|
|
2059
|
+
prettier: Schema.optional<typeof Schema.Boolean>;
|
|
2060
|
+
changedFilePatterns: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
2061
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional<typeof Schema.Boolean>;
|
|
2062
|
+
snapshot: Schema.optional<Schema.Struct<{
|
|
2063
|
+
useCalculatedVersion: Schema.optional<typeof Schema.Boolean>;
|
|
2064
|
+
prereleaseTemplate: Schema.optional<typeof Schema.String>;
|
|
2065
|
+
}>>;
|
|
2066
|
+
}>]>>;
|
|
2067
|
+
versioning: Schema.NullOr<Schema.Struct<{
|
|
2068
|
+
type: Schema.Literal<["single", "fixed-group", "independent"]>;
|
|
2069
|
+
fixedGroups: Schema.Array$<Schema.Array$<typeof Schema.String>>;
|
|
2070
|
+
publishablePackages: Schema.Array$<typeof Schema.String>;
|
|
2071
|
+
}>>;
|
|
2072
|
+
tagStrategy: Schema.NullOr<Schema.Literal<["single", "scoped"]>>;
|
|
2073
|
+
}>;
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Raised when workspace analysis fails for a given root directory.
|
|
2077
|
+
*
|
|
2078
|
+
* @remarks
|
|
2079
|
+
* Returned by {@link SilkWorkspaceAnalyzer.analyze} when the analysis pipeline
|
|
2080
|
+
* encounters an unrecoverable error — e.g. workspace discovery failure,
|
|
2081
|
+
* package manager detection failure, or publishability detection errors.
|
|
2082
|
+
*
|
|
2083
|
+
* @since 0.2.0
|
|
2084
|
+
*/
|
|
2085
|
+
export declare class WorkspaceAnalysisError extends WorkspaceAnalysisError_base<{
|
|
2086
|
+
readonly root: string;
|
|
2087
|
+
readonly reason: string;
|
|
2088
|
+
}> {
|
|
2089
|
+
get message(): string;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
declare const WorkspaceAnalysisError_base: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & {
|
|
2093
|
+
readonly _tag: "WorkspaceAnalysisError";
|
|
2094
|
+
} & Readonly<A>;
|
|
2095
|
+
|
|
1785
2096
|
export { }
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, TopologicalSorter, WorkspaceDiscovery, WorkspaceRoot } from "workspaces-effect";
|
|
3
4
|
import { parse } from "jsonc-effect";
|
|
4
|
-
import { PackageManagerDetector, WorkspaceRoot } from "workspaces-effect";
|
|
5
5
|
class BiomeSyncError extends Data.TaggedError("BiomeSyncError") {
|
|
6
6
|
get message() {
|
|
7
7
|
return `Failed to sync biome schema in ${this.path}: ${this.reason}`;
|
|
@@ -67,6 +67,11 @@ class VersioningDetectionError extends Data.TaggedError("VersioningDetectionErro
|
|
|
67
67
|
return `Failed to detect versioning strategy: ${this.reason}`;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
class WorkspaceAnalysisError extends Data.TaggedError("WorkspaceAnalysisError") {
|
|
71
|
+
get message() {
|
|
72
|
+
return `Workspace analysis failed at ${this.root}: ${this.reason}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
70
75
|
const PublishProtocol = Schema.Literal("npm", "jsr");
|
|
71
76
|
const AuthStrategy = Schema.Literal("oidc", "token");
|
|
72
77
|
const PublishTargetObject = Schema.Struct({
|
|
@@ -122,9 +127,26 @@ const ToolSource = Schema.Literal("global", "local");
|
|
|
122
127
|
const VersionExtractor = Data.taggedEnum();
|
|
123
128
|
const ResolutionPolicy = Data.taggedEnum();
|
|
124
129
|
const SourceRequirement = Data.taggedEnum();
|
|
125
|
-
|
|
130
|
+
function _to_primitive(input, hint) {
|
|
131
|
+
if ("object" !== _type_of(input) || null === input) return input;
|
|
132
|
+
var prim = input[Symbol.toPrimitive];
|
|
133
|
+
if (void 0 !== prim) {
|
|
134
|
+
var res = prim.call(input, hint || "default");
|
|
135
|
+
if ("object" !== _type_of(res)) return res;
|
|
136
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
137
|
+
}
|
|
138
|
+
return ("string" === hint ? String : Number)(input);
|
|
139
|
+
}
|
|
140
|
+
function _to_property_key(arg) {
|
|
141
|
+
var key = _to_primitive(arg, "string");
|
|
142
|
+
return "symbol" === _type_of(key) ? key : String(key);
|
|
143
|
+
}
|
|
144
|
+
function _type_of(obj) {
|
|
145
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
146
|
+
}
|
|
147
|
+
let _computedKey, _computedKey1;
|
|
126
148
|
const PackageManager = Schema.Literal("npm", "pnpm", "yarn", "bun");
|
|
127
|
-
_computedKey = Equal.symbol, _computedKey1 = Hash.symbol;
|
|
149
|
+
_computedKey = _to_property_key(Equal.symbol), _computedKey1 = _to_property_key(Hash.symbol);
|
|
128
150
|
class ResolvedTool extends Schema.TaggedClass()("ResolvedTool", {
|
|
129
151
|
name: Schema.String,
|
|
130
152
|
source: ToolSource,
|
|
@@ -183,8 +205,25 @@ const CommentStyle = Schema.Literal("#", "//");
|
|
|
183
205
|
const SectionDiff = Data.taggedEnum();
|
|
184
206
|
const SyncResult = Data.taggedEnum();
|
|
185
207
|
const CheckResult = Data.taggedEnum();
|
|
186
|
-
|
|
187
|
-
|
|
208
|
+
function SectionBlock_to_primitive(input, hint) {
|
|
209
|
+
if ("object" !== SectionBlock_type_of(input) || null === input) return input;
|
|
210
|
+
var prim = input[Symbol.toPrimitive];
|
|
211
|
+
if (void 0 !== prim) {
|
|
212
|
+
var res = prim.call(input, hint || "default");
|
|
213
|
+
if ("object" !== SectionBlock_type_of(res)) return res;
|
|
214
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
215
|
+
}
|
|
216
|
+
return ("string" === hint ? String : Number)(input);
|
|
217
|
+
}
|
|
218
|
+
function SectionBlock_to_property_key(arg) {
|
|
219
|
+
var key = SectionBlock_to_primitive(arg, "string");
|
|
220
|
+
return "symbol" === SectionBlock_type_of(key) ? key : String(key);
|
|
221
|
+
}
|
|
222
|
+
function SectionBlock_type_of(obj) {
|
|
223
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
224
|
+
}
|
|
225
|
+
let SectionBlock_computedKey, SectionBlock_computedKey1;
|
|
226
|
+
SectionBlock_computedKey = SectionBlock_to_property_key(Equal.symbol), SectionBlock_computedKey1 = SectionBlock_to_property_key(Hash.symbol);
|
|
188
227
|
class SectionBlock extends Schema.TaggedClass()("SectionBlock", {
|
|
189
228
|
toolName: Schema.String,
|
|
190
229
|
commentStyle: CommentStyle,
|
|
@@ -239,8 +278,25 @@ class SectionBlock extends Schema.TaggedClass()("SectionBlock", {
|
|
|
239
278
|
return Hash.cached(this)(Hash.hash(this.normalized));
|
|
240
279
|
}
|
|
241
280
|
}
|
|
242
|
-
|
|
243
|
-
|
|
281
|
+
function SectionDefinition_to_primitive(input, hint) {
|
|
282
|
+
if ("object" !== SectionDefinition_type_of(input) || null === input) return input;
|
|
283
|
+
var prim = input[Symbol.toPrimitive];
|
|
284
|
+
if (void 0 !== prim) {
|
|
285
|
+
var res = prim.call(input, hint || "default");
|
|
286
|
+
if ("object" !== SectionDefinition_type_of(res)) return res;
|
|
287
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
288
|
+
}
|
|
289
|
+
return ("string" === hint ? String : Number)(input);
|
|
290
|
+
}
|
|
291
|
+
function SectionDefinition_to_property_key(arg) {
|
|
292
|
+
var key = SectionDefinition_to_primitive(arg, "string");
|
|
293
|
+
return "symbol" === SectionDefinition_type_of(key) ? key : String(key);
|
|
294
|
+
}
|
|
295
|
+
function SectionDefinition_type_of(obj) {
|
|
296
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
297
|
+
}
|
|
298
|
+
let SectionDefinition_computedKey, SectionDefinition_computedKey1;
|
|
299
|
+
SectionDefinition_computedKey = SectionDefinition_to_property_key(Equal.symbol), SectionDefinition_computedKey1 = SectionDefinition_to_property_key(Hash.symbol);
|
|
244
300
|
class SectionDefinition extends Schema.TaggedClass()("SectionDefinition", {
|
|
245
301
|
toolName: Schema.String,
|
|
246
302
|
commentStyle: Schema.optionalWith(CommentStyle, {
|
|
@@ -342,11 +398,28 @@ class ShellSectionDefinition extends Schema.TaggedClass()("ShellSectionDefinitio
|
|
|
342
398
|
return `# --- END ${this.toolName.toUpperCase()} MANAGED SECTION ---`;
|
|
343
399
|
}
|
|
344
400
|
}
|
|
345
|
-
|
|
401
|
+
function ToolDefinition_to_primitive(input, hint) {
|
|
402
|
+
if ("object" !== ToolDefinition_type_of(input) || null === input) return input;
|
|
403
|
+
var prim = input[Symbol.toPrimitive];
|
|
404
|
+
if (void 0 !== prim) {
|
|
405
|
+
var res = prim.call(input, hint || "default");
|
|
406
|
+
if ("object" !== ToolDefinition_type_of(res)) return res;
|
|
407
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
408
|
+
}
|
|
409
|
+
return ("string" === hint ? String : Number)(input);
|
|
410
|
+
}
|
|
411
|
+
function ToolDefinition_to_property_key(arg) {
|
|
412
|
+
var key = ToolDefinition_to_primitive(arg, "string");
|
|
413
|
+
return "symbol" === ToolDefinition_type_of(key) ? key : String(key);
|
|
414
|
+
}
|
|
415
|
+
function ToolDefinition_type_of(obj) {
|
|
416
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
417
|
+
}
|
|
418
|
+
let ToolDefinition_computedKey, ToolDefinition_computedKey1;
|
|
346
419
|
const NameSchema = Schema.Struct({
|
|
347
420
|
name: Schema.String
|
|
348
421
|
});
|
|
349
|
-
ToolDefinition_computedKey = Equal.symbol, ToolDefinition_computedKey1 = Hash.symbol;
|
|
422
|
+
ToolDefinition_computedKey = ToolDefinition_to_property_key(Equal.symbol), ToolDefinition_computedKey1 = ToolDefinition_to_property_key(Hash.symbol);
|
|
350
423
|
class ToolDefinition {
|
|
351
424
|
_tag = "ToolDefinition";
|
|
352
425
|
name;
|
|
@@ -375,6 +448,204 @@ class ToolDefinition {
|
|
|
375
448
|
return Hash.cached(this)(Hash.hash(this.name));
|
|
376
449
|
}
|
|
377
450
|
}
|
|
451
|
+
const TagStrategyType = Schema.Literal("single", "scoped");
|
|
452
|
+
const PrivatePackagesConfig = Schema.Union(Schema.Struct({
|
|
453
|
+
tag: Schema.optional(Schema.Boolean),
|
|
454
|
+
version: Schema.optional(Schema.Boolean)
|
|
455
|
+
}), Schema.Literal(false));
|
|
456
|
+
const SnapshotConfig = Schema.Struct({
|
|
457
|
+
useCalculatedVersion: Schema.optional(Schema.Boolean),
|
|
458
|
+
prereleaseTemplate: Schema.optional(Schema.String)
|
|
459
|
+
});
|
|
460
|
+
const ChangesetConfig = Schema.Struct({
|
|
461
|
+
changelog: Schema.optional(Schema.Union(Schema.String, Schema.Array(Schema.Unknown), Schema.Literal(false))),
|
|
462
|
+
commit: Schema.optional(Schema.Union(Schema.Boolean, Schema.String, Schema.Array(Schema.Unknown))),
|
|
463
|
+
fixed: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
464
|
+
linked: Schema.optional(Schema.Array(Schema.Array(Schema.String))),
|
|
465
|
+
access: Schema.optional(Schema.Literal("public", "restricted")),
|
|
466
|
+
baseBranch: Schema.optional(Schema.String),
|
|
467
|
+
updateInternalDependencies: Schema.optional(Schema.Literal("patch", "minor", "major")),
|
|
468
|
+
ignore: Schema.optional(Schema.Array(Schema.String)),
|
|
469
|
+
privatePackages: Schema.optional(PrivatePackagesConfig),
|
|
470
|
+
prettier: Schema.optional(Schema.Boolean),
|
|
471
|
+
changedFilePatterns: Schema.optional(Schema.Array(Schema.String)),
|
|
472
|
+
bumpVersionsWithWorkspaceProtocolOnly: Schema.optional(Schema.Boolean),
|
|
473
|
+
snapshot: Schema.optional(SnapshotConfig)
|
|
474
|
+
});
|
|
475
|
+
const SilkChangesetConfig = Schema.extend(ChangesetConfig, Schema.Struct({
|
|
476
|
+
_isSilk: Schema.optionalWith(Schema.Boolean, {
|
|
477
|
+
default: ()=>true
|
|
478
|
+
})
|
|
479
|
+
}));
|
|
480
|
+
const VersioningStrategyType = Schema.Literal("single", "fixed-group", "independent");
|
|
481
|
+
const VersioningStrategyResult = Schema.Struct({
|
|
482
|
+
type: VersioningStrategyType,
|
|
483
|
+
fixedGroups: Schema.Array(Schema.Array(Schema.String)),
|
|
484
|
+
publishablePackages: Schema.Array(Schema.String)
|
|
485
|
+
});
|
|
486
|
+
function WorkspaceAnalysisSchemas_to_primitive(input, hint) {
|
|
487
|
+
if ("object" !== WorkspaceAnalysisSchemas_type_of(input) || null === input) return input;
|
|
488
|
+
var prim = input[Symbol.toPrimitive];
|
|
489
|
+
if (void 0 !== prim) {
|
|
490
|
+
var res = prim.call(input, hint || "default");
|
|
491
|
+
if ("object" !== WorkspaceAnalysisSchemas_type_of(res)) return res;
|
|
492
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
493
|
+
}
|
|
494
|
+
return ("string" === hint ? String : Number)(input);
|
|
495
|
+
}
|
|
496
|
+
function WorkspaceAnalysisSchemas_to_property_key(arg) {
|
|
497
|
+
var key = WorkspaceAnalysisSchemas_to_primitive(arg, "string");
|
|
498
|
+
return "symbol" === WorkspaceAnalysisSchemas_type_of(key) ? key : String(key);
|
|
499
|
+
}
|
|
500
|
+
function WorkspaceAnalysisSchemas_type_of(obj) {
|
|
501
|
+
return obj && "u" > typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
502
|
+
}
|
|
503
|
+
let WorkspaceAnalysisSchemas_computedKey, WorkspaceAnalysisSchemas_computedKey1, _computedKey2, _computedKey3;
|
|
504
|
+
class SilkPublishConfig extends PublishConfig.extend("SilkPublishConfig")({
|
|
505
|
+
targets: Schema.optional(Schema.Array(Schema.Union(PublishTargetShorthand, PublishTargetObject)))
|
|
506
|
+
}) {
|
|
507
|
+
}
|
|
508
|
+
const KNOWN_REGISTRIES = {
|
|
509
|
+
npm: "https://registry.npmjs.org/",
|
|
510
|
+
github: "https://npm.pkg.github.com/"
|
|
511
|
+
};
|
|
512
|
+
const WorkspaceVersion = Schema.Struct({
|
|
513
|
+
current: Schema.String
|
|
514
|
+
});
|
|
515
|
+
WorkspaceAnalysisSchemas_computedKey = WorkspaceAnalysisSchemas_to_property_key(Equal.symbol), WorkspaceAnalysisSchemas_computedKey1 = WorkspaceAnalysisSchemas_to_property_key(Hash.symbol);
|
|
516
|
+
class AnalyzedWorkspace extends Schema.TaggedClass()("AnalyzedWorkspace", {
|
|
517
|
+
name: Schema.String,
|
|
518
|
+
version: WorkspaceVersion,
|
|
519
|
+
path: Schema.String,
|
|
520
|
+
root: Schema.Boolean,
|
|
521
|
+
publishConfig: Schema.NullOr(SilkPublishConfig),
|
|
522
|
+
publishable: Schema.Boolean,
|
|
523
|
+
targets: Schema.Array(ResolvedTarget),
|
|
524
|
+
versioned: Schema.Boolean,
|
|
525
|
+
tagged: Schema.Boolean,
|
|
526
|
+
released: Schema.Boolean,
|
|
527
|
+
linked: Schema.Array(Schema.suspend(()=>AnalyzedWorkspace)),
|
|
528
|
+
fixed: Schema.Array(Schema.suspend(()=>AnalyzedWorkspace))
|
|
529
|
+
}) {
|
|
530
|
+
get isRoot() {
|
|
531
|
+
return this.root;
|
|
532
|
+
}
|
|
533
|
+
get isPublishable() {
|
|
534
|
+
return this.publishable;
|
|
535
|
+
}
|
|
536
|
+
get isReleasable() {
|
|
537
|
+
return this.released;
|
|
538
|
+
}
|
|
539
|
+
get isFixed() {
|
|
540
|
+
return this.fixed.length > 0;
|
|
541
|
+
}
|
|
542
|
+
get isLinked() {
|
|
543
|
+
return this.linked.length > 0;
|
|
544
|
+
}
|
|
545
|
+
publishesTo(registry) {
|
|
546
|
+
return this.targets.some((t)=>t.registry === registry);
|
|
547
|
+
}
|
|
548
|
+
hasTarget(shorthand) {
|
|
549
|
+
if ("jsr" === shorthand) return this.targets.some((t)=>"jsr" === t.protocol);
|
|
550
|
+
const registry = KNOWN_REGISTRIES[shorthand];
|
|
551
|
+
return void 0 !== registry && this.publishesTo(registry);
|
|
552
|
+
}
|
|
553
|
+
targetFor(registry) {
|
|
554
|
+
const found = this.targets.find((t)=>t.registry === registry);
|
|
555
|
+
return found ? Option.some(found) : Option.none();
|
|
556
|
+
}
|
|
557
|
+
[WorkspaceAnalysisSchemas_computedKey](that) {
|
|
558
|
+
if (!(that instanceof AnalyzedWorkspace)) return false;
|
|
559
|
+
return this.name === that.name && this.path === that.path;
|
|
560
|
+
}
|
|
561
|
+
[WorkspaceAnalysisSchemas_computedKey1]() {
|
|
562
|
+
return Hash.cached(this)(Hash.combine(Hash.hash(this.name))(Hash.hash(this.path)));
|
|
563
|
+
}
|
|
564
|
+
toString() {
|
|
565
|
+
return `${this.name}@${this.version.current}`;
|
|
566
|
+
}
|
|
567
|
+
toJSON() {
|
|
568
|
+
return {
|
|
569
|
+
_tag: "AnalyzedWorkspace",
|
|
570
|
+
name: this.name,
|
|
571
|
+
version: this.version,
|
|
572
|
+
path: this.path,
|
|
573
|
+
root: this.root,
|
|
574
|
+
publishable: this.publishable,
|
|
575
|
+
targets: this.targets,
|
|
576
|
+
versioned: this.versioned,
|
|
577
|
+
tagged: this.tagged,
|
|
578
|
+
released: this.released
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
static publishable(workspaces) {
|
|
582
|
+
return workspaces.filter((w)=>w.publishable);
|
|
583
|
+
}
|
|
584
|
+
static releasable(workspaces) {
|
|
585
|
+
return workspaces.filter((w)=>w.released);
|
|
586
|
+
}
|
|
587
|
+
static findByName;
|
|
588
|
+
static pretty;
|
|
589
|
+
}
|
|
590
|
+
AnalyzedWorkspace.findByName = Function.dual(2, (workspaces, name)=>{
|
|
591
|
+
const found = workspaces.find((w)=>w.name === name);
|
|
592
|
+
return found ? Option.some(found) : Option.none();
|
|
593
|
+
});
|
|
594
|
+
AnalyzedWorkspace.pretty = Pretty.make(AnalyzedWorkspace);
|
|
595
|
+
const PackageManagerInfo = Schema.Struct({
|
|
596
|
+
type: Schema.Literal("npm", "pnpm", "yarn", "bun"),
|
|
597
|
+
version: Schema.optional(Schema.String)
|
|
598
|
+
});
|
|
599
|
+
_computedKey2 = WorkspaceAnalysisSchemas_to_property_key(Equal.symbol), _computedKey3 = WorkspaceAnalysisSchemas_to_property_key(Hash.symbol);
|
|
600
|
+
class WorkspaceAnalysis extends Schema.TaggedClass()("WorkspaceAnalysis", {
|
|
601
|
+
root: Schema.String,
|
|
602
|
+
runtime: Schema.Literal("node", "bun"),
|
|
603
|
+
packageManager: PackageManagerInfo,
|
|
604
|
+
workspaces: Schema.Array(AnalyzedWorkspace),
|
|
605
|
+
changesetConfig: Schema.NullOr(Schema.Union(SilkChangesetConfig, ChangesetConfig)),
|
|
606
|
+
versioning: Schema.NullOr(VersioningStrategyResult),
|
|
607
|
+
tagStrategy: Schema.NullOr(TagStrategyType)
|
|
608
|
+
}) {
|
|
609
|
+
findWorkspace(name) {
|
|
610
|
+
const found = this.workspaces.find((w)=>w.name === name);
|
|
611
|
+
return found ? Option.some(found) : Option.none();
|
|
612
|
+
}
|
|
613
|
+
get rootWorkspace() {
|
|
614
|
+
const root = this.workspaces.find((w)=>w.root);
|
|
615
|
+
return root ? Option.some(root) : Option.none();
|
|
616
|
+
}
|
|
617
|
+
get publishableWorkspaces() {
|
|
618
|
+
return this.workspaces.filter((w)=>w.publishable);
|
|
619
|
+
}
|
|
620
|
+
get versionedWorkspaces() {
|
|
621
|
+
return this.workspaces.filter((w)=>w.versioned);
|
|
622
|
+
}
|
|
623
|
+
get taggedWorkspaces() {
|
|
624
|
+
return this.workspaces.filter((w)=>w.tagged);
|
|
625
|
+
}
|
|
626
|
+
get releasableWorkspaces() {
|
|
627
|
+
return this.workspaces.filter((w)=>w.released);
|
|
628
|
+
}
|
|
629
|
+
get isSilk() {
|
|
630
|
+
if (null == this.changesetConfig) return false;
|
|
631
|
+
return "_isSilk" in this.changesetConfig && true === this.changesetConfig._isSilk;
|
|
632
|
+
}
|
|
633
|
+
get hasChangesets() {
|
|
634
|
+
return null != this.changesetConfig;
|
|
635
|
+
}
|
|
636
|
+
[_computedKey2](that) {
|
|
637
|
+
if (!(that instanceof WorkspaceAnalysis)) return false;
|
|
638
|
+
return this.root === that.root;
|
|
639
|
+
}
|
|
640
|
+
[_computedKey3]() {
|
|
641
|
+
return Hash.cached(this)(Hash.hash(this.root));
|
|
642
|
+
}
|
|
643
|
+
toString() {
|
|
644
|
+
return `WorkspaceAnalysis(${this.root}, ${this.workspaces.length} workspaces)`;
|
|
645
|
+
}
|
|
646
|
+
static pretty;
|
|
647
|
+
}
|
|
648
|
+
WorkspaceAnalysis.pretty = Pretty.make(WorkspaceAnalysis);
|
|
378
649
|
function extractSemver(version) {
|
|
379
650
|
return version.replace(/^[\^~>=<v]+/, "");
|
|
380
651
|
}
|
|
@@ -450,27 +721,6 @@ const BiomeSchemaSyncLive = Layer.effect(BiomeSchemaSync, Effect.gen(function*()
|
|
|
450
721
|
check: (version, options)=>run(version, options, false)
|
|
451
722
|
};
|
|
452
723
|
}));
|
|
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
724
|
const SILK_CHANGELOG_MARKER = "@savvy-web/changesets";
|
|
475
725
|
function isSilkChangelog(changelog) {
|
|
476
726
|
if ("string" == typeof changelog) return changelog.includes(SILK_CHANGELOG_MARKER);
|
|
@@ -799,6 +1049,199 @@ const TagStrategyLive = Layer.succeed(TagStrategy, TagStrategy.of({
|
|
|
799
1049
|
return Effect.succeed(`${name}@${version}`);
|
|
800
1050
|
}
|
|
801
1051
|
}));
|
|
1052
|
+
class VersioningStrategy extends Context.Tag("@savvy-web/silk-effects/VersioningStrategy")() {
|
|
1053
|
+
}
|
|
1054
|
+
const VersioningStrategyLive = Layer.effect(VersioningStrategy, Effect.gen(function*() {
|
|
1055
|
+
const configReader = yield* ChangesetConfigReader;
|
|
1056
|
+
const detect = (publishablePackages, root)=>Effect.gen(function*() {
|
|
1057
|
+
const config = yield* configReader.read(root).pipe(Effect.orElseSucceed(()=>({
|
|
1058
|
+
fixed: [],
|
|
1059
|
+
linked: []
|
|
1060
|
+
})));
|
|
1061
|
+
const fixed = config.fixed ?? [];
|
|
1062
|
+
const packages = [
|
|
1063
|
+
...publishablePackages
|
|
1064
|
+
];
|
|
1065
|
+
if (packages.length <= 1) return {
|
|
1066
|
+
type: "single",
|
|
1067
|
+
fixedGroups: fixed,
|
|
1068
|
+
publishablePackages: packages
|
|
1069
|
+
};
|
|
1070
|
+
const containingGroup = fixed.find((group)=>packages.every((pkg)=>group.includes(pkg)));
|
|
1071
|
+
if (void 0 !== containingGroup) return {
|
|
1072
|
+
type: "fixed-group",
|
|
1073
|
+
fixedGroups: fixed,
|
|
1074
|
+
publishablePackages: packages
|
|
1075
|
+
};
|
|
1076
|
+
return {
|
|
1077
|
+
type: "independent",
|
|
1078
|
+
fixedGroups: fixed,
|
|
1079
|
+
publishablePackages: packages
|
|
1080
|
+
};
|
|
1081
|
+
});
|
|
1082
|
+
return {
|
|
1083
|
+
detect
|
|
1084
|
+
};
|
|
1085
|
+
}));
|
|
1086
|
+
class SilkWorkspaceAnalyzer extends Context.Tag("@savvy-web/silk-effects/SilkWorkspaceAnalyzer")() {
|
|
1087
|
+
}
|
|
1088
|
+
const readRawPkgJson = (fs, packageJsonPath)=>fs.readFileString(packageJsonPath).pipe(Effect.flatMap((content)=>Effect["try"]({
|
|
1089
|
+
try: ()=>JSON.parse(content),
|
|
1090
|
+
catch: ()=>new WorkspaceAnalysisError({
|
|
1091
|
+
root: packageJsonPath,
|
|
1092
|
+
reason: "Invalid JSON in package.json"
|
|
1093
|
+
})
|
|
1094
|
+
})), Effect.mapError((err)=>err instanceof WorkspaceAnalysisError ? err : new WorkspaceAnalysisError({
|
|
1095
|
+
root: packageJsonPath,
|
|
1096
|
+
reason: `Failed to read package.json: ${String(err)}`
|
|
1097
|
+
})));
|
|
1098
|
+
function computeReleaseStatus(pkgName, isPrivate, isPublishable, config) {
|
|
1099
|
+
if (null == config) return {
|
|
1100
|
+
versioned: false,
|
|
1101
|
+
tagged: false,
|
|
1102
|
+
released: false
|
|
1103
|
+
};
|
|
1104
|
+
if (config.ignore?.includes(pkgName)) return {
|
|
1105
|
+
versioned: false,
|
|
1106
|
+
tagged: false,
|
|
1107
|
+
released: false
|
|
1108
|
+
};
|
|
1109
|
+
if (!isPrivate || isPublishable) return {
|
|
1110
|
+
versioned: true,
|
|
1111
|
+
tagged: true,
|
|
1112
|
+
released: true
|
|
1113
|
+
};
|
|
1114
|
+
const pp = config.privatePackages;
|
|
1115
|
+
if (void 0 === pp) return {
|
|
1116
|
+
versioned: false,
|
|
1117
|
+
tagged: false,
|
|
1118
|
+
released: false
|
|
1119
|
+
};
|
|
1120
|
+
if (false === pp) return {
|
|
1121
|
+
versioned: false,
|
|
1122
|
+
tagged: false,
|
|
1123
|
+
released: false
|
|
1124
|
+
};
|
|
1125
|
+
const versioned = true === pp.version;
|
|
1126
|
+
const tagged = true === pp.tag;
|
|
1127
|
+
const released = versioned && tagged;
|
|
1128
|
+
return {
|
|
1129
|
+
versioned,
|
|
1130
|
+
tagged,
|
|
1131
|
+
released
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
const SilkWorkspaceAnalyzerLive = Layer.effect(SilkWorkspaceAnalyzer, Effect.gen(function*() {
|
|
1135
|
+
const fs = yield* FileSystem.FileSystem;
|
|
1136
|
+
const discovery = yield* WorkspaceDiscovery;
|
|
1137
|
+
const sorter = yield* TopologicalSorter;
|
|
1138
|
+
const pmDetector = yield* PackageManagerDetector;
|
|
1139
|
+
const publishability = yield* SilkPublishabilityPlugin;
|
|
1140
|
+
const configReader = yield* ChangesetConfigReader;
|
|
1141
|
+
const versioningStrategy = yield* VersioningStrategy;
|
|
1142
|
+
const tagStrategy = yield* TagStrategy;
|
|
1143
|
+
const analyze = (root)=>Effect.gen(function*() {
|
|
1144
|
+
const pm = yield* pmDetector.detect(root).pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1145
|
+
root,
|
|
1146
|
+
reason: `Package manager detection failed: ${String(err)}`
|
|
1147
|
+
})));
|
|
1148
|
+
const packages = yield* discovery.listPackages().pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1149
|
+
root,
|
|
1150
|
+
reason: `Workspace discovery failed: ${String(err)}`
|
|
1151
|
+
})));
|
|
1152
|
+
const topoOrder = yield* sorter.sort().pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1153
|
+
root,
|
|
1154
|
+
reason: `Cyclic dependency detected: ${String(err)}`
|
|
1155
|
+
})));
|
|
1156
|
+
const packagesByName = new Map(packages.map((p)=>[
|
|
1157
|
+
p.name,
|
|
1158
|
+
p
|
|
1159
|
+
]));
|
|
1160
|
+
const sortedPackages = topoOrder.flatMap((name)=>{
|
|
1161
|
+
const pkg = packagesByName.get(name);
|
|
1162
|
+
return pkg ? [
|
|
1163
|
+
pkg
|
|
1164
|
+
] : [];
|
|
1165
|
+
});
|
|
1166
|
+
const changesetConfigOption = yield* configReader.read(root).pipe(Effect.option);
|
|
1167
|
+
const changesetConfig = Option.getOrNull(changesetConfigOption);
|
|
1168
|
+
const analyzedWorkspaces = [];
|
|
1169
|
+
for (const pkg of sortedPackages){
|
|
1170
|
+
const pkgJson = yield* readRawPkgJson(fs, pkg.packageJsonPath);
|
|
1171
|
+
const targets = yield* publishability.detect(pkgJson).pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1172
|
+
root,
|
|
1173
|
+
reason: `Publishability detection failed for ${pkg.name}: ${String(err)}`
|
|
1174
|
+
})));
|
|
1175
|
+
const isPublishable = targets.length > 0;
|
|
1176
|
+
const isRoot = "." === pkg.relativePath;
|
|
1177
|
+
const { versioned, tagged, released } = computeReleaseStatus(pkg.name, pkg.private, isPublishable, changesetConfig);
|
|
1178
|
+
const analyzed = new AnalyzedWorkspace({
|
|
1179
|
+
name: pkg.name,
|
|
1180
|
+
version: {
|
|
1181
|
+
current: pkg.version
|
|
1182
|
+
},
|
|
1183
|
+
path: pkg.path,
|
|
1184
|
+
root: isRoot,
|
|
1185
|
+
publishConfig: null,
|
|
1186
|
+
publishable: isPublishable,
|
|
1187
|
+
targets: [
|
|
1188
|
+
...targets
|
|
1189
|
+
],
|
|
1190
|
+
versioned,
|
|
1191
|
+
tagged,
|
|
1192
|
+
released,
|
|
1193
|
+
linked: [],
|
|
1194
|
+
fixed: []
|
|
1195
|
+
});
|
|
1196
|
+
analyzedWorkspaces.push(analyzed);
|
|
1197
|
+
}
|
|
1198
|
+
if (changesetConfig) {
|
|
1199
|
+
const fixedGroups = changesetConfig.fixed ?? [];
|
|
1200
|
+
const linkedGroups = changesetConfig.linked ?? [];
|
|
1201
|
+
const fixedByName = new Map();
|
|
1202
|
+
for (const group of fixedGroups){
|
|
1203
|
+
const members = analyzedWorkspaces.filter((w)=>group.includes(w.name));
|
|
1204
|
+
for (const member of members)fixedByName.set(member.name, members.filter((m)=>m !== member));
|
|
1205
|
+
}
|
|
1206
|
+
const linkedByName = new Map();
|
|
1207
|
+
for (const group of linkedGroups){
|
|
1208
|
+
const members = analyzedWorkspaces.filter((w)=>group.includes(w.name));
|
|
1209
|
+
for (const member of members)linkedByName.set(member.name, members.filter((m)=>m !== member));
|
|
1210
|
+
}
|
|
1211
|
+
for(let i = 0; i < analyzedWorkspaces.length; i++){
|
|
1212
|
+
const ws = analyzedWorkspaces[i];
|
|
1213
|
+
const fixedRefs = fixedByName.get(ws.name) ?? [];
|
|
1214
|
+
const linkedRefs = linkedByName.get(ws.name) ?? [];
|
|
1215
|
+
if (fixedRefs.length > 0 || linkedRefs.length > 0) analyzedWorkspaces[i] = new AnalyzedWorkspace({
|
|
1216
|
+
...ws,
|
|
1217
|
+
fixed: fixedRefs,
|
|
1218
|
+
linked: linkedRefs
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
const publishableNames = analyzedWorkspaces.filter((w)=>w.publishable).map((w)=>w.name);
|
|
1223
|
+
const versioning = yield* versioningStrategy.detect(publishableNames, root).pipe(Effect.mapError((err)=>new WorkspaceAnalysisError({
|
|
1224
|
+
root,
|
|
1225
|
+
reason: `Versioning strategy detection failed: ${String(err)}`
|
|
1226
|
+
})));
|
|
1227
|
+
const tagStrategyType = yield* tagStrategy.determine(versioning);
|
|
1228
|
+
return new WorkspaceAnalysis({
|
|
1229
|
+
root,
|
|
1230
|
+
runtime: pm.runtime,
|
|
1231
|
+
packageManager: {
|
|
1232
|
+
type: pm.type,
|
|
1233
|
+
version: pm.version
|
|
1234
|
+
},
|
|
1235
|
+
workspaces: analyzedWorkspaces,
|
|
1236
|
+
changesetConfig,
|
|
1237
|
+
versioning,
|
|
1238
|
+
tagStrategy: tagStrategyType
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
return {
|
|
1242
|
+
analyze
|
|
1243
|
+
};
|
|
1244
|
+
}));
|
|
802
1245
|
class ToolDiscovery extends Context.Tag("@savvy-web/silk-effects/ToolDiscovery")() {
|
|
803
1246
|
}
|
|
804
1247
|
function pmExecArgs(pmType, name) {
|
|
@@ -986,38 +1429,4 @@ const ToolDiscoveryLive = Layer.effect(ToolDiscovery, Effect.gen(function*() {
|
|
|
986
1429
|
clearCache
|
|
987
1430
|
};
|
|
988
1431
|
}));
|
|
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 };
|
|
1432
|
+
export { AnalyzedWorkspace, 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, SilkPublishConfig, SilkPublishabilityPlugin, SilkPublishabilityPluginLive, SilkWorkspaceAnalyzer, SilkWorkspaceAnalyzerLive, SourceRequirement, SyncResult, TagFormatError, TagStrategy, TagStrategyLive, TargetResolutionError, TargetResolver, TargetResolverLive, 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.3.0",
|
|
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",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@effect/platform": "^0.96.0",
|
|
31
30
|
"jsonc-effect": "^0.2.1",
|
|
32
31
|
"semver-effect": "^0.2.1",
|
|
33
|
-
"workspaces-effect": "^0.
|
|
32
|
+
"workspaces-effect": "^0.4.1",
|
|
34
33
|
"yaml-effect": "^0.2.3"
|
|
35
34
|
},
|
|
36
35
|
"peerDependencies": {
|
|
36
|
+
"@effect/platform": ">=0.96.0",
|
|
37
37
|
"effect": ">=3.21.0"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|