diff --git a/.github/workflows/deno.yaml b/.github/workflows/deno.yaml
index efc0e30..1047c54 100644
--- a/.github/workflows/deno.yaml
+++ b/.github/workflows/deno.yaml
@@ -16,7 +16,7 @@ jobs:
steps:
- name: Git Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
diff --git a/application.meta.ts b/application.meta.ts
index abc992a..c529f97 100644
--- a/application.meta.ts
+++ b/application.meta.ts
@@ -21,7 +21,7 @@
const Application = {
name: "pup",
- version: "1.0.0-rc.14",
+ version: "1.0.0-rc.15",
url: "https://deno.land/x/pup@$VERSION/pup.ts",
canary_url: "https://raw.githubusercontent.com/Hexagon/pup/main/pup.ts",
deno: null, /* Minimum stable version of Deno required to run Pup (without --unstable-* flags) */
diff --git a/deno.json b/deno.json
index 59197f0..45c4f29 100644
--- a/deno.json
+++ b/deno.json
@@ -27,12 +27,12 @@
"@std/assert": "jsr:@std/assert@^0.221.0",
"@std/async": "jsr:@std/async@^0.221.0",
"@std/io": "jsr:@std/io@^0.221.0",
- "@std/jsonc": "jsr:@std/jsonc@^0.221.0",
"@std/path": "jsr:@std/path@^0.221.0",
"@std/semver": "jsr:@std/semver@^0.221.0",
"@std/testing": "jsr:@std/testing@^0.221.0",
"@std/uuid": "jsr:@std/uuid@^0.221.0",
"dax-sh": "npm:dax-sh@^0.40.0",
+ "json5": "npm:json5@^2.2.3",
"zod": "npm:zod@^3.22.4",
"zod-to-json-schema": "npm:zod-to-json-schema@^3.22.5"
}
diff --git a/docs/src/changelog.md b/docs/src/changelog.md
index 825b1b0..9548437 100644
--- a/docs/src/changelog.md
+++ b/docs/src/changelog.md
@@ -17,13 +17,14 @@ All notable changes to this project will be documented in this section.
- [x] change(cli): Rename cli command `install` to `enable-service`
- [x] change(cli): Rename cli command `uninstall` to `disable-service`
- [ ] change(logging): Make logs streaming by default.
-- [ ] change(config): Support JSON5.
-- [ ] change(packaging): Use jsr.io instead of deno.land/x for distribution.
-- [ ] change(packaging]: Specify installation command for next version in version metadata instead of code, allowing for new installation commands for new versions.
+- [x] change(config): Support JSON5.
### Non-breaking
- [ ] fix(core): Foreground command does not keep an autostarted process running.
+- [x] fix(cli): Controlled output of manual rests after installing/uninstalling as service.
+- [x] fix(docs): Docs incorrectly stated that `**/_._` is default for watcher config. `**/*.*` is correct.
+- [ ] chore(docs): Add a PM2 migration guide.
## Maintenance
diff --git a/docs/src/examples/basic-webinterface/README.md b/docs/src/examples/basic-webinterface/README.md
index feddc7a..fe2be81 100644
--- a/docs/src/examples/basic-webinterface/README.md
+++ b/docs/src/examples/basic-webinterface/README.md
@@ -11,7 +11,7 @@ nav_order: 3
The example at [/docs/src/examples/basic-webinterface](https://github.com/Hexagon/pup/tree/main/docs/src/examples/basic-webinterface) borrows the server.ts and task.ts from the basic example. Both
processes have logging configurations, with the second process having custom logger settings which enable the periodic process to write its logs to separate files.
-The web interface plugin is enabled by `pup.jsonc` and available at
+The web interface plugin is enabled by `pup.json` and available at
## Example Files
@@ -43,7 +43,7 @@ intallation, you **can not** use the `$VERSION` variable, and should give an abs
`cd` to `/docs/src/examples/basic-webinterface` directory.
-Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
+Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Browse to
diff --git a/docs/src/examples/basic/README.md b/docs/src/examples/basic/README.md
index 3a64965..405cdf3 100644
--- a/docs/src/examples/basic/README.md
+++ b/docs/src/examples/basic/README.md
@@ -25,6 +25,6 @@ its logs to separate files.
`cd` to `/docs/src/examples/basic` directory.
-Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
+Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Success!
diff --git a/docs/src/examples/cluster/README.md b/docs/src/examples/cluster/README.md
index ed65774..91204c5 100644
--- a/docs/src/examples/cluster/README.md
+++ b/docs/src/examples/cluster/README.md
@@ -22,7 +22,7 @@ Detailed documentation available at [5. Scaling applications](https://hexagon.gi
`cd` to `/docs/src/examples/cluster` directory.
-Run using command `pup run`
+Run using command `pup foreground`
Browse to `http://localhost:3456`
diff --git a/docs/src/examples/splunk/README.md b/docs/src/examples/splunk/README.md
index 7eb49ee..d22824f 100644
--- a/docs/src/examples/splunk/README.md
+++ b/docs/src/examples/splunk/README.md
@@ -12,7 +12,7 @@ The example at [/docs/src/examples/splunk](https://github.com/Hexagon/pup/tree/m
output to Splunk using the splunk-hec plugin.
> **Note:** If you're connecting to a Splunk HEC server with a bad certificate, such as during testing, you'll need to start pup manually with the `--unsafely-ignore-certificate-errors` flag. The full
-> command for this would be `deno run -Ar --unsafely-ignore-certificate-errors https://deno.land/x/pup/pup.ts run` { .note }
+> command for this would be `deno run -Ar --unsafely-ignore-certificate-errors https://deno.land/x/pup/pup.ts foreground` { .note }
## Files
@@ -29,6 +29,6 @@ The HEC token can be configured in the `pup.jsonc` configuration file as shown i
`cd` to `/docs/src/examples/splunk` directory.
-Start the example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
+Start the example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Success!
diff --git a/docs/src/examples/telemetry/README.md b/docs/src/examples/telemetry/README.md
index a3bd5fd..acd5afc 100644
--- a/docs/src/examples/telemetry/README.md
+++ b/docs/src/examples/telemetry/README.md
@@ -59,7 +59,7 @@ telemetry.emit("another-process-id", "my-event", { data: { to: "send" } })
`cd` to `docs/examples/telemetry` directory.
-Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
+Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Now open another terminal and issue `pup status`, a brief overview of current status is shown, including memory usage.
diff --git a/docs/src/examples/watcher/README.md b/docs/src/examples/watcher/README.md
index e3dde4c..5db4366 100644
--- a/docs/src/examples/watcher/README.md
+++ b/docs/src/examples/watcher/README.md
@@ -21,8 +21,8 @@ current directory (configuration `watch: ["."]`).
`cd` to `/docs/src/examples/watcher` directory.
-Start example by running `pup run` if pup is installed, pup will automatically pick up the configuration in`pup.jsonc`.
+Start example by running `pup foreground` if pup is installed, pup will automatically pick up the configuration in`pup.jsonc`.
-Run something like `deno run -A ../../../pup.ts run` if pup is not installed globally.
+Run something like `deno run -A ../../../pup.ts foreground` if pup is not installed globally.
Success!
diff --git a/docs/src/examples/worker/README.md b/docs/src/examples/worker/README.md
index 805069b..10a2249 100644
--- a/docs/src/examples/worker/README.md
+++ b/docs/src/examples/worker/README.md
@@ -21,7 +21,7 @@ process using a worker. The process has logging configurations to write logs to
`cd` to `/docs/src/examples/worker` directory.
-Start example by running `pup run` if pup is installed, or something like `deno run -A ../../../pup.ts run` if not.
+Start example by running `pup foreground` if pup is installed, or something like `deno run -A ../../../pup.ts foreground` if not.
Success!
diff --git a/docs/src/index.md b/docs/src/index.md
index 39abcef..ffcf3f8 100644
--- a/docs/src/index.md
+++ b/docs/src/index.md
@@ -20,8 +20,8 @@ Pup is a powerful process manager for Deno, designed to simplify the management
> **Note** Programmatic usage, process telemetry, and IPC are currently available only when running Deno client processes. { .note }
-Pup is centered on a single configuration file, ideally named `pup.json` or `pup.jsonc`, which manages all aspects of the processes to be executed, including their execution methods and logging
-handling.
+Pup is centered on a single configuration file, `pup.json`, which manages all aspects of the processes to be executed, including their execution methods and logging handling.
+[JSON5](https://github.com/json5/json5) syntax is supported.
## Quick Start
diff --git a/docs/src/installation.md b/docs/src/installation.md
index 0c29ed3..22aae2b 100644
--- a/docs/src/installation.md
+++ b/docs/src/installation.md
@@ -13,7 +13,7 @@ This section will guide you through the installation process of Pup.
Before proceeding with the installation, ensure that you have the following installed on your system:
-- Deno (version `1.30.x` or higher): You can install Deno by following the official Deno [instructions](https://deno.com/manual/getting_started/installation).
+- Deno (version `1.38.x` or higher): You can install Deno by following the official Deno [instructions](https://deno.com/manual/getting_started/installation).
## Installing or upgrading Pup
@@ -35,7 +35,7 @@ If you already have Pup installed and want to upgrade to the latest version, you
pup upgrade --channel prerelease
```
-Both the `setup` and `upgrade` commands support the following parameters:
+The `upgrade` command support the following parameters:
- `--version`: Install, upgrade, or downgrade to a specific version.
- `--channel `: Defaults to stable, but you can also install the `prerelease` or `canary` channel.
diff --git a/docs/src/usage/configuration.md b/docs/src/usage/configuration.md
index aed806f..37053b3 100644
--- a/docs/src/usage/configuration.md
+++ b/docs/src/usage/configuration.md
@@ -94,7 +94,7 @@ configuration file:
- `console` (boolean): Set to true to enable logging to the console. Default is false.
- `stdout` (string): The file path to write standard output logs.
-- `stderr` (string): The file path to write standard error logs.
+- `stderr` (string): The file path to write standard error logs. If omitted, stderr is redirected to stdout.
- `decorateFiles` (boolean): Set to true to enable decoration in the output files. Default is false.
- `decorate` (boolean): **Only available in global scope.** Set to true to enable decoration in the logs. Default is false.
- `colors` (boolean): **Only available in global scope.** Set to true to enable colored output. Default is false.
@@ -139,7 +139,7 @@ To change default behavior of the global watcher, use the following properties w
- `interval` (number): The interval (in milliseconds) at which the watcher checks for file changes. Default is `1000`.
- `exts` (array of strings): The file extensions to watch. Default is `["ts", "tsx", "js", "jsx", "json"]`.
-- `match` (array of strings): The patterns to match for watched files. Default is `["**/_._"]`.
+- `match` (array of strings): The patterns to match for watched files. Default is `["**/*.*"]`.
- `skip` (array of strings): The patterns to exclude from watching. Default is `["**/.git/**"]`.
```json
@@ -148,7 +148,7 @@ To change default behavior of the global watcher, use the following properties w
"watcher": {
"interval": 100, // default
"exts": ["ts", "tsx", "js", "jsx", "json"], // default
- "match": ["**/_._"], // default
+ "match": ["**/*.*"], // default
"skip": ["**/.git/**"] // default
},
@@ -194,8 +194,8 @@ To activate plugins, add your plugins to the configuration using this pattern:
## Validating the Configuration
-To ensure your configuration is valid, just run `pup run` (or `pup run --config custom/path/to/config.json`). If using pup as a library, you can use the `validateConfiguration()` function provided by
-the `/lib/core/configuration.ts` file. This function checks if the configuration adheres to the schema and will throw an error if it doesn't.
+To ensure your configuration is valid, just run `pup foreground` (or `pup run --config custom/path/to/config.json`). If using pup as a library, you can use the `validateConfiguration()` function
+provided by the `/lib/core/configuration.ts` file. This function checks if the configuration adheres to the schema and will throw an error if it doesn't.
With a valid configuration in place, you're ready to use Pup to manage your processes.
diff --git a/docs/src/usage/service.md b/docs/src/usage/service.md
index 4d18fd6..11dc1f5 100644
--- a/docs/src/usage/service.md
+++ b/docs/src/usage/service.md
@@ -17,7 +17,7 @@ Follow the guide below to install Pup as a system service and launch at boot. Th
### Prerequisites
-Ensure that you have a working environment set up so that you can run `pup run` with a `pup.json` in the current directory, or that you can start Pup using `pup run --config path/to/pup.json`.
+Ensure that you have a working environment set up so that you can run `pup foreground` with a `pup.json` in the current directory, or that you can start Pup using `pup run --config path/to/pup.json`.
Now there is two options, User Mode Installation, or System Installation. User Mode Installation is recommended as it rhymes best with Deno, which is installed for the current user. User mode is only
supported with launchd or systemd.
@@ -34,11 +34,11 @@ Replace `username` with your actual username.
2. Install Pup as a user mode service, named `pup`:
-`pup install`
+`pup enable-service`
To install multiple services, provide a unique name for each instance:
-`pup install --name my-service`
+`pup enable-service --name my-service`
### System Mode Installation
@@ -46,11 +46,11 @@ To install multiple services, provide a unique name for each instance:
1. Install Pup as a system service, by default named `pup`:
-`pup install --system`
+`pup enable-service --system`
To install multiple services, provide a unique name for each instance:
-`pup install --system --name my-service`
+`pup enable-service --system --name my-service`
2. Follow the on-screen instructions to copy the generated configuration file to the correct location, and enable the service.
@@ -59,8 +59,8 @@ To install multiple services, provide a unique name for each instance:
Use the `pup [...flags]` command with the following methods and flags:
- Methods:
- - `install`: Installs the configured Pup instance as a system service, then verifies the installation by enabling and starting the service. Rolls back any changes on error.
- - `uninstall`: Uninstall service
+ - `enable-service`: Installs the configured Pup instance as a system service, then verifies the installation by enabling and starting the service. Rolls back any changes on error.
+ - `disable-service`: Uninstall service
- Flags:
- `--config`: Specifies the configuration file for the instance to be installed, defaulting to `pup.json` or `pup.jsonc` in the current directory.
@@ -144,7 +144,7 @@ Description=Pup
After=network.target
[Service]
-ExecStart=/home/user/.deno/bin/deno run -A https://deno.land/x/pup/pup.ts run --config /path/to/your/pup.json
+ExecStart=/home/user/.deno/bin/deno run -A https://deno.land/x/pup/`pup.ts foreground` --config /path/to/your/pup.json
Restart=always
[Install]
diff --git a/lib/cli/config.ts b/lib/cli/config.ts
index 8e66157..17e3435 100644
--- a/lib/cli/config.ts
+++ b/lib/cli/config.ts
@@ -7,7 +7,7 @@
*/
import { Configuration, generateConfiguration, ProcessConfiguration } from "../core/configuration.ts"
-import * as jsonc from "@std/jsonc"
+import JSON5 from "npm:json5"
import { join } from "@std/path"
import { exists } from "@cross/fs"
import { ArgsParser } from "@cross/utils"
@@ -55,7 +55,7 @@ export async function appendConfigurationFile(configFile: string, checkedArgs: A
let existingConfigurationObject
try {
const existingConfiguration = await Deno.readTextFile(configFile)
- existingConfigurationObject = jsonc.parse(existingConfiguration) as unknown as Configuration
+ existingConfigurationObject = JSON5.parse(existingConfiguration) as unknown as Configuration
} catch (e) {
throw new Error("Could not read configuration file: " + e.message)
}
@@ -109,7 +109,7 @@ export async function removeFromConfigurationFile(configFile: string, checkedArg
let existingConfigurationObject
try {
const existingConfiguration = await Deno.readTextFile(configFile)
- existingConfigurationObject = jsonc.parse(existingConfiguration) as unknown as Configuration
+ existingConfigurationObject = JSON5.parse(existingConfiguration) as unknown as Configuration
} catch (e) {
throw new Error("Could not read configuration file.", e.message)
}
@@ -155,15 +155,15 @@ export async function findConfigFile(cwd: string, useConfigFile?: boolean, argum
}
}
- // Try to find configuration file, jsonc first. Take cwd into account.
+ // Try to find configuration file, JSON5 first. Take cwd into account.
let jsonPath = "./pup.json"
- let jsoncPath = "./pup.jsonc"
+ let JSON5Path = "./pup.JSON5"
if (cwd) {
jsonPath = join(toResolvedAbsolutePath(cwd), jsonPath)
- jsoncPath = join(toResolvedAbsolutePath(cwd), jsoncPath)
+ JSON5Path = join(toResolvedAbsolutePath(cwd), JSON5Path)
}
- if (await exists(jsoncPath)) {
- return jsoncPath
+ if (await exists(JSON5Path)) {
+ return JSON5Path
} else {
return jsonPath
}
diff --git a/lib/cli/main.ts b/lib/cli/main.ts
index 203fadb..e1c6e41 100644
--- a/lib/cli/main.ts
+++ b/lib/cli/main.ts
@@ -22,14 +22,14 @@ import { toPersistentPath, toResolvedAbsolutePath, toTempPath } from "../common/
import { exists, readFile } from "@cross/fs"
// Import external dependencies
-import * as jsonc from "@std/jsonc"
+import JSON5 from "json5"
import * as path from "@std/path"
import { Logger } from "../core/logger.ts"
import { args } from "@cross/utils/args"
import { installService, uninstallService } from "@cross/service"
-import { exit } from "@cross/utils"
+import { Colors, exit } from "@cross/utils"
import { chdir, cwd } from "@cross/fs"
/**
@@ -144,7 +144,18 @@ async function main() {
const env = parsedArgs.getArray("env") || []
try {
- await installService({ system, name, cmd, cwd, user, home, env }, parsedArgs.getBoolean("dry-run"))
+ const result = await installService({ system, name, cmd, cwd, user, home, env }, parsedArgs.getBoolean("dry-run"))
+ if (result.manualSteps && result.manualSteps.length) {
+ console.log(Colors.bold("To complete the installation, carry out these manual steps:"))
+ result.manualSteps.forEach((step, index) => {
+ console.log(Colors.cyan(`${index + 1}. ${step.text}`))
+ if (step.command) {
+ console.log(" " + Colors.yellow("Command: ") + step.command)
+ }
+ })
+ } else {
+ console.log(`Service ยด${name}' successfully installed at '${result.servicePath}'.`)
+ }
exit(0)
} catch (e) {
console.error(`Could not install service, error: ${e.message}`)
@@ -154,10 +165,19 @@ async function main() {
const system = parsedArgs.getBoolean("system")
const name = parsedArgs.get("name") || "pup"
const home = parsedArgs.get("home")
-
try {
- await uninstallService({ system, name, home })
- console.log(`Service '${name}' uninstalled.`)
+ const result = await uninstallService({ system, name, home })
+ if (result.manualSteps && result.manualSteps.length) {
+ console.log(Colors.bold("To complete the uninstallation, carry out these manual steps:"))
+ result.manualSteps.forEach((step, index) => {
+ console.log(Colors.cyan(`${index + 1}. ${step.text}`))
+ if (step.command) {
+ console.log(" " + Colors.yellow("Command: ") + step.command)
+ }
+ })
+ } else {
+ console.log(`Service '${name}' at '${result.servicePath}' is now uninstalled.`)
+ }
exit(0)
} catch (e) {
console.error(`Could not uninstall service, error: ${e.message}`)
@@ -169,8 +189,8 @@ async function main() {
* Now, handle the argument to generate a new configuration file and exit
*/
if (baseArgument === "init") {
- // Default new configuration file to pup.jsonc
- const fallbackedConfigFile = configFile ?? "pup.jsonc"
+ // Default new configuration file to pup.json
+ const fallbackedConfigFile = configFile ?? "pup.json"
if (await exists(fallbackedConfigFile)) {
console.error(`Configuration file '${fallbackedConfigFile}' already exists, exiting.`)
exit(1)
@@ -234,7 +254,7 @@ async function main() {
try {
const rawConfig = await readFile(configFile)
const rawConfigText = new TextDecoder().decode(rawConfig)
- configuration = validateConfiguration(jsonc.parse(rawConfigText))
+ configuration = validateConfiguration(JSON5.parse(rawConfigText))
} catch (e) {
console.error(`Could not start, error reading or parsing configuration file '${configFile}': ${e.message}`)
exit(1)
diff --git a/lib/cli/output.ts b/lib/cli/output.ts
index c38605d..0848adb 100644
--- a/lib/cli/output.ts
+++ b/lib/cli/output.ts
@@ -47,7 +47,7 @@ export function createFlagsMessage(externalInstaller: boolean): string {
{ long: "disable-service", description: "Uninstall pup service" },
{ separator: "empty" },
{ short: "-c", long: "--config ", description: "Optional. Use specific configuration file." },
- { description: "Default: ./pup.jsonc or ./pup.json" },
+ { description: "Default: ./pup.json" },
{ long: "--dry-run", description: "Generate and output service configuration, do not actually install the service" },
{ long: "--system", description: "Optional. Install the service system-wide (requires root)." },
{ long: "--cwd", description: "Optional. Set working directory for service" },
@@ -67,7 +67,7 @@ export function createFlagsMessage(externalInstaller: boolean): string {
{ long: "--severity ", description: "Optional. Filter logs based on the severity level." },
{ long: "--start ", description: "Display logs after a specified timestamp." },
{ long: "--end ", description: "Display logs before a specific timestamp." },
- { description: "Default: ./pup.jsonc or ./pup.json" },
+ { description: "Default: ./pup.json" },
{ separator: "empty" },
{ content: "Configuration helpers", spanStart: 1 },
{ separator: "empty" },
@@ -77,7 +77,7 @@ export function createFlagsMessage(externalInstaller: boolean): string {
{ description: "configure using the flags below." },
{ separator: "empty" },
{ short: "-c", long: "--config ", description: "Optional. Use specific configuration file." },
- { description: "Default: ./pup.jsonc or ./pup.json" },
+ { description: "Default: ./pup.json" },
{ short: "-I", long: "--id", description: "Id of the process to add/append/remove from configuration." },
{ short: "-C", long: "--cmd", description: "Command to run, for complex commands use '--' then the command." },
{ short: "-W", long: "--worker", description: "Worker script to run, any trailing arguments are passed to the worker" },
diff --git a/lib/common/utils.ts b/lib/common/utils.ts
index cd29106..a7c8c7d 100644
--- a/lib/common/utils.ts
+++ b/lib/common/utils.ts
@@ -25,7 +25,7 @@ export function toResolvedAbsolutePath(path: string, cwdInput?: string) {
*/
export async function toTempPath(configFile: string) {
const resolvedPath = parse(toResolvedAbsolutePath(configFile))
- const tempPath = toResolvedAbsolutePath(`${resolvedPath.dir}/.${resolvedPath.name}${resolvedPath.ext}-tmp`)
+ const tempPath = toResolvedAbsolutePath(`${resolvedPath.dir}/.pup/${resolvedPath.name}${resolvedPath.ext}-tmp`)
await mkdir(tempPath, { recursive: true })
return tempPath
}
@@ -38,7 +38,7 @@ export async function toTempPath(configFile: string) {
*/
export async function toPersistentPath(configFile: string) {
const resolvedPath = parse(toResolvedAbsolutePath(configFile))
- const persistentStoragePath = resolve(`${resolvedPath.dir}/.${resolvedPath.name}${resolvedPath.ext}-data`)
+ const persistentStoragePath = resolve(`${resolvedPath.dir}/.pup/${resolvedPath.name}${resolvedPath.ext}-data`)
await mkdir(persistentStoragePath, { recursive: true })
return persistentStoragePath
}
diff --git a/lib/core/runner.ts b/lib/core/runner.ts
index 85f4986..87a9a72 100644
--- a/lib/core/runner.ts
+++ b/lib/core/runner.ts
@@ -38,8 +38,8 @@ class Runner extends BaseRunner {
runningCallback()
- this.pipeToLogger("stdout", this.process.stdout())
- this.pipeToLogger("stderr", this.process.stderr())
+ this.pipeToLogger("stdout", this.process.stdout() as ReadableStream)
+ this.pipeToLogger("stderr", this.process.stderr() as ReadableStream)
const result = await this.waitForProcessEnd()
diff --git a/telemetry.ts b/telemetry.ts
index 9eed00a..2d9939b 100644
--- a/telemetry.ts
+++ b/telemetry.ts
@@ -31,7 +31,7 @@
import { EventEmitter, EventHandler } from "./lib/common/eventemitter.ts"
import { FileIPC } from "./lib/common/ipc.ts"
-import { dirExists } from "./lib/common/utils.ts"
+import { exists, isDir } from "@cross/fs"
export interface TelemetryData {
sender: string
@@ -85,7 +85,7 @@ export class PupTelemetry {
const pupTempPath = Deno.env.get("PUP_TEMP_STORAGE")
const pupProcessId = Deno.env.get("PUP_PROCESS_ID")
- if (pupTempPath && (await dirExists(pupTempPath)) && pupProcessId) {
+ if (pupTempPath && (await exists(pupTempPath)) && pupProcessId) {
const data: TelemetryData = {
sender: pupProcessId,
memory: Deno.memoryUsage(),
@@ -102,7 +102,7 @@ export class PupTelemetry {
const pupTempPath = Deno.env.get("PUP_TEMP_STORAGE")
const pupProcessId = Deno.env.get("PUP_PROCESS_ID")
- if (pupTempPath && (await dirExists(pupTempPath)) && pupProcessId) {
+ if (pupTempPath && (await isDir(pupTempPath)) && pupProcessId) {
const ipcPath = `${pupTempPath}/.${pupProcessId}.ipc` // Process-specific IPC path
this.ipc = new FileIPC(ipcPath)
@@ -157,7 +157,7 @@ export class PupTelemetry {
async emit(targetProcessId: string, event: string, eventData?: T) {
const pupTempPath = Deno.env.get("PUP_TEMP_STORAGE")
- if (pupTempPath && (await dirExists(pupTempPath)) && targetProcessId) {
+ if (pupTempPath && (await isDir(pupTempPath)) && targetProcessId) {
const ipcPath = `${pupTempPath}/.${targetProcessId}.ipc` // Target process IPC path
// Create a temporary IPC to send the message
diff --git a/test/cli/args.test.ts b/test/cli/args.test.ts
index 7931e6f..19dc9ce 100644
--- a/test/cli/args.test.ts
+++ b/test/cli/args.test.ts
@@ -56,7 +56,7 @@ Deno.test("String options and aliases are parsed correctly", () => {
assertEquals(parsedArgs.get("cmd"), "command")
assertEquals(parsedArgs.getBoolean("dry-run"), true)
})
-/*
+
Deno.test("checkArguments should throw error when autostart argument is provided without init, append or --cmd", async () => {
const args = new ArgsParser(["--cron"])
assertThrows(
@@ -68,6 +68,7 @@ Deno.test("checkArguments should throw error when autostart argument is provided
)
})
+/*
Deno.test("checkArguments should throw error when cron argument is provided without init or append", async () => {
const args = new ArgsParser(["cron"])
assertThrows(
diff --git a/test/common/ipc.test.ts b/test/common/ipc.test.ts
index eb1287c..250c24a 100644
--- a/test/common/ipc.test.ts
+++ b/test/common/ipc.test.ts
@@ -1,6 +1,6 @@
import { assertEquals } from "@std/assert"
import { FileIPC } from "../../lib/common/ipc.ts"
-import { fileExists } from "../../lib/common/utils.ts"
+import { exists } from "@cross/fs"
const TEST_FILE_PATH = "./test_data_FileIPC.ipctest"
const TEST_STALE_LIMIT = 2000
@@ -10,7 +10,7 @@ Deno.test({
async fn() {
const fileIPC = new FileIPC(TEST_FILE_PATH)
await fileIPC.sendData("test data")
- const fileExistsResult = await fileExists(TEST_FILE_PATH)
+ const fileExistsResult = await exists(TEST_FILE_PATH)
assertEquals(fileExistsResult, true)
await fileIPC.close()
},
@@ -78,7 +78,7 @@ Deno.test({
const fileIPC = new FileIPC(TEST_FILE_PATH)
await fileIPC.sendData("test data")
await fileIPC.close()
- const fileExistsResult = await fileExists(TEST_FILE_PATH)
+ const fileExistsResult = await exists(TEST_FILE_PATH)
assertEquals(fileExistsResult, false)
},
})
@@ -89,7 +89,7 @@ Deno.test({
const fileIPC = new FileIPC(TEST_FILE_PATH)
await fileIPC.sendData("test data")
await fileIPC.close(true)
- const fileExistsResult = await fileExists(TEST_FILE_PATH)
+ const fileExistsResult = await exists(TEST_FILE_PATH)
assertEquals(fileExistsResult, true)
await Deno.remove(TEST_FILE_PATH)
},
@@ -101,7 +101,7 @@ Deno.test({
const fileIPC = new FileIPC(TEST_FILE_PATH)
await fileIPC.sendData("test data")
await fileIPC.close(true)
- const fileExistsResult = await fileExists(TEST_FILE_PATH)
+ const fileExistsResult = await exists(TEST_FILE_PATH)
assertEquals(fileExistsResult, true)
await Deno.remove(TEST_FILE_PATH)
},
@@ -113,7 +113,7 @@ Deno.test({
const fileIPC = new FileIPC(TEST_FILE_PATH)
await fileIPC.sendData("test data")
await fileIPC.close(true)
- const fileExistsResult = await fileExists(TEST_FILE_PATH)
+ const fileExistsResult = await exists(TEST_FILE_PATH)
assertEquals(fileExistsResult, true)
await Deno.remove(TEST_FILE_PATH)
},
diff --git a/test/common/utils.test.ts b/test/common/utils.test.ts
deleted file mode 100644
index 9731989..0000000
--- a/test/common/utils.test.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { dirExists, fileExists } from "../../lib/common/utils.ts"
-import { assertEquals } from "@std/assert"
-
-Deno.test("dirExists - Directory exists", async () => {
- const tempDir = await Deno.makeTempDir()
-
- const exists = await dirExists(tempDir)
- assertEquals(exists, true)
-
- await Deno.remove(tempDir)
-})
-
-Deno.test("dirExists - Directory does not exist", async () => {
- const tempDir = await Deno.makeTempDir()
- await Deno.remove(tempDir)
-
- const exists = await dirExists(tempDir)
- assertEquals(exists, false)
-})
-
-Deno.test("dirExists - Non-NotFound error occurs", async () => {
- const invalidDir = "\0"
-
- let errorOccurred = false
- try {
- await dirExists(invalidDir)
- } catch (_e) {
- errorOccurred = true
- }
- assertEquals(errorOccurred, true)
-})
-
-Deno.test("dirExists - Path exists but is not a directory", async () => {
- const tempFile = await Deno.makeTempFile()
-
- const exists = await dirExists(tempFile)
- assertEquals(exists, false)
-
- await Deno.remove(tempFile)
-})
-
-Deno.test("fileExists - File exists", async () => {
- const tempFile = await Deno.makeTempFile()
-
- const exists = await fileExists(tempFile)
- assertEquals(exists, true)
-
- await Deno.remove(tempFile)
-})
-
-Deno.test("fileExists - File does not exist", async () => {
- const tempFile = await Deno.makeTempFile()
- await Deno.remove(tempFile)
-
- const exists = await fileExists(tempFile)
- assertEquals(exists, false)
-})
-
-Deno.test("fileExists - Non-NotFound error occurs", async () => {
- const invalidFile = "\0"
-
- let errorOccurred = false
- try {
- await fileExists(invalidFile)
- } catch (_e) {
- errorOccurred = true
- }
- assertEquals(errorOccurred, true)
-})
-
-Deno.test("fileExists - Path exists but is not a file", async () => {
- const tempDir = await Deno.makeTempDir()
-
- const exists = await fileExists(tempDir)
- assertEquals(exists, false)
-
- await Deno.remove(tempDir)
-})