Skip to content

Commit

Permalink
stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
rutvik110 committed Aug 22, 2023
1 parent 2ac5399 commit 9f90fc9
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 159 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.acceptSuggestionOnEnter": "on"
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.0

- Moved to stable release.
- Generated path now includes the missing backslash "/" at the end.
- Using backslash "/" as the path separater for all platforms. Earlier using the default path on windows platforms resulted in compilation errors. This update fixes that issue.
## 0.1.3-dev.2+5

- Latest version string updated in version file.
Expand Down
34 changes: 10 additions & 24 deletions lib/asset_manager_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:args/args.dart';
import 'package:asset_manager_cli/src/version.dart';
import 'package:mason_logger/mason_logger.dart';
import 'package:pub_updater/pub_updater.dart';
import 'package:path/path.dart' as p;

final pubUpdater = PubUpdater();

Expand All @@ -22,11 +23,9 @@ Future<void> checkForUpdate() async {
}
}

void commandNotFound(
String commands, ArgResults argResults, Logger logger) async {
void commandNotFound(String commands, ArgResults argResults, Logger logger) async {
final unknownCommand = argResults.arguments[0];
logger.err(
"Command not found $unknownCommand\nDid you mean one of these commands?\n$commands");
logger.err("Command not found $unknownCommand\nDid you mean one of these commands?\n$commands");
await checkForUpdate();
exit(1);
}
Expand All @@ -40,29 +39,18 @@ void addAssetsCode(Logger logger) async {
final progress = logger.progress("Generating assets code");
try {
final assetDir = Directory('assets');
final fontsDir = Directory('assets/fonts');
final fontsDir = Directory(p.joinAll(['assets', 'fonts']));
final pubspecFile = File('pubspec.yaml');

final subdirectories = assetDir.listSync();

final openedFile = pubspecFile.readAsLinesSync();
final addAfterLine =
openedFile.indexWhere(((element) => element == "flutter:"));
final addAfterLine = openedFile.indexWhere(((element) => element == "flutter:"));

openedFile.insert(addAfterLine + 1, "\n assets:");

List<String> assetsString = [];
// add assets code except fonts
for (var i = 0; i < subdirectories.length; i++) {
final subdirectory = subdirectories[i];
if (subdirectory is Directory) {
if (!subdirectory.path.contains("fonts")) {
assetsString.add(generateAssetDirPath(subdirectory.path));

assetsString.addAll(generateDirAssetsCode(subdirectory));
}
}
}
assetsString.add(generateAssetDirPath("assets/"));
assetsString.addAll(generateDirAssetsCode(assetDir));

openedFile.insertAll(addAfterLine + 2, assetsString);

Expand All @@ -82,12 +70,10 @@ void addAssetsCode(Logger logger) async {
final fontFiles = Directory(font.path).listSync();
for (var fontFile in fontFiles) {
if (fontFile is File) {
final fontFileExtension =
fontFile.path.split('/').last.split(".").last;
final fontFileExtension = fontFile.path.split('/').last.split(".").last;
if (fontFileExtension == "ttf") {
final fontFilePath = fontFile.path;
final fontProperties =
fontFilePath.split('/').last.split('.').first.split('-');
final fontProperties = fontFilePath.split('/').last.split('.').first.split('-');
final fontFileWeight = fontProperties.last;
final fontFileStyle = fontProperties[1].toLowerCase();
fontsString.add(
Expand Down Expand Up @@ -127,7 +113,7 @@ List<String> generateDirAssetsCode(Directory directory) {

for (var subDir in subDirectories) {
if (subDir is Directory) {
final subDirPath = subDir.path;
final subDirPath = "${Uri.file(subDir.path).toFilePath(windows: false)}/";
if (!subDirPath.contains('fonts')) {
assetString.add(generateAssetDirPath(subDirPath));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9f90fc9

Please sign in to comment.