From e40b7d7040182e014c186f99f3bf01d9831341fb Mon Sep 17 00:00:00 2001 From: Vyacheslav Khorkov Date: Sat, 30 Sep 2023 19:10:21 +0500 Subject: [PATCH 1/2] feat: add rugby completion spec --- src/rugby.ts | 764 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 764 insertions(+) create mode 100644 src/rugby.ts diff --git a/src/rugby.ts b/src/rugby.ts new file mode 100644 index 000000000000..f70f1c350b8c --- /dev/null +++ b/src/rugby.ts @@ -0,0 +1,764 @@ +const completionSpec: Fig.Spec = { + description: + "Cache Cocoa ๐ŸŒฑ pods for faster rebuild and indexing Xcode project. https://github.com/swiftyfinch/Rugby", + name: "rugby", + options: [ + { + description: "Show the version", + name: "--version", + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + subcommands: [ + { + description: "Set of base commands combinations", + name: "shortcuts", + icon: "๐Ÿ“", + options: [ + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + subcommands: [ + { + args: { + description: "Any arguments of plan or cache commands", + isOptional: true, + isVariadic: true, + name: "arguments", + }, + description: + "Run the plan command if plans file exists or run the cache command", + name: "umbrella", + icon: "โ›ฑ๏ธ", + options: [ + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Run the build and use commands", + name: "cache", + icon: "๐Ÿˆ", + options: [ + { + description: "Ignore shared cache", + name: "--ignore-cache", + }, + { + description: "Delete target groups from project", + name: "--delete-sources", + }, + { + description: "Restore projects state before the last Rugby usage", + name: ["--rollback", "-r"], + }, + { + args: { + default: "sim", + name: "sdk", + }, + description: "Build SDK: sim or ios", + name: ["--sdk", "-s"], + }, + { + args: { + default: "auto", + name: "arch", + }, + description: "Build architecture: auto, x86_64 or arm64", + name: ["--arch", "-a"], + }, + { + args: { + default: "Debug", + name: "config", + }, + description: "Build configuration", + name: ["--config", "-c"], + }, + { + description: "Build without debug symbols", + name: "--strip", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + args: { + name: "warmup", + }, + description: "Warmup cache with this endpoint", + name: "--warmup", + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + ], + }, + { + description: "Build targets from Pods project", + name: "build", + icon: "๐Ÿ—๏ธ", + options: [ + { + description: "Ignore shared cache", + name: "--ignore-cache", + }, + { + args: { + default: "sim", + name: "sdk", + }, + description: "Build SDK: sim or ios", + name: ["--sdk", "-s"], + }, + { + args: { + default: "auto", + name: "arch", + }, + description: "Build architecture: auto, x86_64 or arm64", + name: ["--arch", "-a"], + }, + { + args: { + default: "Debug", + name: "config", + }, + description: "Build configuration", + name: ["--config", "-c"], + }, + { + description: "Build without debug symbols", + name: "--strip", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Use already built binaries instead of sources", + name: "use", + icon: "๐ŸŽฏ", + options: [ + { + description: "Delete target groups from project", + name: "--delete-sources", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + description: "Build without debug symbols", + name: "--strip", + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Delete targets from the project", + name: "delete", + icon: "๐Ÿ—‘๏ธ", + options: [ + { + args: { + default: "Pods/Pods.xcodeproj", + name: "path", + }, + description: "Project location", + name: ["--path", "-p"], + }, + { + description: "Keep dependencies of excepted targets", + name: "--safe", + }, + { + description: "Delete target groups from project", + name: "--delete-sources", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + args: { + description: + "Endpoint for your binaries storage (s3.eu-west-2.amazonaws.com)", + isOptional: true, + name: "endpoint", + }, + description: "Download remote binaries for targets from Pods project", + name: "warmup", + icon: "๐Ÿณ", + options: [ + { + description: + "Run only in analyse mode without downloading. The endpoint is optional", + name: "--analyse", + }, + { + args: { + default: "sim", + name: "sdk", + }, + description: "Build SDK: sim or ios", + name: ["--sdk", "-s"], + }, + { + args: { + default: "auto", + name: "arch", + }, + description: "Build architecture: auto, x86_64 or arm64", + name: ["--arch", "-a"], + }, + { + args: { + default: "Debug", + name: "config", + }, + description: "Build configuration", + name: ["--config", "-c"], + }, + { + description: "Build without debug symbols", + name: "--strip", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + args: { + default: "60", + name: "timeout", + }, + description: "Timeout for requests in seconds", + name: "--timeout", + }, + { + args: { + default: "10", + name: "max-connections", + }, + description: "The maximum number of simultaneous connections", + name: "--max-connections", + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Restore projects state before the last Rugby usage", + name: "rollback", + icon: "โ™ป๏ธ", + options: [ + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + args: { + description: "Name of plan to run", + isOptional: true, + name: "name", + }, + description: "Run sequence of Rugby commands", + name: "plan", + icon: "โœˆ๏ธ", + options: [ + { + args: { + default: ".rugby/plans.yml", + name: "path", + }, + description: "Path to plans yaml", + name: ["--path", "-p"], + }, + { + description: "Restore projects state before the last Rugby usage", + name: ["--rollback", "-r"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Clear modules cache", + name: "clear", + icon: "๐Ÿงผ", + options: [ + { + args: { + name: "modules", + }, + description: "List of modules for deletion", + isRepeatable: true, + name: ["--modules", "-m"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + subcommands: [ + { + description: "Delete .rugby/build folder", + name: "build", + icon: "๐Ÿงผ", + options: [ + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Delete .rugby/bin folder", + name: "shared", + icon: "๐Ÿงผ", + options: [ + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + ], + }, + { + description: "Update Rugby version", + name: "update", + icon: "๐Ÿ“ฆ", + options: [ + { + args: { + default: "latest", + name: "version", + }, + description: "Version, like 2.0.0", + name: "--version", + }, + { + args: { + name: "arch", + }, + description: "Binary architecture: x86_64 or arm64", + name: ["--arch", "-a"], + }, + { + description: "Allow install the latest pre-release version", + name: "--beta", + }, + { + description: "Force an install even if Rugby is already installed", + name: ["--force", "-f"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + subcommands: [ + { + description: "List of available versions", + name: "list", + options: [ + { + args: { + default: "5", + name: "count", + }, + description: "Maximum versions count", + name: "--count", + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + ], + }, + { + description: "Heal your wounds after using Rugby (or not)", + name: "doctor", + icon: "๐Ÿš‘", + options: [ + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + args: { + description: "Shell script command", + name: "command", + }, + description: "Run shell command from Rugby", + name: "shell", + icon: "๐Ÿš", + options: [ + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + { + description: "Print Rugby environment", + name: "env", + icon: "๐ŸŒ", + options: [ + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, + ], +}; +export default completionSpec; From 7b5dd490264676ea61097c679d7363ca1950e063 Mon Sep 17 00:00:00 2001 From: Vyacheslav Khorkov Date: Sun, 1 Oct 2023 23:06:00 +0500 Subject: [PATCH 2/2] Add dynamic umbrella spec and plans generator --- src/rugby.ts | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) diff --git a/src/rugby.ts b/src/rugby.ts index f70f1c350b8c..83e40e7ec754 100644 --- a/src/rugby.ts +++ b/src/rugby.ts @@ -1,7 +1,79 @@ +// Print plans list if there is .rugby/plans.yml file +const planList: Fig.Generator = { + script: "rugby plan list", + postProcess: (output) => { + if (output === "") { + return []; + } + return output.split("\n").map((plan) => { + return { + name: plan, + description: `Run plan \"${plan}\"`, + icon: "โœˆ๏ธ", + priority: 77, + }; + }); + }, +}; + const completionSpec: Fig.Spec = { description: "Cache Cocoa ๐ŸŒฑ pods for faster rebuild and indexing Xcode project. https://github.com/swiftyfinch/Rugby", name: "rugby", + generateSpec: async (tokens, executeShellCommand) => { + const output = await executeShellCommand("rugby plan list"); + if (output === "") { + return null; + } + // Handle `rugby umbrella` command + return { + name: "plan", + subcommands: output.split("\n").map((plan) => { + return { + name: plan, + description: `Run plan \"${plan}\"`, + icon: "โœˆ๏ธ", + priority: 77, + options: [ + { + args: { + default: ".rugby/plans.yml", + name: "path", + }, + description: "Path to plans yaml", + name: ["--path", "-p"], + }, + { + description: "Restore projects state before the last Rugby usage", + name: ["--rollback", "-r"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }; + }), + }; + }, + args: { + description: "Name of plan to run", + isOptional: true, + name: "name", + }, options: [ { description: "Show the version", @@ -13,6 +85,110 @@ const completionSpec: Fig.Spec = { }, ], subcommands: [ + { + description: "Run the build and use commands", + name: "cache", + priority: 76, + icon: "๐Ÿˆ", + options: [ + { + description: "Ignore shared cache", + name: "--ignore-cache", + }, + { + description: "Delete target groups from project", + name: "--delete-sources", + }, + { + description: "Restore projects state before the last Rugby usage", + name: ["--rollback", "-r"], + }, + { + args: { + default: "sim", + name: "sdk", + }, + description: "Build SDK: sim or ios", + name: ["--sdk", "-s"], + }, + { + args: { + default: "auto", + name: "arch", + }, + description: "Build architecture: auto, x86_64 or arm64", + name: ["--arch", "-a"], + }, + { + args: { + default: "Debug", + name: "config", + }, + description: "Build configuration", + name: ["--config", "-c"], + }, + { + description: "Build without debug symbols", + name: "--strip", + }, + { + args: { + name: "targets", + }, + description: "Targets for building. Empty means all targets", + isRepeatable: true, + name: ["--targets", "-t"], + }, + { + args: { + name: "targets-as-regex", + }, + description: "Targets for building as a RegEx pattern", + isRepeatable: true, + name: ["--targets-as-regex", "-g"], + }, + { + args: { + name: "except", + }, + description: "Exclude targets from building", + isRepeatable: true, + name: ["--except", "-e"], + }, + { + args: { + name: "except-as-regex", + }, + description: "Exclude targets from building as a RegEx pattern", + isRepeatable: true, + name: ["--except-as-regex", "-x"], + }, + { + args: { + default: "fold", + name: "output", + }, + description: "Output mode: fold, multiline, quiet", + name: ["--output", "-o"], + }, + { + description: "Log level", + isRepeatable: true, + name: ["--verbose", "-v"], + }, + { + args: { + name: "warmup", + }, + description: "Warmup cache with this endpoint", + name: "--warmup", + }, + { + description: "Show help information", + name: ["--help", "-h"], + }, + ], + }, { description: "Set of base commands combinations", name: "shortcuts", @@ -511,6 +687,7 @@ const completionSpec: Fig.Spec = { description: "Name of plan to run", isOptional: true, name: "name", + generators: planList, }, description: "Run sequence of Rugby commands", name: "plan",