this post was submitted on 14 Jun 2023
4 points (100.0% liked)

Dart Programming Language

132 readers
1 users here now

This sublemmy is a place for everything related to the Dart programming language and its tools besides Flutter (use [email protected] for that)

founded 1 year ago
MODERATORS
 

I was recently looking into Dart CLI tools and script managers and found a few interesting options. These can really impact productivity and ease of use.

I have personally used Derry to replace some long commands to generate native libs etc. There are other options like Slidy, but haven't used them.

top 3 comments
sorted by: hot top controversial new old
[–] fperson 3 points 1 year ago (1 children)

I've been using makefiles for a while and find them pretty good. The only downside is adding any arguments to recipes (passed when executing them) is tricky. On the other hand, there was only one scenario where that could be useful (release-staging from below), but I managed to get what I wanted without arguments. I like makefiles for portability and automatic shell completion for fish.

Here's a Makefile from one of the projects I'm working on to give a better idea of my usage:

QA_TARGET := "lib/main_qa.dart"
PROD_TARGET := "lib/main_prod.dart"

get-packages:
	flutter pub get

code-generation:
	dart run build_runner build --delete-conflicting-outputs

localizations:
	dart run intl_utils:generate

apk-qa:
	flutter build apk --target $(QA_TARGET)

appbundle-prod:
	flutter build appbundle --target $(PROD_TARGET)

ipa-qa:
	flutter build ipa --target $(QA_TARGET)

ipa-prod:
	flutter build ipa --target $(PROD_TARGET)

launcher-icons:
	dart run flutter_launcher_icons

release-staging:
	$(eval DIFF := $(shell git diff -- pubspec.yaml | grep '^+version'))
	@if [ -z "$(DIFF)" ]; then \
		echo "Error: No changes in version. Aborting."; \
		exit 1; \
	fi

	@OTHER_DIFF=$$(git diff -- './*' ':!pubspec.yaml'); \
	if [ -n "$$OTHER_DIFF" ]; then \
		echo "Error: Changes found outside of pubspec.yaml. Aborting."; \
		exit 1; \
	fi;

	$(eval VERSION := $(shell awk '/^version: / {print $$2}' pubspec.yaml))
	$(eval LAST_RELEASE_HASH := $(shell git log --pretty=format:'%H %s' | grep 'chore(build): Bump build number to' | awk 'NR==1{print $$1}'))
	$(eval CHANGES := $(shell git log --pretty=format:'\n- %s' $(LAST_RELEASE_HASH)...HEAD))

	@echo "chore(build): Bump build number to $(VERSION)\n\nChanges:$(CHANGES)" > commit_msg.txt
	@echo "Releasing version $(VERSION) to STAGING"

	git add pubspec.yaml

	git commit -F commit_msg.txt
	rm commit_msg.txt

	git tag v$(VERSION)
	git push
	git push --tags
[–] problematicconsumer 1 points 1 year ago (1 children)

yes makefile is a more popular and standard way and in most cases is a better choice. but I love new experiments specially in Dart and want to give them a shot. here's an issue regarding derry vs other solutions

[–] fperson 2 points 1 year ago

here’s an issue regarding derry vs other solutions

Yup, that makes sense!