@travetto/cli 3.0.0-rc.2 → 3.0.0-rc.5

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/src/help.ts CHANGED
@@ -1,6 +1,79 @@
1
- import * as commander from 'commander';
1
+ import type * as commander from 'commander';
2
+
3
+ import { cliTpl } from './color';
4
+
5
+ const TYPE_PATTERN = /(\[[^\]]+\])/g;
6
+ const TITLE_PATTERN = /^(\S[^:]+:)/gim;
7
+
8
+ const OPTIONS_PATTERN = new RegExp([
9
+ '^',
10
+ '(?<space>[ ]+)',
11
+ '(?<shortName>-[^, ]+)',
12
+ '(?<paramSpace>,?[ ]*)?',
13
+ '(?<longName>--\\S+)?',
14
+ '((?<typeSpace>[ ]+)?(?<type>(?:\\[[^\\]]+\\])|(?:[<][^>]+[>])))?',
15
+ '((?<descriptionSpace>[ ]+)(?<description>.*?))?',
16
+ '((?<defaultPre>[ ]*[(])(?<defaultKey>default)(?<defaultSpace>: )(?<defaultValue>[^)]+)(?<defaultPost>[)]))?',
17
+ '(?:[ ]+)?',
18
+ '$',
19
+ ].join(''), 'gim');
20
+
21
+ type OptionsGroup = {
22
+ space: string; shortName: string;
23
+ paramSpace?: string; longName?: string;
24
+ typeSpace?: string; type?: string;
25
+ descriptionSpace?: string;
26
+ description?: string;
27
+ defaultPre?: string; defaultKey?: string; defaultSpace?: string; defaultValue?: string; defaultPost?: string;
28
+ };
29
+
30
+ const COMMANDS_PATTERN = new RegExp([
31
+ '^',
32
+ '(?<space>[ ]+)',
33
+ '(?<name>\\S+)',
34
+ '(?<optionsSpace>[ ]+)?',
35
+ '(?<options>\\[.*\\])?',
36
+ '((?<descriptionSpace>[ ]+)(?<description>[a-z][^\\n\\[]+))?',
37
+ '(?:[ ]+)?',
38
+ '$',
39
+ ].join(''), 'gim');
40
+
41
+ type CommandGroup = {
42
+ space: string; name: string;
43
+ optionsSpace?: string; options?: string;
44
+ descriptionSpace?: string; description?: string;
45
+ };
46
+
47
+ const USAGE_PATTERN = new RegExp([
48
+ '^',
49
+ '(?<title>Usage:)',
50
+ '(?<space>[ ]+)?',
51
+ '(?<name>[^\\[ ]+)?',
52
+ '(?<nameSpace>[ ]+)?',
53
+ '(?<options>\\[.*\\])?',
54
+ '(?:[ ]+)?',
55
+ '$',
56
+ ].join(''), 'gim');
57
+
58
+ type UsageGroup = {
59
+ title: string; space?: string;
60
+ name?: string; nameSpace?: string;
61
+ options?: string;
62
+ };
63
+
64
+ function namedReplace<T>(text: string, pattern: RegExp, replacer: (data: T) => (string | (string | undefined)[])): string {
65
+ return text.replace(pattern, (...args: unknown[]): string => {
66
+ const groups = args[args.length - 1];
67
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
68
+ const res = replacer(groups as T);
69
+ if (typeof res === 'string') {
70
+ return res;
71
+ } else {
72
+ return res.filter(x => !!x).join('');
73
+ }
74
+ });
75
+ }
2
76
 
3
- import { color } from './color';
4
77
  /**
5
78
  * Utilities for formatting help
6
79
  */
