@gurulu/cli 1.6.5 → 1.6.6

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/bin.js CHANGED
@@ -40223,7 +40223,7 @@ var pullCmd = defineCommand({
40223
40223
  });
40224
40224
 
40225
40225
  // src/lib/detect.ts
40226
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
40226
+ import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync4 } from "node:fs";
40227
40227
  import { dirname as dirname2, join as join5, parse } from "node:path";
40228
40228
  var COMPETITOR_DEP_MAP = {
40229
40229
  "posthog-js": "posthog",
@@ -40389,11 +40389,51 @@ function detectLlmFrameworks(pkg) {
40389
40389
  }
40390
40390
  return [...found];
40391
40391
  }
40392
+ function expandWorkspaceGlobs(rootDir, patterns) {
40393
+ const out = [];
40394
+ for (const pat of patterns) {
40395
+ if (pat.endsWith("/*")) {
40396
+ const base = join5(rootDir, pat.slice(0, -2));
40397
+ if (!existsSync4(base))
40398
+ continue;
40399
+ try {
40400
+ for (const name of readdirSync2(base)) {
40401
+ const d2 = join5(base, name);
40402
+ if (existsSync4(join5(d2, "package.json")))
40403
+ out.push(d2);
40404
+ }
40405
+ } catch {}
40406
+ } else {
40407
+ const d2 = join5(rootDir, pat);
40408
+ if (existsSync4(join5(d2, "package.json")))
40409
+ out.push(d2);
40410
+ }
40411
+ }
40412
+ return out;
40413
+ }
40414
+ function findWorkspaceFrameworkPackage(rootDir, pkg) {
40415
+ const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages ?? [];
40416
+ if (patterns.length === 0)
40417
+ return null;
40418
+ let fallback = null;
40419
+ for (const d2 of expandWorkspaceGlobs(rootDir, patterns)) {
40420
+ const p = readPackageJson(d2);
40421
+ if (!p)
40422
+ continue;
40423
+ const fw = detectFramework(p, d2);
40424
+ if (frameworkRuntime(fw) === "browser")
40425
+ return { dir: d2, framework: fw, pkg: p };
40426
+ if (fw !== "unknown" && !fallback)
40427
+ fallback = { dir: d2, framework: fw, pkg: p };
40428
+ }
40429
+ return fallback;
40430
+ }
40392
40431
  function detectProject(dir) {
40393
40432
  const pkg = readPackageJson(dir);
40394
40433
  let framework = detectFramework(pkg, dir);
40395
40434
  const { root, isMonorepo } = findWorkspaceRoot(dir);
40396
40435
  let effectivePkg = pkg;
40436
+ let appDir = dir;
40397
40437
  if (framework === "unknown" && isMonorepo && root !== dir) {
40398
40438
  const rootPkg = readPackageJson(root);
40399
40439
  const rootFw = detectFramework(rootPkg, root);
@@ -40402,19 +40442,28 @@ function detectProject(dir) {
40402
40442
  effectivePkg = pkg ?? rootPkg;
40403
40443
  }
40404
40444
  }
40445
+ if (framework === "unknown" && pkg?.workspaces) {
40446
+ const found = findWorkspaceFrameworkPackage(dir, pkg);
40447
+ if (found) {
40448
+ framework = found.framework;
40449
+ appDir = found.dir;
40450
+ effectivePkg = found.pkg;
40451
+ }
40452
+ }
40405
40453
  return {
40406
40454
  dir,
40407
40455
  hasPackageJson: pkg !== null,
40408
40456
  framework,
40409
40457
  runtime: frameworkRuntime(framework),
40410
40458
  packageManager: detectPackageManager(dir),
40411
- packageJson: pkg,
40412
- llmFrameworks: detectLlmFrameworks(pkg),
40459
+ packageJson: effectivePkg,
40460
+ llmFrameworks: detectLlmFrameworks(effectivePkg),
40413
40461
  moduleType: detectModuleType(effectivePkg),
40414
40462
  rootDir: root,
40463
+ appDir,
40415
40464
  isMonorepo,
40416
- competitors: detectCompetitors(pkg),
40417
- language: detectLanguage(dir)
40465
+ competitors: detectCompetitors(effectivePkg),
40466
+ language: detectLanguage(appDir)
40418
40467
  };
40419
40468
  }
40420
40469
 
@@ -41626,7 +41675,7 @@ function createCheckpoint(cwd, snapshots = new Map) {
41626
41675
  }
41627
41676
 
41628
41677
  // src/wizard/context.ts
