@pluginfinity/cli 0.3.9 → 0.3.11

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/cli/run.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { program } from "./program.js";
2
2
  import { CliRuntime } from "@effected/cli";
3
- import { CurrentDistribution, distributionSuffix } from "@effected/engine";
4
3
  import { ToolDiscoveryLive } from "@pluginfinity/engine";
5
4
  import { Effect } from "effect";
6
5
 
@@ -9,30 +8,30 @@ import { Effect } from "effect";
9
8
  * Run `args` through the program under `CliRuntime.main`.
10
9
  *
11
10
  * @remarks
12
- * Reads `CurrentDistribution`, a reference that defaults to none, so a caller
13
- * provides it only for a carrier launch.
11
+ * `CliRuntime.main` provides `distribution` as `CurrentDistribution`, so the
12
+ * program and the engine read the same value, and appends its `via` suffix to
13
+ * the `--version` line.
14
14
  */
15
- const run = (args, options) => Effect.gen(function* () {
16
- const distribution = yield* CurrentDistribution;
15
+ const run = (args, options) => {
17
16
  const deps = {
18
17
  version: options.version,
19
18
  cwd: options.cwd,
20
19
  nodeVersion: options.nodeVersion,
21
20
  stateHome: options.stateHome
22
21
  };
23
- return yield* CliRuntime.main(program(args, deps).pipe(Effect.provide(options.tools ?? ToolDiscoveryLive)), {
22
+ return CliRuntime.main(program(args, deps).pipe(Effect.provide(options.tools ?? ToolDiscoveryLive)), {
24
23
  platform: options.platform,
24
+ distribution: options.distribution ?? null,
25
25
  helpOnUsageError: "stderr",
26
26
  env: {
27
27
  audienceEnvVar: "PLUGINFINITY_AUDIENCE",
28
- ...options.stderrIsTerminal === void 0 ? {} : { stderrIsTerminal: options.stderrIsTerminal },
29
28
  log: {
30
29
  envVar: "PLUGINFINITY_LOG_LEVEL",
31
30
  argv: args
32
31
  },
33
- formatter: { formatVersion: (name, version) => `${name} v${version}${distributionSuffix(distribution)}` }
32
+ formatter: { formatVersion: (name, version) => `${name} v${version}` }
34
33
  }
35
34
  });
36
- });
35
+ };
37
36
 
38
37
  export { run };
package/commands/logs.js CHANGED
@@ -5,7 +5,7 @@ import { Command, Flag } from "effect/cli";
5
5
  import { CurrentDistribution } from "@effected/engine";
6
6
  import { Audience } from "@effected/env";
7
7
  import { configPluginNames, listLogPlugins, logRoot, parseLogLine, readLog, readLogFrom } from "@pluginfinity/engine";
8
- import { Console, Context, Effect, FileSystem, Option } from "effect";
8
+ import { Console, Context, Effect, FileSystem, Option, Schedule } from "effect";
9
9
 
10
10
  // src/commands/logs.ts
11
11
  /** A follow that never stops by itself, checking twice a second. */
@@ -24,14 +24,13 @@ const resolvePlugins = (launch, explicit) => explicit.length > 0 ? Effect.succee
24
24
  /** Print lines appended to the followed files until `stop` completes, checking every `interval`. */
25
25
  const follow = (tails, control, print) => Effect.gen(function* () {
26
26
  const offsets = new Map(tails.map((tail) => [tail.path, tail.offset]));
27
- yield* Effect.forever(Effect.gen(function* () {
27
+ yield* Effect.repeat(Effect.gen(function* () {
28
28
  for (const tail of tails) {
29
29
  const next = yield* readLogFrom(tail.path, offsets.get(tail.path) ?? 0);
30
30
  offsets.set(tail.path, next.offset);
31
31
  for (const line of next.lines) yield* print(tail, line);
32
32
  }
33
- yield* Effect.sleep(control.interval);
34
- }));
33
+ }), Schedule.spaced(control.interval));
35
34
  }).pipe((loop) => Effect.raceFirst(loop, control.stop));
36
35
  /** `pluginfinity logs`: read the logs plugins write under the XDG state directory. */
37
36
  const logsCommand = (launch) => Command.make("logs", {
package/main.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { CurrentFollow, DEFAULT_FOLLOW } from "./commands/logs.js";
2
2
  import { run } from "./cli/run.js";
3
+ import { ShellStateXdg, stateHome } from "./state-home.js";
3
4
  import { CLI_VERSION } from "./version.js";
4
- import { CurrentDistribution } from "@effected/engine";
5
- import { Cause, Effect, Exit, Option, Runtime } from "effect";
6
- import { homedir } from "node:os";
5
+ import { Cause, Effect, Exit, Runtime } from "effect";
7
6
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
8
7
  import * as NodeServices from "@effect/platform-node/NodeServices";
9
8
 
@@ -24,15 +23,14 @@ const exitAfterFlush = (following) => (exit, onExit) => Runtime.defaultTeardown(
24
23
  const main = (options = {}) => {
25
24
  const argv = process.argv.slice(2);
26
25
  let following = false;
27
- const stateHome = process.env.XDG_STATE_HOME || `${process.env.HOME || homedir()}/.local/state`;
28
- NodeRuntime.runMain(run(argv, {
26
+ NodeRuntime.runMain(Effect.flatMap(stateHome.pipe(Effect.provide(ShellStateXdg)), (home) => run(argv, {
29
27
  version: CLI_VERSION,
30
28
  cwd: process.cwd(),
31
29
  nodeVersion: process.versions.node,
32
- stateHome,
30
+ stateHome: home,
33
31
  platform: NodeServices.layer,
34
- stderrIsTerminal: Effect.sync(() => process.stderr.isTTY === true)
35
- }).pipe(Effect.provideService(CurrentDistribution, Option.fromNullishOr(options.distribution)), Effect.provideService(CurrentFollow, {
32
+ distribution: options.distribution
33
+ })).pipe(Effect.provideService(CurrentFollow, {
36
34
  ...DEFAULT_FOLLOW,
37
35
  onStart: () => {
38
36
  following = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluginfinity/cli",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "private": false,
5
5
  "description": "The pluginfinity command-line front end. Install the pluginfinity package to get the pluginfinity bin.",
6
6
  "keywords": [
@@ -40,18 +40,20 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@effect/platform-node": "^4.0.6",
44
- "@effected/cli": "^0.22.2",
45
- "@effected/commands": "^0.16.0",
46
- "@effected/engine": "^0.8.0",
47
- "@effected/env": "^0.5.0",
48
- "@effected/glob": "^0.14.0",
49
- "@effected/semver": "^0.18.0",
50
- "@effected/walker": "^0.20.1",
43
+ "@effect/platform-node": "^4.0.7",
44
+ "@effected/cli": "^0.24.0",
45
+ "@effected/commands": "^0.18.0",
46
+ "@effected/config-file": "^0.22.0",
47
+ "@effected/engine": "^0.10.0",
48
+ "@effected/env": "^0.7.0",
49
+ "@effected/glob": "^0.16.0",
50
+ "@effected/semver": "^0.19.0",
51
+ "@effected/walker": "^0.22.0",
52
+ "@effected/xdg": "^0.17.0",
51
53
  "@pluginfinity/core": "0.3.0",
52
- "@pluginfinity/engine": "0.3.7",
54
+ "@pluginfinity/engine": "0.3.9",
53
55
  "@pluginfinity/targets": "0.3.0",
54
- "effect": "^4.0.6",
56
+ "effect": "^4.0.7",
55
57
  "jiti": "^2.6.1"
56
58
  },
57
59
  "engines": {
package/state-home.js ADDED
@@ -0,0 +1,29 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { Xdg } from "@effected/xdg";
3
+
4
+ // src/state-home.ts
5
+ /**
6
+ * The XDG departures that make the kit read `XDG_STATE_HOME` as `log.sh`'s
7
+ * `:-` does: an empty variable is unset, a relative `XDG_STATE_HOME` is kept as
8
+ * given, and a missing `HOME` is `/nonexistent`, never the OS home directory.
9
+ */
10
+ const SHELL_STATE_RULE = {
11
+ homeFallback: () => "/nonexistent",
12
+ relativeHomes: "keep"
13
+ };
14
+ /**
15
+ * The XDG environment read from the ambient `ConfigProvider` by
16
+ * {@link SHELL_STATE_RULE}. The fallback home is never empty, so the layer's
17
+ * one failure, a missing home, cannot happen.
18
+ */
19
+ const ShellStateXdg = Xdg.layerWith(SHELL_STATE_RULE).pipe(Layer.orDie);
20
+ /**
21
+ * `XDG_STATE_HOME`, else `<home>/.local/state`, joined as the shell joins it
22
+ * (a trailing `/` on `HOME` is kept, as `log.sh` keeps it).
23
+ */
24
+ const stateHome = Effect.gen(function* () {
25
+ const xdg = yield* Xdg;
26
+ return xdg.stateHome ?? `${xdg.home}/.local/state`;
27
+ });
28
+
29
+ export { SHELL_STATE_RULE, ShellStateXdg, stateHome };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }
package/version.js CHANGED
@@ -8,6 +8,6 @@
8
8
  * with this package's own version, so this is not a runtime environment read.
9
9
  * `"0.0.0"` is the unbuilt-source fallback.
10
10
  */
11
- const CLI_VERSION = "0.3.9";
11
+ const CLI_VERSION = "0.3.11";
12
12
 
13
13
  export { CLI_VERSION };