@kradle/cli 0.0.10 → 0.0.12

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.
@@ -5,7 +5,7 @@ import { Listr } from "listr2";
5
5
  import pc from "picocolors";
6
6
  import { ApiClient } from "../../lib/api-client.js";
7
7
  import { getChallengeSlugArgument } from "../../lib/arguments.js";
8
- import { Challenge } from "../../lib/challenge.js";
8
+ import { Challenge, SOURCE_FOLDER } from "../../lib/challenge.js";
9
9
  import { loadConfig } from "../../lib/config.js";
10
10
  import { clearScreen, debounced } from "../../lib/utils.js";
11
11
  export default class Watch extends Command {
@@ -91,7 +91,7 @@ export default class Watch extends Command {
91
91
  this.log(pc.dim("Watching for changes... (Ctrl+C to stop)\n"));
92
92
  const watcher = chokidar.watch([challenge.challengeDir], {
93
93
  // ⚠️ WE IGNORE THE DATAPACK FOLDER FOR NOW, BUT IT'S A SHORT TERM FIX.
94
- ignored: [/(^|[/\\])\../, (p) => p.includes("/datapack")], // ignore dotfiles and datapack folder
94
+ ignored: [/(^|[/\\])\../, (p) => p.includes("/datapack"), (p) => p.includes(`/${SOURCE_FOLDER}`)], // ignore dotfiles and datapack folder
95
95
  persistent: true,
96
96
  ignoreInitial: true,
97
97
  });
@@ -44,17 +44,17 @@ export default class Init extends Command {
44
44
  projectName = flags.name;
45
45
  }
46
46
  else {
47
- let initial;
48
47
  if (useCurrentDir) {
49
- initial = path.basename(cwd);
48
+ projectName = path.basename(cwd);
49
+ }
50
+ else {
51
+ const { name } = await enquirer.prompt({
52
+ type: "input",
53
+ name: "name",
54
+ message: "What should the directory be called?",
55
+ });
56
+ projectName = name;
50
57
  }
51
- const { name } = await enquirer.prompt({
52
- type: "input",
53
- name: "name",
54
- message: "What should the directory be called?",
55
- initial: initial,
56
- });
57
- projectName = name;
58
58
  }
59
59
  // let useDev = flags.dev;
60
60
  // if (!useDev) {
@@ -1,6 +1,7 @@
1
1
  import type { ApiClient } from "./api-client.js";
2
2
  import type { Config } from "./config.js";
3
3
  import { type ChallengeSchemaType } from "./schemas.js";
4
+ export declare const SOURCE_FOLDER = ".src";
4
5
  export declare class Challenge {
5
6
  readonly name: string;
6
7
  private readonly config;
@@ -6,6 +6,7 @@ import pc from "picocolors";
6
6
  import * as tar from "tar";
7
7
  import { ChallengeSchema } from "./schemas.js";
8
8
  import { executeNodeCommand, executeTypescriptFile, getStaticResourcePath, readDirSorted } from "./utils.js";
9
+ export const SOURCE_FOLDER = ".src";
9
10
  export class Challenge {
10
11
  name;
11
12
  config;
@@ -99,10 +100,9 @@ export class Challenge {
99
100
  throw new Error(`Failed to build datapack: ${error instanceof Error ? error.message : error}`);
100
101
  }
101
102
  // @TODO - re-enable once we have a proper build pipeline
102
- // Recursively copy the challenge dir to target directory, under src/
103
- // await fs.cp(this.challengeDir, path.join(this.config.KRADLE_CHALLENGES_PATH, this.shortSlug, "src"), {
104
- // recursive: true,
105
- // });
103
+ // Copy challenge.ts and config.ts to the src directory
104
+ await fs.cp(path.join(this.challengeDir, "challenge.ts"), path.join(this.config.KRADLE_CHALLENGES_PATH, this.shortSlug, SOURCE_FOLDER, "challenge.ts"));
105
+ await fs.cp(path.join(this.challengeDir, "config.ts"), path.join(this.config.KRADLE_CHALLENGES_PATH, this.shortSlug, SOURCE_FOLDER, "config.ts"));
106
106
  }
107
107
  /**
108
108
  * Load the challenge configuration from config.ts
@@ -133,7 +133,7 @@ export class Challenge {
133
133
  gzip: true,
134
134
  cwd: this.datapackPath, // Input directory
135
135
  strict: true,
136
- }, ["datapack"]);
136
+ }, ["datapack", SOURCE_FOLDER]);
137
137
  const uploadUrl = await apiClient.getChallengeUploadUrl(this);
138
138
  const fileBuffer = await fs.readFile(this.tarballPath);
139
139
  const response = await fetch(uploadUrl, {
@@ -401,5 +401,5 @@
401
401
  ]
402
402
  }
403
403
  },
404
- "version": "0.0.10"
404
+ "version": "0.0.12"
405
405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kradle/cli",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Kradle's CLI. Manage challenges, evaluations, agents and more!",
5
5
  "keywords": [
6
6
  "cli"