ph-cmd 0.43.14-dev.2 → 0.43.14-dev.4

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 (54) hide show
  1. package/dist/scripts/generate-commands-md.d.ts +2 -0
  2. package/dist/scripts/generate-commands-md.d.ts.map +1 -0
  3. package/dist/scripts/generate-commands-md.js +72 -0
  4. package/dist/scripts/generate-commands-md.js.map +1 -0
  5. package/dist/src/cli.js +37 -3
  6. package/dist/src/cli.js.map +1 -1
  7. package/dist/src/commands/__tests__/update.test.js +3 -3
  8. package/dist/src/commands/__tests__/update.test.js.map +1 -1
  9. package/dist/src/commands/__tests__/use.test.js +3 -3
  10. package/dist/src/commands/__tests__/use.test.js.map +1 -1
  11. package/dist/src/commands/forward.d.ts.map +1 -1
  12. package/dist/src/commands/forward.js +12 -3
  13. package/dist/src/commands/forward.js.map +1 -1
  14. package/dist/src/commands/help.d.ts +7 -0
  15. package/dist/src/commands/help.d.ts.map +1 -0
  16. package/dist/src/commands/help.js +14 -0
  17. package/dist/src/commands/help.js.map +1 -0
  18. package/dist/src/commands/index.d.ts +1 -0
  19. package/dist/src/commands/index.d.ts.map +1 -1
  20. package/dist/src/commands/index.js +3 -0
  21. package/dist/src/commands/index.js.map +1 -1
  22. package/dist/src/commands/init.d.ts.map +1 -1
  23. package/dist/src/commands/init.js +2 -0
  24. package/dist/src/commands/init.js.map +1 -1
  25. package/dist/src/commands/setup-globals.d.ts.map +1 -1
  26. package/dist/src/commands/setup-globals.js +3 -1
  27. package/dist/src/commands/setup-globals.js.map +1 -1
  28. package/dist/src/commands/update.d.ts.map +1 -1
  29. package/dist/src/commands/update.js +3 -10
  30. package/dist/src/commands/update.js.map +1 -1
  31. package/dist/src/commands/use.d.ts +1 -1
  32. package/dist/src/commands/use.d.ts.map +1 -1
  33. package/dist/src/commands/use.js +22 -4
  34. package/dist/src/commands/use.js.map +1 -1
  35. package/dist/src/help.d.ts +21 -0
  36. package/dist/src/help.d.ts.map +1 -0
  37. package/dist/src/help.js +185 -0
  38. package/dist/src/help.js.map +1 -0
  39. package/dist/src/index.d.ts +1 -1
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/index.js +1 -1
  42. package/dist/src/index.js.map +1 -1
  43. package/dist/src/utils/help-formatting.d.ts +35 -0
  44. package/dist/src/utils/help-formatting.d.ts.map +1 -0
  45. package/dist/src/utils/help-formatting.js +176 -0
  46. package/dist/src/utils/help-formatting.js.map +1 -0
  47. package/dist/src/{utils.d.ts → utils/index.d.ts} +5 -4
  48. package/dist/src/utils/index.d.ts.map +1 -0
  49. package/dist/src/{utils.js → utils/index.js} +27 -8
  50. package/dist/src/utils/index.js.map +1 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +3 -1
  53. package/dist/src/utils.d.ts.map +0 -1
  54. package/dist/src/utils.js.map +0 -1
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Help text for CLI commands
3
+ * This file centralizes all help text to keep command files clean
4
+ */
5
+ /**
6
+ * Help text for the update command
7
+ */
8
+ export declare const updateHelp = "\nCommand Overview:\n The update command helps you manage and update Powerhouse dependencies in your project. It provides\n an efficient way to keep your project up-to-date with the latest versions of Powerhouse packages.\n \n This command:\n 1. Updates all Powerhouse dependencies based on the semver ranges specified in your package.json\n 2. Can force update all dependencies to a specific environment version (dev, prod, latest)\n 3. Automatically builds any local dependencies before updating\n 4. Works with all dependencies with @powerhousedao/ prefix and special packages like document-model\n\nOptions:\n --force <env> Force update to the latest available version for the environment specified.\n Valid environments: dev, prod, latest.\n - dev: Uses @dev tag for all dependencies\n - prod/latest: Uses @latest tag for all dependencies\n \n --package-manager Override the auto-detected package manager with the specified one.\n \n --debug Show additional logs while executing the command.\n\nSpecial Cases:\n - Local Dependencies: If you have dependencies linked from a local monorepo (using file: or link:\n protocols), the command will detect the monorepo root, build affected packages, then update.\n \n - No Dependencies: If no Powerhouse dependencies are found in your project, the command will\n display a message and exit without making changes.\n\nExamples:\n $ ph update # Update dependencies based on package.json ranges\n $ ph update --force dev # Force update to latest dev version available\n $ ph update --force prod # Force update to latest stable version available (same as latest)\n $ ph update --force latest # Force update to latest stable version available (same as prod)\n $ ph update --package-manager pnpm # Specify package manager to use\n $ ph update --debug # Show debug information during update\n";
9
+ /**
10
+ * Help text for the use command
11
+ */
12
+ export declare const useHelp = "\nCommand Overview:\n The use command allows you to quickly switch between different environments for all Powerhouse\n dependencies in your project. It provides a convenient way to toggle between development,\n production, and local versions of the packages.\n\n This command:\n 1. Updates all installed Powerhouse dependencies to the specified environment\n 2. Can link to local dependencies from a monorepo for development\n 3. Only updates dependencies that are already present in your package.json\n 4. Supports special packages without the @powerhousedao prefix\n\nArguments:\n <environment> Required. The environment to use. Valid options:\n - dev: Use development versions (@dev tag)\n - prod/latest: Use production versions (@latest tag)\n - local: Use local filesystem versions (requires localPath)\n \n [localPath] Path to the local monorepo. Required when environment is 'local'.\n This should be the root of your Powerhouse monorepo.\n\nOptions:\n --force Force environment to use, even if not in the predefined list\n \n --package-manager Override the auto-detected package manager with the specified one.\n \n --debug Show additional logs during execution for troubleshooting.\n\nSpecial Cases:\n - Local Development: When using the 'local' environment, dependencies are linked directly\n to local filesystem paths, allowing for real-time development and testing.\n \n - Missing Dependencies: The command only updates Powerhouse dependencies that are already\n installed in your project. It won't add new ones.\n\nExamples:\n $ ph use dev # Switch all dependencies to development versions\n $ ph use prod # Switch all dependencies to production versions\n $ ph use latest # Same as 'prod', use latest production versions\n $ ph use local /path/to/monorepo # Link to local versions in the specified monorepo\n $ ph use dev --package-manager npm # Use npm instead of the auto-detected package manager\n $ ph use dev --debug # Show debug information during execution\n";
13
+ /**
14
+ * Help text for the setup-globals command
15
+ */
16
+ export declare const setupGlobalsHelp = "\nCommand Overview:\n The setup-globals command initializes a new Powerhouse project with the necessary global \n configuration. It helps you set up a project quickly with proper defaults and dependencies.\n\n This command:\n 1. Creates a new project with the specified name or in the current directory\n 2. Sets up all required Powerhouse dependencies\n 3. Configures the project with appropriate settings\n 4. Can run in interactive mode to guide you through the setup process\n\nArguments:\n [project-name] Optional. Name of the project to create. If not provided,\n the command will use the current directory.\n\nOptions:\n -p, --project Specify the name of the project to create.\n \n -i, --interactive Run the command in interactive mode, which will guide you\n through the setup process with questions and prompts.\n \n -v, --version Specify the development version to use. Defaults to \"main\".\n \n --dev Use the \"development\" version of the boilerplate.\n \n --staging Use the \"staging\" version of the boilerplate.\n \n --package-manager Override the auto-detected package manager with the specified one.\n\nProject Structure:\n The command will set up a project with the following structure:\n - Proper configuration files for TypeScript and ESLint\n - Dependencies for Powerhouse packages\n - Build and development scripts\n\nExamples:\n $ ph setup-globals my-project # Create a new project named \"my-project\"\n $ ph setup-globals # Set up a project in the current directory\n $ ph setup-globals -i # Run setup in interactive mode\n $ ph setup-globals --dev # Use development version\n $ ph setup-globals -v beta # Use specific version\n $ ph setup-globals --package-manager npm # Use npm as package manager\n";
17
+ /**
18
+ * Help text for the init command
19
+ */
20
+ export declare const initHelp = "\nCommand Overview:\n The init command creates a new Powerhouse project with optimal defaults. It sets up a fully \n configured project structure with all necessary dependencies, configurations, and boilerplate.\n\n This command:\n 1. Creates a new project with the specified name\n 2. Installs all required dependencies for Powerhouse development\n 3. Sets up a proper project structure and configuration files\n 4. Can run in interactive mode for customized setup\n\nArguments:\n [project-name] Optional. Name of the project to create. If not provided,\n you'll be prompted to provide a name, or the current directory \n will be used if in interactive mode.\n\nOptions:\n -p, --project Specify the name of the project to create.\n \n -i, --interactive Run the command in interactive mode, which will guide you\n through the project setup with customizable options.\n \n -v, --version Specify the development version to use. Defaults to \"main\".\n \n --dev Use the \"development\" version of the boilerplate.\n \n --staging Use the \"staging\" version of the boilerplate.\n \n --package-manager Override the auto-detected package manager with the specified one.\n\nProject Structure:\n The command will create a complete project with:\n - Properly configured TypeScript and build settings\n - Powerhouse document-model integration\n - All necessary package.json dependencies\n - Development scripts and tooling\n\nExamples:\n $ ph init my-awesome-project # Create a new project named \"my-awesome-project\"\n $ ph init -i # Create a project in interactive mode\n $ ph init -p my-project # Same as ph init my-project\n $ ph init --dev # Use development version of boilerplate\n $ ph init -v beta # Use specific version\n $ ph init --package-manager yarn # Use yarn as package manager\n";
21
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/help.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,miEAmCtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,6vEA0CnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,kgEA0C5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,klEA4CpB,CAAC"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Help text for CLI commands
3
+ * This file centralizes all help text to keep command files clean
4
+ */
5
+ /**
6
+ * Help text for the update command
7
+ */
8
+ export const updateHelp = `
9
+ Command Overview:
10
+ The update command helps you manage and update Powerhouse dependencies in your project. It provides
11
+ an efficient way to keep your project up-to-date with the latest versions of Powerhouse packages.
12
+
13
+ This command:
14
+ 1. Updates all Powerhouse dependencies based on the semver ranges specified in your package.json
15
+ 2. Can force update all dependencies to a specific environment version (dev, prod, latest)
16
+ 3. Automatically builds any local dependencies before updating
17
+ 4. Works with all dependencies with @powerhousedao/ prefix and special packages like document-model
18
+
19
+ Options:
20
+ --force <env> Force update to the latest available version for the environment specified.
21
+ Valid environments: dev, prod, latest.
22
+ - dev: Uses @dev tag for all dependencies
23
+ - prod/latest: Uses @latest tag for all dependencies
24
+
25
+ --package-manager Override the auto-detected package manager with the specified one.
26
+
27
+ --debug Show additional logs while executing the command.
28
+
29
+ Special Cases:
30
+ - Local Dependencies: If you have dependencies linked from a local monorepo (using file: or link:
31
+ protocols), the command will detect the monorepo root, build affected packages, then update.
32
+
33
+ - No Dependencies: If no Powerhouse dependencies are found in your project, the command will
34
+ display a message and exit without making changes.
35
+
36
+ Examples:
37
+ $ ph update # Update dependencies based on package.json ranges
38
+ $ ph update --force dev # Force update to latest dev version available
39
+ $ ph update --force prod # Force update to latest stable version available (same as latest)
40
+ $ ph update --force latest # Force update to latest stable version available (same as prod)
41
+ $ ph update --package-manager pnpm # Specify package manager to use
42
+ $ ph update --debug # Show debug information during update
43
+ `;
44
+ /**
45
+ * Help text for the use command
46
+ */
47
+ export const useHelp = `
48
+ Command Overview:
49
+ The use command allows you to quickly switch between different environments for all Powerhouse
50
+ dependencies in your project. It provides a convenient way to toggle between development,
51
+ production, and local versions of the packages.
52
+
53
+ This command:
54
+ 1. Updates all installed Powerhouse dependencies to the specified environment
55
+ 2. Can link to local dependencies from a monorepo for development
56
+ 3. Only updates dependencies that are already present in your package.json
57
+ 4. Supports special packages without the @powerhousedao prefix
58
+
59
+ Arguments:
60
+ <environment> Required. The environment to use. Valid options:
61
+ - dev: Use development versions (@dev tag)
62
+ - prod/latest: Use production versions (@latest tag)
63
+ - local: Use local filesystem versions (requires localPath)
64
+
65
+ [localPath] Path to the local monorepo. Required when environment is 'local'.
66
+ This should be the root of your Powerhouse monorepo.
67
+
68
+ Options:
69
+ --force Force environment to use, even if not in the predefined list
70
+
71
+ --package-manager Override the auto-detected package manager with the specified one.
72
+
73
+ --debug Show additional logs during execution for troubleshooting.
74
+
75
+ Special Cases:
76
+ - Local Development: When using the 'local' environment, dependencies are linked directly
77
+ to local filesystem paths, allowing for real-time development and testing.
78
+
79
+ - Missing Dependencies: The command only updates Powerhouse dependencies that are already
80
+ installed in your project. It won't add new ones.
81
+
82
+ Examples:
83
+ $ ph use dev # Switch all dependencies to development versions
84
+ $ ph use prod # Switch all dependencies to production versions
85
+ $ ph use latest # Same as 'prod', use latest production versions
86
+ $ ph use local /path/to/monorepo # Link to local versions in the specified monorepo
87
+ $ ph use dev --package-manager npm # Use npm instead of the auto-detected package manager
88
+ $ ph use dev --debug # Show debug information during execution
89
+ `;
90
+ /**
91
+ * Help text for the setup-globals command
92
+ */
93
+ export const setupGlobalsHelp = `
94
+ Command Overview:
95
+ The setup-globals command initializes a new Powerhouse project with the necessary global
96
+ configuration. It helps you set up a project quickly with proper defaults and dependencies.
97
+
98
+ This command:
99
+ 1. Creates a new project with the specified name or in the current directory
100
+ 2. Sets up all required Powerhouse dependencies
101
+ 3. Configures the project with appropriate settings
102
+ 4. Can run in interactive mode to guide you through the setup process
103
+
104
+ Arguments:
105
+ [project-name] Optional. Name of the project to create. If not provided,
106
+ the command will use the current directory.
107
+
108
+ Options:
109
+ -p, --project Specify the name of the project to create.
110
+
111
+ -i, --interactive Run the command in interactive mode, which will guide you
112
+ through the setup process with questions and prompts.
113
+
114
+ -v, --version Specify the development version to use. Defaults to "main".
115
+
116
+ --dev Use the "development" version of the boilerplate.
117
+
118
+ --staging Use the "staging" version of the boilerplate.
119
+
120
+ --package-manager Override the auto-detected package manager with the specified one.
121
+
122
+ Project Structure:
123
+ The command will set up a project with the following structure:
124
+ - Proper configuration files for TypeScript and ESLint
125
+ - Dependencies for Powerhouse packages
126
+ - Build and development scripts
127
+
128
+ Examples:
129
+ $ ph setup-globals my-project # Create a new project named "my-project"
130
+ $ ph setup-globals # Set up a project in the current directory
131
+ $ ph setup-globals -i # Run setup in interactive mode
132
+ $ ph setup-globals --dev # Use development version
133
+ $ ph setup-globals -v beta # Use specific version
134
+ $ ph setup-globals --package-manager npm # Use npm as package manager
135
+ `;
136
+ /**
137
+ * Help text for the init command
138
+ */
139
+ export const initHelp = `
140
+ Command Overview:
141
+ The init command creates a new Powerhouse project with optimal defaults. It sets up a fully
142
+ configured project structure with all necessary dependencies, configurations, and boilerplate.
143
+
144
+ This command:
145
+ 1. Creates a new project with the specified name
146
+ 2. Installs all required dependencies for Powerhouse development
147
+ 3. Sets up a proper project structure and configuration files
148
+ 4. Can run in interactive mode for customized setup
149
+
150
+ Arguments:
151
+ [project-name] Optional. Name of the project to create. If not provided,
152
+ you'll be prompted to provide a name, or the current directory
153
+ will be used if in interactive mode.
154
+
155
+ Options:
156
+ -p, --project Specify the name of the project to create.
157
+
158
+ -i, --interactive Run the command in interactive mode, which will guide you
159
+ through the project setup with customizable options.
160
+
161
+ -v, --version Specify the development version to use. Defaults to "main".
162
+
163
+ --dev Use the "development" version of the boilerplate.
164
+
165
+ --staging Use the "staging" version of the boilerplate.
166
+
167
+ --package-manager Override the auto-detected package manager with the specified one.
168
+
169
+ Project Structure:
170
+ The command will create a complete project with:
171
+ - Properly configured TypeScript and build settings
172
+ - Powerhouse document-model integration
173
+ - All necessary package.json dependencies
174
+ - Development scripts and tooling
175
+
176
+ Examples:
177
+ $ ph init my-awesome-project # Create a new project named "my-awesome-project"
178
+ $ ph init -i # Create a project in interactive mode
179
+ $ ph init -p my-project # Same as ph init my-project
180
+ $ ph init --dev # Use development version of boilerplate
181
+ $ ph init -v beta # Use specific version
182
+ $ ph init --package-manager yarn # Use yarn as package manager
183
+ `;
184
+ // Add other command help texts here as needed
185
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/help.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCzB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0C/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CvB,CAAC;AAEF,8CAA8C"}
@@ -1,3 +1,3 @@
1
1
  export * from "./commands/index.js";
