@versatiles/release-tool 2.5.0 → 2.7.0

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/README.md CHANGED
@@ -51,6 +51,7 @@ Node.js/TypeScript projects.
51
51
 
52
52
  Options:
53
53
  -h, --help display help for command
54
+ -v, --verbose Enable verbose output
54
55
 
55
56
  Commands:
56
57
  check Check repo for required scripts and other stuff.
@@ -61,7 +62,7 @@ Commands:
61
62
  doc-toc <readme> [heading] Generate a Table of Contents (TOC) in a Markdown file.
62
63
  doc-typescript [options] Generate documentation for a TypeScript project.
63
64
  help [command] display help for command
64
- release-npm [path] Publish an npm package from the specified path to the npm registry.
65
+ release-npm [options] [path] Publish an npm package from the specified path to the npm registry.
65
66
  ```
66
67
 
67
68
  ## Subcommand: `vrt check`
@@ -178,11 +179,12 @@ Usage: vrt release-npm [options] [path]
178
179
  Publish an npm package from the specified path to the npm registry.
179
180
 
180
181
  Arguments:
181
- path Root path of the Node.js project. Defaults to the current
182
- directory.
182
+ path Root path of the Node.js project. Defaults to the current
183
+ directory.
183
184
 
184
185
  Options:
185
- -h, --help display help for command
186
+ -h, --help display help for command
187
+ -n, --dry-run Show what would be done without making any changes
186
188
  ```
187
189
 
188
190
  # Development
@@ -201,39 +203,51 @@ flowchart TB
201
203
  subgraph 0["src"]
202
204
  subgraph 1["commands"]
203
205
  2["check.ts"]
204
- 5["deps-graph.ts"]
205
- 6["deps-upgrade.ts"]
206
- 8["doc-command.ts"]
207
- A["doc-typescript.ts"]
208
- B["markdown.ts"]
209
- C["release-npm.ts"]
206
+ 6["deps-graph.ts"]
207
+ 7["deps-upgrade.ts"]
208
+ 9["doc-command.ts"]
209
+ B["doc-typescript.ts"]
210
+ C["markdown.ts"]
211
+ D["release-npm.ts"]
210
212
  end
211
213
  subgraph 3["lib"]
212
214
  4["log.ts"]
213
- 7["shell.ts"]
214
- 9["utils.ts"]
215
- D["git.ts"]
215
+ 5["errors.ts"]
216
+ 8["shell.ts"]
217
+ A["utils.ts"]
218
+ E["changelog.ts"]
219
+ F["git.ts"]
220
+ G["retry.ts"]
221
+ I["benchmark.ts"]
216
222
  end
217
- E["index.ts"]
223
+ H["index.ts"]
218
224
  end
219
225
  2-->4
220
- 5-->4
226
+ 4-->5
221
227
  6-->4
222
- 6-->7
223
- 8-->9
224
- A-->4
225
- B-->9
226
- C-->D
227
- C-->4
228
- C-->7
229
- D-->7
230
- E-->2
231
- E-->5
232
- E-->6
233
- E-->8
234
- E-->A
235
- E-->B
236
- E-->C
228
+ 7-->4
229
+ 7-->8
230
+ 8-->4
231
+ 9-->A
232
+ B-->4
233
+ C-->5
234
+ C-->A
235
+ D-->E
236
+ D-->5
237
+ D-->F
238
+ D-->4
239
+ D-->G
240
+ D-->8
241
+ E-->F
242
+ F-->8
243
+ H-->2
244
+ H-->6
245
+ H-->7
246
+ H-->9
247
+ H-->B
248
+ H-->C
249
+ H-->D
250
+ H-->4
237
251
 
238
252
  class 0,1,3 subgraphs;
239
253
  classDef subgraphs fill-opacity:0.1, fill:#888, color:#888, stroke:#888;
@@ -1,3 +1,27 @@
1
+ /**
2
+ * Runs all project checks including package.json and workflow validation.
3
+ *
4
+ * @param directory - The project directory to check
5
+ */
1
6
  export declare function check(directory: string): void;
