instant-cli 1.0.40 → 1.0.41-branch-python-sdk-v1.26586025551.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.
@@ -1,21 +1,43 @@
1
1
  import { packageDirectory } from 'package-directory';
2
2
  import { findUp } from 'find-up-simple';
3
3
  import path from 'node:path';
4
+ // Same-directory tie-breaker: Deno > Python > Node. Deno may coexist
5
+ // with package.json for npm interop; pyproject.toml signals Python.
6
+ const TYPE_PRIORITY = {
7
+ deno: 0,
8
+ python: 1,
9
+ node: 2,
10
+ };
11
+ const depth = (filepath) => filepath.split(path.sep).length;
4
12
  export async function findProjectDir(cwd) {
5
- // Check for Deno first. A Deno project may also have a package.json (for npm
6
- // compatibility), but if deno.json exists, the user intends to use Deno and
7
- // we should use Deno-specific behavior (e.g., resolving @instantdb/* from
8
- // CLI's dependencies instead of node_modules).
9
- const denoConfig = (await findUp('deno.json', { cwd })) ||
10
- (await findUp('deno.jsonc', { cwd }));
11
- if (denoConfig) {
12
- return { dir: path.dirname(denoConfig), type: 'deno' };
13
- }
14
- // Fall back to package-directory for Node
15
- const nodeDir = await packageDirectory({ cwd });
13
+ const [denoJson, denoJsonc, pyproject, nodeDir] = await Promise.all([
14
+ findUp('deno.json', { cwd }),
15
+ findUp('deno.jsonc', { cwd }),
16
+ findUp('pyproject.toml', { cwd }),
17
+ packageDirectory({ cwd }),
18
+ ]);
19
+ // Push deno.json and deno.jsonc independently so the depth-sort can
20
+ // pick the nearer one when both exist at different levels.
21
+ const candidates = [];
22
+ if (denoJson)
23
+ candidates.push({ file: denoJson, type: 'deno' });
24
+ if (denoJsonc)
25
+ candidates.push({ file: denoJsonc, type: 'deno' });
26
+ if (pyproject)
27
+ candidates.push({ file: pyproject, type: 'python' });
16
28
  if (nodeDir) {
17
- return { dir: nodeDir, type: 'node' };
29
+ candidates.push({ file: path.join(nodeDir, 'package.json'), type: 'node' });
18
30
  }
19
- return null;
31
+ if (candidates.length === 0)
32
+ return null;
33
+ // Nearest marker wins (deepest path), so a Python project nested in a
34
+ // Node monorepo isn't misclassified by a parent's package.json.
35
+ candidates.sort((a, b) => {
36
+ const depthDiff = depth(b.file) - depth(a.file);
37
+ return depthDiff !== 0
38
+ ? depthDiff
39
+ : TYPE_PRIORITY[a.type] - TYPE_PRIORITY[b.type];
40
+ });
41
+ return { dir: path.dirname(candidates[0].file), type: candidates[0].type };
20
42
  }
21
43
  //# sourceMappingURL=projectDir.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectDir.js","sourceRoot":"","sources":["../../src/util/projectDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAY;IAEZ,6EAA6E;IAC7E,4EAA4E;IAC5E,0EAA0E;IAC1E,+CAA+C;IAC/C,MAAM,UAAU,GACd,CAAC,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACpC,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACxC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACzD,CAAC;IAED,0CAA0C;IAC1C,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { packageDirectory } from 'package-directory';\nimport { findUp } from 'find-up-simple';\nimport path from 'node:path';\n\nexport type ProjectType = 'node' | 'deno';\n\nexport interface ProjectInfo {\n dir: string;\n type: ProjectType;\n}\n\nexport async function findProjectDir(\n cwd?: string,\n): Promise<ProjectInfo | null> {\n // Check for Deno first. A Deno project may also have a package.json (for npm\n // compatibility), but if deno.json exists, the user intends to use Deno and\n // we should use Deno-specific behavior (e.g., resolving @instantdb/* from\n // CLI's dependencies instead of node_modules).\n const denoConfig =\n (await findUp('deno.json', { cwd })) ||\n (await findUp('deno.jsonc', { cwd }));\n if (denoConfig) {\n return { dir: path.dirname(denoConfig), type: 'deno' };\n }\n\n // Fall back to package-directory for Node\n const nodeDir = await packageDirectory({ cwd });\n if (nodeDir) {\n return { dir: nodeDir, type: 'node' };\n }\n\n return null;\n}\n"]}
