From 56ab2ea532031ec69ffa5a15dae8f025cf36eda1 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Thu, 12 Dec 2024 21:46:20 +0500 Subject: [PATCH 1/2] fix: do not save localStorage if using deprectated store --- packages/core/lib/store.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/lib/store.ts b/packages/core/lib/store.ts index 1f4f4f5..fe85e01 100644 --- a/packages/core/lib/store.ts +++ b/packages/core/lib/store.ts @@ -109,6 +109,7 @@ class LocalStorage implements Storage { } save() { + logger.debug(`Saving localStorage state to ${this.filePath}`); writeFileSync(this.filePath, this.stringify()); } } @@ -139,6 +140,9 @@ export const createStorage = async (name: string) => { return obj; }; + const localStorage = new LocalStorage(storagePath); + await localStorage.load(); + const storage: Record = { async load() { const data = (await fs.readJson(storagePath).catch(() => {})) || {}; @@ -171,6 +175,7 @@ export const createStorage = async (name: string) => { return serializable(storage); }, async save(items?: Record) { + exitQueue.length = 0; clear(storage); const data = items || serializable(storage); for (const [key, value] of Object.entries(data)) storage[key] = value; @@ -178,9 +183,6 @@ export const createStorage = async (name: string) => { }, }; - const localStorage = new LocalStorage(storagePath); - await localStorage.load(); - return { storage, localStorage }; }; @@ -199,8 +201,9 @@ export const createStore = (name: string) => { return state as T; }; const setState = async >(data?: T) => { + exitQueue.length = 0; Object.assign(state, data || {}); - logger.debug(`Saving state...`); + logger.debug(`Saving state to ${storePath}`); logger.debug(data || state); await fs.writeJson(storePath, data || state); }; From 0d12a5388b4b51a3f9b88e15d2848c06be2aed6a Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Tue, 17 Dec 2024 21:54:54 +0500 Subject: [PATCH 2/2] update submodules --- apps/cli | 2 +- package-lock.json | 2 +- packages/dasha | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/cli b/apps/cli index b34b028..2d60ab4 160000 --- a/apps/cli +++ b/apps/cli @@ -1 +1 @@ -Subproject commit b34b028d8f8aa1c94ae3a31e56d740a0174c7113 +Subproject commit 2d60ab44f7faff0c5b39f6b7918eba5ad099f89d diff --git a/package-lock.json b/package-lock.json index 422538a..a325c5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ }, "apps/cli": { "name": "@streamyx/cli", - "version": "4.2.2", + "version": "4.2.3", "hasInstallScript": true, "dependencies": { "@inquirer/prompts": "^7.2.0", diff --git a/packages/dasha b/packages/dasha index 51f20a5..e66e322 160000 --- a/packages/dasha +++ b/packages/dasha @@ -1 +1 @@ -Subproject commit 51f20a55f939d58195823a98e490e9427f34aaa4 +Subproject commit e66e322c7e270b35352e014db0d4c0fdcea0565f