@magic/cli 0.0.47 → 0.0.49
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 +13 -1
- package/package.json +7 -7
- package/src/index.js +27 -3
- package/src/parse/clean.js +2 -2
- package/src/parse/index.js +2 -27
- package/types/index.d.ts +22 -1
- package/types/parse/clean.d.ts +2 -2
- package/types/parse/index.d.ts +1 -22
package/README.md
CHANGED
|
@@ -558,6 +558,18 @@ update dependencies
|
|
|
558
558
|
- add more tests
|
|
559
559
|
- update dependencies
|
|
560
560
|
|
|
561
|
-
##### 0.0.48
|
|
561
|
+
##### 0.0.48
|
|
562
|
+
|
|
563
|
+
- types changed to allow correct props when calling /src/index.js cli function
|
|
564
|
+
|
|
565
|
+
##### 0.0.49
|
|
566
|
+
|
|
567
|
+
- update dependencies
|
|
568
|
+
|
|
569
|
+
##### 0.0.50
|
|
570
|
+
|
|
571
|
+
- update dependencies
|
|
572
|
+
|
|
573
|
+
##### 0.0.51 - unreleased
|
|
562
574
|
|
|
563
575
|
- ...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"homepage": "https://magic.github.io/cli",
|
|
5
5
|
"description": "declarative command line interfaces with aliasing, commands and environment sanitization",
|
|
6
6
|
"scripts": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"declarative"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@magic/cases": "0.0.
|
|
40
|
-
"@magic/deep": "0.1.
|
|
41
|
-
"@magic/error": "0.0.
|
|
42
|
-
"@magic/log": "0.1.
|
|
43
|
-
"@magic/types": "0.1.
|
|
39
|
+
"@magic/cases": "0.0.11",
|
|
40
|
+
"@magic/deep": "0.1.20",
|
|
41
|
+
"@magic/error": "0.0.21",
|
|
42
|
+
"@magic/log": "0.1.21",
|
|
43
|
+
"@magic/types": "0.1.30"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@magic-modules/git-badges": "0.0.12",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@magic-themes/docs": "0.0.15",
|
|
51
51
|
"@magic/core": "0.0.156",
|
|
52
52
|
"@magic/format": "0.0.68",
|
|
53
|
-
"@magic/test": "0.2.
|
|
53
|
+
"@magic/test": "0.2.25",
|
|
54
54
|
"typescript": "5.9.3"
|
|
55
55
|
},
|
|
56
56
|
"author": "Wizards & Witches",
|
package/src/index.js
CHANGED
|
@@ -8,11 +8,35 @@ import { execFile as executeFile } from './execFile.js'
|
|
|
8
8
|
import { spawn as spawner } from './spawn.js'
|
|
9
9
|
import { prompt as promptUser } from './prompt.js'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {object} ParseProps
|
|
13
|
+
* @property {Array<string|string[]>} [options]
|
|
14
|
+
* @property {Record<string, any>|Array<any>} [prepend]
|
|
15
|
+
* @property {Record<string, any>|Array<any>} [append]
|
|
16
|
+
* @property {Record<string, any>} [default]
|
|
17
|
+
* @property {boolean} [pure]
|
|
18
|
+
* @property {boolean} [pureEnv]
|
|
19
|
+
* @property {boolean} [pureArgv]
|
|
20
|
+
* @property {boolean} [pureCommands]
|
|
21
|
+
* @property {Array<string|string[]>} [commands]
|
|
22
|
+
* @property {Array<[string[], string, string]>} [env]
|
|
23
|
+
* @property {Array<string|string[]>} [required]
|
|
24
|
+
* @property {object} [help]
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} ParsedCLI
|
|
29
|
+
* @property {Record<string, string>} env
|
|
30
|
+
* @property {Record<string, any>} argv
|
|
31
|
+
* @property {Record<string, any>} args
|
|
32
|
+
* @property {Record<string, boolean>} commands
|
|
33
|
+
* @property {Array<string|string[]>} errors
|
|
34
|
+
*/
|
|
35
|
+
|
|
11
36
|
/**
|
|
12
37
|
* Main CLI entry point
|
|
13
|
-
* @param {
|
|
14
|
-
* @
|
|
15
|
-
* @returns {object} Parsed CLI data.
|
|
38
|
+
* @param {ParseProps} args - CLI configuration object.
|
|
39
|
+
* @returns {ParsedCLI}
|
|
16
40
|
*/
|
|
17
41
|
export const cli = (args = {}) => {
|
|
18
42
|
const { options = [] } = args
|
package/src/parse/clean.js
CHANGED
|
@@ -10,9 +10,9 @@ import cases from '@magic/cases'
|
|
|
10
10
|
/**
|
|
11
11
|
* Cleans CLI parsed arguments for single-value keys, applying defaults.
|
|
12
12
|
*
|
|
13
|
-
* @param {import('
|
|
13
|
+
* @param {import('../index.js').ParsedCLI} cli
|
|
14
14
|
* @param {CleanProps} [props={}]
|
|
15
|
-
* @returns {import('
|
|
15
|
+
* @returns {import('../index.js').ParsedCLI}
|
|
16
16
|
*/
|
|
17
17
|
export const clean = (cli, props = {}) => {
|
|
18
18
|
if (is.empty(props.single)) {
|
package/src/parse/index.js
CHANGED
|
@@ -4,36 +4,11 @@ import { parseCommands } from './commands.js'
|
|
|
4
4
|
import { parseRequired } from './required.js'
|
|
5
5
|
import { clean } from './clean.js'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {object} ParseProps
|
|
9
|
-
* @property {Array<string|string[]>} [options]
|
|
10
|
-
* @property {Record<string, any>|Array<any>} [prepend]
|
|
11
|
-
* @property {Record<string, any>|Array<any>} [append]
|
|
12
|
-
* @property {Record<string, any>} [default]
|
|
13
|
-
* @property {boolean} [pure]
|
|
14
|
-
* @property {boolean} [pureEnv]
|
|
15
|
-
* @property {boolean} [pureArgv]
|
|
16
|
-
* @property {boolean} [pureCommands]
|
|
17
|
-
* @property {Array<string|string[]>} [commands]
|
|
18
|
-
* @property {Array<[string[], string, string]>} [env]
|
|
19
|
-
* @property {Array<string|string[]>} [required]
|
|
20
|
-
* @property {object} [help]
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {object} ParsedCLI
|
|
25
|
-
* @property {Record<string, string>} env
|
|
26
|
-
* @property {Record<string, any>} argv
|
|
27
|
-
* @property {Record<string, any>} args
|
|
28
|
-
* @property {Record<string, boolean>} commands
|
|
29
|
-
* @property {Array<string|string[]>} errors
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
7
|
/**
|
|
33
8
|
* Parses CLI arguments, commands, environment variables, and required options.
|
|
34
9
|
*
|
|
35
|
-
* @param {ParseProps} props
|
|
36
|
-
* @returns {ParsedCLI}
|
|
10
|
+
* @param {import('../index.js').ParseProps} props
|
|
11
|
+
* @returns {import('../index.js').ParsedCLI}
|
|
37
12
|
*/
|
|
38
13
|
export const parse = props => {
|
|
39
14
|
const { pure = false } = props
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function cli(args?:
|
|
1
|
+
export function cli(args?: ParseProps): ParsedCLI
|
|
2
2
|
export namespace cli {
|
|
3
3
|
export { spawner as spawn }
|
|
4
4
|
export { execute as exec }
|
|
@@ -30,6 +30,27 @@ export const execFile: (
|
|
|
30
30
|
opts?: import('child_process').ExecFileOptions,
|
|
31
31
|
) => Promise<string | Buffer>
|
|
32
32
|
export default cli
|
|
33
|
+
export type ParseProps = {
|
|
34
|
+
options?: (string | string[])[] | undefined
|
|
35
|
+
prepend?: any[] | Record<string, any> | undefined
|
|
36
|
+
append?: any[] | Record<string, any> | undefined
|
|
37
|
+
default?: Record<string, any> | undefined
|
|
38
|
+
pure?: boolean | undefined
|
|
39
|
+
pureEnv?: boolean | undefined
|
|
40
|
+
pureArgv?: boolean | undefined
|
|
41
|
+
pureCommands?: boolean | undefined
|
|
42
|
+
commands?: (string | string[])[] | undefined
|
|
43
|
+
env?: [string[], string, string][] | undefined
|
|
44
|
+
required?: (string | string[])[] | undefined
|
|
45
|
+
help?: object | undefined
|
|
46
|
+
}
|
|
47
|
+
export type ParsedCLI = {
|
|
48
|
+
env: Record<string, string>
|
|
49
|
+
argv: Record<string, any>
|
|
50
|
+
args: Record<string, any>
|
|
51
|
+
commands: Record<string, boolean>
|
|
52
|
+
errors: Array<string | string[]>
|
|
53
|
+
}
|
|
33
54
|
import { spawn as spawner } from './spawn.js'
|
|
34
55
|
import { exec as execute } from './exec.js'
|
|
35
56
|
import { prompt as promptUser } from './prompt.js'
|
package/types/parse/clean.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function clean(
|
|
2
|
-
cli: import('
|
|
2
|
+
cli: import('../index.js').ParsedCLI,
|
|
3
3
|
props?: CleanProps,
|
|
4
|
-
): import('
|
|
4
|
+
): import('../index.js').ParsedCLI
|
|
5
5
|
export type CleanProps = {
|
|
6
6
|
/**
|
|
7
7
|
* - List of single-value argument keys to clean.
|
package/types/parse/index.d.ts
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
export function parse(props: ParseProps): ParsedCLI
|
|
2
|
-
export type ParseProps = {
|
|
3
|
-
options?: (string | string[])[] | undefined
|
|
4
|
-
prepend?: any[] | Record<string, any> | undefined
|
|
5
|
-
append?: any[] | Record<string, any> | undefined
|
|
6
|
-
default?: Record<string, any> | undefined
|
|
7
|
-
pure?: boolean | undefined
|
|
8
|
-
pureEnv?: boolean | undefined
|
|
9
|
-
pureArgv?: boolean | undefined
|
|
10
|
-
pureCommands?: boolean | undefined
|
|
11
|
-
commands?: (string | string[])[] | undefined
|
|
12
|
-
env?: [string[], string, string][] | undefined
|
|
13
|
-
required?: (string | string[])[] | undefined
|
|
14
|
-
help?: object | undefined
|
|
15
|
-
}
|
|
16
|
-
export type ParsedCLI = {
|
|
17
|
-
env: Record<string, string>
|
|
18
|
-
argv: Record<string, any>
|
|
19
|
-
args: Record<string, any>
|
|
20
|
-
commands: Record<string, boolean>
|
|
21
|
-
errors: Array<string | string[]>
|
|
22
|
-
}
|
|
1
|
+
export function parse(props: import('../index.js').ParseProps): import('../index.js').ParsedCLI
|