mdboard 1.1.0 → 1.2.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.js CHANGED
@@ -3,11 +3,14 @@
3
3
  const path = require('path');
4
4
  const args = process.argv.slice(2);
5
5
 
6
- // Pre-process --config flag before dispatching commands
6
+ // Pre-process --config and --workspace flags before dispatching commands
7
7
  for (let i = 0; i < args.length; i++) {
8
8
  if (args[i] === '--config' && args[i + 1]) {
9
9
  process.env.MDBOARD_CONFIG = path.resolve(args[i + 1]);
10
10
  }
11
+ if (args[i] === '--workspace' && args[i + 1]) {
12
+ process.env.MDBOARD_WORKSPACE = path.resolve(args[i + 1]);
13
+ }
11
14
  }
12
15
 
13
16
  const command = args[0];
@@ -28,11 +31,45 @@ if (command === 'init') {
28
31
  } else if (command === 'help') {
29
32
  printHelp();
30
33
  process.exit(0);
34
+ } else if (command === 'cache') {
35
+ handleCache();
31
36
  } else {
32
37
  // Default: start server. Pass all args through.
33
38
  require('./server.js');
34
39
  }
35
40
 
41
+ function handleCache() {
42
+ const subCmd = args[1];
43
+ const { listCache, cleanCache, CACHE_DIR } = require('./workspace');
44
+
45
+ if (subCmd === 'list') {
46
+ const entries = listCache();
47
+ if (entries.length === 0) {
48
+ console.log('\n No cached remote repos.\n Cache dir: ' + CACHE_DIR + '\n');
49
+ } else {
50
+ console.log('\n Cached remote repos (' + CACHE_DIR + '):\n');
51
+ entries.forEach(function(e) { console.log(' ' + e); });
52
+ console.log('');
53
+ }
54
+ } else if (subCmd === 'clean') {
55
+ const ok = cleanCache();
56
+ if (ok) {
57
+ console.log('\n Cache cleaned successfully.\n');
58
+ } else {
59
+ console.log('\n No cache to clean or error occurred.\n');
60
+ }
61
+ } else {
62
+ console.log(`
63
+ mdboard cache — Manage remote source cache
64
+
65
+ Subcommands:
66
+ mdboard cache list List cached remote repos
67
+ mdboard cache clean Remove all cached repos
68
+ `);
69
+ }
70
+ process.exit(0);
71
+ }
72
+
36
73
  function printHelp() {
37
74
  console.log(`
38
75
  mdboard — Git-based project management dashboard
@@ -40,6 +77,7 @@ function printHelp() {
40
77
  Usage:
41
78
  mdboard Start the dashboard server
42
79
  mdboard init Scaffold a new project/ directory
80
+ mdboard cache list|clean Manage remote source cache
43
81
  mdboard --version Print version
44
82
  mdboard --help Show this help
45
83
 
@@ -47,11 +85,18 @@ function printHelp() {
47
85
  --project <path> Workspace root directory (default: cwd)
48
86
  --port <number> Server port (default: 3333)
49
87
  --config <path> Path to mdboard.json config file
88
+ --workspace <path> Path to workspace.json
89
+
90
+ Multi-repo workspace:
91
+ Create a workspace.json in your project root to manage
92
+ multiple repositories from a single dashboard.
50
93
 
51
94
  Examples:
52
95
  npx mdboard Start dashboard in current directory
53
96
  npx mdboard init Create project/ with templates
54
97
  npx mdboard --port 4000 Start on port 4000
55
- npx mdboard --config ./my-config.json
98
+ npx mdboard --workspace ./workspace.json
99
+ npx mdboard cache list Show cached remote repos
100
+ npx mdboard cache clean Clear remote cache
56
101
  `);
57
102
  }
package/config.js CHANGED
@@ -70,4 +70,4 @@ function loadConfig(projectDir, explicitPath) {
70
70
  return config;
71
71
  }
72
72
 
73
- module.exports = { loadConfig };
73
+ module.exports = { loadConfig, deepMerge };