@driftless-sh/cli 0.1.36 → 0.1.38
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 +55 -24
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -217,9 +217,22 @@ var require_identity = __commonJS({
|
|
|
217
217
|
return "";
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
+
function findPackageJson(startPath) {
|
|
221
|
+
let dir = startPath;
|
|
222
|
+
for (let i = 0; i < 4; i++) {
|
|
223
|
+
const candidate = node_path_1.default.join(dir, "package.json");
|
|
224
|
+
if (node_fs_1.default.existsSync(candidate))
|
|
225
|
+
return candidate;
|
|
226
|
+
const parent = node_path_1.default.dirname(dir);
|
|
227
|
+
if (parent === dir)
|
|
228
|
+
break;
|
|
229
|
+
dir = parent;
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
220
233
|
function detectFramework(fileNames, rootPath, cache) {
|
|
221
|
-
const pkgPath =
|
|
222
|
-
const pkgContent = readFileCached(pkgPath, cache);
|
|
234
|
+
const pkgPath = findPackageJson(rootPath);
|
|
235
|
+
const pkgContent = pkgPath ? readFileCached(pkgPath, cache) : "";
|
|
223
236
|
if (pkgContent) {
|
|
224
237
|
try {
|
|
225
238
|
const pkg = JSON.parse(pkgContent);
|
|
@@ -213318,15 +213331,16 @@ var require_nestjs_extractor = __commonJS({
|
|
|
213318
213331
|
var typescript_1 = __importDefault(require_typescript());
|
|
213319
213332
|
function discoverFiles(rootPath) {
|
|
213320
213333
|
const files = [];
|
|
213321
|
-
const srcDir = node_path_1.default.join(rootPath, "src");
|
|
213334
|
+
const srcDir = node_fs_1.default.existsSync(node_path_1.default.join(rootPath, "src")) ? node_path_1.default.join(rootPath, "src") : rootPath;
|
|
213322
213335
|
if (!node_fs_1.default.existsSync(srcDir))
|
|
213323
213336
|
return files;
|
|
213337
|
+
const SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", ".next", "build", ".turbo", "coverage"]);
|
|
213324
213338
|
function walk(dir) {
|
|
213325
213339
|
const entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
213326
213340
|
for (const entry of entries) {
|
|
213327
213341
|
const full = node_path_1.default.join(dir, entry.name);
|
|
213328
213342
|
if (entry.isDirectory()) {
|
|
213329
|
-
if (
|
|
213343
|
+
if (SKIP.has(entry.name))
|
|
213330
213344
|
continue;
|
|
213331
213345
|
walk(full);
|
|
213332
213346
|
} else if (entry.isFile() && entry.name.endsWith(".ts") && !entry.name.endsWith(".d.ts") && !entry.name.endsWith(".spec.ts") && !entry.name.endsWith(".test.ts")) {
|
|
@@ -213590,7 +213604,7 @@ var require_nestjs_extractor = __commonJS({
|
|
|
213590
213604
|
function isInSourceDir(filePath) {
|
|
213591
213605
|
if (filePath.includes("node_modules") || filePath.includes("/dist/"))
|
|
213592
213606
|
return false;
|
|
213593
|
-
return filePath.startsWith("src/") || filePath.includes("/src/");
|
|
213607
|
+
return filePath.startsWith("src/") || filePath.includes("/src/") || !filePath.startsWith("..");
|
|
213594
213608
|
}
|
|
213595
213609
|
var HTTP_METHODS = {
|
|
213596
213610
|
Get: "GET",
|
|
@@ -214567,7 +214581,7 @@ async function installSkillCommand() {
|
|
|
214567
214581
|
// src/commands/init.ts
|
|
214568
214582
|
function getVersion() {
|
|
214569
214583
|
try {
|
|
214570
|
-
return "0.1.
|
|
214584
|
+
return "0.1.38";
|
|
214571
214585
|
} catch {
|
|
214572
214586
|
return "0.0.0";
|
|
214573
214587
|
}
|
|
@@ -216031,30 +216045,45 @@ init_api_client();
|
|
|
216031
216045
|
function notLinkedMessage(remote, workspaceSlug) {
|
|
216032
216046
|
return `Repo '${remote.org}/${remote.repo}' is not registered in workspace '${workspaceSlug}'. Run \`driftless init\` to register it.`;
|
|
216033
216047
|
}
|
|
216048
|
+
async function fetchRepos(slug) {
|
|
216049
|
+
try {
|
|
216050
|
+
const raw = await api.get(`/workspaces/${slug}/repos`);
|
|
216051
|
+
return Array.isArray(raw) ? raw : null;
|
|
216052
|
+
} catch {
|
|
216053
|
+
return null;
|
|
216054
|
+
}
|
|
216055
|
+
}
|
|
216034
216056
|
async function resolveRepo() {
|
|
216035
216057
|
const remote = getGitRemote();
|
|
216036
216058
|
if (!remote) return { ok: false, reason: "no_remote" };
|
|
216037
|
-
let
|
|
216059
|
+
let meSlug;
|
|
216038
216060
|
try {
|
|
216039
216061
|
const me = await api.get("/me");
|
|
216040
|
-
|
|
216062
|
+
meSlug = me?.slug;
|
|
216041
216063
|
} catch {
|
|
216042
216064
|
}
|
|
216043
|
-
|
|
216044
|
-
let
|
|
216045
|
-
|
|
216046
|
-
const repos = await
|
|
216047
|
-
|
|
216048
|
-
|
|
216065
|
+
const candidates = [...new Set([meSlug, remote.org].filter(Boolean))];
|
|
216066
|
+
let lastLinkedSlug;
|
|
216067
|
+
for (const slug of candidates) {
|
|
216068
|
+
const repos = await fetchRepos(slug);
|
|
216069
|
+
if (!repos) continue;
|
|
216070
|
+
const repo = repos.find((r) => r.github_org === remote.org && r.github_repo === remote.repo);
|
|
216071
|
+
if (repo) {
|
|
216072
|
+
return {
|
|
216073
|
+
ok: true,
|
|
216074
|
+
workspaceSlug: slug,
|
|
216075
|
+
repoId: repo.id,
|
|
216076
|
+
remote,
|
|
216077
|
+
hasScanBaseline: !!repo.scan_summary
|
|
216078
|
+
};
|
|
216079
|
+
}
|
|
216080
|
+
lastLinkedSlug = slug;
|
|
216049
216081
|
}
|
|
216050
|
-
if (
|
|
216051
|
-
|
|
216052
|
-
|
|
216053
|
-
|
|
216054
|
-
|
|
216055
|
-
remote,
|
|
216056
|
-
hasScanBaseline: !!repo.scan_summary
|
|
216057
|
-
};
|
|
216082
|
+
if (lastLinkedSlug) {
|
|
216083
|
+
return { ok: false, reason: "not_linked", workspaceSlug: lastLinkedSlug, remote };
|
|
216084
|
+
}
|
|
216085
|
+
const triedSlugs = candidates.join(", ");
|
|
216086
|
+
return { ok: false, reason: "no_workspace", remote, detail: `tried slugs: ${triedSlugs}` };
|
|
216058
216087
|
}
|
|
216059
216088
|
|
|
216060
216089
|
// src/commands/sync.ts
|
|
@@ -216084,7 +216113,9 @@ async function syncCommand(args) {
|
|
|
216084
216113
|
const isJSON = !!flags["json"];
|
|
216085
216114
|
const resolution = await resolveRepo();
|
|
216086
216115
|
if (!resolution.ok) {
|
|
216087
|
-
const
|
|
216116
|
+
const base = resolution.reason === "no_remote" ? "Error: no git remote configured." : resolution.reason === "no_workspace" ? "Error: could not resolve workspace." : notLinkedMessage(resolution.remote, resolution.workspaceSlug);
|
|
216117
|
+
const detail = resolution.reason === "no_workspace" && resolution.detail ? ` (${resolution.detail})` : "";
|
|
216118
|
+
const msg = base + detail;
|
|
216088
216119
|
if (!isJSON) {
|
|
216089
216120
|
console.log(`\u26A0 ${msg}`);
|
|
216090
216121
|
if (resolution.reason !== "no_remote") console.log(" Run `driftless doctor` to diagnose.");
|
|
@@ -216374,7 +216405,7 @@ function pad2(s, n) {
|
|
|
216374
216405
|
}
|
|
216375
216406
|
|
|
216376
216407
|
// src/index.ts
|
|
216377
|
-
var VERSION = "0.1.
|
|
216408
|
+
var VERSION = "0.1.38";
|
|
216378
216409
|
var HELP_TEXT = `Driftless CLI v${VERSION} \u2014 Living repo context for humans and coding agents
|
|
216379
216410
|
|
|
216380
216411
|
Install: npm install -g @driftless-sh/cli
|