Skip to content

Commit

Permalink
feat: RedData.Json is now optional.
Browse files Browse the repository at this point in the history
Configure project with red-cli.
  • Loading branch information
poirierlouis committed Jul 14, 2024
1 parent fe0546a commit bd7ddc2
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 226 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- `RedData.Json` is now optional when installing `RedHttpClient`.

### Added
- support in `HttpClient` and `AsyncHttpClient` to send a body with `DELETE`
methods.
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,14 @@ target_link_libraries(RedHttpClient PRIVATE
RedFileSystem
cpr::cpr
)

## Debug mode: install scripts (+ tests) and plugin in game folder.
## Release mode: create archive with bundled scripts and plugin.
add_custom_command(
TARGET RedHttpClient
POST_BUILD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "$<$<CONFIG:Debug>:Install scripts with red-cli>" "$<$<CONFIG:Release>:Build archive with red-cli>"
COMMAND "$<$<CONFIG:Debug>:red-cli;install;--debug>" "$<$<CONFIG:Release>:red-cli;pack>"
COMMAND_EXPAND_LISTS
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ CET.
## Installation
1. Install requirements:
- [RED4ext] v1.24.3+
- [RedData] v0.4.0+
- [RedFileSystem] v0.9.0+ is recommended
- [RedData] v0.4.0+ (only required for Json data)
- [RedFileSystem] v0.9.0+ (recommended)
2. Extract the [latest archive] into the Cyberpunk 2077 directory.

## Usage
Expand Down
154 changes: 0 additions & 154 deletions bundle.mjs

This file was deleted.

67 changes: 0 additions & 67 deletions install.mjs

This file was deleted.

15 changes: 15 additions & 0 deletions red.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "RedHttpClient",
"version": "0.3.3",
"license": true,
"dist": "dist\\",
"scripts": {
"redscript": {
"src": "scripts\\RedHttpClient\\"
}
},
"plugin": {
"debug": "build\\Debug\\",
"release": "build\\Release\\"
}
}
5 changes: 5 additions & 0 deletions scripts/RedHttpClient/AsyncHttpClient.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module RedHttpClient

@if(ModuleExists("RedData.Json"))
import RedData.Json.*

public native class AsyncHttpClient {
public static native func Get(callback: HttpCallback, url: String, opt headers: array<HttpHeader>) -> Void;
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/HttpCallback.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient

public native struct HttpCallback {
public static func Create(target: wref<IScriptable>, function: CName, opt data: array<Variant>) -> HttpCallback {
Expand Down
5 changes: 5 additions & 0 deletions scripts/RedHttpClient/HttpClient.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module RedHttpClient

@if(ModuleExists("RedData.Json"))
import RedData.Json.*

public native class HttpClient {
public static native func Get(url: String, opt headers: array<HttpHeader>) -> ref<HttpResponse>;
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/HttpHeader.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient

public native struct HttpHeader {
public static func Create(name: String, value: String) -> HttpHeader {
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/HttpMultipart.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient

public native class HttpMultipart {
public native func AddPart(name: String, value: String) -> Void;
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/HttpPair.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient

public native struct HttpPair {
public static func Create(key: String, value: String) -> HttpPair {
Expand Down
5 changes: 5 additions & 0 deletions scripts/RedHttpClient/HttpResponse.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module RedHttpClient

@if(ModuleExists("RedData.Json"))
import RedData.Json.*

public native class HttpResponse {
public native func GetStatus() -> HttpStatus;
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/HttpStatus.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient

enum HttpStatus {
Continue = 100,
SwitchingProtocols = 101,
Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/Test/AsyncHttpClientTest.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient.Test

import RedData.Json.*
import RedHttpClient.*

Expand Down
2 changes: 2 additions & 0 deletions scripts/RedHttpClient/Test/HttpClientTest.reds
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module RedHttpClient.Test

import RedData.Json.*
import RedHttpClient.*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module RedHttpClient.Test

import Codeware.*
import RedHttpClient.*

public class MainTest extends ScriptableEnv {
public class RedHttpClientTest extends ScriptableEnv {
private let m_runner: ref<RedTest>;
/// Lifecycle ///
Expand All @@ -15,6 +18,6 @@ public class MainTest extends ScriptableEnv {
}

public static func GetMainTest() -> ref<MainTest> {
return ScriptableEnv.Get(n"MainTest") as MainTest;
public static func GetRedHttpClientTest() -> ref<RedHttpClientTest> {
return ScriptableEnv.Get(n"RedHttpClientTest") as RedHttpClientTest;
}

0 comments on commit bd7ddc2

Please sign in to comment.