Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@balancy/cli

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balancy/cli - npm Package Compare versions

Comparing version 1.0.0-rc.8 to 1.0.0-rc.9

8

dist/file-helper.class.d.ts
import { CoreVector } from '@balancy/wasm';
import { Balancy } from '@balancy/core';
export declare class Vector<T> implements CoreVector<T> {

@@ -14,3 +13,2 @@ private array;

export declare class FileHelperClass {
private balancy;
private root;

@@ -21,7 +19,7 @@ private readonly cacheDir;

private readonly resourcesDir;
constructor(balancy: Balancy, root: string);
constructor(root: string);
private saveFileToDir;
private clearDir;
private readFileFromDir;
getFilesInFolderCallback(folder: string): CoreVector<string>;
getFilesInFolderCallback(folder: string): string[];
createSubDirectoryInCacheCallback(fileName: string): void;

@@ -39,5 +37,5 @@ saveFileInCacheCallback(fileName: string, data: string): void;

deleteCachedFileCallback(path: string): void;
getFilesInCachedFolderCallback(path: string): CoreVector<string>;
getFilesInCachedFolderCallback(path: string): string[];
applyTempFolderCallback(tempFolder: string): void;
}
//# sourceMappingURL=file-helper.class.d.ts.map

@@ -1,5 +0,5 @@

"use strict";const D=require("commander"),f=require("@balancy/core"),i=require("node:path"),t=require("node:fs"),w=require("node:util"),c=require("mkdirp"),S=require("fs"),y=require("rimraf"),F="1.0.0-rc.7",v="todo";class g{constructor(e){this.array=e}size(){return this.array.length}set(e){throw new Error("readonly array")}push_back(e){this.array.unshift(e)}get(e){return this.array[e]}resize(e,r){throw new Error("not implemented")}reserve(e){throw new Error("not implemented")}}class C{constructor(e,r){this.balancy=e,this.root=r,this.cacheDir=i.resolve(this.root,".cache"),this.cacheBinaryDir=i.resolve(this.root,".cache_binary"),this.codeDir=i.resolve(this.root,"models"),this.resourcesDir=i.resolve(this.root,"resources"),!t.existsSync(this.root)&&c.mkdirpSync(this.root),!t.existsSync(this.cacheDir)&&c.mkdirpSync(this.cacheDir),!t.existsSync(this.cacheBinaryDir)&&c.mkdirpSync(this.cacheBinaryDir),!t.existsSync(this.codeDir)&&c.mkdirpSync(this.codeDir),!t.existsSync(this.resourcesDir)&&c.mkdirpSync(this.resourcesDir)}saveFileToDir(e,r,a){const o=i.resolve(e,r),{dir:p}=i.parse(o);c.mkdirpSync(p),t.writeFileSync(o,a)}clearDir(e){t.readdirSync(e).forEach(r=>{t.lstatSync(i.resolve(e,r)).isDirectory()?y.rimrafSync(i.resolve(e,r)):t.unlinkSync(i.resolve(e,r))})}readFileFromDir(e,r){return S.readFileSync(i.resolve(e,r)).toString("utf-8")}getFilesInFolderCallback(e){const r=t.readdirSync(i.resolve(this.root,e));return new g(r)}createSubDirectoryInCacheCallback(e){c.mkdirpSync(i.resolve(this.cacheDir,e))}saveFileInCacheCallback(e,r){this.saveFileToDir(this.cacheDir,e,r)}saveFileInCacheBinaryCallback(e,r){this.saveFileToDir(this.cacheBinaryDir,e,r)}saveFileInResourcesCallback(e,r){this.saveFileToDir(this.resourcesDir,e,r)}cleanUpResourcesFolderCallback(){this.clearDir(this.resourcesDir)}cleanGeneratedCodeFolderCallback(){this.clearDir(this.codeDir)}saveGeneratedCodeCallback(e,r){this.saveFileToDir(this.codeDir,e,r)}loadFileFromCacheCallback(e){return this.readFileFromDir(this.cacheDir,e)}loadFileFromResourcesCallback(e){return this.readFileFromDir(this.resourcesDir,e)}deleteFolderCallback(e){y.rimrafSync(i.resolve(this.root,e))}deleteCachedFolderCallback(e){y.rimrafSync(i.resolve(this.cacheDir,e))}deleteCachedFileCallback(e){t.unlinkSync(i.resolve(this.cacheDir,e))}getFilesInCachedFolderCallback(e){return new g(t.readdirSync(this.cacheDir))}applyTempFolderCallback(e){throw new Error("not implemented")}}const n=i.resolve(__dirname,"../.cache");t.existsSync(n)||t.mkdirSync(n);async function k(s,e){await w.promisify(t.writeFile).bind(t.writeFile)(i.resolve(n,`${s}.json`),JSON.stringify(e,null,2))}async function b(s){t.unlinkSync(i.resolve(n,`${s}.json`))}async function q(s){if(!t.existsSync(i.resolve(n,`${s}.json`)))return null;const e=await w.promisify(t.readFile).bind(t.readFile)(i.resolve(n,`${s}.json`));return JSON.parse(e.toString())}const m=new D.Command;let d,l,u;function h(s,e){s&&(u==="json"?process.stderr.write(JSON.stringify(s)):(process.stderr.write(s.title),process.stderr.write(`
`+s.message)),process.exit(s.code||1)),e&&(u==="json"?process.stdout.write(JSON.stringify(e)):(process.stdout.write(e.title),e.message&&process.stdout.write(`
`+e.message),e.list&&e.list.forEach(({id:r,name:a})=>{process.stdout.write(`
${r}: ${a}`)})))}m.name("Balancy CLI").description(v).version(F).option("-h, --help","Show help info",!1).option("-f, --format <format>","Output format","raw").hook("preAction",async(s,e)=>{switch(s.optsWithGlobals().format){case"json":u="json";break;default:u="raw"}if(d=await f.instance(),d.getLogger().setLevel(f.LogLevel.Off),l=d.getConfig(),e.name()!=="login"){const r=await q("auth");if(!r)return h({title:"Login failed",message:"please login first",code:403});const{email:a,password:o}=r;if(!await l.setAuthData(a,o))return await b("auth"),h({title:"Login failed",message:"auth data incorrect",code:403})}});m.command("login").requiredOption("-e, --email <email>","Balancy user's email").requiredOption("-p, --password <password>","Balancy user's password").action(async s=>{const{email:e,password:r}=s;await l.setAuthData(e,r)?(await k("auth",{email:e,password:r}),h(null,{title:"Success"})):h({title:"Login failed",message:"auth data incorrect",code:403})});m.command("generate").requiredOption("-p, --path <path>","Path generate to").requiredOption("-g, --game <game>","Game ID").action(async s=>{const{game:e,path:r}=s;d.initializeFileHelper(new C(d,r)),l.selectGame(e),l.generateCode(r,0,(a,o)=>{console.log("generated",{success:a,fileName:o}),h(null,{title:"Success",message:`Generated to ${r} for ${e}`})})});m.command("list").action(async s=>{const e=await l.getGameList();h(null,{title:"Games list",list:e.map(r=>({id:r.getGameId(),name:r.getGameName()}))})});m.parse(process.argv);
"use strict";const D=require("commander"),C=require("@balancy/core"),r=require("node:path"),c=require("node:fs");require("node:util");const d=require("mkdirp"),S=require("fs"),u=require("rimraf"),w="1.0.0-rc.9",F="todo";class k{constructor(e){this.root=e,this.cacheDir=r.resolve(this.root,".balancy_cache"),this.cacheBinaryDir=r.resolve(this.root,".balancy_cache"),this.codeDir=r.resolve(this.root,"assets/balancy/AutoGeneratedCode"),this.resourcesDir=r.resolve(this.root,"assets/balancy/resources"),!c.existsSync(this.root)&&d.mkdirpSync(this.root),!c.existsSync(this.cacheDir)&&d.mkdirpSync(this.cacheDir),!c.existsSync(this.cacheBinaryDir)&&d.mkdirpSync(this.cacheBinaryDir),!c.existsSync(this.codeDir)&&d.mkdirpSync(this.codeDir),!c.existsSync(this.resourcesDir)&&d.mkdirpSync(this.resourcesDir)}saveFileToDir(e,t,i){const s=r.resolve(e,t),{dir:h}=r.parse(s);d.mkdirpSync(h),c.writeFileSync(s,i)}clearDir(e){c.readdirSync(e).forEach(t=>{c.lstatSync(r.resolve(e,t)).isDirectory()?u.rimrafSync(r.resolve(e,t)):c.unlinkSync(r.resolve(e,t))})}readFileFromDir(e,t){try{return S.readFileSync(r.resolve(e,t)).toString("utf-8")}catch{return""}}getFilesInFolderCallback(e){return c.readdirSync(r.resolve(this.root,e))}createSubDirectoryInCacheCallback(e){d.mkdirpSync(r.resolve(this.cacheDir,e))}saveFileInCacheCallback(e,t){this.saveFileToDir(this.cacheDir,e,t)}saveFileInCacheBinaryCallback(e,t){this.saveFileToDir(this.cacheBinaryDir,e,t)}saveFileInResourcesCallback(e,t){this.saveFileToDir(this.resourcesDir,e,t)}cleanUpResourcesFolderCallback(){this.clearDir(this.resourcesDir)}cleanGeneratedCodeFolderCallback(){this.clearDir(this.codeDir)}saveGeneratedCodeCallback(e,t){this.saveFileToDir(this.codeDir,e,t)}loadFileFromCacheCallback(e){return this.readFileFromDir(this.cacheDir,e)}loadFileFromResourcesCallback(e){return this.readFileFromDir(this.resourcesDir,e)}deleteFolderCallback(e){u.rimrafSync(r.resolve(this.root,e))}deleteCachedFolderCallback(e){u.rimrafSync(r.resolve(this.cacheDir,e))}deleteCachedFileCallback(e){c.unlinkSync(r.resolve(this.cacheDir,e))}getFilesInCachedFolderCallback(e){return c.readdirSync(this.cacheDir)}applyTempFolderCallback(e){throw new Error("not implemented")}}const g=r.resolve(__dirname,"..",".cache");c.existsSync(g)||c.mkdirSync(g);const l=new D.Command;let n,p;const v=4;function o(a,e){a&&(p==="json"?process.stderr.write(JSON.stringify(a)):(process.stderr.write(a.title),process.stderr.write(`
`+a.message)),process.exit(a.code||1)),e&&(p==="json"?process.stdout.write(JSON.stringify(e)):(process.stdout.write(e.title),e.message&&process.stdout.write(`
`+e.message),e.list&&e.list.forEach(({id:t,name:i})=>{process.stdout.write(`
${t}: ${i}`)})))}l.name("Balancy CLI").description(F).version(w).option("-h, --help","Show help info",!1).option("-f, --format <format>","Output format","raw").hook("preAction",async(a,e)=>{switch(a.optsWithGlobals().format){case"json":p="json";break;default:p="raw"}n=await C.instanceWasm()});l.command("config-launch").action(async()=>{});function m(a){C.Balancy.initFileHelper(n,new k(a)),n.balancyConfigLaunch(v)}l.command("config-select-game").requiredOption("-g, --game <game>","Game ID").requiredOption("-f, --path <path>","location to save the config file").action(async a=>{try{const{game:e,path:t}=a;m(t),n.balancyConfigSetSelectedGame(e),o(null,{title:"Init Ok"})}catch(e){const t=e;o({title:"Init Failed",message:t==null?void 0:t.message,code:403})}});l.command("config-select-branch").requiredOption("-g, --branch <branch>","Branch ID").requiredOption("-f, --path <path>","location to save the config file").action(async a=>{try{const{branch:e,path:t}=a;m(t),n.balancyConfigSetSelectedBranch(Number(e)),o(null,{title:"Init Ok"})}catch(e){const t=e;o({title:"Init Failed",message:t==null?void 0:t.message,code:403})}});async function B(a,e){return new Promise((t,i)=>{n.balancyConfigAuth(a,e,(s,h)=>{const f=!!s,y=String(h);f?t({isAuthorized:f,message:y}):i(new Error(y||"Authorization failed"))})})}l.command("config-login").requiredOption("-e, --email <email>","Balancy user's email").requiredOption("-p, --password <password>","Balancy user's password").requiredOption("-f, --path <path>","location to save the config file").action(async a=>{const{email:e,password:t,path:i}=a;m(i);try{const s=await B(e,t);o(null,{title:"Auth Success"})}catch(s){const h=s;o({title:"Login Failed",message:h==null?void 0:h.message,code:403})}n.balancyConfigClose()});async function q(){return new Promise((a,e)=>{n.balancyConfigGenerateCode((t,i)=>{a({success:t,message:i})})})}l.command("config-generate").requiredOption("-p, --path <path>","Path generate to").action(async a=>{const{path:e}=a;m(e);const t=await q();t.success?o(null,{title:"Success"}):o({title:"Generation Failed",message:t.message}),n.balancyConfigClose()});async function O(){return new Promise((a,e)=>{n.balancyConfigDownloadContentToResources((t,i)=>{a({success:t,message:i})},(t,i)=>{console.log(`Downloading ${t}: ${i}%`)})})}l.command("config-download").requiredOption("-p, --path <path>","Path download to").action(async a=>{const{path:e}=a;m(e),await b();const t=await O();t.success?o(null,{title:"Success"}):o({title:"Generation Failed",message:t.message}),n.balancyConfigClose()});async function I(){return new Promise((a,e)=>{n.balancyConfigLoadListOfGames(t=>{let i=[];for(let s=0;s<t.size();s+=3)i.push({name:t.get(s),id:t.get(s+1)});a({games:i})})})}l.command("config-list-games").requiredOption("-p, --path <path>","Specify the path").action(async a=>{const{path:e}=a;m(e);const t=await I();o(null,{title:"Games list",list:t.games}),n.balancyConfigClose()});async function b(){return new Promise((a,e)=>{n.balancyConfigLoadBranches(t=>{let i=[];for(let s=0;s<t.size();s+=2)i.push({name:t.get(s),id:t.get(s+1)});a({branches:i})})})}l.command("config-list-branches").requiredOption("-p, --path <path>","Specify the path").action(async a=>{const{path:e}=a;m(e);const t=await b();o(null,{title:"Branches list",list:t.branches}),n.balancyConfigClose()});l.parse(process.argv);
//# sourceMappingURL=index.js.map
{
"name": "@balancy/cli",
"version": "1.0.0-rc.8",
"version": "1.0.0-rc.9",
"homepage": "https://balancy.co",

@@ -22,3 +22,5 @@ "repository": {

"build": "vite build",
"start": "vite build --watch"
"start": "vite build --watch",
"publish:next": "npm publish --tag next --access public",
"publish:last": "npm publish --tag last --access public"
},

@@ -41,3 +43,3 @@ "files": [

"dependencies": {
"@balancy/core": "~1.0.0-rc.8",
"@balancy/core": "~1.0.0-rc.9",
"commander": "^12.1.0",

@@ -52,2 +54,2 @@ "mkdirp": "^3.0.1",

}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc