fork-version 1.4.91 → 1.4.95
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/CHANGELOG.md +32 -0
- package/dist/{chunk-NOQPR45O.cjs → chunk-6SI2AHBP.cjs} +238 -243
- package/dist/chunk-6SI2AHBP.cjs.map +1 -0
- package/dist/{chunk-3BQZUKK5.js → chunk-7ZOLJADN.js} +239 -242
- package/dist/chunk-7ZOLJADN.js.map +1 -0
- package/dist/cli.cjs +26 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +22 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +26 -24
- package/dist/chunk-3BQZUKK5.js.map +0 -1
- package/dist/chunk-NOQPR45O.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Fork Version
|
|
2
2
|
|
|
3
|
+
## 1.4.95 (2024-10-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Chore
|
|
7
|
+
|
|
8
|
+
* bump dependencies ([#71](https://github.com/eglavin/fork-version/issues/71)) ([d2d046c](https://github.com/eglavin/fork-version/commit/d2d046ca22bf7f0a078e3f1d02a10d8b6e98b9b5))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## 1.4.94 (2024-10-04)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Test
|
|
15
|
+
|
|
16
|
+
* improve versioning tests ([#68](https://github.com/eglavin/fork-version/issues/68)) ([635329c](https://github.com/eglavin/fork-version/commit/635329c6b9beb1929f5e03da6ecd76c340b7c406))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 1.4.93 (2024-07-28)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Refactor
|
|
23
|
+
|
|
24
|
+
* extract types from schema + use js file to define schema ([#69](https://github.com/eglavin/fork-version/issues/69)) ([01fccbe](https://github.com/eglavin/fork-version/commit/01fccbe020a70d2c5f8c3c3b6c33da6cb9260ebd))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## 1.4.92 (2024-06-21)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Refactor
|
|
31
|
+
|
|
32
|
+
* add should ignore option to git class + remove dotgitignore ([#67](https://github.com/eglavin/fork-version/issues/67)) ([527b8a4](https://github.com/eglavin/fork-version/commit/527b8a4766e59a509794a0de5ad978f92e3226bf))
|
|
33
|
+
|
|
34
|
+
|
|
3
35
|
## 1.4.91 (2024-06-17)
|
|
4
36
|
|
|
5
37
|
|
|
@@ -6,17 +6,16 @@ var path = require('path');
|
|
|
6
6
|
var JoyCon = require('joycon');
|
|
7
7
|
var bundleRequire = require('bundle-require');
|
|
8
8
|
var glob = require('glob');
|
|
9
|
-
var dotgitignore = require('dotgitignore');
|
|
10
9
|
var meow = require('meow');
|
|
11
10
|
var conventionalChangelogConfigSpec = require('conventional-changelog-config-spec');
|
|
12
11
|
var child_process = require('child_process');
|
|
12
|
+
var detectIndent = require('detect-indent');
|
|
13
|
+
var detectNewline = require('detect-newline');
|
|
14
|
+
var cheerio = require('cheerio/slim');
|
|
13
15
|
var semver3 = require('semver');
|
|
14
16
|
var conventionalRecommendedBump = require('conventional-recommended-bump');
|
|
15
17
|
var gitSemverTags = require('git-semver-tags');
|
|
16
18
|
var conventionalChangelog = require('conventional-changelog');
|
|
17
|
-
var detectIndent = require('detect-indent');
|
|
18
|
-
var detectNewline = require('detect-newline');
|
|
19
|
-
var cheerio = require('cheerio/lib/slim');
|
|
20
19
|
|
|
21
20
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
22
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -40,17 +39,16 @@ function _interopNamespace(e) {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
var JoyCon__default = /*#__PURE__*/_interopDefault(JoyCon);
|
|
43
|
-
var dotgitignore__default = /*#__PURE__*/_interopDefault(dotgitignore);
|
|
44
42
|
var meow__default = /*#__PURE__*/_interopDefault(meow);
|
|
45
43
|
var conventionalChangelogConfigSpec__default = /*#__PURE__*/_interopDefault(conventionalChangelogConfigSpec);
|
|
44
|
+
var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
|
|
45
|
+
var cheerio__namespace = /*#__PURE__*/_interopNamespace(cheerio);
|
|
46
46
|
var semver3__default = /*#__PURE__*/_interopDefault(semver3);
|
|
47
47
|
var conventionalRecommendedBump__default = /*#__PURE__*/_interopDefault(conventionalRecommendedBump);
|
|
48
48
|
var gitSemverTags__default = /*#__PURE__*/_interopDefault(gitSemverTags);
|
|
49
49
|
var conventionalChangelog__default = /*#__PURE__*/_interopDefault(conventionalChangelog);
|
|
50
|
-
var detectIndent__default = /*#__PURE__*/_interopDefault(detectIndent);
|
|
51
|
-
var cheerio__namespace = /*#__PURE__*/_interopNamespace(cheerio);
|
|
52
50
|
|
|
53
|
-
// src/config/schema.
|
|
51
|
+
// src/config/schema.js
|
|
54
52
|
var ChangelogPresetConfigTypeSchema = zod.z.object({
|
|
55
53
|
/**
|
|
56
54
|
* The type of commit message.
|
|
@@ -295,9 +293,6 @@ var ForkConfigSchema = zod.z.object({
|
|
|
295
293
|
*/
|
|
296
294
|
releaseMessageSuffix: zod.z.string().optional().describe("Add a suffix to the release commit message.")
|
|
297
295
|
});
|
|
298
|
-
function defineConfig(config) {
|
|
299
|
-
return config;
|
|
300
|
-
}
|
|
301
296
|
|
|
302
297
|
// src/config/defaults.ts
|
|
303
298
|
var DEFAULT_CONFIG = {
|
|
@@ -399,7 +394,7 @@ Examples:
|
|
|
399
394
|
Run fork-version and update all "package.json" files in subdirectories.`;
|
|
400
395
|
function getCliArguments() {
|
|
401
396
|
return meow__default.default(helperText, {
|
|
402
|
-
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('
|
|
397
|
+
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-6SI2AHBP.cjs', document.baseURI).href)) }),
|
|
403
398
|
booleanDefault: void 0,
|
|
404
399
|
helpIndent: 0,
|
|
405
400
|
flags: {
|
|
@@ -573,10 +568,7 @@ async function getUserConfig() {
|
|
|
573
568
|
const detectedGitHost = await detectGitHost(cwd);
|
|
574
569
|
return {
|
|
575
570
|
...mergedConfig,
|
|
576
|
-
files:
|
|
577
|
-
cwd,
|
|
578
|
-
getFilesList(configFile?.files, cliArguments.flags?.files, globResults)
|
|
579
|
-
),
|
|
571
|
+
files: getFilesList(configFile?.files, cliArguments.flags?.files, globResults),
|
|
580
572
|
path: cwd,
|
|
581
573
|
preRelease: (
|
|
582
574
|
// Meow doesn't support multiple flags with the same name, so we need to check both.
|
|
@@ -632,10 +624,232 @@ function getFilesList(configFiles, cliFiles, globResults) {
|
|
|
632
624
|
}
|
|
633
625
|
return DEFAULT_CONFIG.files;
|
|
634
626
|
}
|
|
635
|
-
function
|
|
636
|
-
|
|
637
|
-
|
|
627
|
+
function defineConfig(config) {
|
|
628
|
+
return config;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/utils/logger.ts
|
|
632
|
+
var Logger = class {
|
|
633
|
+
constructor(config) {
|
|
634
|
+
this.config = config;
|
|
635
|
+
this.log = this.log.bind(this);
|
|
636
|
+
this.warn = this.warn.bind(this);
|
|
637
|
+
this.error = this.error.bind(this);
|
|
638
|
+
this.debug = this.debug.bind(this);
|
|
639
|
+
this.disableLogs = this.config.silent || this.config.inspectVersion;
|
|
640
|
+
}
|
|
641
|
+
disableLogs = false;
|
|
642
|
+
log(...messages) {
|
|
643
|
+
if (!this.disableLogs) {
|
|
644
|
+
console.log(...messages);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
warn(...messages) {
|
|
648
|
+
if (!this.disableLogs) {
|
|
649
|
+
console.warn(...messages);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
error(...messages) {
|
|
653
|
+
if (!this.disableLogs) {
|
|
654
|
+
console.error(...messages);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
debug(...messages) {
|
|
658
|
+
if (this.config.debug && !this.disableLogs) {
|
|
659
|
+
console.debug(...messages);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// src/libs/stringify-package.ts
|
|
665
|
+
var DEFAULT_INDENT = 2;
|
|
666
|
+
var CRLF = "\r\n";
|
|
667
|
+
var LF = "\n";
|
|
668
|
+
function stringifyPackage(data, indent, newline) {
|
|
669
|
+
const stringified = JSON.stringify(data, null, indent ?? DEFAULT_INDENT);
|
|
670
|
+
if (newline === CRLF) {
|
|
671
|
+
return stringified.replace(new RegExp(LF, "g"), CRLF);
|
|
672
|
+
}
|
|
673
|
+
return stringified;
|
|
674
|
+
}
|
|
675
|
+
function fileExists(filePath) {
|
|
676
|
+
try {
|
|
677
|
+
return fs.lstatSync(filePath).isFile();
|
|
678
|
+
} catch (_error) {
|
|
679
|
+
return false;
|
|
680
|
+
}
|
|
638
681
|
}
|
|
682
|
+
|
|
683
|
+
// src/strategies/json-package.ts
|
|
684
|
+
var JSONPackage = class {
|
|
685
|
+
constructor(config, logger) {
|
|
686
|
+
this.config = config;
|
|
687
|
+
this.logger = logger;
|
|
688
|
+
}
|
|
689
|
+
read(fileName) {
|
|
690
|
+
const filePath = path.resolve(this.config.path, fileName);
|
|
691
|
+
if (fileExists(filePath)) {
|
|
692
|
+
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
693
|
+
const parsedJson = JSON.parse(fileContents);
|
|
694
|
+
if (parsedJson.version) {
|
|
695
|
+
return {
|
|
696
|
+
name: fileName,
|
|
697
|
+
path: filePath,
|
|
698
|
+
version: parsedJson.version,
|
|
699
|
+
isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
this.logger.warn(`[File Manager] Unable to determine json package: ${fileName}`);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
write(fileState, newVersion) {
|
|
706
|
+
const fileContents = fs.readFileSync(fileState.path, "utf8");
|
|
707
|
+
const parsedJson = JSON.parse(fileContents);
|
|
708
|
+
parsedJson.version = newVersion;
|
|
709
|
+
if (parsedJson.packages?.[""]) {
|
|
710
|
+
parsedJson.packages[""].version = newVersion;
|
|
711
|
+
}
|
|
712
|
+
fs.writeFileSync(
|
|
713
|
+
fileState.path,
|
|
714
|
+
stringifyPackage(parsedJson, detectIndent__default.default(fileContents).indent, detectNewline.detectNewline(fileContents)),
|
|
715
|
+
"utf8"
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
isSupportedFile(fileName) {
|
|
719
|
+
return fileName.endsWith(".json");
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
var PlainText = class {
|
|
723
|
+
constructor(config, logger) {
|
|
724
|
+
this.config = config;
|
|
725
|
+
this.logger = logger;
|
|
726
|
+
}
|
|
727
|
+
read(fileName) {
|
|
728
|
+
const filePath = path.resolve(this.config.path, fileName);
|
|
729
|
+
if (fileExists(filePath)) {
|
|
730
|
+
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
731
|
+
return {
|
|
732
|
+
name: fileName,
|
|
733
|
+
path: filePath,
|
|
734
|
+
version: fileContents || ""
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
this.logger.warn(`[File Manager] Unable to determine plain text: ${fileName}`);
|
|
738
|
+
}
|
|
739
|
+
write(fileState, newVersion) {
|
|
740
|
+
fs.writeFileSync(fileState.path, newVersion, "utf8");
|
|
741
|
+
}
|
|
742
|
+
isSupportedFile(fileName) {
|
|
743
|
+
return fileName.endsWith("version.txt");
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
var MSBuildProject = class {
|
|
747
|
+
constructor(config, logger) {
|
|
748
|
+
this.config = config;
|
|
749
|
+
this.logger = logger;
|
|
750
|
+
}
|
|
751
|
+
read(fileName) {
|
|
752
|
+
const filePath = path.resolve(this.config.path, fileName);
|
|
753
|
+
if (fileExists(filePath)) {
|
|
754
|
+
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
755
|
+
const $ = cheerio__namespace.load(fileContents, {
|
|
756
|
+
xmlMode: true,
|
|
757
|
+
xml: { decodeEntities: false }
|
|
758
|
+
});
|
|
759
|
+
const version = $("Project > PropertyGroup > Version").text();
|
|
760
|
+
if (version) {
|
|
761
|
+
return {
|
|
762
|
+
name: fileName,
|
|
763
|
+
path: filePath,
|
|
764
|
+
version
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
this.logger.warn(`[File Manager] Unable to determine ms-build package: ${fileName}`);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
write(fileState, newVersion) {
|
|
771
|
+
const fileContents = fs.readFileSync(fileState.path, "utf8");
|
|
772
|
+
const $ = cheerio__namespace.load(fileContents, {
|
|
773
|
+
xmlMode: true,
|
|
774
|
+
xml: { decodeEntities: false }
|
|
775
|
+
});
|
|
776
|
+
$("Project > PropertyGroup > Version").text(newVersion);
|
|
777
|
+
const updatedContent = $.xml().replaceAll('"/>', '" />');
|
|
778
|
+
fs.writeFileSync(fileState.path, updatedContent, "utf8");
|
|
779
|
+
}
|
|
780
|
+
isSupportedFile(fileName) {
|
|
781
|
+
return [".csproj", ".dbproj", ".esproj", ".fsproj", ".props", ".vbproj", ".vcxproj"].findIndex(
|
|
782
|
+
(ext) => fileName.endsWith(ext)
|
|
783
|
+
) !== -1;
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
// src/strategies/file-manager.ts
|
|
788
|
+
var FileManager = class {
|
|
789
|
+
constructor(config, logger) {
|
|
790
|
+
this.config = config;
|
|
791
|
+
this.logger = logger;
|
|
792
|
+
this.JSONPackage = new JSONPackage(config, logger);
|
|
793
|
+
this.PlainText = new PlainText(config, logger);
|
|
794
|
+
this.MSBuildProject = new MSBuildProject(config, logger);
|
|
795
|
+
}
|
|
796
|
+
JSONPackage;
|
|
797
|
+
PlainText;
|
|
798
|
+
MSBuildProject;
|
|
799
|
+
/**
|
|
800
|
+
* Get the state from the given file name.
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```ts
|
|
804
|
+
* fileManager.read("package.json");
|
|
805
|
+
* ```
|
|
806
|
+
*
|
|
807
|
+
* @returns
|
|
808
|
+
* ```json
|
|
809
|
+
* { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
|
|
810
|
+
* ```
|
|
811
|
+
*/
|
|
812
|
+
read(fileName) {
|
|
813
|
+
const _fileName = fileName.toLowerCase();
|
|
814
|
+
if (this.JSONPackage.isSupportedFile(_fileName)) {
|
|
815
|
+
return this.JSONPackage.read(fileName);
|
|
816
|
+
}
|
|
817
|
+
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
818
|
+
return this.PlainText.read(fileName);
|
|
819
|
+
}
|
|
820
|
+
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
821
|
+
return this.MSBuildProject.read(fileName);
|
|
822
|
+
}
|
|
823
|
+
this.logger.error(`[File Manager] Unsupported file: ${fileName}`);
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Write the new version to the given file.
|
|
827
|
+
*
|
|
828
|
+
* @example
|
|
829
|
+
* ```ts
|
|
830
|
+
* fileManager.write(
|
|
831
|
+
* { name: "package.json", path: "/path/to/package.json", version: "1.2.2" },
|
|
832
|
+
* "1.2.3"
|
|
833
|
+
* );
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
write(fileState, newVersion) {
|
|
837
|
+
if (this.config.dryRun) {
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
const _fileName = fileState.name.toLowerCase();
|
|
841
|
+
if (this.JSONPackage.isSupportedFile(_fileName)) {
|
|
842
|
+
return this.JSONPackage.write(fileState, newVersion);
|
|
843
|
+
}
|
|
844
|
+
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
845
|
+
return this.PlainText.write(fileState, newVersion);
|
|
846
|
+
}
|
|
847
|
+
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
848
|
+
return this.MSBuildProject.write(fileState, newVersion);
|
|
849
|
+
}
|
|
850
|
+
this.logger.error(`[File Manager] Unsupported file: ${fileState.path}`);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
639
853
|
async function getLatestGitTagVersion(tagPrefix) {
|
|
640
854
|
const gitTags = await gitSemverTags__default.default({ tagPrefix });
|
|
641
855
|
if (!gitTags.length) {
|
|
@@ -679,10 +893,10 @@ function getReleaseType(releaseType, currentVersion, preReleaseTag) {
|
|
|
679
893
|
}
|
|
680
894
|
|
|
681
895
|
// src/process/version.ts
|
|
682
|
-
async function getCurrentVersion(config, logger, fileManager) {
|
|
896
|
+
async function getCurrentVersion(config, logger, fileManager, filesToUpdate) {
|
|
683
897
|
const files = [];
|
|
684
898
|
const versions = /* @__PURE__ */ new Set();
|
|
685
|
-
for (const file of
|
|
899
|
+
for (const file of filesToUpdate) {
|
|
686
900
|
const fileState = fileManager.read(file);
|
|
687
901
|
if (fileState) {
|
|
688
902
|
files.push(fileState);
|
|
@@ -748,7 +962,7 @@ async function getNextVersion(config, logger, currentVersion) {
|
|
|
748
962
|
tagPrefix: config.tagPrefix,
|
|
749
963
|
cwd: config.path
|
|
750
964
|
});
|
|
751
|
-
} catch (
|
|
965
|
+
} catch (_error) {
|
|
752
966
|
throw new Error(`[conventional-recommended-bump] Unable to determine next version`);
|
|
753
967
|
}
|
|
754
968
|
if (recommendedBump.releaseType) {
|
|
@@ -772,15 +986,6 @@ async function getNextVersion(config, logger, currentVersion) {
|
|
|
772
986
|
}
|
|
773
987
|
throw new Error("Unable to find next version");
|
|
774
988
|
}
|
|
775
|
-
function fileExists(filePath) {
|
|
776
|
-
try {
|
|
777
|
-
return fs.lstatSync(filePath).isFile();
|
|
778
|
-
} catch (e) {
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
// src/process/changelog.ts
|
|
784
989
|
var RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/m;
|
|
785
990
|
function getOldReleaseContent(filePath, exists) {
|
|
786
991
|
if (exists) {
|
|
@@ -906,216 +1111,6 @@ async function tagChanges(config, logger, git, nextVersion) {
|
|
|
906
1111
|
);
|
|
907
1112
|
}
|
|
908
1113
|
|
|
909
|
-
// src/libs/stringify-package.ts
|
|
910
|
-
var DEFAULT_INDENT = 2;
|
|
911
|
-
var CRLF = "\r\n";
|
|
912
|
-
var LF = "\n";
|
|
913
|
-
function stringifyPackage(data, indent, newline) {
|
|
914
|
-
const stringified = JSON.stringify(data, null, indent ?? DEFAULT_INDENT);
|
|
915
|
-
if (newline === CRLF) {
|
|
916
|
-
return stringified.replace(new RegExp(LF, "g"), CRLF);
|
|
917
|
-
}
|
|
918
|
-
return stringified;
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// src/strategies/json-package.ts
|
|
922
|
-
var JSONPackage = class {
|
|
923
|
-
constructor(config, logger) {
|
|
924
|
-
this.config = config;
|
|
925
|
-
this.logger = logger;
|
|
926
|
-
}
|
|
927
|
-
read(fileName) {
|
|
928
|
-
const filePath = path.resolve(this.config.path, fileName);
|
|
929
|
-
if (fileExists(filePath)) {
|
|
930
|
-
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
931
|
-
const parsedJson = JSON.parse(fileContents);
|
|
932
|
-
if (parsedJson.version) {
|
|
933
|
-
return {
|
|
934
|
-
name: fileName,
|
|
935
|
-
path: filePath,
|
|
936
|
-
version: parsedJson.version,
|
|
937
|
-
isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
this.logger.warn(`[File Manager] Unable to determine json package: ${fileName}`);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
write(fileState, newVersion) {
|
|
944
|
-
const fileContents = fs.readFileSync(fileState.path, "utf8");
|
|
945
|
-
const parsedJson = JSON.parse(fileContents);
|
|
946
|
-
parsedJson.version = newVersion;
|
|
947
|
-
if (parsedJson.packages?.[""]) {
|
|
948
|
-
parsedJson.packages[""].version = newVersion;
|
|
949
|
-
}
|
|
950
|
-
fs.writeFileSync(
|
|
951
|
-
fileState.path,
|
|
952
|
-
stringifyPackage(parsedJson, detectIndent__default.default(fileContents).indent, detectNewline.detectNewline(fileContents)),
|
|
953
|
-
"utf8"
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
isSupportedFile(fileName) {
|
|
957
|
-
return fileName.endsWith(".json");
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
var PlainText = class {
|
|
961
|
-
constructor(config, logger) {
|
|
962
|
-
this.config = config;
|
|
963
|
-
this.logger = logger;
|
|
964
|
-
}
|
|
965
|
-
read(fileName) {
|
|
966
|
-
const filePath = path.resolve(this.config.path, fileName);
|
|
967
|
-
if (fileExists(filePath)) {
|
|
968
|
-
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
969
|
-
return {
|
|
970
|
-
name: fileName,
|
|
971
|
-
path: filePath,
|
|
972
|
-
version: fileContents || ""
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
this.logger.warn(`[File Manager] Unable to determine plain text: ${fileName}`);
|
|
976
|
-
}
|
|
977
|
-
write(fileState, newVersion) {
|
|
978
|
-
fs.writeFileSync(fileState.path, newVersion, "utf8");
|
|
979
|
-
}
|
|
980
|
-
isSupportedFile(fileName) {
|
|
981
|
-
return fileName.endsWith("version.txt");
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
var MSBuildProject = class {
|
|
985
|
-
constructor(config, logger) {
|
|
986
|
-
this.config = config;
|
|
987
|
-
this.logger = logger;
|
|
988
|
-
}
|
|
989
|
-
read(fileName) {
|
|
990
|
-
const filePath = path.resolve(this.config.path, fileName);
|
|
991
|
-
if (fileExists(filePath)) {
|
|
992
|
-
const fileContents = fs.readFileSync(filePath, "utf8");
|
|
993
|
-
const $ = cheerio__namespace.load(fileContents, { xmlMode: true, decodeEntities: false });
|
|
994
|
-
const version = $("Project > PropertyGroup > Version").text();
|
|
995
|
-
if (version) {
|
|
996
|
-
return {
|
|
997
|
-
name: fileName,
|
|
998
|
-
path: filePath,
|
|
999
|
-
version
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
this.logger.warn(`[File Manager] Unable to determine ms-build package: ${fileName}`);
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
write(fileState, newVersion) {
|
|
1006
|
-
const fileContents = fs.readFileSync(fileState.path, "utf8");
|
|
1007
|
-
const $ = cheerio__namespace.load(fileContents, { xmlMode: true, decodeEntities: false });
|
|
1008
|
-
$("Project > PropertyGroup > Version").text(newVersion);
|
|
1009
|
-
const updatedContent = $.xml().replaceAll('"/>', '" />');
|
|
1010
|
-
fs.writeFileSync(fileState.path, updatedContent, "utf8");
|
|
1011
|
-
}
|
|
1012
|
-
isSupportedFile(fileName) {
|
|
1013
|
-
return [".csproj", ".dbproj", ".esproj", ".fsproj", ".props", ".vbproj", ".vcxproj"].findIndex(
|
|
1014
|
-
(ext) => fileName.endsWith(ext)
|
|
1015
|
-
) !== -1;
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
// src/strategies/file-manager.ts
|
|
1020
|
-
var FileManager = class {
|
|
1021
|
-
constructor(config, logger) {
|
|
1022
|
-
this.config = config;
|
|
1023
|
-
this.logger = logger;
|
|
1024
|
-
this.JSONPackage = new JSONPackage(config, logger);
|
|
1025
|
-
this.PlainText = new PlainText(config, logger);
|
|
1026
|
-
this.MSBuildProject = new MSBuildProject(config, logger);
|
|
1027
|
-
}
|
|
1028
|
-
JSONPackage;
|
|
1029
|
-
PlainText;
|
|
1030
|
-
MSBuildProject;
|
|
1031
|
-
/**
|
|
1032
|
-
* Get the state from the given file name.
|
|
1033
|
-
*
|
|
1034
|
-
* @example
|
|
1035
|
-
* ```ts
|
|
1036
|
-
* fileManager.read("package.json");
|
|
1037
|
-
* ```
|
|
1038
|
-
*
|
|
1039
|
-
* @returns
|
|
1040
|
-
* ```json
|
|
1041
|
-
* { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
|
|
1042
|
-
* ```
|
|
1043
|
-
*/
|
|
1044
|
-
read(fileName) {
|
|
1045
|
-
const _fileName = fileName.toLowerCase();
|
|
1046
|
-
if (this.JSONPackage.isSupportedFile(_fileName)) {
|
|
1047
|
-
return this.JSONPackage.read(fileName);
|
|
1048
|
-
}
|
|
1049
|
-
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
1050
|
-
return this.PlainText.read(fileName);
|
|
1051
|
-
}
|
|
1052
|
-
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
1053
|
-
return this.MSBuildProject.read(fileName);
|
|
1054
|
-
}
|
|
1055
|
-
this.logger.error(`[File Manager] Unsupported file: ${fileName}`);
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Write the new version to the given file.
|
|
1059
|
-
*
|
|
1060
|
-
* @example
|
|
1061
|
-
* ```ts
|
|
1062
|
-
* fileManager.write(
|
|
1063
|
-
* { name: "package.json", path: "/path/to/package.json", version: "1.2.2" },
|
|
1064
|
-
* "1.2.3"
|
|
1065
|
-
* );
|
|
1066
|
-
* ```
|
|
1067
|
-
*/
|
|
1068
|
-
write(fileState, newVersion) {
|
|
1069
|
-
if (this.config.dryRun) {
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
const _fileName = fileState.name.toLowerCase();
|
|
1073
|
-
if (this.JSONPackage.isSupportedFile(_fileName)) {
|
|
1074
|
-
return this.JSONPackage.write(fileState, newVersion);
|
|
1075
|
-
}
|
|
1076
|
-
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
1077
|
-
return this.PlainText.write(fileState, newVersion);
|
|
1078
|
-
}
|
|
1079
|
-
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
1080
|
-
return this.MSBuildProject.write(fileState, newVersion);
|
|
1081
|
-
}
|
|
1082
|
-
this.logger.error(`[File Manager] Unsupported file: ${fileState.path}`);
|
|
1083
|
-
}
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
|
-
// src/utils/logger.ts
|
|
1087
|
-
var Logger = class {
|
|
1088
|
-
constructor(config) {
|
|
1089
|
-
this.config = config;
|
|
1090
|
-
this.log = this.log.bind(this);
|
|
1091
|
-
this.warn = this.warn.bind(this);
|
|
1092
|
-
this.error = this.error.bind(this);
|
|
1093
|
-
this.debug = this.debug.bind(this);
|
|
1094
|
-
this.disableLogs = this.config.silent || this.config.inspectVersion;
|
|
1095
|
-
}
|
|
1096
|
-
disableLogs = false;
|
|
1097
|
-
log(...messages) {
|
|
1098
|
-
if (!this.disableLogs) {
|
|
1099
|
-
console.log(...messages);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
warn(...messages) {
|
|
1103
|
-
if (!this.disableLogs) {
|
|
1104
|
-
console.warn(...messages);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
error(...messages) {
|
|
1108
|
-
if (!this.disableLogs) {
|
|
1109
|
-
console.error(...messages);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
debug(...messages) {
|
|
1113
|
-
if (this.config.debug && !this.disableLogs) {
|
|
1114
|
-
console.debug(...messages);
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
1114
|
exports.FileManager = FileManager;
|
|
1120
1115
|
exports.ForkConfigSchema = ForkConfigSchema;
|
|
1121
1116
|
exports.Logger = Logger;
|
|
@@ -1126,5 +1121,5 @@ exports.getNextVersion = getNextVersion;
|
|
|
1126
1121
|
exports.getUserConfig = getUserConfig;
|
|
1127
1122
|
exports.tagChanges = tagChanges;
|
|
1128
1123
|
exports.updateChangelog = updateChangelog;
|
|
1129
|
-
//# sourceMappingURL=
|
|
1130
|
-
//# sourceMappingURL=chunk-
|
|
1124
|
+
//# sourceMappingURL=chunk-6SI2AHBP.cjs.map
|
|
1125
|
+
//# sourceMappingURL=chunk-6SI2AHBP.cjs.map
|