Skip to content

Commit a7723f1

Browse files
authored
Merge pull request #4 from mfazrinizar/dev
v2.0.0
2 parents cefe32c + 6708b38 commit a7723f1

14 files changed

+556
-297
lines changed

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
9+
# flutter_secure_dotenv ^2.0.0 is not yet on pub.dev. We check out its
10+
# matching branch and generate a pubspec_overrides.yaml that redirects
11+
# the hosted dependency to the local checkout.
12+
#
13+
# Once flutter_secure_dotenv is published, simplify back to a single
14+
# checkout and remove the override steps.
15+
#
16+
# Push order: flutter_secure_dotenv first, then this repo.
17+
18+
jobs:
19+
analyze:
20+
name: Analyze
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
path: flutter_secure_dotenv_generator
26+
- uses: actions/checkout@v4
27+
with:
28+
repository: mfazrinizar/flutter_secure_dotenv
29+
ref: ${{ github.base_ref || github.ref_name }}
30+
path: flutter_secure_dotenv
31+
- uses: dart-lang/setup-dart@v1
32+
with:
33+
sdk: stable
34+
- name: Override flutter_secure_dotenv to local path
35+
shell: bash
36+
run: |
37+
cat > pubspec_overrides.yaml << 'EOF'
38+
dependency_overrides:
39+
flutter_secure_dotenv:
40+
path: ../flutter_secure_dotenv
41+
EOF
42+
working-directory: flutter_secure_dotenv_generator
43+
- run: dart pub get
44+
working-directory: flutter_secure_dotenv_generator
45+
- run: dart format --set-exit-if-changed .
46+
working-directory: flutter_secure_dotenv_generator
47+
- run: dart analyze --fatal-infos
48+
working-directory: flutter_secure_dotenv_generator
49+
50+
test:
51+
name: Test
52+
runs-on: ${{ matrix.os }}
53+
strategy:
54+
matrix:
55+
os: [ubuntu-latest, windows-latest, macos-latest]
56+
sdk: [stable, "3.8.0"]
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
path: flutter_secure_dotenv_generator
61+
- uses: actions/checkout@v4
62+
with:
63+
repository: mfazrinizar/flutter_secure_dotenv
64+
ref: ${{ github.base_ref || github.ref_name }}
65+
path: flutter_secure_dotenv
66+
- uses: dart-lang/setup-dart@v1
67+
with:
68+
sdk: ${{ matrix.sdk }}
69+
- name: Override flutter_secure_dotenv to local path
70+
shell: bash
71+
run: |
72+
cat > pubspec_overrides.yaml << 'EOF'
73+
dependency_overrides:
74+
flutter_secure_dotenv:
75+
path: ../flutter_secure_dotenv
76+
EOF
77+
working-directory: flutter_secure_dotenv_generator
78+
- run: dart pub get
79+
working-directory: flutter_secure_dotenv_generator
80+
- run: dart test
81+
working-directory: flutter_secure_dotenv_generator
82+
83+
dry-run:
84+
name: Publish Dry Run
85+
runs-on: ubuntu-latest
86+
needs: [analyze, test]
87+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
88+
steps:
89+
- uses: actions/checkout@v4
90+
with:
91+
path: flutter_secure_dotenv_generator
92+
- uses: actions/checkout@v4
93+
with:
94+
repository: mfazrinizar/flutter_secure_dotenv
95+
ref: main
96+
path: flutter_secure_dotenv
97+
- uses: dart-lang/setup-dart@v1
98+
with:
99+
sdk: stable
100+
- name: Override flutter_secure_dotenv to local path
101+
shell: bash
102+
run: |
103+
cat > pubspec_overrides.yaml << 'EOF'
104+
dependency_overrides:
105+
flutter_secure_dotenv:
106+
path: ../flutter_secure_dotenv
107+
EOF
108+
working-directory: flutter_secure_dotenv_generator
109+
- run: dart pub get
110+
working-directory: flutter_secure_dotenv_generator
111+
- run: dart pub publish --dry-run
112+
working-directory: flutter_secure_dotenv_generator
113+
114+
pana:
115+
name: Package Analysis
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
with:
120+
path: flutter_secure_dotenv_generator
121+
- uses: actions/checkout@v4
122+
with:
123+
repository: mfazrinizar/flutter_secure_dotenv
124+
ref: ${{ github.base_ref || github.ref_name }}
125+
path: flutter_secure_dotenv
126+
- uses: dart-lang/setup-dart@v1
127+
with:
128+
sdk: stable
129+
- run: dart pub global activate pana
130+
- name: Override flutter_secure_dotenv to local path
131+
shell: bash
132+
run: |
133+
cat > pubspec_overrides.yaml << 'EOF'
134+
dependency_overrides:
135+
flutter_secure_dotenv:
136+
path: ../flutter_secure_dotenv
137+
EOF
138+
working-directory: flutter_secure_dotenv_generator
139+
- run: dart pub get
140+
working-directory: flutter_secure_dotenv_generator
141+
- run: dart pub global run pana --no-warning .
142+
working-directory: flutter_secure_dotenv_generator

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ pubspec.lock
88

