Skip to content

Commit

Permalink
Merge pull request #49 from onatcipli/develop-v3
Browse files Browse the repository at this point in the history
Rename 3.0.0
  • Loading branch information
onatcipli authored Sep 27, 2023
2 parents 62b46f3 + 147558e commit 9071d0a
Show file tree
Hide file tree
Showing 97 changed files with 2,587 additions and 1,129 deletions.
274 changes: 144 additions & 130 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions .vscode/launch.json
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"
}
]
}
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
All notable changes to the "Rename CLI Tool" project will be documented in this file.

# 3.0.0

### Added
- Introduced `RenameCommandRunner` class which is responsible for running the rename command in the CLI tool, including several commands such as `SetAppNameCommand`, `SetBundleIdCommand`, `GetAppNameCommand`, and `GetBundleIdCommand`.
- Support for Linux platform.
- New command structure with `getAppName`, `getBundleId`, `setAppName`, and `setBundleId`.
- `--targets` option to specify which platforms to target.
- `--value` option for setting the value in `setAppName` and `setBundleId`.
- Detailed `help` command for global options and individual commands.
- Added warning section noting potential compatibility issues and changes in API.
- Included detailed explanations and examples for each command in the Usage section.
- Added section on Upcoming Features, detailing plans for a Desktop application, integration with other packages, and enabling default platforms for the current Flutter project.
- Contributing section, License section, Author section, and Support section.
- Links to the author's GitHub profile, interact package, and pub_updater package.

### Changed
- Significant updates to the `Rename` class to handle the rename command for all platform file editors, including a switch case to handle different commands such as `setAppName`, `getAppName`, `setBundleId`, and `getBundleId`.
- Improved clarity and professionalism in the language used throughout the documentation.
- Updated installation and usage instructions for better clarity and detail.
- Updated About section with more detail.
- Updated Supported Platforms section with additional platforms and clarifications.
- Clearer instructions for custom usage.

### Removed
- Deprecated the `--launcherIcon` option and removed it from the Parameters section.

### Other Changes
- Updated the `pubspec.yaml` file to include new dependencies.
- `AbstractPlatformFileEditor` class providing a blueprint for platform-specific file editors.
- Minor updates to the `README.md` file for new instructions and usage examples.

## 2.1.1

- readme fix
Expand Down
180 changes: 142 additions & 38 deletions README.md
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).
77 changes: 28 additions & 49 deletions bin/rename.dart
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
}
}
9 changes: 6 additions & 3 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
Expand All @@ -31,11 +32,13 @@
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
Loading

0 comments on commit 9071d0a

Please sign in to comment.