@aspects-ai/workspace-cli 0.1.1 → 0.1.3

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 (3) hide show
  1. package/README.md +15 -0
  2. package/dist/index.js +38 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -83,6 +83,21 @@ The command will:
83
83
  3. Update `workspace.config.json`
84
84
  4. Add dependencies to `package.json`
85
85
 
86
+ ### `update <library>`
87
+
88
+ Update an installed library to the latest version from the repository.
89
+
90
+ ```bash
91
+ WORKSPACE_CLI_TOKEN=ghp_xxx workspace-cli update animate-core
92
+ ```
93
+
94
+ This command will:
95
+ 1. Check the currently installed version
96
+ 2. Fetch the latest version from the git repository
97
+ 3. Overwrite the existing files
98
+ 4. Update `workspace.config.json` with the new version and commit hash
99
+ 5. Update dependencies in `package.json` if they changed
100
+
86
101
  ## Usage Examples
87
102
 
88
103
  ### Basic Workflow
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command4 } from "commander";
4
+ import { Command as Command5 } from "commander";
5
5
 
6
6
  // src/commands/init.ts
7
7
  import { Command } from "commander";
@@ -272,7 +272,10 @@ async function fetchDirectory(options) {
272
272
  if (!await fs3.pathExists(sourceDir)) {
273
273
  throw new Error(`Directory '${options.directory}' not found in repository`);
274
274
  }
275
- await fs3.ensureDir(options.targetPath);
275
+ if (await fs3.pathExists(options.targetPath)) {
276
+ await fs3.remove(options.targetPath);
277
+ }
278
+ await fs3.ensureDir(path3.dirname(options.targetPath));
276
279
  await fs3.copy(sourceDir, options.targetPath, {
277
280
  overwrite: true,
278
281
  errorOnExist: false
@@ -397,10 +400,42 @@ function createAddCommand() {
397
400
  });
398
401
  }
399
402
 
403
+ // src/commands/update.ts
404
+ import { Command as Command4 } from "commander";
405
+ import chalk4 from "chalk";
406
+ function createUpdateCommand() {
407
+ return new Command4("update").description("Update an installed library to the latest version").argument("<library>", "Name of the library to update").action(async (libraryName) => {
408
+ try {
409
+ const workspaceRoot = await ensureWorkspaceRoot();
410
+ await getOrCreateConfig(workspaceRoot);
411
+ if (!await isLibraryInstalled(workspaceRoot, libraryName)) {
412
+ throw new Error(
413
+ `Library '${libraryName}' is not installed.
414
+ Use 'workspace-cli add ${libraryName}' to install it first.`
415
+ );
416
+ }
417
+ const config = await loadWorkspaceConfig(workspaceRoot);
418
+ const currentVersion = config?.libraries[libraryName]?.version || "unknown";
419
+ const currentCommit = config?.libraries[libraryName]?.commit || "unknown";
420
+ logger.info(`Current version: ${currentVersion} (commit: ${currentCommit.substring(0, 7)})`);
421
+ logger.info(`Updating ${libraryName}...`);
422
+ await installLibrary(workspaceRoot, libraryName, { force: true });
423
+ logger.log("\n" + chalk4.bold("Next steps:"));
424
+ logger.log(` ${chalk4.gray("Review changes:")} git diff ./core/${libraryName.replace("animate-", "")}`);
425
+ logger.log(` ${chalk4.gray("Install updated dependencies:")} npm install`);
426
+ logger.log("");
427
+ } catch (error) {
428
+ logger.error(error.message);
429
+ process.exit(1);
430
+ }
431
+ });
432
+ }
433
+
400
434
  // src/index.ts
401
- var program = new Command4();
435
+ var program = new Command5();
402
436
  program.name("workspace-cli").description("Lightweight CLI for installing libraries into workspaces").version("0.1.0");
403
437
  program.addCommand(createInitCommand());
404
438
  program.addCommand(createListCommand());
405
439
  program.addCommand(createAddCommand());
440
+ program.addCommand(createUpdateCommand());
406
441
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspects-ai/workspace-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "Lightweight CLI for installing libraries into workspaces",
6
6
  "type": "module",
@@ -33,4 +33,4 @@
33
33
  "engines": {
34
34
  "node": ">=18.0.0"
35
35
  }
36
- }
36
+ }