@decantr/cli 2.8.0 → 2.8.1

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.
@@ -0,0 +1,78 @@
1
+ // src/workspace.ts
2
+ import { existsSync, readdirSync, readFileSync } from "fs";
3
+ import { dirname, join, resolve } from "path";
4
+ function readPackageJson(dir) {
5
+ const path = join(dir, "package.json");
6
+ if (!existsSync(path)) return null;
7
+ try {
8
+ return JSON.parse(readFileSync(path, "utf-8"));
9
+ } catch {
10
+ return null;
11
+ }
12
+ }
13
+ function hasWorkspaceMarker(dir) {
14
+ if (existsSync(join(dir, "pnpm-workspace.yaml")) || existsSync(join(dir, "turbo.json")) || existsSync(join(dir, "nx.json"))) {
15
+ return true;
16
+ }
17
+ const pkg = readPackageJson(dir);
18
+ return Boolean(pkg?.workspaces);
19
+ }
20
+ function findWorkspaceRoot(startDir) {
21
+ let current = resolve(startDir);
22
+ while (true) {
23
+ if (hasWorkspaceMarker(current)) return current;
24
+ const parent = dirname(current);
25
+ if (parent === current) return null;
26
+ current = parent;
27
+ }
28
+ }
29
+ function looksLikeApp(dir, options = {}) {
30
+ const allowSourceDirs = options.allowSourceDirs ?? true;
31
+ if (existsSync(join(dir, "next.config.js")) || existsSync(join(dir, "next.config.ts")) || existsSync(join(dir, "next.config.mjs")) || existsSync(join(dir, "vite.config.ts")) || existsSync(join(dir, "vite.config.js")) || existsSync(join(dir, "angular.json")) || existsSync(join(dir, "svelte.config.js")) || existsSync(join(dir, "svelte.config.ts")) || existsSync(join(dir, "astro.config.mjs")) || allowSourceDirs && (existsSync(join(dir, "src")) || existsSync(join(dir, "app")) || existsSync(join(dir, "pages")))) {
32
+ return true;
33
+ }
34
+ const pkg = readPackageJson(dir);
35
+ const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
36
+ return Boolean(
37
+ deps.react || deps.next || deps.vue || deps.svelte || deps["@angular/core"] || deps.astro || deps.nuxt
38
+ );
39
+ }
40
+ function listWorkspaceApps(workspaceRoot) {
41
+ const candidates = [];
42
+ for (const base of ["apps", "packages"]) {
43
+ const baseDir = join(workspaceRoot, base);
44
+ if (!existsSync(baseDir)) continue;
45
+ for (const entry of readdirSync(baseDir, { withFileTypes: true })) {
46
+ if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
47
+ const candidate = join(baseDir, entry.name);
48
+ if (looksLikeApp(candidate, { allowSourceDirs: base === "apps" })) {
49
+ candidates.push(`${base}/${entry.name}`);
50
+ }
51
+ }
52
+ }
53
+ return candidates.sort();
54
+ }
55
+ function listWorkspaceAppCandidates(workspaceRoot) {
56
+ return listWorkspaceApps(resolve(workspaceRoot));
57
+ }
58
+ function resolveWorkspaceInfo(cwd, projectArg) {
59
+ const absoluteCwd = resolve(cwd);
60
+ const workspaceRoot = findWorkspaceRoot(absoluteCwd) ?? absoluteCwd;
61
+ const appRoot = projectArg ? resolve(absoluteCwd, projectArg) : absoluteCwd;
62
+ const appCandidates = listWorkspaceApps(workspaceRoot);
63
+ const projectScope = workspaceRoot !== appRoot || appCandidates.length > 0 ? "workspace-app" : "single-app";
64
+ const requiresProjectSelection = !projectArg && workspaceRoot === absoluteCwd && appCandidates.length > 0;
65
+ return {
66
+ cwd: absoluteCwd,
67
+ workspaceRoot,
68
+ appRoot,
69
+ projectScope,
70
+ appCandidates,
71
+ requiresProjectSelection
72
+ };
73
+ }
74
+
75
+ export {
76
+ listWorkspaceAppCandidates,
77
+ resolveWorkspaceInfo
78
+ };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import "./chunk-QTPNV5WU.js";
1
+ import "./chunk-RKZMHS2K.js";
2
2
  import "./chunk-V3XAQWKD.js";
3
+ import "./chunk-VE6N3XWG.js";
3
4
  import "./chunk-KT2ROK2D.js";
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  createWorkspaceHealthReport
3
- } from "./chunk-ICSLIYSX.js";
3
+ } from "./chunk-FV6DGYD7.js";
4
+ import "./chunk-VE6N3XWG.js";
4
5
  import {
5
6
  createProjectHealthReport
6
7
  } from "./chunk-PAF4PBD3.js";
@@ -3,10 +3,12 @@ import {
3
3
  createWorkspaceHealthReport,
4
4
  formatWorkspaceHealthMarkdown,
5
5
  formatWorkspaceHealthText,
6
+ listWorkspaceCandidates,
6
7
  listWorkspaceProjects,
7
8
  parseWorkspaceArgs,
8
9
  shouldFailWorkspaceHealth
9
- } from "./chunk-ICSLIYSX.js";
10
+ } from "./chunk-FV6DGYD7.js";
11
+ import "./chunk-VE6N3XWG.js";
10
12
  import "./chunk-PAF4PBD3.js";
11
13
  import "./chunk-3TH5PLFO.js";
12
14
  import "./chunk-KT2ROK2D.js";
@@ -15,6 +17,7 @@ export {
15
17
  createWorkspaceHealthReport,
16
18
  formatWorkspaceHealthMarkdown,
17
19
  formatWorkspaceHealthText,
20
+ listWorkspaceCandidates,
18
21
  listWorkspaceProjects,
19
22
  parseWorkspaceArgs,
20
23
  shouldFailWorkspaceHealth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decantr/cli",
3
- "version": "2.8.0",
3
+ "version": "2.8.1",
4
4
  "description": "Decantr CLI - scaffold, audit, inspect Project Health, and maintain Decantr projects from the terminal",
5
5
  "keywords": [
6
6
  "decantr",
@@ -49,10 +49,10 @@
49
49
  "dependencies": {
50
50
  "ajv": "^8.20.0",
51
51
  "@decantr/core": "2.1.0",
52
- "@decantr/registry": "2.2.0",
53
- "@decantr/verifier": "2.2.0",
54
52
  "@decantr/essence-spec": "2.0.1",
55
- "@decantr/telemetry": "2.2.1"
53
+ "@decantr/telemetry": "2.2.1",
54
+ "@decantr/verifier": "2.2.0",
55
+ "@decantr/registry": "2.2.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",