@phreshos/cli 0.1.30 → 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/template/package.json +1 -1
- 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
|
});
|
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
|
-
}
|