fork-version 1.4.13 → 1.4.48

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/dist/index.d.ts CHANGED
@@ -3,26 +3,18 @@ import { ReleaseType } from 'semver';
3
3
 
4
4
  declare const ForkConfigSchema: z.ZodObject<{
5
5
  /**
6
- * The path where the changes should be calculated from.
6
+ * The path fork-version will run from.
7
7
  * @default
8
8
  * ```js
9
9
  * process.cwd()
10
10
  * ```
11
11
  */
12
- changePath: z.ZodString;
12
+ path: z.ZodString;
13
13
  /**
14
- * The name of the changelog file.
14
+ * Name of the changelog file.
15
15
  * @default "CHANGELOG.md"
16
16
  */
17
17
  changelog: z.ZodString;
18
- /**
19
- * Files to be updated.
20
- * @default
21
- * ```js
22
- * ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]
23
- * ```
24
- */
25
- outFiles: z.ZodArray<z.ZodString, "many">;
26
18
  /**
27
19
  * The header to be used in the changelog.
28
20
  * @default
@@ -34,16 +26,44 @@ declare const ForkConfigSchema: z.ZodObject<{
34
26
  */
35
27
  header: z.ZodString;
36
28
  /**
37
- * Specify a prefix for the git tag that will be taken into account during the comparison.
29
+ * Files to be updated.
30
+ * @default
31
+ * ```js
32
+ * ["bower.json", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]
33
+ * ```
34
+ */
35
+ files: z.ZodArray<z.ZodString, "many">;
36
+ /**
37
+ * Specify a prefix for the git tag fork-version will create.
38
+ *
39
+ * For instance if your version tag is prefixed by "version/" instead of "v" you have to specify
40
+ * `tagPrefix: "version/"`.
38
41
  *
39
- * For instance if your version tag is prefixed by `version/` instead of `v` you would
40
- * have to specify `tagPrefix: "version/"`.
41
- * @default `v`
42
+ * `tagPrefix` can also be used for a monorepo environment where you might want to deploy
43
+ * multiple package from the same repository. In this case you can specify a prefix for
44
+ * each package:
45
+ *
46
+ * | Value | Tag Created |
47
+ * |:-------------------------|:------------------------------|
48
+ * | "" | `1.2.3` |
49
+ * | "version/" | `version/1.2.3` |
50
+ * | "@eglavin/fork-version-" | `@eglavin/fork-version-1.2.3` |
51
+ *
52
+ * @example "", "version/", "@eglavin/fork-version-"
53
+ * @default "v"
42
54
  */
43
55
  tagPrefix: z.ZodString;
44
56
  /**
45
- * Make a pre-release with optional label to specify a tag id.
46
- * @example true, "alpha", "beta", "rc", etc.
57
+ * Make a pre-release with optional label, if value is a string it will be used as the
58
+ * pre-release tag.
59
+ *
60
+ * | Value | Version |
61
+ * |:----------|:----------------|
62
+ * | true | "1.2.3-0" |
63
+ * | "alpha" | "1.2.3-alpha-0" |
64
+ * | "beta" | "1.2.3-beta-0" |
65
+ *
66
+ * @example true, "alpha", "beta", "rc"
47
67
  * @default undefined
48
68
  */
49
69
  preReleaseTag: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
@@ -52,17 +72,27 @@ declare const ForkConfigSchema: z.ZodObject<{
52
72
  * @default false
53
73
  */
54
74
  commitAll: z.ZodBoolean;
75
+ /**
76
+ * If set we'll log debug information.
77
+ * @default false
78
+ */
79
+ debug: z.ZodBoolean;
55
80
  /**
56
81
  * If true, no output will be written to disk or committed.
57
82
  * @default false
58
83
  */
59
84
  dryRun: z.ZodBoolean;
60
85
  /**
61
- * If true and we cant find a version in an `outFiles`, we'll fallback and attempt
62
- * to use the latest git tag for the current version.
86
+ * If true and we cant find a version in the list of `files`, we'll fallback
87
+ * and attempt to use the latest git tag to get the current version.
63
88
  * @default true
64
89
  */
65
90
  gitTagFallback: z.ZodBoolean;
91
+ /**
92
+ * If set, we'll gather information about the current version and exit.
93
+ * @default false
94
+ */
95
+ inspectVersion: z.ZodBoolean;
66
96
  /**
67
97
  * Should we sign the git commit using GPG?
68
98
  * @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt GPG Sign Commits}
@@ -80,13 +110,14 @@ declare const ForkConfigSchema: z.ZodObject<{
80
110
  */
81
111
  verify: z.ZodBoolean;
82
112
  /**
83
- * If set, we'll use this version number instead of trying to find it in an `outFiles`.
113
+ * If set, we'll use this version number instead of trying to find a version from the list of `files`.
84
114
  * @example "1.0.0"
85
115
  * @default undefined
86
116
  */
87
117
  currentVersion: z.ZodOptional<z.ZodString>;
88
118
  /**
89
- * If set, we'll attempt to update the version number to this version.
119
+ * If set, we'll attempt to update the version number to this version, instead of incrementing
120
+ * using "conventional-commit".
90
121
  * @example "2.0.0"
91
122
  * @default undefined
92
123
  */
@@ -95,9 +126,6 @@ declare const ForkConfigSchema: z.ZodObject<{
95
126
  * Override the default conventional-changelog preset configuration.
96
127
  */
97
128
  changelogPresetConfig: z.ZodObject<{
98
- /**
99
- * An array of `type` objects representing the explicitly supported commit message types, and whether they should show up in generated `CHANGELOG`s.
100
- */
101
129
  types: z.ZodOptional<z.ZodArray<z.ZodObject<{
102
130
  type: z.ZodString;
103
131
  section: z.ZodOptional<z.ZodString>;
@@ -111,29 +139,11 @@ declare const ForkConfigSchema: z.ZodObject<{
111
139
  section?: string | undefined;
112
140
  hidden?: boolean | undefined;
113
141
  }>, "many">>;
114
- /**
115
- * A URL representing a specific commit at a hash.
116
- */
117
142
  commitUrlFormat: z.ZodOptional<z.ZodString>;
118
- /**
119
- * A URL representing the comparison between two git SHAs.
120
- */
121
143
  compareUrlFormat: z.ZodOptional<z.ZodString>;
122
- /**
123
- * A URL representing the issue format (allowing a different URL format to be swapped in for Gitlab, Bitbucket, etc).
124
- */
125
144
  issueUrlFormat: z.ZodOptional<z.ZodString>;
126
- /**
127
- * A URL representing the a user's profile URL on GitHub, Gitlab, etc. This URL is used for substituting @bcoe with https://github.com/bcoe in commit messages.
128
- */
129
145
  userUrlFormat: z.ZodOptional<z.ZodString>;
130
- /**
131
- * A string to be used to format the auto-generated release commit message.
132
- */
133
146
  releaseCommitMessageFormat: z.ZodOptional<z.ZodString>;
134
- /**
135
- * An array of prefixes used to detect references to issues
136
- */
137
147
  issuePrefixes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
138
148
  }, "strip", z.ZodTypeAny, {
139
149
  types?: {
@@ -161,14 +171,16 @@ declare const ForkConfigSchema: z.ZodObject<{
161
171
  issuePrefixes?: string[] | undefined;
162
172
  }>;
163
173
  }, "strip", z.ZodTypeAny, {
164
- changePath: string;
174
+ path: string;
165
175
  changelog: string;
166
- outFiles: string[];
167
176
  header: string;
177
+ files: string[];
168
178
  tagPrefix: string;
169
179
  commitAll: boolean;
180
+ debug: boolean;
170
181
  dryRun: boolean;
171
182
  gitTagFallback: boolean;
183
+ inspectVersion: boolean;
172
184
  sign: boolean;
173
185
  silent: boolean;
174
186
  verify: boolean;
@@ -189,14 +201,16 @@ declare const ForkConfigSchema: z.ZodObject<{
189
201
  currentVersion?: string | undefined;
190
202
  nextVersion?: string | undefined;
191
203
  }, {
192
- changePath: string;
204
+ path: string;
193
205
  changelog: string;
194
- outFiles: string[];
195
206
  header: string;
207
+ files: string[];
196
208
  tagPrefix: string;
197
209
  commitAll: boolean;
210
+ debug: boolean;
198
211
  dryRun: boolean;
199
212
  gitTagFallback: boolean;
213
+ inspectVersion: boolean;
200
214
  sign: boolean;
201
215
  silent: boolean;
202
216
  verify: boolean;
@@ -217,74 +231,93 @@ declare const ForkConfigSchema: z.ZodObject<{
217
231
  currentVersion?: string | undefined;
218
232
  nextVersion?: string | undefined;
219
233
  }>;
220
- type ForkConfig = z.infer<typeof ForkConfigSchema> & {
221
- /**
222
- * Log function, can be used to override the default `console.log` function
223
- * to log to a file or another service.
224
- * @default console.log
225
- */
226
- log: (...args: unknown[]) => void;
234
+ type ForkConfig = z.infer<typeof ForkConfigSchema>;
235
+ declare function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig>;
236
+
237
+ declare function getUserConfig(): Promise<ForkConfig>;
238
+
239
+ declare class Logger {
240
+ private config;
241
+ disableLogs: boolean;
242
+ constructor(config: Pick<ForkConfig, "silent" | "debug" | "inspectVersion">);
243
+ log(...messages: any[]): void;
244
+ warn(...messages: any[]): void;
245
+ error(...messages: any[]): void;
246
+ debug(...messages: any[]): void;
247
+ }
248
+
249
+ interface FileState {
250
+ name: string;
251
+ path: string;
252
+ version: string;
253
+ [other: string]: unknown;
254
+ }
255
+ interface IFileManager {
256
+ read(fileName: string): FileState | undefined;
257
+ write(filePath: string, newVersion: string): void;
258
+ }
259
+ declare class FileManager implements IFileManager {
260
+ private config;
261
+ private logger;
262
+ private JSONPackage;
263
+ private PlainText;
264
+ constructor(config: ForkConfig, logger: Logger);
227
265
  /**
228
- * Error logger function, can be used to override the default `console.error`
229
- * function to log to a file or another service.
230
- * @default console.error
266
+ * Get the state from the given file name.
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * fileManager.read("package.json");
271
+ * ```
272
+ *
273
+ * @returns
274
+ * ```json
275
+ * { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
276
+ * ```
231
277
  */
232
- error: (...args: unknown[]) => void;
278
+ read(fileName: string): FileState | undefined;
233
279
  /**
234
- * Debug logger function, by default this is a noop function, but can be replaced
235
- * with a custom logger function or `console.info` to print output.
236
- * @default () => {}
280
+ * Write the new version to the given file path.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * fileManager.write("/path/to/package.json", "1.2.3");
285
+ * ```
237
286
  */
238
- debug: (...args: unknown[]) => void;
239
- };
240
- declare function defineConfig(config: Partial<ForkConfig>): Partial<ForkConfig>;
287
+ write(filePath: string, newVersion: string): void;
288
+ }
241
289
 
242
- type FileState = {
243
- name: string;
244
- path: string;
245
- type: "package-file" | ({} & string);
290
+ interface CurrentVersion {
246
291
  version: string;
247
- isPrivate: boolean;
248
- };
249
- type CurrentVersion = {
250
- currentVersion: string;
251
292
  files: FileState[];
252
- };
253
- type NextVersion = {
254
- nextVersion: string;
293
+ }
294
+ declare function getCurrentVersion(config: ForkConfig, logger: Logger, fileManager: IFileManager): Promise<CurrentVersion>;
295
+ interface NextVersion {
296
+ version: string;
255
297
  level?: number;
256
298
  preMajor?: boolean;
257
299
  reason?: string;
258
300
  releaseType?: ReleaseType;
259
- };
260
- type BumpVersion = CurrentVersion & NextVersion;
261
- declare function bumpVersion(options: ForkConfig): Promise<BumpVersion>;
301
+ }
302
+ declare function getNextVersion(config: ForkConfig, logger: Logger, currentVersion: string): Promise<NextVersion>;
262
303
 
263
- type CreateChangelog = {
264
- path: string;
265
- exists: boolean;
266
- };
267
- type UpdateChangelog = {
268
- changelog: CreateChangelog;
304
+ interface UpdateChangelog {
305
+ changelogPath: string;
269
306
  oldContent: string;
270
307
  newContent: string;
271
- };
272
- declare function updateChangelog(options: ForkConfig, bumpResult: BumpVersion): Promise<UpdateChangelog>;
308
+ }
309
+ declare function updateChangelog(config: ForkConfig, logger: Logger, nextVersion: string): Promise<UpdateChangelog>;
273
310
 
274
- type CommitChanges = {
311
+ interface CommitChanges {
275
312
  filesToCommit: string[];
276
313
  gitAddOutput?: string;
277
314
  gitCommitOutput?: string;
278
- };
279
- declare function commitChanges(options: ForkConfig, bumpResult: BumpVersion): Promise<CommitChanges>;
315
+ }
316
+ declare function commitChanges(config: ForkConfig, logger: Logger, files: FileState[], nextVersion: string): Promise<CommitChanges>;
280
317
 
281
- type TagChanges = {
318
+ interface TagChanges {
282
319
  gitTagOutput: string;
283
- currentBranchName: string;
284
- hasPublicPackageFile: boolean;
285
- pushMessage: string;
286
- publishMessage: string;
287
- };
288
- declare function tagChanges(options: ForkConfig, bumpResult: BumpVersion): Promise<TagChanges>;
320
+ }
321
+ declare function tagChanges(config: ForkConfig, logger: Logger, nextVersion: string): Promise<TagChanges>;
289
322
 
290
- export { BumpVersion, ForkConfig, bumpVersion, commitChanges, defineConfig, tagChanges, updateChangelog };
323
+ export { type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigSchema, type IFileManager, type NextVersion, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { bumpVersion, commitChanges, defineConfig, tagChanges, updateChangelog } from './chunk-Z5YLEJGR.js';
1
+ export { FileManager, ForkConfigSchema, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog } from './chunk-S2VPLFG2.js';
2
2
  //# sourceMappingURL=out.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,79 +1,92 @@
1
1
  {
2
- "name": "fork-version",
3
- "version": "1.4.13",
4
- "license": "ISC",
5
- "description": "Replacement for standard version written with modern syntax",
6
- "homepage": "https://github.com/eglavin/fork-version",
7
- "bugs": {
8
- "url": "https://github.com/eglavin/fork-version/issues"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/eglavin/fork-version.git"
13
- },
14
- "author": {
15
- "name": "Eanna Glavin",
16
- "url": "https://eglavin.com"
17
- },
18
- "type": "module",
19
- "main": "dist/index.cjs",
20
- "module": "dist/index.js",
21
- "types": "dist/index.d.ts",
22
- "exports": {
23
- ".": {
24
- "import": "./dist/index.js",
25
- "require": "./dist/index.cjs",
26
- "types": "./dist/index.d.ts"
27
- },
28
- "./cli": {
29
- "import": "./dist/cli.js",
30
- "require": "./dist/cli.cjs",
31
- "types": "./dist/cli.d.ts"
32
- },
33
- "./package.json": "./package.json"
34
- },
35
- "bin": {
36
- "fork-version": "./dist/cli.js"
37
- },
38
- "files": [
39
- "dist"
40
- ],
41
- "scripts": {
42
- "fork-version": "node dist/cli.js",
43
- "dev": "tsup --watch",
44
- "build": "tsup",
45
- "lint:style": "prettier --write \"src/**/*.ts\"",
46
- "lint:code": "eslint --fix \"src/**/*.ts\""
47
- },
48
- "dependencies": {
49
- "bundle-require": "4.0.1",
50
- "conventional-changelog": "5.1.0",
51
- "conventional-changelog-config-spec": "2.1.0",
52
- "conventional-changelog-conventionalcommits": "7.0.2",
53
- "conventional-recommended-bump": "9.0.0",
54
- "detect-indent": "6.1.0",
55
- "detect-newline": "3.1.0",
56
- "esbuild": "0.19.3",
57
- "git-semver-tags": "7.0.1",
58
- "joycon": "3.1.1",
59
- "meow": "12.1.1",
60
- "semver": "7.5.4",
61
- "zod": "3.22.2"
62
- },
63
- "devDependencies": {
64
- "@types/conventional-changelog-config-spec": "2.1.3",
65
- "@types/git-raw-commits": "2.0.2",
66
- "@types/json-schema": "7.0.13",
67
- "@types/node": "20.6.2",
68
- "@types/semver": "7.5.2",
69
- "@typescript-eslint/eslint-plugin": "6.7.2",
70
- "@typescript-eslint/parser": "6.7.2",
71
- "eslint": "8.49.0",
72
- "eslint-config-prettier": "9.0.0",
73
- "eslint-plugin-prettier": "5.0.0",
74
- "globals": "13.21.0",
75
- "prettier": "3.0.3",
76
- "tsup": "7.2.0",
77
- "typescript": "5.2.2"
78
- }
2
+ "name": "fork-version",
3
+ "version": "1.4.48",
4
+ "license": "ISC",
5
+ "description": "Replacement for standard version written with modern syntax",
6
+ "homepage": "https://github.com/eglavin/fork-version",
7
+ "bugs": {
8
+ "url": "https://github.com/eglavin/fork-version/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/eglavin/fork-version.git"
13
+ },
14
+ "author": {
15
+ "name": "Eanna Glavin",
16
+ "url": "https://eglavin.com"
17
+ },
18
+ "packageManager": "pnpm@8.15.6",
19
+ "private": false,
20
+ "type": "module",
21
+ "main": "dist/index.cjs",
22
+ "module": "dist/index.js",
23
+ "types": "dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "./cli": {
31
+ "import": "./dist/cli.js",
32
+ "require": "./dist/cli.cjs",
33
+ "types": "./dist/cli.d.ts"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "bin": {
38
+ "fork-version": "./dist/cli.js"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md",
43
+ "README.md"
44
+ ],
45
+ "scripts": {
46
+ "fork-version": "node dist/cli.js",
47
+ "dev": "tsup --watch",
48
+ "build": "tsup",
49
+ "lint": "eslint --fix \"src/**/*.ts\"",
50
+ "lint:check": "eslint \"src/**/*.ts\"",
51
+ "lint:format": "prettier --write \"src/**/*.ts\"",
52
+ "typecheck": "tsc --noEmit",
53
+ "test": "vitest",
54
+ "test:cover": "vitest --coverage",
55
+ "test:ci": "vitest run --coverage --no-file-parallelism",
56
+ "test:ui": "vitest --ui",
57
+ "test:cleanup": "rimraf -g ../fork-version.tests/*"
58
+ },
59
+ "dependencies": {
60
+ "bundle-require": "4.0.2",
61
+ "conventional-changelog": "5.1.0",
62
+ "conventional-changelog-config-spec": "2.1.0",
63
+ "conventional-changelog-conventionalcommits": "7.0.2",
64
+ "conventional-recommended-bump": "9.0.0",
65
+ "detect-indent": "7.0.1",
66
+ "detect-newline": "4.0.1",
67
+ "esbuild": "0.20.2",
68
+ "git-semver-tags": "7.0.1",
69
+ "joycon": "3.1.1",
70
+ "meow": "13.2.0",
71
+ "semver": "7.6.0",
72
+ "zod": "3.22.4"
73
+ },
74
+ "devDependencies": {
75
+ "@types/git-raw-commits": "2.0.4",
76
+ "@types/json-schema": "7.0.15",
77
+ "@types/node": "20.11.30",
78
+ "@types/semver": "7.5.8",
79
+ "@vitest/coverage-v8": "1.4.0",
80
+ "@vitest/ui": "1.4.0",
81
+ "eslint": "8.57.0",
82
+ "eslint-config-prettier": "9.1.0",
83
+ "eslint-plugin-prettier": "5.1.3",
84
+ "globals": "15.0.0",
85
+ "prettier": "3.2.5",
86
+ "rimraf": "5.0.5",
87
+ "tsup": "8.0.2",
88
+ "typescript": "5.4.3",
89
+ "typescript-eslint": "7.4.0",
90
+ "vitest": "1.4.0"
91
+ }
79
92
  }