@inquirerer/utils 3.1.2 → 3.2.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 +17 -0
- package/esm/index.d.ts +2 -6
- package/esm/index.js +3 -7
- package/index.d.ts +2 -6
- package/index.js +10 -13
- package/package.json +5 -6
- package/argv.d.ts +0 -13
- package/argv.js +0 -16
- package/cli-error.d.ts +0 -14
- package/cli-error.js +0 -33
- package/esm/argv.d.ts +0 -13
- package/esm/argv.js +0 -12
- package/esm/cli-error.d.ts +0 -14
- package/esm/cli-error.js +0 -29
- package/esm/package-json.d.ts +0 -18
- package/esm/package-json.js +0 -20
- package/package-json.d.ts +0 -18
- package/package-json.js +0 -26
package/README.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @inquirerer/utils
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" height="250">
|
|
5
|
+
<br />
|
|
6
|
+
<strong>CLI lifecycle utilities</strong>
|
|
7
|
+
<br />
|
|
8
|
+
<br />
|
|
9
|
+
Utilities for building command-line applications with inquirerer
|
|
10
|
+
<br />
|
|
11
|
+
<br />
|
|
12
|
+
<a href="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml">
|
|
13
|
+
<img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/constructive-io/dev-utils/blob/main/LICENSE">
|
|
16
|
+
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
|
|
17
|
+
</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
3
20
|
CLI lifecycle utilities for building command-line applications with [inquirerer](https://www.npmjs.com/package/inquirerer).
|
|
4
21
|
|
|
5
22
|
## Installation
|
package/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export { extractFirst } from '
|
|
2
|
-
export type { ParsedArgs } from '
|
|
3
|
-
export { cliExitWithError } from './cli-error';
|
|
4
|
-
export type { CliExitOptions } from './cli-error';
|
|
1
|
+
export { parseArgv, extractFirst, cliExitWithError, getPackageJson, getPackageVersion, getPackageName } from 'inquirerer';
|
|
2
|
+
export type { ParsedArgs, ParseArgvOptions, CliExitOptions, PackageJson } from 'inquirerer';
|
|
5
3
|
export { checkForUpdates, shouldSkipUpdateCheck } from './update-check';
|
|
6
4
|
export type { UpdateCheckOptions, UpdateCheckResult } from './update-check';
|
|
7
|
-
export { getSelfPackageJson, getSelfVersion, getSelfName } from './package-json';
|
|
8
|
-
export type { PackageJsonInfo } from './package-json';
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
export { extractFirst } from '
|
|
3
|
-
//
|
|
4
|
-
export { cliExitWithError } from './cli-error';
|
|
5
|
-
// Update checking
|
|
1
|
+
// Re-export core CLI utilities from inquirerer
|
|
2
|
+
export { parseArgv, extractFirst, cliExitWithError, getPackageJson, getPackageVersion, getPackageName } from 'inquirerer';
|
|
3
|
+
// Update checking (requires appstash, not available in inquirerer)
|
|
6
4
|
export { checkForUpdates, shouldSkipUpdateCheck } from './update-check';
|
|
7
|
-
// Package.json utilities
|
|
8
|
-
export { getSelfPackageJson, getSelfVersion, getSelfName } from './package-json';
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export { extractFirst } from '
|
|
2
|
-
export type { ParsedArgs } from '
|
|
3
|
-
export { cliExitWithError } from './cli-error';
|
|
4
|
-
export type { CliExitOptions } from './cli-error';
|
|
1
|
+
export { parseArgv, extractFirst, cliExitWithError, getPackageJson, getPackageVersion, getPackageName } from 'inquirerer';
|
|
2
|
+
export type { ParsedArgs, ParseArgvOptions, CliExitOptions, PackageJson } from 'inquirerer';
|
|
5
3
|
export { checkForUpdates, shouldSkipUpdateCheck } from './update-check';
|
|
6
4
|
export type { UpdateCheckOptions, UpdateCheckResult } from './update-check';
|
|
7
|
-
export { getSelfPackageJson, getSelfVersion, getSelfName } from './package-json';
|
|
8
|
-
export type { PackageJsonInfo } from './package-json';
|
package/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
//
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(exports, "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "
|
|
10
|
-
|
|
3
|
+
exports.shouldSkipUpdateCheck = exports.checkForUpdates = exports.getPackageName = exports.getPackageVersion = exports.getPackageJson = exports.cliExitWithError = exports.extractFirst = exports.parseArgv = void 0;
|
|
4
|
+
// Re-export core CLI utilities from inquirerer
|
|
5
|
+
var inquirerer_1 = require("inquirerer");
|
|
6
|
+
Object.defineProperty(exports, "parseArgv", { enumerable: true, get: function () { return inquirerer_1.parseArgv; } });
|
|
7
|
+
Object.defineProperty(exports, "extractFirst", { enumerable: true, get: function () { return inquirerer_1.extractFirst; } });
|
|
8
|
+
Object.defineProperty(exports, "cliExitWithError", { enumerable: true, get: function () { return inquirerer_1.cliExitWithError; } });
|
|
9
|
+
Object.defineProperty(exports, "getPackageJson", { enumerable: true, get: function () { return inquirerer_1.getPackageJson; } });
|
|
10
|
+
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return inquirerer_1.getPackageVersion; } });
|
|
11
|
+
Object.defineProperty(exports, "getPackageName", { enumerable: true, get: function () { return inquirerer_1.getPackageName; } });
|
|
12
|
+
// Update checking (requires appstash, not available in inquirerer)
|
|
11
13
|
var update_check_1 = require("./update-check");
|
|
12
14
|
Object.defineProperty(exports, "checkForUpdates", { enumerable: true, get: function () { return update_check_1.checkForUpdates; } });
|
|
13
15
|
Object.defineProperty(exports, "shouldSkipUpdateCheck", { enumerable: true, get: function () { return update_check_1.shouldSkipUpdateCheck; } });
|
|
14
|
-
// Package.json utilities
|
|
15
|
-
var package_json_1 = require("./package-json");
|
|
16
|
-
Object.defineProperty(exports, "getSelfPackageJson", { enumerable: true, get: function () { return package_json_1.getSelfPackageJson; } });
|
|
17
|
-
Object.defineProperty(exports, "getSelfVersion", { enumerable: true, get: function () { return package_json_1.getSelfVersion; } });
|
|
18
|
-
Object.defineProperty(exports, "getSelfName", { enumerable: true, get: function () { return package_json_1.getSelfName; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirerer/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "CLI lifecycle utilities for building command-line applications",
|
|
6
6
|
"main": "index.js",
|
|
@@ -28,14 +28,13 @@
|
|
|
28
28
|
"test:watch": "jest --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"appstash": "0.
|
|
32
|
-
"
|
|
33
|
-
"minimist": "^1.2.8"
|
|
31
|
+
"appstash": "0.3.0",
|
|
32
|
+
"inquirerer": "4.4.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/minimist": "^1.2.5",
|
|
37
|
-
"makage": "0.1.
|
|
36
|
+
"makage": "0.1.10"
|
|
38
37
|
},
|
|
39
38
|
"keywords": [],
|
|
40
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "c6f85c28e227126d86839ba1628748ba7d857da9"
|
|
41
40
|
}
|
package/argv.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ParsedArgs } from 'minimist';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the first positional argument from argv and returns it along with the remaining argv.
|
|
4
|
-
* This is useful for command routing in CLI applications where the first argument is a subcommand.
|
|
5
|
-
*/
|
|
6
|
-
export declare const extractFirst: (argv: Partial<ParsedArgs>) => {
|
|
7
|
-
first: string;
|
|
8
|
-
newArgv: {
|
|
9
|
-
_: string[];
|
|
10
|
-
"--"?: string[] | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export type { ParsedArgs } from 'minimist';
|
package/argv.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractFirst = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the first positional argument from argv and returns it along with the remaining argv.
|
|
6
|
-
* This is useful for command routing in CLI applications where the first argument is a subcommand.
|
|
7
|
-
*/
|
|
8
|
-
const extractFirst = (argv) => {
|
|
9
|
-
const first = argv._?.[0];
|
|
10
|
-
const newArgv = {
|
|
11
|
-
...argv,
|
|
12
|
-
_: argv._?.slice(1) ?? []
|
|
13
|
-
};
|
|
14
|
-
return { first, newArgv };
|
|
15
|
-
};
|
|
16
|
-
exports.extractFirst = extractFirst;
|
package/cli-error.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface CliExitOptions {
|
|
2
|
-
context?: Record<string, any>;
|
|
3
|
-
beforeExit?: () => Promise<void>;
|
|
4
|
-
logger?: {
|
|
5
|
-
error: (message: string, ...args: any[]) => void;
|
|
6
|
-
debug: (message: string, ...args: any[]) => void;
|
|
7
|
-
warn: (message: string, ...args: any[]) => void;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Exits the CLI with an error message and optional cleanup.
|
|
12
|
-
* Supports a beforeExit hook for cleanup operations (e.g., closing database connections).
|
|
13
|
-
*/
|
|
14
|
-
export declare const cliExitWithError: (error: Error | string, options?: CliExitOptions) => Promise<never>;
|
package/cli-error.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cliExitWithError = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Exits the CLI with an error message and optional cleanup.
|
|
6
|
-
* Supports a beforeExit hook for cleanup operations (e.g., closing database connections).
|
|
7
|
-
*/
|
|
8
|
-
const cliExitWithError = async (error, options = {}) => {
|
|
9
|
-
const { context, beforeExit, logger = console } = options;
|
|
10
|
-
if (error instanceof Error) {
|
|
11
|
-
logger.error(`Error: ${error.message}`);
|
|
12
|
-
if (context) {
|
|
13
|
-
logger.debug('Context:', context);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else if (typeof error === 'string') {
|
|
17
|
-
logger.error(`Error: ${error}`);
|
|
18
|
-
if (context) {
|
|
19
|
-
logger.debug('Context:', context);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (beforeExit) {
|
|
23
|
-
try {
|
|
24
|
-
await beforeExit();
|
|
25
|
-
logger.debug('Cleanup completed');
|
|
26
|
-
}
|
|
27
|
-
catch (cleanupError) {
|
|
28
|
-
logger.warn('Failed to complete cleanup:', cleanupError);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
process.exit(1);
|
|
32
|
-
};
|
|
33
|
-
exports.cliExitWithError = cliExitWithError;
|
package/esm/argv.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ParsedArgs } from 'minimist';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the first positional argument from argv and returns it along with the remaining argv.
|
|
4
|
-
* This is useful for command routing in CLI applications where the first argument is a subcommand.
|
|
5
|
-
*/
|
|
6
|
-
export declare const extractFirst: (argv: Partial<ParsedArgs>) => {
|
|
7
|
-
first: string;
|
|
8
|
-
newArgv: {
|
|
9
|
-
_: string[];
|
|
10
|
-
"--"?: string[] | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export type { ParsedArgs } from 'minimist';
|
package/esm/argv.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the first positional argument from argv and returns it along with the remaining argv.
|
|
3
|
-
* This is useful for command routing in CLI applications where the first argument is a subcommand.
|
|
4
|
-
*/
|
|
5
|
-
export const extractFirst = (argv) => {
|
|
6
|
-
const first = argv._?.[0];
|
|
7
|
-
const newArgv = {
|
|
8
|
-
...argv,
|
|
9
|
-
_: argv._?.slice(1) ?? []
|
|
10
|
-
};
|
|
11
|
-
return { first, newArgv };
|
|
12
|
-
};
|
package/esm/cli-error.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface CliExitOptions {
|
|
2
|
-
context?: Record<string, any>;
|
|
3
|
-
beforeExit?: () => Promise<void>;
|
|
4
|
-
logger?: {
|
|
5
|
-
error: (message: string, ...args: any[]) => void;
|
|
6
|
-
debug: (message: string, ...args: any[]) => void;
|
|
7
|
-
warn: (message: string, ...args: any[]) => void;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Exits the CLI with an error message and optional cleanup.
|
|
12
|
-
* Supports a beforeExit hook for cleanup operations (e.g., closing database connections).
|
|
13
|
-
*/
|
|
14
|
-
export declare const cliExitWithError: (error: Error | string, options?: CliExitOptions) => Promise<never>;
|
package/esm/cli-error.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exits the CLI with an error message and optional cleanup.
|
|
3
|
-
* Supports a beforeExit hook for cleanup operations (e.g., closing database connections).
|
|
4
|
-
*/
|
|
5
|
-
export const cliExitWithError = async (error, options = {}) => {
|
|
6
|
-
const { context, beforeExit, logger = console } = options;
|
|
7
|
-
if (error instanceof Error) {
|
|
8
|
-
logger.error(`Error: ${error.message}`);
|
|
9
|
-
if (context) {
|
|
10
|
-
logger.debug('Context:', context);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
else if (typeof error === 'string') {
|
|
14
|
-
logger.error(`Error: ${error}`);
|
|
15
|
-
if (context) {
|
|
16
|
-
logger.debug('Context:', context);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (beforeExit) {
|
|
20
|
-
try {
|
|
21
|
-
await beforeExit();
|
|
22
|
-
logger.debug('Cleanup completed');
|
|
23
|
-
}
|
|
24
|
-
catch (cleanupError) {
|
|
25
|
-
logger.warn('Failed to complete cleanup:', cleanupError);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
process.exit(1);
|
|
29
|
-
};
|
package/esm/package-json.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface PackageJsonInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
version: string;
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Gets the package.json for the current package by searching up from the given directory.
|
|
8
|
-
* This is useful for CLIs to get their own version information.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getSelfPackageJson: (dirname: string) => PackageJsonInfo;
|
|
11
|
-
/**
|
|
12
|
-
* Gets the version from the package.json for the current package.
|
|
13
|
-
*/
|
|
14
|
-
export declare const getSelfVersion: (dirname: string) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Gets the name from the package.json for the current package.
|
|
17
|
-
*/
|
|
18
|
-
export declare const getSelfName: (dirname: string) => string;
|
package/esm/package-json.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { findAndRequirePackageJson } from 'find-and-require-package-json';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the package.json for the current package by searching up from the given directory.
|
|
4
|
-
* This is useful for CLIs to get their own version information.
|
|
5
|
-
*/
|
|
6
|
-
export const getSelfPackageJson = (dirname) => {
|
|
7
|
-
return findAndRequirePackageJson(dirname);
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Gets the version from the package.json for the current package.
|
|
11
|
-
*/
|
|
12
|
-
export const getSelfVersion = (dirname) => {
|
|
13
|
-
return getSelfPackageJson(dirname).version;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Gets the name from the package.json for the current package.
|
|
17
|
-
*/
|
|
18
|
-
export const getSelfName = (dirname) => {
|
|
19
|
-
return getSelfPackageJson(dirname).name;
|
|
20
|
-
};
|
package/package-json.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface PackageJsonInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
version: string;
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Gets the package.json for the current package by searching up from the given directory.
|
|
8
|
-
* This is useful for CLIs to get their own version information.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getSelfPackageJson: (dirname: string) => PackageJsonInfo;
|
|
11
|
-
/**
|
|
12
|
-
* Gets the version from the package.json for the current package.
|
|
13
|
-
*/
|
|
14
|
-
export declare const getSelfVersion: (dirname: string) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Gets the name from the package.json for the current package.
|
|
17
|
-
*/
|
|
18
|
-
export declare const getSelfName: (dirname: string) => string;
|
package/package-json.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSelfName = exports.getSelfVersion = exports.getSelfPackageJson = void 0;
|
|
4
|
-
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
5
|
-
/**
|
|
6
|
-
* Gets the package.json for the current package by searching up from the given directory.
|
|
7
|
-
* This is useful for CLIs to get their own version information.
|
|
8
|
-
*/
|
|
9
|
-
const getSelfPackageJson = (dirname) => {
|
|
10
|
-
return (0, find_and_require_package_json_1.findAndRequirePackageJson)(dirname);
|
|
11
|
-
};
|
|
12
|
-
exports.getSelfPackageJson = getSelfPackageJson;
|
|
13
|
-
/**
|
|
14
|
-
* Gets the version from the package.json for the current package.
|
|
15
|
-
*/
|
|
16
|
-
const getSelfVersion = (dirname) => {
|
|
17
|
-
return (0, exports.getSelfPackageJson)(dirname).version;
|
|
18
|
-
};
|
|
19
|
-
exports.getSelfVersion = getSelfVersion;
|
|
20
|
-
/**
|
|
21
|
-
* Gets the name from the package.json for the current package.
|
|
22
|
-
*/
|
|
23
|
-
const getSelfName = (dirname) => {
|
|
24
|
-
return (0, exports.getSelfPackageJson)(dirname).name;
|
|
25
|
-
};
|
|
26
|
-
exports.getSelfName = getSelfName;
|