41629
- import { readdirSync as readdirSync2, readFileSync as readFileSync9 } from "node:fs";
41678
+ import { readdirSync as readdirSync3, readFileSync as readFileSync9 } from "node:fs";
41630
41679
  import { extname as extname2, join as join10, relative as relative2 } from "node:path";
41631
41680
  var INCLUDE_EXT = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue", ".svelte", ".astro"]);
41632
41681
  var SECRET_PATTERNS = [
@@ -41709,7 +41758,7 @@ function collectCandidates(dir, base, depth, maxDepth, out) {
41709
41758
  return;
41710
41759
  let entries;
41711
41760
  try {
41712
- entries = readdirSync2(dir, { withFileTypes: true });
41761
+ entries = readdirSync3(dir, { withFileTypes: true });
41713
41762
  } catch {
41714
41763
  return;
41715
41764
  }
@@ -42381,6 +42430,10 @@ async function runWizard(opts) {
42381
42430
  const { workspaceId, writeKey } = await resolveWorkspace(client, auth.workspaceId, opts);
42382
42431
  phase(3, "Projeni tanıyoruz", "Kodun okunuyor; hangi kullanıcı olaylarını (ör. kayıt, satın alma) izleyeceğimiz planlanıyor.");
42383
42432
  const detected = detectProject(opts.cwd);
42433
+ if (detected.appDir !== opts.cwd) {
42434
+ p4.log.info(c3.dim(`Monorepo: kurulum ${detected.framework} app'ine → ${detected.appDir}`));
42435
+ opts.cwd = detected.appDir;
42436
+ }
42384
42437
  let framework = detected.framework;
42385
42438
  if (opts.framework && FRAMEWORKS.includes(opts.framework)) {
42386
42439
  framework = opts.framework;
@@ -43133,7 +43186,7 @@ var uninstallCmd = defineCommand({
43133
43186
  });
43134
43187
 
43135
43188
  // src/index.ts
43136
- var VERSION = "1.6.5";
43189
+ var VERSION = "1.6.6";
43137
43190
  var mainCmd = defineCommand({
43138
43191
  meta: {
43139
43192
  name: "gurulu",
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "1.6.5";
1
+ export declare const VERSION = "1.6.6";
2
2
  declare const mainCmd: import("citty").CommandDef<{
3
3
  workspace: {
4
4
  type: "string";
package/dist/index.js CHANGED
@@ -39800,7 +39800,7 @@ var pullCmd = defineCommand({
39800
39800
  });
39801
39801
 
39802
39802
  // src/lib/detect.ts
39803
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
39803
+ import { existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync4 } from "node:fs";
39804
39804
  import { dirname as dirname2, join as join5, parse } from "node:path";
39805
39805
  var COMPETITOR_DEP_MAP = {
39806
39806
  "posthog-js": "posthog",
@@ -39966,11 +39966,51 @@ function detectLlmFrameworks(pkg) {
39966
39966
  }
39967
39967
  return [...found];
39968
39968
  }
39969
+ function expandWorkspaceGlobs(rootDir, patterns) {
39970
+ const out = [];
39971
+ for (const pat of patterns) {
39972
+ if (pat.endsWith("/*")) {
39973
+ const base = join5(rootDir, pat.slice(0, -2));
39974
+ if (!existsSync4(base))
39975
+ continue;
39976
+ try {
39977
+ for (const name of readdirSync2(base)) {
39978
+ const d2 = join5(base, name);
39979
+ if (existsSync4(join5(d2, "package.json")))
39980
+ out.push(d2);
39981
+ }
39982
+ } catch {}
39983
+ } else {
39984
+ const d2 = join5(rootDir, pat);
39985
+ if (existsSync4(join5(d2, "package.json")))
39986
+ out.push(d2);
39987
+ }
39988
+ }
39989
+ return out;
39990
+ }
39991
+ function findWorkspaceFrameworkPackage(rootDir, pkg) {
39992
+ const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages ?? [];
39993
+ if (patterns.length === 0)
39994
+ return null;
39995
+ let fallback = null;
39996
+ for (const d2 of expandWorkspaceGlobs(rootDir, patterns)) {
39997
+ const p = readPackageJson(d2);
39998
+ if (!p)
39999
+ continue;
40000
+ const fw = detectFramework(p, d2);
40001
+ if (frameworkRuntime(fw) === "browser")
40002
+ return { dir: d2, framework: fw, pkg: p };
40003
+ if (fw !== "unknown" && !fallback)
40004
+ fallback = { dir: d2, framework: fw, pkg: p };
40005
+ }
40006
+ return fallback;
40007
+ }
39969
40008
  function detectProject(dir) {
39970
40009
  const pkg = readPackageJson(dir);
39971
40010
  let framework = detectFramework(pkg, dir);
39972
40011
  const { root, isMonorepo } = findWorkspaceRoot(dir);
39973
40012
  let effectivePkg = pkg;
40013
+ let appDir = dir;
39974
40014
  if (framework === "unknown" && isMonorepo && root !== dir) {
39975
40015
  const rootPkg = readPackageJson(root);
39976
40016
  const rootFw = detectFramework(rootPkg, root);
@@ -39979,19 +40019,28 @@ function detectProject(dir) {
39979
40019
  effectivePkg = pkg ?? rootPkg;
39980
40020
  }
39981
40021
  }
40022
+ if (framework === "unknown" && pkg?.workspaces) {
40023
+ const found = findWorkspaceFrameworkPackage(dir, pkg);
40024
+ if (found) {
40025
+ framework = found.framework;
40026
+ appDir = found.dir;
40027
+ effectivePkg = found.pkg;
40028
+ }
40029
+ }
39982
40030
  return {
39983
40031
  dir,
39984
40032
  hasPackageJson: pkg !== null,
39985
40033
  framework,
39986
40034
  runtime: frameworkRuntime(framework),
39987
40035
  packageManager: detectPackageManager(dir),
39988
- packageJson: pkg,
39989
- llmFrameworks: detectLlmFrameworks(pkg),
40036
+ packageJson: effectivePkg,
40037
+ llmFrameworks: detectLlmFrameworks(effectivePkg),
39990
40038
  moduleType: detectModuleType(effectivePkg),
39991
40039
  rootDir: root,
40040
+ appDir,
39992
40041
  isMonorepo,
39993
- competitors: detectCompetitors(pkg),
39994
- language: detectLanguage(dir)
40042
+ competitors: detectCompetitors(effectivePkg),
40043
+ language: detectLanguage(appDir)
39995
40044
  };
39996
40045
  }
39997
40046
 
@@ -41203,7 +41252,7 @@ function createCheckpoint(cwd, snapshots = new Map) {
41203
41252
  }
41204
41253
 
41205
41254
  // src/wizard/context.ts
41206
- import { readdirSync as readdirSync2, readFileSync as readFileSync9 } from "node:fs";
41255
+ import { readdirSync as readdirSync3, readFileSync as readFileSync9 } from "node:fs";
41207
41256
  import { extname as extname2, join as join10, relative as relative2 } from "node:path";
41208
41257
  var INCLUDE_EXT = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue", ".svelte", ".astro"]);
41209
41258
  var SECRET_PATTERNS = [
@@ -41286,7 +41335,7 @@ function collectCandidates(dir, base, depth, maxDepth, out) {
41286
41335
  return;
41287
41336
  let entries;
41288
41337
  try {
41289
- entries = readdirSync2(dir, { withFileTypes: true });
41338
+ entries = readdirSync3(dir, { withFileTypes: true });
41290
41339
  } catch {
41291
41340
  return;
41292
41341
  }
@@ -41958,6 +42007,10 @@ async function runWizard(opts) {
41958
42007
  const { workspaceId, writeKey } = await resolveWorkspace(client, auth.workspaceId, opts);
41959
42008
  phase(3, "Projeni tanıyoruz", "Kodun okunuyor; hangi kullanıcı olaylarını (ör. kayıt, satın alma) izleyeceğimiz planlanıyor.");
41960
42009
  const detected = detectProject(opts.cwd);
42010
+ if (detected.appDir !== opts.cwd) {
42011
+ p4.log.info(c3.dim(`Monorepo: kurulum ${detected.framework} app'ine → ${detected.appDir}`));
42012
+ opts.cwd = detected.appDir;
42013
+ }
41961
42014
  let framework = detected.framework;
41962
42015
  if (opts.framework && FRAMEWORKS.includes(opts.framework)) {
41963
42016
  framework = opts.framework;
@@ -42710,7 +42763,7 @@ var uninstallCmd = defineCommand({
42710
42763
  });
42711
42764
 
42712
42765
  // src/index.ts
42713
- var VERSION = "1.6.5";
42766
+ var VERSION = "1.6.6";
42714
42767
  var mainCmd = defineCommand({
42715
42768
  meta: {
42716
42769
  name: "gurulu",
@@ -22,6 +22,12 @@ export interface DetectedProject {
22
22
  moduleType: ModuleType;
23
23
  /** Workspace root (lockfile dizini); cwd ile aynıysa monorepo değil. */
24
24
  rootDir: string;
25
+ /**
26
+ * Framework app'inin gerçek dizini. Genelde = dir; ama monorepo ROOT'unda
27
+ * çalışıp framework bir alt-pakette (ör. apps/dashboard) ise o alt-paket dizini.
28
+ * `.env` + kod-wire + SDK install BURAYA hedeflenir (root'a değil).
29
+ */
30
+ appDir: string;
25
31
  /** cwd bir monorepo paketi mi (root farklı + workspaces sinyali). */
26
32
  isMonorepo: boolean;
27
33
  /** Tespit edilen rakip analytics SDK'ları (augmentation/twin için, boş = yok). */
@@ -1 +1 @@
1
- {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["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
1
1
  // src/lib/detect.ts
2
- import { existsSync, readFileSync } from "node:fs";
2
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
3
3
  import { dirname, join, parse } from "node:path";
4
4
  var COMPETITOR_DEP_MAP = {
5
5
  "posthog-js": "posthog",
@@ -165,11 +165,51 @@ function detectLlmFrameworks(pkg) {
165
165
  }
166
166
  return [...found];
167
167
  }
168
+ function expandWorkspaceGlobs(rootDir, patterns) {
169
+ const out = [];
170
+ for (const pat of patterns) {
171
+ if (pat.endsWith("/*")) {
172
+ const base = join(rootDir, pat.slice(0, -2));
173
+ if (!existsSync(base))
174
+ continue;
175
+ try {
176
+ for (const name of readdirSync(base)) {
177
+ const d = join(base, name);
178
+ if (existsSync(join(d, "package.json")))
179
+ out.push(d);
180
+ }
181
+ } catch {}
182
+ } else {
183
+ const d = join(rootDir, pat);
184
+ if (existsSync(join(d, "package.json")))
185
+ out.push(d);
186
+ }
187
+ }
188
+ return out;
189
+ }
190
+ function findWorkspaceFrameworkPackage(rootDir, pkg) {
191
+ const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages ?? [];
192
+ if (patterns.length === 0)
193
+ return null;
194
+ let fallback = null;
195
+ for (const d of expandWorkspaceGlobs(rootDir, patterns)) {
196
+ const p = readPackageJson(d);
197
+ if (!p)
198
+ continue;
199
+ const fw = detectFramework(p, d);
200
+ if (frameworkRuntime(fw) === "browser")
201
+ return { dir: d, framework: fw, pkg: p };
202
+ if (fw !== "unknown" && !fallback)
203
+ fallback = { dir: d, framework: fw, pkg: p };
204
+ }
205
+ return fallback;
206
+ }
168
207
  function detectProject(dir) {
169
208
  const pkg = readPackageJson(dir);
170
209
  let framework = detectFramework(pkg, dir);
171
210
  const { root, isMonorepo } = findWorkspaceRoot(dir);
172
211
  let effectivePkg = pkg;
212
+ let appDir = dir;
173
213
  if (framework === "unknown" && isMonorepo && root !== dir) {
174
214
  const rootPkg = readPackageJson(root);
175
215
  const rootFw = detectFramework(rootPkg, root);
@@ -178,19 +218,28 @@ function detectProject(dir) {
178
218
  effectivePkg = pkg ?? rootPkg;
179
219
  }
180
220
  }
221
+ if (framework === "unknown" && pkg?.workspaces) {
222
+ const found = findWorkspaceFrameworkPackage(dir, pkg);
223
+ if (found) {
224
+ framework = found.framework;
225
+ appDir = found.dir;
226
+ effectivePkg = found.pkg;
227
+ }
228
+ }
181
229
  return {
182
230
  dir,
183
231
  hasPackageJson: pkg !== null,
184
232
  framework,
185
233
  runtime: frameworkRuntime(framework),
186
234
  packageManager: detectPackageManager(dir),
187
- packageJson: pkg,
188
- llmFrameworks: detectLlmFrameworks(pkg),
235
+ packageJson: effectivePkg,
236
+ llmFrameworks: detectLlmFrameworks(effectivePkg),
189
237
  moduleType: detectModuleType(effectivePkg),
190
238
  rootDir: root,
239
+ appDir,
191
240
  isMonorepo,
192
- competitors: detectCompetitors(pkg),
193
- language: detectLanguage(dir)
241
+ competitors: detectCompetitors(effectivePkg),
242
+ language: detectLanguage(appDir)
194
243
  };
195
244
  }
196
245
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/wizard/run.ts"],"names":[],"mappings":"AAuCA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,sFAAsF;IACtF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA0DD,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAidlE"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/wizard/run.ts"],"names":[],"mappings":"AAuCA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,sFAAsF;IACtF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA0DD,wBAAsB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAwdlE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gurulu/cli",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "private": false,
5
5
  "license": "BUSL-1.1",
6
6
  "publishConfig": {