pokit 0.0.6 → 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 +24 -70
- 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.
|
|
@@ -56,10 +55,10 @@ function findConfigFileSimple(startDir: string): { configPath: string; configDir
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
async function main() {
|
|
59
|
-
const
|
|
58
|
+
const processCwd = process.cwd();
|
|
60
59
|
|
|
61
60
|
// Step 1: Find config file using simple inline search
|
|
62
|
-
const configResult = findConfigFileSimple(
|
|
61
|
+
const configResult = findConfigFileSimple(processCwd);
|
|
63
62
|
|
|
64
63
|
if (!configResult) {
|
|
65
64
|
console.error(`Error: No pok configuration found.
|
|
@@ -73,13 +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
|
+
) => {
|
|
79
|
+
appDir: string;
|
|
80
|
+
cwd: string;
|
|
77
81
|
commandsDir: string;
|
|
78
|
-
projectRoot?: string;
|
|
79
82
|
appName?: string;
|
|
80
|
-
|
|
81
|
-
prompter:
|
|
82
|
-
tabs?:
|
|
83
|
+
reporter: unknown;
|
|
84
|
+
prompter: unknown;
|
|
85
|
+
tabs?: unknown;
|
|
83
86
|
version?: string;
|
|
84
87
|
};
|
|
85
88
|
};
|
|
@@ -109,10 +112,10 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
// Step 4: Resolve paths relative to config file location
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
// appDir is relative to configDir, commandsDir is relative to appDir
|
|
116
|
+
const appDir = path.resolve(configDir, config.appDir);
|
|
117
|
+
const commandsDir = path.resolve(appDir, config.commandsDir);
|
|
118
|
+
const cwd = path.resolve(configDir, config.cwd);
|
|
116
119
|
|
|
117
120
|
// Verify commands directory exists
|
|
118
121
|
if (!fs.existsSync(commandsDir)) {
|
|
@@ -121,79 +124,30 @@ Run \`pok init\` to create a pok.config.ts file.
|
|
|
121
124
|
process.exit(1);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
// Step 5: Resolve @pokit/core from
|
|
127
|
+
// Step 5: Resolve @pokit/core from appDir (where packages are installed)
|
|
125
128
|
let corePath: string;
|
|
126
129
|
try {
|
|
127
|
-
corePath = await resolve('@pokit/core',
|
|
130
|
+
corePath = await resolve('@pokit/core', appDir);
|
|
128
131
|
} catch {
|
|
129
132
|
console.error(
|
|
130
|
-
`Error: @pokit/core is not installed in ${
|
|
133
|
+
`Error: @pokit/core is not installed in ${appDir}\n\n` +
|
|
131
134
|
'Install it with:\n' +
|
|
132
135
|
' bun add @pokit/core\n'
|
|
133
136
|
);
|
|
134
137
|
process.exit(1);
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
// Step 6:
|
|
138
|
-
let createReporterAdapter: (options?: { output?: unknown }) => unknown;
|
|
139
|
-
let createPrompter: () => unknown;
|
|
140
|
-
let createTabs: (() => unknown) | undefined;
|
|
141
|
-
|
|
142
|
-
// Import reporter adapter
|
|
143
|
-
try {
|
|
144
|
-
const reporterPath = await resolve(config.reporterAdapter, configDir);
|
|
145
|
-
const reporterModule = await import(reporterPath);
|
|
146
|
-
createReporterAdapter = reporterModule.createReporterAdapter;
|
|
147
|
-
} catch {
|
|
148
|
-
console.error(
|
|
149
|
-
`Error: Reporter adapter "${config.reporterAdapter}" is not installed.\n\n` +
|
|
150
|
-
`Install it with:\n` +
|
|
151
|
-
` bun add ${config.reporterAdapter}\n`
|
|
152
|
-
);
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Import prompter
|
|
157
|
-
try {
|
|
158
|
-
const prompterPath = await resolve(config.prompter, configDir);
|
|
159
|
-
const prompterModule = await import(prompterPath);
|
|
160
|
-
createPrompter = prompterModule.createPrompter;
|
|
161
|
-
} catch {
|
|
162
|
-
console.error(
|
|
163
|
-
`Error: Prompter "${config.prompter}" is not installed.\n\n` +
|
|
164
|
-
`Install it with:\n` +
|
|
165
|
-
` bun add ${config.prompter}\n`
|
|
166
|
-
);
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Import tabs adapter if configured
|
|
171
|
-
if (config.tabs) {
|
|
172
|
-
try {
|
|
173
|
-
const tabsPath = await resolve(config.tabs, configDir);
|
|
174
|
-
const tabsModule = await import(tabsPath);
|
|
175
|
-
createTabs = tabsModule.createTabs;
|
|
176
|
-
} catch {
|
|
177
|
-
console.error(
|
|
178
|
-
`Error: Tabs adapter "${config.tabs}" is not installed.\n\n` +
|
|
179
|
-
`Install it with:\n` +
|
|
180
|
-
` bun add ${config.tabs}\n`
|
|
181
|
-
);
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Step 7: Import core and call runCli
|
|
140
|
+
// Step 6: Import core and call runCli with config adapters
|
|
187
141
|
const { runCli } = await import(corePath);
|
|
188
142
|
|
|
189
143
|
await runCli(process.argv.slice(2), {
|
|
190
144
|
commandsDir,
|
|
191
|
-
projectRoot,
|
|
145
|
+
projectRoot: cwd, // core uses projectRoot, config uses cwd
|
|
192
146
|
appName: config.appName,
|
|
193
147
|
version: config.version,
|
|
194
|
-
reporterAdapter:
|
|
195
|
-
prompter:
|
|
196
|
-
tabs:
|
|
148
|
+
reporterAdapter: config.reporter,
|
|
149
|
+
prompter: config.prompter,
|
|
150
|
+
tabs: config.tabs,
|
|
197
151
|
});
|
|
198
152
|
}
|
|
199
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
|
|