pokit 0.0.7 → 0.0.10
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 +21 -64
- 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,17 +72,22 @@ 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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
reporter: unknown;
|
|
84
|
+
prompter: unknown;
|
|
85
|
+
tabs?: unknown;
|
|
86
|
+
version?: string;
|
|
87
|
+
npmScripts?: boolean | string[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
87
91
|
|
|
88
92
|
try {
|
|
89
93
|
const configModulePath = await resolve('@pokit/config', configDir);
|
|
@@ -135,56 +139,7 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
135
139
|
process.exit(1);
|
|
136
140
|
}
|
|
137
141
|
|
|
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
|
|
142
|
+
// Step 6: Import core and call runCli with config adapters
|
|
188
143
|
const { runCli } = await import(corePath);
|
|
189
144
|
|
|
190
145
|
await runCli(process.argv.slice(2), {
|
|
@@ -192,11 +147,13 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
192
147
|
projectRoot: cwd, // core uses projectRoot, config uses cwd
|
|
193
148
|
appName: config.appName,
|
|
194
149
|
version: config.version,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
150
|
+
reporterAdapter: config.reporter,
|
|
151
|
+
prompter: config.prompter,
|
|
152
|
+
tabs: config.tabs,
|
|
153
|
+
npmScripts: config.npmScripts,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
200
157
|
|
|
201
158
|
main().catch((err) => {
|
|
202
159
|
console.error(err);
|
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
|
|