@w5s/managed-script 1.0.0-alpha.2 → 1.0.0-alpha.5

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/ManagedScript-B8d632d3.js +321 -0
  4. package/dist/ManagedScript-B8d632d3.js.map +1 -0
  5. package/dist/cli.js +27 -43
  6. package/dist/cli.js.map +1 -1
  7. package/dist/defaultContext-Xl2iA7UM.js +91 -0
  8. package/dist/defaultContext-Xl2iA7UM.js.map +1 -0
  9. package/dist/index.d.ts +27 -54
  10. package/dist/index.js +27 -12
  11. package/dist/index.js.map +1 -1
  12. package/dist/type-hvsy_R0f.d.ts +103 -0
  13. package/dist/zx.d.ts +45 -14
  14. package/dist/zx.js +67 -26
  15. package/dist/zx.js.map +1 -1
  16. package/package.json +4 -2
  17. package/src/ManagedScript/defaultContext.ts +2 -4
  18. package/src/ManagedScript/execute.ts +48 -25
  19. package/src/ManagedScript/resolveScripts.ts +52 -5
  20. package/src/cli/RootCommand.ts +2 -3
  21. package/src/internal/Executor.ts +27 -10
  22. package/src/internal/Logger.ts +25 -7
  23. package/src/internal/PackageScriptOverride.ts +43 -0
  24. package/src/internal/ScriptInvocation.ts +55 -0
  25. package/src/internal/ScriptNameResolver.ts +5 -4
  26. package/src/internal/Stdio.ts +41 -0
  27. package/src/internal/lazy.ts +7 -0
  28. package/src/mergeConfig.ts +28 -0
  29. package/src/type/CommandContext.ts +6 -7
  30. package/src/type/ResolvedConfig.ts +27 -8
  31. package/src/type/StdOptions.ts +1 -0
  32. package/src/type/UserConfig.ts +38 -1
  33. package/src/type.ts +1 -0
  34. package/src/zx/ZXOptions.ts +73 -1
  35. package/src/zx/ZXShell.ts +18 -1
  36. package/src/zx/defaults.ts +6 -0
  37. package/src/zx/isCI.ts +26 -0
  38. package/src/zx/zx.ts +7 -13
  39. package/src/zx.ts +2 -0
  40. package/dist/ManagedScript-DIacNHCc.js +0 -149
  41. package/dist/ManagedScript-DIacNHCc.js.map +0 -1
  42. package/dist/defaultContext-D_QWP9aF.js +0 -98
  43. package/dist/defaultContext-D_QWP9aF.js.map +0 -1
  44. package/dist/type-DQiyX1q_.d.ts +0 -53
  45. package/src/zx/defaultZXOptions.ts +0 -37
@@ -1,18 +1,37 @@
1
1
  export interface ResolvedConfig {
2
- readonly scripts: Record<string, {
3
- /**
4
- * Command to execute
5
- */
6
- readonly command: string;
2
+ readonly scripts: Record<string, ResolvedConfig.Script>;
3
+ }
4
+
5
+ export namespace ResolvedConfig {
6
+ /**
7
+ * Direct executable invocation. Extra CLI arguments are appended to {@link args}.
8
+ */
9
+ export interface RunnerScript extends Origin {
10
+ readonly args: ReadonlyArray<string>;
11
+ readonly run?: undefined;
12
+ readonly runner: string;
13
+ }
14
+
15
+ export type Script = RunnerScript | ShellScript;
16
+
17
+ /**
18
+ * Shell command. Extra CLI arguments are appended to the command string.
19
+ */
20
+ export interface ShellScript extends Origin {
21
+ readonly args?: undefined;
22
+ readonly run: string;
23
+ readonly runner?: undefined;
24
+ }
7
25
 
26
+ interface Origin {
8
27
  /**
9
- * File path of the configuration file that defined this script
28
+ * Directory of the configuration file that defined this script.
10
29
  */
11
30
  readonly configDir: string | undefined;
12
31
 
13
32
  /**
14
- * Directory of the configuration file that defined this script
33
+ * File path of the configuration file that defined this script.
15
34
  */
16
35
  readonly configFile: string | undefined;
17
- }>;
36
+ }
18
37
  }
@@ -0,0 +1 @@
1
+ export type { StdioOptions } from 'node:child_process';
@@ -1,5 +1,42 @@
1
1
  import type { InputConfig } from 'c12';
2
2
 
3
+ /**
4
+ * Run an executable directly, in the same way a lefthook script uses `runner` and `args`.
5
+ *
6
+ * `runner` is the program, such as `node` or `bash`. `args` are its arguments.
7
+ * Arguments passed to the managed-script CLI are appended after `args`.
8
+ * The process is spawned directly, so the shell does not parse the arguments.
9
+ */
10
+ export interface RunnerScript {
11
+ /**
12
+ * Arguments passed to {@link RunnerScript.runner}.
13
+ */
14
+ readonly args?: ReadonlyArray<string> | undefined;
15
+
16
+ readonly run?: undefined;
17
+
18
+ /**
19
+ * Executable name or path. A multi-word command belongs in {@link RunnerScript.args}:
20
+ * `{ runner: "go", args: ["run", "main.go"] }`.
21
+ */
22
+ readonly runner: string;
23
+ }
24
+
25
+ /**
26
+ * A shell command string (shorthand for `{ run }`), a {@link ShellScript} or a direct {@link RunnerScript}.
27
+ */
28
+ export type ScriptDefinition = RunnerScript | ShellScript | string;
29
+
30
+ /**
31
+ * Run a shell command, in the same way as a lefthook `run`.
32
+ * Arguments passed to the managed-script CLI are appended (shell-quoted).
33
+ */
34
+ export interface ShellScript {
35
+ readonly args?: undefined;
36
+ readonly run: string;
37
+ readonly runner?: undefined;
38
+ }
39
+
3
40
  export interface UserConfig extends InputConfig<{
4
- readonly scripts?: Record<string, string> | undefined;
41
+ readonly scripts?: Record<string, ScriptDefinition> | undefined;
5
42
  }> {}
package/src/type.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './type/Command.js';
2
2
  export * from './type/CommandContext.js';
3
3
  export * from './type/ResolvedConfig.js';
