instant-cli 0.22.68 → 0.22.69

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,4 +1,4 @@
1
1
 
2
- > instant-cli@0.22.68 build /home/runner/work/instant/instant/client/packages/cli
2
+ > instant-cli@0.22.69 build /home/runner/work/instant/instant/client/packages/cli
3
3
  > rm -rf dist; tsc -p tsconfig.json
4
4
 
@@ -1,6 +1,6 @@
1
1
  type ConfigCandidate = {
2
2
  files: string;
3
- extensions: string[];
3
+ extensions?: string[];
4
4
  transform: (code: string) => string;
5
5
  };
6
6
  export declare function getSchemaReadCandidates(): ConfigCandidate[];
@@ -1 +1 @@
1
- {"version":3,"file":"findConfigCandidates.d.ts","sourceRoot":"","sources":["../../src/util/findConfigCandidates.ts"],"names":[],"mappings":"AAIA,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,CAAC;AA+EF,wBAAgB,uBAAuB,IAAI,eAAe,EAAE,CA8C3D;AAED,wBAAgB,sBAAsB,IAAI,eAAe,EAAE,CAuC1D;AAED,wBAAgB,oBAAoB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CASjE"}
1
+ {"version":3,"file":"findConfigCandidates.d.ts","sourceRoot":"","sources":["../../src/util/findConfigCandidates.ts"],"names":[],"mappings":"AAIA,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,CAAC;AA+EF,wBAAgB,uBAAuB,IAAI,eAAe,EAAE,CA+C3D;AAED,wBAAgB,sBAAsB,IAAI,eAAe,EAAE,CAuC1D;AAED,wBAAgB,oBAAoB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAUlE;AAED,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CASjE"}
@@ -61,9 +61,10 @@ function getEnvPermsPathWithLogging() {
61
61
  }
