pokit 0.0.21 → 0.0.35

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/bin/pok.ts CHANGED
@@ -113,6 +113,7 @@ Run \`pok init\` to create a pok.config.ts file.
113
113
  tabs: config.tabs,
114
114
  pmScripts: config.pmScripts,
115
115
  pmCommands: config.pmCommands,
116
+ plugins: config.plugins,
116
117
  });
117
118
  }
118
119
 
package/bin/poks.ts ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env bun
2
+ import { resolve } from 'bun';
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
5
+
6
+ main().catch((err) => {
7
+ console.error(err);
8
+ process.exit(1);
9
+ });
10
+
11
+ async function main() {
12
+ const args = process.argv.slice(2);
13
+
14
+ const processCwd = process.cwd();
15
+ const configResult = findConfigFileSimple(processCwd);
16
+
17
+ let appName: string;
18
+ let configDir: string;
19
+
20
+ if (configResult) {
21
+ configDir = configResult.configDir;
22
+ try {
23
+ const rawConfig = await import(configResult.configPath);
24
+ appName = rawConfig.default?.appName ?? path.basename(configDir);
25
+ } catch {
26
+ appName = path.basename(configDir);
27
+ }
28
+ } else {
29
+ configDir = processCwd;
30
+ appName = path.basename(processCwd);
31
+ }
32
+
33
+ const core = await resolveModule('@pokit/core', configDir);
34
+ if (!core) {
35
+ console.error('Error: @pokit/core is not installed.');
36
+ process.exit(1);
37
+ }
38
+
39
+ const { loadHistory, formatEntryLabel, clearHistory } = core;
40
+
41
+ if (args[0] === '--clear') {
42
+ clearHistory(appName);
43
+ console.log('History cleared.');
44
+ return;
45
+ }
46
+
47
+ const entries = loadHistory(appName);
48
+
49
+ if (entries.length === 0) {
50
+ console.log('No command history yet.');
51
+ return;
52
+ }
53
+
54
+ const reporter = await resolveModule('@pokit/reporter-clack', configDir);
55
+ const prompter = await resolveModule('@pokit/prompter-clack', configDir);
56
+
57
+ if (!reporter || !prompter) {
58
+ console.error('Error: @pokit/reporter-clack and @pokit/prompter-clack are required.');
59
+ process.exit(1);
60
+ }
61
+
62
+ const { createPrompter } = prompter;
63
+ const p = createPrompter();
64
+
65
+ const options = entries.map((entry: any) => ({
66
+ value: entry,
67
+ label: formatEntryLabel(entry),
68
+ }));
69
+
70
+ const choose = p.autocomplete ? p.autocomplete.bind(p) : p.select.bind(p);
71
+
72
+ const selected: any = await choose({
73
+ message: 'Recent commands',
74
+ options,
75
+ });
76
+
77
+ if (!selected) {
78
+ return;
79
+ }
80
+
81
+ const rerunArgs = [...selected.commandPath, ...selected.args];
82
+
83
+ const { execSync } = await import('child_process');
84
+ execSync(`pok ${rerunArgs.join(' ')}`, {
85
+ stdio: 'inherit',
86
+ cwd: processCwd,
87
+ });
88
+ }
89
+
90
+ function findConfigFileSimple(startDir: string): { configPath: string; configDir: string } | null {
91
+ let dir = startDir;
92
+
93
+ while (true) {
94
+ const configPath = path.join(dir, 'pok.config.ts');
95
+ if (fs.existsSync(configPath)) {
96
+ return { configPath, configDir: dir };
97
+ }
98
+
99
+ const dotConfigPath = path.join(dir, '.config', 'pok.config.ts');
100
+ if (fs.existsSync(dotConfigPath)) {
101
+ return { configPath: dotConfigPath, configDir: dir };
102
+ }
103
+
104
+ const parentDir = path.dirname(dir);
105
+ if (parentDir === dir) {
106
+ return null;
107
+ }
108
+ dir = parentDir;
109
+ }
110
+ }
111
+
112
+ async function resolveModule(name: string, configDir: string) {
113
+ try {
114
+ const projectModulePath = await resolve(name, configDir);
115
+ return await import(projectModulePath);
116
+ } catch {
117
+ try {
118
+ return await import(name);
119
+ } catch {
120
+ return null;
121
+ }
122
+ }
123
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokit",
3
- "version": "0.0.21",
3
+ "version": "0.0.35",
4
4
  "description": "Global CLI launcher for pok - install once, run anywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,7 +14,8 @@
14
14
  "url": "https://github.com/notation-dev/openpok/issues"
15
15
  },
16
16
  "bin": {
17
- "pok": "./bin/pok.ts"
17
+ "pok": "./bin/pok.ts",
18
+ "poks": "./bin/poks.ts"
18
19
  },
19
20
  "exports": {
20
21
  ".": {
@@ -31,9 +32,9 @@
31
32
  },
32
33
  "devDependencies": {
33
34
  "@types/bun": "latest",
34
- "@pokit/core": "0.0.21",
35
- "@pokit/reporter-clack": "0.0.21",
36
- "@pokit/prompter-clack": "0.0.21"
35
+ "@pokit/core": "0.0.35",
36
+ "@pokit/prompter-clack": "0.0.35",
37
+ "@pokit/reporter-clack": "0.0.35"
37
38
  },
38
39
  "engines": {
39
40
  "bun": ">=1.0.0"
package/src/protocol.ts CHANGED
@@ -37,6 +37,10 @@ export interface LauncherSkeleton {
37
37
  * - string[]: List of specific commands to include
38
38
  */
39
39
  pmCommands?: boolean | string[];
40
+ /**
41
+ * Plugins to mount at the root.
42
+ */
43
+ plugins?: any[];
40
44
  }
41
45
 
42
46
  /**