2
- export * from "./utils.js";
2
+ export * from "./utils/index.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "./commands/index.js";
2
- export * from "./utils.js";
2
+ export * from "./utils/index.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type Command } from "commander";
2
+ export declare const HELP_FORMATTING_CONFIG: {
3
+ FIXED_COLUMN_WIDTH: number;
4
+ COMMANDS_TO_PAD: string[];
5
+ DESCRIPTION_PADDING: string;
6
+ };
7
+ /**
8
+ * Merges CLI help text with the forwarded PH CLI help text
9
+ * @param {string} cliHelp - Commander-generated help text
10
+ * @param {string} forwardedHelp - Help text from the PH CLI
11
+ * @returns {string} Merged help text
12
+ */
13
+ export declare function mergeHelp(cliHelp: string, forwardedHelp: string): string;
14
+ /**
15
+ * Applies padding to command descriptions for better alignment
16
+ * @param {Command} program - Commander program instance
17
+ */
18
+ export declare function applyCommandPadding(program: Command): void;
19
+ /**
20
+ * Restores original command descriptions after generating help
21
+ * @param {Command} program - Commander program instance
22
+ */
23
+ export declare function restoreCommandDescriptions(program: Command): void;
24
+ /**
25
+ * Captures Commander help output as a string
26
+ * @param {Command} program - Commander program instance
27
+ * @returns {string} Help text as a string
28
+ */
29
+ export declare function captureCommanderHelp(program: Command): string;
30
+ /**
31
+ * Generates and displays the merged help output
32
+ * @param {Command} program - Commander program instance
33
+ */
34
+ export declare function generateMergedHelp(program: Command): Promise<void>;
35
+ //# sourceMappingURL=help-formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-formatting.d.ts","sourceRoot":"","sources":["../../../src/utils/help-formatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,eAAO,MAAM,sBAAsB;;;;CAOlC,CAAC;AAiEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA2DxE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAS1D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAOjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAe7D;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BxE"}
@@ -0,0 +1,176 @@
1
+ import { forwardPHCommand, getPackageManagerFromLockfile, getProjectInfo, } from "./index.js";
2
+ // Configuration constants for help formatting
3
+ export const HELP_FORMATTING_CONFIG = {
4
+ // Column width for command descriptions alignment
5
+ FIXED_COLUMN_WIDTH: 55,
6
+ // List of command names to apply padding to
7
+ COMMANDS_TO_PAD: ["setup-globals", "init", "use", "update", "help"],
8
+ // Padding to add before command descriptions for alignment
9
+ DESCRIPTION_PADDING: " ",
10
+ };
11
+ /**
12
+ * Extracts command and description parts from a command line
13
+ * @param {string} line - A line from the help text containing a command
14
+ * @returns {{ cmd: string, desc: string }} Normalized command parts
15
+ */
16
+ function extractCommandParts(line) {
17
+ // First try to match a command with options and arguments
18
+ let match = /^(\s+\S+(?:\|\S+)*(?:\s+\[options\])?(?:\s+\[[^\]]+\]|\s+<[^>]+>)*)(.*)$/.exec(line);
19
+ if (!match) {
20
+ // Fallback to a simpler pattern
21
+ match = /^(\s+\S+(?:\|\S+)*)(.*)$/.exec(line);
22
+ }
23
+ if (!match) {
24
+ return { cmd: line, desc: "" };
25
+ }
26
+ return {
27
+ cmd: match[1].trimEnd(),
28
+ desc: match[2].trim(),
29
+ };
30
+ }
31
+ /**
32
+ * Formats a command with proper description alignment
33
+ * @param {object} parts - Command parts with cmd and desc properties
34
+ * @param {number} columnWidth - Fixed position for descriptions to start
35
+ * @returns {string} Formatted command line
36
+ */
37
+ function formatCommandLine({ cmd, desc }, columnWidth) {
38
+ // Calculate padding needed for alignment
39
+ const padding = " ".repeat(Math.max(2, columnWidth - cmd.length));
40
+ return `${cmd}${padding}${desc}`;
41
+ }
42
+ /**
43
+ * Extracts command lines from help text starting from the Commands section
44
+ * @param {string[]} lines - Help text split into lines
45
+ * @param {number} startIndex - Index of the Commands section header
46
+ * @returns {string[]} Array of command lines
47
+ */
48
+ function extractCommandLines(lines, startIndex) {
49
+ const commands = [];
50
+ for (let i = startIndex + 1; i < lines.length; i++) {
51
+ const line = lines[i];
52
+ // Stop when we hit an empty line or no longer see command formatting
53
+ if (!line.trim() || !/^\s{2}\S/.exec(line)) {
54
+ break;
55
+ }
56
+ commands.push(line);
57
+ }
58
+ return commands;
59
+ }
60
+ /**
61
+ * Merges CLI help text with the forwarded PH CLI help text
62
+ * @param {string} cliHelp - Commander-generated help text
63
+ * @param {string} forwardedHelp - Help text from the PH CLI
64
+ * @returns {string} Merged help text
65
+ */
66
+ export function mergeHelp(cliHelp, forwardedHelp) {
67
+ // Split help text into lines
68
+ const cliLines = cliHelp.split("\n");
69
+ const forwardedLines = forwardedHelp.split("\n");
70
+ // Find the Commands section in both help texts
71
+ const cliCommandsIndex = cliLines.findIndex((line) => line.trim() === "Commands:");
72
+ const forwardedCommandsIndex = forwardedLines.findIndex((line) => line.trim() === "Commands:");
73
+ // Extract command lines
74
+ const cliCommands = extractCommandLines(cliLines, cliCommandsIndex);
75
+ const forwardedCommands = extractCommandLines(forwardedLines, forwardedCommandsIndex);
76
+ // Create a set of CLI command names to avoid duplicates
77
+ const cliCommandNames = new Set();
78
+ cliCommands.forEach((line) => {
79
+ const match = /^\s+(\S+)(?:\|.*)?/.exec(line);
80
+ if (match)
81
+ cliCommandNames.add(match[1]);
82
+ });
83
+ // Filter out duplicate commands from forwarded help
84
+ const uniqueForwardedCommands = forwardedCommands.filter((line) => {
85
+ const match = /^\s+(\S+)(?:\|.*)?/.exec(line);
86
+ if (!match)
87
+ return false;
88
+ // Explicitly filter out 'help' command from forwarded commands
89
+ if (match[1] === "help")
90
+ return false;
91
+ return !cliCommandNames.has(match[1]);
92
+ });
93
+ // Process and format all commands
94
+ const cliParts = cliCommands.map(extractCommandParts);
95
+ const forwardedParts = uniqueForwardedCommands.map(extractCommandParts);
96
+ // Format with consistent alignment
97
+ const formattedCliCommands = cliParts.map((parts) => formatCommandLine(parts, HELP_FORMATTING_CONFIG.FIXED_COLUMN_WIDTH));
98
+ const formattedForwardedCommands = forwardedParts.map((parts) => formatCommandLine(parts, HELP_FORMATTING_CONFIG.FIXED_COLUMN_WIDTH));
99
+ // Extract header section
100
+ const headerSection = cliLines.slice(0, cliCommandsIndex + 1).join("\n");
101
+ // Combine all sections
102
+ return [
103
+ headerSection,
104
+ formattedCliCommands.join("\n"),
105
+ formattedForwardedCommands.join("\n"),
106
+ ].join("\n");
107
+ }
108
+ /**
109
+ * Applies padding to command descriptions for better alignment
110
+ * @param {Command} program - Commander program instance
111
+ */
112
+ export function applyCommandPadding(program) {
113
+ program.commands.forEach((cmd) => {
114
+ if (HELP_FORMATTING_CONFIG.COMMANDS_TO_PAD.includes(cmd.name())) {
115
+ // Store original description in a property we can retrieve later
116
+ const desc = cmd.description();
117
+ // Add padding to the description
118
+ cmd.description(HELP_FORMATTING_CONFIG.DESCRIPTION_PADDING + desc);
119
+ }
120
+ });
121
+ }
122
+ /**
123
+ * Restores original command descriptions after generating help
124
+ * @param {Command} program - Commander program instance
125
+ */
126
+ export function restoreCommandDescriptions(program) {
127
+ program.commands.forEach((cmd) => {
128
+ if (HELP_FORMATTING_CONFIG.COMMANDS_TO_PAD.includes(cmd.name())) {
129
+ const desc = cmd.description();
130
+ cmd.description(desc.trim());
131
+ }
132
+ });
133
+ }
134
+ /**
135
+ * Captures Commander help output as a string
136
+ * @param {Command} program - Commander program instance
137
+ * @returns {string} Help text as a string
138
+ */
139
+ export function captureCommanderHelp(program) {
140
+ let helpText = "";
141
+ const originalConsoleLog = console.log;
142
+ // Override console.log to capture output
143
+ console.log = (...args) => {
144
+ helpText += args.join(" ") + "\n";
145
+ };
146
+ program.outputHelp();
147
+ // Restore console.log
148
+ console.log = originalConsoleLog;
149
+ return helpText;
150
+ }
151
+ /**
152
+ * Generates and displays the merged help output
153
+ * @param {Command} program - Commander program instance
154
+ */
155
+ export async function generateMergedHelp(program) {
156
+ // Get project information
157
+ const projectInfo = await getProjectInfo(undefined, false);
158
+ if (projectInfo.available) {
159
+ const packageManager = getPackageManagerFromLockfile(projectInfo.path);
160
+ // Get forwarded help from PH CLI
161
+ const forwardedHelp = forwardPHCommand(packageManager, projectInfo.path, "help", undefined, true);
162
+ // Apply padding to command descriptions for better alignment
163
+ applyCommandPadding(program);
164
+ // Capture the output without displaying it
165
+ const helpText = captureCommanderHelp(program);
166
+ // Restore original descriptions
167
+ restoreCommandDescriptions(program);
168
+ // Merge and display help
169
+ const mergedHelp = mergeHelp(helpText, forwardedHelp);
170
+ console.log(mergedHelp);
171
+ }
172
+ else {
173
+ console.log(captureCommanderHelp(program));
174
+ }
175
+ }
176
+ //# sourceMappingURL=help-formatting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-formatting.js","sourceRoot":"","sources":["../../../src/utils/help-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CAAC;IAEF,OAAO,CAAC,UAAU,EAAE,CAAC;IAErB,sBAAsB;IACtB,OAAO,CAAC,GAAG,GAAG,kBAAkB,CAAC;IAEjC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAgB;IACvD,0BAA0B;IAC1B,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE3D,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAG,6BAA6B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAEvE,iCAAiC;QACjC,MAAM,aAAa,GAAG,gBAAgB,CACpC,cAAc,EACd,WAAW,CAAC,IAAI,EAChB,MAAM,EACN,SAAS,EACT,IAAI,CACL,CAAC;QAEF,6DAA6D;QAC7D,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAE7B,2CAA2C;QAC3C,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAE/C,gCAAgC;QAChC,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAEpC,yBAAyB;QACzB,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -48,6 +48,7 @@ export declare const packageManagers: {
48
48
  };