@@ -29,48 +102,60 @@ export class HelpUtil {
29
102
  * Colorize Usage
30
103
  */
31
104
  static colorizeOptions(option: string): string {
32
- return option.replace(/(\s*)(-[^, ]+)(,?\s*)(--\S+)?((\s+)?((?:\[[^\]]+\])|(?:\<[^>]+>)))?((\s+)(.*))?/g, (
33
- p: string, spacing: string,
34
- simpleParam: string, pSep: string,
35
- fullParam: string, sub: string,
36
- subSp: string, subVal: string,
37
- desc: string, descSp: string,
38
- descVal: string
39
- ) => {
40
- const line: string[] = [];
41
- line.push(
42
- spacing,
43
- color`${{ param: simpleParam }}`,
44
- pSep,
45
- color`${{ param: fullParam }}`,
46
- subSp,
47
- color`${{ type: subVal }}`,
48
- descSp,
49
- color`${{ description: descVal }}`
50
- .replace(/(\(default:\s+)(.*?)(\))/g,
51
- (__, l, input, r) => color`${l}${{ input }}${{ description: r }}`)
52
- );
53
-
54
- return line.filter(x => !!x).join('');
55
- })
56
- .replace(/Options:/, title => color`${{ title }}`);
105
+ return namedReplace<OptionsGroup>(option, OPTIONS_PATTERN,
106
+ ({
107
+ space, shortName, paramSpace, longName, typeSpace, type, descriptionSpace, description,
108
+ defaultPre, defaultKey, defaultSpace, defaultValue, defaultPost
109
+ }) =>
110
+ [
111
+ space,
112
+ cliTpl`${{ param: shortName }}`,
113
+ paramSpace,
114
+ cliTpl`${{ param: longName }}`,
115
+ typeSpace,
116
+ cliTpl`${{ type }}`,
117
+ descriptionSpace,
118
+ cliTpl`${{ description }}`,
119
+ defaultPre,
120
+ cliTpl`${{ description: defaultKey }}`,
121
+ defaultSpace,
122
+ cliTpl`${{ input: defaultValue }}`,
123
+ defaultPost
124
+ ]
125
+ )
126
+ .replace(TITLE_PATTERN, title => cliTpl`${{ title }}`);
57
127
  }
58
128
 
59
129
  /**
60
130
  * Colorize command section
61
131
  */
62
132
  static colorizeCommands(commands: string): string {
63
- return commands
64
- .replace(/\s([^\[\]]\S+)/g, param => color`${{ param }}`)
65
- .replace(/(\s*[^\x1b]\[[^\]]+\])/g, input => color`${{ input }}`) // eslint-disable-line no-control-regex
66
- .replace(/Commands:/, title => color`${{ title }}`);
133
+ return namedReplace<CommandGroup>(commands, COMMANDS_PATTERN,
134
+ ({ space, name, optionsSpace, options, descriptionSpace, description }) => [
135
+ space,
136
+ cliTpl`${{ param: name }}`,
137
+ optionsSpace,
138
+ options?.replace(TYPE_PATTERN, input => cliTpl`${{ input }}`),
139
+ descriptionSpace,
140
+ cliTpl`${{ description }}`
141
+ ]
142
+ )
143
+ .replace(TITLE_PATTERN, title => cliTpl`${{ title }}`);
67
144
  }
68
145
 
69
146
  /**
70
147
  * Colorize usage
71
148
  */
72
149
  static colorizeUsage(usage: string): string {
73
- return usage.replace(/Usage:/, title => color`${{ title }}`);
150
+ return namedReplace<UsageGroup>(usage, USAGE_PATTERN,
151
+ ({ title, space, name, nameSpace, options }) => [
152
+ cliTpl`${{ title }}`,
153
+ space,
154
+ cliTpl`${{ param: name }}`,
155
+ nameSpace,
156
+ options?.replace(TYPE_PATTERN, input => cliTpl`${{ input }}`),
157
+ ]
158
+ );
74
159
  }
75
160
 
76
161
  /**
@@ -97,16 +182,15 @@ export class HelpUtil {
97
182
  /**
98
183
  * Show the help
99
184
  * @param command
100
- * @param message
185
+ * @param failure
101
186
  * @param extra
102
187
  */