62
62
  export function getSchemaReadCandidates() {
63
63
  const existing = getEnvSchemaPathWithLogging();
64
+ if (existing) {
65
+ return [{ files: existing, transform: transformImports }];
66
+ }
64
67
  const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
65
- if (existing)
66
- return [{ files: existing, extensions, transform: transformImports }];
67
68
  const candidates = [];
68
69
  candidates.push({
69
70
  files: 'instant.schema',
@@ -1 +1 @@
1
- {"version":3,"file":"findConfigCandidates.js","sourceRoot":"","sources":["../../src/util/findConfigCandidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B;;;;;;;;;;;GAWG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CACjB,mCAAmC,EACnC,oCAAoC,CACrC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAe,EACf,QAAgB,EAChB,QAAgB;IAEhB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,MAAM,OAAO,GAAG,CAAC,UAAkB,EAAE,YAAoB,EAAQ,EAAE;QACjE,IAAI,YAAY,GAAG,QAAQ;YAAE,OAAO;QAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;Y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,CAAC,YAAqB;IACxD,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC;QACzC,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAC9C,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAAqB;IACvD,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAC7C,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import { existsSync, readdirSync } from 'fs';\nimport { join } from 'path';\nimport chalk from 'chalk';\n\ntype ConfigCandidate = {\n files: string;\n extensions: string[];\n transform: (code: string) => string;\n};\n\n/**\n * We need to do a bit of a hack of `@instantdb/react-native`.\n *\n * If a user writes import { i } from '@instantdb/react-native'\n *\n * We will fail to evaluate the file. This is because\n * `@instantdb/react-native` brings in `react-native`, which\n * does not run in a node context.\n *\n * To bypass this, we have a 'cli' module inside `react-native`, which\n * has all the necessary imports\n */\nfunction transformImports(code: string): string {\n return code.replace(\n /[\"']@instantdb\\/react-native[\"']/g,\n '\"@instantdb/react-native/dist/cli\"',\n );\n}\n\nfunction findPathsRecursive(\n baseDir: string,\n maxDepth: number,\n fileName: string,\n): string[] {\n const paths: string[] = [];\n const cwd = process.cwd();\n\n const scanDir = (currentDir: string, currentDepth: number): void => {\n if (currentDepth > maxDepth) return;\n\n const fullPath = join(cwd, currentDir);\n if (!existsSync(fullPath)) return;\n\n paths.push(join(currentDir, fileName));\n\n if (currentDepth < maxDepth) {\n try {\n const entries = readdirSync(fullPath, { withFileTypes: true });\n for (const entry of entries) {\n if (\n entry.isDirectory() &&\n !entry.name.startsWith('.') &&\n entry.name !== 'node_modules'\n ) {\n scanDir(join(currentDir, entry.name), currentDepth + 1);\n }\n }\n } catch (err) {\n console.error(`Error scanning directory ${fullPath}: ${err}`);\n }\n }\n };\n\n scanDir(baseDir, 0);\n return paths;\n}\n\nfunction getEnvSchemaPathWithLogging(): string | undefined {\n const path = process.env.INSTANT_SCHEMA_FILE_PATH;\n if (path) {\n console.log(\n `Using INSTANT_SCHEMA_FILE_PATH=${chalk.green(process.env.INSTANT_SCHEMA_FILE_PATH)}`,\n );\n }\n return path;\n}\n\nfunction getEnvPermsPathWithLogging(): string | undefined {\n const path = process.env.INSTANT_PERMS_FILE_PATH;\n if (path) {\n console.log(\n `Using INSTANT_PERMS_FILE_PATH=${chalk.green(process.env.INSTANT_PERMS_FILE_PATH)}`,\n );\n }\n return path;\n}\n\nexport function getSchemaReadCandidates(): ConfigCandidate[] {\n const existing = getEnvSchemaPathWithLogging();\n const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];\n if (existing)\n return [{ files: existing, extensions, transform: transformImports }];\n\n const candidates: ConfigCandidate[] = [];\n\n candidates.push({\n files: 'instant.schema',\n extensions,\n transform: transformImports,\n });\n\n // matches: src/any-folder/any-folder/instant.schema\n // src/any-folder/instant.schema\n // src/instant.schema\n // 3 levels in case someone does src/lib/db/instant.schema\n const srcPaths = findPathsRecursive('src', 3, 'instant.schema');\n for (const srcPath of srcPaths) {\n candidates.push({\n files: srcPath,\n extensions,\n transform: transformImports,\n });\n }\n\n // matches: lib/any-folder/instant.schema\n // lib/instant.schema\n // 2 levels in case someone does lib/db/instant.schema\n const libPaths = findPathsRecursive('lib', 2, 'instant.schema');\n for (const libPath of libPaths) {\n candidates.push({\n files: libPath,\n extensions,\n transform: transformImports,\n });\n }\n\n candidates.push({\n files: 'app/instant.schema',\n extensions,\n transform: transformImports,\n });\n\n return candidates;\n}\n\nexport function getPermsReadCandidates(): ConfigCandidate[] {\n const existing = getEnvPermsPathWithLogging();\n const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];\n if (existing)\n return [{ files: existing, extensions, transform: transformImports }];\n\n const candidates: ConfigCandidate[] = [];\n\n candidates.push({\n files: 'instant.perms',\n extensions,\n transform: transformImports,\n });\n\n const srcPaths = findPathsRecursive('src', 3, 'instant.perms');\n for (const srcPath of srcPaths) {\n candidates.push({\n files: srcPath,\n extensions,\n transform: transformImports,\n });\n }\n\n const libPaths = findPathsRecursive('lib', 2, 'instant.perms');\n for (const libPath of libPaths) {\n candidates.push({\n files: libPath,\n extensions,\n transform: transformImports,\n });\n }\n\n candidates.push({\n files: 'app/instant.perms',\n extensions,\n transform: transformImports,\n });\n\n return candidates;\n}\n\nexport function getSchemaPathToWrite(existingPath?: string): string {\n if (existingPath) return existingPath;\n if (process.env.INSTANT_SCHEMA_FILE_PATH) {\n return process.env.INSTANT_SCHEMA_FILE_PATH;\n }\n if (existsSync(join(process.cwd(), 'src'))) {\n return join('src', 'instant.schema.ts');\n }\n\n return 'instant.schema.ts';\n}\n\nexport function getPermsPathToWrite(existingPath?: string): string {\n if (existingPath) return existingPath;\n if (process.env.INSTANT_PERMS_FILE_PATH) {\n return process.env.INSTANT_PERMS_FILE_PATH;\n }\n if (existsSync(join(process.cwd(), 'src'))) {\n return join('src', 'instant.perms.ts');\n }\n return 'instant.perms.ts';\n}\n"]}
1
+ {"version":3,"file":"findConfigCandidates.js","sourceRoot":"","sources":["../../src/util/findConfigCandidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,W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UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import { existsSync, readdirSync } from 'fs';\nimport { join } from 'path';\nimport chalk from 'chalk';\n\ntype ConfigCandidate = {\n files: string;\n extensions?: string[];\n transform: (code: string) => string;\n};\n\n/**\n * We need to do a bit of a hack of `@instantdb/react-native`.\n *\n * If a user writes import { i } from '@instantdb/react-native'\n *\n * We will fail to evaluate the file. This is because\n * `@instantdb/react-native` brings in `react-native`, which\n * does not run in a node context.\n *\n * To bypass this, we have a 'cli' module inside `react-native`, which\n * has all the necessary imports\n */\nfunction transformImports(code: string): string {\n return code.replace(\n /[\"']@instantdb\\/react-native[\"']/g,\n '\"@instantdb/react-native/dist/cli\"',\n );\n}\n\nfunction findPathsRecursive(\n baseDir: string,\n maxDepth: number,\n fileName: string,\n): string[] {\n const paths: string[] = [];\n const cwd = process.cwd();\n\n const scanDir = (currentDir: string, currentDepth: number): void => {\n if (currentDepth > maxDepth) return;\n\n const fullPath = join(cwd, currentDir);\n if (!existsSync(fullPath)) return;\n\n paths.push(join(currentDir, fileName));\n\n if (currentDepth < maxDepth) {\n try {\n const entries = readdirSync(fullPath, { withFileTypes: true });\n for (const entry of entries) {\n if (\n entry.isDirectory() &&\n !entry.name.startsWith('.') &&\n entry.name !== 'node_modules'\n ) {\n scanDir(join(currentDir, entry.name), currentDepth + 1);\n }\n }\n } catch (err) {\n console.error(`Error scanning directory ${fullPath}: ${err}`);\n }\n }\n };\n\n scanDir(baseDir, 0);\n return paths;\n}\n\nfunction getEnvSchemaPathWithLogging(): string | undefined {\n const path = process.env.INSTANT_SCHEMA_FILE_PATH;\n if (path) {\n console.log(\n `Using INSTANT_SCHEMA_FILE_PATH=${chalk.green(process.env.INSTANT_SCHEMA_FILE_PATH)}`,\n );\n }\n return path;\n}\n\nfunction getEnvPermsPathWithLogging(): string | undefined {\n const path = process.env.INSTANT_PERMS_FILE_PATH;\n if (path) {\n console.log(\n `Using INSTANT_PERMS_FILE_PATH=${chalk.green(process.env.INSTANT_PERMS_FILE_PATH)}`,\n );\n }\n return path;\n}\n\nexport function getSchemaReadCandidates(): ConfigCandidate[] {\n const existing = getEnvSchemaPathWithLogging();\n\n if (existing) {\n return [{ files: existing, transform: transformImports }];\n }\n const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];\n const candidates: ConfigCandidate[] = [];\n\n candidates.push({\n files: 'instant.schema',\n extensions,\n transform: transformImports,\n });\n\n // matches: src/any-folder/any-folder/instant.schema\n // src/any-folder/instant.schema\n // src/instant.schema\n // 3 levels in case someone does src/lib/db/instant.schema\n const srcPaths = findPathsRecursive('src', 3, 'instant.schema');\n for (const srcPath of srcPaths) {\n candidates.push({\n files: srcPath,\n extensions,\n transform: transformImports,\n });\n }\n\n // matches: lib/any-folder/instant.schema\n // lib/instant.schema\n // 2 levels in case someone does lib/db/instant.schema\n const libPaths = findPathsRecursive('lib', 2, 'instant.schema');\n for (const libPath of libPaths) {\n candidates.push({\n files: libPath,\n extensions,\n transform: transformImports,\n });\n }\n\n candidates.push({\n files: 'app/instant.schema',\n extensions,\n transform: transformImports,\n });\n\n return candidates;\n}\n\nexport function getPermsReadCandidates(): ConfigCandidate[] {\n const existing = getEnvPermsPathWithLogging();\n const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];\n if (existing)\n return [{ files: existing, extensions, transform: transformImports }];\n\n const candidates: ConfigCandidate[] = [];\n\n candidates.push({\n files: 'instant.perms',\n extensions,\n transform: transformImports,\n });\n\n const srcPaths = findPathsRecursive('src', 3, 'instant.perms');\n for (const srcPath of srcPaths) {\n candidates.push({\n files: srcPath,\n extensions,\n transform: transformImports,\n });\n }\n\n const libPaths = findPathsRecursive('lib', 2, 'instant.perms');\n for (const libPath of libPaths) {\n candidates.push({\n files: libPath,\n extensions,\n transform: transformImports,\n });\n }\n\n candidates.push({\n files: 'app/instant.perms',\n extensions,\n transform: transformImports,\n });\n\n return candidates;\n}\n\nexport function getSchemaPathToWrite(existingPath?: string): string {\n if (existingPath) return existingPath;\n if (process.env.INSTANT_SCHEMA_FILE_PATH) {\n return process.env.INSTANT_SCHEMA_FILE_PATH;\n }\n if (existsSync(join(process.cwd(), 'src'))) {\n return join('src', 'instant.schema.ts');\n }\n\n return 'instant.schema.ts';\n}\n\nexport function getPermsPathToWrite(existingPath?: string): string {\n if (existingPath) return existingPath;\n if (process.env.INSTANT_PERMS_FILE_PATH) {\n return process.env.INSTANT_PERMS_FILE_PATH;\n }\n if (existsSync(join(process.cwd(), 'src'))) {\n return join('src', 'instant.perms.ts');\n }\n return 'instant.perms.ts';\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "instant-cli",
3
3
  "type": "module",
4
- "version": "0.22.68",
4
+ "version": "0.22.69",
5
5
  "description": "Instant's CLI",
6
6
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/cli",
7
7
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "strip-ansi": "^7.1.2",
39
39
  "terminal-link": "^3.0.0",
40
40
  "unconfig": "^0.5.5",
41
- "@instantdb/platform": "0.22.68",
42
- "@instantdb/version": "0.22.68"
41
+ "@instantdb/platform": "0.22.69",
42
+ "@instantdb/version": "0.22.69"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@babel/core": "^7.17.9",
@@ -4,7 +4,7 @@ import chalk from 'chalk';
4
4
 
5
5
  type ConfigCandidate = {
6
6
  files: string;
7
- extensions: string[];
7
+ extensions?: string[];
8
8
  transform: (code: string) => string;
9
9
  };
10
10
 
@@ -87,10 +87,11 @@ function getEnvPermsPathWithLogging(): string | undefined {
87
87
 
88
88
  export function getSchemaReadCandidates(): ConfigCandidate[] {
89
89
  const existing = getEnvSchemaPathWithLogging();
90
- const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
91
- if (existing)
92
- return [{ files: existing, extensions, transform: transformImports }];
93
90
 
91
+ if (existing) {
92
+ return [{ files: existing, transform: transformImports }];
93
+ }
94
+ const extensions = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'];
94
95
  const candidates: ConfigCandidate[] = [];
95
96
 
96
97
  candidates.push({