From 8a9f2095bfd64a2ad52577eb0ba04d21693362de Mon Sep 17 00:00:00 2001 From: Michael Yan Date: Tue, 27 Feb 2024 16:16:02 +0800 Subject: [PATCH] Grace: update profile and commands --- .../groovy/grails/build/logging/GrailsConsole.java | 2 +- .../src/main/groovy/org/grails/cli/GrailsCli.groovy | 6 +++--- .../org/grails/cli/profile/AbstractProfile.groovy | 2 +- .../grails/cli/profile/commands/HelpCommand.groovy | 8 ++++---- .../cli/profile/commands/ListProfilesCommand.groovy | 11 ++++++----- .../cli/profile/commands/ProfileInfoCommand.groovy | 8 ++++---- .../repository/AbstractJarProfileRepository.groovy | 2 +- .../profile/repository/MavenProfileRepository.groovy | 6 +++--- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/grace-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java b/grace-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java index b56d6c5cbf..8e92ff49e1 100644 --- a/grace-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java +++ b/grace-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java @@ -70,7 +70,7 @@ public class GrailsConsole implements ConsoleLogger { public static final String CATEGORY_SEPARATOR = "|"; - public static final String PROMPT = "grails> "; + public static final String PROMPT = "grace> "; public static final String SPACE = " "; diff --git a/grace-shell/src/main/groovy/org/grails/cli/GrailsCli.groovy b/grace-shell/src/main/groovy/org/grails/cli/GrailsCli.groovy index f331a6e07e..a5663d4641 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/GrailsCli.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/GrailsCli.groovy @@ -183,7 +183,7 @@ class GrailsCli { } catch (Throwable e) { e = ExceptionUtils.getRootCause(e) - GrailsConsole.instance.error("Error occurred running Grails CLI: $e.message", e) + GrailsConsole.instance.error("Error occurred running Grace CLI: $e.message", e) exit(1) } } @@ -203,7 +203,7 @@ class GrailsCli { private int getBaseUsage() { System.out.println "Usage: \n\t $USAGE_MESSAGE \n\t $PLUGIN_USAGE_MESSAGE \n\n" this.execute 'list-profiles' - System.out.println "\nType 'grails help' or 'grails -h' for more information." + System.out.println "\nType 'grace help' or 'grails -h' for more information." 1 } @@ -229,7 +229,7 @@ class GrailsCli { GrailsVersion currentVersion = GrailsVersion.current() GrailsDependenciesDependencyManagement grailsDependencies = new GrailsDependenciesDependencyManagement() StringBuilder sb = new StringBuilder() - sb.append('%n------------------------------------------------------------%nGrails ') + sb.append('%n------------------------------------------------------------%nGrace ') sb.append(currentVersion.getVersion()) sb.append('%n------------------------------------------------------------%n%nBuild time: ') sb.append(currentVersion.getBuildTimestamp()) diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy index 686c668220..3ff64089c7 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy @@ -481,7 +481,7 @@ abstract class AbstractProfile implements Profile { int requiredArgumentCount = requiredArguments?.findAll { CommandArgument ca -> ca.required }?.size() ?: 0 if (commandLine.remainingArgs.size() < requiredArgumentCount) { context.console.error "Command [$commandName] missing required arguments: ${requiredArguments*.name}. " + - "Type 'grails help $commandName' for more info." + "Type 'grace help $commandName' for more info." return false } diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/HelpCommand.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/HelpCommand.groovy index c501f5e46c..4d96422bca 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/HelpCommand.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/HelpCommand.groovy @@ -96,14 +96,14 @@ class HelpCommand implements ProfileCommand, Completer, ProjectContextAware, Pro console.log ''' Usage (optionals marked with *):' -grails [environment]* [target] [arguments]*' +grace [environment]* [target] [arguments]*' ''' console.addStatus('Examples:') - console.log('$ grails dev run-app') - console.log('$ grails create-app books') + console.log('$ grace create-app blog') + console.log('$ grace dev run-app') console.log '' - console.addStatus('Available Commands (type grails help \'command-name\' for more info):') + console.addStatus('Available Commands (type grace help \'command-name\' for more info):') console.addStatus("${'Command Name'.padRight(37)} Command Description") console.println('-' * 100) for (CommandDescription desc : allCommands) { diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ListProfilesCommand.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ListProfilesCommand.groovy index 59ef2f00ac..0a1d090a3d 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ListProfilesCommand.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ListProfilesCommand.groovy @@ -36,18 +36,19 @@ import org.grails.cli.profile.ProfileRepositoryAware class ListProfilesCommand implements Command, ProfileRepositoryAware { final String name = 'list-profiles' - final CommandDescription description = new CommandDescription(name, 'Lists the available profiles', 'grails list-profiles') + final CommandDescription description = new CommandDescription(name, 'Lists the available profiles', 'grace list-profiles') ProfileRepository profileRepository @Override boolean handle(ExecutionContext executionContext) { - List allProfiles = profileRepository.allProfiles + List allProfiles = profileRepository.allProfiles.sort { Profile p -> p.name} GrailsConsole console = executionContext.console - console.addStatus('Available Profiles') - console.log('--------------------') + console.log('-' * 100) + console.log('Available Profiles') + console.log('-' * 100) for (Profile p in allProfiles) { - console.log("* $p.name - ${p.description}") + console.log("* ${p.name.padRight(30)} ${p.version.padRight(20)} ${p.description}") } true diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ProfileInfoCommand.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ProfileInfoCommand.groovy index f3902237c6..ea5e1b2d2a 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ProfileInfoCommand.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/commands/ProfileInfoCommand.groovy @@ -69,12 +69,12 @@ class ProfileInfoCommand extends ArgumentCompletingCommand implements ProfileRep console.error("Profile not found for name [$profileName]") } else { - console.log("Profile: ${profile.name}") - console.log('--------------------') + console.log("Profile: ${profile.name} v${profile.version}") + console.log('-' * 40) console.log(profile.description) console.log('') console.log('Provided Commands:') - console.log('--------------------') + console.log('-' * 40) Iterable commands = findCommands(profile, console).toUnique { Command c -> c.name } for (cmd in commands) { @@ -83,7 +83,7 @@ class ProfileInfoCommand extends ArgumentCompletingCommand implements ProfileRep } console.log('') console.log('Provided Features:') - console.log('--------------------') + console.log('-' * 40) Iterable features = profile.features for (feature in features) { diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/repository/AbstractJarProfileRepository.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/repository/AbstractJarProfileRepository.groovy index 0411e1288d..874adc59a0 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/repository/AbstractJarProfileRepository.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/repository/AbstractJarProfileRepository.groovy @@ -40,7 +40,7 @@ abstract class AbstractJarProfileRepository implements ProfileRepository { protected final List allProfiles = [] protected final Map profilesByName = [:] - protected static final String DEFAULT_PROFILE_GROUPID = 'org.grails.profiles' + protected static final String DEFAULT_PROFILE_GROUPID = 'org.graceframework.profiles' private final Set registeredUrls = [] diff --git a/grace-shell/src/main/groovy/org/grails/cli/profile/repository/MavenProfileRepository.groovy b/grace-shell/src/main/groovy/org/grails/cli/profile/repository/MavenProfileRepository.groovy index 2cdfe1c9d6..3e23c4790b 100644 --- a/grace-shell/src/main/groovy/org/grails/cli/profile/repository/MavenProfileRepository.groovy +++ b/grace-shell/src/main/groovy/org/grails/cli/profile/repository/MavenProfileRepository.groovy @@ -38,7 +38,7 @@ import org.grails.cli.profile.Profile class MavenProfileRepository extends AbstractJarProfileRepository { public static final GrailsRepositoryConfiguration DEFAULT_REPO = new GrailsRepositoryConfiguration( - 'grailsCentral', new URI('https://repo.grails.org/grails/core'), true) + 'mavenCentral', new URI('https://repo1.maven.org/maven2/'), false) List repositoryConfigurations MavenResolverGrapeEngine grapeEngine @@ -126,7 +126,7 @@ class MavenProfileRepository extends AbstractJarProfileRepository { if (!this.resolved) { List profiles = [] this.resolutionContext.managedDependencies.each { Dependency dep -> - if (dep.artifact.groupId == 'org.grails.profiles') { + if (dep.artifact.groupId == 'org.graceframework.profiles') { profiles.add([group: dep.artifact.groupId, module: dep.artifact.artifactId]) } } @@ -136,7 +136,7 @@ class MavenProfileRepository extends AbstractJarProfileRepository { this.grapeEngine.grab(profile) } - def localData = new File(System.getProperty('user.home'), '/.m2/repository/org/grails/profiles') + def localData = new File(System.getProperty('user.home'), '/.m2/repository/org/graceframework/profiles') if (localData.exists()) { localData.eachDir { File dir -> if (!dir.name.startsWith('.')) {