49
49
  export type ProjectInfo = {
50
50
  isGlobal: boolean;
51
+ available: boolean;
51
52
  path: string;
52
53
  };
53
54
  export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
@@ -57,8 +58,8 @@ export declare function isPowerhouseProject(dir: string): boolean;
57
58
  export declare function findNodeProjectRoot(dir: string, pathValidation?: PathValidation): string | null;
58
59
  export declare function getPackageManagerFromPath(dir: string): PackageManager;
59
60
  export declare function getPackageManagerFromLockfile(dir: string): PackageManager;
60
- export declare function getProjectInfo(debug?: boolean): Promise<ProjectInfo>;
61
- export declare function forwardPHCommand(packageManager: PackageManager, projectPath: string, args: string, debug?: boolean): void;
61
+ export declare function getProjectInfo(debug?: boolean, generateGlobalProject?: boolean): Promise<ProjectInfo>;
62
+ export declare function forwardPHCommand(packageManager: PackageManager, projectPath: string, args: string, debug?: boolean, captureOutput?: boolean): string;
62
63
  /**
63
64
  * Recursively searches for a specific file by traversing up the directory tree.
64
65
  * Starting from the given path, it checks each parent directory until it finds
@@ -86,5 +87,5 @@ export type GlobalProjectOptions = {
86
87
  packageManager?: string;
87
88
  };
88
89
  export declare const createGlobalProject: (projectName?: string, options?: GlobalProjectOptions) => Promise<void>;
89
- export {};
90
- //# sourceMappingURL=utils.d.ts.map
90
+ export * from "./help-formatting.js";
91
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,QAAkB,CAAC;AAC3C,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,eAAe,UAiB3B,CAAC;AACF,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,QAAQ,QAAY,CAAC;AAClC,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,qBAAqB,QAGjC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwClB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MA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BnC,CAAC;AAEF,cAAc,sBAAsB,CAAC"}
@@ -111,25 +111,31 @@ export function getPackageManagerFromLockfile(dir) {
111
111
  }
112
112
  return "npm";
113
113
  }
114
- export async function getProjectInfo(debug) {
114
+ export async function getProjectInfo(debug, generateGlobalProject = true) {
115
115
  const currentPath = process.cwd();
116
116
  if (debug) {
117
117
  console.log(">>> currentPath:", currentPath);
118
118
  }
119
119
  const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);
120
120
  if (!projectPath) {
121
- await createGlobalProject();
121
+ let available = fs.existsSync(POWERHOUSE_GLOBAL_DIR);
122
+ if (generateGlobalProject) {
123
+ await createGlobalProject();
124
+ available = true;
125
+ }
122
126
  return {
127
+ available,
123
128
  isGlobal: true,
124
129
  path: POWERHOUSE_GLOBAL_DIR,
125
130
  };
126
131
  }
127
132
  return {
128
133
  isGlobal: false,
134
+ available: true,
129
135
  path: projectPath,
130
136
  };
131
137
  }
132
- export function forwardPHCommand(packageManager, projectPath, args, debug) {
138
+ export function forwardPHCommand(packageManager, projectPath, args, debug, captureOutput = false) {
133
139
  const manager = packageManagers[packageManager];
134
140
  const command = manager.execCommand;
135
141
  const execCommand = command.replace("{{arguments}}", args);
@@ -140,10 +146,22 @@ export function forwardPHCommand(packageManager, projectPath, args, debug) {
140
146
  console.log(">>> projectPath:", projectPath);
141
147
  console.log(">>> packageManager:", packageManager);
142
148
  }
143
- execSync(execCommand, {
144
- stdio: "inherit",
145
- ...commandOptions,
146
- });
149
+ if (captureOutput) {
150
+ // Capture output and return it
151
+ return execSync(execCommand, {
152
+ stdio: "pipe",
153
+ encoding: "utf8",
154
+ ...commandOptions,
155
+ });
156
+ }
157
+ else {
158
+ // Original behavior - pipe directly to stdout/stderr
159
+ execSync(execCommand, {
160
+ stdio: "inherit",
161
+ ...commandOptions,
162
+ });
163
+ return "";
164
+ }
147
165
  }
148
166
  /**
149
167
  * Recursively searches for a specific file by traversing up the directory tree.
@@ -210,4 +228,5 @@ export const createGlobalProject = async (projectName, options = {}) => {
210
228
  console.error("❌ Failed to initialize the global project", error);
211
229
  }
212
230
  };
213
- //# sourceMappingURL=utils.js.map
231
+ export * from "./help-formatting.js";
232
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM;IACN,KAAK;IACL,SAAS;IACT,UAAU;IACV,SAAS;IACT,aAAa;IACb,MAAM;IACN,SAAS;IACT,KAAK;IACL,GAAG;IACH,QAAQ;IACR,WAAW;IACX,SAAS;IACT,MAAM;IACN,SAAS;IACT,SAAS;CACV,CAAC;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAC5C,QAAQ,EACR,sBAAsB,CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE;QACH,cAAc,EAAE,wBAAwB;QACxC,WAAW,EAAE,OAAO,MAAM,gBAAgB;QAC1C,UAAU,EAAE,mBA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