pokit 0.0.7 → 0.0.8
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 +12 -59
- package/package.json +1 -1
- package/src/init.ts +5 -4
package/bin/pok.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* 1. Searches for pok.config.ts (or .config/pok.config.ts) starting from cwd
|
|
7
7
|
* 2. Loads and validates the config
|
|
8
8
|
* 3. Resolves paths relative to config file location
|
|
9
|
-
* 4.
|
|
10
|
-
* 5. Calls runCli() with resolved configuration
|
|
9
|
+
* 4. Calls runCli() with the config
|
|
11
10
|
*
|
|
12
11
|
* Install globally with: bun add -g pokit
|
|
13
12
|
* Then run `pok` from any project with a pok.config.ts file.
|
|
@@ -73,14 +72,17 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
73
72
|
|
|
74
73
|
// Step 2: Dynamically resolve @pokit/config from the project directory
|
|
75
74
|
let configModule: {
|
|
76
|
-
validateConfig: (
|
|
75
|
+
validateConfig: (
|
|
76
|
+
config: unknown,
|
|
77
|
+
configPath: string
|
|
78
|
+
) => {
|
|
77
79
|
appDir: string;
|
|
78
80
|
cwd: string;
|
|
79
81
|
commandsDir: string;
|
|
80
82
|
appName?: string;
|
|
81
|
-
|
|
82
|
-
prompter:
|
|
83
|
-
tabs?:
|
|
83
|
+
reporter: unknown;
|
|
84
|
+
prompter: unknown;
|
|
85
|
+
tabs?: unknown;
|
|
84
86
|
version?: string;
|
|
85
87
|
};
|
|
86
88
|
};
|
|
@@ -135,56 +137,7 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
135
137
|
process.exit(1);
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
// Step 6:
|
|
139
|
-
let createReporterAdapter: (options?: { output?: unknown }) => unknown;
|
|
140
|
-
let createPrompter: () => unknown;
|
|
141
|
-
let createTabs: (() => unknown) | undefined;
|
|
142
|
-
|
|
143
|
-
// Import reporter adapter
|
|
144
|
-
try {
|
|
145
|
-
const reporterPath = await resolve(config.reporterAdapter, appDir);
|
|
146
|
-
const reporterModule = await import(reporterPath);
|
|
147
|
-
createReporterAdapter = reporterModule.createReporterAdapter;
|
|
148
|
-
} catch {
|
|
149
|
-
console.error(
|
|
150
|
-
`Error: Reporter adapter "${config.reporterAdapter}" is not installed.\n\n` +
|
|
151
|
-
`Install it with:\n` +
|
|
152
|
-
` bun add ${config.reporterAdapter}\n`
|
|
153
|
-
);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Import prompter
|
|
158
|
-
try {
|
|
159
|
-
const prompterPath = await resolve(config.prompter, appDir);
|
|
160
|
-
const prompterModule = await import(prompterPath);
|
|
161
|
-
createPrompter = prompterModule.createPrompter;
|
|
162
|
-
} catch {
|
|
163
|
-
console.error(
|
|
164
|
-
`Error: Prompter "${config.prompter}" is not installed.\n\n` +
|
|
165
|
-
`Install it with:\n` +
|
|
166
|
-
` bun add ${config.prompter}\n`
|
|
167
|
-
);
|
|
168
|
-
process.exit(1);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Import tabs adapter if configured
|
|
172
|
-
if (config.tabs) {
|
|
173
|
-
try {
|
|
174
|
-
const tabsPath = await resolve(config.tabs, appDir);
|
|
175
|
-
const tabsModule = await import(tabsPath);
|
|
176
|
-
createTabs = tabsModule.createTabs;
|
|
177
|
-
} catch {
|
|
178
|
-
console.error(
|
|
179
|
-
`Error: Tabs adapter "${config.tabs}" is not installed.\n\n` +
|
|
180
|
-
`Install it with:\n` +
|
|
181
|
-
` bun add ${config.tabs}\n`
|
|
182
|
-
);
|
|
183
|
-
process.exit(1);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Step 7: Import core and call runCli
|
|
140
|
+
// Step 6: Import core and call runCli with config adapters
|
|
188
141
|
const { runCli } = await import(corePath);
|
|
189
142
|
|
|
190
143
|
await runCli(process.argv.slice(2), {
|
|
@@ -192,9 +145,9 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
192
145
|
projectRoot: cwd, // core uses projectRoot, config uses cwd
|
|
193
146
|
appName: config.appName,
|
|
194
147
|
version: config.version,
|
|
195
|
-
reporterAdapter:
|
|
196
|
-
prompter:
|
|
197
|
-
tabs:
|
|
148
|
+
reporterAdapter: config.reporter,
|
|
149
|
+
prompter: config.prompter,
|
|
150
|
+
tabs: config.tabs,
|
|
198
151
|
});
|
|
199
152
|
}
|
|
200
153
|
|
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -14,12 +14,13 @@ 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/config'
|
|
18
|
+
import { createReporterAdapter } from '@pokit/reporter-clack'
|
|
19
|
+
import { createPrompter } from '@pokit/prompter-clack'
|
|
18
20
|
|
|
19
21
|
export default defineConfig({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
prompter: '@pokit/prompter-clack',
|
|
22
|
+
reporter: createReporterAdapter(),
|
|
23
|
+
prompter: createPrompter(),
|
|
23
24
|
})
|
|
24
25
|
`;
|
|
25
26
|
|