Przeglądaj źródła

fix node-persist dependency errors

main
James Fenn 2 miesięcy temu
rodzic
commit
d38abe3850
5 zmienionych plików z 15 dodań i 8 usunięć
  1. +0
    -3
      example-nodejs/src/index.js
  2. +1
    -3
      gitrest/build.gradle
  3. +4
    -0
      gitrest/src/jsMain/kotlin/me/jfenn/gitrest/service/DiskCache.kt
  4. +2
    -1
      npm/package.json
  5. +8
    -1
      npm/test.js

+ 0
- 3
example-nodejs/src/index.js Wyświetl plik

@@ -1,9 +1,6 @@
const { Client } = require("git-rest-wrapper-gitrest");

let gitrest = new Client({
cache: {
type: "disk"
},
tokens: {
'a.b': "c"
}


+ 1
- 3
gitrest/build.gradle Wyświetl plik

@@ -58,7 +58,7 @@ kotlin {
nodejs()
browser {
dceTask {
keep 'git-rest-wrapper-gitrest.RequestProvider', "ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io"
keep 'git-rest-wrapper-gitrest.Client', "ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io"
}
compilations.all {
kotlinOptions {
@@ -147,8 +147,6 @@ kotlin {
implementation npm("node-fetch", "2.6.0")
implementation npm("text-encoding", "0.7.0")
implementation npm("abort-controller", "3.0.0")

implementation npm("node-persist", "3.1.0")
}
}
jsTest {


+ 4
- 0
gitrest/src/jsMain/kotlin/me/jfenn/gitrest/service/DiskCache.kt Wyświetl plik

@@ -5,6 +5,7 @@ import me.jfenn.gitrest.model.GitrestConfig
import me.jfenn.gitrest.model.Repo
import kotlin.js.Date
import kotlin.js.Promise
import kotlin.js.jsTypeOf

external fun require(module: String): dynamic

@@ -20,6 +21,9 @@ class DiskCache(
private var promisePersist: Promise<dynamic>? = null

private suspend fun getPersist() : dynamic {
if (js("typeof localStorage") != "undefined")
persist = js("localStorage")

if (persist == null) {
persist = require("node-persist")
promisePersist = (persist.init() as Promise<dynamic>)


+ 2
- 1
npm/package.json Wyświetl plik

@@ -23,7 +23,8 @@
"dependencies": {
"abort-controller": "^3.0.0",
"node-fetch": "^2.6.0",
"text-encoding": "^0.7.0"
"text-encoding": "^0.7.0",
"node-persist": "^3.1.0"
},
"bundledDependencies": [
"kotlin",


+ 8
- 1
npm/test.js Wyświetl plik

@@ -1,6 +1,13 @@
const { Client } = require('./index.js');

let provider = new Client();
let provider = new Client({
cache: {
type: 'disk'
},
tokens: {
'a.b': "c"
}
});

// simple usability test, probably shouldn't break anytime soon...
provider.getUser("fennifith").then((user) => {


Ładowanie…
Anuluj
Zapisz