Skip to content

New core - #118

Open
Shamyyoun wants to merge 355 commits into
developfrom
new_core
Open

Shamyyoun wants to merge 355 commits into
developfrom
new_core

Conversation

@Shamyyoun

@Shamyyoun Shamyyoun commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Note

High Risk
High risk due to a large-scale refactor that restructures modules/packages, replaces core configuration + networking/publishing wiring, and adds CI that mutates the repo (auto-commits version catalog updates) while publishing artifacts to GitHub Packages.

Overview
Introduces a new modular “new core” KMM layout (e.g. core:core, core:files, core:notifications, core:phone-core, core:sample) and removes the previous coreapp/androidApp sample app implementation, alongside broad package renames from com.metacto.core.utils.* to com.metacto.core.*/com.metacto.core.extensions.

Refactors core configuration and DI: replaces environment-style inputs with CoreConfigs, adds a new coreModule() + platform modules, updates repositories to use com.metacto.kmm.network/HttpService, and adds new date wrappers/serializers (CoreDate, CoreDateTime, CoreTime) plus updated relative-date APIs that accept TimeZone.

Updates build/publishing automation: switches root buildscript classpaths to the version catalog, adds UpdateVersionCatalogTask to bump metacto-core in gradle/libs.versions.toml from versions.properties, and adds a new GitHub Actions workflow (deployNewCore.yml) that generates versions, commits the catalog, and publishes; deployRelease.yml is aligned to PUBLISH_CORE_VERSION and publishes :CmpCore.

Written by Cursor Bugbot for commit 124bc4b. This will update automatically on new commits. Configure here.

fun updateVersion() {
val versionProperties = Properties().apply {
load(File(project.rootDir, "versions.properties").inputStream())
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input stream never closed causing resource leak

Low Severity

The inputStream() created from versions.properties is passed directly to Properties.load() without using .use {} or explicitly closing it. This leaves the file handle open until garbage collection, which could exhaust file descriptors if the task runs repeatedly or in resource-constrained environments.

Fix in Cursor Fix in Web


file.writeText(content)
return file.absolutePath
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android createFile can crash while iOS handles errors gracefully

Medium Severity

The Android createFile implementation lacks error handling, while the iOS implementation wraps the operation in a try-catch and returns an empty string on failure. The IFileManager interface does not declare @Throws(Throwable::class) for createFile, indicating it should not throw. When file.writeText(content) fails on Android (disk full, permission denied, etc.), an unhandled IOException will crash the app, whereas iOS would gracefully return an empty string. This platform inconsistency could cause production crashes on Android.

Fix in Cursor Fix in Web


@Throws(Throwable::class)
suspend fun updateVideoPreviewUrl(id: Int, previewUrl: String) {
uploadService.put<Unit> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unchecked cast and array access in upload response parsing

Medium Severity

The uploadMedia function casts response.body() directly to JsonArray without validation, then accesses [0] without checking if the array is empty. If the server returns an error response (typically a JsonObject), an empty array, or any non-array response, this will crash with ClassCastException or IndexOutOfBoundsException. Upload failures would surface as cryptic parsing errors rather than meaningful error messages.

Fix in Cursor Fix in Web

logoutUseCase = get(),
enforceDefaultDataWrapper = configs.strapiVersion == StrapiVersion.V5
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing DI registrations for required service dependencies

High Severity

The DI module attempts to resolve userService for CoreUserRepository and appConfigurationService for CoreAppConfigurationRepository, but neither service is registered in the module. Only HttpService is registered (from RepositoriesFactory.httpService), which is a different type. This causes Koin to throw NoBeanDefFoundException at runtime when these repositories are resolved.

Additional Locations (1)

Fix in Cursor Fix in Web

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

fun updateVersion() {
val versionProperties = Properties().apply {
load(File(project.rootDir, "versions.properties").inputStream())
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File input stream not closed after loading properties

Medium Severity

The FileInputStream created by File(...).inputStream() is passed to Properties.load() but never closed afterward. The Properties.load() method does not close the stream—that responsibility belongs to the caller. In Gradle daemon environments where the JVM persists across builds, these leaked file descriptors accumulate and can eventually cause "Too many open files" errors when the system limit is reached.

Fix in Cursor Fix in Web

includes(platformModule())
}

internal expect fun platformModule(): Module No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused empty sample module adds no functionality

Low Severity

The core/sample module was added as an empty placeholder, providing no actual functionality. It's included in the build but unused, and its build.gradle.kts contains a large commented-out publishing configuration, adding unnecessary clutter and dead code.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants