pokit 0.0.20 → 0.0.24

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 (2) hide show
  1. package/bin/pok.ts +91 -91
  2. package/package.json +4 -4
package/bin/pok.ts CHANGED
@@ -25,6 +25,97 @@ if (args[0] === 'init') {
25
25
  process.exit(0);
26
26
  }
27
27
 
28
+ main().catch((err) => {
29
+ console.error(err);
30
+ process.exit(1);
31
+ });
32
+
33
+ async function main() {
34
+ const processCwd = process.cwd();
35
+
36
+ // Step 1: Find config file using simple inline search
37
+ const configResult = findConfigFileSimple(processCwd);
38
+
39
+ if (!configResult) {
40
+ // Look for package.json
41
+ const pkgJsonResult = findPackageJsonSimple(processCwd);
42
+ if (pkgJsonResult) {
43
+ await runInFallbackMode(pkgJsonResult.pkgDir);
44
+ return;
45
+ }
46
+
47
+ console.error(`Error: No pok configuration or package.json found.
48
+
49
+ Run \`pok init\` to create a pok.config.ts file.
50
+ `);
51
+ process.exit(1);
52
+ }
53
+
54
+ const { configPath, configDir } = configResult;
55
+
56
+ // Step 2: Dynamically resolve @pokit/core from the project directory
57
+ let configModule = await resolveModule('@pokit/core', configDir);
58
+
59
+ if (!configModule) {
60
+ if (await ensureModulesInstalled(configDir, ['@pokit/core'])) {
61
+ configModule = await resolveModule('@pokit/core', configDir);
62
+ }
63
+ }
64
+
65
+ if (!configModule) {
66
+ const installCmd = getInstallCommand(configDir, ['@pokit/core']);
67
+ console.error(
68
+ `Error: @pokit/core is not installed in ${configDir}\n\n` +
69
+ 'Install it with:\n' +
70
+ ` ${installCmd}\n`
71
+ );
72
+ process.exit(1);
73
+ }
74
+
75
+ // Step 3: Load and validate config using the dynamically imported module
76
+ let config: LauncherSkeleton;
77
+ try {
78
+ const rawConfig = await import(configPath);
79
+ config = configModule.validateConfig(rawConfig.default, configPath);
80
+ } catch (err) {
81
+ const errorMessage = err instanceof Error ? err.message : String(err);
82
+ console.error(`Error: Failed to load config from ${configPath}\n`);
83
+ console.error(errorMessage);
84
+ process.exit(1);
85
+ }
86
+
87
+ // Step 4: Resolve paths relative to config file location
88
+ // appDir is relative to configDir, commandsDir is relative to appDir
89
+ const appDir = path.resolve(configDir, config.appDir);
90
+ const commandsDir = path.resolve(appDir, config.commandsDir);
91
+ const cwd = path.resolve(configDir, config.cwd);
92
+
93
+ // Verify commands directory exists
94
+ if (!fs.existsSync(commandsDir)) {
95
+ console.error(`Error: Commands directory not found: ${commandsDir}\n`);
96
+ console.error(
97
+ `The commandsDir path in ${configPath} resolves to a directory that doesn't exist.`
98
+ );
99
+ process.exit(1);
100
+ }
101
+
102
+ // Step 5: Import core and call runCli with config adapters
103
+ // (In merged architecture, configModule and core are the same package)
104
+ const { runCli } = configModule as any;
105
+
106
+ await runCli(process.argv.slice(2), {
107
+ commandsDir,
108
+ projectRoot: cwd, // core uses projectRoot, config uses cwd
109
+ appName: config.appName,
110
+ version: config.version,
111
+ reporterAdapter: config.reporter,
112
+ prompter: config.prompter,
113
+ tabs: config.tabs,
114
+ pmScripts: config.pmScripts,
115
+ pmCommands: config.pmCommands,
116
+ });
117
+ }
118
+
28
119
  /**
29
120
  * Simple inline config file search (no external dependencies).
30
121
  * Searches for pok.config.ts starting from startDir, walking up the tree.
@@ -260,94 +351,3 @@ async function runInFallbackMode(pkgDir: string) {
260
351
  },
261
352
  });
262
353
  }
263
-
264
- async function main() {
265
- const processCwd = process.cwd();
266
-
267
- // Step 1: Find config file using simple inline search
268
- const configResult = findConfigFileSimple(processCwd);
269
-
270
- if (!configResult) {
271
- // Look for package.json
272
- const pkgJsonResult = findPackageJsonSimple(processCwd);
273
- if (pkgJsonResult) {
274
- await runInFallbackMode(pkgJsonResult.pkgDir);
275
- return;
276
- }
277
-
278
- console.error(`Error: No pok configuration or package.json found.
279
-
280
- Run \`pok init\` to create a pok.config.ts file.
281
- `);
282
- process.exit(1);
283
- }
284
-
285
- const { configPath, configDir } = configResult;
286
-
287
- // Step 2: Dynamically resolve @pokit/core from the project directory
288
- let configModule = await resolveModule('@pokit/core', configDir);
289
-
290
- if (!configModule) {
291
- if (await ensureModulesInstalled(configDir, ['@pokit/core'])) {
292
- configModule = await resolveModule('@pokit/core', configDir);
293
- }
294
- }
295
-
296
- if (!configModule) {
297
- const installCmd = getInstallCommand(configDir, ['@pokit/core']);
298
- console.error(
299
- `Error: @pokit/core is not installed in ${configDir}\n\n` +
300
- 'Install it with:\n' +
301
- ` ${installCmd}\n`
302
- );
303
- process.exit(1);
304
- }
305
-
306
- // Step 3: Load and validate config using the dynamically imported module
307
- let config: LauncherSkeleton;
308
- try {
309
- const rawConfig = await import(configPath);
310
- config = configModule.validateConfig(rawConfig.default, configPath);
311
- } catch (err) {
312
- const errorMessage = err instanceof Error ? err.message : String(err);
313
- console.error(`Error: Failed to load config from ${configPath}\n`);
314
- console.error(errorMessage);
315
- process.exit(1);
316
- }
317
-
318
- // Step 4: Resolve paths relative to config file location
319
- // appDir is relative to configDir, commandsDir is relative to appDir
320
- const appDir = path.resolve(configDir, config.appDir);
321
- const commandsDir = path.resolve(appDir, config.commandsDir);
322
- const cwd = path.resolve(configDir, config.cwd);
323
-
324
- // Verify commands directory exists
325
- if (!fs.existsSync(commandsDir)) {
326
- console.error(`Error: Commands directory not found: ${commandsDir}\n`);
327
- console.error(
328
- `The commandsDir path in ${configPath} resolves to a directory that doesn't exist.`
329
- );
330
- process.exit(1);
331
- }
332
-
333
- // Step 5: Import core and call runCli with config adapters
334
- // (In merged architecture, configModule and core are the same package)
335
- const { runCli } = configModule as any;
336
-
337
- await runCli(process.argv.slice(2), {
338
- commandsDir,
339
- projectRoot: cwd, // core uses projectRoot, config uses cwd
340
- appName: config.appName,
341
- version: config.version,
342
- reporterAdapter: config.reporter,
343
- prompter: config.prompter,
344
- tabs: config.tabs,
345
- pmScripts: config.pmScripts,
346
- pmCommands: config.pmCommands,
347
- });
348
- }
349
-
350
- main().catch((err) => {
351
- console.error(err);
352
- process.exit(1);
353
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokit",
3
- "version": "0.0.20",
3
+ "version": "0.0.24",
4
4
  "description": "Global CLI launcher for pok - install once, run anywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/bun": "latest",
34
- "@pokit/reporter-clack": "0.0.20",
35
- "@pokit/core": "0.0.20",
36
- "@pokit/prompter-clack": "0.0.20"
34
+ "@pokit/core": "0.0.24",
35
+ "@pokit/prompter-clack": "0.0.24",
36
+ "@pokit/reporter-clack": "0.0.24"
37
37
  },
38
38
  "engines": {
39
39
  "bun": ">=1.0.0"