mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
chore: UPdate the shell
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Effects } from "../../types";
|
import { Effects } from "../../types";
|
||||||
|
import { parseCommand } from "../../util/parseCommand";
|
||||||
import { CheckResult } from "./CheckResult";
|
import { CheckResult } from "./CheckResult";
|
||||||
export function containsAddress(x: string, port: number) {
|
export function containsAddress(x: string, port: number) {
|
||||||
const readPorts = x
|
const readPorts = x
|
||||||
@@ -25,8 +26,14 @@ export async function checkPortListening(
|
|||||||
} = {}
|
} = {}
|
||||||
): Promise<CheckResult> {
|
): Promise<CheckResult> {
|
||||||
const hasAddress =
|
const hasAddress =
|
||||||
containsAddress(await effects.shell("cat /proc/net/tcp"), port) ||
|
containsAddress(
|
||||||
containsAddress(await effects.shell("cat /proc/net/udp"), port);
|
await effects.runCommand(parseCommand("cat /proc/net/tcp")),
|
||||||
|
port
|
||||||
|
) ||
|
||||||
|
containsAddress(
|
||||||
|
await effects.runCommand(parseCommand("cat /proc/net/udp")),
|
||||||
|
port
|
||||||
|
);
|
||||||
if (hasAddress) {
|
if (hasAddress) {
|
||||||
return { status: "passing", message };
|
return { status: "passing", message };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,10 +129,6 @@ export type Effects = {
|
|||||||
path: string;
|
path: string;
|
||||||
}): Promise<Record<string, unknown>>;
|
}): Promise<Record<string, unknown>>;
|
||||||
|
|
||||||
shell(
|
|
||||||
command: string,
|
|
||||||
options?: { timeoutMillis?: number | null }
|
|
||||||
): Promise<string>;
|
|
||||||
runCommand(input: {
|
runCommand(input: {
|
||||||
command: string;
|
command: string;
|
||||||
args?: string[];
|
args?: string[];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as T from "../types";
|
|||||||
export { guardAll, typeFromProps } from "./propertiesMatcher";
|
export { guardAll, typeFromProps } from "./propertiesMatcher";
|
||||||
export { default as nullIfEmpty } from "./nullIfEmpty";
|
export { default as nullIfEmpty } from "./nullIfEmpty";
|
||||||
export { FileHelper } from "./fileHelper";
|
export { FileHelper } from "./fileHelper";
|
||||||
export { sh } from "./shell";
|
export { parseCommand as sh } from "./parseCommand";
|
||||||
|
|
||||||
/** Used to check if the file exists before hand */
|
/** Used to check if the file exists before hand */
|
||||||
export const exists = (
|
export const exists = (
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ const quoteSeperated = (s: string, quote: typeof quotes) => {
|
|||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function sh(shellCommand: string) {
|
type ValidIfNoStupidEscape<A> = A extends `${string}'"'"'${string}` ? never : A;
|
||||||
|
export function parseCommand<T extends string>(
|
||||||
|
shellCommand: ValidIfNoStupidEscape<T>
|
||||||
|
) {
|
||||||
const [command, ...args] = quoteSeperated(shellCommand, quotes).filter(
|
const [command, ...args] = quoteSeperated(shellCommand, quotes).filter(
|
||||||
Boolean
|
Boolean
|
||||||
);
|
);
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie8",
|
"version": "0.4.0-lib0.charlie9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie8",
|
"version": "0.4.0-lib0.charlie9",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iarna/toml": "^2.2.5",
|
"@iarna/toml": "^2.2.5",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "start-sdk",
|
"name": "start-sdk",
|
||||||
"version": "0.4.0-lib0.charlie8",
|
"version": "0.4.0-lib0.charlie9",
|
||||||
"description": "For making the patterns that are wanted in making services for the startOS.",
|
"description": "For making the patterns that are wanted in making services for the startOS.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user