Skip to content

Commit 808d21e

Browse files
authored
feat: Open source Celest CLI (#241)
Adds the source code for Celest CLI which includes the Celest analyzer and code-generation framework. This code is being provided as-is. The documentation will initially be very sparse and while future development may happen, the goal is mainly to share learnings from Celest's development.
2 parents 2423b84 + 33ce9ca commit 808d21e

File tree

1,013 files changed

+670019
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,013 files changed

+670019
-2
lines changed

.github/workflows/celest_cli.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: celest_cli
2+
on:
3+
pull_request:
4+
paths:
5+
- ".github/workflows/apps_cli.yaml"
6+
- "apps/cli/**"
7+
- "packages/**"
8+
- "services/**"
9+
10+
# Prevent duplicate runs due to Graphite
11+
# https://graphite.dev/docs/troubleshooting#why-are-my-actions-running-twice
12+
concurrency:
13+
group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}-${{ github.ref == 'refs/heads/main' && github.sha || ''}}
14+
cancel-in-progress: true
15+
16+
env:
17+
CELEST_LOCAL_PATH: ${{ github.workspace }}
18+
19+
jobs:
20+
test:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os:
25+
- ubuntu-latest
26+
- macos-14
27+
# TODO: Need to fix tests on Windows
28+
# - windows-latest
29+
runs-on: ${{ matrix.os }}
30+
timeout-minutes: 15
31+
steps:
32+
- name: Git Checkout
33+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
34+
with:
35+
submodules: recursive
36+
# Needed for flutter-version-file: https://github.com/subosito/flutter-action?tab=readme-ov-file#use-version-from-pubspecyaml
37+
- name: Install yq
38+
if: runner.os == 'Windows'
39+
shell: bash
40+
run: |
41+
curl -sL "https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_windows_amd64.exe" -o yq.exe
42+
echo "$PWD" >> "$GITHUB_PATH"
43+
- name: Setup Flutter
44+
uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0
45+
with:
46+
cache: true
47+
# Locks version to repo constraint (for golden test alignment)
48+
flutter-version-file: pubspec.yaml
49+
- name: Setup Libsecret
50+
if: runner.os == 'Linux'
51+
run: tool/setup-ci.sh
52+
- name: Get Packages
53+
working-directory: apps/cli
54+
run: dart pub upgrade
55+
- name: Test
56+
working-directory: apps/cli
57+
run: dart test -x e2e --fail-fast -j 1
58+
# - name: Test (Fixtures)
59+
# working-directory: apps/cli
60+
# run: dart test fixtures/legacy/fixtures_test.dart --fail-fast -j 1

apps/cli/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
4+
5+
# Build dir
6+
build/
7+
8+
tool/debug
9+
**/*.dill
10+
**/*.pkg
11+
vm_service_info.json

apps/cli/.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "CLI / E2E (--update-goldens)",
6+
"request": "launch",
7+
"type": "dart",
8+
"program": "fixtures/legacy/fixtures_test.dart",
9+
"env": {
10+
"UPDATE_GOLDENS": "true",
11+
"INCLUDE_TESTS": "flutter"
12+
},
13+
"args": ["--timeout=none"]
14+
},
15+
{
16+
"name": "CLI (test/analyzer)",
17+
"request": "launch",
18+
"type": "dart",
19+
"program": "test/analyzer/celest_analyzer_test.dart",
20+
"args": ["--timeout=none"]
21+
}
22+
]
23+
}

apps/cli/.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// -- Dart --
3+
"dart.analysisExcludedFolders": ["test/openapi/goldens"],
4+
5+
"files.associations": {
6+
"*.drift": "sql"
7+
}
8+
}

apps/cli/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1.0
2+
3+
- Initial version.

apps/cli/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: database
2+
3+
database:
4+
@echo "Generating Dart Drift classes..."
5+
@dart run build_runner build --delete-conflicting-outputs
6+
@for DB in cache cloud project; do \
7+
echo "Generating schema JSON for $${DB} database..."; \
8+
mkdir -p lib/database/$${DB}/schema/; \
9+
dart run drift_dev schema dump lib/database/$${DB}/$${DB}_database.dart lib/database/$${DB}/schema/; \
10+
echo "Generating migration file for $${DB} database..."; \
11+
dart run drift_dev schema steps lib/database/$${DB}/schema/ lib/database/$${DB}/$${DB}.migrations.dart; \
12+
done

apps/cli/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Celest CLI
2+
3+
The command line interface for Celest.

apps/cli/analysis_options.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include: package:celest_lints/app.yaml
2+
3+
analyzer:
4+
exclude:
5+
- "**/*.g.dart"
6+
errors:
7+
implementation_imports: ignore
8+
avoid_print: ignore
9+
avoid_catches_without_on_clauses: ignore
10+
camel_case_types: ignore
11+
require_trailing_commas: ignore # TODO: Conflicts with 3.7 formatting
12+
unused_element: info

apps/cli/bin/celest.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'package:celest_cli/commands/analysis_server_command.dart';
2+
import 'package:celest_cli/commands/build_command.dart';
3+
import 'package:celest_cli/commands/init_command.dart';
4+
import 'package:celest_cli/commands/precache_command.dart';
5+
import 'package:celest_cli/commands/start_command.dart';
6+
import 'package:celest_cli/commands/uninstall_command.dart';
7+
import 'package:celest_cli/commands/upgrade_command.dart';
8+
import 'package:celest_cli/src/cli.dart';
9+
import 'package:celest_cli/src/version.dart';
10+
11+
void main(List<String> args) async {
12+
final cli =
13+
Cli(
14+
'celest',
15+
'A command-line interface for Celest, the Flutter cloud platform.',
16+
version: packageVersion,
17+
)
18+
..addCommand(InitCommand())
19+
..addCommand(StartCommand())
20+
..addCommand(BuildCommand())
21+
..addCommand(AnalysisServerCommand())
22+
..addCommand(UpgradeCommand())
23+
..addCommand(UninstallCommand())
24+
..addCommand(PrecacheCommand());
25+
26+
await cli.run(args);
27+
}

apps/cli/build.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
targets:
2+
json:
3+
sources:
4+
exclude:
5+
- "fixtures/**"
6+
- "lib/database/**"
7+
auto_apply_builders: false
8+
builders:
9+
json_serializable:
10+
enabled: true
11+
options:
12+
explicit_to_json: true
13+
14+
$default:
15+
sources:
16+
include:
17+
- "lib/database/**"
18+
dependencies:
19+
- ":json"
20+
builders:
21+
drift_dev:
22+
enabled: true
23+
options:
24+
named_parameters: true
25+
store_date_time_values_as_text: false
26+
sql:
27+
dialect: sqlite
28+
options:
29+
version: "3.38"
30+
modules:
31+
- json1
32+
known_functions:
33+
typeid: text(text)
34+
35+
# Reduces generated code
36+
skip_verification_code: true
37+
data_class_to_companions: false

0 commit comments

Comments
 (0)