hereya-cli 0.20.0 → 0.22.0

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.
@@ -1,10 +1,9 @@
1
1
  import { SpawnOptions } from 'node:child_process';
2
- export declare function setDebug(value: boolean): void;
3
- export declare function isDebug(): boolean;
2
+ import { type Logger } from './log.js';
4
3
  export interface RunShellOptions {
5
4
  directory?: string;
6
5
  env?: NodeJS.ProcessEnv;
7
- logger?: typeof defaultLogger;
6
+ logger?: Logger;
8
7
  stdio?: SpawnOptions['stdio'];
9
8
  }
10
9
  export declare function runShell(cmd: string, args: string[], options?: RunShellOptions): Promise<{
@@ -15,8 +14,3 @@ export declare function runShell(cmd: string, args: string[], options?: RunShell
15
14
  stdout: string;
16
15
  }>;
17
16
  export declare function delay(ms: number): Promise<unknown> | undefined;
18
- export declare const defaultLogger: {
19
- debug(message: string): void;
20
- error(message: string): void;
21
- info(message: string): void;
22
- };
package/dist/lib/shell.js CHANGED
@@ -1,24 +1,18 @@
1
1
  import { spawn } from 'node:child_process';
2
- let debug = false;
3
- export function setDebug(value) {
4
- debug = value;
5
- }
6
- export function isDebug() {
7
- return debug;
8
- }
2
+ import { getDefaultLogger } from './log.js';
9
3
  // Asynchronous runShell that logs output using the provided logger.
10
4
  export async function runShell(cmd, args, options = {}) {
11
5
  return new Promise((resolve, reject) => {
12
6
  // Use the provided logger or default to console.log
13
- const logger = options.logger ?? defaultLogger;
7
+ const logger = options.logger ?? getDefaultLogger();
14
8
  const spawnOptions = {
15
9
  cwd: options.directory ?? process.cwd(),
16
10
  env: { ...process.env, ...options.env },
17
11
  shell: true,
18
12
  // If not explicitly set, use 'inherit' when debugging, or 'pipe' otherwise
19
- stdio: options.stdio ?? (isDebug() ? 'inherit' : 'pipe'),
13
+ stdio: options.stdio ?? 'pipe',
20
14
  };
21
- logger.debug(`Executing: ${cmd} ${args.join(' ')}`);
15
+ logger.debug(`Executing: ${cmd} ${args.join(' ')}\n`);
22
16
  const child = spawn(cmd, args, spawnOptions);
23
17
  // Buffers to accumulate output from the process.
24
18
  let stdout = '';
@@ -49,7 +43,7 @@ export async function runShell(cmd, args, options = {}) {
49
43
  });
50
44
  child.on('close', () => {
51
45
  if (exitCode !== 0) {
52
- const errorMsg = `Command "${cmd} ${args.join(' ')}" failed with exit code "${exitCode}"`;
46
+ const errorMsg = `Command "${cmd} ${args.join(' ')}" failed with exit code "${exitCode}"\n`;
53
47
  logger.error(errorMsg);
54
48
  return reject(new Error(errorMsg));
55
49
  }
@@ -71,20 +65,3 @@ export function delay(ms) {
71
65
  setTimeout(resolve, ms);
72
66
  });
73
67
  }
74
- export const defaultLogger = {
75
- debug(message) {
76
- if (isDebug()) {
77
- console.debug(message);
78
- }
79
- },
80
- error(message) {
81
- if (isDebug()) {
82
- console.error(message);
83
- }
84
- },
85
- info(message) {
86
- if (isDebug()) {
87
- console.info(message);
88
- }
89
- },
90
- };
@@ -4,7 +4,7 @@
4
4
  "aliases": [],
5
5
  "args": {
6
6
  "package": {
7
- "description": "The package to add. Packages are gitHub repositories. Use the format owner/repository",
7
+ "description": "\n The package to add, specified as a GitHub repository in the format owner/repository.\n To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.\n For local packages, use the format local://path/to/package where path/to/package is the path to the package on your local machine.\n ",
8
8
  "name": "package",
9
9
  "required": true
10
10
  }
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "flags": {
17
17
  "chdir": {
18
- "description": "directory to run command in",
18
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
19
19
  "name": "chdir",
20
20
  "required": false,
21
21
  "hasDynamicHelp": false,
@@ -102,7 +102,7 @@
102
102
  ],
103
103
  "flags": {
104
104
  "chdir": {
105
- "description": "directory to run command in",
105
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
106
106
  "name": "chdir",
107
107
  "required": false,
108
108
  "hasDynamicHelp": false,
@@ -150,7 +150,7 @@
150
150
  ],
151
151
  "flags": {
152
152
  "chdir": {
153
- "description": "directory to run command in",
153
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
154
154
  "name": "chdir",
155
155
  "required": false,
156
156
  "hasDynamicHelp": false,
@@ -172,7 +172,7 @@
172
172
  },
173
173
  "workspace": {
174
174
  "char": "w",
175
- "description": "name of the workspace to install the packages for",
175
+ "description": "name of the workspace to destroy the packages for",
176
176
  "name": "workspace",
177
177
  "required": false,
178
178
  "hasDynamicHelp": false,
@@ -308,7 +308,7 @@
308
308
  "aliases": [],
309
309
  "args": {
310
310
  "package": {
311
- "description": "The package to remove. Packages are gitHub repositories. Use the format owner/repository",
311
+ "description": "Remove a previously added package.",
312
312
  "name": "package",
313
313
  "required": true
314
314
  }
@@ -319,7 +319,7 @@
319
319
  ],
320
320
  "flags": {
321
321
  "chdir": {
322
- "description": "directory to run command in",
322
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
323
323
  "name": "chdir",
324
324
  "required": false,
325
325
  "hasDynamicHelp": false,
@@ -446,7 +446,7 @@
446
446
  ],
447
447
  "flags": {
448
448
  "chdir": {
449
- "description": "directory to run command in",
449
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
450
450
  "name": "chdir",
451
451
  "required": false,
452
452
  "hasDynamicHelp": false,
@@ -494,7 +494,7 @@
494
494
  ],
495
495
  "flags": {
496
496
  "chdir": {
497
- "description": "directory to run command in",
497
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
498
498
  "name": "chdir",
499
499
  "required": false,
500
500
  "hasDynamicHelp": false,
@@ -954,5 +954,5 @@
954
954
  ]
955
955
  }
956
956
  },
957
- "version": "0.20.0"
957
+ "version": "0.22.0"
958
958
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.20.0",
4
+ "version": "0.22.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"