pokit 0.0.10 → 0.0.11

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
@@ -15,6 +15,7 @@
15
15
  import { resolve } from 'bun';
16
16
  import * as fs from 'fs';
17
17
  import * as path from 'path';
18
+ import type { ConfigModule, LauncherSkeleton } from '../src/protocol';
18
19
 
19
20
  // Handle init before config discovery - must work without a config file
20
21
  const args = process.argv.slice(2);
@@ -70,39 +71,23 @@ Run \`pok init\` to create a pok.config.ts file.
70
71
 
71
72
  const { configPath, configDir } = configResult;
72
73
 
73
- // Step 2: Dynamically resolve @pokit/config from the project directory
74
- let configModule: {
75
- validateConfig: (
76
- config: unknown,
77
- configPath: string
78
- ) => {
79
- appDir: string;
80
- cwd: string;
81
- commandsDir: string;
82
- appName?: string;
83
- reporter: unknown;
84
- prompter: unknown;
85
- tabs?: unknown;
86
- version?: string;
87
- npmScripts?: boolean | string[];
88
- };
89
- };
90
-
74
+ // Step 2: Dynamically resolve @pokit/core from the project directory
75
+ let configModule: ConfigModule;
91
76
 
92
77
  try {
93
- const configModulePath = await resolve('@pokit/config', configDir);
78
+ const configModulePath = await resolve('@pokit/core', configDir);
94
79
  configModule = await import(configModulePath);
95
80
  } catch {
96
81
  console.error(
97
- `Error: @pokit/config is not installed in ${configDir}\n\n` +
82
+ `Error: @pokit/core is not installed in ${configDir}\n\n` +
98
83
  'Install it with:\n' +
99
- ' bun add @pokit/config\n'
84
+ ' bun add @pokit/core\n'
100
85
  );
101
86
  process.exit(1);
102
87
  }
103
88
 
104
89
  // Step 3: Load and validate config using the dynamically imported module
105
- let config: ReturnType<typeof configModule.validateConfig>;
90
+ let config: LauncherSkeleton;
106
91
  try {
107
92
  const rawConfig = await import(configPath);
108
93
  config = configModule.validateConfig(rawConfig.default, configPath);
@@ -126,21 +111,9 @@ Run \`pok init\` to create a pok.config.ts file.
126
111
  process.exit(1);
127
112
  }
128
113
 
129
- // Step 5: Resolve @pokit/core from appDir (where packages are installed)
130
- let corePath: string;
131
- try {
132
- corePath = await resolve('@pokit/core', appDir);
133
- } catch {
134
- console.error(
135
- `Error: @pokit/core is not installed in ${appDir}\n\n` +
136
- 'Install it with:\n' +
137
- ' bun add @pokit/core\n'
138
- );
139
- process.exit(1);
140
- }
141
-
142
- // Step 6: Import core and call runCli with config adapters
143
- const { runCli } = await import(corePath);
114
+ // Step 5: Import core and call runCli with config adapters
115
+ // (In merged architecture, configModule and core are the same package)
116
+ const { runCli } = configModule as any;
144
117
 
145
118
  await runCli(process.argv.slice(2), {
146
119
  commandsDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pokit",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Global CLI launcher for pok - install once, run anywhere",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -16,6 +16,12 @@
16
16
  "bin": {
17
17
  "pok": "./bin/pok.ts"
18
18
  },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./src/protocol.ts",
22
+ "import": "./bin/pok.ts"
23
+ }
24
+ },
19
25
  "files": [
20
26
  "bin",
21
27
  "src"
package/src/init.ts CHANGED
@@ -14,7 +14,7 @@ const CONFIG_FILENAME = 'pok.config.ts';
14
14
  * Fallback template used when @pokit/config isn't installed yet.
15
15
  * This enables bootstrapping new projects.
16
16
  */
17
- const FALLBACK_CONFIG_TEMPLATE = `import { defineConfig } from '@pokit/config'
17
+ const FALLBACK_CONFIG_TEMPLATE = `import { defineConfig } from '@pokit/core'
18
18
  import { createReporterAdapter } from '@pokit/reporter-clack'
19
19
  import { createPrompter } from '@pokit/prompter-clack'
20
20
 
@@ -25,15 +25,15 @@ export default defineConfig({
25
25
  `;
26
26
 
27
27
  /**
28
- * Try to get CONFIG_TEMPLATE from @pokit/config, falling back to hardcoded template.
28
+ * Try to get CONFIG_TEMPLATE from @pokit/core, falling back to hardcoded template.
29
29
  */
30
30
  async function getConfigTemplate(cwd: string): Promise<string> {
31
31
  try {
32
- const configModulePath = await resolve('@pokit/config', cwd);
32
+ const configModulePath = await resolve('@pokit/core', cwd);
33
33
  const configModule = await import(configModulePath);
34
34
  return configModule.CONFIG_TEMPLATE ?? FALLBACK_CONFIG_TEMPLATE;
35
35
  } catch {
36
- // @pokit/config not installed yet - use fallback for bootstrapping
36
+ // @pokit/core not installed yet - use fallback for bootstrapping
37
37
  return FALLBACK_CONFIG_TEMPLATE;
38
38
  }
39
39
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The Pokit Launcher Protocol
3
+ *
4
+ * This file defines the "Skeleton" that any pok configuration must satisfy
5
+ * for the global launcher to successfully bootstrap the application.
6
+ *
7
+ * This is the "Master" contract.
8
+ */
9
+
10
+ export interface LauncherSkeleton {
11
+ /** Root directory of the pok CLI app */
12
+ appDir: string;
13
+ /** Working directory for running commands */
14
+ cwd: string;
15
+ /** Directory containing command files */
16
+ commandsDir: string;
17
+ /** App name for CLI display */
18
+ appName?: string;
19
+ /** Version string */
20
+ version?: string;
21
+ /** Reporter adapter instance */
22
+ reporter: any;
23
+ /** Prompter instance */
24
+ prompter: any;
25
+ /** Optional tabs adapter instance */
26
+ tabs?: any;
27
+ /** NPM scripts configuration */
28
+ npmScripts?: boolean | string[];
29
+ }
30
+
31
+ /**
32
+ * The shape of the module exported by @pokit/config
33
+ */
34
+ export interface ConfigModule {
35
+ validateConfig(config: unknown, configPath: string): LauncherSkeleton;
36
+ }