versionary 0.28.0 → 0.28.2

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.
@@ -1,22 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.nodeVersionStrategy = void 0;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
1
+ import fs from "node:fs";
2
+ import path from "node:path";
9
3
  function readJsonFile(targetPath) {
10
- return JSON.parse(node_fs_1.default.readFileSync(targetPath, "utf8"));
4
+ return JSON.parse(fs.readFileSync(targetPath, "utf8"));
11
5
  }
12
6
  function writeJsonFile(targetPath, value) {
13
- node_fs_1.default.writeFileSync(targetPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
7
+ fs.writeFileSync(targetPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
14
8
  }
15
9
  function updateNodeLockfileVersion(cwd, version) {
16
10
  const updated = [];
17
11
  for (const lockfile of ["package-lock.json", "npm-shrinkwrap.json"]) {
18
- const lockfilePath = node_path_1.default.join(cwd, lockfile);
19
- if (!node_fs_1.default.existsSync(lockfilePath)) {
12
+ const lockfilePath = path.join(cwd, lockfile);
13
+ if (!fs.existsSync(lockfilePath)) {
20
14
  continue;
21
15
  }
22
16
  const parsed = readJsonFile(lockfilePath);
@@ -29,15 +23,15 @@ function updateNodeLockfileVersion(cwd, version) {
29
23
  }
30
24
  return updated;
31
25
  }
32
- exports.nodeVersionStrategy = {
26
+ export const nodeVersionStrategy = {
33
27
  name: "node",
34
28
  getVersionFile(config) {
35
29
  return config["version-file"] ?? "package.json";
36
30
  },
37
31
  readVersion(cwd, config) {
38
32
  const versionFile = this.getVersionFile(config);
39
- const versionPath = node_path_1.default.join(cwd, versionFile);
40
- if (!node_fs_1.default.existsSync(versionPath)) {
33
+ const versionPath = path.join(cwd, versionFile);
34
+ if (!fs.existsSync(versionPath)) {
41
35
  throw new Error(`Versionary requires ${versionFile} to exist.`);
42
36
  }
43
37
  const packageJson = readJsonFile(versionPath);
@@ -48,8 +42,8 @@ exports.nodeVersionStrategy = {
48
42
  },
49
43
  writeVersion(cwd, config, version) {
50
44
  const versionFile = this.getVersionFile(config);
51
- const versionPath = node_path_1.default.join(cwd, versionFile);
52
- if (!node_fs_1.default.existsSync(versionPath)) {
45
+ const versionPath = path.join(cwd, versionFile);
46
+ if (!fs.existsSync(versionPath)) {
53
47
  throw new Error(`Versionary requires ${versionFile} to exist.`);
54
48
  }
55
49
  const packageJson = readJsonFile(versionPath);
@@ -66,8 +60,8 @@ exports.nodeVersionStrategy = {
66
60
  },
67
61
  readPackageName(cwd, config) {
68
62
  const versionFile = this.getVersionFile(config);
69
- const versionPath = node_path_1.default.join(cwd, versionFile);
70
- if (!node_fs_1.default.existsSync(versionPath)) {
63
+ const versionPath = path.join(cwd, versionFile);
64
+ if (!fs.existsSync(versionPath)) {
71
65
  throw new Error(`Versionary requires ${versionFile} to exist.`);
72
66
  }
73
67
  const packageJson = readJsonFile(versionPath);
@@ -1,13 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveReleaseName = resolveReleaseName;
7
- exports.resolvePackageStrategyContext = resolvePackageStrategyContext;
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const resolve_js_1 = require("./resolve.js");
10
- function resolveReleaseName(cwd, packagePath, packageConfig, strategy, strategyConfig) {
1
+ import path from "node:path";
2
+ import { resolveVersionStrategy } from "./resolve.js";
3
+ export function resolveReleaseName(cwd, packagePath, packageConfig, strategy, strategyConfig) {
11
4
  const configuredName = packageConfig["package-name"]?.trim();
12
5
  if (configuredName) {
13
6
  return configuredName;
@@ -20,7 +13,7 @@ function withVersionFile(config, versionFile) {
20
13
  "version-file": versionFile,
21
14
  };
22
15
  }
23
- function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
16
+ export function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
24
17
  const packageReleaseType = packageConfig["release-type"];
25
18
  const baseConfig = packageReleaseType
26
19
  ? {
@@ -28,7 +21,7 @@ function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
28
21
  "release-type": packageReleaseType,
29
22
  }
30
23
  : { ...rootConfig };
31
- const baseStrategy = (0, resolve_js_1.resolveVersionStrategy)(baseConfig);
24
+ const baseStrategy = resolveVersionStrategy(baseConfig);
32
25
  if (!packageReleaseType) {
33
26
  const versionFile = packagePath === "."
34
27
  ? (baseConfig["version-file"] ??
@@ -36,7 +29,7 @@ function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
36
29
  : baseStrategy.name === "simple"
37
30
  ? (baseConfig["version-file"] ??
38
31
  baseStrategy.getVersionFile(baseConfig))
39
- : node_path_1.default.posix.join(packagePath, baseStrategy.getVersionFile({
32
+ : path.posix.join(packagePath, baseStrategy.getVersionFile({
40
33
  ...baseConfig,
41
34
  "version-file": undefined,
42
35
  }));
@@ -52,7 +45,7 @@ function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
52
45
  }
53
46
  const packageVersionFile = packagePath === "."
54
47
  ? (baseConfig["version-file"] ?? baseStrategy.getVersionFile(baseConfig))
55
- : node_path_1.default.posix.join(packagePath, baseStrategy.getVersionFile({
48
+ : path.posix.join(packagePath, baseStrategy.getVersionFile({
56
49
  ...baseConfig,
57
50
  "version-file": undefined,
58
51
  }));
@@ -60,7 +53,7 @@ function resolvePackageStrategyContext(rootConfig, packagePath, packageConfig) {
60
53
  ...baseConfig,
61
54
  packages: packagePath === "." ? baseConfig.packages : undefined,
62
55
  }, packageVersionFile);
63
- const strategy = (0, resolve_js_1.resolveVersionStrategy)(config);
56
+ const strategy = resolveVersionStrategy(config);
64
57
  return {
65
58
  strategy,
66
59
  config,
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.pythonVersionStrategy = void 0;
7
- const node_child_process_1 = require("node:child_process");
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const toml_1 = __importDefault(require("@iarna/toml"));
1
+ import { execFileSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { parse as parseToml } from "smol-toml";
11
5
  const SOURCE_FILE_VERSION_PATTERN = /^(\s*__version__\s*=\s*)(["'])([^"']+)(\2)(\s*(?:#.*)?)?$/mu;
12
6
  function isSourceFileMode(versionFile) {
13
7
  return versionFile.toLowerCase().endsWith(".py");
@@ -15,7 +9,7 @@ function isSourceFileMode(versionFile) {
15
9
  function parsePyProject(content, versionFile) {
16
10
  let parsed;
17
11
  try {
18
- parsed = toml_1.default.parse(content);
12
+ parsed = parseToml(content);
19
13
  }
20
14
  catch (error) {
21
15
  const message = error instanceof Error ? error.message : String(error);
@@ -148,7 +142,7 @@ const LOCKFILE_SPECS = [
148
142
  ];
149
143
  function refreshLockfile(cwd, spec) {
150
144
  try {
151
- (0, node_child_process_1.execFileSync)(spec.command, [...spec.args], {
145
+ execFileSync(spec.command, [...spec.args], {
152
146
  cwd,
153
147
  stdio: ["ignore", "pipe", "pipe"],
154
148
  });
@@ -159,11 +153,11 @@ function refreshLockfile(cwd, spec) {
159
153
  }
160
154
  }
161
155
  function readPyProjectFromCwd(cwd) {
162
- const target = node_path_1.default.join(cwd, "pyproject.toml");
163
- if (!node_fs_1.default.existsSync(target)) {
156
+ const target = path.join(cwd, "pyproject.toml");
157
+ if (!fs.existsSync(target)) {
164
158
  return null;
165
159
  }
166
- const content = node_fs_1.default.readFileSync(target, "utf8");
160
+ const content = fs.readFileSync(target, "utf8");
167
161
  return { parsed: parsePyProject(content, "pyproject.toml"), rawPath: target };
168
162
  }
169
163
  function packageNameFromParsed(parsed) {
@@ -187,15 +181,15 @@ function findAuxiliaryInitPy(cwd, parsed) {
187
181
  }
188
182
  const moduleName = normalizeModuleName(packageName);
189
183
  const candidates = [
190
- node_path_1.default.join("src", moduleName, "__init__.py"),
191
- node_path_1.default.join(moduleName, "__init__.py"),
184
+ path.join("src", moduleName, "__init__.py"),
185
+ path.join(moduleName, "__init__.py"),
192
186
  ];
193
187
  for (const candidate of candidates) {
194
- const absolute = node_path_1.default.join(cwd, candidate);
195
- if (!node_fs_1.default.existsSync(absolute)) {
188
+ const absolute = path.join(cwd, candidate);
189
+ if (!fs.existsSync(absolute)) {
196
190
  continue;
197
191
  }
198
- const content = node_fs_1.default.readFileSync(absolute, "utf8");
192
+ const content = fs.readFileSync(absolute, "utf8");
199
193
  if (SOURCE_FILE_VERSION_PATTERN.test(content)) {
200
194
  return candidate;
201
195
  }
@@ -203,43 +197,43 @@ function findAuxiliaryInitPy(cwd, parsed) {
203
197
  return null;
204
198
  }
205
199
  function tryUpdateInitPyVersion(cwd, relativePath, version) {
206
- const absolute = node_path_1.default.join(cwd, relativePath);
207
- const existing = node_fs_1.default.readFileSync(absolute, "utf8");
200
+ const absolute = path.join(cwd, relativePath);
201
+ const existing = fs.readFileSync(absolute, "utf8");
208
202
  if (!SOURCE_FILE_VERSION_PATTERN.test(existing)) {
209
203
  return false;
210
204
  }
211
205
  const updated = writeSourceFileVersion(existing, relativePath, version);
212
- node_fs_1.default.writeFileSync(absolute, updated, "utf8");
206
+ fs.writeFileSync(absolute, updated, "utf8");
213
207
  return true;
214
208
  }
215
209
  function tryUpdatePyProjectVersion(cwd, version) {
216
- const target = node_path_1.default.join(cwd, "pyproject.toml");
217
- if (!node_fs_1.default.existsSync(target)) {
210
+ const target = path.join(cwd, "pyproject.toml");
211
+ if (!fs.existsSync(target)) {
218
212
  return null;
219
213
  }
220
- const content = node_fs_1.default.readFileSync(target, "utf8");
214
+ const content = fs.readFileSync(target, "utf8");
221
215
  const parsed = parsePyProject(content, "pyproject.toml");
222
216
  const { projectVersion, poetryVersion } = lookupPyProjectVersions(parsed);
223
217
  if (!projectVersion && !poetryVersion) {
224
218
  return null;
225
219
  }
226
220
  const updated = writePyProjectVersion(content, "pyproject.toml", version);
227
- node_fs_1.default.writeFileSync(target, updated, "utf8");
221
+ fs.writeFileSync(target, updated, "utf8");
228
222
  return "pyproject.toml";
229
223
  }
230
- exports.pythonVersionStrategy = {
224
+ export const pythonVersionStrategy = {
231
225
  name: "python",
232
226
  getVersionFile(config) {
233
227
  return config["version-file"] ?? "pyproject.toml";
234
228
  },
235
229
  validateProject(cwd, config) {
236
230
  const versionFile = this.getVersionFile(config);
237
- const versionPath = node_path_1.default.join(cwd, versionFile);
238
- if (!node_fs_1.default.existsSync(versionPath)) {
231
+ const versionPath = path.join(cwd, versionFile);
232
+ if (!fs.existsSync(versionPath)) {
239
233
  return null;
240
234
  }
241
235
  try {
242
- const content = node_fs_1.default.readFileSync(versionPath, "utf8");
236
+ const content = fs.readFileSync(versionPath, "utf8");
243
237
  if (isSourceFileMode(versionFile)) {
244
238
  readSourceFileVersion(content, versionFile);
245
239
  }
@@ -254,26 +248,26 @@ exports.pythonVersionStrategy = {
254
248
  },
255
249
  readVersion(cwd, config) {
256
250
  const versionFile = this.getVersionFile(config);
257
- const versionPath = node_path_1.default.join(cwd, versionFile);
258
- if (!node_fs_1.default.existsSync(versionPath)) {
251
+ const versionPath = path.join(cwd, versionFile);
252
+ if (!fs.existsSync(versionPath)) {
259
253
  throw new Error(`Versionary requires ${versionFile} to exist.`);
260
254
  }
261
- const content = node_fs_1.default.readFileSync(versionPath, "utf8");
255
+ const content = fs.readFileSync(versionPath, "utf8");
262
256
  return isSourceFileMode(versionFile)
263
257
  ? readSourceFileVersion(content, versionFile)
264
258
  : readPyProjectVersion(content, versionFile);
265
259
  },
266
260
  writeVersion(cwd, config, version) {
267
261
  const versionFile = this.getVersionFile(config);
268
- const versionPath = node_path_1.default.join(cwd, versionFile);
269
- if (!node_fs_1.default.existsSync(versionPath)) {
262
+ const versionPath = path.join(cwd, versionFile);
263
+ if (!fs.existsSync(versionPath)) {
270
264
  throw new Error(`Versionary requires ${versionFile} to exist.`);
271
265
  }
272
- const existing = node_fs_1.default.readFileSync(versionPath, "utf8");
266
+ const existing = fs.readFileSync(versionPath, "utf8");
273
267
  const written = [];
274
268
  if (isSourceFileMode(versionFile)) {
275
269
  const updated = writeSourceFileVersion(existing, versionFile, version);
276
- node_fs_1.default.writeFileSync(versionPath, updated, "utf8");
270
+ fs.writeFileSync(versionPath, updated, "utf8");
277
271
  written.push(versionFile);
278
272
  const auxiliary = tryUpdatePyProjectVersion(cwd, version);
279
273
  if (auxiliary && auxiliary !== versionFile) {
@@ -282,7 +276,7 @@ exports.pythonVersionStrategy = {
282
276
  }
283
277
  else {
284
278
  const updated = writePyProjectVersion(existing, versionFile, version);
285
- node_fs_1.default.writeFileSync(versionPath, updated, "utf8");
279
+ fs.writeFileSync(versionPath, updated, "utf8");
286
280
  written.push(versionFile);
287
281
  const parsed = parsePyProject(updated, versionFile);
288
282
  const initPy = findAuxiliaryInitPy(cwd, parsed);
@@ -310,8 +304,8 @@ exports.pythonVersionStrategy = {
310
304
  finalizeVersionWrites(cwd, _writes, _context) {
311
305
  const refreshed = [];
312
306
  for (const spec of LOCKFILE_SPECS) {
313
- const lockPath = node_path_1.default.join(cwd, spec.lockfile);
314
- if (!node_fs_1.default.existsSync(lockPath)) {
307
+ const lockPath = path.join(cwd, spec.lockfile);
308
+ if (!fs.existsSync(lockPath)) {
315
309
  continue;
316
310
  }
317
311
  refreshLockfile(cwd, spec);
@@ -1,11 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.rVersionStrategy = void 0;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
1
+ import fs from "node:fs";
2
+ import path from "node:path";
9
3
  function readDescriptionVersion(content, versionFile) {
10
4
  const match = content.match(/^Version:\s*(.+)\s*$/mu);
11
5
  if (!match?.[1]) {
@@ -19,7 +13,7 @@ function writeDescriptionVersion(content, versionFile, version) {
19
13
  }
20
14
  return content.replace(/^Version:\s*.*$/mu, `Version: ${version}`);
21
15
  }
22
- exports.rVersionStrategy = {
16
+ export const rVersionStrategy = {
23
17
  name: "r",
24
18
  getDefaultChangelogFormat() {
25
19
  return "r-news";
@@ -29,12 +23,12 @@ exports.rVersionStrategy = {
29
23
  },
30
24
  validateProject(cwd, config) {
31
25
  const versionFile = this.getVersionFile(config);
32
- const versionPath = node_path_1.default.join(cwd, versionFile);
33
- if (!node_fs_1.default.existsSync(versionPath)) {
26
+ const versionPath = path.join(cwd, versionFile);
27
+ if (!fs.existsSync(versionPath)) {
34
28
  return null;
35
29
  }
36
30
  try {
37
- readDescriptionVersion(node_fs_1.default.readFileSync(versionPath, "utf8"), versionFile);
31
+ readDescriptionVersion(fs.readFileSync(versionPath, "utf8"), versionFile);
38
32
  return null;
39
33
  }
40
34
  catch (error) {
@@ -43,30 +37,30 @@ exports.rVersionStrategy = {
43
37
  },
44
38
  readVersion(cwd, config) {
45
39
  const versionFile = this.getVersionFile(config);
46
- const versionPath = node_path_1.default.join(cwd, versionFile);
47
- if (!node_fs_1.default.existsSync(versionPath)) {
40
+ const versionPath = path.join(cwd, versionFile);
41
+ if (!fs.existsSync(versionPath)) {
48
42
  throw new Error(`Versionary requires ${versionFile} to exist.`);
49
43
  }
50
- return readDescriptionVersion(node_fs_1.default.readFileSync(versionPath, "utf8"), versionFile);
44
+ return readDescriptionVersion(fs.readFileSync(versionPath, "utf8"), versionFile);
51
45
  },
52
46
  writeVersion(cwd, config, version) {
53
47
  const versionFile = this.getVersionFile(config);
54
- const versionPath = node_path_1.default.join(cwd, versionFile);
55
- if (!node_fs_1.default.existsSync(versionPath)) {
48
+ const versionPath = path.join(cwd, versionFile);
49
+ if (!fs.existsSync(versionPath)) {
56
50
  throw new Error(`Versionary requires ${versionFile} to exist.`);
57
51
  }
58
- const existing = node_fs_1.default.readFileSync(versionPath, "utf8");
52
+ const existing = fs.readFileSync(versionPath, "utf8");
59
53
  const updated = writeDescriptionVersion(existing, versionFile, version);
60
- node_fs_1.default.writeFileSync(versionPath, updated, "utf8");
54
+ fs.writeFileSync(versionPath, updated, "utf8");
61
55
  return [versionFile];
62
56
  },
63
57
  readPackageName(cwd, config) {
64
58
  const versionFile = this.getVersionFile(config);
65
- const versionPath = node_path_1.default.join(cwd, versionFile);
66
- if (!node_fs_1.default.existsSync(versionPath)) {
59
+ const versionPath = path.join(cwd, versionFile);
60
+ if (!fs.existsSync(versionPath)) {
67
61
  throw new Error(`Versionary requires ${versionFile} to exist.`);
68
62
  }
69
- const content = node_fs_1.default.readFileSync(versionPath, "utf8");
63
+ const content = fs.readFileSync(versionPath, "utf8");
70
64
  const match = content.match(/^Package:\s*(.+)\s*$/mu);
71
65
  if (!match?.[1]) {
72
66
  return null;
@@ -1,23 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listKnownReleaseTypes = listKnownReleaseTypes;
4
- exports.resolveVersionStrategy = resolveVersionStrategy;
5
- const composite_js_1 = require("./composite.js");
6
- const latex_js_1 = require("./latex.js");
7
- const node_js_1 = require("./node.js");
8
- const python_js_1 = require("./python.js");
9
- const r_js_1 = require("./r.js");
10
- const rust_js_1 = require("./rust.js");
11
- const simple_js_1 = require("./simple.js");
1
+ import { compositeVersionStrategy } from "./composite.js";
2
+ import { latexVersionStrategy } from "./latex.js";
3
+ import { nodeVersionStrategy } from "./node.js";
4
+ import { pythonVersionStrategy } from "./python.js";
5
+ import { rVersionStrategy } from "./r.js";
6
+ import { rustVersionStrategy } from "./rust.js";
7
+ import { simpleVersionStrategy } from "./simple.js";
12
8
  const strategyRegistry = {
13
- latex: latex_js_1.latexVersionStrategy,
14
- simple: simple_js_1.simpleVersionStrategy,
15
- node: node_js_1.nodeVersionStrategy,
16
- rust: rust_js_1.rustVersionStrategy,
17
- r: r_js_1.rVersionStrategy,
18
- python: python_js_1.pythonVersionStrategy,
9
+ latex: latexVersionStrategy,
10
+ simple: simpleVersionStrategy,
11
+ node: nodeVersionStrategy,
12
+ rust: rustVersionStrategy,
13
+ r: rVersionStrategy,
14
+ python: pythonVersionStrategy,
19
15
  };
20
- function listKnownReleaseTypes() {
16
+ export function listKnownReleaseTypes() {
21
17
  return Object.keys(strategyRegistry).sort((a, b) => a.localeCompare(b));
22
18
  }
23
19
  function resolveSingle(name) {
@@ -28,7 +24,7 @@ function resolveSingle(name) {
28
24
  }
29
25
  return strategy;
30
26
  }
31
- function resolveVersionStrategy(config) {
27
+ export function resolveVersionStrategy(config) {
32
28
  const releaseType = config["release-type"] ?? "simple";
33
29
  if (Array.isArray(releaseType)) {
34
30
  if (releaseType.length === 0) {
@@ -43,7 +39,7 @@ function resolveVersionStrategy(config) {
43
39
  seen.add(name);
44
40
  strategies.push(resolveSingle(name));
45
41
  }
46
- return (0, composite_js_1.compositeVersionStrategy)(strategies);
42
+ return compositeVersionStrategy(strategies);
47
43
  }
48
44
  return resolveSingle(releaseType);
49
45
  }