Skip to content

Commit 480e35b

Browse files
committed
Added sql console. Cleanup.
1 parent ad8d205 commit 480e35b

File tree

14 files changed

+134
-44
lines changed

14 files changed

+134
-44
lines changed

.github/workflows/dev-packages.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The version is pulled from the CHANGELOG.md file of the package.
2-
# Add a `-dev.xxx` suffix to the version.
2+
# Add a `-dev.xxx` suffix to the version. Example: `0.0.1-dev.1`
33
name: Create Dev Release
44

55
on: workflow_dispatch
@@ -24,17 +24,25 @@ jobs:
2424
- name: Restore dependencies
2525
run: dotnet restore
2626

27-
- name: Extract Version from CHANGELOG.md
27+
- name: Extract Common Package Version from CHANGELOG.md
2828
id: extract_version
2929
shell: bash
3030
run: |
31-
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32-
echo "Detected Version: $VERSION"
33-
echo "VERSION=$VERSION" >> $GITHUB_ENV
34-
35-
- name: Run Pack
36-
run: dotnet pack -c Release -o ${{ github.workspace }}/output
31+
COMMON_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32+
echo "Detected Version: $COMMON_VERSION"
33+
echo "VERSION=$COMMON_VERSION" >> $GITHUB_ENV
34+
35+
- name: Extract MAUI Package Version from CHANGELOG.md
36+
id: extract_maui_version
37+
shell: bash
38+
run: |
39+
COMMON_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.MAUI/CHANGELOG.md)
40+
echo "Detected Version: $COMMON_VERSION"
41+
echo "VERSION=$COMMON_VERSION" >> $GITHUB_ENV
3742
38-
- name: Run Push
39-
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40-
43+
# - name: Run Pack
44+
# run: dotnet pack -c Release -o ${{ github.workspace }}/output
45+
#
46+
# - name: Run Push
47+
# run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
48+
#

PowerSync/PowerSync.Maui/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# PowerSync.Maui Changelog
22

3-
4-
## 0.0.1-alpha.1
3+
## 0.0.1-dev.1
54

65
- Introduce package. Support for iOS/Android use cases.
76

PowerSync/PowerSync.Maui/PowerSync.Maui.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</ItemGroup>
4242

4343
<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
44-
<Content Include="Platforms\iOS\**\*.*">
44+
<Content Include="Platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework\**\*.*">
4545
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4646
</Content>
4747
</ItemGroup>
@@ -52,6 +52,6 @@
5252
</ItemGroup>
5353

5454
<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
55-
<None Include="Platforms\iOS\**\*.*" Pack="true" PackagePath="Platforms\iOS" />
55+
<None Include="Platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework\**\*.*" Pack="true" PackagePath="Platforms\iOS" />
5656
</ItemGroup>
5757
</Project>

Tools/Setup/Setup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public async Task SetupMauiAndroid()
112112
var downloadUrl = $"{MAVEN_BASE_URL}/{aarFileName}";
113113

114114
await DownloadFile(downloadUrl, aarPath);
115-
await ExtractAarNativeLibraries(aarPath, nativeDir);
115+
ExtractAarNativeLibraries(aarPath, nativeDir);
116116

117117
Console.WriteLine($"✓ Android: Extracted native libraries from {aarFileName}");
118118
}
@@ -122,7 +122,7 @@ public async Task SetupMauiAndroid()
122122
}
123123
}
124124

125-
private async Task ExtractAarNativeLibraries(string aarPath, string nativeDir)
125+
private void ExtractAarNativeLibraries(string aarPath, string nativeDir)
126126
{
127127
var extractedDir = Path.Combine(nativeDir, "temp_extracted");
128128

demos/TodoSQLite/AppShell.xaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@
66
xmlns:views="clr-namespace:TodoSQLite.Views"
77
Shell.FlyoutBehavior="Disabled">
88

9-
<ShellContent
10-
Title="Todo Lists"
11-
ContentTemplate="{DataTemplate views:ListsPage}"
12-
Route="ListsPage" />
9+
<TabBar>
10+
<Tab Title="Todo Lists">
11+
<ShellContent
12+
Title="Todo Lists"
13+
ContentTemplate="{DataTemplate views:ListsPage}"
14+
Route="ListsPage" />
15+
</Tab>
16+
<Tab Title="SQL Console">
17+
<ShellContent
18+
Title="SQL Console"
19+
ContentTemplate="{DataTemplate views:SqlConsolePage}"
20+
Route="SqlConsolePage" />
21+
</Tab>
22+
</TabBar>
1323

1424
</Shell>

demos/TodoSQLite/AppShell.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public AppShell()
88
{
99
InitializeComponent();
1010
Routing.RegisterRoute(nameof(TodoListPage), typeof(TodoListPage));
11+
Routing.RegisterRoute(nameof(SqlConsolePage), typeof(SqlConsolePage));
1112
}
1213
}

