create-whop-kit 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/exec.ts
4
+ import { execSync } from "child_process";
5
+ function exec(cmd, cwd) {
6
+ try {
7
+ const stdout = execSync(cmd, {
8
+ cwd,
9
+ stdio: "pipe",
10
+ encoding: "utf-8",
11
+ timeout: 12e4
12
+ }).trim();
13
+ return { stdout, success: true };
14
+ } catch {
15
+ return { stdout: "", success: false };
16
+ }
17
+ }
18
+ function hasCommand(cmd) {
19
+ return exec(`which ${cmd}`).success;
20
+ }
21
+ function detectPackageManager() {
22
+ if (hasCommand("pnpm")) return "pnpm";
23
+ if (hasCommand("yarn")) return "yarn";
24
+ if (hasCommand("bun")) return "bun";
25
+ return "npm";
26
+ }
27
+
28
+ // src/scaffolding/manifest.ts
29
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
30
+ import { join } from "path";
31
+ var MANIFEST_DIR = ".whop";
32
+ var MANIFEST_FILE = "config.json";
33
+ function getManifestPath(projectDir) {
34
+ return join(projectDir, MANIFEST_DIR, MANIFEST_FILE);
35
+ }
36
+ function createManifest(projectDir, data) {
37
+ const dir = join(projectDir, MANIFEST_DIR);
38
+ if (!existsSync(dir)) {
39
+ mkdirSync(dir, { recursive: true });
40
+ }
41
+ const manifest = {
42
+ version: 1,
43
+ ...data,
44
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
45
+ };
46
+ writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
47
+ }
48
+ function readManifest(projectDir) {
49
+ const path = getManifestPath(projectDir);
50
+ if (!existsSync(path)) return null;
51
+ try {
52
+ return JSON.parse(readFileSync(path, "utf-8"));
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ function addFeatureToManifest(projectDir, feature) {
58
+ const manifest = readManifest(projectDir);
59
+ if (!manifest) return;
60
+ if (!manifest.features.includes(feature)) {
61
+ manifest.features.push(feature);
62
+ }
63
+ writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
64
+ }
65
+
66
+ export {
67
+ exec,
68
+ hasCommand,
69
+ detectPackageManager,
70
+ createManifest,
71
+ readManifest,
72
+ addFeatureToManifest
73
+ };