4
+ export * from './type/StdOptions.js';
4
5
  export * from './type/UserConfig.js';
@@ -1 +1,73 @@
1
- export type { Options as ZXOptions } from 'zx';
1
+ import { stripVTControlCharacters } from 'node:util';
2
+ import { chalk, log as zxLog } from 'zx';
3
+
4
+ import type { LogLevel } from '../internal/Logger.js';
5
+ import type { ZXDefaultOptions } from '../zx.js';
6
+
7
+ import { Stdio } from '../internal/Stdio.js';
8
+ import { defaultContext } from '../ManagedScript/defaultContext.js';
9
+
10
+ export type { Options as ZXDefaultOptions } from 'zx';
11
+
12
+ export interface ZXOptions extends ZXDefaultOptions {
13
+ /**
14
+ *
15
+ */
16
+ logLevel?: LogLevel | undefined;
17
+ }
18
+
19
+ /**
20
+ * @namespace
21
+ */
22
+ export const ZXOptions = {
23
+ create(options: Partial<ZXOptions>): Partial<ZXOptions> {
24
+ const { cwd: optionsCwd, env: optionsEnv, logLevel: optionsLogLevel, stdio: optionsStdio, ...optionsRest } = options;
25
+ const env = optionsEnv == null ? process.env : { ...process.env, ...optionsEnv };
26
+ const context = defaultContext({
27
+ env,
28
+ ...(optionsCwd == null ? {} : { cwd: optionsCwd }),
29
+ ...(optionsLogLevel == null ? {} : { logLevel: optionsLogLevel }),
30
+ ...(optionsStdio == null ? {} : { stdio: optionsStdio }),
31
+ });
32
+ const { stderr, stdout } = Stdio.resolve(context.stdio);
33
+
34
+ return {
35
+ cwd: context.cwd,
36
+ env: context.env,
37
+ log: (entry) => {
38
+ const target = (entry.kind === 'cmd' || entry.kind === 'stdout' ? stdout : stderr) as NodeJS.WriteStream;
39
+ const colorEnabled = context.color === 'always' || (context.color === 'auto' && autoColor(context.env, target));
40
+ const previousOutput = zxLog.output;
41
+ const previousLevel = chalk.level;
42
+ zxLog.output = colorEnabled
43
+ ? target
44
+ : ({ write: (chunk: string) => target.write(stripVTControlCharacters(chunk)) } as unknown as NodeJS.WriteStream);
45
+ if (colorEnabled && !chalk.level) {
46
+ chalk.level = 1;
47
+ } else if (!colorEnabled) {
48
+ chalk.level = 0;
49
+ }
50
+ try {
51
+ zxLog(entry.kind === 'cmd' && (context.logLevel === 'info' || context.logLevel === 'debug') ? { ...entry, verbose: true } : entry);
52
+ } finally {
53
+ // eslint-disable-next-line ts/no-non-null-assertion
54
+ zxLog.output = previousOutput!;
55
+ chalk.level = previousLevel;
56
+ }
57
+ },
58
+ preferLocal: true,
59
+ quiet: context.logLevel === 'silent',
60
+ stdio: 'inherit',
61
+ verbose: context.logLevel === 'debug',
62
+ ...optionsRest,
63
+ };
64
+ },
65
+ };
66
+
67
+ function autoColor(env: NodeJS.ProcessEnv, stream: NodeJS.WriteStream): boolean {
68
+ if (env['NO_COLOR'] != null && env['NO_COLOR'] !== '') {
69
+ return false;
70
+ }
71
+ const force = env['FORCE_COLOR'];
72
+ return force == null ? stream.isTTY === true : force !== '0' && force !== 'false';
73
+ }
package/src/zx/ZXShell.ts CHANGED
@@ -1 +1,18 @@
1
- export type { Shell as ZXShell } from 'zx';
1
+ /* eslint-disable ts/no-shadow */
2
+ import type { ProcessOutput, ProcessPromise } from 'zx';
3
+
4
+ import type { ZXOptions } from './ZXOptions.js';
5
+
6
+ /**
7
+ * Shell interface with some extensions
8
+ */
9
+ export interface ZXShell<S = false, R = S extends true ? ProcessOutput : ProcessPromise> {
10
+ (pieces: TemplateStringsArray, ...args: Array<any>): R;
11
+ <O extends Partial<ZXOptions> = Partial<ZXOptions>, R = O extends {
12
+ sync: true;
13
+ } ? ZXShell<true> : ZXShell>(opts: O): R;
14
+ sync: {
15
+ (pieces: TemplateStringsArray, ...args: Array<any>): ProcessOutput;
16
+ (opts: Partial<Omit<ZXOptions, 'sync'>>): ZXShell<true>;
17
+ };
18
+ }
@@ -0,0 +1,6 @@
1
+ import { ZXOptions } from './ZXOptions.js';
2
+
3
+ /**
4
+ * Default ZX options for the managed script environment.
5
+ */
6
+ export const defaults = ZXOptions.create({});
package/src/zx/isCI.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { bool, cleanEnv } from 'envalid';
2
+
3
+ import { lazy } from '../internal/lazy.js';
4
+
5
+ const envSchema = {
6
+ CI: bool({ default: false }),
7
+ CONTINUOUS_INTEGRATION: bool({ default: false }),
8
+ };
9
+
10
+ const getEnvClean = lazy(() =>
11
+ cleanEnv(process.env, envSchema, {
12
+ reporter: null,
13
+ }),
14
+ );
15
+
16
+ /**
17
+ * Determines if the current environment is a CI (Continuous Integration) environment.
18
+ * Checks the `CI` and `CONTINUOUS_INTEGRATION` environment variables to determine if the current environment is a CI environment.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const ci = isCI();
23
+ * ```
24
+ * @returns `true` if the current environment is a CI environment, otherwise `false`
25
+ */
26
+ export const isCI = lazy(() => getEnvClean().CI || getEnvClean().CONTINUOUS_INTEGRATION);
package/src/zx/zx.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { $ as zxDefault } from 'zx';
1
+ import { $ as zxFn } from 'zx';
2
2
 
3
- import type { CommandContext } from '../type.js';
3
+ import type { CommandContext, StdioOptions } from '../type.js';
4
4
  import type { ZXShell } from './ZXShell.js';
