pokit 0.0.8 → 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 +17 -40
- package/package.json +7 -1
- package/src/init.ts +4 -4
- package/src/protocol.ts +36 -0
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,37 +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/
|
|
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
|
-
};
|
|
88
|
-
};
|
|
74
|
+
// Step 2: Dynamically resolve @pokit/core from the project directory
|
|
75
|
+
let configModule: ConfigModule;
|
|
89
76
|
|
|
90
77
|
try {
|
|
91
|
-
const configModulePath = await resolve('@pokit/
|
|
78
|
+
const configModulePath = await resolve('@pokit/core', configDir);
|
|
92
79
|
configModule = await import(configModulePath);
|
|
93
80
|
} catch {
|
|
94
81
|
console.error(
|
|
95
|
-
`Error: @pokit/
|
|
82
|
+
`Error: @pokit/core is not installed in ${configDir}\n\n` +
|
|
96
83
|
'Install it with:\n' +
|
|
97
|
-
' bun add @pokit/
|
|
84
|
+
' bun add @pokit/core\n'
|
|
98
85
|
);
|
|
99
86
|
process.exit(1);
|
|
100
87
|
}
|
|
101
88
|
|
|
102
89
|
// Step 3: Load and validate config using the dynamically imported module
|
|
103
|
-
let config:
|
|
90
|
+
let config: LauncherSkeleton;
|
|
104
91
|
try {
|
|
105
92
|
const rawConfig = await import(configPath);
|
|
106
93
|
config = configModule.validateConfig(rawConfig.default, configPath);
|
|
@@ -124,32 +111,22 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
124
111
|
process.exit(1);
|
|
125
112
|
}
|
|
126
113
|
|
|
127
|
-
// Step 5:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
corePath = await resolve('@pokit/core', appDir);
|
|
131
|
-
} catch {
|
|
132
|
-
console.error(
|
|
133
|
-
`Error: @pokit/core is not installed in ${appDir}\n\n` +
|
|
134
|
-
'Install it with:\n' +
|
|
135
|
-
' bun add @pokit/core\n'
|
|
136
|
-
);
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Step 6: Import core and call runCli with config adapters
|
|
141
|
-
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;
|
|
142
117
|
|
|
143
118
|
await runCli(process.argv.slice(2), {
|
|
144
119
|
commandsDir,
|
|
145
120
|
projectRoot: cwd, // core uses projectRoot, config uses cwd
|
|
146
121
|
appName: config.appName,
|
|
147
122
|
version: config.version,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
123
|
+
reporterAdapter: config.reporter,
|
|
124
|
+
prompter: config.prompter,
|
|
125
|
+
tabs: config.tabs,
|
|
126
|
+
npmScripts: config.npmScripts,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
153
130
|
|
|
154
131
|
main().catch((err) => {
|
|
155
132
|
console.error(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pokit",
|
|
3
|
-
"version": "0.0.
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
36
|
+
// @pokit/core not installed yet - use fallback for bootstrapping
|
|
37
37
|
return FALLBACK_CONFIG_TEMPLATE;
|
|
38
38
|
}
|
|
39
39
|
}
|
package/src/protocol.ts
ADDED
|
@@ -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
|
+
}
|