103
- static showHelp(command: commander.Command, message?: string, extra?: string): never {
104
- if (message) {
105
- console!.error(color`${{ failure: message }}\n`);
188
+ static showHelp(command: commander.Command, failure?: string, extra?: string): void {
189
+ if (failure) {
190
+ console!.error(cliTpl`${{ failure }}\n`);
106
191
  }
107
- console![message ? 'error' : 'log'](
192
+ console![failure ? 'error' : 'log'](
108
193
  HelpUtil.getHelpText(command.helpInformation(), extra)
109
194
  );
110
- process.exit(message ? 1 : 0);
111
195
  }
112
196
  }
package/src/module.ts ADDED
@@ -0,0 +1,185 @@
1
+ import { ColorDefineUtil, NAMED_COLORS, Terminal, GlobalTerminal, TermLinePosition } from '@travetto/terminal';
2
+ import { Env, ExecutionOptions, ExecutionResult, ExecutionState, TypedObject } from '@travetto/base';
3
+ import { IndexedModule, PackageUtil, RootIndex } from '@travetto/manifest';
4
+ import { IterableWorkSet, WorkPool, type Worker } from '@travetto/worker';
5
+
6
+ import { CliScmUtil } from './scm';
7
+
8
+ type ModuleRunConfig<T = ExecutionResult> = {
9
+ progressMessage?: (mod: IndexedModule | undefined) => string;
10
+ filter?: (mod: IndexedModule) => boolean | Promise<boolean>;
11
+ transformResult?: (mod: IndexedModule, result: ExecutionResult) => T;
12
+ workerCount?: number;
13
+ progressPosition?: TermLinePosition;
14
+ prefixOutput?: boolean;
15
+ showStdout?: boolean;
16
+ showStderr?: boolean;
17
+ };
18
+
19
+ const COLORS = TypedObject.keys(NAMED_COLORS)
20
+ .map(k => [k, ColorDefineUtil.defineColor(k).hsl] as const)
21
+ .filter(([, [, s, l]]) => l > .5 && l < .8 && s > .8)
22
+ .map(([k]) => GlobalTerminal.colorer(k));
23
+
24
+ const colorize = (val: string, idx: number): string => COLORS[idx % COLORS.length](val);
25
+
26
+ /**
27
+ * Simple utilities for understanding modules for CLI use cases
28
+ */
29
+ export class CliModuleUtil {
30
+
31
+ /**
32
+ * Generate execution options for running on modules
33
+ */
34
+ static #buildExecutionOptions<T = ExecutionState>(
35
+ mod: IndexedModule,
36
+ config: ModuleRunConfig<T>,
37
+ prefixes: Record<string, string>,
38
+ stdoutTerm: Terminal,
39
+ stderrTerm: Terminal
40
+ ): ExecutionOptions {
41
+ const folder = mod.workspaceRelative;
42
+ const opts: ExecutionOptions = {
43
+ stdio: ['ignore', 'pipe', 'pipe', 'ignore'],
44
+ outputMode: 'text',
45
+ catchAsResult: true,
46
+ cwd: folder,
47
+ env: { TRV_MANIFEST: '' },
48
+ };
49
+
50
+ if (config.showStdout) {
51
+ opts.onStdOutLine = (line: string): unknown => stdoutTerm.writeLines(`${prefixes[folder] ?? ''}${line}`);
52
+ }
53
+ if (config.showStderr) {
54
+ opts.onStdErrorLine = (line: string): unknown => stderrTerm.writeLines(`${prefixes[folder] ?? ''}${line}`);
55
+ }
56
+ return opts;
57
+ }
58
+
59
+ /**
60
+ * Build equal sized prefix labels for outputting
61
+ * @param mods
62
+ * @returns
63
+ */
64
+ static #buildPrefixes(mods: IndexedModule[]): Record<string, string> {
65
+ const folders = mods.map(x => x.workspaceRelative);
66
+ const maxWidth = Math.max(...folders.map(x => x.length));
67
+ return Object.fromEntries(folders.map((x, i) => [x, colorize(x.padStart(maxWidth, ' ').padEnd(maxWidth + 1), i)]));
68
+ }
69
+
70
+ /**
71
+ * Find modules that changed, and the dependent modules
72
+ * @param hash
73
+ * @param transitive
74
+ * @returns
75
+ */
76
+ static async findChangedModulesRecursive(hash?: string, transitive = true): Promise<IndexedModule[]> {
77
+ if (!hash) {
78
+ hash = await CliScmUtil.findLastRelease();
79
+ }
80
+
81
+ const out = new Map<string, IndexedModule>();
82
+ for (const mod of await CliScmUtil.findChangedModulesSince(hash)) {
83
+ out.set(mod.name, mod);
84
+ if (transitive) {
85
+ for (const sub of await RootIndex.getDependentModules(mod)) {
86
+ out.set(sub.name, sub);
87
+ }
88
+ }
89
+ }
90
+
91
+ return [...out.values()]
92
+ .sort((a, b) => a.name.localeCompare(b.name));
93
+ }
94
+
95
+ /**
96
+ * Find modules that changed, and the dependent modules
97
+ * @param hash
98
+ * @param transitive
99
+ * @returns
100
+ */
101
+ static async findModules(mode: 'all' | 'changed'): Promise<IndexedModule[]> {
102
+ return (mode === 'changed' ?
103
+ await this.findChangedModulesRecursive() :
104
+ [...RootIndex.getModuleList('all')].map(x => RootIndex.getModule(x)!)
105
+ ).filter(x => x.source !== RootIndex.manifest.workspacePath);
106
+ }
107
+
108
+ /**
109
+ * Synchronize all workspace modules to have the correct versions from the current packages
110
+ */
111
+ static async synchronizeModuleVersions(): Promise<void> {
112
+ await PackageUtil.syncVersions((await this.findModules('all')).map(x => x.source));
113
+ }
114
+
115
+ /**
116
+ * Run on all modules
117
+ */
118
+ static async execOnModules<T = ExecutionResult>(
119
+ mode: 'all' | 'changed',
120
+ operation: (mod: IndexedModule, options: ExecutionOptions) => ExecutionState,
121
+ config: ModuleRunConfig<T> = {}
122
+ ): Promise<Map<IndexedModule, T>> {
123
+
124
+ config.showStdout = config.showStdout ?? (Env.isSet('DEBUG') && !Env.isFalse('DEBUG'));
125
+ config.showStderr = config.showStderr ?? true;
126
+
127
+ const workerCount = config.workerCount ?? WorkPool.DEFAULT_SIZE;
128
+
129
+ const mods = await CliModuleUtil.findModules(mode);
130
+ const results = new Map<IndexedModule, T>();
131
+ const processes = new Map<IndexedModule, ExecutionState>();
132
+
133
+ const prefixes = config.prefixOutput !== false ? this.#buildPrefixes(mods) : {};
134
+ const stdoutTerm = await Terminal.for({ output: process.stdout });
135
+ const stderrTerm = await Terminal.for({ output: process.stderr });
136
+
137
+ let id = 1;
138
+ const pool = new WorkPool(async () => {
139
+ const worker: Worker<IndexedModule> & { mod?: IndexedModule } = {
140
+ id: id += 1,
141
+ mod: undefined,
142
+ active: false,
143
+ async destroy() {
144
+ this.active = false;
145
+ processes.get(this.mod!)?.process.kill('SIGKILL');
146
+ },
147
+ async execute(mod: IndexedModule) {
148
+ try {
149
+ this.mod = mod;
150
+ this.active = true;
151
+
152
+ if (await config.filter?.(mod) === false) {
153
+ this.active = false;
154
+ } else {
155
+ const opts = CliModuleUtil.#buildExecutionOptions(mod, config, prefixes, stdoutTerm, stderrTerm);
156
+
157
+ const result = await operation(mod, opts).result;
158
+
159
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
160
+ const output = (config.transformResult ? config.transformResult(mod, result) : result) as T;
161
+ results.set(mod, output);
162
+ }
163
+ } finally {
164
+ this.active = false;
165
+ delete this.mod;
166
+ }
167
+ },
168
+ };
169
+ return worker;
170
+ }, { max: workerCount, min: workerCount });
171
+
172
+ const work = pool.iterateProcess(new IterableWorkSet(mods));
173
+
174
+ if (config.progressMessage) {
175
+ const cfg = { position: config.progressPosition ?? 'bottom' } as const;
176
+ await stdoutTerm.trackProgress(work, ev => ({ ...ev, text: config.progressMessage!(ev.value) }), cfg);
177
+ } else {
178
+ for await (const _ of work) {
179
+ // Ensure its all consumed
180
+ }
181
+ }
182
+
183
+ return results;
184
+ }
185
+ }
package/src/scm.ts ADDED
@@ -0,0 +1,77 @@
1
+ import fs from 'fs/promises';
2
+
3
+ import { Env, ExecUtil } from '@travetto/base';
4
+ import { IndexedModule, RootIndex, path } from '@travetto/manifest';
5
+
6
+ export class CliScmUtil {
7
+ /**
8
+ * See if folder is a repository root
9
+ * @param folder
10
+ * @returns
11
+ */
12
+ static isRepoRoot(folder: string): Promise<boolean> {
13
+ return fs.stat(path.resolve(folder, '.git')).then(() => true, () => false);
14
+ }
15
+
16
+ /**
17
+ * Get author information
18
+ * @returns
19
+ */
20
+ static async getAuthor(): Promise<{ name?: string, email: string }> {
21
+ const [name, email] = await Promise.all([
22
+ await ExecUtil.spawn('git', ['config', 'user.name'], { catchAsResult: true }).result,
23
+ await ExecUtil.spawn('git', ['config', 'user.email']).result,
24
+ ]);
25
+ return {
26
+ name: (name.valid ? name.stdout.trim() : '') || Env.get('USER'),
27
+ email: email.stdout.trim()
28
+ };
29
+ }
30
+
31
+ /**
32
+ * Find the last code release
33
+ * @returns
34
+ */
35
+ static async findLastRelease(): Promise<string> {
36
+ const root = await RootIndex.manifest;
37
+ const { result } = ExecUtil.spawn('git', ['log', '--pretty=oneline'], { cwd: root.workspacePath });
38
+ return (await result).stdout
39
+ .split(/\n/)
40
+ .find(x => /Publish /.test(x))!
41
+ .split(/\s+/)[0]!;
42
+ }
43
+
44
+ /**
45
+ * Find all modules that changed since hash
46
+ * @param hash
47
+ * @returns
48
+ */
49
+ static async findChangedModulesSince(hash: string): Promise<IndexedModule[]> {
50
+ const ws = RootIndex.manifest.workspacePath;
51
+ const res = await ExecUtil.spawn('git', ['diff', '--name-only', `HEAD..${hash}`], { cwd: ws }).result;
52
+ const out = new Set<IndexedModule>();
53
+ for (const line of res.stdout.split(/\n/g)) {
54
+ const mod = RootIndex.getFromSource(path.resolve(ws, line));
55
+ if (mod) {
56
+ out.add(RootIndex.getModule(mod.module)!);
57
+ }
58
+ }
59
+ return [...out].sort((a, b) => a.name.localeCompare(b.name));
60
+ }
61
+
62
+ /**
63
+ * Create a commit
64
+ */
65
+ static createCommit(message: string): Promise<string> {
66
+ return ExecUtil.spawn('git', ['commit', '.', '-m', message]).result.then(r => r.stdout);
67
+ }
68
+
69
+ /**
70
+ * Verify if workspace is dirty
71
+ */
72
+ static async isWorkspaceDirty(): Promise<boolean> {
73
+ const res1 = await ExecUtil.spawn('git', ['diff', '--quiet', '--exit-code'], { catchAsResult: true }).result;
74
+ const res2 = await ExecUtil.spawn('git', ['diff', '--quiet', '--exit-code', '--cached'], { catchAsResult: true }).result;
75
+ return !res1.valid || !res2.valid;
76
+ }
77
+ }
@@ -0,0 +1,53 @@
1
+ import { CliCommand, CliModuleUtil, OptionConfig } from '@travetto/cli';
2
+ import { WorkPool } from '@travetto/worker';
3
+ import { RootIndex } from '@travetto/manifest';
4
+ import { ExecUtil, GlobalEnvConfig } from '@travetto/base';
5
+
6
+ type Options = {
7
+ changed: OptionConfig<boolean>;
8
+ workers: OptionConfig<number>;
9
+ prefixOutput: OptionConfig<boolean>;
10
+ showStdout: OptionConfig<boolean>;
11
+ };
12
+
13
+ /**
14
+ * Repo execution
15
+ */
16
+ export class RepoExecCommand extends CliCommand<Options> {
17
+ name = 'exec';
18
+
19
+ isActive(): boolean {
20
+ return !!RootIndex.manifest.monoRepo;
21
+ }
22
+
23
+ getOptions(): Options {
24
+ return {
25
+ changed: this.boolOption({ desc: 'Only changed modules', def: true }),
26
+ workers: this.option({ desc: 'Number of concurrent workers', def: WorkPool.DEFAULT_SIZE }),
27
+ prefixOutput: this.boolOption({ desc: 'Prefix output by folder', def: true }),
28
+ showStdout: this.boolOption({ desc: 'Show stdout', def: true })
29
+ };
30
+ }
31
+
32
+ getArgs(): string {
33
+ return '[command] [...args]';
34
+ }
35
+
36
+ envInit(): GlobalEnvConfig {
37
+ return { debug: false };
38
+ }
39
+
40
+ async action(): Promise<void> {
41
+ await CliModuleUtil.execOnModules(
42
+ this.cmd.changed ? 'changed' : 'all',
43
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
44
+ (mod, opts) => ExecUtil.spawn(this.args[0], this.args.slice(1), opts),
45
+ {
46
+ progressMessage: mod => `Running '${this.args.join(' ')}' [%idx/%total] ${mod?.workspaceRelative ?? ''}`,
47
+ showStdout: this.cmd.showStdout,
48
+ prefixOutput: this.cmd.prefixOutput,
49
+ workerCount: this.cmd.workers,
50
+ }
51
+ );
52
+ }
53
+ }
@@ -0,0 +1,47 @@
1
+ import { CliCommand, CliModuleUtil, OptionConfig } from '@travetto/cli';
2
+ import { RootIndex } from '@travetto/manifest';
3
+
4
+ type Options = {
5
+ changed: OptionConfig<boolean>;
6
+ graph: OptionConfig<boolean>;
7
+ };
8
+
9
+ /**
10
+ * `npx trv list`
11
+ *
12
+ * Allows for listing of modules
13
+ */
14
+ export class RepoListCommand extends CliCommand<Options> {
15
+
16
+ name = 'list';
17
+
18
+ isActive(): boolean {
19
+ return !!RootIndex.manifest.monoRepo;
20
+ }
21
+
22
+ getOptions(): Options {
23
+ return {
24
+ changed: this.boolOption({ desc: 'Only show changed modules', def: false }),
25
+ graph: this.boolOption({ desc: 'Show as a digraph', def: false })
26
+ };
27
+ }
28
+
29
+ async action(...args: unknown[]): Promise<void> {
30
+ const mods = await CliModuleUtil.findModules(this.cmd.changed ? 'changed' : 'all');
31
+ if (!this.cmd.graph) {
32
+ for (const mod of mods.map(x => x.workspaceRelative).sort()) {
33
+ console.log!(mod);
34
+ }
35
+ } else {
36
+ console.log!('digraph g {');
37
+ for (const el of mods) {
38
+ for (const dep of el.parents) {
39
+ if (dep !== RootIndex.mainPackage.name) {
40
+ console.log!(` "${dep}" -> "${el.name}";`);
41
+ }
42
+ }
43
+ }
44
+ console.log!('}');
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,17 @@
1
+ import { CliCommand, CliModuleUtil } from '@travetto/cli';
2
+ import { RootIndex } from '@travetto/manifest';
3
+
4
+ /**
5
+ * Enforces all packages to write out their versions and dependencies
6
+ */
7
+ export class VersionSyncCommand extends CliCommand {
8
+ name = 'version-sync';
9
+
10
+ isActive(): boolean {
11
+ return !!RootIndex.manifest.monoRepo;
12
+ }
13
+
14
+ async action(): Promise<void> {
15
+ await CliModuleUtil.synchronizeModuleVersions();
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ import { ExecutionManager } from '@travetto/cli';
2
+
3
+ /**
4
+ * Entry point
5
+ */
6
+ export async function main(): Promise<void> {
7
+ return ExecutionManager.run(process.argv); // Run cli
8
+ }
@@ -1,18 +0,0 @@
1
- # Bash Autocompletion
2
- _travetto()
3
- {
4
- local trv="${PWD}/node_modules/.bin/trv";
5
- local cur=${COMP_WORDS[COMP_CWORD]}
6
- if [ -f "$trv" ]; then
7
- local words=`${trv} complete ${COMP_WORDS[@]:1}`
8
- if [[ -z "$words" ]]; then
9
- COMPREPLY=( )
10
- else
11
- COMPREPLY=( $(compgen -W "$words" -- $cur) )
12
- fi
13
- else
14
- COMPREPLY=( )
15
- fi
16
- }
17
- complete -o default -F _travetto travetto
18
- complete -o default -F _travetto trv
package/bin/cli.ts DELETED
@@ -1,28 +0,0 @@
1
- import { PathUtil } from '@travetto/boot/src/path';
2
- import { ModuleManager } from '@travetto/boot/src/internal/module';
3
- import { SourceIndex } from '@travetto/boot/src/internal/source';
4
- import { EnvUtil } from '@travetto/boot';
5
-
6
- /**
7
- * Entry point
8
- */
9
- export async function main(): Promise<void> {
10
- if (!EnvUtil.isFalse('TRV_CLI_LOCAL') && !PathUtil.toUnix(__filename).includes(PathUtil.cwd)) { // If the current file is not under the working directory
11
- console.error(`
12
- The @travetto/cli is not intended to be installed globally. Please install it within your local project
13
-
14
- npm i --save-dev @travetto/cli
15
-
16
- and invoke it locally using
17
-
18
- npx trv
19
- `);
20
- process.exit(1);
21
- }
22
-
23
- // Compile CLI for usage
24
- ModuleManager.transpileAll(SourceIndex.find({ folder: 'bin' }));
25
-
26
- const { ExecutionManager } = await import('@travetto/cli/src/execute');
27
- return ExecutionManager.run(process.argv); // Run cli
28
- }
package/bin/trv.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- require('@travetto/boot/bin/register');
3
- require('@travetto/cli/bin/cli').main();
package/src/types.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Completion interface
3
- */
4
- export interface CompletionConfig {
5
- /**
6
- * All top level commands
7
- */
8
- all: string[];
9
- /**
10
- * Flags for sub tasks
11
- */
12
- task: {
13
- [key: string]: {
14
- [key: string]: string[];
15
- };
16
- };
17
- }