5
5
 
6
- import { defaultZXOptions } from './defaultZXOptions.js';
6
+ import { ZXOptions } from './ZXOptions.js';
7
7
 
8
8
  export interface CreateZXOptions {
9
9
  /**
@@ -23,14 +23,9 @@ export interface CreateZXOptions {
23
23
  readonly logLevel?: CommandContext['logLevel'] | undefined;
24
24
 
25
25
  /**
26
- * Stream used to write instrumented command logs at the error and warn levels.
26
+ * Standard I/O used to write instrumented command logs (index `1` for command lines and output, index `2` for the rest).
27
27
  */
28
- readonly stderr?: NodeJS.WritableStream | undefined;
29
-
30
- /**
31
- * Stream used to write instrumented command logs at the info and debug levels.
32
- */
33
- readonly stdout?: NodeJS.WritableStream | undefined;
28
+ readonly stdio?: StdioOptions | undefined;
34
29
  }
35
30
 
36
31
  /**
@@ -41,11 +36,10 @@ export interface CreateZXOptions {
41
36
  export function zx(options: CreateZXOptions = {}): ZXShell {
42
37
  const env = options.env == null ? process.env : { ...process.env, ...options.env };
43
38
 
44
- return zxDefault(defaultZXOptions({
39
+ return zxFn(ZXOptions.create({
45
40
  env,
46
41
  ...(options.cwd == null ? {} : { cwd: options.cwd }),
47
42
  ...(options.logLevel == null ? {} : { logLevel: options.logLevel }),
48
- ...(options.stderr == null ? {} : { stderr: options.stderr }),
49
- ...(options.stdout == null ? {} : { stdout: options.stdout }),
43
+ ...(options.stdio == null ? {} : { stdio: options.stdio }),
50
44
  }));
51
45
  }
package/src/zx.ts CHANGED
@@ -2,6 +2,8 @@ import type { ZXShell } from './zx/ZXShell.js';
2
2
 
3
3
  import { zx } from './zx/zx.js';
4
4
 
5
+ export * from './zx/defaults.js';
6
+ export * from './zx/isCI.js';
5
7
  export * from './zx/zx.js';
6
8
  export type * from './zx/ZXOptions.js';
7
9
  export type * from './zx/ZXShell.js';
@@ -1,149 +0,0 @@
1
- import { n as ManagedScriptEnv, r as Logger, t as defaultContext } from "./defaultContext-D_QWP9aF.js";
2
- import { loadConfig } from "c12";
3
- import { spawn } from "node:child_process";
4
- import path from "node:path/win32";
5
- //#region src/meta.ts
6
- const meta = Object.freeze({
7
- binaryLabel: "W5S Managed Script",
8
- binaryName: "managed-script",
9
- binaryVersion: "1.0.0-alpha.2",
10
- buildNumber: 1,
11
- name: "@w5s/managed-script",
12
- version: "1.0.0-alpha.2"
13
- });
14
- //#endregion
15
- //#region src/internal/ConfigLoader.ts
16
- const ConfigLoader = { async load(options) {
17
- const result = await loadConfig({
18
- cwd: options.cwd,
19
- name: meta.binaryName,
20
- packageJson: [meta.binaryName]
21
- });
22
- return {
23
- config: result.config,
24
- configFile: result.configFile ?? void 0,
25
- layers: result.layers ?? []
26
- };
27
- } };
28
- //#endregion
29
- //#region src/internal/Executor.ts
30
- /**
31
- * Executes a command via the system shell, inheriting stdio and forwarding its exit code.
32
- */
33
- const Executor = { async run(command, options = {}) {
34
- return new Promise((resolve, reject) => {
35
- const child = spawn(command, {
36
- cwd: options.cwd,
37
- env: options.env == null ? process.env : {
38
- ...process.env,
39
- ...options.env
40
- },
41
- shell: true,
42
- stdio: "inherit"
43
- });
44
- child.on("error", reject);
45
- child.on("close", (code, signal) => {
46
- resolve(code ?? (signal == null ? 1 : 128));
47
- });
48
- });
49
- } };
50
- //#endregion
51
- //#region src/internal/ScriptNameResolver.ts
52
- /**
53
- * Resolves the script name to run.
54
- *
55
- * Priority: first positional CLI argument > `MANAGED_SCRIPT_NAME` env var > `npm_lifecycle_event` env var.
56
- */
57
- const ScriptNameResolver = { resolve({ env, scriptName }) {
58
- return scriptName ?? env[ManagedScriptEnv.Name] ?? env["npm_lifecycle_event"];
59
- } };
60
- //#endregion
61
- //#region src/ManagedScript/resolveScripts.ts
62
- function resolveScripts(loaded) {
63
- const scripts = {};
64
- const layers = loaded.layers.length > 0 ? loaded.layers : [{ config: loaded.config }];
65
- for (const layer of layers) for (const [name, command] of Object.entries(layer.config?.scripts ?? {})) {
66
- const configFile = layer.configFile ?? loaded.configFile;
67
- const configDir = configFile == null ? void 0 : path.dirname(configFile);
68
- scripts[name] ??= {
69
- command,
70
- configDir,
71
- configFile
72
- };
73
- }
74
- return { scripts };
75
- }
76
- //#endregion
77
- //#region src/ManagedScript/execute.ts
78
- const handlers = { RunScript: async (command) => {
79
- const { context: { color, cwd, dryRun, env, logLevel, stderr, stdout }, parameters: { scriptArgs = [], scriptName } } = command;
80
- const logger = Logger.create({
81
- color,
82
- level: logLevel,
83
- stderr,
84
- stdout
85
- });
86
- const loaded = await ConfigLoader.load({ cwd });
87
- logger.debug(`Resolved configuration from ${loaded.configFile ?? "defaults (no config file found)"}.`);
88
- const { scripts } = resolveScripts(loaded);
89
- const name = ScriptNameResolver.resolve({
90
- env,
91
- scriptName
92
- });
93
- if (name == null) throw new Error("Unable to resolve the script name. Pass it as the first argument, set the MANAGED_SCRIPT_NAME environment variable, or run through an npm/pnpm script (npm_lifecycle_event).");
94
- const script = scripts[name];
95
- if (script == null) {
96
- const available = Object.keys(scripts);
97
- throw new Error(`No script named "${name}" found in the configuration.${available.length > 0 ? ` Available scripts: ${available.join(", ")}.` : " No scripts are configured."}`);
98
- }
99
- const commandLine = [script.command, ...scriptArgs.map((argument) => `'${argument.replaceAll("'", String.raw`'\''`)}'`)].join(" ");
100
- if (dryRun) {
101
- stdout.write(`${commandLine}\n`);
102
- return 0;
103
- }
104
- logger.info(`Running script "${name}": ${commandLine}`);
105
- const scriptEnv = {
106
- [ManagedScriptEnv.Color]: color,
107
- [ManagedScriptEnv.ConfigDir]: script.configDir,
108
- [ManagedScriptEnv.ConfigFile]: script.configFile,
109
- [ManagedScriptEnv.Cwd]: cwd,
110
- [ManagedScriptEnv.LogLevel]: logLevel,
111
- [ManagedScriptEnv.Name]: name
112
- };
113
- const exitCode = await Executor.run(commandLine, {
114
- cwd,
115
- env: scriptEnv
116
- });
117
- if (exitCode !== 0) throw new Error(`Script "${name}" exited with code ${exitCode}.`);
118
- return exitCode;
119
- } };
120
- /**
121
- * Dispatch the command to the appropriate handler based on its type.
122
- *
123
- * @param command
124
- */
125
- async function execute(command) {
126
- const context = defaultContext(command.context);
127
- return handlers[command._]({
128
- ...command,
129
- context
130
- });
131
- }
132
- //#endregion
133
- //#region src/ManagedScript/runScript.ts
134
- async function runScript(options) {
135
- return execute({
136
- _: "RunScript",
137
- ...options
138
- });
139
- }
140
- //#endregion
141
- //#region src/ManagedScript.ts
142
- /**
143
- * @namespace
144
- */
145
- const ManagedScript = Object.freeze({ runScript });
146
- //#endregion
147
- export { meta as n, ManagedScript as t };
148
-
149
- //# sourceMappingURL=ManagedScript-DIacNHCc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ManagedScript-DIacNHCc.js","names":[],"sources":["../src/meta.ts","../src/internal/ConfigLoader.ts","../src/internal/Executor.ts","../src/internal/ScriptNameResolver.ts","../src/ManagedScript/resolveScripts.ts","../src/ManagedScript/execute.ts","../src/ManagedScript/runScript.ts","../src/ManagedScript.ts"],"sourcesContent":["export const meta = Object.freeze({\n binaryLabel: 'W5S Managed Script',\n binaryName: 'managed-script',\n // @ts-ignore - these variables are injected at build time\n binaryVersion: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n});\n","import type { ConfigLayer } from 'c12';\n\nimport { loadConfig } from 'c12';\n\nimport type { UserConfig } from '../type/UserConfig.js';\n\nimport { meta } from '../meta.js';\n\nexport interface ConfigLoaderOptions {\n readonly cwd: string;\n}\n\nexport interface ConfigLoaderResult {\n readonly config: UserConfig;\n readonly configFile: string | undefined;\n readonly layers: Array<ConfigLayer<UserConfig>>;\n}\n\nexport const ConfigLoader = {\n async load(options: ConfigLoaderOptions): Promise<ConfigLoaderResult> {\n const result = await loadConfig<UserConfig>({\n cwd: options.cwd,\n name: meta.binaryName,\n packageJson: [meta.binaryName],\n });\n\n return {\n config: result.config,\n configFile: result.configFile ?? undefined,\n layers: result.layers ?? [],\n };\n },\n};\n","import { spawn } from 'node:child_process';\n\nexport interface ExecutorRunOptions {\n readonly cwd?: string | undefined;\n readonly env?: NodeJS.ProcessEnv | undefined;\n}\n\n/**\n * Executes a command via the system shell, inheriting stdio and forwarding its exit code.\n */\nexport const Executor = {\n async run(command: string, options: ExecutorRunOptions = {}): Promise<number> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, {\n cwd: options.cwd,\n env: options.env == null ? process.env : { ...process.env, ...options.env },\n shell: true,\n stdio: 'inherit',\n });\n\n child.on('error', reject);\n child.on('close', (code, signal) => {\n resolve(code ?? (signal == null ? 1 : 128));\n });\n });\n },\n};\n","import { ManagedScriptEnv } from '../ManagedScriptEnv.js';\n\nexport interface ScriptNameResolverOptions {\n readonly env: NodeJS.ProcessEnv;\n readonly scriptName: string | undefined;\n}\n\n/**\n * Resolves the script name to run.\n *\n * Priority: first positional CLI argument > `MANAGED_SCRIPT_NAME` env var > `npm_lifecycle_event` env var.\n */\nexport const ScriptNameResolver = {\n resolve({ env, scriptName }: ScriptNameResolverOptions): string | undefined {\n return scriptName ?? env[ManagedScriptEnv.Name] ?? env['npm_lifecycle_event'];\n },\n};\n","import path from 'node:path/win32';\n\nimport type { ConfigLoaderResult } from '../internal/ConfigLoader.js';\nimport type { ResolvedConfig } from '../type/ResolvedConfig.js';\n\nexport function resolveScripts(loaded: ConfigLoaderResult): ResolvedConfig {\n const scripts: ResolvedConfig['scripts'] = {};\n const layers = loaded.layers.length > 0 ? loaded.layers : [{ config: loaded.config }];\n\n for (const layer of layers) {\n for (const [name, command] of Object.entries(layer.config?.scripts ?? {})) {\n const configFile = layer.configFile ?? loaded.configFile;\n const configDir = configFile == null ? undefined : path.dirname(configFile);\n scripts[name] ??= {\n command,\n configDir,\n configFile,\n };\n }\n }\n\n return {\n scripts,\n };\n}\n","import type { ManagedScriptCommand } from '../type.js';\n\nimport { ConfigLoader } from '../internal/ConfigLoader.js';\nimport { Executor } from '../internal/Executor.js';\nimport { Logger } from '../internal/Logger.js';\nimport { ScriptNameResolver } from '../internal/ScriptNameResolver.js';\nimport { ManagedScriptEnv } from '../ManagedScriptEnv.js';\nimport { defaultContext } from './defaultContext.js';\nimport { resolveScripts } from './resolveScripts.js';\n\nconst handlers = {\n RunScript: async (command: ManagedScriptCommand.RunScript): Promise<number> => {\n const {\n context: { color, cwd, dryRun, env, logLevel, stderr, stdout },\n parameters: { scriptArgs = [], scriptName },\n } = command;\n const logger = Logger.create({ color, level: logLevel, stderr, stdout });\n const loaded = await ConfigLoader.load({ cwd });\n logger.debug(`Resolved configuration from ${loaded.configFile ?? 'defaults (no config file found)'}.`);\n const resolved = resolveScripts(loaded);\n const { scripts } = resolved;\n\n const name = ScriptNameResolver.resolve({ env, scriptName: scriptName });\n if (name == null) {\n throw new Error(\n 'Unable to resolve the script name. Pass it as the first argument, set the MANAGED_SCRIPT_NAME environment variable, or run through an npm/pnpm script (npm_lifecycle_event).',\n );\n }\n\n const script = scripts[name];\n if (script == null) {\n const available = Object.keys(scripts);\n throw new Error(\n `No script named \"${name}\" found in the configuration.${\n available.length > 0 ? ` Available scripts: ${available.join(', ')}.` : ' No scripts are configured.'\n }`,\n );\n }\n\n const commandLine = [\n script.command,\n ...scriptArgs.map((argument) => `'${argument.replaceAll(\"'\", String.raw`'\\''`)}'`),\n ].join(' ');\n\n if (dryRun) {\n stdout.write(`${commandLine}\\n`);\n return 0;\n }\n\n logger.info(`Running script \"${name}\": ${commandLine}`);\n\n // Prepare the environment variables for the script execution.\n const scriptEnv = {\n [ManagedScriptEnv.Color]: color,\n [ManagedScriptEnv.ConfigDir]: script.configDir,\n [ManagedScriptEnv.ConfigFile]: script.configFile,\n [ManagedScriptEnv.Cwd]: cwd,\n [ManagedScriptEnv.LogLevel]: logLevel,\n [ManagedScriptEnv.Name]: name,\n };\n\n const exitCode = await Executor.run(commandLine, { cwd, env: scriptEnv });\n\n if (exitCode !== 0) {\n throw new Error(`Script \"${name}\" exited with code ${exitCode}.`);\n }\n\n return exitCode;\n },\n} satisfies {\n [K in ManagedScriptCommand['_']]: (command: Extract<ManagedScriptCommand, { _: K }>) => Promise<any>;\n};\n\nexport type ExecuteCommand<T extends ManagedScriptCommand> = Omit<T, 'context'> & {\n /**\n * Context is optional\n */\n context?: Partial<ManagedScriptCommand['context']>;\n};\n\n/**\n * Extract command parameter from execute handler\n */\nexport type ExecuteCommandParameters<T extends ManagedScriptCommand> = Omit<Parameters<typeof execute<T>>[0], '_'>;\n\n/**\n * Dispatch the command to the appropriate handler based on its type.\n *\n * @param command\n */\nexport async function execute<T extends ManagedScriptCommand>(command: ExecuteCommand<T>): Promise<Awaited<ReturnType<typeof handlers[T['_']]>>> {\n const context = defaultContext(command.context);\n // @ts-ignore we know this works\n return handlers[command._]({\n ...command,\n context,\n });\n}\n","import { ManagedScriptCommand } from '../type.js';\nimport { execute, type ExecuteCommandParameters } from './execute.js';\n\nexport async function runScript(options: ExecuteCommandParameters<ManagedScriptCommand.RunScript>) {\n return execute({\n _: 'RunScript',\n ...options,\n });\n}\n","import { runScript } from './ManagedScript/runScript.js';\n\n/**\n * @namespace\n */\nexport const ManagedScript = Object.freeze({\n runScript,\n});\n"],"mappings":";;;;;AAAA,MAAa,OAAO,OAAO,OAAO;CAChC,aAAa;CACb,YAAY;CAEZ,eAAA;CAEA,aAAa;CAEb,MAAA;CAEA,SAAA;AACF,CAAC;;;ACOD,MAAa,eAAe,EAC1B,MAAM,KAAK,SAA2D;CACpE,MAAM,SAAS,MAAM,WAAuB;EAC1C,KAAK,QAAQ;EACb,MAAM,KAAK;EACX,aAAa,CAAC,KAAK,UAAU;CAC/B,CAAC;CAED,OAAO;EACL,QAAQ,OAAO;EACf,YAAY,OAAO,cAAc,KAAA;EACjC,QAAQ,OAAO,UAAU,CAAC;CAC5B;AACF,EACF;;;;;;ACtBA,MAAa,WAAW,EACtB,MAAM,IAAI,SAAiB,UAA8B,CAAC,GAAoB;CAC5E,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,QAAQ,MAAM,SAAS;GAC3B,KAAK,QAAQ;GACb,KAAK,QAAQ,OAAO,OAAO,QAAQ,MAAM;IAAE,GAAG,QAAQ;IAAK,GAAG,QAAQ;GAAI;GAC1E,OAAO;GACP,OAAO;EACT,CAAC;EAED,MAAM,GAAG,SAAS,MAAM;EACxB,MAAM,GAAG,UAAU,MAAM,WAAW;GAClC,QAAQ,SAAS,UAAU,OAAO,IAAI,IAAI;EAC5C,CAAC;CACH,CAAC;AACH,EACF;;;;;;;;ACdA,MAAa,qBAAqB,EAChC,QAAQ,EAAE,KAAK,cAA6D;CAC1E,OAAO,cAAc,IAAI,iBAAiB,SAAS,IAAI;AACzD,EACF;;;ACXA,SAAgB,eAAe,QAA4C;CACzE,MAAM,UAAqC,CAAC;CAC5C,MAAM,SAAS,OAAO,OAAO,SAAS,IAAI,OAAO,SAAS,CAAC,EAAE,QAAQ,OAAO,OAAO,CAAC;CAEpF,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,MAAM,QAAQ,WAAW,CAAC,CAAC,GAAG;EACzE,MAAM,aAAa,MAAM,cAAc,OAAO;EAC9C,MAAM,YAAY,cAAc,OAAO,KAAA,IAAY,KAAK,QAAQ,UAAU;EAC1E,QAAQ,UAAU;GAChB;GACA;GACA;EACF;CACF;CAGF,OAAO,EACL,QACF;AACF;;;ACdA,MAAM,WAAW,EACf,WAAW,OAAO,YAA6D;CAC7E,MAAM,EACJ,SAAS,EAAE,OAAO,KAAK,QAAQ,KAAK,UAAU,QAAQ,UACtD,YAAY,EAAE,aAAa,CAAC,GAAG,iBAC7B;CACJ,MAAM,SAAS,OAAO,OAAO;EAAE;EAAO,OAAO;EAAU;EAAQ;CAAO,CAAC;CACvE,MAAM,SAAS,MAAM,aAAa,KAAK,EAAE,IAAI,CAAC;CAC9C,OAAO,MAAM,+BAA+B,OAAO,cAAc,kCAAkC,EAAE;CAErG,MAAM,EAAE,YADS,eAAe,MACL;CAE3B,MAAM,OAAO,mBAAmB,QAAQ;EAAE;EAAiB;CAAW,CAAC;CACvE,IAAI,QAAQ,MACV,MAAM,IAAI,MACR,8KACF;CAGF,MAAM,SAAS,QAAQ;CACvB,IAAI,UAAU,MAAM;EAClB,MAAM,YAAY,OAAO,KAAK,OAAO;EACrC,MAAM,IAAI,MACR,oBAAoB,KAAK,+BACvB,UAAU,SAAS,IAAI,uBAAuB,UAAU,KAAK,IAAI,EAAE,KAAK,+BAE5E;CACF;CAEA,MAAM,cAAc,CAClB,OAAO,SACP,GAAG,WAAW,KAAK,aAAa,IAAI,SAAS,WAAW,KAAK,OAAO,GAAG,MAAM,EAAE,EAAE,CACnF,CAAC,CAAC,KAAK,GAAG;CAEV,IAAI,QAAQ;EACV,OAAO,MAAM,GAAG,YAAY,GAAG;EAC/B,OAAO;CACT;CAEA,OAAO,KAAK,mBAAmB,KAAK,KAAK,aAAa;CAGtD,MAAM,YAAY;GACf,iBAAiB,QAAQ;GACzB,iBAAiB,YAAY,OAAO;GACpC,iBAAiB,aAAa,OAAO;GACrC,iBAAiB,MAAM;GACvB,iBAAiB,WAAW;GAC5B,iBAAiB,OAAO;CAC3B;CAEA,MAAM,WAAW,MAAM,SAAS,IAAI,aAAa;EAAE;EAAK,KAAK;CAAU,CAAC;CAExE,IAAI,aAAa,GACf,MAAM,IAAI,MAAM,WAAW,KAAK,qBAAqB,SAAS,EAAE;CAGlE,OAAO;AACT,EACF;;;;;;AAqBA,eAAsB,QAAwC,SAAmF;CAC/I,MAAM,UAAU,eAAe,QAAQ,OAAO;CAE9C,OAAO,SAAS,QAAQ,EAAE,CAAC;EACzB,GAAG;EACH;CACF,CAAC;AACH;;;AC9FA,eAAsB,UAAU,SAAmE;CACjG,OAAO,QAAQ;EACb,GAAG;EACH,GAAG;CACL,CAAC;AACH;;;;;;ACHA,MAAa,gBAAgB,OAAO,OAAO,EACzC,UACF,CAAC"}
@@ -1,98 +0,0 @@
1
- //#region src/internal/Logger.ts
2
- /**
3
- * Rank order used to compare log levels, higher means more verbose.
4
- */
5
- const logLevelRank = {
6
- debug: 4,
7
- error: 1,
8
- info: 3,
9
- silent: 0,
10
- warn: 2
11
- };
12
- /**
13
- * Creates a logger writing to `stream`, filtering out messages above the configured `level`.
14
- */
15
- const Logger = { create({ color = "auto", level, stderr, stdout }) {
16
- const write = (messageLevel, message) => {
17
- if (!(logLevelRank[messageLevel] <= logLevelRank[level])) return;
18
- const outputStream = logLevelRank[messageLevel] <= logLevelRank.warn ? stderr : stdout;
19
- const shouldColor = color === "always" || color === "auto" && "isTTY" in outputStream && outputStream.isTTY === true;
20
- const colorCode = {
21
- debug: "\x1B[36m",
22
- error: "\x1B[31m",
23
- info: "\x1B[32m",
24
- silent: "",
25
- warn: "\x1B[33m"
26
- }[messageLevel];
27
- outputStream.write(`${shouldColor ? `${colorCode}${message}\u{1B}[0m` : message}\n`);
28
- };
29
- return {
30
- debug: (message) => write("debug", message),
31
- error: (message) => write("error", message),
32
- info: (message) => write("info", message),
33
- warn: (message) => write("warn", message)
34
- };
35
- } };
36
- //#endregion
37
- //#region src/ManagedScriptEnv.ts
38
- /**
39
- * Enum for managed script environment variables.
40
- *
41
- * @enum
42
- */
43
- const ManagedScriptEnv = Object.freeze({
44
- /**
45
- * The color mode used for messages.
46
- */
47
- Color: "MANAGED_SCRIPT_COLOR",
48
- /**
49
- * The directory where the managed script configuration is located.
50
- */
51
- ConfigDir: "MANAGED_SCRIPT_CONFIG_DIR",
52
- /**
53
- * The file where the managed script configuration is located.
54
- */
55
- ConfigFile: "MANAGED_SCRIPT_CONFIG_FILE",
56
- /**
57
- * The invocation directory used to resolve configuration and spawn the script.
58
- */
59
- Cwd: "MANAGED_SCRIPT_CWD",
60
- /**
61
- * The resolved log level.
62
- */
63
- LogLevel: "MANAGED_SCRIPT_LOGLEVEL",
64
- /**
65
- * The name of the managed script.
66
- */
67
- Name: "MANAGED_SCRIPT_NAME"
68
- });
69
- //#endregion
70
- //#region src/ManagedScript/defaultContext.ts
71
- function defaultContext(context) {
72
- const { cli = {}, color, cwd, dryRun, env = process.env, logLevel, stderr = process.stderr, stdout = process.stdout } = context ?? {};
73
- const envLogLevel = env[ManagedScriptEnv.LogLevel];
74
- return {
75
- cli,
76
- color: color ?? cli.color ?? "auto",
77
- cwd: cwd ?? cli.cwd ?? env[ManagedScriptEnv.Cwd] ?? process.cwd(),
78
- dryRun: dryRun ?? cli.dryRun ?? false,
79
- env,
80
- logLevel: logLevel ?? cli.logLevel ?? (isLogLevel(envLogLevel) ? envLogLevel : "info"),
81
- stderr,
82
- stdout
83
- };
84
- }
85
- const knownLogLevels = /* @__PURE__ */ new Set([
86
- "debug",
87
- "error",
88
- "info",
89
- "silent",
90
- "warn"
91
- ]);
92
- function isLogLevel(value) {
93
- return knownLogLevels.has(value);
94
- }
95
- //#endregion
96
- export { ManagedScriptEnv as n, Logger as r, defaultContext as t };
97
-
98
- //# sourceMappingURL=defaultContext-D_QWP9aF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultContext-D_QWP9aF.js","names":[],"sources":["../src/internal/Logger.ts","../src/ManagedScriptEnv.ts","../src/ManagedScript/defaultContext.ts"],"sourcesContent":["export type ColorMode = 'always' | 'auto' | 'never';\nexport type LogLevel = 'debug' | 'error' | 'info' | 'silent' | 'warn';\n\n/**\n * Rank order used to compare log levels, higher means more verbose.\n */\nconst logLevelRank: Record<LogLevel, number> = {\n debug: 4,\n error: 1,\n info: 3,\n silent: 0,\n warn: 2,\n};\n\nexport interface CreateLoggerOptions {\n readonly color?: ColorMode;\n readonly level: LogLevel;\n readonly stderr: NodeJS.WritableStream;\n readonly stdout: NodeJS.WritableStream;\n}\n\nexport interface Logger {\n debug(message: string): void;\n error(message: string): void;\n info(message: string): void;\n warn(message: string): void;\n}\n\n/**\n * Creates a logger writing to `stream`, filtering out messages above the configured `level`.\n */\nexport const Logger = {\n create({ color = 'auto', level, stderr, stdout }: CreateLoggerOptions): Logger {\n const write = (messageLevel: LogLevel, message: string) => {\n if (!(logLevelRank[messageLevel] <= logLevelRank[level])) {\n return;\n }\n // write to stderr for warnings and errors\n const outputStream = logLevelRank[messageLevel] <= logLevelRank.warn ? stderr : stdout;\n const shouldColor = color === 'always' || (color === 'auto' && 'isTTY' in outputStream && outputStream.isTTY === true);\n const colorCode = {\n debug: '\\u{1B}[36m',\n error: '\\u{1B}[31m',\n info: '\\u{1B}[32m',\n silent: '',\n warn: '\\u{1B}[33m',\n }[messageLevel];\n outputStream.write(`${shouldColor ? `${colorCode}${message}\\u{1B}[0m` : message}\\n`);\n };\n\n return {\n debug: (message) => write('debug', message),\n error: (message) => write('error', message),\n info: (message) => write('info', message),\n warn: (message) => write('warn', message),\n };\n },\n};\n","/**\n * Enum for managed script environment variables.\n *\n * @enum\n */\nexport const ManagedScriptEnv = Object.freeze({\n /**\n * The color mode used for messages.\n */\n Color: 'MANAGED_SCRIPT_COLOR',\n\n /**\n * The directory where the managed script configuration is located.\n */\n ConfigDir: 'MANAGED_SCRIPT_CONFIG_DIR',\n\n /**\n * The file where the managed script configuration is located.\n */\n ConfigFile: 'MANAGED_SCRIPT_CONFIG_FILE',\n\n /**\n * The invocation directory used to resolve configuration and spawn the script.\n */\n Cwd: 'MANAGED_SCRIPT_CWD',\n\n /**\n * The resolved log level.\n */\n LogLevel: 'MANAGED_SCRIPT_LOGLEVEL',\n\n /**\n * The name of the managed script.\n */\n Name: 'MANAGED_SCRIPT_NAME',\n});\nexport type ManagedScriptEnv = typeof ManagedScriptEnv[keyof typeof ManagedScriptEnv];\n","import type { LogLevel } from '../internal/Logger.js';\nimport type { CommandContext } from '../type.js';\n\nimport { ManagedScriptEnv } from '../ManagedScriptEnv.js';\n\nexport function defaultContext(context: Partial<CommandContext> | undefined): CommandContext {\n const {\n cli = {},\n color,\n cwd,\n dryRun,\n env = process.env,\n logLevel,\n stderr = process.stderr,\n stdout = process.stdout,\n } = context ?? {};\n const envLogLevel = env[ManagedScriptEnv.LogLevel];\n return {\n cli,\n color: color ?? cli.color ?? 'auto',\n cwd: cwd ?? cli.cwd ?? env[ManagedScriptEnv.Cwd] ?? process.cwd(),\n dryRun: dryRun ?? cli.dryRun ?? false,\n env,\n logLevel: logLevel ?? cli.logLevel ?? (isLogLevel(envLogLevel) ? envLogLevel : 'info'),\n stderr,\n stdout,\n };\n}\n\nconst knownLogLevels = new Set<LogLevel>(['debug', 'error', 'info', 'silent', 'warn']);\n\nfunction isLogLevel(value: string | undefined): value is LogLevel {\n return knownLogLevels.has(value as LogLevel);\n}\n"],"mappings":";;;;AAMA,MAAM,eAAyC;CAC7C,OAAO;CACP,OAAO;CACP,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;;;AAmBA,MAAa,SAAS,EACpB,OAAO,EAAE,QAAQ,QAAQ,OAAO,QAAQ,UAAuC;CAC7E,MAAM,SAAS,cAAwB,YAAoB;EACzD,IAAI,EAAE,aAAa,iBAAiB,aAAa,SAC/C;EAGF,MAAM,eAAe,aAAa,iBAAiB,aAAa,OAAO,SAAS;EAChF,MAAM,cAAc,UAAU,YAAa,UAAU,UAAU,WAAW,gBAAgB,aAAa,UAAU;EACjH,MAAM,YAAY;GAChB,OAAO;GACP,OAAO;GACP,MAAM;GACN,QAAQ;GACR,MAAM;EACR,EAAE;EACF,aAAa,MAAM,GAAG,cAAc,GAAG,YAAY,QAAQ,aAAa,QAAQ,GAAG;CACrF;CAEA,OAAO;EACL,QAAQ,YAAY,MAAM,SAAS,OAAO;EAC1C,QAAQ,YAAY,MAAM,SAAS,OAAO;EAC1C,OAAO,YAAY,MAAM,QAAQ,OAAO;EACxC,OAAO,YAAY,MAAM,QAAQ,OAAO;CAC1C;AACF,EACF;;;;;;;;ACpDA,MAAa,mBAAmB,OAAO,OAAO;;;;CAI5C,OAAO;;;;CAKP,WAAW;;;;CAKX,YAAY;;;;CAKZ,KAAK;;;;CAKL,UAAU;;;;CAKV,MAAM;AACR,CAAC;;;AC9BD,SAAgB,eAAe,SAA8D;CAC3F,MAAM,EACJ,MAAM,CAAC,GACP,OACA,KACA,QACA,MAAM,QAAQ,KACd,UACA,SAAS,QAAQ,QACjB,SAAS,QAAQ,WACf,WAAW,CAAC;CAChB,MAAM,cAAc,IAAI,iBAAiB;CACzC,OAAO;EACL;EACA,OAAO,SAAS,IAAI,SAAS;EAC7B,KAAK,OAAO,IAAI,OAAO,IAAI,iBAAiB,QAAQ,QAAQ,IAAI;EAChE,QAAQ,UAAU,IAAI,UAAU;EAChC;EACA,UAAU,YAAY,IAAI,aAAa,WAAW,WAAW,IAAI,cAAc;EAC/E;EACA;CACF;AACF;AAEA,MAAM,iCAAiB,IAAI,IAAc;CAAC;CAAS;CAAS;CAAQ;CAAU;AAAM,CAAC;AAErF,SAAS,WAAW,OAA8C;CAChE,OAAO,eAAe,IAAI,KAAiB;AAC7C"}
@@ -1,53 +0,0 @@
1
- import { InputConfig } from "c12";
2
- //#region src/type/UserConfig.d.ts
3
- interface UserConfig extends InputConfig<{
4
- readonly scripts?: Record<string, string> | undefined;
5
- }> {}
6
- //#endregion
7
- //#region src/internal/Logger.d.ts
8
- type ColorMode = 'always' | 'auto' | 'never';
9
- type LogLevel = 'debug' | 'error' | 'info' | 'silent' | 'warn';
10
- //#endregion
11
- //#region src/type/CommandContext.d.ts
12
- interface CommandContext {
13
- /**
14
- * Command-line arguments passed to the script.
15
- */
16
- readonly cli: {
17
- color?: ColorMode | undefined;
18
- cwd?: string | undefined;
19
- dryRun?: boolean | undefined;
20
- logLevel?: LogLevel | undefined;
21
- };
22
- /**
23
- * Color mode used for status messages.
24
- */
25
- readonly color: ColorMode;
26
- /**
27
- * Current working directory of the script.
28
- */
29
- readonly cwd: string;
30
- /**
31
- * When `true`, the resolved command is printed instead of being executed.
32
- */
33
- readonly dryRun: boolean;
34
- /**
35
- * Environment variables available to the script.
36
- */
37
- readonly env: NodeJS.ProcessEnv;
38
- /**
39
- * Resolved log level used to filter status messages.
40
- */
41
- readonly logLevel: LogLevel;
42
- /**
43
- * Stream used to write error log messages.
44
- */
45
- readonly stderr: NodeJS.WritableStream;
46
- /**
47
- * Stream used to write standard log messages.
48
- */
49
- readonly stdout: NodeJS.WritableStream;
50
- }
51
- //#endregion
52
- export { UserConfig as n, CommandContext as t };
53
- //# sourceMappingURL=type-DQiyX1q_.d.ts.map
@@ -1,37 +0,0 @@
1
- import { log as zxLog } from 'zx';
2
-
3
- import type { LogLevel } from '../internal/Logger.js';
4
- import type { ZXOptions } from './ZXOptions.js';
5
-
6
- import { Logger } from '../internal/Logger.js';
7
- import { defaultContext } from '../ManagedScript/defaultContext.js';
8
-
9
- export function defaultZXOptions(options: Partial<ZXOptions> & { logLevel?: LogLevel | undefined; stderr?: NodeJS.WritableStream | undefined; stdout?: NodeJS.WritableStream | undefined }): Partial<ZXOptions> {
10
- const { cwd: optionsCwd, env: optionsEnv, logLevel: optionsLogLevel, stderr: optionsStderr, stdout: optionsStdout, ...optionsRest } = options;
11
- const env = optionsEnv == null ? process.env : { ...process.env, ...optionsEnv };
12
- const context = defaultContext({
13
- env,
14
- ...(optionsCwd == null ? {} : { cwd: optionsCwd }),
15
- ...(optionsLogLevel == null ? {} : { logLevel: optionsLogLevel }),
16
- ...(optionsStderr == null ? {} : { stderr: optionsStderr }),
17
- ...(optionsStdout == null ? {} : { stdout: optionsStdout }),
18
- });
19
- const logger = Logger.create({ color: context.color, level: context.logLevel, stderr: context.stderr, stdout: context.stdout });
20
-
21
- return {
22
- cwd: context.cwd,
23
- env: context.env,
24
- log: (entry) => {
25
- if (entry.kind === 'cmd') {
26
- logger.info(entry.cmd);
27
- return;
28
- }
29
- zxLog(entry);
30
- },
31
- preferLocal: true,
32
- quiet: context.logLevel === 'silent',
33
- stdio: 'inherit',
34
- verbose: context.logLevel === 'debug',
35
- ...optionsRest,
36
- };
37
- }