7
+ /**
8
+ * Validates package.json configuration for VersaTiles projects.
9
+ *
10
+ * Checks for:
11
+ * - Required scripts (build, check, prepack, release)
12
+ * - Recommended scripts (test, doc, upgrade, doc-graph)
13
+ * - Script configurations following best practices
14
+ * - Unnecessary dependencies
15
+ *
16
+ * @param directory - The project directory containing package.json
17
+ * @throws {VrtError} If package.json is missing required scripts
18
+ */
2
19
  export declare function checkPackage(directory: string): void;
20
+ /**
21
+ * Validates GitHub Actions workflow configuration.
22
+ *
23
+ * Checks for the presence of expected workflow files.
24
+ *
25
+ * @param directory - The project directory to check
26
+ */
3
27
  export declare function checkWorkflow(directory: string): void;
@@ -1,10 +1,27 @@
1
1
  import { existsSync, readFileSync } from 'fs';
2
- import { panic, info, warn } from '../lib/log.js';
3
2
  import { resolve } from 'path';
3
+ import { info, panic, warn } from '../lib/log.js';
4
+ /**
5
+ * Runs all project checks including package.json and workflow validation.
6
+ *
7
+ * @param directory - The project directory to check
8
+ */
4
9
  export function check(directory) {
5
10
  checkPackage(directory);
6
11
  checkWorkflow(directory);
7
12
  }
13
+ /**
14
+ * Validates package.json configuration for VersaTiles projects.
15
+ *
16
+ * Checks for:
17
+ * - Required scripts (build, check, prepack, release)
18
+ * - Recommended scripts (test, doc, upgrade, doc-graph)
19
+ * - Script configurations following best practices
20
+ * - Unnecessary dependencies
21
+ *
22
+ * @param directory - The project directory containing package.json
23
+ * @throws {VrtError} If package.json is missing required scripts
24
+ */
8
25
  export function checkPackage(directory) {
9
26
  const pack = JSON.parse(readFileSync(resolve(directory, 'package.json'), 'utf8'));
10
27
  const { scripts } = pack;
@@ -17,8 +34,8 @@ export function checkPackage(directory) {
17
34
  info('scripts.doc is recommended');
18
35
  if (!scripts.build)
19
36
  warn('scripts.build is required');
20
- else if (!scripts.build.includes("npm run doc")) {
21
- warn(`scripts.build should include "npm run doc-graph", but is "${scripts.build}"`);
37
+ else if (!scripts.build.includes('npm run doc')) {
38
+ warn(`scripts.build should include "npm run doc", but is "${scripts.build}"`);
22
39
  }
23
40
  if (!scripts.check)
24
41
  warn('scripts.check is required');
@@ -60,6 +77,13 @@ export function checkPackage(directory) {
60
77
  }
61
78
  });
62
79
  }
