@jonit-dev/night-watch-cli 1.7.83 → 1.7.84
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/dist/cli.js +46 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4792,13 +4792,52 @@ var init_prd_utils = __esm({
|
|
|
4792
4792
|
import * as fs12 from "fs";
|
|
4793
4793
|
import * as os5 from "os";
|
|
4794
4794
|
import * as path11 from "path";
|
|
4795
|
+
function readLegacyRegistryEntries() {
|
|
4796
|
+
const registryPath = getRegistryPath();
|
|
4797
|
+
if (!fs12.existsSync(registryPath)) {
|
|
4798
|
+
return [];
|
|
4799
|
+
}
|
|
4800
|
+
try {
|
|
4801
|
+
const raw = fs12.readFileSync(registryPath, "utf-8");
|
|
4802
|
+
const parsed = JSON.parse(raw);
|
|
4803
|
+
if (!Array.isArray(parsed)) {
|
|
4804
|
+
return [];
|
|
4805
|
+
}
|
|
4806
|
+
return parsed.filter((entry) => typeof entry === "object" && entry !== null && typeof entry.name === "string" && entry.name.length > 0 && typeof entry.path === "string" && entry.path.length > 0);
|
|
4807
|
+
} catch {
|
|
4808
|
+
return [];
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
function loadRegistryEntriesWithLegacyFallback() {
|
|
4812
|
+
const { projectRegistry } = getRepositories();
|
|
4813
|
+
const entries = projectRegistry.getAll();
|
|
4814
|
+
if (entries.length > 0) {
|
|
4815
|
+
return entries;
|
|
4816
|
+
}
|
|
4817
|
+
const db = getDb();
|
|
4818
|
+
const alreadyHydrated = db.prepare("SELECT value FROM schema_meta WHERE key = 'legacy_projects_json_hydrated'").get();
|
|
4819
|
+
if (alreadyHydrated) {
|
|
4820
|
+
return [];
|
|
4821
|
+
}
|
|
4822
|
+
const legacyEntries = readLegacyRegistryEntries();
|
|
4823
|
+
if (legacyEntries.length === 0) {
|
|
4824
|
+
return [];
|
|
4825
|
+
}
|
|
4826
|
+
db.transaction(() => {
|
|
4827
|
+
for (const entry of legacyEntries) {
|
|
4828
|
+
projectRegistry.upsert(entry);
|
|
4829
|
+
}
|
|
4830
|
+
db.prepare(`INSERT INTO schema_meta (key, value) VALUES ('legacy_projects_json_hydrated', ?)
|
|
4831
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value`).run((/* @__PURE__ */ new Date()).toISOString());
|
|
4832
|
+
})();
|
|
4833
|
+
return projectRegistry.getAll();
|
|
4834
|
+
}
|
|
4795
4835
|
function getRegistryPath() {
|
|
4796
4836
|
const base = process.env.NIGHT_WATCH_HOME || path11.join(os5.homedir(), GLOBAL_CONFIG_DIR);
|
|
4797
4837
|
return path11.join(base, REGISTRY_FILE_NAME);
|
|
4798
4838
|
}
|
|
4799
4839
|
function loadRegistry() {
|
|
4800
|
-
|
|
4801
|
-
return projectRegistry.getAll();
|
|
4840
|
+
return loadRegistryEntriesWithLegacyFallback();
|
|
4802
4841
|
}
|
|
4803
4842
|
function saveRegistry(entries) {
|
|
4804
4843
|
const { projectRegistry } = getRepositories();
|
|
@@ -4810,7 +4849,7 @@ function saveRegistry(entries) {
|
|
|
4810
4849
|
function registerProject(projectDir) {
|
|
4811
4850
|
const resolvedPath = path11.resolve(projectDir);
|
|
4812
4851
|
const { projectRegistry } = getRepositories();
|
|
4813
|
-
const entries =
|
|
4852
|
+
const entries = loadRegistryEntriesWithLegacyFallback();
|
|
4814
4853
|
const existing = entries.find((e) => e.path === resolvedPath);
|
|
4815
4854
|
if (existing) {
|
|
4816
4855
|
return existing;
|
|
@@ -4824,6 +4863,7 @@ function registerProject(projectDir) {
|
|
|
4824
4863
|
}
|
|
4825
4864
|
function unregisterProject(projectDir) {
|
|
4826
4865
|
const resolvedPath = path11.resolve(projectDir);
|
|
4866
|
+
loadRegistryEntriesWithLegacyFallback();
|
|
4827
4867
|
const { projectRegistry } = getRepositories();
|
|
4828
4868
|
return projectRegistry.remove(resolvedPath);
|
|
4829
4869
|
}
|
|
@@ -4846,6 +4886,7 @@ var init_registry = __esm({
|
|
|
4846
4886
|
init_constants();
|
|
4847
4887
|
init_repositories();
|
|
4848
4888
|
init_client();
|
|
4889
|
+
init_client();
|
|
4849
4890
|
init_status_data();
|
|
4850
4891
|
}
|
|
4851
4892
|
});
|
|
@@ -7026,7 +7067,7 @@ var init_dist = __esm({
|
|
|
7026
7067
|
// src/cli.ts
|
|
7027
7068
|
import "reflect-metadata";
|
|
7028
7069
|
import { Command as Command3 } from "commander";
|
|
7029
|
-
import { existsSync as existsSync29, readFileSync as
|
|
7070
|
+
import { existsSync as existsSync29, readFileSync as readFileSync18 } from "fs";
|
|
7030
7071
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
7031
7072
|
import { dirname as dirname8, join as join34 } from "path";
|
|
7032
7073
|
|
|
@@ -15335,7 +15376,7 @@ function findPackageRoot(dir) {
|
|
|
15335
15376
|
return dir;
|
|
15336
15377
|
}
|
|
15337
15378
|
var packageRoot = findPackageRoot(__dirname4);
|
|
15338
|
-
var packageJson = JSON.parse(
|
|
15379
|
+
var packageJson = JSON.parse(readFileSync18(join34(packageRoot, "package.json"), "utf-8"));
|
|
15339
15380
|
var program = new Command3();
|
|
15340
15381
|
program.name("night-watch").description("Autonomous PRD execution using Claude CLI + cron").version(packageJson.version);
|
|
15341
15382
|
initCommand(program);
|