Skip to content

Commit

Permalink
RJS-2792: Upgrade to Realm Core v14.5.0 (#6598)
Browse files Browse the repository at this point in the history
* Upgrading Realm Core to 14.5.0

* Copied relevant notes from the core changelog

* Removed the dependency on the clang-format package

* Using trunk to lint c++ on CI

* Using trunk install and run clang-format

* Replacing break with returns for unreachable code

* Moved "trunk:*" scripts into the existing lint scripts

* Apply suggestions from code review

Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
Co-authored-by: Kenneth Geisshirt <kenneth.geisshirt@mongodb.com>

* Mergin formatters into a single file and renaming them to *Formatter

* Updating the changelog from feedback

---------

Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
Co-authored-by: Kenneth Geisshirt <kenneth.geisshirt@mongodb.com>
  • Loading branch information
3 people authored Apr 10, 2024
1 parent 56ec83a commit e51a793
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 86 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/pr-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 20
# Install the root package (--ignore-scripts to avoid downloading or building the native module)
- name: Install root package dependencies
run: npm ci --ignore-scripts
run: npm ci
- name: Run linting of subpackages
run: npm run lint
- name: Run linting of C++ code
run: npm run lint:cpp
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
25 changes: 25 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.21.0
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.5
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
# runtimes:
# enabled:
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- clang-format@16.0.3
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
* Fixed opening a Realm with cached user while offline results in fatal error and session does not retry connection. ([#6554](https://github.com/realm/realm-js/issues/6554) and [#6558](https://github.com/realm/realm-js/issues/6558), since v12.6.0)
* Fixed sorting order of strings to use standard unicode codepoint order instead of grouping similar English letters together. A noticeable change will be from "aAbBzZ" to "ABZabz". ([realm/realm-core#2573](https://github.com/realm/realm-core/issues/2573))
* `data` and `string` are now strongly typed for comparisons and queries. This change is especially relevant when querying for a string constant on a Mixed property, as now only strings will be returned. If searching for `data` is desired, then that type must be specified by the constant. In RQL the new way to specify a binary constant is to use `mixed = bin('xyz')` or `mixed = binary('xyz')`. ([realm/realm-core#6407](https://github.com/realm/realm-core/issues/6407))
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). ([realm/realm-core#7536](https://github.com/realm/realm-core/issues/7536))
* Null pointer exception may be triggered when logging out and async commits callbacks not executed. ([realm/realm-core#7434](https://github.com/realm/realm-core/issues/7434), since v12.6.0)

### Compatibility
* React Native >= v0.71.4
* Realm Studio v15.0.0.
* File format: generates Realms with format v24 (reads and upgrades file format v10 or later).

### Internal
* Upgraded Realm Core from v13.26.0 to v14.4.1. ([#6499](https://github.com/realm/realm-js/issues/6499), [#6541](https://github.com/realm/realm-js/issues/6541), [#6568](https://github.com/realm/realm-js/issues/6568), and [#6572](https://github.com/realm/realm-js/issues/6572))
* The base URL used to communicate with the Atlas App Services was changed from "https://realm.mongodb.com" to "https://services.cloud.mongodb.com". ([realm/realm-core#7534](https://github.com/realm/realm-core/pull/7534)).
* Upgraded Realm Core from v13.26.0 to v14.5.0. ([#6499](https://github.com/realm/realm-js/issues/6499), [#6541](https://github.com/realm/realm-js/issues/6541), [#6568](https://github.com/realm/realm-js/issues/6568), [#6572](https://github.com/realm/realm-js/issues/6572), and [#6599](https://github.com/realm/realm-js/issues/6599))

## 12.7.0-rc.0 (2024-03-26)

Expand Down
188 changes: 139 additions & 49 deletions package-lock.json

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

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"bundle": "wireit",
"lint": "wireit",
"lint:fix": "wireit",
"lint:cpp": "find src packages/realm/bindgen/src -name '*.cpp' -or -name '*.h' -or -name '*.hpp' | xargs clang-format --dry-run --Werror",
"lint:cpp:fix": "find src packages/realm/bindgen/src -name '*.cpp' -or -name '*.h' -or -name '*.hpp' | xargs clang-format -i",
"clean": "git clean -fdx -e node_modules -e .env",
"prepend-changelog-header": "tsx scripts/prepend-changelog-header.ts"
},
Expand All @@ -32,13 +30,13 @@
]
},
"lint": {
"command": "npm run lint --workspaces --if-present",
"command": "npm run lint --workspaces --if-present && trunk check --all",
"dependencies": [
"./packages/babel-plugin:bundle"
]
},
"lint:fix": {
"command": "npm run lint --workspaces --if-present -- --fix",
"command": "npm run lint --workspaces --if-present -- --fix && trunk fmt",
"dependencies": [
"./packages/babel-plugin:bundle"
]
Expand Down Expand Up @@ -79,10 +77,10 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
"@trunkio/launcher": "^1.3.0",
"@tsconfig/node-lts": "^20.1.1",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"clang-format": "^1.8.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-flowtype": "^8.0.3",
Expand Down
3 changes: 0 additions & 3 deletions packages/realm/bindgen/src/eslint-formatter.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/realm/bindgen/src/formatters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createCommandFormatter } from "@realm/bindgen/formatter";

export const eslintFormatter = createCommandFormatter("eslint", ["npx", "eslint", "--fix", "--format=stylish"]);
export const trunkFormatter = createCommandFormatter("trunk", ["npx", "trunk", "fmt", "--force"]);
10 changes: 4 additions & 6 deletions packages/realm/bindgen/src/templates/jsi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
} from "@realm/bindgen/bound-model";

import { doJsPasses } from "../js-passes";
import { clangFormat } from "@realm/bindgen/formatter";
import { trunkFormatter } from "../formatters";

// Code assumes this is a unique name that is always in scope to refer to the jsi::Runtime.
// Callbacks need to ensure this is in scope. Functions taking Runtime arguments must use this name.
Expand Down Expand Up @@ -485,8 +485,7 @@ function convertToJsi(addon: JsiAddon, type: Type, expr: string): string {
case "AsyncResult":
assert.fail("Should never see AsyncResult here");
}
assert.fail(`unknown template ${type.name}`);
break;
return assert.fail(`unknown template ${type.name}`);

case "Class":
assert(!type.sharedPtrWrapped, `should not directly convert from ${type.name} without shared_ptr wrapper`);
Expand Down Expand Up @@ -617,8 +616,7 @@ function convertFromJsi(addon: JsiAddon, type: Type, expr: string): string {
case "std::function":
return `${type.toCpp()}(${c(inner, expr)})`;
}
assert.fail(`unknown template ${type.name}`);
break;
return assert.fail(`unknown template ${type.name}`);

case "Class":
if (type.sharedPtrWrapped) return `*JS_TO_SHARED_${type.name}(_env, ${expr})`;
Expand Down Expand Up @@ -1060,7 +1058,7 @@ class JsiCppDecls extends CppDecls {
}

export function generate({ rawSpec, spec, file: makeFile }: TemplateContext): void {
const out = makeFile("jsi_init.cpp", clangFormat);
const out = makeFile("jsi_init.cpp", trunkFormatter);

// HEADER
out(`// This file is generated: Update the spec instead of editing this file directly`);
Expand Down
Loading

0 comments on commit e51a793

Please sign in to comment.