@dafish/gogo-meta 1.6.0 → 1.7.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/README.md CHANGED
@@ -563,6 +563,25 @@ gogo npm run lint --if-present
563
563
 
564
564
  ---
565
565
 
566
+ ### `gogo validate`
567
+
568
+ Validate your configuration. This runs two checks:
569
+
570
+ 1. **Config files** — every `.gogo` / `.gogo.*` / `.looprc` file in the current
571
+ directory is parsed and checked against its schema.
572
+ 2. **Working copy** — each project declared in the resolved config must have a
573
+ matching directory on disk.
574
+
575
+ If a configured project directory is missing, validation fails with a hint:
576
+ run `gogo migrate` if the project was moved/renamed in the config, or
577
+ `gogo git update` to clone a project that has not been cloned yet.
578
+
579
+ ```bash
580
+ gogo validate
581
+ ```
582
+
583
+ ---
584
+
566
585
  ## Examples
567
586
 
568
587
  ### Setting Up a New Meta Repository
package/dist/cli.js CHANGED
@@ -1461,6 +1461,7 @@ function registerNpmCommands(program) {
1461
1461
  await runCommand2(script, options);
1462
1462
  });
1463
1463
  }
1464
+ var MISSING_DIRECTORY_HINT = "directory missing \u2014 run 'gogo migrate' if it moved, or 'gogo git update' to clone";
1464
1465
  function isGogoConfigFile(filename) {
1465
1466
  return filename === ".gogo" || filename.startsWith(".gogo.");
1466
1467
  }
@@ -1501,10 +1502,36 @@ async function validateCommand() {
1501
1502
  projectStatus(result.file, "error", result.error);
1502
1503
  }
1503
1504
  }
1504
- if (hasErrors) {
1505
+ const workingCopyHasErrors = await validateWorkingCopy(cwd);
1506
+ if (hasErrors || workingCopyHasErrors) {
1505
1507
  throw new Error("Validation failed");
1506
1508
  }
1507
1509
  }
1510
+ async function validateWorkingCopy(cwd) {
1511
+ let config;
1512
+ let metaDir;
1513
+ try {
1514
+ ({ config, metaDir } = await readMetaConfig(cwd));
1515
+ } catch {
1516
+ return false;
1517
+ }
1518
+ const projectPaths = Object.keys(config.projects);
1519
+ if (projectPaths.length === 0) {
1520
+ return false;
1521
+ }
1522
+ let hasErrors = false;
1523
+ for (const projectPath of projectPaths) {
1524
+ const projectDir = join(metaDir, projectPath);
1525
+ if (!await fileExists(projectDir)) {
1526
+ projectStatus(projectPath, "error", MISSING_DIRECTORY_HINT);
1527
+ hasErrors = true;
1528
+ }
1529
+ }
1530
+ if (!hasErrors) {
1531
+ success(`All ${projectPaths.length} project directories present`);
1532
+ }
1533
+ return hasErrors;
1534
+ }
1508
1535
  async function validateConfigFile(filePath, filename) {
1509
1536
  const format = detectFormat(filePath);
1510
1537
  try {
@@ -1542,7 +1569,7 @@ async function validateLoopRcFile(filePath) {
1542
1569
  }
1543
1570
  }
1544
1571
  function registerValidateCommand(program) {
1545
- program.command("validate").description("Validate all config files in the current directory").action(async () => {
1572
+ program.command("validate").description("Validate config files and check that configured projects exist in the working copy").action(async () => {
1546
1573
  await validateCommand();
1547
1574
  });
1548
1575
  }