Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
appdirectory
Advanced tools
A cross-platform utility to find the best directory to put data and config files.
The appdirectory npm package is designed to help you find the appropriate directories for storing application data, configuration files, and cache files in a cross-platform manner. It abstracts away the differences between operating systems, providing a consistent API for accessing these directories.
Get User Data Directory
This feature allows you to get the directory path where user-specific data should be stored. The code sample demonstrates how to create an instance of AppDirectory for an application named 'MyApp' and retrieve the user data directory.
const AppDirectory = require('appdirectory');
const dirs = new AppDirectory('MyApp');
console.log(dirs.userData());
Get User Config Directory
This feature allows you to get the directory path where user-specific configuration files should be stored. The code sample shows how to retrieve the user config directory for an application named 'MyApp'.
const AppDirectory = require('appdirectory');
const dirs = new AppDirectory('MyApp');
console.log(dirs.userConfig());
Get User Cache Directory
This feature allows you to get the directory path where user-specific cache files should be stored. The code sample demonstrates how to retrieve the user cache directory for an application named 'MyApp'.
const AppDirectory = require('appdirectory');
const dirs = new AppDirectory('MyApp');
console.log(dirs.userCache());
Get Shared Data Directory
This feature allows you to get the directory path where shared data should be stored. The code sample shows how to retrieve the shared data directory for an application named 'MyApp'.
const AppDirectory = require('appdirectory');
const dirs = new AppDirectory('MyApp');
console.log(dirs.sharedData());
The env-paths package provides similar functionality to appdirectory by offering paths for storing configuration, data, cache, and log files in a cross-platform manner. It is more modern and has a simpler API compared to appdirectory.
The xdg-basedir package focuses on providing paths based on the XDG Base Directory Specification, which is primarily used in Unix-like operating systems. It is more specialized compared to appdirectory, which aims to be cross-platform.
AppDirectory is a port of Python's appdirs module. It can be used as a small cross-platform tool to find the correct directory for an application to use for persistence. It isn't perfect, but it might be useful.
AppDirectory offers one export: the AppDirectory
constructor:
var AppDirectory = require('appdirectory')
var dirs = new AppDirectory('mycoolappname')
AppDirectory
can be instantiated either with a single string (the application's name) or an object containing more information about the application.
var dirs = new AppDirectory({
appName: "mycoolapp", // the app's name, kinda self-explanatory
appAuthor: "Superman", // The author's name, or (more likely) the name of the company/organisation producing this software.
// Only used on Windows, if omitted will default to appName.
appVersion: "v6000", // The version, will be appended to certain dirs to allow for distinction between versions.
// If it isn't present, no version parameter will appear in the paths
useRoaming: true, // Should AppDirectory use Window's roaming directories? (Defaults to false)
platform: "darwin" // You should almost never need to use this, it will be automatically determined
})
Now to get some actual paths.
dirs.userData() // e.g. /home/awesomeuser/Library/Application Support/mycoolapp on Macs
dirs.userConfig() // e.g. /home/awesomeuser/.config/mycoolapp on linux etc.
dirs.userCache() // e.g. C:\Users\awesomeuser\AppData\Local\mycoolapp\mycoolapp\Cache on Windows 7 (and Vista, I believe)
dirs.userLogs() // e.g. /home/awesomeuser/.cache/mycoolapp/log
That's pretty much all there is to it.
Note: All this limitations have been fixed by virtue of removing the site* functions. The aim is to add them back in, at which point they will still exist, as one's a design decision, and the other's unfixable as far as I can tell. However, at this point, there are no known limitations to AppDirectory! (Feel free to tell me about new limitations by filing an issue.)
FAQs
A cross-platform utility to find the best directory to put data and config files.
The npm package appdirectory receives a total of 113,048 weekly downloads. As such, appdirectory popularity was classified as popular.
We found that appdirectory demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.