docstar-cli 1.1.0 → 1.2.1-beta.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.
package/bin/run.js CHANGED
@@ -1,5 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import {execute} from '@oclif/core'
4
+ import {readFileSync} from 'node:fs'
5
+
6
+ // oclif's built-in --version prints `docstar-cli/1.2.0 darwin-arm64 node-v22.22.3`. We only want
7
+ // the bare version number, so intercept it here before oclif ever sees the flag.
8
+ const args = process.argv.slice(2)
9
+ if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) {
10
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
11
+ console.log(pkg.version)
12
+ process.exit(0)
13
+ }
4
14
 
5
15
  await execute({dir: import.meta.url})
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Clean extends Command {
3
+ static args: {
4
+ collection: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,88 @@
1
+ import { checkbox, confirm } from '@inquirer/prompts';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
+ import { readFile, rm, writeFile } from 'node:fs/promises';
4
+ import { join } from 'node:path';
5
+ import { collectionModulesDir, configPath, modulePath } from '../lib/paths.js';
6
+ export default class Clean extends Command {
7
+ static args = {
8
+ collection: Args.string({ description: 'The collection (CLI name) to clean up, e.g. msg91', required: true }),
9
+ };
10
+ static description = [
11
+ 'Uninstall modules from a collection, or the entire collection.',
12
+ 'By default shows a checklist of the collection\'s installed modules to remove.',
13
+ '`--all` targets the whole collection instead; combine with `--force` to skip the confirmation prompt.',
14
+ ].join('\n');
15
+ static examples = [
16
+ '<%= config.bin %> <%= command.id %> msg91 # pick modules to remove from "msg91"',
17
+ '<%= config.bin %> <%= command.id %> msg91 --all # remove the whole "msg91" collection (asks to confirm)',
18
+ '<%= config.bin %> <%= command.id %> msg91 --all --force # remove the whole "msg91" collection without asking',
19
+ ];
20
+ static flags = {
21
+ all: Flags.boolean({ description: 'Remove the entire collection instead of picking modules' }),
22
+ force: Flags.boolean({ description: 'Skip the confirmation prompt (only relevant with --all)' }),
23
+ };
24
+ async run() {
25
+ const { args, flags } = await this.parse(Clean);
26
+ let savedConfig;
27
+ try {
28
+ savedConfig = JSON.parse(await readFile(configPath(), 'utf8'));
29
+ }
30
+ catch {
31
+ this.error('No installed modules found. Run `docstar-cli init <domain>` first.');
32
+ }
33
+ const collection = savedConfig.collections.find((c) => c.cliName === args.collection);
34
+ if (!collection) {
35
+ this.error(`Collection "${args.collection}" isn't installed. Run \`docstar-cli list\` to see installed collections.`);
36
+ }
37
+ if (flags.all) {
38
+ if (!flags.force) {
39
+ const shouldDelete = await confirm({
40
+ default: false,
41
+ message: `Delete the entire "${collection.cliName}" collection and all ${collection.modules.length} installed module(s)?`,
42
+ });
43
+ if (!shouldDelete) {
44
+ this.log('Aborted, nothing was removed.');
45
+ return;
46
+ }
47
+ }
48
+ await rm(collectionModulesDir(collection.cliName), { force: true, recursive: true });
49
+ await rm(join(this.config.root, 'dist', 'commands', collection.cliName), { force: true, recursive: true });
50
+ savedConfig.collections = savedConfig.collections.filter((c) => c.cliName !== collection.cliName);
51
+ await writeFile(configPath(), JSON.stringify(savedConfig, null, 2));
52
+ this.log(`Removed collection "${collection.cliName}" and its ${collection.modules.length} module(s).`);
53
+ return;
54
+ }
55
+ if (collection.modules.length === 0) {
56
+ this.log(`Collection "${collection.cliName}" has no installed modules.`);
57
+ return;
58
+ }
59
+ const SELECT_ALL = '__select_all__';
60
+ const rawSelection = await checkbox({
61
+ choices: [
62
+ ...collection.modules.map((module) => ({ checked: false, name: `${module.name} (${module.path})`, value: module.path })),
63
+ { checked: false, name: '➤ Select all modules', value: SELECT_ALL },
64
+ ],
65
+ message: `Select modules to remove from "${collection.cliName}" (space to toggle, enter to confirm)`,
66
+ });
67
+ const selectedPaths = rawSelection.includes(SELECT_ALL) ? collection.modules.map((module) => module.path) : rawSelection;
68
+ if (selectedPaths.length === 0) {
69
+ this.log('No modules selected, nothing removed.');
70
+ return;
71
+ }
72
+ for (const path of selectedPaths) {
73
+ // eslint-disable-next-line no-await-in-loop
74
+ await rm(modulePath(collection.cliName, path), { force: true });
75
+ // eslint-disable-next-line no-await-in-loop
76
+ await rm(join(this.config.root, 'dist', 'commands', collection.cliName, path), { force: true, recursive: true });
77
+ this.log(` removed: ${collection.cliName} ${path}`);
78
+ }
79
+ collection.modules = collection.modules.filter((module) => !selectedPaths.includes(module.path));
80
+ if (collection.modules.length === 0) {
81
+ await rm(collectionModulesDir(collection.cliName), { force: true, recursive: true });
82
+ savedConfig.collections = savedConfig.collections.filter((c) => c.cliName !== collection.cliName);
83
+ this.log(`Collection "${collection.cliName}" has no modules left, removed it entirely.`);
84
+ }
85
+ await writeFile(configPath(), JSON.stringify(savedConfig, null, 2));
86
+ this.log(`Removed ${selectedPaths.length} module(s) from "${collection.cliName}".`);
87
+ }
88
+ }
@@ -1,5 +1,49 @@
1
1
  {
2
2
  "commands": {
3
+ "clean": {
4
+ "aliases": [],
5
+ "args": {
6
+ "collection": {
7
+ "description": "The collection (CLI name) to clean up, e.g. msg91",
8
+ "name": "collection",
9
+ "required": true
10
+ }
11
+ },
12
+ "description": "Uninstall modules from a collection, or the entire collection.\nBy default shows a checklist of the collection's installed modules to remove.\n`--all` targets the whole collection instead; combine with `--force` to skip the confirmation prompt.",
13
+ "examples": [
14
+ "<%= config.bin %> <%= command.id %> msg91 # pick modules to remove from \"msg91\"",
15
+ "<%= config.bin %> <%= command.id %> msg91 --all # remove the whole \"msg91\" collection (asks to confirm)",
16
+ "<%= config.bin %> <%= command.id %> msg91 --all --force # remove the whole \"msg91\" collection without asking"
17
+ ],
18
+ "flags": {
19
+ "all": {
20
+ "description": "Remove the entire collection instead of picking modules",
21
+ "name": "all",
22
+ "allowNo": false,
23
+ "type": "boolean"
24
+ },
25
+ "force": {
26
+ "description": "Skip the confirmation prompt (only relevant with --all)",
27
+ "name": "force",
28
+ "allowNo": false,
29
+ "type": "boolean"
30
+ }
31
+ },
32
+ "hasDynamicHelp": false,
33
+ "hiddenAliases": [],
34
+ "id": "clean",
35
+ "pluginAlias": "docstar-cli",
36
+ "pluginName": "docstar-cli",
37
+ "pluginType": "core",
38
+ "strict": true,
39
+ "enableJsonFlag": false,
40
+ "isESM": true,
41
+ "relativePath": [
42
+ "dist",
43
+ "commands",
44
+ "clean.js"
45
+ ]
46
+ },
3
47
  "complete": {
4
48
  "aliases": [],
5
49
  "args": {
@@ -160,5 +204,5 @@
160
204
  ]
161
205
  }
162
206
  },
163
- "version": "1.1.0"
207
+ "version": "1.2.1-beta.0"
164
208
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docstar-cli",
3
3
  "description": "Call published DocStar API endpoints directly from your terminal, or expose them as MCP tools for AI clients.",
4
- "version": "1.1.0",
4
+ "version": "1.2.1-beta.0",
5
5
  "author": "Swayam Maheshwari",
6
6
  "bin": {
7
7
  "docstar-cli": "./bin/run.js"
@@ -12,7 +12,6 @@
12
12
  "@modelcontextprotocol/sdk": "^1.30.0",
13
13
  "@oclif/core": "^4",
14
14
  "@oclif/plugin-help": "^6",
15
- "@oclif/plugin-plugins": "^5",
16
15
  "zod": "^4.4.3"
17
16
  },
18
17
  "devDependencies": {
@@ -52,13 +51,9 @@
52
51
  "dirname": "docstar-cli",
53
52
  "commands": "./dist/commands",
54
53
  "plugins": [
55
- "@oclif/plugin-help",
56
- "@oclif/plugin-plugins"
54
+ "@oclif/plugin-help"
57
55
  ],
58
- "topicSeparator": " ",
59
- "additionalVersionFlags": [
60
- "-v"
61
- ]
56
+ "topicSeparator": " "
62
57
  },
63
58
  "repository": "swayammaheshwari/docstar-cli",
64
59
  "scripts": {