1
+ {"version":3,"file":"projectDir.js","sourceRoot":"","sources":["../../src/util/projectDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,qEAAqE;AACrE,oEAAoE;AACpE,MAAM,aAAa,GAAgC;IACjD,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAY;IAEZ,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAClE,MAAM,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC;QAC5B,MAAM,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC;QAC7B,MAAM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,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import { packageDirectory } from 'package-directory';\nimport { findUp } from 'find-up-simple';\nimport path from 'node:path';\n\nexport type ProjectType = 'node' | 'deno' | 'python';\n\nexport interface ProjectInfo {\n dir: string;\n type: ProjectType;\n}\n\n// Same-directory tie-breaker: Deno > Python > Node. Deno may coexist\n// with package.json for npm interop; pyproject.toml signals Python.\nconst TYPE_PRIORITY: Record<ProjectType, number> = {\n deno: 0,\n python: 1,\n node: 2,\n};\n\nconst depth = (filepath: string) => filepath.split(path.sep).length;\n\nexport async function findProjectDir(\n cwd?: string,\n): Promise<ProjectInfo | null> {\n const [denoJson, denoJsonc, pyproject, nodeDir] = await Promise.all([\n findUp('deno.json', { cwd }),\n findUp('deno.jsonc', { cwd }),\n findUp('pyproject.toml', { cwd }),\n packageDirectory({ cwd }),\n ]);\n\n // Push deno.json and deno.jsonc independently so the depth-sort can\n // pick the nearer one when both exist at different levels.\n const candidates: { file: string; type: ProjectType }[] = [];\n if (denoJson) candidates.push({ file: denoJson, type: 'deno' });\n if (denoJsonc) candidates.push({ file: denoJsonc, type: 'deno' });\n if (pyproject) candidates.push({ file: pyproject, type: 'python' });\n if (nodeDir) {\n candidates.push({ file: path.join(nodeDir, 'package.json'), type: 'node' });\n }\n\n if (candidates.length === 0) return null;\n\n // Nearest marker wins (deepest path), so a Python project nested in a\n // Node monorepo isn't misclassified by a parent's package.json.\n candidates.sort((a, b) => {\n const depthDiff = depth(b.file) - depth(a.file);\n return depthDiff !== 0\n ? depthDiff\n : TYPE_PRIORITY[a.type] - TYPE_PRIORITY[b.type];\n });\n\n return { dir: path.dirname(candidates[0].file), type: candidates[0].type };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "instant-cli",
3
3
  "type": "module",
4
- "version": "1.0.40",
4
+ "version": "1.0.41-branch-python-sdk-v1.26586025551.1",
5
5
  "description": "Instant's CLI",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/cli",
@@ -16,7 +16,8 @@
16
16
  "types": "./dist/ui/index.d.ts",
17
17
  "default": "./dist/ui/index.js"
18
18
  }
19
- }
19
+ },
20
+ "./bin/index.js": "./bin/index.js"
20
21
  },
21
22
  "bin": {
22
23
  "instant-cli": "bin/index.js"
@@ -50,9 +51,9 @@
50
51
  "strip-ansi": "^7.1.2",
51
52
  "supports-hyperlinks": "^4.4.0",
52
53
  "unconfig": "^7.5.0",
53
- "@instantdb/core": "1.0.40",
54
- "@instantdb/platform": "1.0.40",
55
- "@instantdb/version": "1.0.40"
54
+ "@instantdb/platform": "1.0.41-branch-python-sdk-v1.26586025551.1",
55
+ "@instantdb/version": "1.0.41-branch-python-sdk-v1.26586025551.1",
56
+ "@instantdb/core": "1.0.41-branch-python-sdk-v1.26586025551.1"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@babel/core": "^7.17.9",