New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sinix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinix - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.eslintignore

87

bin/sinix.js
#!/usr/bin/env node
const fs = require("fs")
const path = require("path")
const tmp = require("tmp")
const path = require("path")
const archiver = require('archiver')
const [,, ... args] = process.argv
const CONF_PATH = path.join(process.cwd(), "sinix.config.js")
const PACK_PATH = path.join(process.cwd(), "package.json")
const cwd = process.cwd()
const build = () => {
if (!fs.existsSync(PACK_PATH)){
console.log("Not a Node project.")
console.log(`
$ npm init
`)
}
if (!fs.existsSync(CONF_PATH)){
console.log("Not a Sinix application.")
console.log(`
$ sinix init # to initialize
`)
return
}
const config = require(CONF_PATH)
if (!fs.existsSync("release")){
fs.mkdirSync("release");
fs.mkdirSync("release")
}
tmp.file((err, path, fd, cleanupCallback) => {
if (err) throw err;
tmp.file((err, tmp_path) => {
if (err) throw err
const output = fs.createWriteStream(path)
const archive = archiver("tar")
const output = fs.createWriteStream(tmp_path)
const archive = archiver("zip")

@@ -26,4 +44,6 @@ output.on("close", () => {

fs.copyFile(path, "release/app.dext", function(err){
console.log(err)
fs.copyFile(tmp_path, "release/app.dext", function(err){
if(err){
console.log(err)
}
})

@@ -33,3 +53,3 @@ })

output.on("end", () => {
console.log("Data has been drained");
console.log("Data has been drained")
})

@@ -41,3 +61,3 @@

} else {
throw err;
throw err
}

@@ -51,6 +71,29 @@ })

archive.pipe(output)
archive.glob('**', {
if (!fs.existsSync(config.distDir)){
console.log(`${config.distDir} does not exists`)
return
}
const packageJsonObj = JSON.parse(fs.readFileSync("package.json"))
const sinixJsonObj = {
name: packageJsonObj.name,
version: packageJsonObj.version,
title: config.title ? config.title : packageJsonObj.name,
slug: `${packageJsonObj.name}-v${packageJsonObj.version}`
}
const sinixJson = JSON.stringify(sinixJsonObj, null, 2)
process.chdir(config.distDir)
fs.writeFileSync("sinix.manifest.json", sinixJson)
archive.glob("**", {
ignore: ['node_modules/**', 'release/**']
})
process.chdir("../")
archive.finalize()

@@ -60,4 +103,22 @@ })

const init = () => {
const configObj = {
"distDir": "dist/"
}
const config = JSON.stringify(configObj, null, 2)
const code = `module.exports = ${config}`
fs.writeFile("sinix.config.js", code, (err) => {
if(err){
console.log(err)
} else {
console.log("Initialized Sinix project")
}
})
}
switch(args[0]){
case "build": build(); break;
case "build": build(); break
case "init": init(); break
}

7

package.json
{
"name": "sinix",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},

@@ -16,4 +17,6 @@ "bin": {

"archiver": "^5.0.0",
"axios": "^0.20.0",
"eslint": "^7.7.0",
"tmp": "^0.2.1"
}
}

@@ -1,17 +0,68 @@

const all = () => {
console.info("Get all users")
/* eslint-disable */
const axios = require("axios")
const EVENT_OBJ = {}
const poll = (resolve) => {
axios.post("http://localhost:41431/health")
.then((res) => {
resolve()
})
.catch((err) => {
setTimeout(() => {
poll(resolve)
}, 1430)
})
}
const disconnect = (username) => {
console.info("Disconnect specific user")
const register = () => {
return new Promise((resolve, reject) => {
const params = new URLSearchParams()
params.append("username", "sinix")
axios.post("http://localhost:41431/register", params)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
})
}
const listen = (username, event, cb) => {
console.info("Listen for specific event by specific user")
const connect = () => {
const socket = new WebSocket("ws://localhost:41431/ws/sinix")
return socket
}
const setup = new Promise((resolve, reject) => {
poll(async () => {
await register()
const socket = connect()
socket.onmessage = (resp) => {
let { data } = resp
data = JSON.parse(data)
if(EVENT_OBJ[data.event_type]){
EVENT_OBJ[data.event_type](data.payload)
}
}
resolve(socket)
})
})
const listen = (evnt, cb) => {
setup.then((socket) => {
EVENT_OBJ[evnt] = cb
})
}
module.exports = {
all,
disconnect,
listen
listen,
}
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