UNPKG

@betacodd/lighthouse-package

Version:

NPM package and CLI tool to interact with lighthouse protocol

45 lines (44 loc) 1.91 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const path_1 = require("path"); const Lighthouse_1 = __importDefault(require("../Lighthouse")); const getNetwork_1 = require("./utils/getNetwork"); const kleur_1 = require("kleur"); async function default_1(_path, options) { if (!_path) { console.log('lighthouse-web3 create-car <path>\r\n\r\n' + (0, kleur_1.green)('Description: ') + 'Create car for deal making\r\n\r\n' + (0, kleur_1.cyan)('Options:\r\n') + Array(3).fill('\xa0').join('') + '--path: Required, path to file\r\n\r\n' + (0, kleur_1.magenta)('Example:') + Array(3).fill('\xa0').join('') + 'lighthouse-web3 create-car /home/cosmos/Desktop/ILoveAnime.jpg\r\n'); } else { try { const path = (0, path_1.resolve)(process.cwd(), _path); if (fs_1.default.lstatSync(path).isDirectory()) { throw new Error('Directory is not supported'); } else { const apiKey = getNetwork_1.config.get('LIGHTHOUSE_GLOBAL_API_KEY'); if (!apiKey) { throw new Error('Please create api-key first: use api-key command'); } const authToken = (await Lighthouse_1.default.dataDepotAuth(apiKey)).data.access_token; const uploadResponse = await Lighthouse_1.default.createCar(path, authToken); console.log((0, kleur_1.green)('File uploaded successfully!!!')); } } catch (error) { console.log((0, kleur_1.red)(error.message)); } } } exports.default = default_1;