@aneuhold/core-ts-lib 2.2.9 → 2.2.11

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.
Files changed (89) hide show
  1. package/lib/index.d.ts +5 -3
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.js +3 -2
  4. package/lib/index.js.map +1 -1
  5. package/lib/index.ts +5 -2
  6. package/lib/services/ChangelogService/ChangelogFileService.d.ts +42 -0
  7. package/lib/services/ChangelogService/ChangelogFileService.d.ts.map +1 -0
  8. package/lib/services/ChangelogService/ChangelogFileService.js +65 -0
  9. package/lib/services/ChangelogService/ChangelogFileService.js.map +1 -0
  10. package/lib/services/ChangelogService/ChangelogFileService.ts +68 -0
  11. package/lib/services/ChangelogService/ChangelogGenerator.d.ts +58 -0
  12. package/lib/services/ChangelogService/ChangelogGenerator.d.ts.map +1 -0
  13. package/lib/services/ChangelogService/ChangelogGenerator.js +145 -0
  14. package/lib/services/ChangelogService/ChangelogGenerator.js.map +1 -0
  15. package/lib/services/ChangelogService/ChangelogGenerator.ts +188 -0
  16. package/lib/services/ChangelogService/ChangelogParser.d.ts +21 -0
  17. package/lib/services/ChangelogService/ChangelogParser.d.ts.map +1 -0
  18. package/lib/services/ChangelogService/ChangelogParser.js +76 -0
  19. package/lib/services/ChangelogService/ChangelogParser.js.map +1 -0
  20. package/lib/services/ChangelogService/ChangelogParser.ts +94 -0
  21. package/lib/services/ChangelogService/ChangelogService.d.ts +54 -0
  22. package/lib/services/ChangelogService/ChangelogService.d.ts.map +1 -0
  23. package/lib/services/ChangelogService/ChangelogService.js +201 -0
  24. package/lib/services/ChangelogService/ChangelogService.js.map +1 -0
  25. package/lib/services/ChangelogService/ChangelogService.ts +293 -0
  26. package/lib/services/ChangelogService/ChangelogValidator.d.ts +15 -0
  27. package/lib/services/ChangelogService/ChangelogValidator.d.ts.map +1 -0
  28. package/lib/services/ChangelogService/ChangelogValidator.js +44 -0
  29. package/lib/services/ChangelogService/ChangelogValidator.js.map +1 -0
  30. package/lib/services/ChangelogService/ChangelogValidator.ts +55 -0
  31. package/lib/services/ChangelogService/GitTagService.d.ts +29 -0
  32. package/lib/services/ChangelogService/GitTagService.d.ts.map +1 -0
  33. package/lib/services/ChangelogService/GitTagService.js +57 -0
  34. package/lib/services/ChangelogService/GitTagService.js.map +1 -0
  35. package/lib/services/ChangelogService/GitTagService.ts +60 -0
  36. package/lib/services/ChangelogService/RepositoryInfoService.d.ts +14 -0
  37. package/lib/services/ChangelogService/RepositoryInfoService.d.ts.map +1 -0
  38. package/lib/services/ChangelogService/RepositoryInfoService.js +55 -0
  39. package/lib/services/ChangelogService/RepositoryInfoService.js.map +1 -0
  40. package/lib/services/ChangelogService/RepositoryInfoService.ts +64 -0
  41. package/lib/services/ChangelogService/index.d.ts +2 -0
  42. package/lib/services/ChangelogService/index.d.ts.map +1 -0
  43. package/lib/services/ChangelogService/index.js +2 -0
  44. package/lib/services/ChangelogService/index.js.map +1 -0
  45. package/lib/services/ChangelogService/index.ts +1 -0
  46. package/lib/services/ChangelogService/types.d.ts +27 -0
  47. package/lib/services/ChangelogService/types.d.ts.map +1 -0
  48. package/lib/services/ChangelogService/types.js +3 -0
  49. package/lib/services/ChangelogService/types.js.map +1 -0
  50. package/lib/services/ChangelogService/types.ts +30 -0
  51. package/lib/services/DependencyService.d.ts +2 -9
  52. package/lib/services/DependencyService.d.ts.map +1 -1
  53. package/lib/services/DependencyService.js +2 -11
  54. package/lib/services/DependencyService.js.map +1 -1
  55. package/lib/services/DependencyService.ts +2 -11
  56. package/lib/services/PackageService/JsrPackageService.d.ts +81 -0
  57. package/lib/services/PackageService/JsrPackageService.d.ts.map +1 -0
  58. package/lib/services/{PackageService.js → PackageService/JsrPackageService.js} +70 -312
  59. package/lib/services/PackageService/JsrPackageService.js.map +1 -0
  60. package/lib/services/{PackageService.ts → PackageService/JsrPackageService.ts} +79 -372
  61. package/lib/services/PackageService/NpmPackageService.d.ts +45 -0
  62. package/lib/services/PackageService/NpmPackageService.d.ts.map +1 -0
  63. package/lib/services/PackageService/NpmPackageService.js +146 -0
  64. package/lib/services/PackageService/NpmPackageService.js.map +1 -0
  65. package/lib/services/PackageService/NpmPackageService.ts +178 -0
  66. package/lib/services/PackageService/PackageService.d.ts +77 -0
  67. package/lib/services/PackageService/PackageService.d.ts.map +1 -0
  68. package/lib/services/PackageService/PackageService.js +96 -0
  69. package/lib/services/PackageService/PackageService.js.map +1 -0
  70. package/lib/services/PackageService/PackageService.ts +108 -0
  71. package/lib/services/PackageService/PackageServiceUtils.d.ts +69 -0
  72. package/lib/services/PackageService/PackageServiceUtils.d.ts.map +1 -0
  73. package/lib/services/PackageService/PackageServiceUtils.js +185 -0
  74. package/lib/services/PackageService/PackageServiceUtils.js.map +1 -0
  75. package/lib/services/PackageService/PackageServiceUtils.ts +239 -0
  76. package/lib/services/StringService.d.ts +12 -0
  77. package/lib/services/StringService.d.ts.map +1 -1
  78. package/lib/services/StringService.js +56 -0
  79. package/lib/services/StringService.js.map +1 -1
  80. package/lib/services/StringService.ts +72 -0
  81. package/lib/types/VersionType.d.ts +9 -0
  82. package/lib/types/VersionType.d.ts.map +1 -0
  83. package/lib/types/VersionType.js +10 -0
  84. package/lib/types/VersionType.js.map +1 -0
  85. package/lib/types/VersionType.ts +8 -0
  86. package/package.json +7 -6
  87. package/lib/services/PackageService.d.ts +0 -159
  88. package/lib/services/PackageService.d.ts.map +0 -1
  89. package/lib/services/PackageService.js.map +0 -1
