mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-27 09:36:04 -05:00
commit
fa688a5253
5 changed files with 54 additions and 8 deletions
|
@ -108,10 +108,7 @@ export class ArgvService {
|
||||||
const finalCommandNameSet: Set<string> = new Set<string>(finalCommands.map((x) => x.name));
|
const finalCommandNameSet: Set<string> = new Set<string>(finalCommands.map((x) => x.name));
|
||||||
const userInputCmdName: string = argv._[1] || '';
|
const userInputCmdName: string = argv._[1] || '';
|
||||||
|
|
||||||
if (current.includes('sparo')) {
|
if (finalCommandNameSet.has(userInputCmdName)) {
|
||||||
// top level completion
|
|
||||||
done(finalCommands.map(({ name, description }) => `${name}:${description}`));
|
|
||||||
} else if (finalCommandNameSet.has(userInputCmdName)) {
|
|
||||||
switch (current) {
|
switch (current) {
|
||||||
case 'add': {
|
case 'add': {
|
||||||
done(this._getFileCompletions());
|
done(this._getFileCompletions());
|
||||||
|
@ -159,14 +156,14 @@ export class ArgvService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (current) {
|
} else {
|
||||||
|
const prefix: string = current === 'sparo' ? '' : current;
|
||||||
done(
|
done(
|
||||||
finalCommands
|
finalCommands
|
||||||
.filter(({ name }) => name.startsWith(current))
|
.filter(({ name }) => name.startsWith(prefix))
|
||||||
.map(({ name, description }) => `${name}:${description}`)
|
.map(({ name, description }) => `${name}:${description}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
done([]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private _getFileCompletions(partial: string = ''): string[] {
|
private _getFileCompletions(partial: string = ''): string[] {
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
const { spawnSync } = require('child_process');
|
const { spawnSync } = require('child_process');
|
||||||
|
|
||||||
function runCommand(command, args) {
|
function runCommand(command, args) {
|
||||||
const result = spawnSync(command, args, { stdio: 'inherit', shell: true });
|
const result = spawnSync(command, args, {
|
||||||
|
stdio: 'inherit',
|
||||||
|
shell: true,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
// Suppress the "Browserslist: caniuse-lite is outdated" warning. Although the warning is
|
||||||
|
// potentially useful, the check is performed in a way that is nondeterministic and can cause
|
||||||
|
// Rush pipelines to fail. Moreover, the outdated version is often irrelevant and/or nontrivial
|
||||||
|
// to upgrade. See this thread for details: https://github.com/microsoft/rushstack/issues/2981
|
||||||
|
BROWSERSLIST_IGNORE_OLD_DATA: '1'
|
||||||
|
}
|
||||||
|
});
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
console.log(result.error.message);
|
console.log(result.error.message);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
Running "sparo --get-yargs-completions sparo ":
|
||||||
|
auto-config:Automatic setup optimized git config
|
||||||
|
list-profiles:List all available profiles or query profiles that contain the specified project name
|
||||||
|
init-profile:Initialize a new profile.
|
||||||
|
clone:Clone a repository into a new directory
|
||||||
|
checkout:Updates files in the working tree to match the version in the index or the specified tree. If no pathspec was given, git checkout will also update HEAD to set the specified branch as the current branch.
|
||||||
|
fetch:fetch remote branch to local
|
||||||
|
pull:Incorporates changes from a remote repository into the current branch.
|
||||||
|
git-clone:original git clone command
|
||||||
|
git-checkout:original git checkout command
|
||||||
|
git-fetch:original git fetch command
|
||||||
|
git-pull:original git pull command
|
||||||
|
add:add file contents to the index
|
||||||
|
branch:list, create, or delete branches
|
||||||
|
commit:record changes to the repository
|
||||||
|
diff:show changes between commits, commit and working tree, etc
|
||||||
|
log:show commit logs
|
||||||
|
merge:join two or more development histories together
|
||||||
|
push:update remote refs along with associated objects
|
||||||
|
rebase:forward-port local commits to the updated upstream head
|
||||||
|
reset:reset current HEAD to the specified state
|
||||||
|
restore:restore working tree files
|
||||||
|
status:show the working tree status
|
|
@ -25,6 +25,11 @@ export async function runAsync(runScriptOptions: IRunScriptOptions): Promise<voi
|
||||||
name: 'sparo-top-level-completion',
|
name: 'sparo-top-level-completion',
|
||||||
args: prefixArgs.concat([])
|
args: prefixArgs.concat([])
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
kind: 'sparo-command',
|
||||||
|
name: 'sparo-top-level-2-completion',
|
||||||
|
args: prefixArgs.concat([''])
|
||||||
|
},
|
||||||
// auto-config
|
// auto-config
|
||||||
{
|
{
|
||||||
kind: 'sparo-command',
|
kind: 'sparo-command',
|
||||||
|
|
10
common/changes/sparo/fix-completion_2024-08-27-05-07.json
Normal file
10
common/changes/sparo/fix-completion_2024-08-27-05-07.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"packageName": "sparo",
|
||||||
|
"comment": "Fix an edge case for shell completion",
|
||||||
|
"type": "none"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packageName": "sparo"
|
||||||
|
}
|
Loading…
Reference in a new issue