@driftless-sh/cli 0.1.35 → 0.1.36
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/index.js +69 -65
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -214567,7 +214567,7 @@ async function installSkillCommand() {
|
|
|
214567
214567
|
// src/commands/init.ts
|
|
214568
214568
|
function getVersion() {
|
|
214569
214569
|
try {
|
|
214570
|
-
return "0.1.
|
|
214570
|
+
return "0.1.36";
|
|
214571
214571
|
} catch {
|
|
214572
214572
|
return "0.0.0";
|
|
214573
214573
|
}
|
|
@@ -214935,6 +214935,12 @@ async function initCommand(args) {
|
|
|
214935
214935
|
}
|
|
214936
214936
|
};
|
|
214937
214937
|
const components = scanResult.components;
|
|
214938
|
+
if (components.length === 0) {
|
|
214939
|
+
console.warn(`\u26A0 0 components found in ${srcOverride ? `--src ${srcOverride}` : "repo root"}.`);
|
|
214940
|
+
console.warn(" For NestJS monorepos, point --src at the app source root, not the package root.");
|
|
214941
|
+
console.warn(" Example: driftless init --src apps/api/src (not apps/api)");
|
|
214942
|
+
console.warn(" Continuing with baseline upload \u2014 no components or relations will be registered.");
|
|
214943
|
+
}
|
|
214938
214944
|
const relationCount = components.reduce(
|
|
214939
214945
|
(sum, component) => sum + (component.relations?.length || 0),
|
|
214940
214946
|
0
|
|
@@ -215536,13 +215542,17 @@ async function contextCommand(args) {
|
|
|
215536
215542
|
}
|
|
215537
215543
|
}
|
|
215538
215544
|
const pattern = flags["pattern"];
|
|
215539
|
-
if (pattern
|
|
215545
|
+
if (pattern) {
|
|
215540
215546
|
if (pattern.includes(",")) {
|
|
215541
|
-
console.error(`
|
|
215547
|
+
console.error(`Error: pattern "${pattern}" contains a comma. Only one glob is accepted per topic.`);
|
|
215548
|
+
console.error(" Create separate topics for each path, or use a broader glob.");
|
|
215549
|
+
process.exit(1);
|
|
215542
215550
|
}
|
|
215543
215551
|
const localCount = countLocalFilesMatching(pattern);
|
|
215544
215552
|
if (localCount === 0) {
|
|
215545
|
-
console.error(`
|
|
215553
|
+
console.error(`Error: pattern "${pattern}" matches 0 files locally. Topic not created.`);
|
|
215554
|
+
console.error(" Verify the glob against your repo root, or use --where for explicit file paths.");
|
|
215555
|
+
process.exit(1);
|
|
215546
215556
|
}
|
|
215547
215557
|
}
|
|
215548
215558
|
try {
|
|
@@ -216015,6 +216025,39 @@ Run 'driftless help context' for full reference.`);
|
|
|
216015
216025
|
|
|
216016
216026
|
// src/commands/sync.ts
|
|
216017
216027
|
init_api_client();
|
|
216028
|
+
|
|
216029
|
+
// src/repo-resolver.ts
|
|
216030
|
+
init_api_client();
|
|
216031
|
+
function notLinkedMessage(remote, workspaceSlug) {
|
|
216032
|
+
return `Repo '${remote.org}/${remote.repo}' is not registered in workspace '${workspaceSlug}'. Run \`driftless init\` to register it.`;
|
|
216033
|
+
}
|
|
216034
|
+
async function resolveRepo() {
|
|
216035
|
+
const remote = getGitRemote();
|
|
216036
|
+
if (!remote) return { ok: false, reason: "no_remote" };
|
|
216037
|
+
let workspaceSlug;
|
|
216038
|
+
try {
|
|
216039
|
+
const me = await api.get("/me");
|
|
216040
|
+
workspaceSlug = me?.slug;
|
|
216041
|
+
} catch {
|
|
216042
|
+
}
|
|
216043
|
+
if (!workspaceSlug) return { ok: false, reason: "no_workspace", remote };
|
|
216044
|
+
let repo;
|
|
216045
|
+
try {
|
|
216046
|
+
const repos = await api.get(`/workspaces/${workspaceSlug}/repos`);
|
|
216047
|
+
repo = repos.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
|
|
216048
|
+
} catch {
|
|
216049
|
+
}
|
|
216050
|
+
if (!repo) return { ok: false, reason: "not_linked", workspaceSlug, remote };
|
|
216051
|
+
return {
|
|
216052
|
+
ok: true,
|
|
216053
|
+
workspaceSlug,
|
|
216054
|
+
repoId: repo.id,
|
|
216055
|
+
remote,
|
|
216056
|
+
hasScanBaseline: !!repo.scan_summary
|
|
216057
|
+
};
|
|
216058
|
+
}
|
|
216059
|
+
|
|
216060
|
+
// src/commands/sync.ts
|
|
216018
216061
|
function parseArgs2(args) {
|
|
216019
216062
|
const flags = {};
|
|
216020
216063
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -216032,19 +216075,6 @@ function parseArgs2(args) {
|
|
|
216032
216075
|
function emitJSON3(data) {
|
|
216033
216076
|
console.log(JSON.stringify(data, null, 2));
|
|
216034
216077
|
}
|
|
216035
|
-
async function resolveWorkspaceSlug2() {
|
|
216036
|
-
try {
|
|
216037
|
-
const me = await api.get("/me");
|
|
216038
|
-
if (me?.slug) return me.slug;
|
|
216039
|
-
} catch {
|
|
216040
|
-
}
|
|
216041
|
-
const remote = getGitRemote();
|
|
216042
|
-
if (!remote) {
|
|
216043
|
-
console.error("Error: no git remote found.");
|
|
216044
|
-
process.exit(1);
|
|
216045
|
-
}
|
|
216046
|
-
return remote.org;
|
|
216047
|
-
}
|
|
216048
216078
|
async function syncCommand(args) {
|
|
216049
216079
|
if (!isGitRepo()) {
|
|
216050
216080
|
console.error("Error: not a git repository.");
|
|
@@ -216052,28 +216082,18 @@ async function syncCommand(args) {
|
|
|
216052
216082
|
}
|
|
216053
216083
|
const { flags } = parseArgs2(args);
|
|
216054
216084
|
const isJSON = !!flags["json"];
|
|
216055
|
-
const
|
|
216056
|
-
if (!
|
|
216057
|
-
|
|
216058
|
-
process.exit(1);
|
|
216059
|
-
}
|
|
216060
|
-
const workspaceSlug = await resolveWorkspaceSlug2();
|
|
216061
|
-
let repoId = null;
|
|
216062
|
-
try {
|
|
216063
|
-
const repos = await api.get(`/workspaces/${workspaceSlug}/repos`);
|
|
216064
|
-
const match = repos.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
|
|
216065
|
-
if (match) repoId = match.id;
|
|
216066
|
-
} catch {
|
|
216067
|
-
}
|
|
216068
|
-
if (!repoId) {
|
|
216085
|
+
const resolution = await resolveRepo();
|
|
216086
|
+
if (!resolution.ok) {
|
|
216087
|
+
const msg = resolution.reason === "no_remote" ? "Error: no git remote configured." : resolution.reason === "no_workspace" ? "Error: could not resolve workspace. Run `driftless doctor` to diagnose." : notLinkedMessage(resolution.remote, resolution.workspaceSlug);
|
|
216069
216088
|
if (!isJSON) {
|
|
216070
|
-
console.log(`\u26A0
|
|
216071
|
-
console.log(" Run `driftless
|
|
216089
|
+
console.log(`\u26A0 ${msg}`);
|
|
216090
|
+
if (resolution.reason !== "no_remote") console.log(" Run `driftless doctor` to diagnose.");
|
|
216072
216091
|
} else {
|
|
216073
|
-
emitJSON3({ error:
|
|
216092
|
+
emitJSON3({ error: resolution.reason, message: msg });
|
|
216074
216093
|
}
|
|
216075
216094
|
process.exit(1);
|
|
216076
216095
|
}
|
|
216096
|
+
const { workspaceSlug, repoId, remote } = resolution;
|
|
216077
216097
|
const [eventsRes, staleTopics, violations, suggestedTopics] = await Promise.allSettled([
|
|
216078
216098
|
api.get(`/workspaces/${workspaceSlug}/watchers/events?repo_id=${repoId}&limit=20`),
|
|
216079
216099
|
api.get(`/workspaces/${workspaceSlug}/watchers?stale=true&repo=${repoId}`),
|
|
@@ -216273,38 +216293,22 @@ async function doctorCommand() {
|
|
|
216273
216293
|
} else {
|
|
216274
216294
|
checks.push({ name: "Workspace", status: "warn", detail: "Skipped (local API or no key)" });
|
|
216275
216295
|
}
|
|
216276
|
-
|
|
216277
|
-
|
|
216278
|
-
|
|
216279
|
-
|
|
216280
|
-
|
|
216281
|
-
|
|
216282
|
-
|
|
216283
|
-
|
|
216284
|
-
|
|
216285
|
-
|
|
216286
|
-
|
|
216287
|
-
|
|
216288
|
-
}
|
|
216296
|
+
const resolution = await resolveRepo();
|
|
216297
|
+
if (resolution.ok) {
|
|
216298
|
+
checks.push({ name: "Repo linked", status: "ok", detail: `${resolution.remote.org}/${resolution.remote.repo}` });
|
|
216299
|
+
checks.push({
|
|
216300
|
+
name: "Baseline",
|
|
216301
|
+
status: resolution.hasScanBaseline ? "ok" : "warn",
|
|
216302
|
+
detail: resolution.hasScanBaseline ? "Scan data present" : "No scan baseline. Run `driftless init`"
|
|
216303
|
+
});
|
|
216304
|
+
} else if (resolution.reason === "not_linked") {
|
|
216305
|
+
checks.push({ name: "Repo linked", status: "warn", detail: notLinkedMessage(resolution.remote, resolution.workspaceSlug) });
|
|
216306
|
+
checks.push({ name: "Baseline", status: "warn", detail: "Could not verify (repo not registered)" });
|
|
216307
|
+
} else if (resolution.reason === "no_workspace") {
|
|
216308
|
+
checks.push({ name: "Repo linked", status: "warn", detail: "Could not verify (workspace unknown)" });
|
|
216309
|
+
checks.push({ name: "Baseline", status: "warn", detail: "Could not verify (workspace unknown)" });
|
|
216289
216310
|
} else {
|
|
216290
216311
|
checks.push({ name: "Repo linked", status: "warn", detail: "Skipped (no git remote)" });
|
|
216291
|
-
}
|
|
216292
|
-
if (remote) {
|
|
216293
|
-
const me = await getMe();
|
|
216294
|
-
if (me?.slug) {
|
|
216295
|
-
const repos = await getRepos(me.slug);
|
|
216296
|
-
const linked = repos?.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
|
|
216297
|
-
if (linked?.scan_summary) {
|
|
216298
|
-
checks.push({ name: "Baseline", status: "ok", detail: "Scan data present" });
|
|
216299
|
-
} else if (linked) {
|
|
216300
|
-
checks.push({ name: "Baseline", status: "warn", detail: "Repo connected but no scan baseline. Run `driftless init`" });
|
|
216301
|
-
} else {
|
|
216302
|
-
checks.push({ name: "Baseline", status: "warn", detail: "Could not verify" });
|
|
216303
|
-
}
|
|
216304
|
-
} else {
|
|
216305
|
-
checks.push({ name: "Baseline", status: "warn", detail: "Could not verify" });
|
|
216306
|
-
}
|
|
216307
|
-
} else {
|
|
216308
216312
|
checks.push({ name: "Baseline", status: "warn", detail: "Skipped (no git remote)" });
|
|
216309
216313
|
}
|
|
216310
216314
|
const agentsPath = (0, import_node_path7.resolve)(process.cwd(), "AGENTS.md");
|
|
@@ -216370,7 +216374,7 @@ function pad2(s, n) {
|
|
|
216370
216374
|
}
|
|
216371
216375
|
|
|
216372
216376
|
// src/index.ts
|
|
216373
|
-
var VERSION = "0.1.
|
|
216377
|
+
var VERSION = "0.1.36";
|
|
216374
216378
|
var HELP_TEXT = `Driftless CLI v${VERSION} \u2014 Living repo context for humans and coding agents
|
|
216375
216379
|
|
|
216376
216380
|
Install: npm install -g @driftless-sh/cli
|