Skip to content

Commit

Permalink
Path fixes. Revert schema.json location.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 15, 2024
1 parent 3175176 commit b626981
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test.jsonc
.*-data
.*-tmp
test.sh
.pup

# Pup test files
test_data_*.*
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"/pup.json",
"/pup.jsonc"
],
"url": "https://jsr.io/@pup/pup/1.0.0-rc.20/docs/pup.schema.json"
"url": "https://deno.land/x/pup/docs/pup.schema.json"
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _For detailed documentation, visit [pup.56k.guru](https://pup.56k.guru)._
To install Pup, open your terminal and execute the following command:

```bash
deno run -Ar jsr:@pup/[email protected].20 setup --channel prerelease
deno run -Ar jsr:@pup/[email protected].21 setup --channel prerelease
```

This command downloads the latest version of Pup and installs it on your system. The `--channel prerelease` option is included as there is no stable version of Pup yet. Read more abour release
Expand Down
2 changes: 1 addition & 1 deletion application.meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const Application = {
name: "pup",
version: "1.0.0-rc.20",
version: "1.0.0-rc.21",
url: "jsr:@pup/pup@$VERSION",
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) */
Expand Down
6 changes: 4 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@pup/pup",
"version": "1.0.0-rc.20",
"version": "1.0.0-rc.21",
"exports": {
".": "./pup.ts",
"./mod.ts": "./mod.ts"
"./mod.ts": "./mod.ts",
"./plugins/splunk-hec/mod.ts": "./plugins/splunk-hec/mod.ts"
},

"fmt": {
Expand Down Expand Up @@ -32,6 +33,7 @@
"imports": {
"@cross/env": "jsr:@cross/env@^1.0.0",
"@cross/fs": "jsr:@cross/fs@^0.0.9",
"@cross/runtime": "jsr:@cross/runtime@^1.0.0",
"@cross/service": "jsr:@cross/service@^1.0.0",
"@cross/test": "jsr:@cross/test@^0.0.9",
"@cross/utils": "jsr:@cross/utils@^0.11.0",
Expand Down
6 changes: 6 additions & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ nav_order: 13

All notable changes to this project will be documented in this section.

## [1.0.0-rc.21] - 2024-04-15

- fix(runner): Always pass all environment variables from pup environment to sub process
- fix(runner): Use correct PATH separator when spawning child processes in Windows
- fix(docs): Revert to using deno.land/x as source for schema.json, until first stable release

## [1.0.0-rc.20] - 2024-04-14

- fix(plugins): Export plugin entrypoints on jsr.io
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/basic/pup.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// Completely optional: Include $schema to get auto completion in VS Code etc...
"$schema": "https://jsr.io/@pup/pup/1.0.0-rc.20/docs/pup.schema.json",
"$schema": "https://deno.land/x/pup/docs/pup.schema.json",

// Global logger configuration, all options can be ovverridden per process
"logger": {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pup is centered on a single configuration file, `pup.json`, which manages all as
To install Pup, open your terminal and execute the following command:

```bash
deno run -Ar jsr:@pup/[email protected].20 setup --channel prerelease
deno run -Ar jsr:@pup/[email protected].21 setup --channel prerelease
```

This command downloads the latest version of Pup and installs it on your system. The `--channel prerelease` option is included as there is no stable version of Pup yet. Read more abour release
Expand Down
2 changes: 1 addition & 1 deletion docs/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Before proceeding with the installation, ensure that you have the following inst
To install Pup, open your terminal and execute the following command:

```bash
deno run -Ar jsr:@pup/[email protected].20 setup --channel prerelease
deno run -Ar jsr:@pup/[email protected].21 setup --channel prerelease
```

This command downloads the latest version of Pup and installs it on your system.
Expand Down
7 changes: 4 additions & 3 deletions docs/src/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ Here's a list of available configuration options for each process:
- `cmd` (optional): A string containing the full command to run, supporting common shell features such as `&&` for chaining through [dax](https://github.com/dsherret/dax).
- `worker` (optional): A string containing the worker script as first entry.
- `cwd` (optional): The working directory for the process.
- `env` (optional): An object containing environment variables for the process.
- `path` (optional): Extra paths that will be **appended** to `PATH` for this process.
- `env` (optional): An object containing extended environment variables for the process. This will **override** environment variables conflicting with existing ones, except `PATH` that will be
**appended**.
- `path` (optional): Extra paths that will be **appended** to `PATH` for this process, this is a shortcut for adding `PATH` to the `env`-option.
- `pidFile` (optional): The path to the file where the process ID (PID) will be stored.
- `timeout` (optional): A number specifying the maximum time (in seconds) that the process is allowed to run before it's terminated.
- `overrun` (optional): A boolean indicating whether a new instance of the process is allowed to start if the previous instance is still running. Default: false.
Expand Down Expand Up @@ -94,7 +95,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. If omitted, stderr is redirected to stdout.
- `stderr` (string): The file path to write standard error logs. If omitted, stderr is written to the file specified by `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.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/usage/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 jsr:@pup/pup run --config /path/to/your/pup.json
Restart=always

[Install]
Expand Down
2 changes: 2 additions & 0 deletions lib/cli/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Application } from "../../application.meta.ts"
import { greaterThan, lessThan, parse } from "@std/semver"
import { exit } from "@cross/utils"

// The deno.land/x-url has to be used until first stable release, or until jsr.io fixes issue
// https://github.com/jsr-io/jsr/issues/382
const VERSION_INVENTORY_URL = "https://deno.land/x/pup/versions.json"
const LOCAL_VERSION_INVENTORY_FILE = "./versions.json"

Expand Down
46 changes: 28 additions & 18 deletions lib/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import type { ProcessConfiguration, Pup } from "./pup.ts"
import { readLines, StringReader } from "@std/io"
import { BaseRunner, type RunnerCallback, type RunnerResult } from "../types/runner.ts"
import { $, type CommandChild } from "dax-sh"
import { getEnv } from "@cross/env"
import { getAllEnv } from "@cross/env"
import { deepMerge } from "jsr:@cross/deepmerge@^1.0.0"
import { CurrentOS, OperatingSystem } from "@cross/runtime"

/**
* Represents a task runner that executes tasks as regular processes.
Expand Down Expand Up @@ -100,28 +102,36 @@ class Runner extends BaseRunner {
*
* @returns The environment configuration.
*/
private createEnvironmentConfig() {
const env = this.processConfig.env ? structuredClone(this.processConfig.env) : {}
env.PUP_PROCESS_ID = this.processConfig.id
private createEnvironmentConfig(): Record<string, string | undefined> {
// Start with current environment
let env = getAllEnv() || {}

// Transfer environment variables from process config .env
if (this.processConfig.env) {
env = deepMerge(env, this.processConfig.env)
}

// Append/overwrite
// - PUP_PROCESS_ID
env.PUP_PROCESS_ID = this.processConfig.id
// - PUP_TEMP_STORAGE
if (this.pup.temporaryStoragePath) env.PUP_TEMP_STORAGE = this.pup.temporaryStoragePath
// - PUP_DATA_STORAGE
if (this.pup.persistentStoragePath) env.PUP_DATA_STORAGE = this.pup.persistentStoragePath

// Transfer real path
if (getEnv("PATH")) {
if (env.PATH) {
env.PATH = getEnv("PATH") + ":" + env.PATH
} else {
env.PATH = getEnv("PATH")!
}
}

// Transfer specified path
// Transfer path from process config if specified
if (this.processConfig.path) {
const paths = []
if (env.PATH) {
env.PATH = this.processConfig.path + ":" + env.PATH
} else {
env.PATH = this.processConfig.path
paths.push(env.PATH)
}
if (this.processConfig.path) {
paths.push(this.processConfig.path)
}
if (paths.length > 0) {
// Use ; as path separator in Windows, : in others
const pathSeparator = CurrentOS === OperatingSystem.Windows ? ";" : ":"
env.PATH = paths.join(pathSeparator)
}
}

Expand All @@ -134,7 +144,7 @@ class Runner extends BaseRunner {
* @param env The environment configuration for the command.
* @returns The command to be executed.
*/
private prepareCommand(env: Record<string, string>) {
private prepareCommand(env?: Record<string, string | undefined>) {
let child = $.raw`${this.processConfig.cmd!}`.stdout("piped").stderr("piped")
if (this.processConfig.cwd) child = child.cwd(this.processConfig.cwd)
if (env) child = child.env(env)
Expand Down
2 changes: 1 addition & 1 deletion plugins/web-interface/deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Application, Router } from "https://deno.land/x/[email protected]/mod.ts"
export { dirname, fromFileUrl } from "https://deno.land/[email protected]/path/mod.ts"
export { dirname, fromFileUrl } from "@std/path"
export { Bundlee } from "https://deno.land/x/[email protected]/mod.ts"
14 changes: 14 additions & 0 deletions versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
"canary_url": "https://raw.githubusercontent.com/Hexagon/pup/main/pup.ts",
"stable": [],
"prerelease": [
{
"version": "1.0.0-rc.21",
"url": "jsr:@pup/[email protected]",
"deno": null,
"deno_unstable": "1.42.0",
"default_permissions": [
"--allow-env",
"--allow-read",
"--allow-write",
"--allow-sys=loadavg,systemMemoryInfo,osUptime,osRelease",
"--allow-net",
"--allow-run"
]
},
{
"version": "1.0.0-rc.20",
"url": "jsr:@pup/[email protected]",
Expand Down

0 comments on commit b626981

Please sign in to comment.