@detergent-software/atk 8.9.0-dev.16 → 8.9.0-dev.18
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/CHANGELOG.md +17 -0
- package/README.md +11 -1
- package/build/cli.js +11 -3
- package/build/cli.js.map +1 -1
- package/build/command-manifest.json +1507 -0
- package/build/commands/browse.js +2 -2
- package/build/commands/browse.js.map +1 -1
- package/build/commands/cache.d.ts +1 -1
- package/build/commands/cache.d.ts.map +1 -1
- package/build/commands/cache.js +1 -16
- package/build/commands/cache.js.map +1 -1
- package/build/commands/info.js +1 -1
- package/build/commands/info.js.map +1 -1
- package/build/commands/init.d.ts.map +1 -1
- package/build/commands/init.js +4 -2
- package/build/commands/init.js.map +1 -1
- package/build/commands/list.js +2 -2
- package/build/commands/list.js.map +1 -1
- package/build/commands/outdated.js +1 -1
- package/build/commands/outdated.js.map +1 -1
- package/build/commands/publish.d.ts +1 -1
- package/build/commands/schema.d.ts +3 -3
- package/build/commands/search.js +1 -1
- package/build/commands/search.js.map +1 -1
- package/build/components/Header.d.ts +2 -3
- package/build/components/Header.d.ts.map +1 -1
- package/build/components/Header.js +2 -9
- package/build/components/Header.js.map +1 -1
- package/build/components/header-art.d.ts +7 -0
- package/build/components/header-art.d.ts.map +1 -0
- package/build/components/header-art.js +14 -0
- package/build/components/header-art.js.map +1 -0
- package/build/lib/api-client.d.ts +2 -1
- package/build/lib/api-client.d.ts.map +1 -1
- package/build/lib/api-client.js +10 -1
- package/build/lib/api-client.js.map +1 -1
- package/build/lib/diagnostics.d.ts.map +1 -1
- package/build/lib/diagnostics.js +5 -2
- package/build/lib/diagnostics.js.map +1 -1
- package/build/lib/diff-command.js +1 -1
- package/build/lib/diff-command.js.map +1 -1
- package/build/lib/format-age.d.ts +3 -0
- package/build/lib/format-age.d.ts.map +1 -0
- package/build/lib/format-age.js +18 -0
- package/build/lib/format-age.js.map +1 -0
- package/build/lib/offline.d.ts +19 -0
- package/build/lib/offline.d.ts.map +1 -0
- package/build/lib/offline.js +26 -0
- package/build/lib/offline.js.map +1 -0
- package/build/lib/pastel/commander-specs.d.ts +7 -0
- package/build/lib/pastel/commander-specs.d.ts.map +1 -0
- package/build/lib/pastel/commander-specs.js +50 -0
- package/build/lib/pastel/commander-specs.js.map +1 -0
- package/build/lib/pastel/generate-arguments.d.ts +3 -3
- package/build/lib/pastel/generate-arguments.d.ts.map +1 -1
- package/build/lib/pastel/generate-arguments.js +25 -22
- package/build/lib/pastel/generate-arguments.js.map +1 -1
- package/build/lib/pastel/generate-command.d.ts +7 -5
- package/build/lib/pastel/generate-command.d.ts.map +1 -1
- package/build/lib/pastel/generate-command.js +32 -62
- package/build/lib/pastel/generate-command.js.map +1 -1
- package/build/lib/pastel/generate-commands.d.ts +3 -5
- package/build/lib/pastel/generate-commands.d.ts.map +1 -1
- package/build/lib/pastel/generate-commands.js +6 -10
- package/build/lib/pastel/generate-commands.js.map +1 -1
- package/build/lib/pastel/generate-options.d.ts +3 -3
- package/build/lib/pastel/generate-options.d.ts.map +1 -1
- package/build/lib/pastel/generate-options.js +16 -13
- package/build/lib/pastel/generate-options.js.map +1 -1
- package/build/lib/pastel/index.d.ts +20 -4
- package/build/lib/pastel/index.d.ts.map +1 -1
- package/build/lib/pastel/index.js +35 -21
- package/build/lib/pastel/index.js.map +1 -1
- package/build/lib/pastel/internal-types.d.ts +39 -8
- package/build/lib/pastel/internal-types.d.ts.map +1 -1
- package/build/lib/pastel/manifest.d.ts +8 -0
- package/build/lib/pastel/manifest.d.ts.map +1 -0
- package/build/lib/pastel/manifest.js +7 -0
- package/build/lib/pastel/manifest.js.map +1 -0
- package/build/lib/pastel/read-commands.d.ts +7 -2
- package/build/lib/pastel/read-commands.d.ts.map +1 -1
- package/build/lib/pastel/read-commands.js +51 -30
- package/build/lib/pastel/read-commands.js.map +1 -1
- package/build/lib/pastel/render-command.d.ts +13 -0
- package/build/lib/pastel/render-command.d.ts.map +1 -0
- package/build/lib/pastel/render-command.js +56 -0
- package/build/lib/pastel/render-command.js.map +1 -0
- package/build/lib/registry.d.ts +11 -0
- package/build/lib/registry.d.ts.map +1 -1
- package/build/lib/registry.js +104 -22
- package/build/lib/registry.js.map +1 -1
- package/build/lib/update-check.d.ts.map +1 -1
- package/build/lib/update-check.js +5 -1
- package/build/lib/update-check.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
import {} from 'commander';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const generateCommand = (commanderCommand, pastelCommand, {
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
import { toArguments, toOptions } from './commander-specs.js';
|
|
13
|
+
/**
|
|
14
|
+
* Set up a commander command from its spec. Its module is imported only when the command runs, and Ink with it
|
|
15
|
+
* (`render-command.tsx`), so `--help` and `--version` load neither (ATK-605).
|
|
16
|
+
*/
|
|
17
|
+
const generateCommand = (commanderCommand, pastelCommand, { commandsDirectory }) => {
|
|
10
18
|
commanderCommand.helpOption('-h, --help', 'Show help');
|
|
11
19
|
if (pastelCommand.description) {
|
|
12
20
|
commanderCommand.description(pastelCommand.description);
|
|
@@ -14,67 +22,29 @@ const generateCommand = (commanderCommand, pastelCommand, { appComponent }) => {
|
|
|
14
22
|
if (pastelCommand.alias) {
|
|
15
23
|
commanderCommand.alias(pastelCommand.alias);
|
|
16
24
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const options = generateOptions(optionsSchema);
|
|
20
|
-
for (const option of options) {
|
|
21
|
-
commanderCommand.addOption(option);
|
|
22
|
-
}
|
|
25
|
+
for (const option of toOptions(pastelCommand.options ?? [])) {
|
|
26
|
+
commanderCommand.addOption(option);
|
|
23
27
|
}
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
for (const argument of arguments_) {
|
|
29
|
-
if (argument.variadic) {
|
|
30
|
-
hasVariadicArgument = true;
|
|
31
|
-
}
|
|
32
|
-
commanderCommand.addArgument(argument);
|
|
28
|
+
let variadic = false;
|
|
29
|
+
for (const argument of toArguments(pastelCommand.args ?? [])) {
|
|
30
|
+
if (argument.variadic) {
|
|
31
|
+
variadic = true;
|
|
33
32
|
}
|
|
33
|
+
commanderCommand.addArgument(argument);
|
|
34
34
|
}
|
|
35
|
-
const {
|
|
36
|
-
if (
|
|
37
|
-
commanderCommand.action((...input) => {
|
|
35
|
+
const { file } = pastelCommand;
|
|
36
|
+
if (file) {
|
|
37
|
+
commanderCommand.action(async (...input) => {
|
|
38
38
|
// Remove the last argument, which is an instance of Commander command
|
|
39
39
|
input.pop();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
rejectInput(commanderCommand, result.error);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let arguments_ = [];
|
|
52
|
-
if (pastelCommand.args) {
|
|
53
|
-
const result = pastelCommand.args.safeParse(hasVariadicArgument ? input.flat() : input);
|
|
54
|
-
if (result.success) {
|
|
55
|
-
arguments_ = result.data ?? [];
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
rejectInput(commanderCommand, result.error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
render(React.createElement(appComponent, {
|
|
62
|
-
commandProps: {
|
|
63
|
-
args: arguments_,
|
|
64
|
-
options: parsedOptions,
|
|
65
|
-
},
|
|
66
|
-
Component: component,
|
|
67
|
-
}));
|
|
40
|
+
const moduleUrl = pathToFileURL(path.join(commandsDirectory, file)).href;
|
|
41
|
+
const [module, { default: renderCommand }] = await Promise.all([
|
|
42
|
+
import(__rewriteRelativeImportExtension(moduleUrl)),
|
|
43
|
+
import('./render-command.js'),
|
|
44
|
+
]);
|
|
45
|
+
await renderCommand(commanderCommand, module, { commandsDirectory, input, variadic });
|
|
68
46
|
});
|
|
69
47
|
}
|
|
70
48
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Options or arguments the command's schema rejects are a usage error, reported through commander like its own
|
|
73
|
-
* (exit 2), so `Pastel`'s `onUsageError` sees them too.
|
|
74
|
-
*/
|
|
75
|
-
function rejectInput(commanderCommand, error) {
|
|
76
|
-
const { message } = fromZodError(error, { maxIssuesInMessage: 1, prefix: '', prefixSeparator: '' });
|
|
77
|
-
commanderCommand.error(`error: ${message}`, { code: 'pastel.invalidInput', exitCode: 2 });
|
|
78
|
-
}
|
|
79
49
|
export default generateCommand;
|
|
80
50
|
//# sourceMappingURL=generate-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-command.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,MAAM,WAAW,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"generate-command.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-command.tsx"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAoC,MAAM,WAAW,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,WAAW,EAAE,SAAS,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,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC7D,MAAM,kCAAC,SAAS,EAA4B;gBAC5C,MAAM,CAAC,qBAAqB,CAAC;aAC9B,CAAC,CAAC;YAEH,MAAM,aAAa,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxF,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Command as CommanderCommand } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const generateCommands: (parentCommanderCommand: CommanderCommand, pastelCommands: Map<string, Command>, { appComponent }: {
|
|
6
|
-
appComponent: ComponentType<AppProps>;
|
|
2
|
+
import type { CommandSpec } from './internal-types.js';
|
|
3
|
+
declare const generateCommands: (parentCommanderCommand: CommanderCommand, pastelCommands: readonly CommandSpec[], { commandsDirectory }: {
|
|
4
|
+
commandsDirectory: string;
|
|
7
5
|
}) => void;
|
|
8
6
|
export default generateCommands;
|
|
9
7
|
//# sourceMappingURL=generate-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-commands.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/generate-commands.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-commands.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/generate-commands.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,QAAA,MAAM,gBAAgB,GACpB,wBAAwB,gBAAgB,EACxC,gBAAgB,SAAS,WAAW,EAAE,EACtC,uBAAuB;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,SAkBrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { Command as CommanderCommand } from 'commander';
|
|
2
|
-
import {} from 'react';
|
|
3
2
|
import generateCommand from './generate-command.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (pastelCommands.size > 0) {
|
|
3
|
+
const generateCommands = (parentCommanderCommand, pastelCommands, { commandsDirectory }) => {
|
|
4
|
+
if (pastelCommands.length > 0) {
|
|
7
5
|
parentCommanderCommand.addHelpCommand('help [command]', 'Show help for command');
|
|
8
6
|
}
|
|
9
|
-
for (const
|
|
10
|
-
const commanderCommand = new CommanderCommand(name);
|
|
11
|
-
generateCommand(commanderCommand, pastelCommand, {
|
|
7
|
+
for (const pastelCommand of pastelCommands) {
|
|
8
|
+
const commanderCommand = new CommanderCommand(pastelCommand.name);
|
|
9
|
+
generateCommand(commanderCommand, pastelCommand, { commandsDirectory });
|
|
12
10
|
if (pastelCommand.commands) {
|
|
13
|
-
generateCommands(commanderCommand, pastelCommand.commands, {
|
|
14
|
-
appComponent,
|
|
15
|
-
});
|
|
11
|
+
generateCommands(commanderCommand, pastelCommand.commands, { commandsDirectory });
|
|
16
12
|
}
|
|
17
13
|
parentCommanderCommand.addCommand(commanderCommand, {
|
|
18
14
|
isDefault: pastelCommand.isDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-commands.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-commands.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-commands.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-commands.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIxD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,MAAM,gBAAgB,GAAG,CACvB,sBAAwC,EACxC,cAAsC,EACtC,EAAE,iBAAiB,EAAiC,EACpD,EAAE;IACF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,sBAAsB,CAAC,cAAc,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAClE,eAAe,CAAC,gBAAgB,EAAE,aAAa,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAExE,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,gBAAgB,CAAC,gBAAgB,EAAE,aAAa,CAAC,QAAQ,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACpF,CAAC;QAED,sBAAsB,CAAC,UAAU,CAAC,gBAAgB,EAAE;YAClD,SAAS,EAAE,aAAa,CAAC,SAAS;SACnC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default function
|
|
1
|
+
import { type CommandOptions, type OptionSpec } from './internal-types.js';
|
|
2
|
+
/** Describe a command's Zod `options` as commander option specs (`toOptions` in `commander-specs.ts` builds them). */
|
|
3
|
+
export default function describeOptions(optionsSchema: CommandOptions): OptionSpec[];
|
|
4
4
|
//# sourceMappingURL=generate-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-options.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/generate-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-options.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/generate-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAyB3E,sHAAsH;AACtH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,UAAU,EAAE,CA0GnF"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Option } from 'commander';
|
|
2
1
|
import decamelize from 'decamelize';
|
|
3
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
4
2
|
import plur from 'plur';
|
|
5
3
|
import { ZodArray, ZodBoolean, ZodDefault, ZodEnum, ZodNumber, ZodOptional, ZodSet } from 'zod';
|
|
6
4
|
import {} from './internal-types.js';
|
|
@@ -22,7 +20,8 @@ const getValueDescription = (value) => {
|
|
|
22
20
|
const getAlias = (value) => {
|
|
23
21
|
return getConfig(value)?.alias;
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
/** Describe a command's Zod `options` as commander option specs (`toOptions` in `commander-specs.ts` builds them). */
|
|
24
|
+
export default function describeOptions(optionsSchema) {
|
|
26
25
|
let isOptionalByDefault = false;
|
|
27
26
|
if (optionsSchema instanceof ZodOptional) {
|
|
28
27
|
isOptionalByDefault = true;
|
|
@@ -71,27 +70,31 @@ export default function generateOptions(optionsSchema) {
|
|
|
71
70
|
const rest = isVariadic ? '...' : '';
|
|
72
71
|
flag += isOptional || defaultValue ? ` [${valueDescription}${rest}]` : ` <${valueDescription}${rest}>`;
|
|
73
72
|
}
|
|
74
|
-
const option =
|
|
73
|
+
const option = { flags: flag };
|
|
74
|
+
if (description) {
|
|
75
|
+
option.description = description;
|
|
76
|
+
}
|
|
75
77
|
if (optionSchema instanceof ZodNumber) {
|
|
76
|
-
option.
|
|
78
|
+
option.parse = 'number';
|
|
77
79
|
}
|
|
78
80
|
if (optionSchema instanceof ZodEnum) {
|
|
79
|
-
option.choices
|
|
81
|
+
option.choices = Object.values(optionSchema._zod.def.entries).map(String);
|
|
80
82
|
}
|
|
81
83
|
if (optionSchema instanceof ZodBoolean && defaultValue === undefined) {
|
|
82
84
|
defaultValue = false;
|
|
83
85
|
}
|
|
84
86
|
if (optionSchema instanceof ZodSet) {
|
|
85
|
-
option.
|
|
86
|
-
const joinPreviousValue = previousValue instanceof Set && !isDeepStrictEqual(previousValue, defaultValue);
|
|
87
|
-
return joinPreviousValue ? new Set([...previousValue, value]) : new Set([value]);
|
|
88
|
-
});
|
|
87
|
+
option.parse = 'set';
|
|
89
88
|
}
|
|
90
89
|
if (defaultValue !== undefined) {
|
|
91
|
-
if (
|
|
92
|
-
defaultValueDescription
|
|
90
|
+
if (defaultValue instanceof Set) {
|
|
91
|
+
defaultValueDescription ||= JSON.stringify([...defaultValue]);
|
|
92
|
+
defaultValue = [...defaultValue];
|
|
93
|
+
}
|
|
94
|
+
option.defaultValue = defaultValue;
|
|
95
|
+
if (defaultValueDescription) {
|
|
96
|
+
option.defaultValueDescription = defaultValueDescription;
|
|
93
97
|
}
|
|
94
|
-
option.default(defaultValue, defaultValueDescription);
|
|
95
98
|
}
|
|
96
99
|
options.push(option);
|
|
97
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-options.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-options.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"generate-options.js","sourceRoot":"","sources":["../../../src/lib/pastel/generate-options.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAEhG,OAAO,EAAwC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAA4B,MAAM,YAAY,CAAC;AAEtD,MAAM,SAAS,GAAG,CAAC,KAAyB,EAAmC,EAAE;IAC/E,OAAO,KA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AG,EAAE,CAAC;gBAChC,uBAAuB,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;gBAC9D,YAAY,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;YACnC,CAAC;YAED,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;YAEnC,IAAI,uBAAuB,EAAE,CAAC;gBAC5B,MAAM,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import type { CommandManifest } from './internal-types.js';
|
|
1
2
|
import type { CommandArgumentConfig, CommandOptionConfig } from './types.js';
|
|
2
3
|
export type Options = {
|
|
4
|
+
/**
|
|
5
|
+
* The commands, described ahead of time by `describeCommands` (`lib/pastel/manifest.js`), so a run imports only
|
|
6
|
+
* the command it runs. Without it, Pastel imports every command in the `commands` folder to describe them.
|
|
7
|
+
*/
|
|
8
|
+
commands?: CommandManifest;
|
|
3
9
|
/**
|
|
4
10
|
* Description. Defaults to `description` in the nearest package.json.
|
|
5
11
|
*/
|
|
6
12
|
description?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Options every command accepts, before or after its name (commander's program options), listed under
|
|
15
|
+
* "Global Options" in each command's help. Pastel only declares them: commands don't receive their values, so the
|
|
16
|
+
* app reads them itself.
|
|
17
|
+
*/
|
|
18
|
+
globalOptions?: ReadonlyArray<{
|
|
19
|
+
description: string;
|
|
20
|
+
flags: string;
|
|
21
|
+
}>;
|
|
7
22
|
/**
|
|
8
23
|
* Text to display before all help output.
|
|
9
24
|
*/
|
|
@@ -27,6 +42,10 @@ export type Options = {
|
|
|
27
42
|
*/
|
|
28
43
|
version?: string;
|
|
29
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Set additional metadata for an option. Must be used as an argument to `describe` function from Zod.
|
|
47
|
+
*/
|
|
48
|
+
export declare function option(config: CommandOptionConfig): string;
|
|
30
49
|
export default class Pastel {
|
|
31
50
|
private readonly options;
|
|
32
51
|
constructor(options: Options);
|
|
@@ -39,9 +58,6 @@ export default class Pastel {
|
|
|
39
58
|
* Set additional metadata for an argument. Must be used as an argument to `describe` function from Zod.
|
|
40
59
|
*/
|
|
41
60
|
export declare function argument(config: CommandArgumentConfig): string;
|
|
42
|
-
|
|
43
|
-
* Set additional metadata for an option. Must be used as an argument to `describe` function from Zod.
|
|
44
|
-
*/
|
|
45
|
-
export declare function option(config: CommandOptionConfig): string;
|
|
61
|
+
export type { CommandManifest } from './internal-types.js';
|
|
46
62
|
export * from './types.js';
|
|
47
63
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAK7E,MAAM,MAAM,OAAO,GAAG;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAE3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEtE;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAKF;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,mBAAmB,UAEjD;AAED,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,OAAO,EAAE,OAAO;IAI5B;;OAEG;IACG,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB;CA0DxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,UAErD;AA6BD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,cAAc,YAAY,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import process from 'node:process';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { readPackageUp } from 'read-package-up';
|
|
5
|
-
import App from './_app.js';
|
|
6
4
|
import generateCommand from './generate-command.js';
|
|
7
5
|
import generateCommands from './generate-commands.js';
|
|
8
|
-
import readCommands from './read-commands.js';
|
|
9
|
-
import readCustomApp from './read-custom-app.js';
|
|
10
6
|
/** Commander's exits that are output, not errors: `--help`, `help`, a bare command group, `--version`. */
|
|
11
7
|
const NOT_USAGE_ERRORS = new Set(['commander.help', 'commander.helpDisplayed', 'commander.version']);
|
|
8
|
+
/**
|
|
9
|
+
* Set additional metadata for an option. Must be used as an argument to `describe` function from Zod.
|
|
10
|
+
*/
|
|
11
|
+
export function option(config) {
|
|
12
|
+
return `__pastel_option_config__${JSON.stringify(config)}`;
|
|
13
|
+
}
|
|
12
14
|
export default class Pastel {
|
|
13
15
|
options;
|
|
14
16
|
constructor(options) {
|
|
@@ -19,33 +21,44 @@ export default class Pastel {
|
|
|
19
21
|
*/
|
|
20
22
|
async run(argv = process.argv) {
|
|
21
23
|
const commandsDirectory = fileURLToPath(new URL('commands', this.options.importMeta.url));
|
|
22
|
-
const appComponent = (await readCustomApp(commandsDirectory)) ?? App;
|
|
23
24
|
const program = new Command();
|
|
24
|
-
const commands = await
|
|
25
|
-
const indexCommand = commands.
|
|
25
|
+
const commands = this.options.commands ?? (await (await import('./manifest.js')).describeCommands(commandsDirectory));
|
|
26
|
+
const indexCommand = commands.find((command) => command.name === 'index');
|
|
26
27
|
if (indexCommand) {
|
|
27
|
-
generateCommand(program, indexCommand, {
|
|
28
|
-
commands.delete('index');
|
|
28
|
+
generateCommand(program, indexCommand, { commandsDirectory });
|
|
29
29
|
}
|
|
30
|
-
generateCommands(program, commands, {
|
|
30
|
+
generateCommands(program, commands.filter((command) => command !== indexCommand), { commandsDirectory });
|
|
31
31
|
if (this.options.name) {
|
|
32
32
|
program.name(this.options.name);
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
let version = this.options.version;
|
|
35
|
+
let description = indexCommand?.description ?? this.options.description;
|
|
36
|
+
// Only for what the app didn't pass: read-package-up loads about 50 ms of modules (ATK-605).
|
|
37
|
+
if (version === undefined || description === undefined) {
|
|
38
|
+
const { readPackageUp } = await import('read-package-up');
|
|
39
|
+
const package_ = await readPackageUp();
|
|
40
|
+
version ??= package_?.packageJson.version;
|
|
41
|
+
description ??= package_?.packageJson.description;
|
|
42
|
+
}
|
|
36
43
|
if (version) {
|
|
37
44
|
program.version(version, '-v, --version', 'Show version number');
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
program.description(description);
|
|
46
|
+
program.description(description ?? '');
|
|
41
47
|
program.helpOption('-h, --help', 'Show help');
|
|
42
48
|
if (this.options.helpHeader) {
|
|
43
49
|
program.addHelpText('beforeAll', this.options.helpHeader);
|
|
44
50
|
}
|
|
51
|
+
if (this.options.globalOptions) {
|
|
52
|
+
for (const { description, flags } of this.options.globalOptions) {
|
|
53
|
+
program.option(flags, description);
|
|
54
|
+
}
|
|
55
|
+
showGlobalOptions(program);
|
|
56
|
+
}
|
|
45
57
|
if (this.options.onUsageError) {
|
|
46
58
|
routeUsageErrors(program, this.options.onUsageError);
|
|
47
59
|
}
|
|
48
|
-
|
|
60
|
+
// Async, because a command's action imports its module.
|
|
61
|
+
await program.parseAsync(argv);
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
/**
|
|
@@ -54,12 +67,6 @@ export default class Pastel {
|
|
|
54
67
|
export function argument(config) {
|
|
55
68
|
return `__pastel_argument_config__${JSON.stringify(config)}`;
|
|
56
69
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Set additional metadata for an option. Must be used as an argument to `describe` function from Zod.
|
|
59
|
-
*/
|
|
60
|
-
export function option(config) {
|
|
61
|
-
return `__pastel_option_config__${JSON.stringify(config)}`;
|
|
62
|
-
}
|
|
63
70
|
/**
|
|
64
71
|
* Send every command's usage errors to `onUsageError`. Commands added with `addCommand` don't inherit their
|
|
65
72
|
* parent's `exitOverride` or `configureOutput`, so each one gets its own.
|
|
@@ -76,5 +83,12 @@ function routeUsageErrors(command, onUsageError) {
|
|
|
76
83
|
routeUsageErrors(subcommand, onUsageError);
|
|
77
84
|
}
|
|
78
85
|
}
|
|
86
|
+
/** List the program's options under "Global Options" in every command's help; `addCommand` doesn't inherit it. */
|
|
87
|
+
function showGlobalOptions(command) {
|
|
88
|
+
command.configureHelp({ ...command.configureHelp(), showGlobalOptions: true });
|
|
89
|
+
for (const subcommand of command.commands) {
|
|
90
|
+
showGlobalOptions(subcommand);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
79
93
|
export * from './types.js';
|
|
80
94
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/pastel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,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AAClH,SAAS,iBAAiB,CAAC,OAAgB;IACzC,OAAO,CAAC,aAAa,CAAC,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/E,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1C,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAGD,cAAc,YAAY,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import type { ZodArray, ZodBoolean, ZodDefault, ZodEnum, ZodNumber, ZodObject, ZodOptional, ZodSet, ZodString, ZodTuple, ZodTypeAny } from 'zod';
|
|
3
3
|
import { type AppProps } from './types.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A commander argument as plain data, described from a command's Zod `args` (`generate-arguments.tsx`) and turned
|
|
6
|
+
* back into an `Argument` without Zod (`commander-specs.ts`), so a manifest can carry it (ATK-605).
|
|
7
|
+
*/
|
|
8
|
+
export type ArgumentSpec = {
|
|
9
|
+
choices?: string[];
|
|
10
|
+
defaultValue?: unknown;
|
|
11
|
+
defaultValueDescription?: string;
|
|
9
12
|
description?: string;
|
|
10
|
-
|
|
13
|
+
/** commander's name with its brackets: `<name>`, `[name]`, `[name...]`. */
|
|
11
14
|
name: string;
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
/** `number`: one number; `number-list`: numbers collected into an array, restarting from the default. */
|
|
16
|
+
parse?: 'number' | 'number-list';
|
|
14
17
|
};
|
|
15
18
|
export type CommandArgument = ZodEnum<Record<string, number | string>> | ZodNumber | ZodString;
|
|
16
19
|
export type CommandArguments = ZodMaybeOptionalOrDefault<CommandArgumentsArray | CommandArgumentsTuple>;
|
|
@@ -27,8 +30,36 @@ export type CommandExports = {
|
|
|
27
30
|
isDefault?: boolean;
|
|
28
31
|
options?: CommandOptions;
|
|
29
32
|
};
|
|
33
|
+
/** Every command in the commands folder, the root's `index` among them, in file-name order. */
|
|
34
|
+
export type CommandManifest = CommandSpec[];
|
|
30
35
|
export type CommandOption = ZodMaybeOptionalOrDefault<ZodArray<ZodEnum<Record<string, number | string>>>> | ZodMaybeOptionalOrDefault<ZodArray<ZodNumber>> | ZodMaybeOptionalOrDefault<ZodArray<ZodString>> | ZodMaybeOptionalOrDefault<ZodBoolean> | ZodMaybeOptionalOrDefault<ZodEnum<Record<string, number | string>>> | ZodMaybeOptionalOrDefault<ZodNumber> | ZodMaybeOptionalOrDefault<ZodSet<ZodEnum<Record<string, number | string>>>> | ZodMaybeOptionalOrDefault<ZodSet<ZodNumber>> | ZodMaybeOptionalOrDefault<ZodSet<ZodString>> | ZodMaybeOptionalOrDefault<ZodString>;
|
|
31
36
|
export type CommandOptions = ZodMaybeOptional<ZodObject<Record<string, CommandOption>>>;
|
|
37
|
+
/**
|
|
38
|
+
* A command as plain data: what commander needs to parse it and print its help, without importing its module. `file`
|
|
39
|
+
* is the module (with its component) relative to the commands folder, with a `.js` extension; a folder without an
|
|
40
|
+
* `index` has none.
|
|
41
|
+
*/
|
|
42
|
+
export type CommandSpec = {
|
|
43
|
+
alias?: string;
|
|
44
|
+
args?: ArgumentSpec[];
|
|
45
|
+
commands?: CommandSpec[];
|
|
46
|
+
description?: string;
|
|
47
|
+
file?: string;
|
|
48
|
+
isDefault: boolean;
|
|
49
|
+
name: string;
|
|
50
|
+
options?: OptionSpec[];
|
|
51
|
+
};
|
|
52
|
+
/** A commander option as plain data, described from a command's Zod `options` (`generate-options.ts`). */
|
|
53
|
+
export type OptionSpec = {
|
|
54
|
+
choices?: string[];
|
|
55
|
+
/** For `parse: 'set'`, the set's members. */
|
|
56
|
+
defaultValue?: unknown;
|
|
57
|
+
defaultValueDescription?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
flags: string;
|
|
60
|
+
/** `number`: parsed as a number; `set`: repeated values collected into a `Set`. */
|
|
61
|
+
parse?: 'number' | 'set';
|
|
62
|
+
};
|
|
32
63
|
export type ZodMaybeOptional<T extends ZodTypeAny> = T | ZodOptional<T>;
|
|
33
64
|
export type ZodMaybeOptionalOrDefault<T extends ZodTypeAny> = T | ZodDefault<T> | ZodDefault<ZodOptional<T>> | ZodOptional<T> | ZodOptional<ZodDefault<T>>;
|
|
34
65
|
//# sourceMappingURL=internal-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/internal-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,MAAM,EACN,SAAS,EACT,QAAQ,EACR,UAAU,EACX,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/internal-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,MAAM,EACN,SAAS,EACT,QAAQ,EACR,UAAU,EACX,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,WAAW,CAAC,E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AAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,UAAU,IACxD,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pastel's build-time entry: describe a commands folder as the manifest `Pastel`'s `commands` option takes. It imports
|
|
3
|
+
* every command and Zod, which is why `index.ts` doesn't re-export it (ATK-605).
|
|
4
|
+
*/
|
|
5
|
+
import readCommands from './read-commands.js';
|
|
6
|
+
export type { ArgumentSpec, CommandManifest, CommandSpec, OptionSpec } from './internal-types.js';
|
|
7
|
+
export { readCommands as describeCommands };
|
|
8
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/manifest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAE9C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pastel's build-time entry: describe a commands folder as the manifest `Pastel`'s `commands` option takes. It imports
|
|
3
|
+
* every command and Zod, which is why `index.ts` doesn't re-export it (ATK-605).
|
|
4
|
+
*/
|
|
5
|
+
import readCommands from './read-commands.js';
|
|
6
|
+
export { readCommands as describeCommands };
|
|
7
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/lib/pastel/manifest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAI9C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { CommandManifest } from './internal-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Import every command in `directory` and describe it as plain data. Files are read in name order, so the manifest
|
|
4
|
+
* and the help list commands the same way on every file system. `prefix` is the folder's path from the commands
|
|
5
|
+
* folder, for `file`.
|
|
6
|
+
*/
|
|
7
|
+
declare const readCommands: (directory: string, prefix?: string) => Promise<CommandManifest>;
|
|
3
8
|
export default readCommands;
|
|
4
9
|
//# sourceMappingURL=read-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-commands.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/read-commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-commands.d.ts","sourceRoot":"","sources":["../../../src/lib/pastel/read-commands.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAkB,eAAe,EAAe,MAAM,qBAAqB,CAAC;AAKxF;;;;GAIG;AACH,QAAA,MAAM,YAAY,GAAU,WAAW,MAAM,EAAE,eAAW,KAAG,OAAO,CAAC,eAAe,CA8DnF,CAAC;AAiBF,eAAe,YAAY,CAAC"}
|