@flownet/lib-to-electron
v0.3.6
Published
This project provides a set of scripts to help you convert your existing Flownet applications into Electron applications seamlessly. By utilizing this project, developers can package their applications as desktop applications using Electron, allowing them
Downloads
215
Readme
@flownet/lib-to-electron
This project provides a set of scripts to help you convert your existing Flownet applications into Electron applications seamlessly. By utilizing this project, developers can package their applications as desktop applications using Electron, allowing them to reach a wider audience beyond the web.
How It Works
The project works by taking your existing Flownet-based web application and preparing it to be packaged as an Electron application. It automates the process of templating, copying necessary files, and setting up the required project directory structure. After setting up, it installs dependencies and builds the application, making it ready for distribution as a desktop application.
Key Features
- Automatic Templating: Configures your project with a predefined Electron template to ensure consistency and reliability in the setup process.
- Directory Setup: Automatically creates and cleans necessary directories to avoid conflicts and ensure a smooth packaging process.
- Dependency Management: Handles the installation of required dependencies specific to the Electron environment.
- Build Automation: Automates the execution of build scripts to compile the project into an Electron-compatible format.
Conclusion
This utility provides a straightforward way for developers using Flownet to transition their applications into the Electron environment. It simplifies the process of setting up an Electron project, allowing more focus on the development and less on the configuration and setup.
@flownet/lib-to-electron Developer Guide
Overview
The @flownet/lib-to-electron
library is designed to streamline the process of building Electron applications. It provides utility functions to set up necessary directories, manage templates, and automate the build process by integrating with shell commands. This library helps developers quickly scaffold and package their Electron apps.
Installation
To add @flownet/lib-to-electron
to your project, use npm or yarn:
npm install @flownet/lib-to-electron
Or, if you prefer yarn:
yarn add @flownet/lib-to-electron
Usage
The primary function exported by this library is an asynchronous index
function, which you can integrate into your Electron app setup script. This function helps to configure your application’s directories and build processes based on specified parameters.
Real-World Usage Example
Below is a step-by-step example showing how to use the index
function in a typical Electron application setup:
Import the library:
import index from '@flownet/lib-to-electron';
Define the necessary parameters for your project:
const params = { name: "myElectronApp", entry: "app/electron", id: "com.example.electron", version: "1.0.0", }; const config = {}; // Add your configuration options if needed const src = './src'; // Source directory for your app const dest = './build'; // Destination directory for the build
Use the
index
function:async function setup() { try { await index({ params, config, src, dest }); console.log('Electron app successfully set up!'); } catch (error) { console.error('Error setting up Electron app:', error); } } setup();
Run your setup script to scaffold and build your Electron application.
Examples
Here are some concise code examples to illustrate core functionalities:
Setting Up an Electron Application
import index from '@flownet/lib-to-electron';
const params = {
name: "myApp",
entry: "app/main",
id: "com.example.myapp",
version: "1.0.0",
};
const src = './source';
const dest = './output';
(async () => {
try {
await index({ params, src, dest });
} catch (error) {
console.error('Setup failed:', error);
}
})();
This example demonstrates how to use the index
function to prepare an Electron application with specified parameters, source, and destination directories.
Acknowledgements
Special thanks to contributors and any other libraries that indirectly supported the development of this library.
Input Schema
$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
params:
type: object
properties:
name:
type: string
default: electron
description: The name of the application
entry:
type: string
default: app/electron
description: Entry point of the application
id:
type: string
default: com.example.electron
description: Application identifier
version:
type: string
default: 0.1.0
description: Version of the application
title:
type: string
description: Title of the application
package_name:
type: string
description: Package name of the application
author:
type: string
description: Author of the application
description:
type: string
description: Description of the application
vendor:
type: string
default: flownet.ai
description: Vendor information
include_css:
type: boolean
description: Indicates if CSS should be included
bundle_name:
type: string
description: Name of the bundle
package_dir:
type: string
description: Directory of the package
out_dir:
type: string
description: Output directory for the package
config:
type: object
description: Configuration object
src:
type: string
description: Source directory path
dest:
type: string
description: Destination directory path
required:
- params
- src
- dest