@versatiles/release-tool 1.2.3 → 1.2.5

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.
@@ -31,7 +31,6 @@ export async function generateCommandDocumentation(command) {
31
31
  */
32
32
  async function getCommandResults(command) {
33
33
  return new Promise((resolve, reject) => {
34
- // eslint-disable-next-line @typescript-eslint/naming-convention
35
34
  const env = { ...process.env, NODE_ENV: undefined };
36
35
  // Spawn a child process to run the command with the '--help' flag.
37
36
  const childProcess = cp.spawn('npx', [...command.split(' '), '--help'], { env });
@@ -72,7 +71,7 @@ function extractSubcommands(result) {
72
71
  .split('\n') // Split by newline to process each line.
73
72
  .flatMap((line) => {
74
73
  // Extract subcommand names from each line.
75
- const extract = /^ ([^ ]{2,})/.exec(line);
74
+ const extract = /^ {2}([^ ]{2,})/.exec(line);
76
75
  if (!extract)
77
76
  return [];
78
77
  const [, subcommand] = extract;
@@ -10,7 +10,6 @@ import { getErrorMessage } from '../lib/utils.js';
10
10
  * @param foldable If true, makes the segment foldable.
11
11
  * @returns The modified Markdown document.
12
12
  */
13
- // eslint-disable-next-line @typescript-eslint/max-params
14
13
  export function injectMarkdown(document, segment, heading, foldable) {
15
14
  // Parse the input strings into Abstract Syntax Trees (ASTs).
16
15
  const documentAst = parseMarkdown(document);
@@ -134,20 +133,8 @@ function getHeadingDepth(mainAst, index) {
134
133
  */
135
134
  function indentSegmentToDepth(segmentAst, depth) {
136
135
  segmentAst.children.forEach(node => {
137
- switch (node.type) {
138
- case 'code':
139
- case 'html':
140
- case 'list':
141
- case 'listItem':
142
- case 'paragraph':
143
- case 'text':
144
- return;
145
- case 'heading':
146
- return node.depth += depth;
147
- default:
148
- console.log(node);
149
- throw Error('unknown type: ' + node.type);
150
- }
136
+ if (node.type == 'heading')
137
+ return node.depth += depth;
151
138
  });
152
139
  }
153
140
  /**
@@ -157,7 +144,6 @@ function indentSegmentToDepth(segmentAst, depth) {
157
144
  * @param startIndex The start index in the main AST.
158
145
  * @param endIndex The end index in the main AST.
159
146
  */
160
- // eslint-disable-next-line @typescript-eslint/max-params
161
147
  function mergeSegments(mainAst, segmentAst, startIndex, endIndex) {
162
148
  mainAst.children.splice(startIndex, endIndex - startIndex, ...segmentAst.children);
163
149
  }
@@ -193,11 +179,12 @@ function getMDAnchor(node) {
193
179
  for (const c of node.children) {
194
180
  // Handle different types of child nodes to construct the anchor text.
195
181
  switch (c.type) {
196
- case 'html':
182
+ case 'html': {
197
183
  const match = /<a\s.*id\s*=\s*['"]([^'"]+)/i.exec(c.value);
198
184
  if (match)
199
185
  return match[1];
200
186
  break;
187
+ }
201
188
  case 'text':
202
189
  case 'inlineCode':
203
190
  text += c.value;
@@ -211,7 +198,7 @@ function getMDAnchor(node) {
211
198
  text = text.toLowerCase()
212
199
  .replace(/[()]+/g, '')
213
200
  .replace(/[^a-z0-9]+/g, '-')
214
- .replace(/^\-+|\-+$/g, '');
201
+ .replace(/^-+|-+$/g, '');
215
202
  return text;
216
203
  }
217
204
  /**
@@ -268,13 +255,17 @@ export function nodeToHtml(node) {
268
255
  return `<strong>${nodesToHtml(node.children)}</strong>`;
269
256
  case 'link':
270
257
  return `<a href="${node.url}"${node.title == null ? '' : ` title="${node.title}"`}>${nodesToHtml(node.children)}</a>`;
271
- case 'image':
258
+ case 'image': {
272
259
  const attributes = [`src="${node.url}"`];
273
260
  if (node.alt ?? '')
274
261
  attributes.push(`alt="${node.alt}"`);
275
262
  if (node.title ?? '')
276
263
  attributes.push(`title="${node.title}"`);
277
264
  return `<img ${attributes.join(' ')} />`;
265
+ }
266
+ case 'footnoteReference': throw new Error('Not implemented yet: "footnoteReference" case');
267
+ case 'imageReference': throw new Error('Not implemented yet: "imageReference" case');
268
+ case 'linkReference': throw new Error('Not implemented yet: "linkReference" case');
278
269
  default:
279
270
  console.log(node);
280
271
  throw Error('unknown type');
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env npx tsx
2
2
  import { readFileSync, writeFileSync } from 'node:fs';
3
- import inquirer from 'inquirer';
3
+ import select from '@inquirer/select';
4
4
  import { check, info, panic, warn } from '../lib/log.js';
5
5
  import { getShell } from '../lib/shell.js';
6
6
  import { getGit } from '../lib/git.js';
@@ -46,7 +46,7 @@ export async function release(directory, branch = 'main') {
46
46
  await check('update version', setNextVersion(nextVersion));
47
47
  // prepare release notes
48
48
  const releaseNotes = await check('prepare release notes', getReleaseNotes(nextVersion, shaLast, shaCurrent));
49
- if (!('private' in pkg) || !Boolean(pkg.private)) {
49
+ if (!('private' in pkg) || !pkg.private) {
50
50
  // npm publish
51
51
  await check('npm publish', shell.run('npm publish --access public'));
52
52
  }
@@ -72,7 +72,6 @@ export async function release(directory, branch = 'main') {
72
72
  }
73
73
  async function setNextVersion(version) {
74
74
  // set new version in package.json
75
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76
75
  const packageJSON = JSON.parse(readFileSync(resolve(directory, 'package.json'), 'utf8'));
77
76
  packageJSON.version = version;
78
77
  writeFileSync(resolve(directory, 'package.json'), JSON.stringify(packageJSON, null, ' ') + '\n');
@@ -89,15 +88,17 @@ export async function release(directory, branch = 'main') {
89
88
  }
90
89
  async function getNewVersion(versionPackage) {
91
90
  // ask for new version
92
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
93
- const versionNew = (await inquirer.prompt({
91
+ const choices = [
92
+ { value: versionPackage },
93
+ { ...bump(2) },
94
+ { ...bump(1) },
95
+ { ...bump(0) }
96
+ ];
97
+ const versionNew = (await select({
94
98
  message: 'What should be the new version?',
95
- name: 'versionNew',
96
- type: 'list',
97
- choices: [versionPackage, bump(2), bump(1), bump(0)],
98
- default: 1,
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
100
- })).versionNew;
99
+ choices,
100
+ default: choices[1].value,
101
+ }));
101
102
  if (!versionNew)
102
103
  throw Error();
103
104
  return versionNew;
@@ -18,7 +18,8 @@ function* documentProject(project) {
18
18
  }
19
19
  for (const group of project.groups) {
20
20
  yield '\n# ' + group.title;
21
- for (const declaration of group.children) {
21
+ for (const d of group.children) {
22
+ const declaration = d;
22
23
  switch (declaration.kind) {
23
24
  case ReflectionKind.Class:
24
25
  yield* documentClass(declaration);
@@ -201,7 +202,7 @@ function formatTypeDeclaration(someType) {
201
202
  return some.name;
202
203
  case 'literal':
203
204
  return JSON.stringify(some.value);
204
- case 'reference':
205
+ case 'reference': {
205
206
  let result = some.name;
206
207
  if (some.reflection)
207
208
  result = `[${result}](#${createAnchorId(some.reflection)})`;
@@ -211,6 +212,7 @@ function formatTypeDeclaration(someType) {
211
212
  .map(getTypeRec).join(',')
212
213
  + '&gt;';
213
214
  return result;
215
+ }
214
216
  case 'reflection':
215
217
  switch (some.declaration.kind) {
216
218
  case ReflectionKind.TypeLiteral: return decodeReflectionTypeLiteral(some.declaration);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versatiles/release-tool",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "VersaTiles release and documentation tools",
5
5
  "bin": {
6
6
  "vrt": "./dist/index.js"
@@ -29,24 +29,26 @@
29
29
  },
30
30
  "homepage": "https://github.com/versatiles-org/node-versatiles/blob/main/versatiles-release-tool/README.md",
31
31
  "devDependencies": {
32
+ "@eslint/js": "^9.9.0",
32
33
  "@types/inquirer": "^9.0.7",
33
34
  "@types/jest": "^29.5.12",
34
- "@types/node": "^20.12.4",
35
- "@typescript-eslint/eslint-plugin": "^7.5.0",
36
- "@typescript-eslint/parser": "^7.5.0",
37
- "eslint": "^8.57.0",
35
+ "@types/node": "^22.3.0",
36
+ "@typescript-eslint/eslint-plugin": "^8.1.0",
37
+ "@typescript-eslint/parser": "^8.1.0",
38
+ "eslint": "^9.9.0",
38
39
  "jest": "^29.7.0",
39
- "npm-check-updates": "^16.14.18",
40
- "ts-jest": "^29.1.2",
40
+ "npm-check-updates": "^17.0.6",
41
+ "ts-jest": "^29.2.4",
41
42
  "ts-node": "^10.9.2",
42
- "tsx": "^4.7.2",
43
- "typescript": "^5.4.4"
43
+ "tsx": "^4.17.0",
44
+ "typescript": "^5.5.4",
45
+ "typescript-eslint": "^8.1.0"
44
46
  },
45
47
  "dependencies": {
46
- "commander": "^12.0.0",
47
- "inquirer": "^9.2.17",
48
+ "@inquirer/select": "^2.4.7",
49
+ "commander": "^12.1.0",
48
50
  "remark": "^15.0.1",
49
51
  "remark-gfm": "^4.0.0",
50
- "typedoc": "^0.25.12"
52
+ "typedoc": "^0.26.5"
51
53
  }
52
54
  }