80
+ /**
81
+ * Validates GitHub Actions workflow configuration.
82
+ *
83
+ * Checks for the presence of expected workflow files.
84
+ *
85
+ * @param directory - The project directory to check
86
+ */
63
87
  export function checkWorkflow(directory) {
64
88
  if (!existsSync(resolve(directory, '.github/workflows/pages.yml'))) {
65
89
  info('GitHub Pages workflow not found');
@@ -1 +1,23 @@
1
+ /**
2
+ * Generates a Mermaid dependency graph for the project's source files.
3
+ *
4
+ * Uses dependency-cruiser to analyze imports and outputs a Mermaid flowchart
5
+ * diagram to stdout. The output is wrapped in markdown code blocks for
6
+ * easy inclusion in documentation.
7
+ *
8
+ * Configuration:
9
+ * - Only includes files from `src/` directory
10
+ * - Excludes test files, declaration files, and mocks
11
+ * - Uses ELK layout for better graph rendering
12
+ *
13
+ * @param directory - The project directory to analyze
14
+ * @throws {VrtError} If dependency analysis fails
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // Generate graph and pipe to doc-insert
19
+ * await generateDependencyGraph('./');
20
+ * // Output: ```mermaid\nflowchart TB\n...\n```
21
+ * ```
22
+ */
1
23
  export declare function generateDependencyGraph(directory: string): Promise<void>;
@@ -1,12 +1,34 @@
1
1
  import { cruise } from 'dependency-cruiser';
2
2
  import { panic } from '../lib/log.js';
3
+ /**
4
+ * Generates a Mermaid dependency graph for the project's source files.
5
+ *
6
+ * Uses dependency-cruiser to analyze imports and outputs a Mermaid flowchart
7
+ * diagram to stdout. The output is wrapped in markdown code blocks for
8
+ * easy inclusion in documentation.
9
+ *
10
+ * Configuration:
11
+ * - Only includes files from `src/` directory
12
+ * - Excludes test files, declaration files, and mocks
13
+ * - Uses ELK layout for better graph rendering
14
+ *
15
+ * @param directory - The project directory to analyze
16
+ * @throws {VrtError} If dependency analysis fails
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // Generate graph and pipe to doc-insert
21
+ * await generateDependencyGraph('./');
22
+ * // Output: ```mermaid\nflowchart TB\n...\n```
23
+ * ```
24
+ */
3
25
  export async function generateDependencyGraph(directory) {
4
26
  let cruiseResult;
5
27
  try {
6
28
  cruiseResult = await cruise([directory], {
7
29
  includeOnly: '^src',
8
30
  outputType: 'mermaid',
9
- exclude: ["\\.(test|d)\\.ts$", "node_modules", "__mocks__/"],
31
+ exclude: ['\\.(test|d|mock)\\.ts$', 'node_modules', '__mocks__/'],
10
32
  });
11
33
  }
12
34
  catch (pError) {
@@ -36,18 +36,18 @@ async function getCommandResults(command) {
36
36
  NODE_ENV: undefined,
37
37
  NODE_DISABLE_COLORS: '1',
38
38
  NO_COLORS: '1',
39
- FORCE_COLOR: '0'
39
+ FORCE_COLOR: '0',
40
40
  };
41
41
  // Spawn a child process to run the command with the '--help' flag.
42
42
  const childProcess = cp.spawn('npm', ['--offline', 'exec', '--', ...command.split(' '), '--help'], { env });
43
43
  let output = '';
44
44
  // Collect output data from the process.
45
- childProcess.stdout.on('data', data => output += String(data));
46
- childProcess.stderr.on('data', data => {
45
+ childProcess.stdout.on('data', (data) => (output += String(data)));
46
+ childProcess.stderr.on('data', (data) => {
47
47
  console.error(`stderr: ${data}`);
48
48
  });
49
49
  // Handle process errors.
50
- childProcess.on('error', error => {
50
+ childProcess.on('error', (error) => {
51
51
  reject(new Error(`Failed to start subprocess: ${error.message}`));
52
52
  });
53
53
  // Handle process exit.
@@ -72,8 +72,8 @@ async function getCommandResults(command) {
72
72
  */
73
73
  function extractSubcommands(result) {
74
74
  return result
75
- .replace(/.*\nCommands:/msgi, '') // Remove everything before the "Commands:" section.
76
- .replace(/\n[a-z]+:.*/msi, '') // Remove everything after the subcommands list.
75
+ .replace(/.*\nCommands:/gims, '') // Remove everything before the "Commands:" section.
76
+ .replace(/\n[a-z]+:.*/ims, '') // Remove everything after the subcommands list.
77
77
  .split('\n') // Split by newline to process each line.
78
78
  .flatMap((line) => {
79
79
  // Extract subcommand names from each line.
@@ -1,6 +1,42 @@
1
- export declare function generateTypescriptDocs(options: {
1
+ /**
2
+ * Output format for generated TypeScript documentation.
3
+ */
4
+ export type DocFormat = 'markdown' | 'wiki' | 'html';
5
+ /**
6
+ * Options for generating TypeScript documentation.
7
+ */
8
+ export interface TypescriptDocOptions {
9
+ /** Path to the entry point file (default: './src/index.ts') */
2
10
  entryPoint?: string;
11
+ /** Output directory for generated docs (default: './docs') */
3
12
  outputPath?: string;
4
- format?: 'markdown' | 'wiki' | 'html';
13
+ /** Documentation format: 'markdown', 'wiki', or 'html' (default: 'markdown') */
14
+ format?: DocFormat;
15
+ /** Suppress info-level logging (default: false) */
5
16
  quiet?: boolean;
6
- }): Promise<void>;
17
+ }
18
+ /**
19
+ * Generates TypeScript documentation using TypeDoc.
20
+ *
21
+ * Supports multiple output formats:
22
+ * - `markdown`: Standard Markdown files using typedoc-plugin-markdown
23
+ * - `wiki`: GitHub Wiki compatible Markdown using typedoc-github-wiki-theme
24
+ * - `html`: HTML documentation using typedoc-github-theme
25
+ *
26
+ * @param options - Configuration options for documentation generation
27
+ * @throws {VrtError} If project conversion fails or validation errors occur
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * // Generate markdown docs from default entry point
32
+ * await generateTypescriptDocs({ format: 'markdown' });
33
+ *
34
+ * // Generate HTML docs to custom directory
35
+ * await generateTypescriptDocs({
36
+ * entryPoint: './src/main.ts',
37
+ * outputPath: './api-docs',
38
+ * format: 'html'
39
+ * });
40
+ * ```
41
+ */
42
+ export declare function generateTypescriptDocs(options: TypescriptDocOptions): Promise<void>;
@@ -1,5 +1,29 @@
1
1
  import * as td from 'typedoc';
2
2
  import { panic, warn } from '../lib/log.js';
3
+ /**
4
+ * Generates TypeScript documentation using TypeDoc.
5
+ *
6
+ * Supports multiple output formats:
7
+ * - `markdown`: Standard Markdown files using typedoc-plugin-markdown
8
+ * - `wiki`: GitHub Wiki compatible Markdown using typedoc-github-wiki-theme
9
+ * - `html`: HTML documentation using typedoc-github-theme
10
+ *
11
+ * @param options - Configuration options for documentation generation
12
+ * @throws {VrtError} If project conversion fails or validation errors occur
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // Generate markdown docs from default entry point
17
+ * await generateTypescriptDocs({ format: 'markdown' });
18
+ *
19
+ * // Generate HTML docs to custom directory
20
+ * await generateTypescriptDocs({
21
+ * entryPoint: './src/main.ts',
22
+ * outputPath: './api-docs',
23
+ * format: 'html'
24
+ * });
25
+ * ```
26
+ */
3
27
  export async function generateTypescriptDocs(options) {
4
28
  const { entryPoint, outputPath, quiet } = options;
5
29
  const format = options.format ?? 'markdown';
@@ -16,11 +40,7 @@ export async function generateTypescriptDocs(options) {
16
40
  logLevel: quiet ? 'Warn' : 'Info',
17
41
  highlightLanguages: ['typescript', 'javascript', 'json', 'shell', 'bash', 'sh', 'css', 'html'],
18
42
  groupOrder: ['Classes', 'Variables', 'Functions', '*'],
19
- }, [
20
- new td.TypeDocReader(),
21
- new td.PackageJsonReader(),
22
- new td.TSConfigReader(),
23
- ]);
43
+ }, [new td.TypeDocReader(), new td.PackageJsonReader(), new td.TSConfigReader()]);
24
44
  app.options.setValue('readme', 'none');
25
45
  if (isMarkdown) {
26
46
  app.options.setValue('hidePageHeader', true);
@@ -1,4 +1,4 @@
1
- import type { Root, PhrasingContent } from 'mdast';
1
+ import type { PhrasingContent, Root } from 'mdast';
2
2
  /**
3
3
  * Injects a Markdown segment under a specified heading in a Markdown document.
4
4
  * Optionally, the injected segment can be made foldable for better readability.
@@ -17,5 +17,13 @@ export declare function injectMarkdown(document: string, segment: string, headin
17
17
  * @returns The Markdown document with an updated TOC.
18
18
  */
19
19
  export declare function updateTOC(main: string, heading: string): string;
20
+ /**
21
+ * Converts a PhrasingContent node to its HTML representation.
22
+ * Handles all PhrasingContent types defined in mdast.
23
+ *
24
+ * @param node The phrasing content node to convert.
25
+ * @returns The HTML string representation.
26
+ * @throws {VrtError} For reference types that require resolution (footnote, image, link references).
27
+ */
20
28
  export declare function nodeToHtml(node: PhrasingContent): string;
21
29
  export declare function parseMarkdown(document: string): Root;