ph-cmd 6.0.0-dev.6 → 6.0.0-dev.7
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/build/cli.js +1495 -0
- package/package.json +8 -8
- package/dist/scripts/generate-commands-md.d.ts +0 -2
- package/dist/scripts/generate-commands-md.d.ts.map +0 -1
- package/dist/scripts/generate-commands-md.js +0 -72
- package/dist/scripts/generate-commands-md.js.map +0 -1
- package/dist/scripts/generate-version.d.ts +0 -2
- package/dist/scripts/generate-version.d.ts.map +0 -1
- package/dist/scripts/generate-version.js +0 -13
- package/dist/scripts/generate-version.js.map +0 -1
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -120
- package/dist/src/cli.js.map +0 -1
- package/dist/src/commands/__tests__/update.test.d.ts +0 -2
- package/dist/src/commands/__tests__/update.test.d.ts.map +0 -1
- package/dist/src/commands/__tests__/update.test.js +0 -157
- package/dist/src/commands/__tests__/update.test.js.map +0 -1
- package/dist/src/commands/__tests__/use.test.d.ts +0 -2
- package/dist/src/commands/__tests__/use.test.d.ts.map +0 -1
- package/dist/src/commands/__tests__/use.test.js +0 -496
- package/dist/src/commands/__tests__/use.test.js.map +0 -1
- package/dist/src/commands/checkout.d.ts +0 -9
- package/dist/src/commands/checkout.d.ts.map +0 -1
- package/dist/src/commands/checkout.js +0 -37
- package/dist/src/commands/checkout.js.map +0 -1
- package/dist/src/commands/forward.d.ts +0 -7
- package/dist/src/commands/forward.d.ts.map +0 -1
- package/dist/src/commands/forward.js +0 -45
- package/dist/src/commands/forward.js.map +0 -1
- package/dist/src/commands/help.d.ts +0 -7
- package/dist/src/commands/help.d.ts.map +0 -1
- package/dist/src/commands/help.js +0 -14
- package/dist/src/commands/help.js.map +0 -1
- package/dist/src/commands/index.d.ts +0 -9
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/index.js +0 -15
- package/dist/src/commands/index.js.map +0 -1
- package/dist/src/commands/init.d.ts +0 -2
- package/dist/src/commands/init.d.ts.map +0 -1
- package/dist/src/commands/init.js +0 -165
- package/dist/src/commands/init.js.map +0 -1
- package/dist/src/commands/setup-globals.d.ts +0 -20
- package/dist/src/commands/setup-globals.d.ts.map +0 -1
- package/dist/src/commands/setup-globals.js +0 -24
- package/dist/src/commands/setup-globals.js.map +0 -1
- package/dist/src/commands/update.d.ts +0 -2
- package/dist/src/commands/update.d.ts.map +0 -1
- package/dist/src/commands/update.js +0 -95
- package/dist/src/commands/update.js.map +0 -1
- package/dist/src/commands/update.old.d.ts +0 -13
- package/dist/src/commands/update.old.d.ts.map +0 -1
- package/dist/src/commands/update.old.js +0 -105
- package/dist/src/commands/update.old.js.map +0 -1
- package/dist/src/commands/use-local.d.ts +0 -2
- package/dist/src/commands/use-local.d.ts.map +0 -1
- package/dist/src/commands/use-local.js +0 -115
- package/dist/src/commands/use-local.js.map +0 -1
- package/dist/src/commands/use.d.ts +0 -2
- package/dist/src/commands/use.d.ts.map +0 -1
- package/dist/src/commands/use.js +0 -117
- package/dist/src/commands/use.js.map +0 -1
- package/dist/src/commands/use.old.d.ts +0 -55
- package/dist/src/commands/use.old.d.ts.map +0 -1
- package/dist/src/commands/use.old.js +0 -219
- package/dist/src/commands/use.old.js.map +0 -1
- package/dist/src/commands/version.d.ts +0 -5
- package/dist/src/commands/version.d.ts.map +0 -1
- package/dist/src/commands/version.js +0 -42
- package/dist/src/commands/version.js.map +0 -1
- package/dist/src/help.d.ts +0 -25
- package/dist/src/help.d.ts.map +0 -1
- package/dist/src/help.js +0 -230
- package/dist/src/help.js.map +0 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +0 -1
- package/dist/src/types.d.ts +0 -2
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/constants.d.ts +0 -59
- package/dist/src/utils/constants.d.ts.map +0 -1
- package/dist/src/utils/constants.js +0 -102
- package/dist/src/utils/constants.js.map +0 -1
- package/dist/src/utils/dependencies.d.ts +0 -4
- package/dist/src/utils/dependencies.d.ts.map +0 -1
- package/dist/src/utils/dependencies.js +0 -61
- package/dist/src/utils/dependencies.js.map +0 -1
- package/dist/src/utils/file-system.d.ts +0 -2
- package/dist/src/utils/file-system.d.ts.map +0 -1
- package/dist/src/utils/file-system.js +0 -12
- package/dist/src/utils/file-system.js.map +0 -1
- package/dist/src/utils/help-formatting.d.ts +0 -35
- package/dist/src/utils/help-formatting.d.ts.map +0 -1
- package/dist/src/utils/help-formatting.js +0 -188
- package/dist/src/utils/help-formatting.js.map +0 -1
- package/dist/src/utils/help.d.ts +0 -31
- package/dist/src/utils/help.d.ts.map +0 -1
- package/dist/src/utils/help.js +0 -72
- package/dist/src/utils/help.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -8
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js +0 -7
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/package-manager.d.ts +0 -27
- package/dist/src/utils/package-manager.d.ts.map +0 -1
- package/dist/src/utils/package-manager.js +0 -177
- package/dist/src/utils/package-manager.js.map +0 -1
- package/dist/src/utils/parsing.d.ts +0 -20
- package/dist/src/utils/parsing.d.ts.map +0 -1
- package/dist/src/utils/parsing.js +0 -52
- package/dist/src/utils/parsing.js.map +0 -1
- package/dist/src/utils/run-cmd.d.ts +0 -2
- package/dist/src/utils/run-cmd.d.ts.map +0 -1
- package/dist/src/utils/run-cmd.js +0 -11
- package/dist/src/utils/run-cmd.js.map +0 -1
- package/dist/src/utils/types.d.ts +0 -21
- package/dist/src/utils/types.d.ts.map +0 -1
- package/dist/src/utils/types.js +0 -2
- package/dist/src/utils/types.js.map +0 -1
- package/dist/src/utils/validate-remote-drive-checkout.d.ts +0 -7
- package/dist/src/utils/validate-remote-drive-checkout.d.ts.map +0 -1
- package/dist/src/utils/validate-remote-drive-checkout.js +0 -45
- package/dist/src/utils/validate-remote-drive-checkout.js.map +0 -1
- package/dist/src/utils/validate-remote-drive.d.ts +0 -7
- package/dist/src/utils/validate-remote-drive.d.ts.map +0 -1
- package/dist/src/utils/validate-remote-drive.js +0 -51
- package/dist/src/utils/validate-remote-drive.js.map +0 -1
- package/dist/src/version.d.ts +0 -2
- package/dist/src/version.d.ts.map +0 -1
- package/dist/src/version.js +0 -3
- package/dist/src/version.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -7
- package/dist/vitest.config.js.map +0 -1
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { forwardPHCommand, getPackageManagerFromLockfile, getProjectInfo, } from "./package-manager.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
|
-
const extraHelpLines = `
|
|
152
|
-
init [name] [options] Initialize a new project
|
|
153
|
-
use [release] [options] Specify your version of Powerhouse dependencies
|
|
154
|
-
update Update your powerhouse dependencies
|
|
155
|
-
`;
|
|
156
|
-
function injectExtraHelpLines(helpText, extraLines) {
|
|
157
|
-
const result = `${extraLines}${helpText}`
|
|
158
|
-
.replaceAll("\n\n", "")
|
|
159
|
-
.replace("\n", "");
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Generates and displays the merged help output
|
|
164
|
-
* @param {Command} program - Commander program instance
|
|
165
|
-
*/
|
|
166
|
-
export async function generateMergedHelp(program) {
|
|
167
|
-
// Get project information
|
|
168
|
-
const projectInfo = await getProjectInfo(undefined, false);
|
|
169
|
-
if (projectInfo.available) {
|
|
170
|
-
const packageManager = getPackageManagerFromLockfile(projectInfo.path);
|
|
171
|
-
// Get forwarded help from PH CLI
|
|
172
|
-
const forwardedHelp = forwardPHCommand(packageManager, projectInfo.path, "help", undefined, true);
|
|
173
|
-
// Apply padding to command descriptions for better alignment
|
|
174
|
-
applyCommandPadding(program);
|
|
175
|
-
// Capture the output without displaying it
|
|
176
|
-
const helpText = captureCommanderHelp(program);
|
|
177
|
-
// Restore original descriptions
|
|
178
|
-
restoreCommandDescriptions(program);
|
|
179
|
-
// Merge and display help
|
|
180
|
-
const mergedHelp = mergeHelp(helpText, forwardedHelp);
|
|
181
|
-
const withExtraLines = injectExtraHelpLines(mergedHelp, extraHelpLines);
|
|
182
|
-
console.log(withExtraLines);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
console.log(captureCommanderHelp(program));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=help-formatting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help-formatting.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CAAC;QACN,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
package/dist/src/utils/help.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* Helper to handle help flag detection for commands
|
|
4
|
-
* This centralizes the pattern of checking for help flags and showing command-specific help
|
|
5
|
-
*
|
|
6
|
-
* @param command - The Command instance
|
|
7
|
-
* @param actionFn - The original action function to call if help is not requested
|
|
8
|
-
* @returns A wrapped action function
|
|
9
|
-
*/
|
|
10
|
-
export declare function withHelpHandler<T extends unknown[]>(command: Command, actionFn: (...args: T) => Promise<void> | void): (...args: T) => Promise<void> | void;
|
|
11
|
-
/**
|
|
12
|
-
* Simplified utility to connect a command with an action function that includes help handling
|
|
13
|
-
* This reduces boilerplate in command files by automatically setting up the action with help handling
|
|
14
|
-
*
|
|
15
|
-
* @param command - The Command instance
|
|
16
|
-
* @param actionFn - The action function to call when the command is executed
|
|
17
|
-
* @param preCheck - Optional validation function that runs before the action
|
|
18
|
-
* @returns The command for chaining
|
|
19
|
-
*/
|
|
20
|
-
export declare function withHelpAction<T extends unknown[]>(command: Command, actionFn: (...args: T) => Promise<void> | void, preCheck?: (...args: T) => boolean | undefined): Command;
|
|
21
|
-
/**
|
|
22
|
-
* Enhanced version of withHelpAction that allows custom help text without duplication
|
|
23
|
-
*
|
|
24
|
-
* @param command - The Command instance
|
|
25
|
-
* @param actionFn - The action function to call when the command is executed
|
|
26
|
-
* @param helpText - The custom help text to display (replacing the auto-generated help)
|
|
27
|
-
* @param preCheck - Optional validation function that runs before the action
|
|
28
|
-
* @returns The command for chaining
|
|
29
|
-
*/
|
|
30
|
-
export declare function withCustomHelp<T extends unknown[]>(command: Command, actionFn: (...args: T) => Promise<void> | void, helpText: string, preCheck?: (...args: T) => boolean | undefined): Command;
|
|
31
|
-
//# sourceMappingURL=help.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/utils/help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAAE,EACjD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAC7C,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAgBtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,EAChD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC9C,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,SAAS,GAC7C,OAAO,CAeT;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,OAAO,EAAE,EAChD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC9C,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,SAAS,GAC7C,OAAO,CAkBT"}
|
package/dist/src/utils/help.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper to handle help flag detection for commands
|
|
3
|
-
* This centralizes the pattern of checking for help flags and showing command-specific help
|
|
4
|
-
*
|
|
5
|
-
* @param command - The Command instance
|
|
6
|
-
* @param actionFn - The original action function to call if help is not requested
|
|
7
|
-
* @returns A wrapped action function
|
|
8
|
-
*/
|
|
9
|
-
export function withHelpHandler(command, actionFn) {
|
|
10
|
-
return (...args) => {
|
|
11
|
-
// Check if help was requested
|
|
12
|
-
const rawArgs = process.argv;
|
|
13
|
-
const isHelpRequested = rawArgs.includes("--help") || rawArgs.includes("-h");
|
|
14
|
-
// If help was explicitly requested, show the help and exit
|
|
15
|
-
if (isHelpRequested) {
|
|
16
|
-
command.outputHelp();
|
|
17
|
-
process.exit(0);
|
|
18
|
-
}
|
|
19
|
-
// Otherwise, run the original action
|
|
20
|
-
return actionFn(...args);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Simplified utility to connect a command with an action function that includes help handling
|
|
25
|
-
* This reduces boilerplate in command files by automatically setting up the action with help handling
|
|
26
|
-
*
|
|
27
|
-
* @param command - The Command instance
|
|
28
|
-
* @param actionFn - The action function to call when the command is executed
|
|
29
|
-
* @param preCheck - Optional validation function that runs before the action
|
|
30
|
-
* @returns The command for chaining
|
|
31
|
-
*/
|
|
32
|
-
export function withHelpAction(command, actionFn, preCheck) {
|
|
33
|
-
command.action(withHelpHandler(command, (...args) => {
|
|
34
|
-
// If there's a pre-check function, run it before the action
|
|
35
|
-
if (preCheck) {
|
|
36
|
-
const result = preCheck(...args);
|
|
37
|
-
// If the pre-check returns false explicitly, don't run the action
|
|
38
|
-
if (result === false)
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
return actionFn(...args);
|
|
42
|
-
}));
|
|
43
|
-
return command;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Enhanced version of withHelpAction that allows custom help text without duplication
|
|
47
|
-
*
|
|
48
|
-
* @param command - The Command instance
|
|
49
|
-
* @param actionFn - The action function to call when the command is executed
|
|
50
|
-
* @param helpText - The custom help text to display (replacing the auto-generated help)
|
|
51
|
-
* @param preCheck - Optional validation function that runs before the action
|
|
52
|
-
* @returns The command for chaining
|
|
53
|
-
*/
|
|
54
|
-
export function withCustomHelp(command, actionFn, helpText, preCheck) {
|
|
55
|
-
// Clear any existing help text
|
|
56
|
-
command.helpInformation = function () {
|
|
57
|
-
const name = command.name();
|
|
58
|
-
const args = command.usage();
|
|
59
|
-
const description = command.description();
|
|
60
|
-
// Create a minimal header
|
|
61
|
-
let header = `\nUsage: ph ${name}`;
|
|
62
|
-
if (args)
|
|
63
|
-
header += ` ${args}`;
|
|
64
|
-
if (description)
|
|
65
|
-
header += `\n\n${description}\n`;
|
|
66
|
-
// Return the custom help text
|
|
67
|
-
return header + "\n" + helpText;
|
|
68
|
-
};
|
|
69
|
-
// Add help action handler
|
|
70
|
-
return withHelpAction(command, actionFn, preCheck);
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=help.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/utils/help.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,QAA8C;IAE9C,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;QACpB,8BAA8B;QAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;QAC7B,MAAM,eAAe,GACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEvD,2DAA2D;QAC3D,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,qCAAqC;QACrC,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,QAA8C,EAC9C,QAA8C;IAE9C,OAAO,CAAC,MAAM,CACZ,eAAe,CAAI,OAAO,EAAE,CAAC,GAAG,IAAO,EAAE,EAAE;QACzC,4DAA4D;QAC5D,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YACjC,kEAAkE;YAClE,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO;QAC/B,CAAC;QAED,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,QAA8C,EAC9C,QAAgB,EAChB,QAA8C;IAE9C,+BAA+B;IAC/B,OAAO,CAAC,eAAe,GAAG;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAE1C,0BAA0B;QAC1B,IAAI,MAAM,GAAG,eAAe,IAAI,EAAE,CAAC;QACnC,IAAI,IAAI;YAAE,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,WAAW;YAAE,MAAM,IAAI,OAAO,WAAW,IAAI,CAAC;QAElD,8BAA8B;QAC9B,OAAO,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;IAClC,CAAC,CAAC;IAEF,0BAA0B;IAC1B,OAAO,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./constants.js";
|
|
2
|
-
export * from "./dependencies.js";
|
|
3
|
-
export * from "./help-formatting.js";
|
|
4
|
-
export * from "./help.js";
|
|
5
|
-
export * from "./package-manager.js";
|
|
6
|
-
export type * from "./types.js";
|
|
7
|
-
export * from "./validate-remote-drive.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,YAAY,CAAC;AAChC,cAAc,4BAA4B,CAAC"}
|
package/dist/src/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AAErC,cAAc,4BAA4B,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { GlobalProjectOptions, PackageManager, PathValidation, ProjectInfo } from "./types.js";
|
|
2
|
-
export declare function defaultPathValidation(): boolean;
|
|
3
|
-
export declare function isPowerhouseProject(dir: string): boolean;
|
|
4
|
-
export declare function findNodeProjectRoot(dir: string, pathValidation?: PathValidation): string | null;
|
|
5
|
-
export declare function getPackageManagerFromPath(dir: string): PackageManager;
|
|
6
|
-
export declare function getPackageManagerFromLockfile(dir: string): PackageManager;
|
|
7
|
-
export declare function getProjectInfo(debug?: boolean, generateGlobalProject?: boolean): Promise<ProjectInfo>;
|
|
8
|
-
export declare function forwardPHCommand(packageManager: PackageManager, projectPath: string, args: string, debug?: boolean, captureOutput?: boolean): string;
|
|
9
|
-
/**
|
|
10
|
-
* Recursively searches for a specific file by traversing up the directory tree.
|
|
11
|
-
* Starting from the given path, it checks each parent directory until it finds
|
|
12
|
-
* the target file or reaches the root directory.
|
|
13
|
-
*
|
|
14
|
-
* @param startPath - The absolute path of the directory to start searching from
|
|
15
|
-
* @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')
|
|
16
|
-
* @returns The absolute path of the directory containing the target file, or null if not found
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Find the workspace root directory
|
|
20
|
-
* const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');
|
|
21
|
-
*
|
|
22
|
-
* // Find the nearest package.json
|
|
23
|
-
* const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');
|
|
24
|
-
*/
|
|
25
|
-
export declare const findContainerDirectory: (startPath: string, targetFile: string) => string | null;
|
|
26
|
-
export declare const createGlobalProject: (projectName?: string, options?: GlobalProjectOptions) => Promise<void>;
|
|
27
|
-
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../src/utils/package-manager.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,wBAAgB,qBAAqB,YAEpC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,WAI9C;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,cAAsC,iBAevD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAYrE;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAUzE;AAED,wBAAsB,cAAc,CAClC,KAAK,CAAC,EAAE,OAAO,EACf,qBAAqB,UAAO,GAC3B,OAAO,CAAC,WAAW,CAAC,CA6BtB;AAED,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,OAAO,EACf,aAAa,UAAQ,UAoCtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,YAAY,MAAM,KACjB,MAAM,GAAG,IAeX,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,cAAc,MAAM,EACpB,UAAS,oBAAyB,kBAoDnC,CAAC"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { createProject } from "@powerhousedao/codegen";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
-
import path, { dirname } from "node:path";
|
|
5
|
-
import { HOME_DIR, PH_BIN_PATH, PH_GLOBAL_DIR_NAME, PH_GLOBAL_PACKAGE_NAME, POWERHOUSE_CONFIG_FILE, POWERHOUSE_GLOBAL_DIR, packageManagers, } from "./constants.js";
|
|
6
|
-
import { parsePackageManager, parseTag } from "./parsing.js";
|
|
7
|
-
export function defaultPathValidation() {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
export function isPowerhouseProject(dir) {
|
|
11
|
-
const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);
|
|
12
|
-
return existsSync(powerhouseConfigPath);
|
|
13
|
-
}
|
|
14
|
-
export function findNodeProjectRoot(dir, pathValidation = defaultPathValidation) {
|
|
15
|
-
const packageJsonPath = path.join(dir, "package.json");
|
|
16
|
-
if (existsSync(packageJsonPath) && pathValidation(dir)) {
|
|
17
|
-
return dir;
|
|
18
|
-
}
|
|
19
|
-
const parentDir = dirname(dir);
|
|
20
|
-
if (parentDir === dir) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return findNodeProjectRoot(parentDir, pathValidation);
|
|
24
|
-
}
|
|
25
|
-
export function getPackageManagerFromPath(dir) {
|
|
26
|
-
const lowerCasePath = dir.toLowerCase();
|
|
27
|
-
if (packageManagers.bun.globalPathRegexp.test(lowerCasePath)) {
|
|
28
|
-
return "bun";
|
|
29
|
-
}
|
|
30
|
-
else if (packageManagers.pnpm.globalPathRegexp.test(lowerCasePath)) {
|
|
31
|
-
return "pnpm";
|
|
32
|
-
}
|
|
33
|
-
else if (packageManagers.yarn.globalPathRegexp.test(lowerCasePath)) {
|
|
34
|
-
return "yarn";
|
|
35
|
-
}
|
|
36
|
-
return "npm";
|
|
37
|
-
}
|
|
38
|
-
export function getPackageManagerFromLockfile(dir) {
|
|
39
|
-
if (existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {
|
|
40
|
-
return "pnpm";
|
|
41
|
-
}
|
|
42
|
-
else if (existsSync(path.join(dir, packageManagers.yarn.lockfile))) {
|
|
43
|
-
return "yarn";
|
|
44
|
-
}
|
|
45
|
-
else if (existsSync(path.join(dir, packageManagers.bun.lockfile))) {
|
|
46
|
-
return "bun";
|
|
47
|
-
}
|
|
48
|
-
return "npm";
|
|
49
|
-
}
|
|
50
|
-
export async function getProjectInfo(debug, generateGlobalProject = true) {
|
|
51
|
-
const currentPath = process.cwd();
|
|
52
|
-
if (debug) {
|
|
53
|
-
console.log(">>> currentPath:", currentPath);
|
|
54
|
-
}
|
|
55
|
-
const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);
|
|
56
|
-
if (!projectPath) {
|
|
57
|
-
let available = existsSync(POWERHOUSE_GLOBAL_DIR);
|
|
58
|
-
if (generateGlobalProject) {
|
|
59
|
-
await createGlobalProject();
|
|
60
|
-
available = true;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
available,
|
|
64
|
-
isGlobal: true,
|
|
65
|
-
path: POWERHOUSE_GLOBAL_DIR,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
isGlobal: false,
|
|
70
|
-
available: true,
|
|
71
|
-
path: projectPath,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export function forwardPHCommand(packageManager, projectPath, args, debug, captureOutput = false) {
|
|
75
|
-
const manager = packageManagers[packageManager];
|
|
76
|
-
const command = manager.execCommand;
|
|
77
|
-
const execCommand = command.replace("{{arguments}}", args);
|
|
78
|
-
const commandOptions = { cwd: projectPath };
|
|
79
|
-
if (debug) {
|
|
80
|
-
console.log(">>> execCommand:", execCommand);
|
|
81
|
-
console.log(">>> commandOptions:", commandOptions);
|
|
82
|
-
console.log(">>> projectPath:", projectPath);
|
|
83
|
-
console.log(">>> packageManager:", packageManager);
|
|
84
|
-
}
|
|
85
|
-
if (captureOutput) {
|
|
86
|
-
// Capture output and return it
|
|
87
|
-
try {
|
|
88
|
-
return execSync(execCommand, {
|
|
89
|
-
stdio: "pipe",
|
|
90
|
-
encoding: "utf8",
|
|
91
|
-
...commandOptions,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
throw new Error(`Failed to execute command: ${execCommand}\nError: ${error instanceof Error ? error.message : String(error)}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Original behavior - pipe directly to stdout/stderr
|
|
100
|
-
execSync(execCommand, {
|
|
101
|
-
stdio: "inherit",
|
|
102
|
-
...commandOptions,
|
|
103
|
-
});
|
|
104
|
-
return "";
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Recursively searches for a specific file by traversing up the directory tree.
|
|
109
|
-
* Starting from the given path, it checks each parent directory until it finds
|
|
110
|
-
* the target file or reaches the root directory.
|
|
111
|
-
*
|
|
112
|
-
* @param startPath - The absolute path of the directory to start searching from
|
|
113
|
-
* @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')
|
|
114
|
-
* @returns The absolute path of the directory containing the target file, or null if not found
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* // Find the workspace root directory
|
|
118
|
-
* const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');
|
|
119
|
-
*
|
|
120
|
-
* // Find the nearest package.json
|
|
121
|
-
* const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');
|
|
122
|
-
*/
|
|
123
|
-
export const findContainerDirectory = (startPath, targetFile) => {
|
|
124
|
-
const filePath = path.join(startPath, targetFile);
|
|
125
|
-
if (existsSync(filePath)) {
|
|
126
|
-
return startPath;
|
|
127
|
-
}
|
|
128
|
-
const parentDir = path.dirname(startPath);
|
|
129
|
-
//reached the root directory and haven't found the file
|
|
130
|
-
if (parentDir === startPath) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
return findContainerDirectory(parentDir, targetFile);
|
|
134
|
-
};
|
|
135
|
-
export const createGlobalProject = async (projectName, options = {}) => {
|
|
136
|
-
// check if the global project already exists
|
|
137
|
-
const globalProjectExists = existsSync(POWERHOUSE_GLOBAL_DIR);
|
|
138
|
-
if (globalProjectExists) {
|
|
139
|
-
// Fix existing installations with invalid ".ph" package name
|
|
140
|
-
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
141
|
-
if (existsSync(packageJsonPath)) {
|
|
142
|
-
try {
|
|
143
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
144
|
-
if (packageJson.name?.startsWith(".")) {
|
|
145
|
-
console.log("📦 Fixing invalid package name in global project...");
|
|
146
|
-
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
147
|
-
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
// Ignore errors reading/writing package.json
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
console.log(`📦 Using global project: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
console.log("📦 Initializing global project...");
|
|
158
|
-
process.chdir(HOME_DIR);
|
|
159
|
-
try {
|
|
160
|
-
await createProject({
|
|
161
|
-
name: PH_GLOBAL_DIR_NAME,
|
|
162
|
-
tag: parseTag(options),
|
|
163
|
-
packageManager: parsePackageManager(options) ?? getPackageManagerFromPath(PH_BIN_PATH),
|
|
164
|
-
});
|
|
165
|
-
// Fix the package.json name - ".ph" is invalid for npm/vite
|
|
166
|
-
// The directory name can be ".ph" but the package name must be valid
|
|
167
|
-
const packageJsonPath = path.join(POWERHOUSE_GLOBAL_DIR, "package.json");
|
|
168
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
169
|
-
packageJson.name = PH_GLOBAL_PACKAGE_NAME;
|
|
170
|
-
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
171
|
-
console.log(`🚀 Global project initialized successfully: ${POWERHOUSE_GLOBAL_DIR}`);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
console.error("❌ Failed to initialize the global project", error);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
//# sourceMappingURL=package-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../../src/utils/package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQ7D,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW;I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AC;IAED,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExB,IAAI,CAAC;QACH,MAAM,aAAa,CAAC;YAClB,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC;YACtB,cAAc,EACZ,mBAAmB,CAAC,OAAO,CAAC,IAAI,yBAAyB,CAAC,WAAW,CAAC;SACzE,CAAC,CAAC;QAEH,4DAA4D;QAC5D,qEAAqE;QACrE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAEpE,CAAC;QACF,WAAW,CAAC,IAAI,GAAG,sBAAsB,CAAC;QAC1C,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAErE,OAAO,CAAC,GAAG,CACT,+CAA+C,qBAAqB,EAAE,CACvE,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare function parseTag(args: {
|
|
2
|
-
tag?: string;
|
|
3
|
-
dev?: boolean;
|
|
4
|
-
staging?: boolean;
|
|
5
|
-
}): string;
|
|
6
|
-
export declare function parsePackageManager(args: {
|
|
7
|
-
packageManager?: string;
|
|
8
|
-
npm?: boolean;
|
|
9
|
-
pnpm?: boolean;
|
|
10
|
-
yarn?: boolean;
|
|
11
|
-
bun?: boolean;
|
|
12
|
-
}): string | undefined;
|
|
13
|
-
export declare function handleMutuallyExclusiveOptions(options: Record<string, string | boolean | number | undefined>, optionsName: string): void;
|
|
14
|
-
export declare function getTagFromVersion(version: string): "dev" | "latest" | "staging";
|
|
15
|
-
export declare function logVersionUpdate(args: {
|
|
16
|
-
name: string;
|
|
17
|
-
version: string;
|
|
18
|
-
newVersion: string;
|
|
19
|
-
}): void;
|
|
20
|
-
//# sourceMappingURL=parsing.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,UAMA;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,sBAYA;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,EAC9D,WAAW,EAAE,MAAM,QAcpB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,gCAIhD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,QAKA"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
export function parseTag(args) {
|
|
3
|
-
const { tag, dev, staging } = args;
|
|
4
|
-
if (tag)
|
|
5
|
-
return tag;
|
|
6
|
-
if (dev)
|
|
7
|
-
return "dev";
|
|
8
|
-
if (staging)
|
|
9
|
-
return "staging";
|
|
10
|
-
return "latest";
|
|
11
|
-
}
|
|
12
|
-
export function parsePackageManager(args) {
|
|
13
|
-
const { npm, pnpm, yarn, bun, packageManager } = args;
|
|
14
|
-
if (npm)
|
|
15
|
-
return "npm";
|
|
16
|
-
if (pnpm)
|
|
17
|
-
return "pnpm";
|
|
18
|
-
if (yarn)
|
|
19
|
-
return "yarn";
|
|
20
|
-
if (bun)
|
|
21
|
-
return "bun";
|
|
22
|
-
if (packageManager)
|
|
23
|
-
return packageManager;
|
|
24
|
-
const userAgentPackageManager = process.env.npm_config_user_agent?.match(/^(pnpm|npm|yarn|bun)\b/)?.[1];
|
|
25
|
-
if (userAgentPackageManager)
|
|
26
|
-
return userAgentPackageManager;
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
export function handleMutuallyExclusiveOptions(options, optionsName) {
|
|
30
|
-
const mutuallyExclusiveOptions = Object.entries(options)
|
|
31
|
-
.map(([k, v]) => {
|
|
32
|
-
if (v !== undefined)
|
|
33
|
-
return k;
|
|
34
|
-
return undefined;
|
|
35
|
-
})
|
|
36
|
-
.filter((v) => v !== undefined);
|
|
37
|
-
if (mutuallyExclusiveOptions.length > 1) {
|
|
38
|
-
throw new Error(`Cannot specify multiple ${optionsName} options. You provided: ${mutuallyExclusiveOptions.join(", ")}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function getTagFromVersion(version) {
|
|
42
|
-
if (version.includes("dev"))
|
|
43
|
-
return "dev";
|
|
44
|
-
if (version.includes("staging"))
|
|
45
|
-
return "staging";
|
|
46
|
-
return "latest";
|
|
47
|
-
}
|
|
48
|
-
export function logVersionUpdate(args) {
|
|
49
|
-
const { name, version, newVersion } = args;
|
|
50
|
-
console.log(`⚙️ Updating ${chalk.bold(name)}: ${chalk.blue(version)} -> ${chalk.green(newVersion)}`);
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=parsing.js.map
|
|
@@ -1 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