diff --git a/packages/get-works/README.md b/packages/get-works/README.md new file mode 100644 index 00000000..43ca28c5 --- /dev/null +++ b/packages/get-works/README.md @@ -0,0 +1,40 @@ +

get-works

+

+ Version + + License: Apache--2.0 + +

+ +> Check if the GET request for the given URL works + +## Install + +```sh +npm install --save get-works +``` + +## Usage + + + +### `getWorks` (function) + +Check if the GET request for the given URL works + +**Parameters:** + +- url (`string`) - The given URL + +**returns:** Promise + + + +## 🤝 Contributing + +You can sponsor my work here: + +https://github.com/sponsors/aminya + +Pull requests, issues and feature requests are welcome. +See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md). diff --git a/packages/ok-status/package.json b/packages/get-works/package.json similarity index 100% rename from packages/ok-status/package.json rename to packages/get-works/package.json diff --git a/packages/ok-status/src/index.ts b/packages/get-works/src/index.ts similarity index 100% rename from packages/ok-status/src/index.ts rename to packages/get-works/src/index.ts diff --git a/packages/ok-status/tsconfig.json b/packages/get-works/tsconfig.json similarity index 100% rename from packages/ok-status/tsconfig.json rename to packages/get-works/tsconfig.json diff --git a/packages/root-tools/README.md b/packages/root-tools/README.md deleted file mode 100644 index 12ed6b6a..00000000 --- a/packages/root-tools/README.md +++ /dev/null @@ -1,76 +0,0 @@ -

root-tools

-

- Version - - License: Apache--2.0 - -

- -> Tools for working with root and sudo such as executing command as root, detecting root, etc. - -## Install - -```sh -npm install --save root-tools -``` - -## Usage - - - -### `isSudo` (function) - -Detect if sudo is available and the user has root privileges - -**returns:** boolean - -### `isRoot` (function) - -Detect if the process has root privileges - -**returns:** boolean - -### `prependSudo` (function) - -Prepend `sudo` to the command if sudo is available - -**Parameters:** - -- command (`string`) - -**returns:** string - -### `execRootSync` (function) - -Execute a command as root if sudo is available. Otherwise executes the command normally without sudo. - -**Parameters:** - -- program (`string`) - The program to spawn -- args (`string[]`) - The command arguments -- execOptions (`execa.SyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` - -**returns:** execa.ExecaSyncReturnValue - -### `execRoot` (function) - -Asynchronously execute a command as root if sudo is available. Otherwise executes the command normally without sudo. - -**Parameters:** - -- program (`string`) - The program to spawn -- args (`string[]`) - The command arguments -- execOptions (`execa.Options`) - The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` - -**returns:** execa.ExecaChildProcess - - - -## 🤝 Contributing - -You can sponsor my work here: - -https://github.com/sponsors/aminya - -Pull requests, issues and feature requests are welcome. -See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md). diff --git a/packages/root-tools/package.json b/packages/root-tools/package.json deleted file mode 100644 index 60e13de1..00000000 --- a/packages/root-tools/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "root-tools", - "version": "1.0.0", - "description": "Tools for working with root and sudo such as executing command as root, detecting root, etc.", - "homepage": "https://github.com/aminya/setup-cpp", - "license": "Apache-2.0", - "author": "Amin Yahyaabadi", - "main": "./dist/index.js", - "source": "./src/index.ts", - "scripts": { - "build": "tsc" - }, - "dependencies": { - "execa": "^5.1.1", - "which": "^2.0.2" - }, - "devDependencies": { - "@types/which": "^2.0.1" - }, - "keywords": [ - "sudo", - "root", - "is-root", - "is-sudo", - "exec-sudo", - "exec-root", - "isroot", - "issudo", - "exec", - "execa", - "spawn", - "system", - "unix", - "linux", - "github-actions", - "github", - "actions", - "gitlab", - "ci" - ] -} diff --git a/packages/root-tools/src/index.ts b/packages/root-tools/src/index.ts deleted file mode 100644 index 4d919a00..00000000 --- a/packages/root-tools/src/index.ts +++ /dev/null @@ -1,60 +0,0 @@ -import which from "which" -import execa from "execa" - -/** Detect if sudo is available and the user has root privileges */ -export function isSudo(): boolean { - return (Boolean(process.env.CI) || isRoot()) && which.sync("sudo", { nothrow: true }) !== null -} - -/** Detect if the process has root privileges */ -export function isRoot(): boolean { - return process.getuid?.() === 0 -} - -/** Prepend `sudo` to the command if sudo is available */ -export function prependSudo(command: string) { - if (isSudo()) { - return `sudo ${command}` - } - return command -} - -/** - * Execute a command as root if sudo is available. Otherwise executes the command normally without sudo. - * - * @param program The program to spawn - * @param args The command arguments - * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` - * @returns The execution result - */ -export function execRootSync( - program: string, - args: string[] = [], - execOptions: execa.SyncOptions = { stdio: "inherit", shell: true } -): execa.ExecaSyncReturnValue { - if (isSudo()) { - return execa.commandSync(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) - } else { - return execa.sync(program, args, execOptions) - } -} - -/** - * Asynchronously execute a command as root if sudo is available. Otherwise executes the command normally without sudo. - * - * @param program The program to spawn - * @param args The command arguments - * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` - * @returns A promise to the execution result - */ -export function execRoot( - program: string, - args: string[] = [], - execOptions: execa.Options = { stdio: "inherit", shell: true } -): execa.ExecaChildProcess { - if (isSudo()) { - return execa.command(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) - } else { - return execa(program, args, execOptions) - } -} diff --git a/packages/root-tools/tsconfig.json b/packages/root-tools/tsconfig.json deleted file mode 100644 index 6a62dbc4..00000000 --- a/packages/root-tools/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./dist" - }, - "include": ["./src"] -}