UNPKG

jayfire

Version:

UI JavaScript components like Reactjs,Anguler,Vue.js and more downloader

85 lines (55 loc) 1.79 kB
#!/usr/bin/env node 'use strict'; var program = require('commander'); var fs = require('fs'); var firebase =require('firebase'); var helpers = require('prettify'); var pretty = require('pretty'); // Initialize Firebase var config = { apiKey: "AIzaSyDrPnqRg4-I2elrksQVKsCA5AvsI9o6Ooc", authDomain: "jayfire-6f261.firebaseapp.com", databaseURL: "https://jayfire-6f261.firebaseio.com", projectId: "jayfire-6f261", storageBucket: "jayfire-6f261.appspot.com", messagingSenderId: "545989780824" }; firebase.initializeApp(config); var database = firebase.database(); program .version('0.1.0') .option('install, --fileName [type]', 'Add the specified type of cheese [marble]', 'marble') .parse(process.argv); var dir = './JayfireUI'; if (!fs.existsSync(dir)){ fs.mkdirSync(dir); } //searchTitle(); searchTitle(program.fileName); var found="no"; function searchTitle (searchin){ var ref2 = firebase.database().ref('Componats'); ref2.orderByChild("title").equalTo(searchin).once("child_added", function(snapshot) { var item = snapshot.val().Code; var newCount= snapshot.val().downloadCount+1; var hopperRef = ref2.child(snapshot.key); hopperRef.update({ "downloadCount": newCount }); fs.writeFile('JayfireUI/'+searchin,item, function (err) { if (err) throw err; console.log('Component Saved!, check JayfireUI folder'); found="yes" process.exit(); }); }); } //process.exit(); function myFunc(arg) { //console.log(`arg was => ${arg}`); if(found=="no"){ console.log('component not found, double check the component title, it is case sensitive'); } process.exit(); } setTimeout(myFunc, 2200, 'funky');