demos/TodoSQLite/Data/NodeConnector.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ namespace TodoSQLite.Data;
1313

1414
public class NodeConnector : IPowerSyncBackendConnector
1515
{
16-
private static readonly string StorageFilePath = "user_id.txt"; // Simulating local storage
17-
private readonly HttpClient _httpClient;
16+
private readonly HttpClient httpClient;
1817

1918
public string BackendUrl { get; }
2019
public string PowerSyncUrl { get; }
@@ -23,7 +22,7 @@ public class NodeConnector : IPowerSyncBackendConnector
2322

2423
public NodeConnector()
2524
{
26-
_httpClient = new HttpClient();
25+
httpClient = new HttpClient();
2726

2827
// Load or generate User ID
2928
UserId = LoadOrGenerateUserId();
@@ -41,10 +40,10 @@ public string LoadOrGenerateUserId()
4140

4241
public async Task<PowerSyncCredentials?> FetchCredentials()
4342
{
44-
string tokenEndpoint = "api/auth/token";
45-
string url = $"{BackendUrl}/{tokenEndpoint}?user_id={UserId}";
43+
var tokenEndpoint = "api/auth/token";
44+
var url = $"{BackendUrl}/{tokenEndpoint}?user_id={UserId}";
4645

47-
HttpResponseMessage response = await _httpClient.GetAsync(url);
46+
var response = await httpClient.GetAsync(url);
4847
if (!response.IsSuccessStatusCode)
4948
{
5049
throw new Exception($"Received {response.StatusCode} from {tokenEndpoint}: {await response.Content.ReadAsStringAsync()}");
@@ -99,7 +98,7 @@ public async Task UploadData(IPowerSyncDatabase database)
9998
var payload = JsonSerializer.Serialize(new { batch });
10099
var content = new StringContent(payload, Encoding.UTF8, "application/json");
101100

102-
HttpResponseMessage response = await _httpClient.PostAsync($"{BackendUrl}/api/data", content);
101+
HttpResponseMessage response = await httpClient.PostAsync($"{BackendUrl}/api/data", content);
103102

104103
if (!response.IsSuccessStatusCode)
105104
{

demos/TodoSQLite/Data/PowerSyncData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public PowerSyncData()
1717
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
1818
{
1919
builder.AddConsole();
20-
builder.SetMinimumLevel(LogLevel.Trace);
20+
builder.SetMinimumLevel(LogLevel.Error);
2121
});
2222
var logger = loggerFactory.CreateLogger("PowerSyncLogger");
2323

@@ -73,7 +73,7 @@ await Db.Execute(
7373
[
7474
item.Description,
7575
item.Completed ? 1 : 0,
76-
item.CompletedAt,
76+
item.CompletedAt!,
7777
UserId,
7878
item.ID
7979
]);

demos/TodoSQLite/MauiProgram.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static MauiApp CreateMauiApp()
2222
builder.Services.AddSingleton<PowerSyncData>();
2323
builder.Services.AddTransient<ListsPage>();
2424
builder.Services.AddTransient<TodoListPage>();
25+
builder.Services.AddTransient<SqlConsolePage>();
2526

2627
return builder.Build();
2728
}

demos/TodoSQLite/Models/TodoItem.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@ namespace TodoSQLite.Models;
55
public class TodoItem
66
{
77
[JsonProperty("id")]
8-
public string ID { get; set; } = "";
9-
10-
[JsonProperty("list_id")]
11-
public string ListId { get; set; }
8+
public string ID { get; set; } = null!;
9+
10+
[JsonProperty("list_id")] public string ListId { get; set; } = null!;
1211

1312
[JsonProperty("created_at")]
14-
public string CreatedAt { get; set; }
13+
public string CreatedAt { get; set; }= null!;
1514

1615
[JsonProperty("completed_at")]
17-
public string CompletedAt { get; set; }
16+
public string? CompletedAt { get; set; }
1817

1918
[JsonProperty("description")]
20-
public string Description { get; set; }
19+
public string Description { get; set; }= null!;
2120

2221
[JsonProperty("created_by")]
23-
public string CreatedBy { get; set; }
22+
public string CreatedBy { get; set; }= null!;
2423

2524
[JsonProperty("completed_by")]
26-
public string CompletedBy { get; set; }
25+
public string CompletedBy { get; set; }= null!;
2726

2827
[JsonProperty("completed")]
29-
public bool Completed { get; set; }
28+
public bool Completed { get; set; } = false;
3029
}

0 commit comments

Comments
 (0)