Closed defiQUG closed 8 months ago
Hello @defiQUG thanks for this. We welcome contributions so please feel free to send a PR across and we can review and add functionality in.
Could you also elaborate on what problem this PR is actually solving please? Unless Im missing something here, this feels more complex than what it needs to be? Could you explain the benefit of simulating files being written before writing them - this feels more like something that belongs in the https://www.npmjs.com/package/tmp or https://www.npmjs.com/package/fs-extra repos maybe ie its boilerplate, rather than app specific. The app stores values in memory till the final phase before they are written and zipped, so if something breaks it fails fast without waiting for the user to confirm etc.
The second problem with this approach is that the cli is used for automation - ie in CI where we don't want a user input as it halts a pipeline, where this will halt the pipeline until the user allows it? The existing approach will attempt a write and if it fails the exit code can be read by the next step in the pipeline which alerts the user of issues.
Cheers
It's a tool I personally have used. This is really for those using the Quorum Dev Quickstart, then using the Genesis Tool to change keys. Honestly, you can put it wherever it is appropriate. I occasionally will share some stuff; but really, I have the FusionAI Orchestrator becoming available soon.
Hi @defiQUG yep that is correct we use this in the quickstart and k8s repos. Im still not sure what problem the PR is solving though or how it addresses the concerns of automation. I'll close this PR if that's ok (feel free to open it if it addresses the concerns raised above). Let us know when the FusionAI Orchestrator is ready
Cheers
A tool which runs a simulation, confirms, creates backup in tar.gz, copy/replaces the existing config with the output from the genesis tool.
Full information for a README:
USER:
Please provide a full description of this typescript tool
ASSISTANT:
Creating a TypeScript-based tool to simulate file operations before actually performing them, especially for tasks like file copying and directory structure alignment, involves a more complex setup than a simple shell script. This is primarily because TypeScript (and JavaScript) runs in a Node.js environment, which is not as directly integrated with the file system and shell operations as bash scripting. However, Node.js provides powerful libraries, such as
fs
for file system operations andchild_process
for executing shell commands, making it possible to create a sophisticated tool for your requirements.Description of the TypeScript Tool
This TypeScript tool will be designed to run on a Node.js environment and will perform the following tasks:
Simulation Phase:
output
directory to theconfig
directory based on the most recent directory withinoutput
.Confirmation:
CONFIRM
to proceed with the actual copying process. If the user does not confirm, the tool will exit without making any changes.Backup Phase:
config
directory's current state. This serves as a backup to restore the original state in case of any issues with the update process.Copy and Replace Phase:
output
directory to theconfig
directory, following the simulation's outline.Technical Considerations
fs
andfs-extra
libraries for reading directories, copying files, and creating the backup archive.readline
or similar libraries for handling user input from the console.archiver
or command-line utilities viachild_process
for creating a backup of theconfig
directory.path
library for managing file paths and ensuring compatibility across different operating systems.Implementation Outline
The tool will be structured into several main components:
config
directory before any changes are made.output
toconfig
after user confirmation.Usage
The tool will be a command-line application executed with Node.js. Users will run it from the terminal in the directory containing both the
config
andoutput
directories. The workflow will be:node [toolName].js
or through an npm script.CONFIRM
when prompted to proceed with the copying and backup creation.Advantages
This TypeScript tool provides a user-friendly interface for reviewing potential file system changes before they occur, along with a straightforward method for confirming those changes. It also ensures that a backup is created, adding a layer of safety to the operation.
Development Requirements
fs-extra
,readline-sync
(or similar), andarchiver
need to be installed via npm.This description outlines a high-level overview of what the tool would look like and how it would function. Implementing such a tool requires writing TypeScript code, compiling it to JavaScript, and then running it with Node.js. It offers a robust and user-interactive way to manage file system operations with the added benefit of cross-platform compatibility.