-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from onatcipli/develop-v3
Rename 3.0.0
- Loading branch information
Showing
97 changed files
with
2,587 additions
and
1,129 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "rename", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "example", | ||
"cwd": "example", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "example (profile mode)", | ||
"cwd": "example", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "profile" | ||
}, | ||
{ | ||
"name": "example (release mode)", | ||
"cwd": "example", | ||
"request": "launch", | ||
"type": "dart", | ||
"flutterMode": "release" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,175 @@ | ||
## About (Null-Safety) | ||
# Rename CLI Tool | ||
|
||
It helps you to change your flutter project's AppName and BundleId for different platforms, **currently only available | ||
for IOS, Android, macOS, Windows and Web** | ||
![GitHub issues](https://img.shields.io/github/issues/onatcipli/rename) | ||
![GitHub pull requests](https://img.shields.io/github/issues-pr/onatcipli/rename) | ||
![GitHub contributors](https://img.shields.io/github/contributors/onatcipli/rename) | ||
![GitHub](https://img.shields.io/github/license/onatcipli/rename) | ||
|
||
## Supported Platforms | ||
|
||
You can change the bundleId and appName in following folders | ||
## Warning | ||
|
||
- This package may not be compatible with a flavor setup. | ||
- The API has undergone significant changes; many elements have been deprecated. Please refer to the usage section for the updated functionalities. | ||
|
||
## About | ||
|
||
The Rename CLI Tool is a utility designed to modify your Flutter project's AppName and BundleId across various platforms. The supported platforms include: | ||
|
||
- IOS | ||
- Android | ||
- MacOS | ||
- Linux | ||
- Web | ||
- Web (only app name related functionality) | ||
- Windows | ||
|
||
## Installation | ||
|
||
``` | ||
To install the Rename CLI Tool, execute the following command: | ||
|
||
```sh | ||
flutter pub global activate rename | ||
``` | ||
|
||
## Default Usage | ||
### Running a Script | ||
|
||
You can [run a script directly](https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path) using `rename` from the activated package through the command line. If facing any issues, alternate commands are `dart pub global run rename` or `flutter pub global run rename`. For path variable issues, refer to [ensuring your path variables are set up correctly](https://dart.dev/tools/pub/glossary#system-cache). | ||
|
||
## Usage | ||
|
||
Please ensure you are in the Flutter project root directory before executing any commands. The tool supports various commands for retrieving and setting the AppName and BundleId: | ||
|
||
### Help | ||
|
||
Display general help or command-specific help using: | ||
|
||
```sh | ||
rename help | ||
``` | ||
|
||
```plaintext | ||
A CLI tool that helps for renaming in Flutter projects. | ||
Usage: rename <command> [arguments] | ||
Global options: | ||
-h, --help Print this usage information. | ||
-v, --version | ||
Available commands: | ||
getAppName Get app names for the targeted platforms | ||
getBundleId Get bundleId identifiers for the targeted platforms | ||
setAppName Set app name for the targeted platforms | ||
setBundleId Set bundleId identifier for the targeted platforms | ||
Run "rename help <command>" for more information about a command. | ||
``` | ||
|
||
or for a specific command: | ||
|
||
```sh | ||
rename help <commandName> | ||
``` | ||
|
||
```plaintext | ||
Example output for 'rename help setAppName': | ||
Set app name for the targeted platforms | ||
Usage: rename setAppName [arguments] | ||
-h, --help Print this usage information. | ||
-t, --targets Set which platforms to target. | ||
[ios (default), android (default), macos, linux, web, windows] | ||
-v, --value (mandatory) Set value of the given command | ||
Run "rename help" to see global options. | ||
``` | ||
|
||
### Get AppName | ||
|
||
if you dont pass **-t or --target** parameter it will try to rename all available platform project folders inside | ||
flutter project. | ||
To retrieve the current AppName for a specific platform: | ||
|
||
_**Run this command inside your flutter project root.**_ | ||
```sh | ||
rename getAppName --targets ios | ||
``` | ||
|
||
flutter pub global run rename --bundleId com.onatcipli.networkUpp | ||
flutter pub global run rename --appname "Network Upp" | ||
```plaintext | ||
This will output the current AppName for the iOS platform. | ||
``` | ||
|
||
or for multiple targets: | ||
|
||
```sh | ||
rename getAppName --targets ios,android,macos,windows,linux | ||
``` | ||
|
||
flutter pub global run rename --appname YourAppName --target ios | ||
flutter pub global run rename --appname YourAppName --target android | ||
flutter pub global run rename --appname YourAppName --target web | ||
flutter pub global run rename --appname YourAppName --target macOS | ||
flutter pub global run rename --appname YourAppName --target windows | ||
### Set AppName | ||
|
||
## Custom Usage | ||
To set the AppName for specific platforms: | ||
|
||
if you want to run commands directly (without using `pub global run`) | ||
ensure | ||
you [add system cache bin directory to your path](https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path) | ||
```sh | ||
rename setAppName --targets ios,android --value "YourAppName" | ||
``` | ||
|
||
rename --appname yourappname -t ios | ||
```plaintext | ||
This will set the AppName for the iOS and Android platforms to "YourAppName". | ||
``` | ||
|
||
or | ||
### Get/Set BundleId | ||
|
||
flutter pub global run rename --appname yourappname --target macOS | ||
Similarly, use `getBundleId` and `setBundleId` to retrieve or set the BundleId for the specified platforms. | ||
|
||
To target a specific platform use the "--target" option. e.g. | ||
```sh | ||
rename getBundleId --targets android | ||
``` | ||
|
||
flutter pub global run rename --bundleId com.example.android.app --target android | ||
```plaintext | ||
This will output the current BundleId for the Android platform. | ||
``` | ||
|
||
```sh | ||
rename setBundleId --targets android --value "com.example.bundleId" | ||
``` | ||
|
||
```plaintext | ||
This will set the BundleId for the Android platform to "com.example.bundleId". | ||
``` | ||
|
||
## Parameters | ||
|
||
-t, --target Set which platforms to target. | ||
[android, ios, web, windows, macOS, linux] | ||
-a, --appname Sets the name of the app. | ||
-b, --bundleId Sets the bundle id. | ||
-l, --launcherIcon Sets the launcher icon. (deprecated currently) | ||
-h, --help Shows help. | ||
### Commands | ||
|
||
- `setAppName`: Change the App Name for the given `--targets`. The `--value` option is required. | ||
- `setBundleId`: Change the bundle identifiers for the given `--targets`. The `--value` option is required. | ||
- `getAppName`: Display the app names for the given `--targets`. | ||
- `getBundleId`: Display the bundle identifiers for the given `--targets`. | ||
|
||
### Options | ||
|
||
- `-t, --targets`: Specify the target platforms. Options include `android`, `ios`, `web`, `windows`, `macos`, `linux`. This parameter is mandatory for all commands. | ||
- `-v, --value`: Set the value for the specified command. Mandatory for `setAppName` and `setBundleId`. | ||
- `-h, --help`: Display available instructions for the related command. | ||
|
||
## Upcoming Features | ||
|
||
- A Desktop application for easier usage. | ||
- Integration with the [interact package](https://pub.dev/packages/interact) and [pub_updater package](https://pub.dev/packages/pub_updater). | ||
- Enabling default platforms for the current Flutter project. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. Refer to the LICENSE file for details. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please refer to our contributing guidelines to get started. | ||
|
||
## Changelog | ||
|
||
For all notable changes to this project, refer to the CHANGELOG. | ||
|
||
## Support | ||
|
||
For any issues or suggestions, please open an issue. Your feedback is highly appreciated. | ||
|
||
## Next Coming | ||
## Author | ||
|
||
* Getting the current app names and bundleIds | ||
* UI to be able to easily use | ||
* Changing launcherIcon fix | ||
This project is created and maintained by [Onat Çipli](https://github.com/onatcipli). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,34 @@ | ||
import 'package:args/args.dart'; | ||
import 'package:rename/rename.dart' as rename; | ||
/// File: rename.dart | ||
/// Project: rename | ||
/// Author: Onat Cipli | ||
/// Created Date: 24.09.2023 | ||
/// Description: Entry point of the rename project for the command line. | ||
const android = 'android'; | ||
const macOS = 'macOS'; | ||
const ios = 'ios'; | ||
const linux = 'linux'; | ||
const web = 'web'; | ||
const windows = 'windows'; | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
const target = 'target'; | ||
const appname = 'appname'; | ||
const bundleId = 'bundleId'; | ||
const launcherIcon = 'launcherIcon'; | ||
const help = 'help'; | ||
import 'package:rename/commands/rename_command_runner.dart'; | ||
import 'package:rename/custom_exceptions.dart'; | ||
import 'package:rename/platform_file_editors/abs_platform_file_editor.dart'; | ||
|
||
final argParser = ArgParser() | ||
..addMultiOption(target, | ||
abbr: 't', | ||
allowed: [android, macOS, ios, linux, web, windows], | ||
help: 'Set which platforms to target.') | ||
..addOption(appname, abbr: 'a', help: 'Sets the name of the app.') | ||
..addOption(bundleId, abbr: 'b', help: 'Sets the bundle id.') | ||
..addFlag(help, abbr: 'h', help: 'Shows help.', negatable: false); | ||
|
||
void main(List<String> arguments) async { | ||
/// Entry point of the application. | ||
/// | ||
/// This function is responsible for running the rename command with the provided arguments. | ||
/// It handles any custom exceptions that may occur during the execution of the command. | ||
/// In case of a custom exception, the exit code is set to 1. | ||
/// For any other exceptions, the exit code is set to 64 indicating a command line usage error. | ||
/// | ||
/// Parameters: | ||
/// - `arguments`: List of command line arguments passed to the application. | ||
Future<void> main(List<String> arguments) async { | ||
try { | ||
final results = argParser.parse(arguments); | ||
if (results[help] || results.arguments.isEmpty) { | ||
print(argParser.usage); | ||
return; | ||
} | ||
|
||
final targets = results['target']; | ||
final platforms = <rename.Platform>{ | ||
if (targets.contains(macOS)) rename.Platform.macOS, | ||
if (targets.contains(android)) rename.Platform.android, | ||
if (targets.contains(ios)) rename.Platform.ios, | ||
if (targets.contains(linux)) rename.Platform.linux, | ||
if (targets.contains(web)) rename.Platform.web, | ||
if (targets.contains(windows)) rename.Platform.windows, | ||
}; | ||
|
||
if (results[appname] != null) { | ||
await rename.changeAppName(results[appname], platforms); | ||
} | ||
if (results[bundleId] != null) { | ||
await rename.changeBundleId(results[bundleId], platforms); | ||
} | ||
} on FormatException catch (e) { | ||
print(e.message); | ||
print(''); | ||
print(argParser.usage); | ||
final renameCommandRunner = RenameCommandRunner(); | ||
await renameCommandRunner.run(arguments); | ||
} on CustomException catch (err) { | ||
logger.e(err.toString()); | ||
exitCode = 1; | ||
} catch (e) { | ||
logger.e(e); | ||
exitCode = 64; // command line usage error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.