@aspects-ai/workspace-cli 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/dist/index.js +48 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -518,29 +518,30 @@ function createCreateFrameCommand() {
518
518
  import { Command as Command6 } from "commander";
519
519
  import path6 from "path";
520
520
  import fs6 from "fs-extra";
521
+ import { execa as execa2 } from "execa";
522
+ import os2 from "os";
521
523
  import chalk6 from "chalk";
522
- import { fileURLToPath as fileURLToPath2 } from "url";
523
- var __filename2 = fileURLToPath2(import.meta.url);
524
- var __dirname2 = path6.dirname(__filename2);
524
+ var NOODLE_BASE_REPO = "https://github.com/aspects-ai/noodle-templates";
525
+ var NOODLE_BASE_BRANCH = "main";
526
+ var EDITING_FILE_PATH = "noodle-base/EDITING.md";
525
527
  function createUpdateTemplateCommand() {
526
528
  return new Command6("update-template").description("Update EDITING.md file from noodle-base template").action(async () => {
527
529
  try {
528
530
  const workspaceRoot = await ensureWorkspaceRoot();
529
- const noodleBasePath = path6.resolve(__dirname2, "../../../noodle-base");
530
- const sourceFile = path6.join(noodleBasePath, "EDITING.md");
531
531
  const targetFile = path6.join(workspaceRoot, "EDITING.md");
532
- if (!await fs6.pathExists(sourceFile)) {
533
- throw new Error(
534
- `Template file not found at: ${sourceFile}
535
- Make sure noodle-base is available in the monorepo.`
536
- );
537
- }
532
+ const token = getToken();
538
533
  const targetExists = await fs6.pathExists(targetFile);
539
534
  if (targetExists) {
540
535
  logger.info("Existing EDITING.md found, it will be overwritten.");
541
536
  }
542
- logger.info(`Copying EDITING.md from noodle-base...`);
543
- await fs6.copy(sourceFile, targetFile, { overwrite: true });
537
+ logger.info("Fetching EDITING.md from noodle-base...");
538
+ const content = await fetchFileFromGit({
539
+ repository: NOODLE_BASE_REPO,
540
+ filePath: EDITING_FILE_PATH,
541
+ branch: NOODLE_BASE_BRANCH,
542
+ token
543
+ });
544
+ await fs6.writeFile(targetFile, content, "utf-8");
544
545
  logger.success(
545
546
  `Successfully ${targetExists ? "updated" : "copied"} EDITING.md to workspace`
546
547
  );
@@ -553,11 +554,44 @@ Make sure noodle-base is available in the monorepo.`
553
554
  }
554
555
  });
555
556
  }
557
+ async function fetchFileFromGit(options) {
558
+ const tempDir = await fs6.mkdtemp(path6.join(os2.tmpdir(), "workspace-cli-"));
559
+ try {
560
+ const repoUrl = options.repository.replace(
561
+ "https://github.com/",
562
+ `https://${options.token}@github.com/`
563
+ );
564
+ await execa2("git", ["init"], { cwd: tempDir });
565
+ await execa2("git", ["remote", "add", "origin", repoUrl], { cwd: tempDir });
566
+ await execa2("git", ["config", "core.sparseCheckout", "true"], { cwd: tempDir });
567
+ const sparseFile = path6.join(tempDir, ".git", "info", "sparse-checkout");
568
+ await fs6.writeFile(sparseFile, `${options.filePath}
569
+ `);
570
+ await execa2("git", ["pull", "origin", options.branch, "--depth=1"], {
571
+ cwd: tempDir,
572
+ stderr: "pipe"
573
+ });
574
+ const sourceFile = path6.join(tempDir, options.filePath);
575
+ if (!await fs6.pathExists(sourceFile)) {
576
+ throw new Error(`File '${options.filePath}' not found in repository`);
577
+ }
578
+ return await fs6.readFile(sourceFile, "utf-8");
579
+ } catch (error) {
580
+ if (error.stderr && error.stderr.includes("Authentication failed")) {
581
+ throw new Error(
582
+ "Git authentication failed. Please check your WORKSPACE_CLI_TOKEN.\nThe token must have access to the repository."
583
+ );
584
+ }
585
+ throw new Error(`Failed to fetch file from git: ${error.message}`);
586
+ } finally {
587
+ await fs6.remove(tempDir);
588
+ }
589
+ }
556
590
 
557
591
  // package.json
558
592
  var package_default = {
559
593
  name: "@aspects-ai/workspace-cli",
560
- version: "0.1.5",
594
+ version: "0.1.6",
561
595
  private: false,
562
596
  description: "Lightweight CLI for installing libraries into workspaces",
563
597
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspects-ai/workspace-cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "private": false,
5
5
  "description": "Lightweight CLI for installing libraries into workspaces",
6
6
  "type": "module",