99
.vscode/
1010

11-
.env*
11+
.env*
12+
!example/.env
13+
14+
# Local development overrides
15+
pubspec_overrides.yaml

.pubignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Files to exclude from pub.dev publishing.
2+
# See https://dart.dev/go/pubignore
3+
4+
.dart_tool/
5+
pubspec.lock
6+
.vscode/
7+
pubspec_overrides.yaml

CHANGELOG.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
1-
## 1.0.0
2-
3-
- Initial version.
4-
- Update dependencies, refactor codes and continue the discontinued secure_dotenv_generator
1+
## 2.0.0
2+
3+
- **BREAKING**: Updated `source_gen` from `^2.0.0` to `^4.2.0` (addresses [#3](https://github.com/mfazrinizar/flutter_secure_dotenv_generator/issues/3)).
4+
- Migrated from `TypeChecker.fromRuntime` to `TypeChecker.fromUrl` (source_gen 4.x breaking change).
5+
- Added `inPackage` to `GeneratorForAnnotation` for precise annotation matching.
6+
- **BREAKING**: Updated `build` from `^2.4.2` to `>=3.0.0 <5.0.0`.
7+
- **BREAKING**: Updated `analyzer` from `^7.2.0` to `>=8.0.0 <11.0.0`.
8+
- Migrated from `element.enclosingElement3` to `element.enclosingElement`.
9+
- Migrated from `interface.augmented.lookUpGetter/lookUpSetter` to `interface.lookUpGetter/lookUpSetter`.
10+
- Migrated from `accessor.variable2` to `accessor.variable`.
11+
- Migrated from `interface.accessors` to `interface.getters`/`interface.setters`.
12+
- Migrated from `library.importedLibraries` to `library.firstFragment.libraryImports`.
13+
- **BREAKING**: Updated `pointycastle` from `^3.9.1` to `^4.0.0`.
14+
- **BREAKING**: Minimum Dart SDK bumped from `^3.6.0` to `^3.8.0`.
15+
- **Fix**: Generator no longer processes static/private fields (e.g. `_encryptionKey`, `_iv`) as environment variables.
16+
- Updated `flutter_secure_dotenv` dependency to `^2.0.0`.
17+
- Updated `source_helper` to `^1.3.10`, `lints` to `^6.1.0`, `test` to `^1.29.0`, `build_runner` to `^2.11.1`.
18+
- Updated example to use secure key loading (removed `String.fromEnvironment` pattern).
19+
- Added 100% `public_member_api_docs` coverage with library-level dartdoc.
20+
- Enhanced test coverage from 3 to 14 tests.
21+
- Added GitHub Actions CI workflow with dual-checkout and auto-generated `pubspec_overrides.yaml`.
22+
- Added `CONTRIBUTING.md`.
523

6-
## 1.0.1
24+
## 1.0.5
725

8-
- Minor typo fixes
26+
- Fix enum typePrefix empty building issue
927

10-
## 1.0.2
28+
## 1.0.4
1129

12-
- Fix building issue
30+
- Fix building without encryption
1331

1432
## 1.0.3
1533

1634
- Fix FormatterException caused by dart.core type prefix
1735

18-
## 1.0.4
36+
## 1.0.2
1937

20-
- Fix building without encryption
38+
- Fix building issue
2139

22-
## 1.0.5
40+
## 1.0.1
2341

24-
- Fix enum typePrefix empty building issue
42+
- Minor typo fixes
43+
44+
## 1.0.0
45+
46+
- Initial version.
47+
- Update dependencies, refactor codes and continue the discontinued secure_dotenv_generator

CONTRIBUTING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributing to flutter_secure_dotenv_generator
2+
3+
Thank you for your interest in contributing! This guide will help you get started.
4+
5+
## Getting Started
6+
7+
1. Fork the repository
8+
2. Clone your fork:
9+
```bash
10+
git clone https://github.com/<your-username>/flutter_secure_dotenv_generator.git
11+
```
12+
3. Install dependencies:
13+
```bash
14+
dart pub get
15+
```
16+
17+
### Local Development with flutter_secure_dotenv
18+
19+
During development you may want to test against a local copy of `flutter_secure_dotenv`. Create a `pubspec_overrides.yaml` (git-ignored) in the project root:
20+
21+
```yaml
22+
dependency_overrides:
23+
flutter_secure_dotenv:
24+
path: ../flutter_secure_dotenv
25+
```
26+
27+
## Development Workflow
28+
29+
### Branching
30+
31+
- `main` — stable releases published to pub.dev
32+
- `dev` — active development; PRs should target this branch
33+
34+
Create a feature branch from `dev`:
35+
36+
```bash
37+
git checkout -b feature/my-feature dev
38+
```
39+
40+
### Code Quality
41+
42+
Before submitting a PR, make sure all checks pass:
43+
44+
```bash
45+
dart format --set-exit-if-changed .
46+
dart analyze --fatal-infos
47+
dart test
48+
```
49+
50+
CI runs these automatically on every push and pull request.
51+
52+
### Tests
53+
54+
All new features and bug fixes **must** include tests. Run the test suite with:
55+
56+
```bash
57+
dart test
58+
```
59+
60+
## Pull Requests
61+
62+
1. Keep PRs focused — one feature or fix per PR.
63+
2. Write clear commit messages.
64+
3. Update `CHANGELOG.md` under an `## Unreleased` section.
65+
4. Ensure CI passes before requesting review.
66+
67+
## Reporting Issues
68+
69+
- Use [GitHub Issues](https://github.com/mfazrinizar/flutter_secure_dotenv_generator/issues).
70+
- Include Dart SDK version, package version, and a minimal reproduction.
71+
72+
## Code of Conduct
73+
74+
Be respectful and constructive in all interactions. We follow the [Dart community guidelines](https://dart.dev/community).

analysis_options.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ linter:
2323
rules:
2424
- public_member_api_docs
2525

26-
# analyzer:
27-
# exclude:
28-
# - path/to/excluded/files/**
26+
analyzer:
27+
exclude:
28+
# The example references env.g.dart which is produced by build_runner.
29+
# Without running the generator the file doesn't exist, causing
30+
# uri_has_not_been_generated errors during static analysis.
31+
- example/**
2932

3033
# For more information about the core and recommended set of lints, see
3134
# https://dart.dev/go/core-lints

example/flutter_secure_dotenv_generator_example.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@ import 'package:flutter_secure_dotenv/flutter_secure_dotenv.dart';
22

33
part 'env.g.dart';
44

5-
@DotEnvGen(
6-
filename: '.env',
7-
fieldRename: FieldRename.screamingSnake,
8-
)
5+
/// Example using the "Hardcoded Key + Gitignore" pattern.
6+
///
7+
/// This file (env.dart) is GITIGNORED. A template `env.example.dart` with
8+
/// placeholder values is committed instead. See SECURITY.md in
9+
/// flutter_secure_dotenv for details.
10+
11+
@DotEnvGen(filename: '.env', fieldRename: FieldRename.screamingSnake)
912
abstract class Env {
10-
static Env create() {
11-
String encryptionKey = const String.fromEnvironment(
12-
"APP_ENCRYPTION_KEY"); // On build, change with your generated encryption key (use dart-define for String.fromEnvironment)
13-
String iv = const String.fromEnvironment(
14-
"APP_IV_KEY"); // On build, change with your generated iv (use dart-define for String.fromEnvironment)
15-
return Env(encryptionKey, iv);
16-
}
13+
// These values come from the temporary encryption_key.json generated by
14+
// build_runner. Copy them here, then delete the JSON file.
15+
static const _encryptionKey = 'YOUR_BASE64_ENCRYPTION_KEY';
16+
static const _iv = 'YOUR_BASE64_IV';
17+
18+
static Env create() => Env(_encryptionKey, _iv);
1719

1820
const factory Env(String encryptionKey, String iv) = _$Env;
1921

2022
const Env._();
2123

22-
@FieldKey(defaultValue: "")
24+
@FieldKey(defaultValue: '')
2325
String get apiBaseUrl;
2426

25-
@FieldKey(defaultValue: "")
27+
@FieldKey(defaultValue: '')
2628
String get apiWebSocketUrl;
2729
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/// Code generator for [flutter_secure_dotenv](https://pub.dev/packages/flutter_secure_dotenv).
2+
///
3+
/// Reads `.env` files at build time, encrypts the values with AES-CBC, and
4+
/// emits a `part` file containing the encrypted data.
5+
library;
6+
17
import 'package:build/build.dart';
28
import 'package:source_gen/source_gen.dart';
39

@@ -7,7 +13,6 @@ import 'src/annotation_generator.dart';
713
///
814
/// Takes [options] as a parameter to configure the builder.
915
Builder flutterSecureDotEnvAnnotation(BuilderOptions options) =>
10-
SharedPartBuilder(
11-
[FlutterSecureDotEnvAnnotationGenerator(options)],
12-
'flutter_secure_dot_env_annotation',
13-
);
16+
SharedPartBuilder([
17+
FlutterSecureDotEnvAnnotationGenerator(options),
18+
], 'flutter_secure_dot_env_annotation');

0 commit comments

Comments
 (0)