[PR #5259] [MERGED] feat(desktop): portable phase-1 foundational: infra & build #5131

Closed
opened 2026-03-17 02:36:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5259
Author: @CuriousCorrelation
Created: 7/21/2025
Status: Merged
Merged: 7/24/2025
Merged by: @jamesgeorge007

Base: nextHead: desktop-feat-portable-app-phase-1-foundational-infra-and-build-system


📝 Commits (4)

  • b8fa1e0 feat(desktop): portable phase-1 foundational: infra & build
  • 8cf08d8 fix(desktop) platform conditions when portable
  • 73be937 fix(kernel): import and export type decl
  • 3739075 fix: remove redundant awaits

📊 Changes

19 files changed (+1078 additions, -125 deletions)

View changed files

📝 packages/hoppscotch-common/src/components.d.ts (+6 -5)
📝 packages/hoppscotch-data/package.json (+1 -1)
packages/hoppscotch-desktop/.eslintrc.cjs (+67 -0)
📝 packages/hoppscotch-desktop/package.json (+21 -3)
📝 packages/hoppscotch-desktop/src-tauri/Cargo.lock (+549 -60)
📝 packages/hoppscotch-desktop/src-tauri/Cargo.toml (+13 -0)
📝 packages/hoppscotch-desktop/src-tauri/build.rs (+17 -0)
📝 packages/hoppscotch-desktop/src-tauri/tauri.conf.json (+1 -1)
packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json (+62 -0)
packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json (+60 -0)
packages/hoppscotch-desktop/src/kernel/index.ts (+13 -0)
packages/hoppscotch-desktop/src/kernel/io.ts (+34 -0)
packages/hoppscotch-desktop/src/kernel/relay.ts (+26 -0)
packages/hoppscotch-desktop/src/kernel/store.ts (+114 -0)
packages/hoppscotch-desktop/src/types/kernel.d.ts (+9 -0)
📝 packages/hoppscotch-desktop/tsconfig.json (+6 -1)
📝 packages/hoppscotch-desktop/vite.config.ts (+18 -17)
📝 packages/hoppscotch-kernel/package.json (+1 -1)
📝 pnpm-lock.yaml (+60 -36)

📄 Description

This is first in a series of architectural overhauls for the Desktop app
to support portable and organizational instances, starting by
transitioning from legacy LazyStore-based data management to a common
kernel-unified persistence, cross-platform path management, automated
data migration, and other foundational portable mode support.

Closes FE-929
Closes FE-930
Closes FE-936

The desktop app right now has a rather fragmented data storage, direct
LazyStore usage throughout the codebase, and no unified system for
cross-platform path management.

Also lack of proper linting infrastructure that exists in
hoppscotch-common or hoppscotch-selfhost-web, etc.

This refactoring addresses these issues and also establishes some
patterns for future development; preparing the groundwork for portable
mode implementation.

This is a first in a series of foundational PRs so this one contains a
ton of inert code that establishes infrastructure patterns, but doesn't
actually do anything substantial from the get-go.

So the currently active code maintains full backward compatibility with
existing user data and workflows to be routed through the migration
systems in the subsequent phases.

Kernel Integration

Added foundational kernel integration that wraps existing platform calls with
unified operations across the app. Created desktop-specific
kernel modules in src/kernel/ including index.ts, io.ts,
relay.ts, and store.ts that provide identical interfaces (as to
hoppscotch-common's kernel directory') for IO ops, requests via
Relay, and data store ops.

// src/kernel/index.ts - Central access
export const getModule = <K extends keyof KernelAPI>(name: K): NonNullable<KernelAPI[K]> => {
  const kernel = window.__KERNEL__
  if (!kernel?.[name]) throw new Error(`Kernel ${String(name)} not initialized`)
  return kernel[name]
}

// src/kernel/store.ts - Dynamic path resolution
const getStorePath = async (): Promise<string> => {
  try {
    const instanceDir = await getInstanceDir()
    return join(instanceDir, STORE_PATH)
  } catch (error) {
    console.error("Failed to get instance directory:", error)
    return "hoppscotch-unified.store"
  }
}

The idea is to initialize kernel in main.ts with
initKernel("desktop") but right now it shall remain inert.
Added TypeScript definitions for kernel globals in
src/types/kernel.d.ts.

The kernel modules currently wrap existing functionality and provide a
foundation for future platform-agnostic development without changing
external behavior.

Backward Compatibility: All existing functionality continues to work
unchanged. The kernel system provides wrappers around existing platform
calls without modifying external behavior. Rigth now this is inert.

ESLint Config / Linting Infra

Added ESLint setup in .eslintrc.cjs with TypeScript and
Vue support, configured rules to prevent localStorage misuse, and added
specific restrictions on direct localStorage access to encourage proper
persistence patterns.

NOTE: This is pretty much identical to the ones in hoppscotch-common
and hoppscotch-web.

// localStorage usage restrictions
"no-restricted-globals": [
  "error", {
    name: "localStorage",
    message: "Do not use 'localStorage' directly. Please use
    localpersistence.ts functions or stores",
  },
],
"no-restricted-syntax": [
  "error", {
    selector: "CallExpression[callee.object.property.name='localStorage']",
    message: "Do not use 'localStorage' directly. Please use
    localpersistence.ts functions or stores",
  },
],

Added linting scripts to package.json including lint, lint:ts,
lintfix, and prod-lint for different development scenarios.
Identical to what is already in hoppscotch-selfhost-web or
hoppscotch-common.

Build Config Updates

Updated package.json scripts and Cargo.toml for portable mode
support with feature flags and proper feature gating. Updated build.rs
to handle different config files based on features and separated
portable and standard build commands.

#[cfg(feature = "portable")]
{
   println!("cargo:rerun-if-changed=tauri.portable.windows.conf.json");
   println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.windows.conf.json");

   println!("cargo:rerun-if-changed=tauri.portable.macos.conf.json");
   println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.macos.conf.json");
}

Added new package scripts: dev:portable, build:portable,
prepare-web, and updated existing scripts for development
workflow. Created separate Tauri configuration file for portable
builds with appropriate bundling settings that disable automatic updater
artifacts for portable distributions.

Backward Compatibility: Standard build process remains identical.
Portable mode builds are new functionality that doesn't affect existing
build pipelines.

Notes to reviewers

This only introduces the foundation for subsequent changes, many of the
dependencies introduced here will remain inert. So testing should
verify data integrity in different user scenarios, cross-platform
functionality on Windows/macOS/Linux, resolution in CI and general data
storage + cleanup, and backward compatibility with existing user data
and workflows.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5259 **Author:** [@CuriousCorrelation](https://github.com/CuriousCorrelation) **Created:** 7/21/2025 **Status:** ✅ Merged **Merged:** 7/24/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `desktop-feat-portable-app-phase-1-foundational-infra-and-build-system` --- ### 📝 Commits (4) - [`b8fa1e0`](https://github.com/hoppscotch/hoppscotch/commit/b8fa1e0fc83a53972f2519afe4151853b35efe1f) feat(desktop): portable phase-1 foundational: infra & build - [`8cf08d8`](https://github.com/hoppscotch/hoppscotch/commit/8cf08d8b82c4ca422e88f4733c0510a6e3bc1810) fix(desktop) platform conditions when `portable` - [`73be937`](https://github.com/hoppscotch/hoppscotch/commit/73be9371c0972f6ee1f4f9d6eccbb7b6e83c54f9) fix(kernel): import and export type decl - [`3739075`](https://github.com/hoppscotch/hoppscotch/commit/373907514695683657e89f8e3d24bcf8301c0eef) fix: remove redundant `await`s ### 📊 Changes **19 files changed** (+1078 additions, -125 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/components.d.ts` (+6 -5) 📝 `packages/hoppscotch-data/package.json` (+1 -1) ➕ `packages/hoppscotch-desktop/.eslintrc.cjs` (+67 -0) 📝 `packages/hoppscotch-desktop/package.json` (+21 -3) 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.lock` (+549 -60) 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.toml` (+13 -0) 📝 `packages/hoppscotch-desktop/src-tauri/build.rs` (+17 -0) 📝 `packages/hoppscotch-desktop/src-tauri/tauri.conf.json` (+1 -1) ➕ `packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json` (+62 -0) ➕ `packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json` (+60 -0) ➕ `packages/hoppscotch-desktop/src/kernel/index.ts` (+13 -0) ➕ `packages/hoppscotch-desktop/src/kernel/io.ts` (+34 -0) ➕ `packages/hoppscotch-desktop/src/kernel/relay.ts` (+26 -0) ➕ `packages/hoppscotch-desktop/src/kernel/store.ts` (+114 -0) ➕ `packages/hoppscotch-desktop/src/types/kernel.d.ts` (+9 -0) 📝 `packages/hoppscotch-desktop/tsconfig.json` (+6 -1) 📝 `packages/hoppscotch-desktop/vite.config.ts` (+18 -17) 📝 `packages/hoppscotch-kernel/package.json` (+1 -1) 📝 `pnpm-lock.yaml` (+60 -36) </details> ### 📄 Description This is first in a series of architectural overhauls for the Desktop app to support portable and organizational instances, starting by transitioning from legacy LazyStore-based data management to a common kernel-unified persistence, cross-platform path management, automated data migration, and other foundational portable mode support. Closes FE-929 Closes FE-930 Closes FE-936 The desktop app right now has a rather fragmented data storage, direct LazyStore usage throughout the codebase, and no unified system for cross-platform path management. Also lack of proper linting infrastructure that exists in `hoppscotch-common` or `hoppscotch-selfhost-web`, etc. This refactoring addresses these issues and also establishes some patterns for future development; preparing the groundwork for portable mode implementation. This is a first in a series of foundational PRs so this one contains a ton of inert code that establishes infrastructure patterns, but doesn't actually do anything substantial from the get-go. So the currently active code maintains full backward compatibility with existing user data and workflows to be routed through the migration systems in the subsequent phases. ### Kernel Integration Added foundational kernel integration that wraps existing platform calls with unified operations across the app. Created desktop-specific kernel modules in `src/kernel/` including `index.ts`, `io.ts`, `relay.ts`, and `store.ts` that provide identical interfaces (as to `hoppscotch-common`'s `kernel` directory') for IO ops, requests via Relay, and data store ops. ```typescript // src/kernel/index.ts - Central access export const getModule = <K extends keyof KernelAPI>(name: K): NonNullable<KernelAPI[K]> => { const kernel = window.__KERNEL__ if (!kernel?.[name]) throw new Error(`Kernel ${String(name)} not initialized`) return kernel[name] } // src/kernel/store.ts - Dynamic path resolution const getStorePath = async (): Promise<string> => { try { const instanceDir = await getInstanceDir() return join(instanceDir, STORE_PATH) } catch (error) { console.error("Failed to get instance directory:", error) return "hoppscotch-unified.store" } } ``` The idea is to initialize kernel in `main.ts` with `initKernel("desktop")` but right now it shall remain inert. Added TypeScript definitions for kernel globals in `src/types/kernel.d.ts`. The kernel modules currently wrap existing functionality and provide a foundation for future platform-agnostic development without changing external behavior. **Backward Compatibility**: All existing functionality continues to work unchanged. The kernel system provides wrappers around existing platform calls without modifying external behavior. Rigth now this is inert. ### ESLint Config / Linting Infra Added ESLint setup in `.eslintrc.cjs` with TypeScript and Vue support, configured rules to prevent localStorage misuse, and added specific restrictions on direct localStorage access to encourage proper persistence patterns. NOTE: This is pretty much identical to the ones in `hoppscotch-common` and `hoppscotch-web`. ```javascript // localStorage usage restrictions "no-restricted-globals": [ "error", { name: "localStorage", message: "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", }, ], "no-restricted-syntax": [ "error", { selector: "CallExpression[callee.object.property.name='localStorage']", message: "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", }, ], ``` Added linting scripts to `package.json` including `lint`, `lint:ts`, `lintfix`, and `prod-lint` for different development scenarios. Identical to what is already in `hoppscotch-selfhost-web` or `hoppscotch-common`. ### Build Config Updates Updated `package.json` scripts and `Cargo.toml` for portable mode support with feature flags and proper feature gating. Updated `build.rs` to handle different config files based on features and separated portable and standard build commands. ```rust #[cfg(feature = "portable")] { println!("cargo:rerun-if-changed=tauri.portable.windows.conf.json"); println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.windows.conf.json"); println!("cargo:rerun-if-changed=tauri.portable.macos.conf.json"); println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.macos.conf.json"); } ``` Added new package scripts: `dev:portable`, `build:portable`, `prepare-web`, and updated existing scripts for development workflow. Created separate Tauri configuration file for portable builds with appropriate bundling settings that disable automatic updater artifacts for portable distributions. **Backward Compatibility**: Standard build process remains identical. Portable mode builds are new functionality that doesn't affect existing build pipelines. ### Notes to reviewers This only introduces the foundation for subsequent changes, many of the dependencies introduced here will remain inert. So testing should verify data integrity in different user scenarios, cross-platform functionality on Windows/macOS/Linux, resolution in CI and general data storage + cleanup, and backward compatibility with existing user data and workflows. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:36:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5131
No description provided.