@@ -0,0 +1,69 @@
1
+ import { VersionType } from '../../types/VersionType.js';
2
+ /**
3
+ * Utility service containing common functionality shared between JSR and NPM package services.
4
+ */
5
+ export default class PackageServiceUtils {
6
+ /**
7
+ * Gets the package name and version from package.json.
8
+ *
9
+ * @returns An object containing the package name and version
10
+ */
11
+ static getPackageInfo(): Promise<{
12
+ packageName: string;
13
+ version: string;
14
+ }>;
15
+ /**
16
+ * Validates the current project for changes and changelog before publishing.
17
+ *
18
+ * @param currentVersion The current version to validate changelog for
19
+ */
20
+ static validatePrePublishRequirements(currentVersion: string): Promise<void>;
21
+ /**
22
+ * Common logic for checking version conflicts between current and latest versions.
23
+ *
24
+ * @param currentVersion The current version from package.json
25
+ * @param latestVersion The latest published version
26
+ * @param registryName The name of the registry (for error messages)
27
+ */
28
+ static checkVersionConflict(currentVersion: string, latestVersion: string, registryName: string): void;
29
+ /**
30
+ * Replaces the package name in all files in the root directory, but no child directories,
31
+ * with a new name.
32
+ *
33
+ * @param originalPackageName The original package name to replace
34
+ * @param newPackageName The new package name to use
35
+ */
36
+ static replacePackageName(originalPackageName: string, newPackageName: string): Promise<void>;
37
+ /**
38
+ * Performs a git reset to discard all changes in the working directory.
39
+ * This is used between alternative package name operations.
40
+ */
41
+ static resetGitChanges(): Promise<void>;
42
+ /**
43
+ * Initializes a changelog for the current project if one doesn't exist.
44
+ * This operation is idempotent - it won't modify existing content.
45
+ *
46
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
47
+ */
48
+ static initializeChangelog(packagePath?: string): Promise<void>;
49
+ /**
50
+ * Bumps the version if needed based on npm registry comparison and initializes changelog.
51
+ * This operation is idempotent - it will only bump if the current version conflicts with
52
+ * the registry, and changelog initialization won't modify existing content.
53
+ *
54
+ * @param versionType The type of version bump (patch, minor, major). Defaults to patch.
55
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
56
+ */
57
+ static bumpVersionIfNeededAndInitializeChangelog(versionType?: VersionType, packagePath?: string): Promise<void>;
58
+ /**
59
+ * Checks if a version bump is needed by comparing current version with npm registry
60
+ * and considering the requested version type.
61
+ *
62
+ * @param packageName The package name to check
63
+ * @param currentVersion The current version from package.json
64
+ * @param versionType The type of version bump requested
65
+ * @returns true if a version bump is needed, false otherwise
66
+ */
67
+ private static checkIfVersionBumpNeeded;
68
+ }
69
+ //# sourceMappingURL=PackageServiceUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageServiceUtils.d.ts","sourceRoot":"","sources":["../../../src/services/PackageService/PackageServiceUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAUzD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC;;;;OAIG;WACU,cAAc,IAAI,OAAO,CAAC;QACrC,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAwBF;;;;OAIG;WACU,8BAA8B,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlF;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CACzB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,IAAI;IAqBP;;;;;;OAMG;WACU,kBAAkB,CAC7B,mBAAmB,EAAE,MAAM,EAC3B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;OAGG;WACU,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAU7C;;;;;OAKG;WACU,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrE;;;;;;;OAOG;WACU,yCAAyC,CACpD,WAAW,GAAE,WAA+B,EAC5C,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAiChB;;;;;;;;OAQG;mBACkB,wBAAwB;CAmC9C"}
@@ -0,0 +1,185 @@
1
+ import { exec } from 'child_process';
2
+ import { access, readFile } from 'fs/promises';
3
+ import path from 'path';
4
+ import { promisify } from 'util';
5
+ import { VersionType } from '../../types/VersionType.js';
6
+ import ErrorUtils from '../../utils/ErrorUtils.js';
7
+ import ChangelogService from '../ChangelogService/index.js';
8
+ import { DR } from '../DependencyRegistry.js';
9
+ import DependencyService from '../DependencyService.js';
10
+ import FileSystemService from '../FileSystemService/FileSystemService.js';
11
+ import StringService from '../StringService.js';
12
+ const execAsync = promisify(exec);
13
+ /**
14
+ * Utility service containing common functionality shared between JSR and NPM package services.
15
+ */
16
+ export default class PackageServiceUtils {
17
+ /**
18
+ * Gets the package name and version from package.json.
19
+ *
20
+ * @returns An object containing the package name and version
21
+ */
22
+ static async getPackageInfo() {
23
+ const rootDir = process.cwd();
24
+ const packageJsonPath = path.join(rootDir, 'package.json');
25
+ try {
26
+ await access(packageJsonPath);
27
+ }
28
+ catch {
29
+ throw new Error('No package.json file found in the current directory.');
30
+ }
31
+ try {
32
+ const packageJsonData = JSON.parse(await readFile(packageJsonPath, 'utf-8'));
33
+ return {
34
+ packageName: packageJsonData.name,
35
+ version: packageJsonData.version
36
+ };
37
+ }
38
+ catch (error) {
39
+ const errorString = ErrorUtils.getErrorString(error);
40
+ DR.logger.error(`Failed to read package.json: ${errorString}`);
41
+ throw error;
42
+ }
43
+ }
44
+ /**
45
+ * Validates the current project for changes and changelog before publishing.
46
+ *
47
+ * @param currentVersion The current version to validate changelog for
48
+ */
49
+ static async validatePrePublishRequirements(currentVersion) {
50
+ if (await FileSystemService.hasPendingChanges()) {
51
+ DR.logger.error('Please commit or stash your changes before publishing.');
52
+ process.exit(1);
53
+ }
54
+ // Validate changelog for the current version before proceeding
55
+ await ChangelogService.validateChangelogForVersion(currentVersion);
56
+ }
57
+ /**
58
+ * Common logic for checking version conflicts between current and latest versions.
59
+ *
60
+ * @param currentVersion The current version from package.json
61
+ * @param latestVersion The latest published version
62
+ * @param registryName The name of the registry (for error messages)
63
+ */
64
+ static checkVersionConflict(currentVersion, latestVersion, registryName) {
65
+ DR.logger.info(`Current version: ${currentVersion}, Latest on ${registryName}: ${latestVersion}`);
66
+ // Compare versions using semver-like comparison
67
+ const comparison = StringService.compareSemanticVersions(currentVersion, latestVersion);
68
+ if (comparison === 0) {
69
+ throw new Error(`Version ${currentVersion} already exists on ${registryName}. Please bump the version before publishing.`);
70
+ }
71
+ else if (comparison < 0) {
72
+ throw new Error(`Current version ${currentVersion} is lower than the latest published version ${latestVersion} on ${registryName}. Please bump the version.`);
73
+ }
74
+ DR.logger.info('Version check passed - ready to publish.');
75
+ }
76
+ /**
77
+ * Replaces the package name in all files in the root directory, but no child directories,
78
+ * with a new name.
79
+ *
80
+ * @param originalPackageName The original package name to replace
81
+ * @param newPackageName The new package name to use
82
+ */
83
+ static async replacePackageName(originalPackageName, newPackageName) {
84
+ DR.logger.info(`Replacing package name from "${originalPackageName}" to "${newPackageName}"`);
85
+ const rootDir = process.cwd();
86
+ // Replace in all files in the root directory
87
+ await FileSystemService.replaceInFiles({
88
+ searchString: originalPackageName,
89
+ replaceString: newPackageName,
90
+ rootPath: rootDir,
91
+ includePatterns: ['*'],
92
+ excludePatterns: []
93
+ });
94
+ DR.logger.info(`Successfully replaced package name in configuration files`);
95
+ }
96
+ /**
97
+ * Performs a git reset to discard all changes in the working directory.
98
+ * This is used between alternative package name operations.
99
+ */
100
+ static async resetGitChanges() {
101
+ DR.logger.info('Resetting git changes');
102
+ try {
103
+ await execAsync('git reset --hard HEAD');
104
+ }
105
+ catch (error) {
106
+ DR.logger.error(`Failed to reset git changes: ${ErrorUtils.getErrorString(error)}`);
107
+ throw error;
108
+ }
109
+ }
110
+ /**
111
+ * Initializes a changelog for the current project if one doesn't exist.
112
+ * This operation is idempotent - it won't modify existing content.
113
+ *
114
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
115
+ */
116
+ static async initializeChangelog(packagePath) {
117
+ const { packageName, version } = await PackageServiceUtils.getPackageInfo();
118
+ await ChangelogService.initializeChangelog(version, packageName, packagePath);
119
+ }
120
+ /**
121
+ * Bumps the version if needed based on npm registry comparison and initializes changelog.
122
+ * This operation is idempotent - it will only bump if the current version conflicts with
123
+ * the registry, and changelog initialization won't modify existing content.
124
+ *
125
+ * @param versionType The type of version bump (patch, minor, major). Defaults to patch.
126
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
127
+ */
128
+ static async bumpVersionIfNeededAndInitializeChangelog(versionType = VersionType.Patch, packagePath) {
129
+ const { packageName, version: currentVersion } = await PackageServiceUtils.getPackageInfo();
130
+ DR.logger.info(`Checking if version bump is needed for ${packageName} (current: ${currentVersion})`);
131
+ // Check if version bump is needed by comparing with npm registry
132
+ const needsBump = await PackageServiceUtils.checkIfVersionBumpNeeded(packageName, currentVersion, versionType);
133
+ let finalVersion = currentVersion;
134
+ if (needsBump) {
135
+ DR.logger.info(`Version bump needed - bumping ${versionType} version`);
136
+ await DependencyService.bumpVersion(versionType);
137
+ // Get the new version after bump
138
+ const { version: newVersion } = await PackageServiceUtils.getPackageInfo();
139
+ finalVersion = newVersion;
140
+ DR.logger.success(`Version bumped from ${currentVersion} to ${finalVersion}`);
141
+ }
142
+ else {
143
+ DR.logger.info('No version bump needed - current version is valid');
144
+ }
145
+ // Initialize changelog with the final version
146
+ await ChangelogService.initializeChangelog(finalVersion, packageName, packagePath);
147
+ DR.logger.success(`Version preparation completed for ${packageName} version ${finalVersion}`);
148
+ }
149
+ /**
150
+ * Checks if a version bump is needed by comparing current version with npm registry
151
+ * and considering the requested version type.
152
+ *
153
+ * @param packageName The package name to check
154
+ * @param currentVersion The current version from package.json
155
+ * @param versionType The type of version bump requested
156
+ * @returns true if a version bump is needed, false otherwise
157
+ */
158
+ static async checkIfVersionBumpNeeded(packageName, currentVersion, versionType) {
159
+ DR.logger.info(`Checking npm registry for existing versions of ${packageName}...`);
160
+ let latestVersion = null;
161
+ try {
162
+ const { stdout } = await execAsync(`npm view ${packageName}`);
163
+ // Parse the npm view output to extract the latest version
164
+ const latestVersionMatch = stdout.match(/latest:\s*([^\s|]+)/);
165
+ if (latestVersionMatch) {
166
+ latestVersion = latestVersionMatch[1];
167
+ DR.logger.info(`Current version: ${currentVersion}, Latest on npm: ${latestVersion}`);
168
+ }
169
+ }
170
+ catch (error) {
171
+ const errorString = ErrorUtils.getErrorString(error);
172
+ // If the package doesn't exist on npm, no bump needed for first publish
173
+ if (errorString.includes('404') || errorString.includes('not found')) {
174
+ DR.logger.info('Package not found on npm - no version bump needed for first publish.');
175
+ return false;
176
+ }
177
+ // For other npm command errors, log but assume no bump needed to be safe
178
+ DR.logger.warn(`Could not check npm registry: ${errorString}`);
179
+ return false;
180
+ }
181
+ // Use the new logic to determine if bump is needed based on version type
182
+ return StringService.shouldBumpVersion(currentVersion, latestVersion, versionType);
183
+ }
184
+ }
185
+ //# sourceMappingURL=PackageServiceUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageServiceUtils.js","sourceRoot":"","sources":["../../../src/services/PackageService/PackageServiceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,iBAAiB,MAAM,2CAA2C,CAAC;AAC1E,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,cAAc;QAIzB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAE3D,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,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 import { promisify } from 'util';
5
+ import { PackageJson } from '../../types/PackageJson.js';
6
+ import { VersionType } from '../../types/VersionType.js';
7
+ import ErrorUtils from '../../utils/ErrorUtils.js';
8
+ import ChangelogService from '../ChangelogService/index.js';
9
+ import { DR } from '../DependencyRegistry.js';
10
+ import DependencyService from '../DependencyService.js';
11
+ import FileSystemService from '../FileSystemService/FileSystemService.js';
12
+ import StringService from '../StringService.js';
13
+
14
+ const execAsync = promisify(exec);
15
+
16
+ /**
17
+ * Utility service containing common functionality shared between JSR and NPM package services.
18
+ */
19
+ export default class PackageServiceUtils {
20
+ /**
21
+ * Gets the package name and version from package.json.
22
+ *
23
+ * @returns An object containing the package name and version
24
+ */
25
+ static async getPackageInfo(): Promise<{
26
+ packageName: string;
27
+ version: string;
28
+ }> {
29
+ const rootDir = process.cwd();
30
+ const packageJsonPath = path.join(rootDir, 'package.json');
31
+
32
+ try {
33
+ await access(packageJsonPath);
34
+ } catch {
35
+ throw new Error('No package.json file found in the current directory.');
36
+ }
37
+
38
+ try {
39
+ const packageJsonData = JSON.parse(await readFile(packageJsonPath, 'utf-8')) as PackageJson;
40
+
41
+ return {
42
+ packageName: packageJsonData.name,
43
+ version: packageJsonData.version
44
+ };
45
+ } catch (error) {
46
+ const errorString = ErrorUtils.getErrorString(error);
47
+ DR.logger.error(`Failed to read package.json: ${errorString}`);
48
+ throw error;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Validates the current project for changes and changelog before publishing.
54
+ *
55
+ * @param currentVersion The current version to validate changelog for
56
+ */
57
+ static async validatePrePublishRequirements(currentVersion: string): Promise<void> {
58
+ if (await FileSystemService.hasPendingChanges()) {
59
+ DR.logger.error('Please commit or stash your changes before publishing.');
60
+ process.exit(1);
61
+ }
62
+
63
+ // Validate changelog for the current version before proceeding
64
+ await ChangelogService.validateChangelogForVersion(currentVersion);
65
+ }
66
+
67
+ /**
68
+ * Common logic for checking version conflicts between current and latest versions.
69
+ *
70
+ * @param currentVersion The current version from package.json
71
+ * @param latestVersion The latest published version
72
+ * @param registryName The name of the registry (for error messages)
73
+ */
74
+ static checkVersionConflict(
75
+ currentVersion: string,
76
+ latestVersion: string,
77
+ registryName: string
78
+ ): void {
79
+ DR.logger.info(
80
+ `Current version: ${currentVersion}, Latest on ${registryName}: ${latestVersion}`
81
+ );
82
+
83
+ // Compare versions using semver-like comparison
84
+ const comparison = StringService.compareSemanticVersions(currentVersion, latestVersion);
85
+
86
+ if (comparison === 0) {
87
+ throw new Error(
88
+ `Version ${currentVersion} already exists on ${registryName}. Please bump the version before publishing.`
89
+ );
90
+ } else if (comparison < 0) {
91
+ throw new Error(
92
+ `Current version ${currentVersion} is lower than the latest published version ${latestVersion} on ${registryName}. Please bump the version.`
93
+ );
94
+ }
95
+
96
+ DR.logger.info('Version check passed - ready to publish.');
97
+ }
98
+
99
+ /**
100
+ * Replaces the package name in all files in the root directory, but no child directories,
101
+ * with a new name.
102
+ *
103
+ * @param originalPackageName The original package name to replace
104
+ * @param newPackageName The new package name to use
105
+ */
106
+ static async replacePackageName(
107
+ originalPackageName: string,
108
+ newPackageName: string
109
+ ): Promise<void> {
110
+ DR.logger.info(`Replacing package name from "${originalPackageName}" to "${newPackageName}"`);
111
+
112
+ const rootDir = process.cwd();
113
+
114
+ // Replace in all files in the root directory
115
+ await FileSystemService.replaceInFiles({
116
+ searchString: originalPackageName,
117
+ replaceString: newPackageName,
118
+ rootPath: rootDir,
119
+ includePatterns: ['*'],
120
+ excludePatterns: []
121
+ });
122
+
123
+ DR.logger.info(`Successfully replaced package name in configuration files`);
124
+ }
125
+
126
+ /**
127
+ * Performs a git reset to discard all changes in the working directory.
128
+ * This is used between alternative package name operations.
129
+ */
130
+ static async resetGitChanges(): Promise<void> {
131
+ DR.logger.info('Resetting git changes');
132
+ try {
133
+ await execAsync('git reset --hard HEAD');
134
+ } catch (error) {
135
+ DR.logger.error(`Failed to reset git changes: ${ErrorUtils.getErrorString(error)}`);
136
+ throw error;
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Initializes a changelog for the current project if one doesn't exist.
142
+ * This operation is idempotent - it won't modify existing content.
143
+ *
144
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
145
+ */
146
+ static async initializeChangelog(packagePath?: string): Promise<void> {
147
+ const { packageName, version } = await PackageServiceUtils.getPackageInfo();
148
+ await ChangelogService.initializeChangelog(version, packageName, packagePath);
149
+ }
150
+
151
+ /**
152
+ * Bumps the version if needed based on npm registry comparison and initializes changelog.
153
+ * This operation is idempotent - it will only bump if the current version conflicts with
154
+ * the registry, and changelog initialization won't modify existing content.
155
+ *
156
+ * @param versionType The type of version bump (patch, minor, major). Defaults to patch.
157
+ * @param packagePath Optional path to the package directory (defaults to current working directory)
158
+ */
159
+ static async bumpVersionIfNeededAndInitializeChangelog(
160
+ versionType: VersionType = VersionType.Patch,
161
+ packagePath?: string
162
+ ): Promise<void> {
163
+ const { packageName, version: currentVersion } = await PackageServiceUtils.getPackageInfo();
164
+
165
+ DR.logger.info(
166
+ `Checking if version bump is needed for ${packageName} (current: ${currentVersion})`
167
+ );
168
+
169
+ // Check if version bump is needed by comparing with npm registry
170
+ const needsBump = await PackageServiceUtils.checkIfVersionBumpNeeded(
171
+ packageName,
172
+ currentVersion,
173
+ versionType
174
+ );
175
+
176
+ let finalVersion = currentVersion;
177
+ if (needsBump) {
178
+ DR.logger.info(`Version bump needed - bumping ${versionType} version`);
179
+ await DependencyService.bumpVersion(versionType);
180
+
181
+ // Get the new version after bump
182
+ const { version: newVersion } = await PackageServiceUtils.getPackageInfo();
183
+ finalVersion = newVersion;
184
+ DR.logger.success(`Version bumped from ${currentVersion} to ${finalVersion}`);
185
+ } else {
186
+ DR.logger.info('No version bump needed - current version is valid');
187
+ }
188
+
189
+ // Initialize changelog with the final version
190
+ await ChangelogService.initializeChangelog(finalVersion, packageName, packagePath);
191
+
192
+ DR.logger.success(`Version preparation completed for ${packageName} version ${finalVersion}`);
193
+ }
194
+
195
+ /**
196
+ * Checks if a version bump is needed by comparing current version with npm registry
197
+ * and considering the requested version type.
198
+ *
199
+ * @param packageName The package name to check
200
+ * @param currentVersion The current version from package.json
201
+ * @param versionType The type of version bump requested
202
+ * @returns true if a version bump is needed, false otherwise
203
+ */
204
+ private static async checkIfVersionBumpNeeded(
205
+ packageName: string,
206
+ currentVersion: string,
207
+ versionType: VersionType
208
+ ): Promise<boolean> {
209
+ DR.logger.info(`Checking npm registry for existing versions of ${packageName}...`);
210
+
211
+ let latestVersion: string | null = null;
212
+
213
+ try {
214
+ const { stdout } = await execAsync(`npm view ${packageName}`);
215
+
216
+ // Parse the npm view output to extract the latest version
217
+ const latestVersionMatch = stdout.match(/latest:\s*([^\s|]+)/);
218
+ if (latestVersionMatch) {
219
+ latestVersion = latestVersionMatch[1];
220
+ DR.logger.info(`Current version: ${currentVersion}, Latest on npm: ${latestVersion}`);
221
+ }
222
+ } catch (error) {
223
+ const errorString = ErrorUtils.getErrorString(error);
224
+
225
+ // If the package doesn't exist on npm, no bump needed for first publish
226
+ if (errorString.includes('404') || errorString.includes('not found')) {
227
+ DR.logger.info('Package not found on npm - no version bump needed for first publish.');
228
+ return false;
229
+ }
230
+
231
+ // For other npm command errors, log but assume no bump needed to be safe
232
+ DR.logger.warn(`Could not check npm registry: ${errorString}`);
233
+ return false;
234
+ }
235
+
236
+ // Use the new logic to determine if bump is needed based on version type
237
+ return StringService.shouldBumpVersion(currentVersion, latestVersion, versionType);
238
+ }
239
+ }
@@ -1,3 +1,4 @@
1
+ import { VersionType } from '../types/VersionType.js';
1
2
  /**
2
3
  * A service which can be used to interact with strings.
3
4
  */
@@ -18,5 +19,16 @@ export default class StringService {
18
19
  * @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2
19
20
  */
20
21
  static compareSemanticVersions(version1: string, version2: string): number;
22
+ /**
23
+ * Checks if a version needs to be bumped based on the desired version type.
24
+ * This considers both registry conflicts and whether the requested version type
25
+ * has been incremented from the published version.
26
+ *
27
+ * @param currentVersion The current version from package.json
28
+ * @param publishedVersion The latest published version (or null if not published)
29
+ * @param requestedVersionType The type of version bump requested
30
+ * @returns true if a version bump is needed, false otherwise
31
+ */
32
+ static shouldBumpVersion(currentVersion: string, publishedVersion: string | null, requestedVersionType: VersionType): boolean;
21
33
  }
22
34
  //# sourceMappingURL=StringService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StringService.d.ts","sourceRoot":"","sources":["../../src/services/StringService.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIjE;;;;;;OAMG;IACH,MAAM,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAgB3E"}
1
+ {"version":3,"file":"StringService.d.ts","sourceRoot":"","sources":["../../src/services/StringService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIjE;;;;;;OAMG;IACH,MAAM,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAiB1E;;;;;;;;;OASG;IACH,MAAM,CAAC,iBAAiB,CACtB,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,oBAAoB,EAAE,WAAW,GAChC,OAAO;CAuDX"}
@@ -1,3 +1,4 @@
1
+ import { VersionType } from '../types/VersionType.js';
1
2
  /**
2
3
  * A service which can be used to interact with strings.
3
4
  */
@@ -33,5 +34,60 @@ export default class StringService {
33
34
  }
34
35
  return 0;
35
36
  }
37
+ /**
38
+ * Checks if a version needs to be bumped based on the desired version type.
39
+ * This considers both registry conflicts and whether the requested version type
40
+ * has been incremented from the published version.
41
+ *
42
+ * @param currentVersion The current version from package.json
43
+ * @param publishedVersion The latest published version (or null if not published)
44
+ * @param requestedVersionType The type of version bump requested
45
+ * @returns true if a version bump is needed, false otherwise
46
+ */
47
+ static shouldBumpVersion(currentVersion, publishedVersion, requestedVersionType) {
48
+ // If no published version exists, no bump needed for first publish
49
+ if (!publishedVersion) {
50
+ return false;
51
+ }
52
+ const currentParts = currentVersion.split('.').map(Number);
53
+ const publishedParts = publishedVersion.split('.').map(Number);
54
+ const [currentMajor, currentMinor, currentPatch] = [
55
+ currentParts[0] || 0,
56
+ currentParts[1] || 0,
57
+ currentParts[2] || 0
58
+ ];
59
+ const [publishedMajor, publishedMinor, publishedPatch] = [
60
+ publishedParts[0] || 0,
61
+ publishedParts[1] || 0,
62
+ publishedParts[2] || 0
63
+ ];
64
+ // If current version is lower than or equal to published, always bump
65
+ const comparison = StringService.compareSemanticVersions(currentVersion, publishedVersion);
66
+ if (comparison <= 0) {
67
+ return true;
68
+ }
69
+ // Current version is higher than published, check if requested version type has been bumped
70
+ switch (requestedVersionType) {
71
+ case VersionType.Major:
72
+ // Need to bump if major version hasn't been incremented
73
+ return currentMajor <= publishedMajor;
74
+ case VersionType.Minor:
75
+ // Need to bump if major is same and minor hasn't been incremented
76
+ if (currentMajor > publishedMajor) {
77
+ return false; // Major was already bumped, no need for minor
78
+ }
79
+ return currentMajor === publishedMajor && currentMinor <= publishedMinor;
80
+ case VersionType.Patch:
81
+ default:
82
+ // Need to bump if major and minor are same and patch hasn't been incremented
83
+ if (currentMajor > publishedMajor ||
84
+ (currentMajor === publishedMajor && currentMinor > publishedMinor)) {
85
+ return false; // Major or minor was already bumped, no need for patch
86
+ }
87
+ return (currentMajor === publishedMajor &&
88
+ currentMinor === publishedMinor &&
89
+ currentPatch <= publishedPatch);
90
+ }
91
+ }
36
92
  }
37
93
  //# sourceMappingURL=StringService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StringService.js","sourceRoot":"","sources":["../../src/services/StringService.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAgB;QAC1C,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,uBAAuB,CAAC,QAAgB,EAAE,QAAgB;QAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAEzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAE7B,IAAI,KAAK,GAAG,KAAK;gBAAE,OAAO,CAAC,CAAC,CAAC;YAC7B,IAAI,KAAK,GAAG,KAAK;gBAAE,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
1
+ {"version":3,"file":"StringService.js","sourceRoot":"","sources":["../../src/services/StringService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;;;;;OAMG;IACH,M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