ph-cmd 4.1.0-dev.94 → 4.1.0-dev.96
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/dist/src/commands/checkout.d.ts +9 -0
- package/dist/src/commands/checkout.d.ts.map +1 -0
- package/dist/src/commands/checkout.js +37 -0
- package/dist/src/commands/checkout.js.map +1 -0
- package/dist/src/commands/index.d.ts +2 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +3 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts +1 -0
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +36 -2
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/help.d.ts +4 -0
- package/dist/src/help.d.ts.map +1 -1
- package/dist/src/help.js +31 -0
- package/dist/src/help.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/validate-remote-drive-checkout.d.ts +7 -0
- package/dist/src/utils/validate-remote-drive-checkout.d.ts.map +1 -0
- package/dist/src/utils/validate-remote-drive-checkout.js +45 -0
- package/dist/src/utils/validate-remote-drive-checkout.js.map +1 -0
- package/dist/src/utils/validate-remote-drive.d.ts +6 -0
- package/dist/src/utils/validate-remote-drive.d.ts.map +1 -0
- package/dist/src/utils/validate-remote-drive.js +37 -0
- package/dist/src/utils/validate-remote-drive.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandActionType } from "../types.js";
|
|
3
|
+
export type CheckoutOptions = {
|
|
4
|
+
remoteDrive: string;
|
|
5
|
+
packageManager?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const checkout: CommandActionType<[CheckoutOptions]>;
|
|
8
|
+
export declare function checkoutCommand(program: Command): Command;
|
|
9
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../../src/commands/checkout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKrD,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,CAAC,eAAe,CAAC,CAgCzD,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAWzD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cloneRepository, installDependencies } from "@powerhousedao/codegen";
|
|
2
|
+
import { checkoutHelp } from "../help.js";
|
|
3
|
+
import { withCustomHelp } from "../utils/index.js";
|
|
4
|
+
import { getPackageManagerFromLockfile } from "../utils/package-manager.js";
|
|
5
|
+
import { getPackageDocument } from "../utils/validate-remote-drive-checkout.js";
|
|
6
|
+
export const checkout = async (options) => {
|
|
7
|
+
console.log("Checking out project from remote drive...");
|
|
8
|
+
try {
|
|
9
|
+
// Validate remote drive and get GitHub URL
|
|
10
|
+
const packageDocument = await getPackageDocument(options.remoteDrive);
|
|
11
|
+
if (!packageDocument.isValid) {
|
|
12
|
+
console.error(packageDocument.error);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// Clone repository
|
|
16
|
+
const projectPath = cloneRepository(packageDocument.githubUrl);
|
|
17
|
+
// Detect package manager from lock files or use user-provided one
|
|
18
|
+
const detectedPackageManager = getPackageManagerFromLockfile(projectPath);
|
|
19
|
+
const packageManager = options.packageManager ?? detectedPackageManager;
|
|
20
|
+
// Install dependencies
|
|
21
|
+
installDependencies(projectPath, packageManager);
|
|
22
|
+
console.log("\x1b[32m", "Checkout completed successfully!", "\x1b[0m");
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error("Failed to checkout the project", error instanceof Error ? error.message : String(error));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export function checkoutCommand(program) {
|
|
30
|
+
const checkoutCmd = program
|
|
31
|
+
.command("checkout")
|
|
32
|
+
.description("Checkout an existing project from a remote drive")
|
|
33
|
+
.requiredOption("-r, --remote-drive <remoteDrive>", "Remote drive identifier")
|
|
34
|
+
.option("--package-manager <packageManager>", "Package manager to use");
|
|
35
|
+
return withCustomHelp(checkoutCmd, checkout, checkoutHelp);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAOhF,MAAM,CAAC,MAAM,QAAQ,GAAyC,KAAK,EACjE,OAAO,EACP,EAAE;IACF,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IAEzD,IAAI,CAAC;QACH,2CAA2C;QAC3C,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEtE,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,mBAAmB;QACnB,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,SAAU,CAAC,CAAC;QAEhE,kEAAkE;QAClE,MAAM,sBAAsB,GAAG,6BAA6B,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,sBAAsB,CAAC;QAExE,uBAAuB;QACvB,mBAAmB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAEjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,kCAAkC,EAAE,SAAS,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,gCAAgC,EAChC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,WAAW,GAAG,OAAO;SACxB,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,kDAAkD,CAAC;SAC/D,cAAc,CACb,kCAAkC,EAClC,yBAAyB,CAC1B;SACA,MAAM,CAAC,oCAAoC,EAAE,wBAAwB,CAAC,CAAC;IAE1E,OAAO,cAAc,CAAoB,WAAW,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
+
import { checkoutCommand } from "./checkout.js";
|
|
2
3
|
import { helpCommand } from "./help.js";
|
|
3
4
|
import { initCommand } from "./init.js";
|
|
4
5
|
import { setupGlobalsCommand } from "./setup-globals.js";
|
|
5
6
|
import { updateCommand } from "./update.js";
|
|
6
7
|
import { useCommand } from "./use.js";
|
|
7
8
|
import { versionOption } from "./version.js";
|
|
8
|
-
export { helpCommand, initCommand, setupGlobalsCommand, updateCommand, useCommand, versionOption, };
|
|
9
|
+
export { checkoutCommand, helpCommand, initCommand, setupGlobalsCommand, updateCommand, useCommand, versionOption, };
|
|
9
10
|
export declare const commands: (typeof helpCommand)[];
|
|
10
11
|
export default function registerCommands(program: Command): void;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,aAAa,GACd,CAAC;AACF,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,aAAa,GACd,CAAC;AACF,eAAO,MAAM,QAAQ,wBAQpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAExD"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { checkoutCommand } from "./checkout.js";
|
|
1
2
|
import { helpCommand } from "./help.js";
|
|
2
3
|
import { initCommand } from "./init.js";
|
|
3
4
|
import { setupGlobalsCommand } from "./setup-globals.js";
|
|
4
5
|
import { updateCommand } from "./update.js";
|
|
5
6
|
import { useCommand } from "./use.js";
|
|
6
7
|
import { versionOption } from "./version.js";
|
|
7
|
-
export { helpCommand, initCommand, setupGlobalsCommand, updateCommand, useCommand, versionOption, };
|
|
8
|
+
export { checkoutCommand, helpCommand, initCommand, setupGlobalsCommand, updateCommand, useCommand, versionOption, };
|
|
8
9
|
export const commands = [
|
|
9
10
|
setupGlobalsCommand,
|
|
10
11
|
initCommand,
|
|
12
|
+
checkoutCommand,
|
|
11
13
|
useCommand,
|
|
12
14
|
updateCommand,
|
|
13
15
|
helpCommand,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAA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@@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAUrD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,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;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAClC;IAAC,MAAM,GAAG,SAAS;IAAE,WAAW;CAAC,CAqBlC,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CA+DrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createProject, parseVersion } from "@powerhousedao/codegen";
|
|
2
2
|
import { initHelp } from "../help.js";
|
|
3
|
-
import { getPackageManagerFromPath, PH_BIN_PATH, resolvePackageManagerOptions, withCustomHelp, } from "../utils/index.js";
|
|
3
|
+
import { getPackageManagerFromPath, PH_BIN_PATH, resolvePackageManagerOptions, validateRemoteDrive, withCustomHelp, } from "../utils/index.js";
|
|
4
4
|
export const init = async (projectName, options) => {
|
|
5
5
|
console.log("Initializing a new project...");
|
|
6
6
|
try {
|
|
@@ -14,6 +14,7 @@ export const init = async (projectName, options) => {
|
|
|
14
14
|
}),
|
|
15
15
|
packageManager: resolvePackageManagerOptions(options) ??
|
|
16
16
|
getPackageManagerFromPath(PH_BIN_PATH),
|
|
17
|
+
vetraDriveUrl: options.remoteDrive,
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
@@ -35,7 +36,40 @@ export function initCommand(program) {
|
|
|
35
36
|
.option("--npm", "Use 'npm' as package manager")
|
|
36
37
|
.option("--pnpm", "Use 'pnpm' as package manager")
|
|
37
38
|
.option("--yarn", "Use 'yarn' as package manager")
|
|
38
|
-
.option("--bun", "Use 'bun' as package manager")
|
|
39
|
+
.option("--bun", "Use 'bun' as package manager")
|
|
40
|
+
.option("-r, --remote-drive <remoteDrive>", "Remote drive identifier");
|
|
41
|
+
initCmd.hook("preAction", async (thisCommand) => {
|
|
42
|
+
const options = thisCommand.opts();
|
|
43
|
+
if (options.remoteDrive) {
|
|
44
|
+
const isValid = await validateRemoteDrive(options.remoteDrive);
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
process.exit(1); // Exit if validation fails
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
initCmd.hook("postAction", (thisCommand) => {
|
|
51
|
+
const options = thisCommand.opts();
|
|
52
|
+
if (options.remoteDrive) {
|
|
53
|
+
const args = thisCommand.args;
|
|
54
|
+
const projectName = options.project ?? args[0];
|
|
55
|
+
let branchName = "main";
|
|
56
|
+
if (options.dev) {
|
|
57
|
+
branchName = "dev";
|
|
58
|
+
}
|
|
59
|
+
else if (options.staging) {
|
|
60
|
+
branchName = "staging";
|
|
61
|
+
}
|
|
62
|
+
console.log();
|
|
63
|
+
console.log("To link your project to GitHub:");
|
|
64
|
+
console.log();
|
|
65
|
+
console.log(" 1. Create a new repository on GitHub");
|
|
66
|
+
console.log(` 2. cd ${projectName}`);
|
|
67
|
+
console.log(" 3. git add . && git commit -m 'Initial commit'");
|
|
68
|
+
console.log(" 4. git remote add origin <your-github-url>");
|
|
69
|
+
console.log(` 5. git push -u origin ${branchName}`);
|
|
70
|
+
console.log();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
39
73
|
// Use withCustomHelp instead of withHelpAction and addHelpText
|
|
40
74
|
return withCustomHelp(initCmd, init, initHelp);
|
|
41
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,4BAA4B,EAC5B,cAAc,GACf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,4BAA4B,EAC5B,mBAAmB,EACnB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAkB3B,MAAM,CAAC,MAAM,IAAI,GAEb,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;IACjC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,aAAa,CAAC;YAClB,IAAI,EAAE,OAAO,CAAC,OAAO,IAAI,WAAW;YACpC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK;YACzC,OAAO,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,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,OAAO,cAAc,CACnB,OAAO,EACP,IAAI,EACJ,QAAQ,CACT,CAAC;AACJ,CAAC"}
|
package/dist/src/help.d.ts
CHANGED
|
@@ -18,4 +18,8 @@ export declare const setupGlobalsHelp = "\nCommand Overview:\n The setup-global
|
|
|
18
18
|
* Help text for the init command
|
|
19
19
|
*/
|
|
20
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 $ ph init my-awesome-project --dev --package-manager pnpm # Create a project with Powerhouse dev packages and pnpm as package manager\n";
|
|
21
|
+
/**
|
|
22
|
+
* Help text for the checkout command
|
|
23
|
+
*/
|
|
24
|
+
export declare const checkoutHelp = "\nCommand Overview:\n The checkout command clones an existing Powerhouse project from a remote Vetra drive.\n This allows you to work on projects that have been initialized and configured by others.\n\n This command:\n 1. Fetches the GitHub repository URL from the specified Vetra remote drive\n 2. Clones the repository to your local machine\n 3. Installs all project dependencies\n\nRequired Options:\n -r, --remote-drive <url> URL of the Vetra remote drive containing the project.\n The drive must have a Vetra package with a configured GitHub URL.\n\nOptions:\n --package-manager <pm> Specify which package manager to use for installing dependencies.\n Supported: npm, yarn, pnpm, bun\n If not specified, uses the detected package manager from your environment.\n\nExamples:\n $ ph checkout --remote-drive https://vetra.example.com/d/abc123 # Clone project using default package manager\n $ ph checkout --remote-drive https://vetra.example.com/d/abc123 --package-manager pnpm # Clone and install with pnpm\n\nNotes:\n - The remote drive must contain a Vetra package document with a GitHub URL configured\n - If no GitHub URL is found, you'll need to use 'ph init --remote-drive' instead to create a new project\n - The repository will be cloned into a directory named after the repository\n";
|
|
21
25
|
//# sourceMappingURL=help.d.ts.map
|
package/dist/src/help.d.ts.map
CHANGED
|
@@ -1 +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,wtFAgDnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,kgEA0C5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,y3EA6CpB,CAAC"}
|
|
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,wtFAgDnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,kgEA0C5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,y3EA6CpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,64CA2BxB,CAAC"}
|
package/dist/src/help.js
CHANGED
|
@@ -188,5 +188,36 @@ Examples:
|
|
|
188
188
|
$ ph init --package-manager yarn # Use yarn as package manager
|
|
189
189
|
$ ph init my-awesome-project --dev --package-manager pnpm # Create a project with Powerhouse dev packages and pnpm as package manager
|
|
190
190
|
`;
|
|
191
|
+
/**
|
|
192
|
+
* Help text for the checkout command
|
|
193
|
+
*/
|
|
194
|
+
export const checkoutHelp = `
|
|
195
|
+
Command Overview:
|
|
196
|
+
The checkout command clones an existing Powerhouse project from a remote Vetra drive.
|
|
197
|
+
This allows you to work on projects that have been initialized and configured by others.
|
|
198
|
+
|
|
199
|
+
This command:
|
|
200
|
+
1. Fetches the GitHub repository URL from the specified Vetra remote drive
|
|
201
|
+
2. Clones the repository to your local machine
|
|
202
|
+
3. Installs all project dependencies
|
|
203
|
+
|
|
204
|
+
Required Options:
|
|
205
|
+
-r, --remote-drive <url> URL of the Vetra remote drive containing the project.
|
|
206
|
+
The drive must have a Vetra package with a configured GitHub URL.
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
--package-manager <pm> Specify which package manager to use for installing dependencies.
|
|
210
|
+
Supported: npm, yarn, pnpm, bun
|
|
211
|
+
If not specified, uses the detected package manager from your environment.
|
|
212
|
+
|
|
213
|
+
Examples:
|
|
214
|
+
$ ph checkout --remote-drive https://vetra.example.com/d/abc123 # Clone project using default package manager
|
|
215
|
+
$ ph checkout --remote-drive https://vetra.example.com/d/abc123 --package-manager pnpm # Clone and install with pnpm
|
|
216
|
+
|
|
217
|
+
Notes:
|
|
218
|
+
- The remote drive must contain a Vetra package document with a GitHub URL configured
|
|
219
|
+
- If no GitHub URL is found, you'll need to use 'ph init --remote-drive' instead to create a new project
|
|
220
|
+
- The repository will be cloned into a directory named after the repository
|
|
221
|
+
`;
|
|
191
222
|
// Add other command help texts here as needed
|
|
192
223
|
//# sourceMappingURL=help.js.map
|
package/dist/src/help.js.map
CHANGED
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0C/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CvB,CAAC;AAEF,8CAA8C"}
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDtB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0C/B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CvB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B3B,CAAC;AAEF,8CAA8C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,mBAAmB,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AAErC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface PackageDocumentResult {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
githubUrl?: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function getPackageDocument(remoteDriveUrl: string): Promise<PackageDocumentResult>;
|
|
7
|
+
//# sourceMappingURL=validate-remote-drive-checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-remote-drive-checkout.d.ts","sourceRoot":"","sources":["../../../src/utils/validate-remote-drive-checkout.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,CAAC,CAoDhC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getVetraDocuments } from "@powerhousedao/common/utils";
|
|
2
|
+
export async function getPackageDocument(remoteDriveUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const driveId = remoteDriveUrl.split("/").pop();
|
|
5
|
+
const url = new URL(remoteDriveUrl);
|
|
6
|
+
const graphqlEndpoint = `${url.protocol}//${url.host}/graphql`;
|
|
7
|
+
if (!driveId) {
|
|
8
|
+
return {
|
|
9
|
+
isValid: false,
|
|
10
|
+
error: "❌ Invalid remote drive URL: unable to extract drive ID",
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const documents = await getVetraDocuments(graphqlEndpoint, driveId);
|
|
14
|
+
// Check if no documents found
|
|
15
|
+
if (documents.length === 0) {
|
|
16
|
+
return {
|
|
17
|
+
isValid: false,
|
|
18
|
+
error: "❌ No Vetra package documents found in the remote drive. Use 'ph init --remote-drive' to create a new project first.",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// Find documents with githubUrl
|
|
22
|
+
const documentsWithUrl = documents.filter((doc) => doc.githubUrl);
|
|
23
|
+
if (documentsWithUrl.length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
isValid: false,
|
|
26
|
+
error: "❌ No GitHub URL configured in the Vetra package. Use 'ph init --remote-drive' to create a new project first.",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Warn if multiple documents found
|
|
30
|
+
if (documents.length > 1) {
|
|
31
|
+
console.warn(`⚠️ Warning: Multiple Vetra package documents found (${documents.length}). Using first document with GitHub URL.`);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
isValid: true,
|
|
35
|
+
githubUrl: documentsWithUrl[0].githubUrl,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
isValid: false,
|
|
41
|
+
error: `❌ Unable to fetch remote drive info: ${error instanceof Error ? error.message : String(error)}`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=validate-remote-drive-checkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-remote-drive-checkout.js","sourceRoot":"","sources":["../../../src/utils/validate-remote-drive-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAQhE,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,cAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACpC,MAAM,eAAe,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,UAAU,CAAC;QAE/D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,wDAAwD;aAChE,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAEpE,8BAA8B;QAC9B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EACH,qHAAqH;aACxH,CAAC;QACJ,CAAC;QAED,gCAAgC;QAChC,MAAM,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAElE,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EACH,8GAA8G;aACjH,CAAC;QACJ,CAAC;QAED,mCAAmC;QACnC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CACV,wDAAwD,SAAS,CAAC,MAAM,0CAA0C,CACnH,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS;SACzC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,wCAAwC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;SACxG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a remote drive for initialization.
|
|
3
|
+
* Returns true if validation passes, false if it should stop execution.
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateRemoteDrive(remoteDriveUrl: string): Promise<boolean>;
|
|
6
|
+
//# sourceMappingURL=validate-remote-drive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-remote-drive.d.ts","sourceRoot":"","sources":["../../../src/utils/validate-remote-drive.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC,CA2ClB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getVetraDocuments } from "@powerhousedao/common/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Validates a remote drive for initialization.
|
|
4
|
+
* Returns true if validation passes, false if it should stop execution.
|
|
5
|
+
*/
|
|
6
|
+
export async function validateRemoteDrive(remoteDriveUrl) {
|
|
7
|
+
try {
|
|
8
|
+
// Parse driveId from URL
|
|
9
|
+
const driveId = remoteDriveUrl.split("/").pop();
|
|
10
|
+
if (!remoteDriveUrl || remoteDriveUrl.trim() === "") {
|
|
11
|
+
console.error("❌ Remote drive URL is required");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
// Construct GraphQL endpoint from base URL
|
|
15
|
+
const url = new URL(remoteDriveUrl);
|
|
16
|
+
const graphqlEndpoint = `${url.protocol}//${url.host}/graphql`;
|
|
17
|
+
const documents = await getVetraDocuments(graphqlEndpoint, driveId);
|
|
18
|
+
if (documents.length === 0) {
|
|
19
|
+
console.error("❌ No vetra package document were found in the provided drive");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (documents.length > 1) {
|
|
23
|
+
console.warn("⚠️ Multiple vetra package documents were found in the provided remote drive, this might be an error in your remote drive");
|
|
24
|
+
}
|
|
25
|
+
const hasGithubUrl = documents.some((doc) => doc.githubUrl);
|
|
26
|
+
if (hasGithubUrl) {
|
|
27
|
+
console.error("❌ The remote drive provided already has been configured with a github url, please use the checkout command instead: ph checkout --remote-drive <remote drive url>");
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error("❌ Unable to fetch remote drive info:", error);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=validate-remote-drive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-remote-drive.js","sourceRoot":"","sources":["../../../src/utils/validate-remote-drive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,cAAsB;IAEtB,IAAI,CAAC;QACH,yBAAyB;QACzB,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAEhD,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACpD,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,2CAA2C;QAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QACpC,MAAM,eAAe,GAAG,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,UAAU,CAAC;QAE/D,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,eAAe,EAAE,OAAQ,CAAC,CAAC;QAErE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CACX,8DAA8D,CAC/D,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CACV,2HAA2H,CAC5H,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE5D,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CACX,mKAAmK,CACpK,CAA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