Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cliId: uuidv4(),
};
if (!globalConfOptions.defaults) {
globalConfOptions = {
...globalConfOptions,
defaults: globalStateDefaults,
};
}
globalState = new Conf.default(globalConfOptions);
// frecency
if (globalState instanceof Conf.default) {
const { _options: options } = globalState as typeof globalState & {
_options: { projectName: string };
};
const storageProviderFrecencyFilePath = envPaths(options.projectName).cache; // store frecency in cache, it is disposable
if (willPrintDebugMessages) {
console.log({
storageProviderFrecencyFilePath,
globalStatePath: globalState.path,
});
}
const storageProvider = new LocalStorage(storageProviderFrecencyFilePath);
accessGlobalFrecency = key =>
new Frecency({
key,
storageProvider,
idAttribute: 'value',
...frecencyOpts,
});
}
async function checkOptIn(interactive: boolean): Promise {
// disable via env var for local development
if (module.exports.DISABLE_TELEMETRY) return undefined;
const project = new ProjectFile();
const localOptIn = project.telemetryOptIn;
const { data: globalDataDir } = envPaths('openzeppelin-sdk');
const globalDataPath = path.join(globalDataDir, 'telemetry.json');
let globalOptions: GlobalTelemetryOptions | undefined = await fs.readJson(globalDataPath).catch(() => undefined);
if (localOptIn === false) return undefined;
// disable interactivity manually for tests and CI
if (DISABLE_INTERACTIVITY) interactive = false;
if (globalOptions === undefined && interactive) {
const { optIn } = await inquirer.prompt({
name: 'optIn',
type: 'confirm',
message:
'Would you like to contribute anonymous usage data to help us improve the OpenZeppelin CLI? Learn more at https://zpl.in/telemetry',
default: true,
});
constructor(debug=false) {
let isWin = /^win/.test(process.platform);
let paths = this.paths = { base: envPaths("Songbee", { suffix: "" }) };
Object.assign(this.paths, {
downloads: path.join(paths.base.cache, "downloads"),
});
this.playlist = [];
this.webtorrent = new WebTorrent();
this.player = new MPV({
audio_only: !debug,
socket: isWin ? WINDOWS_SOCKET : "/tmp/songbeempv.sock",
debug: debug,
});
this.releases = {};
this._trackShift = 0;
}
if (values[key]) {
const name = `CORE_PATH_${key.toUpperCase()}`;
let path = resolve(expandHomeDir(values[key]));
if (namespace) {
path += `/${this.variables.network}`;
}
if (process.env[name] === undefined) {
process.env[name] = path;
ensureDirSync(path);
}
}
});
createPathVariables(envPaths(this.variables.token, { suffix: "core" }), this.variables.network);
}
private getEnvPaths(flags: CommandFlags): Paths {
return envPaths(flags.token, { suffix: "core" });
}
}
export function getConfigPath() {
if (configPath) {
return configPath;
}
const configName = 'sqlectron.json';
const oldConfigPath = path.join(homedir(), `.${configName}`);
if (fileExistsSync(oldConfigPath)) {
configPath = oldConfigPath;
} else {
const newConfigDir = envPaths('Sqlectron', { suffix: '' }).config;
configPath = path.join(newConfigDir, configName);
}
return configPath;
}
async function main() {
const historian = createHistorian(
path.join(envPaths(packageJson.name).cache, 'history')
)
const moduler = createModuler(
path.join(envPaths(packageJson.name).cache, 'packages')
)
const ask = createAsk(
moduler,
process.stdin,
process.stdout
)
const {
context,
contextIdPromise,
evaluate,
import envPaths from 'env-paths';
import { name } from './name';
export const paths = envPaths(name.cli, { suffix: '' });
get cacheFile() {
if (this.opts.cacheFile) return this.opts.cacheFile
return require('env-paths')('kopy-cache').config
}