keryx 0.2.1 → 0.3.0

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.
@@ -604,24 +604,7 @@ export class Actions extends Initializer {
604
604
  };
605
605
 
606
606
  async initialize() {
607
- // Load framework actions from the package directory
608
- const frameworkActions = await globLoader<Action>(
609
- path.join(api.packageDir, "actions"),
610
- );
611
-
612
- // Load user project actions (if rootDir differs from packageDir)
613
- let userActions: Action[] = [];
614
- if (api.rootDir !== api.packageDir) {
615
- try {
616
- userActions = await globLoader<Action>(
617
- path.join(api.rootDir, "actions"),
618
- );
619
- } catch {
620
- // user project may not have actions, that's fine
621
- }
622
- }
623
-
624
- const actions = [...frameworkActions, ...userActions];
607
+ const actions = await globLoader<Action>(path.join(api.rootDir, "actions"));
625
608
 
626
609
  for (const a of actions) {
627
610
  if (!a.description) a.description = `An Action: ${a.name}`;
@@ -179,11 +179,8 @@ export class SwaggerInitializer extends Initializer {
179
179
  const cacheDir = path.join(api.rootDir, ".cache");
180
180
  const cacheFile = path.join(cacheDir, "swagger-schemas.json");
181
181
 
182
- // Hash action source files to detect changes (scan both packageDir and rootDir)
183
- const actionsDirs = [path.join(api.packageDir, "actions")];
184
- if (api.rootDir !== api.packageDir) {
185
- actionsDirs.push(path.join(api.rootDir, "actions"));
186
- }
182
+ // Hash action source files to detect changes
183
+ const actionsDirs = [path.join(api.rootDir, "actions")];
187
184
  const glob = new Bun.Glob("**/*.ts");
188
185
  const hasher = new Bun.CryptoHasher("sha256");
189
186
  for (const actionsDir of actionsDirs) {
package/keryx.ts CHANGED
@@ -19,13 +19,14 @@ program
19
19
  .command("new [project-name]")
20
20
  .summary("Create a new Keryx project")
21
21
  .description("Scaffold a new Keryx application with project boilerplate")
22
+ .option("-y, --yes", "Skip prompts and use defaults")
22
23
  .option("--no-interactive", "Skip prompts and use defaults")
23
24
  .option("--no-db", "Skip database setup files")
24
25
  .option("--no-example", "Skip example action")
25
26
  .action(async (projectName: string | undefined, opts) => {
26
27
  let options: ScaffoldOptions;
27
28
 
28
- if (opts.interactive === false) {
29
+ if (opts.yes || opts.interactive === false) {
29
30
  // --no-interactive: use defaults
30
31
  projectName = projectName || "my-keryx-app";
31
32
  options = {
@@ -64,22 +65,13 @@ program
64
65
  await api.start();
65
66
  });
66
67
 
67
- // Load framework actions from the package directory
68
- const frameworkActions = await globLoader<Action>(
69
- path.join(api.packageDir, "actions"),
70
- );
71
-
72
- // Load user project actions (if rootDir differs from packageDir)
73
- let userActions: Action[] = [];
74
- if (api.rootDir !== api.packageDir) {
75
- try {
76
- userActions = await globLoader<Action>(path.join(api.rootDir, "actions"));
77
- } catch {
78
- // user project may not have actions, that's fine
79
- }
68
+ // Load actions from the project directory
69
+ let actions: Action[] = [];
70
+ try {
71
+ actions = await globLoader<Action>(path.join(api.rootDir, "actions"));
72
+ } catch {
73
+ // project may not have actions yet
80
74
  }
81
-
82
- const actions = [...frameworkActions, ...userActions];
83
75
  actions.forEach((action) => addActionToProgram(program, action));
84
76
 
85
77
  program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keryx",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,20 +20,13 @@ program
20
20
  await api.start();
21
21
  });
22
22
 
23
- // Load framework actions from the package directory
24
- const frameworkActions = await globLoader<Action>(
25
- path.join(api.packageDir, "actions"),
26
- );
27
-
28
- // Load user project actions
29
- let userActions: Action[] = [];
23
+ // Load actions from the project directory
24
+ let actions: Action[] = [];
30
25
  try {
31
- userActions = await globLoader<Action>(path.join(api.rootDir, "actions"));
26
+ actions = await globLoader<Action>(path.join(api.rootDir, "actions"));
32
27
  } catch {
33
- // user project may not have actions, that's fine
28
+ // project may not have actions yet
34
29
  }
35
-
36
- const actions = [...frameworkActions, ...userActions];
37
30
  actions.forEach((action) => addActionToProgram(program, action));
38
31
 
39
32
  program
package/util/scaffold.ts CHANGED
@@ -199,12 +199,31 @@ export async function scaffoldProject(
199
199
  await write("drizzle/.gitkeep", "");
200
200
  }
201
201
 
202
+ // --- Built-in actions (always included) ---
203
+ // Copy status and swagger actions from the framework, adjusting imports
204
+ const builtinActions = ["status.ts", "swagger.ts"];
205
+ const actionsDir = path.join(import.meta.dir, "..", "actions");
206
+ for (const file of builtinActions) {
207
+ let content = await Bun.file(path.join(actionsDir, file)).text();
208
+
209
+ // Rewrite relative imports to package imports
210
+ content = content.replace(/from ["']\.\.\/api["']/g, 'from "keryx"');
211
+ content = content.replace(
212
+ /from ["']\.\.\/classes\/Action["']/g,
213
+ 'from "keryx/classes/Action.ts"',
214
+ );
215
+ content = content.replace(
216
+ /from ["']\.\.\/package\.json["']/g,
217
+ 'from "../package.json"',
218
+ );
219
+
220
+ await write(`actions/${file}`, content);
221
+ }
222
+
202
223
  // --- Example action ---
203
224
 
204
225
  if (options.includeExample) {
205
226
  await writeTemplate("actions/hello.ts", "hello-action.ts.mustache");
206
- } else {
207
- await write("actions/.gitkeep", "");
208
227
  }
209
228
 
210
229
  return createdFiles;