@savvy-web/changesets 0.1.2 → 0.2.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 +19 -0
- package/cjs/changelog.cjs +18 -1
- package/cjs/index.cjs +46 -3
- package/cjs/index.d.cts +72 -0
- package/esm/160.js +4 -38
- package/esm/273.js +3 -3
- package/esm/795.js +56 -0
- package/esm/bin/savvy-changesets.js +276 -10
- package/esm/index.d.ts +72 -0
- package/esm/index.js +3 -2
- package/package.json +4 -2
- package/esm/245.js +0 -5
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Custom changelog formatter and markdown processing pipeline for the Silk Suite.
|
|
|
12
12
|
- **13 section categories** -- Consistent categorization with priority-based ordering across all layers
|
|
13
13
|
- **CLI tooling** -- `savvy-changesets` binary with init, lint, transform, check, and version subcommands for CI and local use
|
|
14
14
|
- **GitHub integration** -- Automatic PR links, commit references, and contributor attribution
|
|
15
|
+
- **Version file syncing** -- Bump version fields in additional JSON files (beyond `package.json`) using glob patterns and JSONPath expressions
|
|
15
16
|
- **Remark plugins** -- Lint rules and transform plugins via `@savvy-web/changesets/remark`
|
|
16
17
|
- **markdownlint rules** -- Custom rules compatible with [markdownlint-cli2](https://www.npmjs.com/package/markdownlint-cli2) and the VS Code extension via `@savvy-web/changesets/markdownlint`
|
|
17
18
|
|
|
@@ -57,6 +58,24 @@ Added a new authentication system with OAuth2 support.
|
|
|
57
58
|
- Updated integration test fixtures
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
## Version File Syncing
|
|
62
|
+
|
|
63
|
+
If your project has JSON files beyond `package.json` that contain version fields (e.g., `plugin.json`, `marketplace.json`), add `versionFiles` to your changelog options to keep them in sync during `changeset version`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"changelog": ["@savvy-web/changesets/changelog", {
|
|
68
|
+
"repo": "owner/repo",
|
|
69
|
+
"versionFiles": [
|
|
70
|
+
{ "glob": "plugin.json" },
|
|
71
|
+
{ "glob": ".claude-plugin/marketplace.json", "paths": ["$.metadata.version", "$.plugins[*].version"] }
|
|
72
|
+
]
|
|
73
|
+
}]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
When `paths` is omitted it defaults to `["$.version"]`. In monorepos, each matched file inherits the version from its nearest workspace package. See [Configuration -- versionFiles](./docs/configuration.md#versionfiles-optional) for full details including supported JSONPath syntax.
|
|
78
|
+
|
|
60
79
|
## markdownlint Integration
|
|
61
80
|
|
|
62
81
|
Register the custom rules in your base config (e.g., `lib/configs/.markdownlint-cli2.jsonc`):
|
package/cjs/changelog.cjs
CHANGED
|
@@ -163,6 +163,7 @@ var __webpack_modules__ = {
|
|
|
163
163
|
return `Configuration error (${this.field}): ${this.reason}`;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
effect__rspack_import_0.Data.TaggedError("VersionFileError");
|
|
166
167
|
},
|
|
167
168
|
"./src/schemas/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
168
169
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -209,6 +210,7 @@ var __webpack_modules__ = {
|
|
|
209
210
|
});
|
|
210
211
|
var effect__rspack_import_0 = __webpack_require__("effect");
|
|
211
212
|
var _errors_js__rspack_import_1 = __webpack_require__("./src/errors.ts");
|
|
213
|
+
var _version_files_js__rspack_import_2 = __webpack_require__("./src/schemas/version-files.ts");
|
|
212
214
|
const REPO_PATTERN = /^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/;
|
|
213
215
|
const RepoSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(REPO_PATTERN, {
|
|
214
216
|
message: ()=>'Repository must be in format "owner/repository" (e.g., "microsoft/vscode")'
|
|
@@ -218,7 +220,8 @@ var __webpack_modules__ = {
|
|
|
218
220
|
commitLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
219
221
|
prLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
220
222
|
issueLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
221
|
-
issuePrefixes: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(effect__rspack_import_0.Schema.String))
|
|
223
|
+
issuePrefixes: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(effect__rspack_import_0.Schema.String)),
|
|
224
|
+
versionFiles: effect__rspack_import_0.Schema.optional(_version_files_js__rspack_import_2.Hh)
|
|
222
225
|
});
|
|
223
226
|
function validateChangesetOptions(input) {
|
|
224
227
|
if (null == input) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
|
|
@@ -252,6 +255,20 @@ var __webpack_modules__ = {
|
|
|
252
255
|
effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.minLength(1));
|
|
253
256
|
const PositiveInteger = effect__rspack_import_0.Schema.Number.pipe(effect__rspack_import_0.Schema.int(), effect__rspack_import_0.Schema.positive());
|
|
254
257
|
},
|
|
258
|
+
"./src/schemas/version-files.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
259
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
260
|
+
Hh: ()=>VersionFilesSchema
|
|
261
|
+
});
|
|
262
|
+
var effect__rspack_import_0 = __webpack_require__("effect");
|
|
263
|
+
const JsonPathSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(/^\$\.[^.]/, {
|
|
264
|
+
message: ()=>'JSONPath must start with "$." followed by a property (e.g., "$.version", "$.metadata.version")'
|
|
265
|
+
}));
|
|
266
|
+
const VersionFileConfigSchema = effect__rspack_import_0.Schema.Struct({
|
|
267
|
+
glob: effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.minLength(1)),
|
|
268
|
+
paths: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(JsonPathSchema))
|
|
269
|
+
});
|
|
270
|
+
const VersionFilesSchema = effect__rspack_import_0.Schema.Array(VersionFileConfigSchema);
|
|
271
|
+
},
|
|
255
272
|
"./src/services/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
256
273
|
__webpack_require__.d(__webpack_exports__, {
|
|
257
274
|
Xx: ()=>GitHubService,
|
package/cjs/index.cjs
CHANGED
|
@@ -421,7 +421,9 @@ var __webpack_modules__ = {
|
|
|
421
421
|
TZ: ()=>GitHubApiErrorBase,
|
|
422
422
|
W4: ()=>ConfigurationErrorBase,
|
|
423
423
|
hL: ()=>ChangesetValidationErrorBase,
|
|
424
|
+
iS: ()=>VersionFileErrorBase,
|
|
424
425
|
j1: ()=>ConfigurationError,
|
|
426
|
+
j9: ()=>VersionFileError,
|
|
425
427
|
ww: ()=>MarkdownParseErrorBase,
|
|
426
428
|
zy: ()=>MarkdownParseError
|
|
427
429
|
});
|
|
@@ -461,6 +463,13 @@ var __webpack_modules__ = {
|
|
|
461
463
|
return `Configuration error (${this.field}): ${this.reason}`;
|
|
462
464
|
}
|
|
463
465
|
}
|
|
466
|
+
const VersionFileErrorBase = effect__rspack_import_0.Data.TaggedError("VersionFileError");
|
|
467
|
+
class VersionFileError extends VersionFileErrorBase {
|
|
468
|
+
get message() {
|
|
469
|
+
const path = this.jsonPath ? ` at ${this.jsonPath}` : "";
|
|
470
|
+
return `Version file error (${this.filePath}${path}): ${this.reason}`;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
464
473
|
},
|
|
465
474
|
"./src/schemas/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
466
475
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -512,6 +521,7 @@ var __webpack_modules__ = {
|
|
|
512
521
|
});
|
|
513
522
|
var effect__rspack_import_0 = __webpack_require__("effect");
|
|
514
523
|
var _errors_js__rspack_import_1 = __webpack_require__("./src/errors.ts");
|
|
524
|
+
var _version_files_js__rspack_import_2 = __webpack_require__("./src/schemas/version-files.ts");
|
|
515
525
|
const REPO_PATTERN = /^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/;
|
|
516
526
|
const RepoSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(REPO_PATTERN, {
|
|
517
527
|
message: ()=>'Repository must be in format "owner/repository" (e.g., "microsoft/vscode")'
|
|
@@ -521,7 +531,8 @@ var __webpack_modules__ = {
|
|
|
521
531
|
commitLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
522
532
|
prLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
523
533
|
issueLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
|
|
524
|
-
issuePrefixes: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(effect__rspack_import_0.Schema.String))
|
|
534
|
+
issuePrefixes: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(effect__rspack_import_0.Schema.String)),
|
|
535
|
+
versionFiles: effect__rspack_import_0.Schema.optional(_version_files_js__rspack_import_2.Hh)
|
|
525
536
|
});
|
|
526
537
|
function validateChangesetOptions(input) {
|
|
527
538
|
if (null == input) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
|
|
@@ -556,6 +567,22 @@ var __webpack_modules__ = {
|
|
|
556
567
|
const NonEmptyString = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.minLength(1));
|
|
557
568
|
const PositiveInteger = effect__rspack_import_0.Schema.Number.pipe(effect__rspack_import_0.Schema.int(), effect__rspack_import_0.Schema.positive());
|
|
558
569
|
},
|
|
570
|
+
"./src/schemas/version-files.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
571
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
572
|
+
Hh: ()=>VersionFilesSchema,
|
|
573
|
+
hH: ()=>JsonPathSchema,
|
|
574
|
+
mC: ()=>VersionFileConfigSchema
|
|
575
|
+
});
|
|
576
|
+
var effect__rspack_import_0 = __webpack_require__("effect");
|
|
577
|
+
const JsonPathSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(/^\$\.[^.]/, {
|
|
578
|
+
message: ()=>'JSONPath must start with "$." followed by a property (e.g., "$.version", "$.metadata.version")'
|
|
579
|
+
}));
|
|
580
|
+
const VersionFileConfigSchema = effect__rspack_import_0.Schema.Struct({
|
|
581
|
+
glob: effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.minLength(1)),
|
|
582
|
+
paths: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(JsonPathSchema))
|
|
583
|
+
});
|
|
584
|
+
const VersionFilesSchema = effect__rspack_import_0.Schema.Array(VersionFileConfigSchema);
|
|
585
|
+
},
|
|
559
586
|
"./src/services/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
560
587
|
__webpack_require__.d(__webpack_exports__, {
|
|
561
588
|
Xx: ()=>GitHubService,
|
|
@@ -714,27 +741,32 @@ var __webpack_exports__ = {};
|
|
|
714
741
|
__webpack_require__.r(__webpack_exports__);
|
|
715
742
|
__webpack_require__.d(__webpack_exports__, {
|
|
716
743
|
IssueNumberSchema: ()=>schemas_github.OD,
|
|
744
|
+
VersionFilesSchema: ()=>version_files.Hh,
|
|
717
745
|
ChangelogServiceBase: ()=>ChangelogServiceBase,
|
|
718
746
|
UrlOrMarkdownLinkSchema: ()=>schemas_github.hY,
|
|
719
747
|
GitHubInfoSchema: ()=>schemas_github.lo,
|
|
720
748
|
GitHubServiceBase: ()=>github.wP,
|
|
721
749
|
GitHubApiErrorBase: ()=>errors.TZ,
|
|
750
|
+
VersionFileError: ()=>errors.j9,
|
|
722
751
|
ChangesetLinter: ()=>ChangesetLinter,
|
|
723
|
-
MarkdownServiceBase: ()=>markdown.M4,
|
|
724
752
|
ChangesetSchema: ()=>ChangesetSchema,
|
|
753
|
+
MarkdownServiceBase: ()=>markdown.M4,
|
|
725
754
|
UsernameSchema: ()=>schemas_github.Qo,
|
|
726
755
|
ChangesetOptionsSchema: ()=>schemas_options.YL,
|
|
727
756
|
DependencyUpdateSchema: ()=>DependencyUpdateSchema,
|
|
757
|
+
VersionFileErrorBase: ()=>errors.iS,
|
|
728
758
|
VersionTypeSchema: ()=>VersionTypeSchema,
|
|
729
759
|
makeGitHubTest: ()=>github.e_,
|
|
730
760
|
ChangelogService: ()=>ChangelogService,
|
|
731
761
|
ChangesetSummarySchema: ()=>ChangesetSummarySchema,
|
|
762
|
+
JsonPathSchema: ()=>version_files.hH,
|
|
732
763
|
MarkdownParseError: ()=>errors.zy,
|
|
733
|
-
PositiveInteger: ()=>primitives.e,
|
|
734
764
|
CommitHashSchema: ()=>CommitHashSchema,
|
|
735
765
|
ChangelogTransformer: ()=>ChangelogTransformer,
|
|
766
|
+
PositiveInteger: ()=>primitives.e,
|
|
736
767
|
NonEmptyString: ()=>primitives.u,
|
|
737
768
|
ConfigurationError: ()=>errors.j1,
|
|
769
|
+
VersionFileConfigSchema: ()=>version_files.mC,
|
|
738
770
|
Categories: ()=>Categories,
|
|
739
771
|
Changelog: ()=>Changelog,
|
|
740
772
|
SectionCategorySchema: ()=>SectionCategorySchema,
|
|
@@ -1208,6 +1240,7 @@ var __webpack_exports__ = {};
|
|
|
1208
1240
|
});
|
|
1209
1241
|
var schemas_github = __webpack_require__("./src/schemas/github.ts");
|
|
1210
1242
|
var schemas_options = __webpack_require__("./src/schemas/options.ts");
|
|
1243
|
+
var version_files = __webpack_require__("./src/schemas/version-files.ts");
|
|
1211
1244
|
})();
|
|
1212
1245
|
exports.Categories = __webpack_exports__.Categories;
|
|
1213
1246
|
exports.Changelog = __webpack_exports__.Changelog;
|
|
@@ -1232,6 +1265,7 @@ exports.GitHubLive = __webpack_exports__.GitHubLive;
|
|
|
1232
1265
|
exports.GitHubService = __webpack_exports__.GitHubService;
|
|
1233
1266
|
exports.GitHubServiceBase = __webpack_exports__.GitHubServiceBase;
|
|
1234
1267
|
exports.IssueNumberSchema = __webpack_exports__.IssueNumberSchema;
|
|
1268
|
+
exports.JsonPathSchema = __webpack_exports__.JsonPathSchema;
|
|
1235
1269
|
exports.MarkdownLive = __webpack_exports__.MarkdownLive;
|
|
1236
1270
|
exports.MarkdownParseError = __webpack_exports__.MarkdownParseError;
|
|
1237
1271
|
exports.MarkdownParseErrorBase = __webpack_exports__.MarkdownParseErrorBase;
|
|
@@ -1243,6 +1277,10 @@ exports.RepoSchema = __webpack_exports__.RepoSchema;
|
|
|
1243
1277
|
exports.SectionCategorySchema = __webpack_exports__.SectionCategorySchema;
|
|
1244
1278
|
exports.UrlOrMarkdownLinkSchema = __webpack_exports__.UrlOrMarkdownLinkSchema;
|
|
1245
1279
|
exports.UsernameSchema = __webpack_exports__.UsernameSchema;
|
|
1280
|
+
exports.VersionFileConfigSchema = __webpack_exports__.VersionFileConfigSchema;
|
|
1281
|
+
exports.VersionFileError = __webpack_exports__.VersionFileError;
|
|
1282
|
+
exports.VersionFileErrorBase = __webpack_exports__.VersionFileErrorBase;
|
|
1283
|
+
exports.VersionFilesSchema = __webpack_exports__.VersionFilesSchema;
|
|
1246
1284
|
exports.VersionTypeSchema = __webpack_exports__.VersionTypeSchema;
|
|
1247
1285
|
exports.makeGitHubTest = __webpack_exports__.makeGitHubTest;
|
|
1248
1286
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1269,6 +1307,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
1269
1307
|
"GitHubService",
|
|
1270
1308
|
"GitHubServiceBase",
|
|
1271
1309
|
"IssueNumberSchema",
|
|
1310
|
+
"JsonPathSchema",
|
|
1272
1311
|
"MarkdownLive",
|
|
1273
1312
|
"MarkdownParseError",
|
|
1274
1313
|
"MarkdownParseErrorBase",
|
|
@@ -1280,6 +1319,10 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
1280
1319
|
"SectionCategorySchema",
|
|
1281
1320
|
"UrlOrMarkdownLinkSchema",
|
|
1282
1321
|
"UsernameSchema",
|
|
1322
|
+
"VersionFileConfigSchema",
|
|
1323
|
+
"VersionFileError",
|
|
1324
|
+
"VersionFileErrorBase",
|
|
1325
|
+
"VersionFilesSchema",
|
|
1283
1326
|
"VersionTypeSchema",
|
|
1284
1327
|
"makeGitHubTest"
|
|
1285
1328
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
package/cjs/index.d.cts
CHANGED
|
@@ -330,6 +330,11 @@ export declare const ChangesetOptionsSchema: Schema.Struct<{
|
|
|
330
330
|
issueLinks: Schema.optional<typeof Schema.Boolean>;
|
|
331
331
|
/** Custom issue reference prefixes (e.g., `["#", "GH-"]`). */
|
|
332
332
|
issuePrefixes: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
333
|
+
/** Additional JSON files to update with version numbers. */
|
|
334
|
+
versionFiles: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
335
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
336
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
337
|
+
}>>>;
|
|
333
338
|
}>;
|
|
334
339
|
|
|
335
340
|
/**
|
|
@@ -602,6 +607,14 @@ export declare interface GitHubServiceShape {
|
|
|
602
607
|
*/
|
|
603
608
|
export declare const IssueNumberSchema: Schema.refine<number, Schema.filter<typeof Schema.Number>>;
|
|
604
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Schema for a JSONPath expression starting with `$.`.
|
|
612
|
+
*
|
|
613
|
+
* Supports property access (`$.foo.bar`), array wildcard (`$.foo[*].bar`),
|
|
614
|
+
* and array index access (`$.foo[0].bar`).
|
|
615
|
+
*/
|
|
616
|
+
export declare const JsonPathSchema: Schema.filter<typeof Schema.String>;
|
|
617
|
+
|
|
605
618
|
/**
|
|
606
619
|
* Class-based API wrapper for changeset linting.
|
|
607
620
|
*
|
|
@@ -778,6 +791,65 @@ export declare const UrlOrMarkdownLinkSchema: Schema.filter<typeof Schema.String
|
|
|
778
791
|
*/
|
|
779
792
|
export declare const UsernameSchema: Schema.filter<typeof Schema.String>;
|
|
780
793
|
|
|
794
|
+
/**
|
|
795
|
+
* Inferred type for {@link VersionFileConfigSchema}.
|
|
796
|
+
*/
|
|
797
|
+
export declare interface VersionFileConfig extends Schema.Schema.Type<typeof VersionFileConfigSchema> {
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Schema for a single version file configuration entry.
|
|
802
|
+
*/
|
|
803
|
+
export declare const VersionFileConfigSchema: Schema.Struct<{
|
|
804
|
+
/** Glob pattern to match JSON files. */
|
|
805
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
806
|
+
/** JSONPath expressions to locate version fields. Defaults to `["$.version"]`. */
|
|
807
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
808
|
+
}>;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Version file update failure.
|
|
812
|
+
*
|
|
813
|
+
* Raised when a JSON file targeted by the `versionFiles` config cannot
|
|
814
|
+
* be read, parsed, or updated at the specified JSONPath.
|
|
815
|
+
*
|
|
816
|
+
* @public
|
|
817
|
+
*/
|
|
818
|
+
export declare class VersionFileError extends VersionFileErrorBase<{
|
|
819
|
+
/** Absolute path to the file that failed. */
|
|
820
|
+
readonly filePath: string;
|
|
821
|
+
/** JSONPath expression that failed, if applicable. */
|
|
822
|
+
readonly jsonPath?: string | undefined;
|
|
823
|
+
/** Human-readable failure reason. */
|
|
824
|
+
readonly reason: string;
|
|
825
|
+
}> {
|
|
826
|
+
get message(): string;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Base class for VersionFileError.
|
|
831
|
+
*
|
|
832
|
+
* @privateRemarks
|
|
833
|
+
* This export is required for api-extractor documentation generation.
|
|
834
|
+
* Effect's Data.TaggedError creates an anonymous base class that must be
|
|
835
|
+
* explicitly exported to avoid "forgotten export" warnings. Do not delete.
|
|
836
|
+
*
|
|
837
|
+
* @internal
|
|
838
|
+
*/
|
|
839
|
+
export declare const VersionFileErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & {
|
|
840
|
+
readonly _tag: "VersionFileError";
|
|
841
|
+
} & Readonly<A>;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Schema for the `versionFiles` array.
|
|
845
|
+
*/
|
|
846
|
+
export declare const VersionFilesSchema: Schema.Array$<Schema.Struct<{
|
|
847
|
+
/** Glob pattern to match JSON files. */
|
|
848
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
849
|
+
/** JSONPath expressions to locate version fields. Defaults to `["$.version"]`. */
|
|
850
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
851
|
+
}>>;
|
|
852
|
+
|
|
781
853
|
/**
|
|
782
854
|
* Inferred type for {@link VersionTypeSchema}.
|
|
783
855
|
*
|
package/esm/160.js
CHANGED
|
@@ -1,42 +1,7 @@
|
|
|
1
1
|
import { getInfo } from "@changesets/get-github-info";
|
|
2
|
-
import { Layer, unified, Schema, remark_stringify,
|
|
2
|
+
import { Layer, unified, Schema, remark_stringify, Effect, GitHubApiError, VersionFilesSchema, remark_gfm, ConfigurationError, Context, remark_parse } from "./795.js";
|
|
3
3
|
import { external_mdast_util_to_string_toString } from "./689.js";
|
|
4
4
|
import { resolveCommitType, fromHeading } from "./60.js";
|
|
5
|
-
const ChangesetValidationErrorBase = Data.TaggedError("ChangesetValidationError");
|
|
6
|
-
class ChangesetValidationError extends ChangesetValidationErrorBase {
|
|
7
|
-
get message() {
|
|
8
|
-
const prefix = this.file ? `${this.file}: ` : "";
|
|
9
|
-
const detail = this.issues.map((i)=>` - ${i.path}: ${i.message}`).join("\n");
|
|
10
|
-
return `${prefix}Changeset validation failed:\n${detail}`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const GitHubApiErrorBase = Data.TaggedError("GitHubApiError");
|
|
14
|
-
class GitHubApiError extends GitHubApiErrorBase {
|
|
15
|
-
get message() {
|
|
16
|
-
const status = this.statusCode ? ` (${this.statusCode})` : "";
|
|
17
|
-
return `GitHub API error during ${this.operation}${status}: ${this.reason}`;
|
|
18
|
-
}
|
|
19
|
-
get isRateLimited() {
|
|
20
|
-
return 403 === this.statusCode || 429 === this.statusCode;
|
|
21
|
-
}
|
|
22
|
-
get isRetryable() {
|
|
23
|
-
return void 0 !== this.statusCode && (this.statusCode >= 500 || this.isRateLimited);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const MarkdownParseErrorBase = Data.TaggedError("MarkdownParseError");
|
|
27
|
-
class MarkdownParseError extends MarkdownParseErrorBase {
|
|
28
|
-
get message() {
|
|
29
|
-
const loc = this.line ? `:${this.line}${this.column ? `:${this.column}` : ""}` : "";
|
|
30
|
-
const src = this.source ? `${this.source}${loc}: ` : "";
|
|
31
|
-
return `${src}Markdown parse error: ${this.reason}`;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const ConfigurationErrorBase = Data.TaggedError("ConfigurationError");
|
|
35
|
-
class ConfigurationError extends ConfigurationErrorBase {
|
|
36
|
-
get message() {
|
|
37
|
-
return `Configuration error (${this.field}): ${this.reason}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
5
|
const REPO_PATTERN = /^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/;
|
|
41
6
|
const RepoSchema = Schema.String.pipe(Schema.pattern(REPO_PATTERN, {
|
|
42
7
|
message: ()=>'Repository must be in format "owner/repository" (e.g., "microsoft/vscode")'
|
|
@@ -46,7 +11,8 @@ const ChangesetOptionsSchema = Schema.Struct({
|
|
|
46
11
|
commitLinks: Schema.optional(Schema.Boolean),
|
|
47
12
|
prLinks: Schema.optional(Schema.Boolean),
|
|
48
13
|
issueLinks: Schema.optional(Schema.Boolean),
|
|
49
|
-
issuePrefixes: Schema.optional(Schema.Array(Schema.String))
|
|
14
|
+
issuePrefixes: Schema.optional(Schema.Array(Schema.String)),
|
|
15
|
+
versionFiles: Schema.optional(VersionFilesSchema)
|
|
50
16
|
});
|
|
51
17
|
function validateChangesetOptions(input) {
|
|
52
18
|
if (null == input) return Effect.fail(new ConfigurationError({
|
|
@@ -402,4 +368,4 @@ const changelogFunctions = {
|
|
|
402
368
|
};
|
|
403
369
|
const changelog = changelogFunctions;
|
|
404
370
|
export default changelog;
|
|
405
|
-
export { ChangesetOptionsSchema,
|
|
371
|
+
export { ChangesetOptionsSchema, GitHubInfoSchema, GitHubLive, GitHubService, GitHubServiceBase, IssueNumberSchema, MarkdownLive, MarkdownService, MarkdownServiceBase, NonEmptyString, PositiveInteger, RepoSchema, UrlOrMarkdownLinkSchema, UsernameSchema, makeGitHubTest };
|
package/esm/273.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { unified, remark_gfm, remark_stringify, remark_parse } from "./
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { unified, remark_gfm, remark_stringify, remark_parse } from "./795.js";
|
|
4
4
|
import { MergeSectionsPlugin, DeduplicateItemsPlugin, IssueLinkRefsPlugin, ContentStructureRule, HeadingHierarchyRule, NormalizeFormatPlugin, ReorderSectionsPlugin, ContributorFootnotesPlugin, RequiredSectionsRule } from "./234.js";
|
|
5
5
|
function stripFrontmatter(content) {
|
|
6
6
|
return content.replace(/^---\n[\s\S]*?\n---\n?/, "");
|
|
@@ -38,4 +38,4 @@ class ChangelogTransformer {
|
|
|
38
38
|
writeFileSync(filePath, result, "utf-8");
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
export { ChangelogTransformer, ChangesetLinter, existsSync, join, mkdirSync, readFileSync, resolve, writeFileSync };
|
|
41
|
+
export { ChangelogTransformer, ChangesetLinter, existsSync, join, mkdirSync, readFileSync, relative, resolve, writeFileSync };
|
package/esm/795.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer, Schema } from "effect";
|
|
2
|
+
const ChangesetValidationErrorBase = Data.TaggedError("ChangesetValidationError");
|
|
3
|
+
class ChangesetValidationError extends ChangesetValidationErrorBase {
|
|
4
|
+
get message() {
|
|
5
|
+
const prefix = this.file ? `${this.file}: ` : "";
|
|
6
|
+
const detail = this.issues.map((i)=>` - ${i.path}: ${i.message}`).join("\n");
|
|
7
|
+
return `${prefix}Changeset validation failed:\n${detail}`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const GitHubApiErrorBase = Data.TaggedError("GitHubApiError");
|
|
11
|
+
class GitHubApiError extends GitHubApiErrorBase {
|
|
12
|
+
get message() {
|
|
13
|
+
const status = this.statusCode ? ` (${this.statusCode})` : "";
|
|
14
|
+
return `GitHub API error during ${this.operation}${status}: ${this.reason}`;
|
|
15
|
+
}
|
|
16
|
+
get isRateLimited() {
|
|
17
|
+
return 403 === this.statusCode || 429 === this.statusCode;
|
|
18
|
+
}
|
|
19
|
+
get isRetryable() {
|
|
20
|
+
return void 0 !== this.statusCode && (this.statusCode >= 500 || this.isRateLimited);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const MarkdownParseErrorBase = Data.TaggedError("MarkdownParseError");
|
|
24
|
+
class MarkdownParseError extends MarkdownParseErrorBase {
|
|
25
|
+
get message() {
|
|
26
|
+
const loc = this.line ? `:${this.line}${this.column ? `:${this.column}` : ""}` : "";
|
|
27
|
+
const src = this.source ? `${this.source}${loc}: ` : "";
|
|
28
|
+
return `${src}Markdown parse error: ${this.reason}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const ConfigurationErrorBase = Data.TaggedError("ConfigurationError");
|
|
32
|
+
class ConfigurationError extends ConfigurationErrorBase {
|
|
33
|
+
get message() {
|
|
34
|
+
return `Configuration error (${this.field}): ${this.reason}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const VersionFileErrorBase = Data.TaggedError("VersionFileError");
|
|
38
|
+
class VersionFileError extends VersionFileErrorBase {
|
|
39
|
+
get message() {
|
|
40
|
+
const path = this.jsonPath ? ` at ${this.jsonPath}` : "";
|
|
41
|
+
return `Version file error (${this.filePath}${path}): ${this.reason}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const JsonPathSchema = Schema.String.pipe(Schema.pattern(/^\$\.[^.]/, {
|
|
45
|
+
message: ()=>'JSONPath must start with "$." followed by a property (e.g., "$.version", "$.metadata.version")'
|
|
46
|
+
}));
|
|
47
|
+
const VersionFileConfigSchema = Schema.Struct({
|
|
48
|
+
glob: Schema.String.pipe(Schema.minLength(1)),
|
|
49
|
+
paths: Schema.optional(Schema.Array(JsonPathSchema))
|
|
50
|
+
});
|
|
51
|
+
const VersionFilesSchema = Schema.Array(VersionFileConfigSchema);
|
|
52
|
+
export { default as remark_gfm } from "remark-gfm";
|
|
53
|
+
export { default as remark_parse } from "remark-parse";
|
|
54
|
+
export { default as remark_stringify } from "remark-stringify";
|
|
55
|
+
export { unified } from "unified";
|
|
56
|
+
export { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, Context, Data, Effect, GitHubApiError, GitHubApiErrorBase, JsonPathSchema, Layer, MarkdownParseError, MarkdownParseErrorBase, Schema, VersionFileConfigSchema, VersionFileError, VersionFileErrorBase, VersionFilesSchema };
|
|
@@ -3,8 +3,10 @@ import { Args, Command, Options } from "@effect/cli";
|
|
|
3
3
|
import { NodeContext, NodeRuntime } from "@effect/platform-node";
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
5
|
import { findProjectRoot, getWorkspaceInfos } from "workspace-tools";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { parse } from "jsonc-parser";
|
|
7
|
+
import { globSync } from "tinyglobby";
|
|
8
|
+
import { readFileSync, ChangelogTransformer, ChangesetLinter, resolve, existsSync, relative, mkdirSync, writeFileSync, join } from "../273.js";
|
|
9
|
+
import { VersionFilesSchema, Schema, VersionFileError, Data, Effect } from "../795.js";
|
|
8
10
|
const dirArg = Args.directory({
|
|
9
11
|
name: "dir"
|
|
10
12
|
}).pipe(Args.withDefault(".changeset"));
|
|
@@ -388,6 +390,250 @@ const transformCommand = Command.make("transform", {
|
|
|
388
390
|
dryRun: dryRunOption,
|
|
389
391
|
check: transform_checkOption
|
|
390
392
|
}, ({ file, dryRun, check })=>runTransform(file, dryRun, check)).pipe(Command.withDescription("Post-process CHANGELOG.md"));
|
|
393
|
+
function parseJsonPath(path) {
|
|
394
|
+
if (!path.startsWith("$.")) throw new Error(`Invalid JSONPath: must start with "$." — got "${path}"`);
|
|
395
|
+
const segments = [];
|
|
396
|
+
const raw = path.slice(2);
|
|
397
|
+
if ("" === raw) return segments;
|
|
398
|
+
const tokens = raw.match(/[^.[\]]+|\[\*\]|\[\d+\]/g);
|
|
399
|
+
if (!tokens) throw new Error(`Invalid JSONPath: could not parse "${path}"`);
|
|
400
|
+
for (const token of tokens)if ("[*]" === token) segments.push({
|
|
401
|
+
type: "wildcard"
|
|
402
|
+
});
|
|
403
|
+
else if (token.startsWith("[") && token.endsWith("]")) segments.push({
|
|
404
|
+
type: "index",
|
|
405
|
+
index: Number.parseInt(token.slice(1, -1), 10)
|
|
406
|
+
});
|
|
407
|
+
else segments.push({
|
|
408
|
+
type: "property",
|
|
409
|
+
key: token
|
|
410
|
+
});
|
|
411
|
+
return segments;
|
|
412
|
+
}
|
|
413
|
+
function jsonPathGet(obj, path) {
|
|
414
|
+
const segments = parseJsonPath(path);
|
|
415
|
+
let current = [
|
|
416
|
+
obj
|
|
417
|
+
];
|
|
418
|
+
for (const segment of segments){
|
|
419
|
+
const next = [];
|
|
420
|
+
for (const node of current)if (null != node && "object" == typeof node) switch(segment.type){
|
|
421
|
+
case "property":
|
|
422
|
+
{
|
|
423
|
+
const value = node[segment.key];
|
|
424
|
+
if (void 0 !== value) next.push(value);
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
case "index":
|
|
428
|
+
if (Array.isArray(node) && segment.index < node.length) next.push(node[segment.index]);
|
|
429
|
+
break;
|
|
430
|
+
case "wildcard":
|
|
431
|
+
if (Array.isArray(node)) next.push(...node);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
current = next;
|
|
435
|
+
}
|
|
436
|
+
return current;
|
|
437
|
+
}
|
|
438
|
+
function jsonPathSet(obj, path, value) {
|
|
439
|
+
const segments = parseJsonPath(path);
|
|
440
|
+
if (0 === segments.length) return 0;
|
|
441
|
+
const lastSegment = segments[segments.length - 1];
|
|
442
|
+
const parentSegments = segments.slice(0, -1);
|
|
443
|
+
let parents = [
|
|
444
|
+
obj
|
|
445
|
+
];
|
|
446
|
+
for (const segment of parentSegments){
|
|
447
|
+
const next = [];
|
|
448
|
+
for (const node of parents)if (null != node && "object" == typeof node) switch(segment.type){
|
|
449
|
+
case "property":
|
|
450
|
+
{
|
|
451
|
+
const child = node[segment.key];
|
|
452
|
+
if (void 0 !== child) next.push(child);
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case "index":
|
|
456
|
+
if (Array.isArray(node) && segment.index < node.length) next.push(node[segment.index]);
|
|
457
|
+
break;
|
|
458
|
+
case "wildcard":
|
|
459
|
+
if (Array.isArray(node)) next.push(...node);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
parents = next;
|
|
463
|
+
}
|
|
464
|
+
let count = 0;
|
|
465
|
+
for (const parent of parents)if (null != parent && "object" == typeof parent) switch(lastSegment.type){
|
|
466
|
+
case "property":
|
|
467
|
+
if (lastSegment.key in parent) {
|
|
468
|
+
parent[lastSegment.key] = value;
|
|
469
|
+
count++;
|
|
470
|
+
}
|
|
471
|
+
break;
|
|
472
|
+
case "index":
|
|
473
|
+
if (Array.isArray(parent) && lastSegment.index < parent.length) {
|
|
474
|
+
parent[lastSegment.index] = value;
|
|
475
|
+
count++;
|
|
476
|
+
}
|
|
477
|
+
break;
|
|
478
|
+
case "wildcard":
|
|
479
|
+
if (Array.isArray(parent)) for(let i = 0; i < parent.length; i++){
|
|
480
|
+
parent[i] = value;
|
|
481
|
+
count++;
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
return count;
|
|
486
|
+
}
|
|
487
|
+
class VersionFiles {
|
|
488
|
+
static readConfig(cwd) {
|
|
489
|
+
const configPath = join(cwd, ".changeset", "config.json");
|
|
490
|
+
if (!existsSync(configPath)) return;
|
|
491
|
+
let raw;
|
|
492
|
+
try {
|
|
493
|
+
raw = readFileSync(configPath, "utf-8");
|
|
494
|
+
} catch {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const config = parse(raw);
|
|
498
|
+
const changelog = config.changelog;
|
|
499
|
+
if (!Array.isArray(changelog) || changelog.length < 2) return;
|
|
500
|
+
const options = changelog[1];
|
|
501
|
+
if (!options || "object" != typeof options || !("versionFiles" in options)) return;
|
|
502
|
+
try {
|
|
503
|
+
const decoded = Schema.decodeUnknownSync(VersionFilesSchema)(options.versionFiles);
|
|
504
|
+
return decoded.length > 0 ? decoded : void 0;
|
|
505
|
+
} catch (error) {
|
|
506
|
+
console.warn(`[changesets] Invalid versionFiles configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
static discoverVersions(cwd) {
|
|
511
|
+
const resolvedCwd = resolve(cwd);
|
|
512
|
+
const results = [];
|
|
513
|
+
const seen = new Set();
|
|
514
|
+
try {
|
|
515
|
+
const workspaces = getWorkspaceInfos(resolvedCwd) ?? [];
|
|
516
|
+
for (const ws of workspaces){
|
|
517
|
+
if (seen.has(ws.path)) continue;
|
|
518
|
+
seen.add(ws.path);
|
|
519
|
+
const version = readPackageVersion(ws.path);
|
|
520
|
+
if (version) results.push({
|
|
521
|
+
name: ws.name,
|
|
522
|
+
path: ws.path,
|
|
523
|
+
version
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
} catch {}
|
|
527
|
+
if (!seen.has(resolvedCwd)) {
|
|
528
|
+
const version = readPackageVersion(resolvedCwd);
|
|
529
|
+
if (version) {
|
|
530
|
+
let rootName = "root";
|
|
531
|
+
try {
|
|
532
|
+
const pkg = JSON.parse(readFileSync(join(resolvedCwd, "package.json"), "utf-8"));
|
|
533
|
+
if (pkg.name) rootName = pkg.name;
|
|
534
|
+
} catch {}
|
|
535
|
+
results.push({
|
|
536
|
+
name: rootName,
|
|
537
|
+
path: resolvedCwd,
|
|
538
|
+
version
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return results;
|
|
543
|
+
}
|
|
544
|
+
static resolveVersion(filePath, workspaces, rootVersion) {
|
|
545
|
+
const resolved = resolve(filePath);
|
|
546
|
+
let bestMatch;
|
|
547
|
+
let bestLength = 0;
|
|
548
|
+
for (const ws of workspaces){
|
|
549
|
+
const rel = relative(ws.path, resolved);
|
|
550
|
+
if (!rel.startsWith("..") && ws.path.length > bestLength) {
|
|
551
|
+
bestMatch = ws;
|
|
552
|
+
bestLength = ws.path.length;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return bestMatch?.version ?? rootVersion;
|
|
556
|
+
}
|
|
557
|
+
static resolveGlobs(configs, cwd) {
|
|
558
|
+
const results = [];
|
|
559
|
+
const resolvedCwd = resolve(cwd);
|
|
560
|
+
for (const config of configs){
|
|
561
|
+
const matches = globSync(config.glob, {
|
|
562
|
+
cwd: resolvedCwd,
|
|
563
|
+
ignore: [
|
|
564
|
+
"**/node_modules/**"
|
|
565
|
+
]
|
|
566
|
+
});
|
|
567
|
+
for (const match of matches)results.push([
|
|
568
|
+
join(resolvedCwd, match),
|
|
569
|
+
config
|
|
570
|
+
]);
|
|
571
|
+
}
|
|
572
|
+
return results;
|
|
573
|
+
}
|
|
574
|
+
static detectIndent(content) {
|
|
575
|
+
const match = content.match(/^(\s+)"/m);
|
|
576
|
+
return match?.[1] ?? " ";
|
|
577
|
+
}
|
|
578
|
+
static updateFile(filePath, jsonPaths, version) {
|
|
579
|
+
const content = readFileSync(filePath, "utf-8");
|
|
580
|
+
const indent = VersionFiles.detectIndent(content);
|
|
581
|
+
const trailingNewline = content.endsWith("\n");
|
|
582
|
+
const obj = JSON.parse(content);
|
|
583
|
+
const previousValues = jsonPaths.flatMap((jp)=>jsonPathGet(obj, jp));
|
|
584
|
+
let totalUpdated = 0;
|
|
585
|
+
for (const jp of jsonPaths)totalUpdated += jsonPathSet(obj, jp, version);
|
|
586
|
+
if (0 === totalUpdated) return;
|
|
587
|
+
let output = JSON.stringify(obj, null, indent);
|
|
588
|
+
if (trailingNewline) output += "\n";
|
|
589
|
+
writeFileSync(filePath, output, "utf-8");
|
|
590
|
+
return {
|
|
591
|
+
filePath,
|
|
592
|
+
jsonPaths,
|
|
593
|
+
version,
|
|
594
|
+
previousValues
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
static processVersionFiles(cwd, configs, dryRun = false) {
|
|
598
|
+
const workspaces = VersionFiles.discoverVersions(cwd);
|
|
599
|
+
const rootVersion = workspaces.find((ws)=>ws.path === resolve(cwd))?.version ?? "0.0.0";
|
|
600
|
+
const resolved = VersionFiles.resolveGlobs(configs, cwd);
|
|
601
|
+
const updates = [];
|
|
602
|
+
for (const [filePath, config] of resolved){
|
|
603
|
+
const jsonPaths = config.paths ?? [
|
|
604
|
+
"$.version"
|
|
605
|
+
];
|
|
606
|
+
const version = VersionFiles.resolveVersion(filePath, workspaces, rootVersion);
|
|
607
|
+
try {
|
|
608
|
+
if (dryRun) {
|
|
609
|
+
const content = readFileSync(filePath, "utf-8");
|
|
610
|
+
const obj = JSON.parse(content);
|
|
611
|
+
const previousValues = jsonPaths.flatMap((jp)=>jsonPathGet(obj, jp));
|
|
612
|
+
if (previousValues.length > 0) updates.push({
|
|
613
|
+
filePath,
|
|
614
|
+
jsonPaths,
|
|
615
|
+
version,
|
|
616
|
+
previousValues
|
|
617
|
+
});
|
|
618
|
+
} else {
|
|
619
|
+
const result = VersionFiles.updateFile(filePath, jsonPaths, version);
|
|
620
|
+
if (result) updates.push(result);
|
|
621
|
+
}
|
|
622
|
+
} catch (error) {
|
|
623
|
+
throw new Error(`Failed to update ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return updates;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function readPackageVersion(dir) {
|
|
630
|
+
try {
|
|
631
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
|
|
632
|
+
return pkg.version;
|
|
633
|
+
} catch {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
391
637
|
class Workspace {
|
|
392
638
|
static detectPackageManager(cwd = process.cwd()) {
|
|
393
639
|
const packageJsonPath = join(cwd, "package.json");
|
|
@@ -469,14 +715,34 @@ function runVersion(dryRun) {
|
|
|
469
715
|
});
|
|
470
716
|
}
|
|
471
717
|
const changelogs = Workspace.discoverChangelogs(cwd);
|
|
472
|
-
if (0 === changelogs.length)
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
try
|
|
477
|
-
|
|
718
|
+
if (0 === changelogs.length) yield* Effect.log("No CHANGELOG.md files found.");
|
|
719
|
+
else {
|
|
720
|
+
yield* Effect.log(`Found ${changelogs.length} CHANGELOG.md file(s)`);
|
|
721
|
+
for (const entry of changelogs){
|
|
722
|
+
yield* Effect["try"]({
|
|
723
|
+
try: ()=>ChangelogTransformer.transformFile(entry.changelogPath),
|
|
724
|
+
catch: (error)=>new Error(`Failed to transform ${entry.changelogPath}: ${error instanceof Error ? error.message : String(error)}`)
|
|
725
|
+
});
|
|
726
|
+
yield* Effect.log(`Transformed ${entry.name} → ${entry.changelogPath}`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
const versionFileConfigs = VersionFiles.readConfig(cwd);
|
|
730
|
+
if (versionFileConfigs) {
|
|
731
|
+
yield* Effect.log(`Found ${versionFileConfigs.length} versionFiles config(s)`);
|
|
732
|
+
const updates = yield* Effect["try"]({
|
|
733
|
+
try: ()=>VersionFiles.processVersionFiles(cwd, versionFileConfigs, dryRun),
|
|
734
|
+
catch: (error)=>{
|
|
735
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
736
|
+
return new VersionFileError({
|
|
737
|
+
filePath: message.match(/Failed to update (.+?):/)?.[1] ?? cwd,
|
|
738
|
+
reason: message
|
|
739
|
+
});
|
|
740
|
+
}
|
|
478
741
|
});
|
|
479
|
-
|
|
742
|
+
for (const update of updates){
|
|
743
|
+
const action = dryRun ? "Would update" : "Updated";
|
|
744
|
+
yield* Effect.log(`${action} ${update.filePath} → ${update.version}`);
|
|
745
|
+
}
|
|
480
746
|
}
|
|
481
747
|
});
|
|
482
748
|
}
|
|
@@ -492,7 +758,7 @@ const rootCommand = Command.make("savvy-changesets").pipe(Command.withSubcommand
|
|
|
492
758
|
]));
|
|
493
759
|
const cli = Command.run(rootCommand, {
|
|
494
760
|
name: "savvy-changesets",
|
|
495
|
-
version: "0.1
|
|
761
|
+
version: "0.2.1"
|
|
496
762
|
});
|
|
497
763
|
function runCli() {
|
|
498
764
|
const main = Effect.suspend(()=>cli(process.argv)).pipe(Effect.provide(NodeContext.layer));
|
package/esm/index.d.ts
CHANGED
|
@@ -330,6 +330,11 @@ export declare const ChangesetOptionsSchema: Schema.Struct<{
|
|
|
330
330
|
issueLinks: Schema.optional<typeof Schema.Boolean>;
|
|
331
331
|
/** Custom issue reference prefixes (e.g., `["#", "GH-"]`). */
|
|
332
332
|
issuePrefixes: Schema.optional<Schema.Array$<typeof Schema.String>>;
|
|
333
|
+
/** Additional JSON files to update with version numbers. */
|
|
334
|
+
versionFiles: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
335
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
336
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
337
|
+
}>>>;
|
|
333
338
|
}>;
|
|
334
339
|
|
|
335
340
|
/**
|
|
@@ -602,6 +607,14 @@ export declare interface GitHubServiceShape {
|
|
|
602
607
|
*/
|
|
603
608
|
export declare const IssueNumberSchema: Schema.refine<number, Schema.filter<typeof Schema.Number>>;
|
|
604
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Schema for a JSONPath expression starting with `$.`.
|
|
612
|
+
*
|
|
613
|
+
* Supports property access (`$.foo.bar`), array wildcard (`$.foo[*].bar`),
|
|
614
|
+
* and array index access (`$.foo[0].bar`).
|
|
615
|
+
*/
|
|
616
|
+
export declare const JsonPathSchema: Schema.filter<typeof Schema.String>;
|
|
617
|
+
|
|
605
618
|
/**
|
|
606
619
|
* Class-based API wrapper for changeset linting.
|
|
607
620
|
*
|
|
@@ -778,6 +791,65 @@ export declare const UrlOrMarkdownLinkSchema: Schema.filter<typeof Schema.String
|
|
|
778
791
|
*/
|
|
779
792
|
export declare const UsernameSchema: Schema.filter<typeof Schema.String>;
|
|
780
793
|
|
|
794
|
+
/**
|
|
795
|
+
* Inferred type for {@link VersionFileConfigSchema}.
|
|
796
|
+
*/
|
|
797
|
+
export declare interface VersionFileConfig extends Schema.Schema.Type<typeof VersionFileConfigSchema> {
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Schema for a single version file configuration entry.
|
|
802
|
+
*/
|
|
803
|
+
export declare const VersionFileConfigSchema: Schema.Struct<{
|
|
804
|
+
/** Glob pattern to match JSON files. */
|
|
805
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
806
|
+
/** JSONPath expressions to locate version fields. Defaults to `["$.version"]`. */
|
|
807
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
808
|
+
}>;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Version file update failure.
|
|
812
|
+
*
|
|
813
|
+
* Raised when a JSON file targeted by the `versionFiles` config cannot
|
|
814
|
+
* be read, parsed, or updated at the specified JSONPath.
|
|
815
|
+
*
|
|
816
|
+
* @public
|
|
817
|
+
*/
|
|
818
|
+
export declare class VersionFileError extends VersionFileErrorBase<{
|
|
819
|
+
/** Absolute path to the file that failed. */
|
|
820
|
+
readonly filePath: string;
|
|
821
|
+
/** JSONPath expression that failed, if applicable. */
|
|
822
|
+
readonly jsonPath?: string | undefined;
|
|
823
|
+
/** Human-readable failure reason. */
|
|
824
|
+
readonly reason: string;
|
|
825
|
+
}> {
|
|
826
|
+
get message(): string;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Base class for VersionFileError.
|
|
831
|
+
*
|
|
832
|
+
* @privateRemarks
|
|
833
|
+
* This export is required for api-extractor documentation generation.
|
|
834
|
+
* Effect's Data.TaggedError creates an anonymous base class that must be
|
|
835
|
+
* explicitly exported to avoid "forgotten export" warnings. Do not delete.
|
|
836
|
+
*
|
|
837
|
+
* @internal
|
|
838
|
+
*/
|
|
839
|
+
export declare const VersionFileErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & {
|
|
840
|
+
readonly _tag: "VersionFileError";
|
|
841
|
+
} & Readonly<A>;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Schema for the `versionFiles` array.
|
|
845
|
+
*/
|
|
846
|
+
export declare const VersionFilesSchema: Schema.Array$<Schema.Struct<{
|
|
847
|
+
/** Glob pattern to match JSON files. */
|
|
848
|
+
glob: Schema.filter<typeof Schema.String>;
|
|
849
|
+
/** JSONPath expressions to locate version fields. Defaults to `["$.version"]`. */
|
|
850
|
+
paths: Schema.optional<Schema.Array$<Schema.filter<typeof Schema.String>>>;
|
|
851
|
+
}>>;
|
|
852
|
+
|
|
781
853
|
/**
|
|
782
854
|
* Inferred type for {@link VersionTypeSchema}.
|
|
783
855
|
*
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BREAKING_CHANGES, PERFORMANCE, fromHeading, allHeadings, resolveCommitType, CI, TESTS, DEPENDENCIES, OTHER, CATEGORIES, FEATURES, BUG_FIXES, REVERTS, DOCUMENTATION, isValidHeading, BUILD_SYSTEM, REFACTORING, MAINTENANCE } from "./60.js";
|
|
2
2
|
import { default as changelog, NonEmptyString } from "./160.js";
|
|
3
|
-
import { Context, Schema } from "./
|
|
3
|
+
import { Context, Schema } from "./795.js";
|
|
4
4
|
class Categories {
|
|
5
5
|
static BREAKING_CHANGES = BREAKING_CHANGES;
|
|
6
6
|
static FEATURES = FEATURES;
|
|
@@ -71,5 +71,6 @@ const DependencyUpdateSchema = Schema.Struct({
|
|
|
71
71
|
newVersion: Schema.String
|
|
72
72
|
});
|
|
73
73
|
export { ChangelogTransformer, ChangesetLinter } from "./273.js";
|
|
74
|
-
export { ChangesetOptionsSchema,
|
|
74
|
+
export { ChangesetOptionsSchema, GitHubInfoSchema, GitHubLive, GitHubService, GitHubServiceBase, IssueNumberSchema, MarkdownLive, MarkdownService, MarkdownServiceBase, NonEmptyString, PositiveInteger, RepoSchema, UrlOrMarkdownLinkSchema, UsernameSchema, makeGitHubTest } from "./160.js";
|
|
75
|
+
export { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitHubApiError, GitHubApiErrorBase, JsonPathSchema, MarkdownParseError, MarkdownParseErrorBase, VersionFileConfigSchema, VersionFileError, VersionFileErrorBase, VersionFilesSchema } from "./795.js";
|
|
75
76
|
export { Categories, Changelog, ChangelogService, ChangelogServiceBase, ChangesetSchema, ChangesetSummarySchema, CommitHashSchema, DependencyTypeSchema, DependencyUpdateSchema, SectionCategorySchema, VersionTypeSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/changesets",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Custom changelog formatter and markdown processing pipeline for the Silk Suite. Provides structured changeset sections, remark-based validation and transformation, and an Effect CLI.",
|
|
6
6
|
"keywords": [
|
|
@@ -57,12 +57,14 @@
|
|
|
57
57
|
"@effect/cli": "^0.73.2",
|
|
58
58
|
"@effect/platform": "^0.94.5",
|
|
59
59
|
"@effect/platform-node": "^0.104.1",
|
|
60
|
-
"effect": "^3.19.
|
|
60
|
+
"effect": "^3.19.19",
|
|
61
|
+
"jsonc-parser": "^3.3.1",
|
|
61
62
|
"mdast-util-heading-range": "^4.0.0",
|
|
62
63
|
"mdast-util-to-string": "^4.0.0",
|
|
63
64
|
"remark-gfm": "^4.0.1",
|
|
64
65
|
"remark-parse": "^11.0.0",
|
|
65
66
|
"remark-stringify": "^11.0.0",
|
|
67
|
+
"tinyglobby": "^0.2.15",
|
|
66
68
|
"unified": "^11.0.5",
|
|
67
69
|
"unified-lint-rule": "^3.0.1",
|
|
68
70
|
"unist-util-visit": "^5.1.0",
|
package/esm/245.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { Context, Data, Effect, Layer, Schema } from "effect";
|
|
2
|
-
export { default as remark_gfm } from "remark-gfm";
|
|
3
|
-
export { default as remark_parse } from "remark-parse";
|
|
4
|
-
export { default as remark_stringify } from "remark-stringify";
|
|
5
|
-
export { unified } from "unified";
|