@splitscript.js/core
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
# 3.0.0 | ||
Switch to a Golang Cli | ||
# 2.3.5 | ||
@@ -2,0 +6,0 @@ |
@@ -1,89 +0,37 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var run_exports = {}; | ||
__export(run_exports, { | ||
child: () => child, | ||
run: () => run | ||
}); | ||
module.exports = __toCommonJS(run_exports); | ||
var import_ansi_colors = __toESM(require("ansi-colors")); | ||
var import_child_process = require("child_process"); | ||
var import_fs = require("fs"); | ||
var import_path = __toESM(require("path")); | ||
let child; | ||
let pids = []; | ||
async function run(main, outdir, root) { | ||
const psList = await import("ps-list"); | ||
const processes = (await psList.default()).filter( | ||
(proc) => proc.name === "node.exe" && pids.includes(proc.ppid) && proc.ppid !== process.pid && proc.pid !== process.pid | ||
); | ||
processes.forEach((proc) => { | ||
process.kill(proc.pid); | ||
}); | ||
pids = []; | ||
if (child) { | ||
child.on("exit", function() { | ||
child = void 0; | ||
}); | ||
} | ||
const parsed = import_path.default.parse(main); | ||
if (!(0, import_fs.existsSync)(import_path.default.join(root, outdir, parsed.name + ".js"))) | ||
return console.error(import_ansi_colors.default.bgRed(" ERROR "), `Could not find ${main}`); | ||
child = (0, import_child_process.spawn)(`node`, [import_path.default.join(root, outdir, parsed.name + ".js")], { | ||
shell: true, | ||
env: { | ||
ROOT: import_path.default.join(root, outdir), | ||
CONFIG_LOCATION: root | ||
} | ||
}); | ||
pids.push(child.pid); | ||
console.log(import_ansi_colors.default.bgGreen(" START "), import_path.default.basename(main)); | ||
if (child.stdout && child.stderr) { | ||
child.stdout.on("data", (chunk) => { | ||
const now = /* @__PURE__ */ new Date(); | ||
const formattedDate = `${now.getMonth() + 1}/${now.getDate()}/${now.getFullYear().toString().substr(-2)} ${now.getHours()}:${now.getMinutes().toString().padStart(2, "0")}`; | ||
process.stdout.write( | ||
`${import_ansi_colors.default.bgGreen(" PRINT ")} ${import_ansi_colors.default.green(formattedDate)} ${chunk}` | ||
); | ||
}); | ||
child.stderr.on("data", (chunk) => { | ||
const now = /* @__PURE__ */ new Date(); | ||
const formattedDate = `${now.getMonth() + 1}/${now.getDate()}/${now.getFullYear().toString().substr(-2)} ${now.getHours()}:${now.getMinutes().toString().padStart(2, "0")}`; | ||
process.stderr.write( | ||
`${import_ansi_colors.default.bgRed(" CRASH ")} ${formattedDate.toString()} ${chunk}` | ||
); | ||
process.exit(1); | ||
}); | ||
} else { | ||
console.log( | ||
import_ansi_colors.default.bgYellow(" DEBUG "), | ||
`Cannot read logs of ${import_ansi_colors.default.gray(import_path.default.basename(main))}` | ||
); | ||
} | ||
#!/bin/node | ||
const { spawn } = require('node:child_process') | ||
const path = require('node:path') | ||
let platform = '' | ||
let arch = '' | ||
let fname = '' | ||
switch (process.platform) { | ||
case 'win32': | ||
platform = 'windows' | ||
break | ||
case 'linux': | ||
case 'darwin': | ||
platform = process.platform | ||
break | ||
default: | ||
throw 'Unsupported os' | ||
} | ||
switch (process.arch) { | ||
case 'arm64': | ||
arch = process.arch | ||
break | ||
case 'x64': | ||
arch = 'amd64' | ||
break | ||
default: | ||
throw 'Unsupported architecture' | ||
} | ||
if (platform === 'windows') { | ||
fname = `${platform}_${arch}.exe` | ||
} else { | ||
fname = `${platform}_${arch}` | ||
} | ||
spawn(path.join(__dirname, fname), [...process.argv.slice(2)], { | ||
stdio: 'inherit' | ||
}) |
@@ -34,7 +34,7 @@ "use strict"; | ||
module.exports = __toCommonJS(events_exports); | ||
var import_fs = __toESM(require("fs")); | ||
var import_promises = __toESM(require("fs/promises")); | ||
var import_node_fs = __toESM(require("node:fs")); | ||
var import_promises = __toESM(require("node:fs/promises")); | ||
var import_node_path = __toESM(require("node:path")); | ||
var import_node_url = require("node:url"); | ||
var import_glob = require("glob"); | ||
var import_path = __toESM(require("path")); | ||
var import_url = require("url"); | ||
var import_ansi_colors = __toESM(require("ansi-colors")); | ||
@@ -64,3 +64,3 @@ var import__ = require("../index.js"); | ||
for (const file of files) { | ||
const url = (0, import_url.pathToFileURL)(file); | ||
const url = (0, import_node_url.pathToFileURL)(file); | ||
import(url.toString()).then((module2) => { | ||
@@ -74,3 +74,3 @@ if (typeof module2.default === "function") { | ||
import_ansi_colors.default.bgRed(" ERROR "), | ||
`Listener ${import_path.default.basename( | ||
`Listener ${import_node_path.default.basename( | ||
file | ||
@@ -84,4 +84,4 @@ )} does not export a function (export default for esm, module.exports = for cjs)` | ||
async listeners(event) { | ||
let funcPath = import_path.default.join((0, import__.root)(), "functions", this.uniqueName); | ||
if (import_fs.default.existsSync(funcPath)) { | ||
let funcPath = import_node_path.default.join((0, import__.root)(), "functions", this.uniqueName); | ||
if (import_node_fs.default.existsSync(funcPath)) { | ||
if (!event) { | ||
@@ -94,3 +94,3 @@ const paths = await (0, import_glob.glob)("/**/*.js", { | ||
path: p, | ||
event: import_path.default.relative(funcPath, p).split(import_path.default.sep).slice(0, -1) | ||
event: import_node_path.default.relative(funcPath, p).split(import_node_path.default.sep).slice(0, -1) | ||
}; | ||
@@ -108,3 +108,3 @@ }); | ||
path: p, | ||
event: import_path.default.relative(funcPath, p).split(import_path.default.sep).slice(0, -1) | ||
event: import_node_path.default.relative(funcPath, p).split(import_node_path.default.sep).slice(0, -1) | ||
}; | ||
@@ -130,8 +130,13 @@ }); | ||
registered.push(uniqueName); | ||
let fname = import_node_path.default.join(process.env.CONFIG_LOCATION ?? (0, import__.root)(), ".ss.json"); | ||
let exists = import_node_fs.default.existsSync(fname); | ||
if (!exists) { | ||
import_node_fs.default.writeFileSync(fname, "{}"); | ||
} | ||
import_promises.default.readFile( | ||
import_path.default.join(process.env.CONFIG_LOCATION ?? (0, import__.root)(), "ss.json"), | ||
fname, | ||
"utf-8" | ||
).then((value) => { | ||
let current = JSON.parse(value); | ||
current.packages[uniqueName] = { | ||
current[uniqueName] = { | ||
validEvents, | ||
@@ -141,18 +146,9 @@ packageName | ||
import_promises.default.writeFile( | ||
import_path.default.join(process.env.CONFIG_LOCATION ?? (0, import__.root)(), "ss.json"), | ||
fname, | ||
JSON.stringify(current, null, " ") | ||
); | ||
}, (err) => { | ||
throw "Failed to write to json " + err; | ||
}).catch((err) => { | ||
let current = { | ||
packages: { | ||
[uniqueName]: { | ||
validEvents, | ||
packageName | ||
} | ||
} | ||
}; | ||
import_promises.default.writeFile( | ||
import_path.default.join(process.env.CONFIG_LOCATION ?? (0, import__.root)(), "ss.json"), | ||
JSON.stringify(current, null, " ") | ||
); | ||
throw "Failed to write to json " + err; | ||
}); | ||
@@ -159,0 +155,0 @@ this.validEvents = Array.from(validEvents); |
@@ -36,3 +36,3 @@ "use strict"; | ||
module.exports = __toCommonJS(node_exports); | ||
var import_path = __toESM(require("path")); | ||
var import_node_path = __toESM(require("node:path")); | ||
var import_actual_require_main = __toESM(require("actual.require.main.filename")); | ||
@@ -44,3 +44,3 @@ var import_variable = __toESM(require("./utils/variable.js")); | ||
return process.env.ROOT; | ||
let rootPath = import_path.default.dirname(import_actual_require_main.default); | ||
let rootPath = import_node_path.default.dirname(import_actual_require_main.default); | ||
if (!dir) | ||
@@ -51,3 +51,3 @@ return import_variable.default.get("root") ?? rootPath; | ||
if (dir) { | ||
import_variable.default.set("root", import_path.default.resolve(dir) ?? rootPath); | ||
import_variable.default.set("root", import_node_path.default.resolve(dir) ?? rootPath); | ||
} | ||
@@ -54,0 +54,0 @@ return import_variable.default.get("root") ?? rootPath; |
@@ -1,6 +0,6 @@ | ||
import fs from "fs"; | ||
import fsp from "fs/promises"; | ||
import fs from "node:fs"; | ||
import fsp from "node:fs/promises"; | ||
import path from "node:path"; | ||
import { pathToFileURL } from "node:url"; | ||
import { glob } from "glob"; | ||
import path from "path"; | ||
import { pathToFileURL } from "url"; | ||
import ansiColors from "ansi-colors"; | ||
@@ -91,8 +91,13 @@ import { root } from "../index.js"; | ||
registered.push(uniqueName); | ||
let fname = path.join(process.env.CONFIG_LOCATION ?? root(), ".ss.json"); | ||
let exists = fs.existsSync(fname); | ||
if (!exists) { | ||
fs.writeFileSync(fname, "{}"); | ||
} | ||
fsp.readFile( | ||
path.join(process.env.CONFIG_LOCATION ?? root(), "ss.json"), | ||
fname, | ||
"utf-8" | ||
).then((value) => { | ||
let current = JSON.parse(value); | ||
current.packages[uniqueName] = { | ||
current[uniqueName] = { | ||
validEvents, | ||
@@ -102,18 +107,9 @@ packageName | ||
fsp.writeFile( | ||
path.join(process.env.CONFIG_LOCATION ?? root(), "ss.json"), | ||
fname, | ||
JSON.stringify(current, null, " ") | ||
); | ||
}, (err) => { | ||
throw "Failed to write to json " + err; | ||
}).catch((err) => { | ||
let current = { | ||
packages: { | ||
[uniqueName]: { | ||
validEvents, | ||
packageName | ||
} | ||
} | ||
}; | ||
fsp.writeFile( | ||
path.join(process.env.CONFIG_LOCATION ?? root(), "ss.json"), | ||
JSON.stringify(current, null, " ") | ||
); | ||
throw "Failed to write to json " + err; | ||
}); | ||
@@ -120,0 +116,0 @@ this.validEvents = Array.from(validEvents); |
@@ -1,2 +0,2 @@ | ||
import path from "path"; | ||
import path from "node:path"; | ||
import filename from "actual.require.main.filename"; | ||
@@ -3,0 +3,0 @@ import variable from "./utils/variable.js"; |
111
package.json
{ | ||
"name": "@splitscript.js/core", | ||
"version": "2.3.6", | ||
"description": "Core SplitScript.js library", | ||
"types": "./dist/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/node/esm/index.js", | ||
"require": "./dist/node/cjs/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"default": "./dist/node/esm/index.js" | ||
} | ||
}, | ||
"bin": { | ||
"splitscript": "./dist/cli/index.js" | ||
}, | ||
"files": [ | ||
"dist", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rm -fr dist/* && tsc && esbuild `find src/node -type f -name \"*.ts\"` --platform='node' --ignore-annotations --format='cjs' --outdir='dist/node/cjs' && esbuild `find src/node -type f -name \"*.ts\"` --platform='node' --ignore-annotations --format='esm' --outdir='dist/node/esm' && cp src/esmpackage.json dist/node/esm/package.json && esbuild `find src/cli -type f -name \"*.ts\"` --format='cjs' --outdir='dist/cli' && cp src/cli/package.json dist/cli/package.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/splitscriptjs/core.git" | ||
}, | ||
"author": "Ultraviolet", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/splitscriptjs/core/issues" | ||
}, | ||
"homepage": "https://splitscript.js.org", | ||
"devDependencies": { | ||
"@types/node": "^20.11.25" | ||
}, | ||
"dependencies": { | ||
"actual.require.main.filename": "^1.0.0", | ||
"ansi-colors": "^4.1.3", | ||
"chokidar": "^3.5.3", | ||
"commander": "^10.0.1", | ||
"enquirer": "^2.3.6", | ||
"esbuild": "0.17", | ||
"glob": "^10.2.2", | ||
"ps-list": "^8.1.1" | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true, | ||
"useTabs": true, | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"trailingComma": "none" | ||
} | ||
"name": "@splitscript.js/core", | ||
"version": "3.0.0", | ||
"description": "Core SplitScript.js library", | ||
"types": "./dist/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/node/esm/index.js", | ||
"require": "./dist/node/cjs/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"default": "./dist/node/esm/index.js" | ||
} | ||
}, | ||
"bin": { | ||
"splitscript": "./dist/cli/run.js" | ||
}, | ||
"files": [ | ||
"dist", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rm -fr dist/* && tsc && npm run build:cjs && npm run build:esm && npm run build:cpyesm && npm run build:cli", | ||
"build:cjs": "esbuild `find src/node -type f -name \"*.ts\"` --platform='node' --ignore-annotations --format='cjs' --outdir='dist/node/cjs'", | ||
"build:esm": "esbuild `find src/node -type f -name \"*.ts\"` --platform='node' --ignore-annotations --format='esm' --outdir='dist/node/esm'", | ||
"build:cpyesm": "cp src/esmpackage.json dist/node/esm/package.json", | ||
"build:cli": "bash buildbinary.sh && cp src/cli/run.js dist/cli/run.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/splitscriptjs/core.git" | ||
}, | ||
"author": "Ultraviolet", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/splitscriptjs/core/issues" | ||
}, | ||
"homepage": "https://splitscript.js.org", | ||
"devDependencies": { | ||
"@types/node": "^20.11.25", | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"actual.require.main.filename": "^1.0.0", | ||
"ansi-colors": "^4.1.3", | ||
"esbuild": "0.17", | ||
"glob": "^10.2.2" | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true, | ||
"useTabs": true, | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"trailingComma": "none" | ||
} | ||
} |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
42180977
74583.03%4
-50%6
-68.42%2
100%20
-4.76%586
-55.2%5
150%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed