depflow 3.0.0-dev.1 → 3.0.0-dev.11
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 +108 -43
- package/dist/builder/Builder.d.ts +279 -0
- package/dist/builder/Builder.js +391 -0
- package/dist/builder/Builder.js.map +1 -0
- package/dist/cli/CLI.d.ts +157 -0
- package/dist/cli/CLI.js +214 -0
- package/dist/cli/CLI.js.map +1 -0
- package/dist/cli/DepFLowCLI.d.ts +93 -0
- package/dist/cli/DepFLowCLI.js +413 -0
- package/dist/cli/DepFLowCLI.js.map +1 -0
- package/dist/cli/Flags.d.ts +106 -0
- package/dist/cli/Flags.js +125 -0
- package/dist/cli/Flags.js.map +1 -0
- package/dist/cli/bin.js +68 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/config/Config.d.ts +690 -0
- package/dist/config/Config.js +45 -0
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ImportMap.d.ts +60 -0
- package/dist/config/ImportMap.js +66 -0
- package/dist/config/ImportMap.js.map +1 -0
- package/dist/config/JsonSchema.d.ts +12 -0
- package/dist/config/JsonSchema.js +26 -0
- package/dist/config/JsonSchema.js.map +1 -0
- package/dist/config/Settings.d.ts +201 -0
- package/dist/config/Settings.js +191 -0
- package/dist/config/Settings.js.map +1 -0
- package/dist/config/TSConfig.d.ts +73 -0
- package/dist/config/TSConfig.js +73 -0
- package/dist/config/TSConfig.js.map +1 -0
- package/dist/config/codecs/JsonCodec.d.ts +30 -0
- package/dist/config/codecs/JsonCodec.js +31 -0
- package/dist/config/codecs/JsonCodec.js.map +1 -0
- package/dist/config/codecs/YamlCodec.d.ts +62 -0
- package/dist/config/codecs/YamlCodec.js +89 -0
- package/dist/config/codecs/YamlCodec.js.map +1 -0
- package/dist/dependency/DepUtils.d.ts +50 -0
- package/dist/dependency/DepUtils.js +71 -0
- package/dist/dependency/DepUtils.js.map +1 -0
- package/dist/dependency/Dependency.d.ts +81 -0
- package/dist/dependency/Dependency.js +71 -0
- package/dist/dependency/Dependency.js.map +1 -0
- package/dist/dependency/Git.d.ts +75 -0
- package/dist/dependency/Git.js +97 -0
- package/dist/dependency/Git.js.map +1 -0
- package/dist/dependency/GitDependency.d.ts +30 -0
- package/dist/dependency/GitDependency.js +79 -0
- package/dist/dependency/GitDependency.js.map +1 -0
- package/dist/dependency/NpmDependency.d.ts +27 -0
- package/dist/dependency/NpmDependency.js +91 -0
- package/dist/dependency/NpmDependency.js.map +1 -0
- package/dist/resolve/AliasCompiler.d.ts +45 -0
- package/dist/resolve/AliasCompiler.js +84 -0
- package/dist/resolve/AliasCompiler.js.map +1 -0
- package/{build/support/PathResolver → dist/resolve}/PathResolver.d.ts +26 -9
- package/dist/resolve/PathResolver.js +133 -0
- package/dist/resolve/PathResolver.js.map +1 -0
- package/dist/resolve/PathRewriter.d.ts +24 -0
- package/{build/support/PathResolver → dist/resolve}/PathRewriter.js +21 -11
- package/dist/resolve/PathRewriter.js.map +1 -0
- package/dist/schema/Config/Builder.d.ts +496 -0
- package/dist/schema/Config/Builder.js +78 -0
- package/dist/schema/Config/Builder.js.map +1 -0
- package/dist/schema/Config/Config.d.ts +673 -0
- package/dist/schema/Config/Config.js +62 -0
- package/dist/schema/Config/Config.js.map +1 -0
- package/dist/schema/Config/Dependency.d.ts +878 -0
- package/dist/schema/Config/Dependency.js +80 -0
- package/dist/schema/Config/Dependency.js.map +1 -0
- package/dist/schema/Config/Extractor.d.ts +157 -0
- package/dist/schema/Config/Extractor.js +43 -0
- package/dist/schema/Config/Extractor.js.map +1 -0
- package/dist/schema/Config/Resolver.d.ts +87 -0
- package/dist/schema/Config/Resolver.js +43 -0
- package/dist/schema/Config/Resolver.js.map +1 -0
- package/dist/schema/Config/Transform.d.ts +90 -0
- package/dist/schema/Config/Transform.js +51 -0
- package/dist/schema/Config/Transform.js.map +1 -0
- package/dist/schema/Defaults.d.ts +20 -0
- package/dist/schema/Defaults.js +24 -0
- package/dist/schema/Defaults.js.map +1 -0
- package/dist/schema/ImportMap.d.ts +30 -0
- package/dist/schema/ImportMap.js +28 -0
- package/dist/schema/ImportMap.js.map +1 -0
- package/dist/schema/TSConfig.d.ts +70 -0
- package/dist/schema/TSConfig.js +39 -0
- package/dist/schema/TSConfig.js.map +1 -0
- package/dist/schema/schema.d.ts +38 -0
- package/dist/schema/schema.js +40 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/task/Command.d.ts +287 -0
- package/dist/task/Command.js +404 -0
- package/dist/task/Command.js.map +1 -0
- package/dist/task/Group.d.ts +15 -0
- package/dist/task/Group.js +29 -0
- package/dist/task/Group.js.map +1 -0
- package/dist/task/OutputPolicy.d.ts +262 -0
- package/dist/task/OutputPolicy.js +364 -0
- package/dist/task/OutputPolicy.js.map +1 -0
- package/dist/task/Task.d.ts +210 -0
- package/dist/task/Task.js +312 -0
- package/dist/task/Task.js.map +1 -0
- package/package.json +16 -14
- package/.gitignore +0 -7
- package/build/cli/DepFLowCLI.d.ts +0 -15
- package/build/cli/DepFLowCLI.js +0 -223
- package/build/cli/DepFLowCLI.js.map +0 -1
- package/build/cli/bin.js +0 -41
- package/build/cli/bin.js.map +0 -1
- package/build/config/Config.d.ts +0 -28
- package/build/config/Config.js +0 -46
- package/build/config/Config.js.map +0 -1
- package/build/config/ImportMap.d.ts +0 -37
- package/build/config/ImportMap.js +0 -82
- package/build/config/ImportMap.js.map +0 -1
- package/build/config/Tsconfig.d.ts +0 -57
- package/build/config/Tsconfig.js +0 -100
- package/build/config/Tsconfig.js.map +0 -1
- package/build/config/schemas.d.ts +0 -1194
- package/build/config/schemas.js +0 -66
- package/build/config/schemas.js.map +0 -1
- package/build/support/Async.d.ts +0 -22
- package/build/support/Async.js +0 -62
- package/build/support/Async.js.map +0 -1
- package/build/support/Builder/Builder.d.ts +0 -36
- package/build/support/Builder/Builder.js +0 -89
- package/build/support/Builder/Builder.js.map +0 -1
- package/build/support/Dependency/Dependency.d.ts +0 -38
- package/build/support/Dependency/Dependency.js +0 -14
- package/build/support/Dependency/Dependency.js.map +0 -1
- package/build/support/Dependency/GitDependency.d.ts +0 -20
- package/build/support/Dependency/GitDependency.js +0 -67
- package/build/support/Dependency/GitDependency.js.map +0 -1
- package/build/support/Dependency/NpmDependency.d.ts +0 -18
- package/build/support/Dependency/NpmDependency.js +0 -65
- package/build/support/Dependency/NpmDependency.js.map +0 -1
- package/build/support/Dependency/Resolver.d.ts +0 -7
- package/build/support/Dependency/Resolver.js +0 -4
- package/build/support/Dependency/Resolver.js.map +0 -1
- package/build/support/Git.d.ts +0 -53
- package/build/support/Git.js +0 -86
- package/build/support/Git.js.map +0 -1
- package/build/support/PathResolver/AliasCompiler.d.ts +0 -25
- package/build/support/PathResolver/AliasCompiler.js +0 -39
- package/build/support/PathResolver/AliasCompiler.js.map +0 -1
- package/build/support/PathResolver/PathResolver.js +0 -104
- package/build/support/PathResolver/PathResolver.js.map +0 -1
- package/build/support/PathResolver/PathRewriter.d.ts +0 -18
- package/build/support/PathResolver/PathRewriter.js.map +0 -1
- package/build/support/PathResolver/Utils.d.ts +0 -36
- package/build/support/PathResolver/Utils.js +0 -45
- package/build/support/PathResolver/Utils.js.map +0 -1
- package/build/support/Task/Command.d.ts +0 -49
- package/build/support/Task/Command.js +0 -100
- package/build/support/Task/Command.js.map +0 -1
- package/build/support/Task/Task.d.ts +0 -84
- package/build/support/Task/Task.js +0 -145
- package/build/support/Task/Task.js.map +0 -1
- package/build/support/Utils.d.ts +0 -40
- package/build/support/Utils.js +0 -138
- package/build/support/Utils.js.map +0 -1
- package/build/support/Validator.d.ts +0 -22
- package/build/support/Validator.js +0 -28
- package/build/support/Validator.js.map +0 -1
- /package/{build → dist}/cli/bin.d.ts +0 -0
package/dist/cli/CLI.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>.
|
|
3
|
+
* @description The console interface the CLI is built on: it reads a command, runs it and answers it,
|
|
4
|
+
* and it draws the help the global flags and the arguments of every command are told in.
|
|
5
|
+
* @license Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
import { Logger, ConsoleUI } from '@netfeez/vterm';
|
|
8
|
+
/** The visible column the description of a flag or an argument starts at, in `help`. **/
|
|
9
|
+
const HELP_COLUMN = 26;
|
|
10
|
+
export class CLI {
|
|
11
|
+
/** What reads the input of the console interface. */
|
|
12
|
+
dataHandleInstance;
|
|
13
|
+
/** What is written before every command the interface reads. */
|
|
14
|
+
prompt;
|
|
15
|
+
/** The input the interface reads commands from. */
|
|
16
|
+
in;
|
|
17
|
+
/** The engine the interface answers through. */
|
|
18
|
+
out;
|
|
19
|
+
/** The commands the interface accepts, keyed by the name each one is invoked with. */
|
|
20
|
+
commandMap;
|
|
21
|
+
/** The terminal the prompt and the help are written to. */
|
|
22
|
+
console;
|
|
23
|
+
/** The flags that are not specific to a command, keyed by the name each one is declared under. */
|
|
24
|
+
globals;
|
|
25
|
+
/** The branded line the help opens with. */
|
|
26
|
+
title;
|
|
27
|
+
/**
|
|
28
|
+
* Wires a console interface to its terminal, its global flags and its commands.
|
|
29
|
+
* @param globals - The flags no command owns, declared as `Flags` declares them.
|
|
30
|
+
* @param config - How the interface presents itself: the name of its runs, its prompt and its title.
|
|
31
|
+
*/
|
|
32
|
+
constructor(globals = {}, config = {}) {
|
|
33
|
+
this.dataHandleInstance = this.dataHandler.bind(this);
|
|
34
|
+
this.prompt = ConsoleUI.formatText(config.prompt ?? '&C5[CLI] << &C6&S');
|
|
35
|
+
this.in = process.stdin;
|
|
36
|
+
const logger = new Logger({ name: config.name ?? 'CLI' });
|
|
37
|
+
this.out = logger.engine;
|
|
38
|
+
this.console = logger.console;
|
|
39
|
+
this.globals = globals;
|
|
40
|
+
this.title = config.title ?? '&C1CLI';
|
|
41
|
+
this.commandMap = {};
|
|
42
|
+
this.addDefaultCommands();
|
|
43
|
+
}
|
|
44
|
+
/** Starts reading what is written to the input. **/
|
|
45
|
+
startReadIn() {
|
|
46
|
+
this.in.on('data', this.dataHandleInstance);
|
|
47
|
+
this.console.write(this.prompt);
|
|
48
|
+
}
|
|
49
|
+
/** Stops reading what is written to the input. **/
|
|
50
|
+
stopReadIn() { this.in.off('data', this.dataHandleInstance); }
|
|
51
|
+
/** Starts the console UI. **/
|
|
52
|
+
start() { this.startReadIn(); }
|
|
53
|
+
/** Stops the console UI. **/
|
|
54
|
+
stop() { this.stopReadIn(); }
|
|
55
|
+
/**
|
|
56
|
+
* Runs the command the input carries, and writes the prompt again unless the command leaves.
|
|
57
|
+
* @param data - What arrived in the input.
|
|
58
|
+
* @returns A promise of the command being over.
|
|
59
|
+
*/
|
|
60
|
+
async dataHandler(data) {
|
|
61
|
+
const [cmd, ...args] = data.toString('utf-8').trim().split(' ');
|
|
62
|
+
this.out.log(`&C(80,0,80)command received: &C3${cmd}`, args);
|
|
63
|
+
try {
|
|
64
|
+
const command = this.commandMap[cmd];
|
|
65
|
+
if (command)
|
|
66
|
+
await command.exec.bind(this)(cmd, args);
|
|
67
|
+
else
|
|
68
|
+
this.out.error(`&C1Unknown command: &C3${cmd}`);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
this.out.error(`&C1Error executing command: &C3${cmd}`, error);
|
|
72
|
+
}
|
|
73
|
+
if (cmd !== 'exit-debug')
|
|
74
|
+
this.console.write(this.prompt);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The command of that name, when the map carries one.
|
|
78
|
+
* @param command - The name of the command.
|
|
79
|
+
* @returns The command, or undefined when the map carries no command of that name.
|
|
80
|
+
*/
|
|
81
|
+
getCommand(command) { return this.commandMap[command]; }
|
|
82
|
+
/**
|
|
83
|
+
* Puts a command in the map.
|
|
84
|
+
* @param command - The name of the command.
|
|
85
|
+
* @param exec - What the command does when it is written.
|
|
86
|
+
* @param info - What `help` tells about it, the arguments it accepts among it.
|
|
87
|
+
* @returns This instance, so commands can be added one after another.
|
|
88
|
+
*/
|
|
89
|
+
addCommand(command, exec, info) {
|
|
90
|
+
this.commandMap[command] = { name: command, exec, ...info };
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Takes a command out of the map.
|
|
95
|
+
* @param command - The name of the command.
|
|
96
|
+
* @returns This instance, so commands can be removed one after another.
|
|
97
|
+
*/
|
|
98
|
+
removeCommand(command) {
|
|
99
|
+
delete this.commandMap[command];
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Puts the commands every console interface carries in the map.
|
|
104
|
+
**/
|
|
105
|
+
addDefaultCommands() {
|
|
106
|
+
this.addCommand('help', this.showHelp.bind(this), { description: '&C6Shows this help', usage: 'help' });
|
|
107
|
+
this.addCommand('exit', () => process.exit(), { description: '&C6Exits the process', usage: 'exit' });
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Writes the banner, the global flags and every command of the map with its usage, its description
|
|
111
|
+
* and the arguments it accepts.
|
|
112
|
+
*
|
|
113
|
+
* @remarks The help belongs to the terminal and not to a run, so it is written as it is composed
|
|
114
|
+
* and it is not announced through the engine: no timestamp, level or name is put in front of it,
|
|
115
|
+
* and a line is only broken where this method breaks it.
|
|
116
|
+
**/
|
|
117
|
+
showHelp() {
|
|
118
|
+
const width = Math.max(40, Math.min(process.stdout.columns ?? 80, 100));
|
|
119
|
+
const box = '&C5';
|
|
120
|
+
const lines = [this.title, '', '&C6Global flags:'];
|
|
121
|
+
for (const [name, flag] of Object.entries(this.globals)) {
|
|
122
|
+
const key = CLI.flagKey(name, flag);
|
|
123
|
+
lines.push(...CLI.describe(key, flag.description ?? '', width));
|
|
124
|
+
}
|
|
125
|
+
lines.push('', '&C6Commands:');
|
|
126
|
+
for (const command of Object.values(this.commandMap)) {
|
|
127
|
+
lines.push(`&C3 > ${command.name}`);
|
|
128
|
+
if (command.usage)
|
|
129
|
+
lines.push(` &C7Usage: &C6${command.usage}`);
|
|
130
|
+
if (command.description)
|
|
131
|
+
lines.push(...CLI.wrap(command.description, width - 5).map(line => ` ${line}`));
|
|
132
|
+
for (const [name, argument] of Object.entries(command.args ?? {})) {
|
|
133
|
+
lines.push(...CLI.describe(CLI.argumentKey(name, argument), argument.description, width, 5));
|
|
134
|
+
}
|
|
135
|
+
lines.push('');
|
|
136
|
+
}
|
|
137
|
+
const edge = `${box}╭${'─'.repeat(width - 2)}`;
|
|
138
|
+
this.console.log(edge);
|
|
139
|
+
for (const line of lines)
|
|
140
|
+
this.console.log(`${box}│ ${line}`);
|
|
141
|
+
this.console.log(`${box}╰${'─'.repeat(width - 2)}`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The name of a flag as the help writes it, with the aliases it accepts and the value it takes.
|
|
145
|
+
* @param name - The name the flag is declared under.
|
|
146
|
+
* @param flag - The declared flag.
|
|
147
|
+
* @returns The name of the flag, colored.
|
|
148
|
+
*/
|
|
149
|
+
static flagKey(name, flag) {
|
|
150
|
+
const names = [name, ...flag.aliases ?? []].map(alias => alias.length === 1 ? `-${alias}` : `--${alias}`);
|
|
151
|
+
const value = flag.type === 'boolean' ? '' : ' &C7<string>';
|
|
152
|
+
return `&C3${names.join(', ')}${value}`;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The name of an argument as the help writes it, telling an optional one and a variadic one apart.
|
|
156
|
+
* @param name - The name the argument is declared under.
|
|
157
|
+
* @param argument - The declared argument.
|
|
158
|
+
* @returns The name of the argument, colored.
|
|
159
|
+
*/
|
|
160
|
+
static argumentKey(name, argument) {
|
|
161
|
+
const core = argument.variadic ? `${name}...` : name;
|
|
162
|
+
const written = (argument.required ?? true) ? `<${core}>` : `[${core}]`;
|
|
163
|
+
return `&C3${written}`;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Lays out a name and what it is for in the columns left after the name.
|
|
167
|
+
* @param key - The name, with the tokens that color it.
|
|
168
|
+
* @param description - What the name is for.
|
|
169
|
+
* @param width - The visible width every line is kept within.
|
|
170
|
+
* @param indent - The visible columns the entry starts at.
|
|
171
|
+
* @returns The lines of the entry, the description broken in as many lines as it needs.
|
|
172
|
+
*/
|
|
173
|
+
static describe(key, description, width, indent = 3) {
|
|
174
|
+
const column = indent + HELP_COLUMN;
|
|
175
|
+
const lead = ' '.repeat(indent);
|
|
176
|
+
const padding = ' '.repeat(Math.max(1, column - indent - CLI.visibleWidth(key)));
|
|
177
|
+
const available = Math.max(20, width - column);
|
|
178
|
+
const wrapped = CLI.wrap(description, available);
|
|
179
|
+
if (wrapped.length === 0)
|
|
180
|
+
return [`${lead}${key}`];
|
|
181
|
+
return wrapped.map((line, index) => index === 0
|
|
182
|
+
? `${lead}${key}${padding}&C7${line}`
|
|
183
|
+
: `${' '.repeat(column)}&C7${line}`);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Breaks a text in as many lines as it needs to fit a visible width, on its word boundaries.
|
|
187
|
+
* @param text - The text to break, without tokens in it.
|
|
188
|
+
* @param width - The visible width every line is kept within.
|
|
189
|
+
* @returns The lines the text was broken in.
|
|
190
|
+
*/
|
|
191
|
+
static wrap(text, width) {
|
|
192
|
+
const lines = [];
|
|
193
|
+
let current = '';
|
|
194
|
+
for (const word of text.split(' ')) {
|
|
195
|
+
if (current && CLI.visibleWidth(current) + 1 + CLI.visibleWidth(word) > width) {
|
|
196
|
+
lines.push(current);
|
|
197
|
+
current = word;
|
|
198
|
+
}
|
|
199
|
+
else
|
|
200
|
+
current = current ? `${current} ${word}` : word;
|
|
201
|
+
}
|
|
202
|
+
if (current)
|
|
203
|
+
lines.push(current);
|
|
204
|
+
return lines;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The columns a text paints, with its tokens taken out.
|
|
208
|
+
* @param text - The text to measure, with the tokens of the grammar in it.
|
|
209
|
+
* @returns The number of visible columns it paints.
|
|
210
|
+
*/
|
|
211
|
+
static visibleWidth(text) { return ConsoleUI.cleanFormat(text).length; }
|
|
212
|
+
}
|
|
213
|
+
export default CLI;
|
|
214
|
+
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,CAAC,EAAE,CAAC;YACjC,IAAI,OAAO,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;gBAC5E,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACpB,OAAO,GAAG,IAAI,CAAC;YACnB,CAAC;;gBAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3D,CAAC;QACD,IAAI,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,YAAY,CAAC,IAAY,IAAY,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;CACrG;AAmDD,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author NetFeez <netfeez.dev@gmail.com>.
|
|
3
|
+
* @description Main CLI surface: dependency management commands, builds and config conversions.
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import CLI from "./CLI.js";
|
|
7
|
+
import OutputPolicy from "../task/OutputPolicy.js";
|
|
8
|
+
import Flags from "./Flags.js";
|
|
9
|
+
/** The flags accepted by every command of the CLI. **/
|
|
10
|
+
export declare const options: Flags<{
|
|
11
|
+
readonly flow: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly default: "depflow.yml";
|
|
14
|
+
readonly aliases: readonly ["p", "f"];
|
|
15
|
+
readonly description: "Path to the configuration file the command operates on.";
|
|
16
|
+
};
|
|
17
|
+
readonly watch: {
|
|
18
|
+
readonly type: "boolean";
|
|
19
|
+
readonly default: false;
|
|
20
|
+
readonly aliases: readonly ["w"];
|
|
21
|
+
readonly description: "Keeps watching the built files and rewrites their paths on every change.";
|
|
22
|
+
};
|
|
23
|
+
readonly cdn: {
|
|
24
|
+
readonly type: "boolean";
|
|
25
|
+
readonly default: false;
|
|
26
|
+
readonly description: "Resolves the dependency paths to their CDN target instead of their local one.";
|
|
27
|
+
};
|
|
28
|
+
readonly verbose: {
|
|
29
|
+
readonly type: "boolean";
|
|
30
|
+
readonly default: false;
|
|
31
|
+
readonly aliases: readonly ["v"];
|
|
32
|
+
readonly description: "Streams the output of every command as it runs, attributed to the command that wrote it, instead of only reporting how each of them ended. The indentation of that output is lost, and the complete buffer of every command reaches the evidence file whether this flag is given or not.";
|
|
33
|
+
};
|
|
34
|
+
readonly silent: {
|
|
35
|
+
readonly type: "boolean";
|
|
36
|
+
readonly default: false;
|
|
37
|
+
readonly description: "Says only what failed, one line per failed command. It silences the progress of DepFlow itself, such as \"Installing dependencies...\", and not the help, which belongs to the console interface. The exit status and the evidence file are the same as in any other mode.";
|
|
38
|
+
};
|
|
39
|
+
readonly decorate: {
|
|
40
|
+
readonly type: "boolean";
|
|
41
|
+
readonly default: true;
|
|
42
|
+
readonly description: "Draws boxes, indentation, timestamps, levels and names around what is reported. --decorate=false leaves the content alone and keeps the color of the markers and the diagnostics, which carry information and are not decoration.";
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
45
|
+
export declare class DepFlowCLI extends CLI {
|
|
46
|
+
readonly configPath: string;
|
|
47
|
+
protected readonly projectRoot: string;
|
|
48
|
+
constructor(configPath?: string);
|
|
49
|
+
/** Absolute path of the flow directory (`.depflow`) under the project root. **/
|
|
50
|
+
protected get flowDirectory(): string;
|
|
51
|
+
/**
|
|
52
|
+
* The policy the run is presented through, built for the mode the flags asked for.
|
|
53
|
+
* @param flags - The flags of the command being run.
|
|
54
|
+
* @returns The policy of the run, never `null`: the evidence is written whether it is asked for or not.
|
|
55
|
+
*
|
|
56
|
+
* @remarks The policy is also what settles the channel the lifecycle of the CLI is reported through, so
|
|
57
|
+
* every command asks for it first and reports through `policy.report`: a `silent` run that said
|
|
58
|
+
* "Installing dependencies..." would not be silent, and an undecorated run would still draw boxes
|
|
59
|
+
* around lines that carry nothing but what they say.
|
|
60
|
+
*
|
|
61
|
+
* @remarks A command reports through the policy and not through `this.out`, which belongs to the
|
|
62
|
+
* console interface DepFlow was built on: the help, the prompt and the verdict of an invocation are
|
|
63
|
+
* drawn by surfaces DepFlow does not own, and they stay visible in every mode.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const policy = this.policy(flags);
|
|
68
|
+
* const out = policy.report;
|
|
69
|
+
* if (policy.decoration === 'on') out.group(Group.create('#FFB4DC'));
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
protected policy(flags: DepFlowCLI.Options): OutputPolicy;
|
|
73
|
+
commandAdd(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
74
|
+
commandRemove(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
75
|
+
commandInstall(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
76
|
+
commandRun(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
77
|
+
list(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
78
|
+
rewritePaths(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
79
|
+
commandSync(command: string, args: string[], flags?: DepFlowCLI.Options, caller?: OutputPolicy): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Converts the depflow config file between JSON and YAML.
|
|
82
|
+
* @param command - The invoked command name ('json-to-yaml' or 'yaml-to-json').
|
|
83
|
+
* @param args - Optional output file path.
|
|
84
|
+
* @param flags - The flags of the command being run, which settle how the conversion is reported.
|
|
85
|
+
*/
|
|
86
|
+
convert(command: string, args: string[], flags?: DepFlowCLI.Options): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
export declare namespace DepFlowCLI {
|
|
89
|
+
type Exec = (this: DepFlowCLI, command: string, args: string[], flags: Options) => Promise<void> | void;
|
|
90
|
+
/** The values of the flags accepted by the CLI. **/
|
|
91
|
+
type Options = typeof options.infer;
|
|
92
|
+
}
|
|
93
|
+
export default DepFlowCLI;
|