@phreshos/cli 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -11
- package/dist/cli.js +2 -1
- package/dist/project.js +4 -14
- package/dist/system/command.js +2 -10
- package/dist/system/service/macos.js +16 -3
- package/dist/template/package.json +4 -4
- package/dist/template/phresh.config.ts +3 -3
- package/dist/template.json +2 -2
- package/package.json +2 -1
- package/dist/system/run.js +0 -37
package/README.md
CHANGED
|
@@ -40,17 +40,6 @@ namespaces. System execution and native lifecycle remain isolated under
|
|
|
40
40
|
|
|
41
41
|
## System lifecycle
|
|
42
42
|
|
|
43
|
-
Run a System project or prepared release directly while selecting an independent
|
|
44
|
-
absolute state home:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
PHRESHOS_HOME=/absolute/state phresh system .
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
When `PHRESHOS_HOME` is omitted here, the CLI passes `~/.phreshos`. Running the
|
|
51
|
-
System project itself without the CLI instead defaults to that project's
|
|
52
|
-
`storage/` directory.
|
|
53
|
-
|
|
54
43
|
```bash
|
|
55
44
|
phresh system install
|
|
56
45
|
phresh system uninstall
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, Option } from "commander";
|
|
3
|
-
import
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
4
|
import { PromptCancelled, ReportedFailure } from "./prompts.js";
|
|
5
5
|
import create from "./create.js";
|
|
6
6
|
import install from "./install.js";
|
|
@@ -12,6 +12,7 @@ import systemCommands from "./system/command.js";
|
|
|
12
12
|
import controlCommands from "./control-command.js";
|
|
13
13
|
import describeCommands from "./describe-command.js";
|
|
14
14
|
import { commandContract } from "./command-contract.js";
|
|
15
|
+
const metadata = createRequire(import.meta.url)("../package.json");
|
|
15
16
|
const { version } = metadata;
|
|
16
17
|
const coreRange = metadata.dependencies["@phreshos/core"];
|
|
17
18
|
const runOptionPrefix = "--run-option-";
|
package/dist/project.js
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
1
|
import { isRelativeValue, layers } from "@phreshos/core";
|
|
10
2
|
import { existsSync } from "node:fs";
|
|
11
3
|
import { isAbsolute, normalize, resolve, sep } from "node:path";
|
|
12
|
-
import {
|
|
4
|
+
import { createJiti } from "jiti";
|
|
13
5
|
export const configFile = "phresh.config.ts";
|
|
14
6
|
export async function readConfig(directory = process.cwd()) {
|
|
15
7
|
const path = resolve(directory, configFile);
|
|
16
8
|
if (!existsSync(path))
|
|
17
9
|
throw new Error(`There is no ${configFile} here — run: phresh init`);
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
const loaded = await import(__rewriteRelativeImportExtension(pathToFileURL(path).href)).catch(function (error) {
|
|
10
|
+
// Program declarations remain typed authoring files independently of the
|
|
11
|
+
// Node version that happens to execute the CLI.
|
|
12
|
+
const config = await createJiti(import.meta.url).import(path, { default: true }).catch(function (error) {
|
|
22
13
|
throw new Error(`${configFile} could not be read (${error.message})`);
|
|
23
14
|
});
|
|
24
|
-
const config = loaded.default;
|
|
25
15
|
if (!config)
|
|
26
16
|
throw new Error(`${configFile} must export its config as the default export`);
|
|
27
17
|
coherent(config);
|
package/dist/system/command.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import SystemLifecycle from "./lifecycle.js";
|
|
2
2
|
import prompts, { ReportedFailure } from "../prompts.js";
|
|
3
3
|
import { accent, caution, dim, negative, positive } from "../style.js";
|
|
4
|
-
import runSystem from "./run.js";
|
|
5
4
|
import { commandContract } from "../command-contract.js";
|
|
6
5
|
/** Attach the System lifecycle without mixing it with Program commands. */
|
|
7
6
|
export default function systemCommands(program, provided) {
|
|
8
7
|
let lifecycle = provided;
|
|
9
8
|
const current = () => lifecycle ?? (lifecycle = new SystemLifecycle());
|
|
10
9
|
const system = commandContract(program.command("system")
|
|
11
|
-
.description("
|
|
12
|
-
.argument("[source]", "System project or prepared release to run directly")
|
|
13
|
-
.action(async function (source) {
|
|
14
|
-
if (!source)
|
|
15
|
-
return system.help();
|
|
16
|
-
await runSystem(source);
|
|
17
|
-
}), {
|
|
10
|
+
.description("install and manage the PhreshOS System"), {
|
|
18
11
|
guidance: [
|
|
19
|
-
"
|
|
20
|
-
"Without a source argument, choose one native lifecycle operation.",
|
|
12
|
+
"Choose one native System lifecycle operation.",
|
|
21
13
|
"Running-System Programs, Processes, Endpoints, and Windows are top-level capabilities, not System subcommands."
|
|
22
14
|
]
|
|
23
15
|
});
|
|
@@ -8,12 +8,14 @@ const defaultLabel = "com.phreshos.system";
|
|
|
8
8
|
export default class MacOSSystemService {
|
|
9
9
|
run;
|
|
10
10
|
label;
|
|
11
|
+
environment;
|
|
11
12
|
plist;
|
|
12
13
|
domain;
|
|
13
14
|
target;
|
|
14
|
-
constructor(userHome, run = execute, label = defaultLabel, uid = process.getuid?.()) {
|
|
15
|
+
constructor(userHome, run = execute, label = defaultLabel, uid = process.getuid?.(), environment = process.env) {
|
|
15
16
|
this.run = run;
|
|
16
17
|
this.label = label;
|
|
18
|
+
this.environment = environment;
|
|
17
19
|
if (uid === undefined)
|
|
18
20
|
throw new Error("The current macOS user could not be identified");
|
|
19
21
|
this.plist = join(userHome, "Library", "LaunchAgents", `${this.label}.plist`);
|
|
@@ -40,7 +42,7 @@ export default class MacOSSystemService {
|
|
|
40
42
|
await mkdir(dirname(definition.output), { recursive: true });
|
|
41
43
|
const temporary = `${this.plist}.${randomUUID()}.tmp`;
|
|
42
44
|
try {
|
|
43
|
-
await writeFile(temporary, plist(this.label, definition), { mode: 0o600 });
|
|
45
|
+
await writeFile(temporary, plist(this.label, definition, this.environment), { mode: 0o600 });
|
|
44
46
|
await rename(temporary, this.plist);
|
|
45
47
|
}
|
|
46
48
|
finally {
|
|
@@ -84,7 +86,8 @@ export default class MacOSSystemService {
|
|
|
84
86
|
throw new Error(result.stderr.trim() || result.stdout.trim() || `${command} exited with code ${result.code}`);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
function plist(label, definition) {
|
|
89
|
+
function plist(label, definition, environment) {
|
|
90
|
+
const path = environmentPath(environment);
|
|
88
91
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
89
92
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
90
93
|
<plist version="1.0">
|
|
@@ -99,6 +102,12 @@ ${definition.arguments.map(argument => ` <string>${xml(argument)}</string
|
|
|
99
102
|
</array>
|
|
100
103
|
<key>WorkingDirectory</key>
|
|
101
104
|
<string>${xml(definition.directory)}</string>
|
|
105
|
+
${path === undefined ? "" : ` <key>EnvironmentVariables</key>
|
|
106
|
+
<dict>
|
|
107
|
+
<key>PATH</key>
|
|
108
|
+
<string>${xml(path)}</string>
|
|
109
|
+
</dict>
|
|
110
|
+
`}
|
|
102
111
|
<key>RunAtLoad</key>
|
|
103
112
|
<true/>
|
|
104
113
|
<key>KeepAlive</key>
|
|
@@ -116,6 +125,10 @@ ${definition.arguments.map(argument => ` <string>${xml(argument)}</string
|
|
|
116
125
|
</plist>
|
|
117
126
|
`;
|
|
118
127
|
}
|
|
128
|
+
function environmentPath(environment) {
|
|
129
|
+
const key = Object.keys(environment).find(name => name.toLowerCase() === "path");
|
|
130
|
+
return key === undefined ? undefined : environment[key];
|
|
131
|
+
}
|
|
119
132
|
function xml(value) {
|
|
120
133
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
121
134
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phresh",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.18",
|
|
5
5
|
"description": "The official PhreshOS starter Program.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@phreshos/client": "^0.1.22",
|
|
18
|
-
"@phreshos/core": "^0.1.
|
|
18
|
+
"@phreshos/core": "^0.1.20",
|
|
19
19
|
"@phreshos/react": "^0.1.10",
|
|
20
|
-
"@phreshos/server": "^0.1.
|
|
20
|
+
"@phreshos/server": "^0.1.21",
|
|
21
21
|
"react": "^19.2.8",
|
|
22
22
|
"react-dom": "^19.2.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@phreshos/cli": "^0.1.
|
|
25
|
+
"@phreshos/cli": "^0.1.31",
|
|
26
26
|
"@types/node": "^26.2.0",
|
|
27
27
|
"@types/react": "^19.2.18",
|
|
28
28
|
"@types/react-dom": "^19.2.4",
|
|
@@ -4,7 +4,7 @@ export default defineConfig({
|
|
|
4
4
|
identity: "phresh",
|
|
5
5
|
name: "Phresh Program",
|
|
6
6
|
description: "A minimal counter with direct Client and Server endpoints.",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.18",
|
|
8
8
|
icon: "icon.png",
|
|
9
9
|
categories: ["Development"],
|
|
10
10
|
keywords: ["example", "counter", "client", "server"],
|
|
@@ -12,7 +12,7 @@ export default defineConfig({
|
|
|
12
12
|
buildCommand: "vite-node scripts/build.ts",
|
|
13
13
|
server: {
|
|
14
14
|
location: "dist/server",
|
|
15
|
-
|
|
15
|
+
entryFile: "main.js",
|
|
16
16
|
development: {
|
|
17
17
|
startCommand: "vite-node source/server/main.ts"
|
|
18
18
|
}
|
|
@@ -23,7 +23,7 @@ export default defineConfig({
|
|
|
23
23
|
size: { width: 600, height: 500 },
|
|
24
24
|
development: {
|
|
25
25
|
url: "http://localhost:5200/",
|
|
26
|
-
startCommand: "vite
|
|
26
|
+
startCommand: "vite --config vite.client.ts"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
})
|
package/dist/template.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"repository": "PhreshOS/phresh-program",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"sha256": "
|
|
3
|
+
"version": "0.1.18",
|
|
4
|
+
"sha256": "f612d9c2c55beac0dc618057a68fad177e40564e596047011173e0a5226b65d6",
|
|
5
5
|
"development": true
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.31",
|
|
5
5
|
"description": "The Phresh command-line interface for Program projects and system management.",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.10"
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@phreshos/core": "^0.1.20",
|
|
53
53
|
"adm-zip": "^0.6.0",
|
|
54
54
|
"commander": "^15.0.0",
|
|
55
|
+
"jiti": "^2.7.0",
|
|
55
56
|
"picocolors": "^1.1.1"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
package/dist/system/run.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import phreshosHome from "../home.js";
|
|
2
|
-
import { existsSync, statSync } from "node:fs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
5
|
-
import { spawn } from "node:child_process";
|
|
6
|
-
/** Run one System source directly with an explicit absolute state home. */
|
|
7
|
-
export default async function runSystem(source, environment = process.env) {
|
|
8
|
-
const directory = resolve(source);
|
|
9
|
-
if (!existsSync(directory) || !statSync(directory).isDirectory())
|
|
10
|
-
throw new Error(`The System source does not exist: ${directory}`);
|
|
11
|
-
const entry = join(directory, "server", "main.js");
|
|
12
|
-
const command = existsSync(entry)
|
|
13
|
-
? { file: process.execPath, args: [entry] }
|
|
14
|
-
: await projectCommand(directory);
|
|
15
|
-
const child = spawn(command.file, command.args, {
|
|
16
|
-
cwd: directory,
|
|
17
|
-
env: { ...environment, PHRESHOS_HOME: phreshosHome(environment) },
|
|
18
|
-
stdio: "inherit"
|
|
19
|
-
});
|
|
20
|
-
const result = await new Promise((resolve, reject) => {
|
|
21
|
-
child.once("error", reject);
|
|
22
|
-
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
23
|
-
});
|
|
24
|
-
if (result.signal)
|
|
25
|
-
throw new Error(`The System stopped on ${result.signal}`);
|
|
26
|
-
if (result.code !== 0)
|
|
27
|
-
throw new Error(`The System exited with code ${result.code ?? 1}`);
|
|
28
|
-
}
|
|
29
|
-
async function projectCommand(directory) {
|
|
30
|
-
const path = join(directory, "package.json");
|
|
31
|
-
if (!existsSync(path))
|
|
32
|
-
throw new Error(`The System source has neither server/main.js nor package.json: ${directory}`);
|
|
33
|
-
const manifest = JSON.parse(await readFile(path, "utf8"));
|
|
34
|
-
if (typeof manifest.scripts?.start !== "string")
|
|
35
|
-
throw new Error(`The System source has no start command: ${directory}`);
|
|
36
|
-
return { file: process.execPath, args: ["--run", "start"] };
|
|
37
|
-
}
|