instant-cli 0.22.177 → 0.22.178

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.
Files changed (213) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/__tests__/e2e/cli.e2e.test.ts +3 -3
  3. package/__tests__/e2e/helpers.ts +1 -1
  4. package/__tests__/effectHelpers.ts +45 -0
  5. package/__tests__/mergeSchema.test.ts +2 -2
  6. package/dist/commands/claim.d.ts +6 -0
  7. package/dist/commands/claim.d.ts.map +1 -0
  8. package/dist/commands/claim.js +22 -0
  9. package/dist/commands/claim.js.map +1 -0
  10. package/dist/commands/explorer.d.ts +6 -0
  11. package/dist/commands/explorer.d.ts.map +1 -0
  12. package/dist/commands/explorer.js +13 -0
  13. package/dist/commands/explorer.js.map +1 -0
  14. package/dist/commands/info.d.ts +3 -0
  15. package/dist/commands/info.d.ts.map +1 -0
  16. package/dist/commands/info.js +24 -0
  17. package/dist/commands/info.js.map +1 -0
  18. package/dist/commands/init.d.ts +5 -0
  19. package/dist/commands/init.d.ts.map +1 -0
  20. package/dist/commands/init.js +39 -0
  21. package/dist/commands/init.js.map +1 -0
  22. package/dist/commands/initWithoutFiles.d.ts +6 -0
  23. package/dist/commands/initWithoutFiles.d.ts.map +1 -0
  24. package/dist/commands/initWithoutFiles.js +64 -0
  25. package/dist/commands/initWithoutFiles.js.map +1 -0
  26. package/dist/commands/login.d.ts +9 -0
  27. package/dist/commands/login.d.ts.map +1 -0
  28. package/dist/commands/login.js +52 -0
  29. package/dist/commands/login.js.map +1 -0
  30. package/dist/commands/logout.d.ts +4 -0
  31. package/dist/commands/logout.d.ts.map +1 -0
  32. package/dist/commands/logout.js +21 -0
  33. package/dist/commands/logout.js.map +1 -0
  34. package/dist/commands/pull.d.ts +6 -0
  35. package/dist/commands/pull.d.ts.map +1 -0
  36. package/dist/commands/pull.js +16 -0
  37. package/dist/commands/pull.js.map +1 -0
  38. package/dist/commands/push.d.ts +6 -0
  39. package/dist/commands/push.d.ts.map +1 -0
  40. package/dist/commands/push.js +20 -0
  41. package/dist/commands/push.js.map +1 -0
  42. package/dist/commands/query.d.ts +7 -0
  43. package/dist/commands/query.d.ts.map +1 -0
  44. package/dist/commands/query.js +52 -0
  45. package/dist/commands/query.js.map +1 -0
  46. package/dist/context/authToken.d.ts +30 -0
  47. package/dist/context/authToken.d.ts.map +1 -0
  48. package/dist/context/authToken.js +86 -0
  49. package/dist/context/authToken.js.map +1 -0
  50. package/dist/context/currentApp.d.ts +37 -0
  51. package/dist/context/currentApp.d.ts.map +1 -0
  52. package/dist/context/currentApp.js +204 -0
  53. package/dist/context/currentApp.js.map +1 -0
  54. package/dist/context/globalOpts.d.ts +11 -0
  55. package/dist/context/globalOpts.d.ts.map +1 -0
  56. package/dist/context/globalOpts.js +13 -0
  57. package/dist/context/globalOpts.js.map +1 -0
  58. package/dist/context/platformApi.d.ts +19 -0
  59. package/dist/context/platformApi.d.ts.map +1 -0
  60. package/dist/context/platformApi.js +24 -0
  61. package/dist/context/platformApi.js.map +1 -0
  62. package/dist/context/projectInfo.d.ts +29 -0
  63. package/dist/context/projectInfo.d.ts.map +1 -0
  64. package/dist/context/projectInfo.js +149 -0
  65. package/dist/context/projectInfo.js.map +1 -0
  66. package/dist/errors.d.ts +10 -0
  67. package/dist/errors.d.ts.map +1 -0
  68. package/dist/errors.js +6 -0
  69. package/dist/errors.js.map +1 -0
  70. package/dist/index.d.ts +41 -7
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +169 -1781
  73. package/dist/index.js.map +1 -1
  74. package/dist/layer.d.ts +23 -0
  75. package/dist/layer.d.ts.map +1 -0
  76. package/dist/layer.js +68 -0
  77. package/dist/layer.js.map +1 -0
  78. package/dist/lib/createApp.d.ts +12 -0
  79. package/dist/lib/createApp.d.ts.map +1 -0
  80. package/dist/lib/createApp.js +15 -0
  81. package/dist/lib/createApp.js.map +1 -0
  82. package/dist/lib/handleEnv.d.ts +7 -0
  83. package/dist/lib/handleEnv.d.ts.map +1 -0
  84. package/dist/lib/handleEnv.js +91 -0
  85. package/dist/lib/handleEnv.js.map +1 -0
  86. package/dist/lib/http.d.ts +32 -0
  87. package/dist/lib/http.d.ts.map +1 -0
  88. package/dist/lib/http.js +67 -0
  89. package/dist/lib/http.js.map +1 -0
  90. package/dist/lib/login.d.ts +13 -0
  91. package/dist/lib/login.d.ts.map +1 -0
  92. package/dist/lib/login.js +39 -0
  93. package/dist/lib/login.js.map +1 -0
  94. package/dist/lib/pullPerms.d.ts +7 -0
  95. package/dist/lib/pullPerms.d.ts.map +1 -0
  96. package/dist/lib/pullPerms.js +41 -0
  97. package/dist/lib/pullPerms.js.map +1 -0
  98. package/dist/lib/pullSchema.d.ts +12 -0
  99. package/dist/lib/pullSchema.d.ts.map +1 -0
  100. package/dist/lib/pullSchema.js +62 -0
  101. package/dist/lib/pullSchema.js.map +1 -0
  102. package/dist/lib/pushPerms.d.ts +13 -0
  103. package/dist/lib/pushPerms.d.ts.map +1 -0
  104. package/dist/lib/pushPerms.js +54 -0
  105. package/dist/lib/pushPerms.js.map +1 -0
  106. package/dist/lib/pushSchema.d.ts +53 -0
  107. package/dist/lib/pushSchema.d.ts.map +1 -0
  108. package/dist/lib/pushSchema.js +160 -0
  109. package/dist/lib/pushSchema.js.map +1 -0
  110. package/dist/lib/ui.d.ts +16 -0
  111. package/dist/lib/ui.d.ts.map +1 -0
  112. package/dist/lib/ui.js +22 -0
  113. package/dist/lib/ui.js.map +1 -0
  114. package/dist/logging.d.ts +4 -0
  115. package/dist/logging.d.ts.map +1 -0
  116. package/dist/logging.js +17 -0
  117. package/dist/logging.js.map +1 -0
  118. package/dist/old.d.ts +14 -0
  119. package/dist/old.d.ts.map +1 -0
  120. package/dist/old.js +417 -0
  121. package/dist/old.js.map +1 -0
  122. package/dist/program.d.ts +3 -0
  123. package/dist/program.d.ts.map +1 -0
  124. package/dist/program.js +3 -0
  125. package/dist/program.js.map +1 -0
  126. package/dist/renderSchemaPlan.d.ts +3 -3
  127. package/dist/renderSchemaPlan.d.ts.map +1 -1
  128. package/dist/renderSchemaPlan.js +2 -14
  129. package/dist/renderSchemaPlan.js.map +1 -1
  130. package/dist/ui/index.d.ts +4 -3
  131. package/dist/ui/index.d.ts.map +1 -1
  132. package/dist/ui/index.js +2 -2
  133. package/dist/ui/index.js.map +1 -1
  134. package/dist/ui/lib.js +1 -0
  135. package/dist/ui/lib.js.map +1 -1
  136. package/dist/util/findConfigCandidates.d.ts +1 -1
  137. package/dist/util/findConfigCandidates.d.ts.map +1 -1
  138. package/dist/util/findConfigCandidates.js +1 -3
  139. package/dist/util/findConfigCandidates.js.map +1 -1
  140. package/dist/util/fs.d.ts +1 -1
  141. package/dist/util/fs.d.ts.map +1 -1
  142. package/dist/util/fs.js.map +1 -1
  143. package/dist/util/getAuthPaths.d.ts.map +1 -1
  144. package/dist/util/getAuthPaths.js.map +1 -1
  145. package/dist/util/isHeadlessEnvironment.d.ts +3 -1
  146. package/dist/util/isHeadlessEnvironment.d.ts.map +1 -1
  147. package/dist/util/isHeadlessEnvironment.js.map +1 -1
  148. package/dist/util/loadConfig.d.ts +1 -1
  149. package/dist/util/loadConfig.d.ts.map +1 -1
  150. package/dist/util/loadConfig.js +2 -2
  151. package/dist/util/loadConfig.js.map +1 -1
  152. package/dist/util/mergeSchema.d.ts +9 -1
  153. package/dist/util/mergeSchema.d.ts.map +1 -1
  154. package/dist/util/mergeSchema.js +4 -0
  155. package/dist/util/mergeSchema.js.map +1 -1
  156. package/dist/util/renamePrompt.d.ts +2 -1
  157. package/dist/util/renamePrompt.d.ts.map +1 -1
  158. package/dist/util/renamePrompt.js +1 -1
  159. package/dist/util/renamePrompt.js.map +1 -1
  160. package/package.json +17 -7
  161. package/src/commands/claim.ts +31 -0
  162. package/src/commands/explorer.ts +21 -0
  163. package/src/commands/info.ts +34 -0
  164. package/src/commands/init.ts +58 -0
  165. package/src/commands/initWithoutFiles.ts +107 -0
  166. package/src/commands/login.ts +76 -0
  167. package/src/commands/logout.ts +23 -0
  168. package/src/commands/pull.ts +23 -0
  169. package/src/commands/push.ts +25 -0
  170. package/src/commands/query.ts +61 -0
  171. package/src/context/authToken.ts +149 -0
  172. package/src/context/currentApp.ts +277 -0
  173. package/src/context/globalOpts.ts +22 -0
  174. package/src/context/platformApi.ts +35 -0
  175. package/src/context/projectInfo.ts +215 -0
  176. package/src/errors.ts +7 -0
  177. package/src/index.ts +428 -0
  178. package/src/layer.ts +155 -0
  179. package/src/lib/createApp.ts +28 -0
  180. package/src/lib/handleEnv.ts +115 -0
  181. package/src/lib/http.ts +148 -0
  182. package/src/lib/login.ts +54 -0
  183. package/src/lib/pullPerms.ts +50 -0
  184. package/src/lib/pullSchema.ts +95 -0
  185. package/src/lib/pushPerms.ts +80 -0
  186. package/src/lib/pushSchema.ts +240 -0
  187. package/src/lib/ui.ts +36 -0
  188. package/src/logging.ts +32 -0
  189. package/src/old.js +495 -0
  190. package/src/program.ts +3 -0
  191. package/src/renderSchemaPlan.ts +6 -18
  192. package/src/ui/index.ts +4 -3
  193. package/src/util/findConfigCandidates.ts +1 -2
  194. package/src/util/fs.ts +1 -1
  195. package/src/util/getAuthPaths.ts +1 -0
  196. package/src/util/isHeadlessEnvironment.ts +1 -1
  197. package/src/util/loadConfig.ts +3 -6
  198. package/src/util/{mergeSchema.js → mergeSchema.ts} +26 -16
  199. package/src/util/renamePrompt.ts +2 -1
  200. package/tsconfig.build.json +20 -0
  201. package/tsconfig.json +15 -5
  202. package/vitest.config.ts +2 -1
  203. package/dist/util/packageManager.d.ts +0 -3
  204. package/dist/util/packageManager.d.ts.map +0 -1
  205. package/dist/util/packageManager.js +0 -70
  206. package/dist/util/packageManager.js.map +0 -1
  207. package/dist/util/promptOk.d.ts +0 -4
  208. package/dist/util/promptOk.d.ts.map +0 -1
  209. package/dist/util/promptOk.js +0 -18
  210. package/dist/util/promptOk.js.map +0 -1
  211. package/src/index.js +0 -2333
  212. package/src/util/packageManager.js +0 -78
  213. package/src/util/promptOk.ts +0 -26
@@ -1,11 +1,17 @@
1
1
  import * as acorn from 'acorn';
2
2
  import tsPlugin from 'acorn-typescript';
3
+ import { Data } from 'effect';
3
4
 
5
+ export class MergeSchemaError extends Data.TaggedError('MergeSchemaError')<{
6
+ message: string;
7
+ }> {}
8
+
9
+ // @ts-ignore
4
10
  const node = acorn.Parser.extend(tsPlugin({ dts: false }));
5
11
 
6
12
  // --- Import Handling Helpers ---
7
13
 
8
- function collectImports(ast) {
14
+ function collectImports(ast: any) {
9
15
  const imports = new Map(); // localName -> { source, importedName, type, importKind }
10
16
 
11
17
  for (const node of ast.body) {
@@ -45,7 +51,7 @@ function collectImports(ast) {
45
51
  return imports;
46
52
  }
47
53
 
48
- function collectExistingImports(ast) {
54
+ function collectExistingImports(ast: any) {
49
55
  const existing = new Map(); // source -> Set<localName>
50
56
 
51
57
  for (const node of ast.body) {
@@ -61,7 +67,7 @@ function collectExistingImports(ast) {
61
67
  return existing;
62
68
  }
63
69
 
64
- function findIdentifiers(node, set = new Set()) {
70
+ function findIdentifiers(node: any, set: Set<string> = new Set<string>()) {
65
71
  if (!node) return set;
66
72
 
67
73
  // If it's a Type Reference, grab the name
@@ -96,13 +102,13 @@ function findIdentifiers(node, set = new Set()) {
96
102
 
97
103
  // --- Schema Traversal Helpers ---
98
104
 
99
- function getPropName(prop) {
105
+ function getPropName(prop: any) {
100
106
  if (prop.key.type === 'Identifier') return prop.key.name;
101
107
  if (prop.key.type === 'Literal') return prop.key.value;
102
108
  return null;
103
109
  }
104
110
 
105
- function analyzeChain(node) {
111
+ function analyzeChain(node: any): { typeParams: any; baseCall: any } {
106
112
  let curr = node;
107
113
  let typeParams = null;
108
114
  let baseCall = null;
@@ -129,7 +135,11 @@ function analyzeChain(node) {
129
135
  return { typeParams, baseCall };
130
136
  }
131
137
 
132
- function traverseSchema(node, path, callback) {
138
+ function traverseSchema(
139
+ node: any,
140
+ path: string,
141
+ callback: (node: any, path: string) => void,
142
+ ) {
133
143
  if (node.type === 'ObjectExpression') {
134
144
  for (const prop of node.properties) {
135
145
  const name = getPropName(prop);
@@ -162,9 +172,9 @@ function traverseSchema(node, path, callback) {
162
172
  }
163
173
  }
164
174
 
165
- function findSchemaObject(ast) {
166
- let schemaObj = null;
167
- function walk(node) {
175
+ function findSchemaObject(ast: any) {
176
+ let schemaObj: any = null;
177
+ function walk(node: any) {
168
178
  if (!node) return;
169
179
  if (schemaObj) return;
170
180
  if (
@@ -192,7 +202,7 @@ function findSchemaObject(ast) {
192
202
  return schemaObj;
193
203
  }
194
204
 
195
- export function mergeSchema(oldFile, newFile) {
205
+ export function mergeSchema(oldFile: string, newFile: string): string {
196
206
  const oldParsed = node.parse(oldFile, {
197
207
  sourceType: 'module',
198
208
  ecmaVersion: 'latest',
@@ -210,7 +220,7 @@ export function mergeSchema(oldFile, newFile) {
210
220
  // 1. Extract from old file
211
221
  const oldSchemaObj = findSchemaObject(oldParsed);
212
222
  if (oldSchemaObj) {
213
- traverseSchema(oldSchemaObj, '', (node, path) => {
223
+ traverseSchema(oldSchemaObj, '', (node: any, path: string) => {
214
224
  const { typeParams } = analyzeChain(node);
215
225
  if (typeParams) {
216
226
  const src = oldFile.slice(typeParams.start, typeParams.end);
@@ -222,14 +232,14 @@ export function mergeSchema(oldFile, newFile) {
222
232
  // 2. Collect Imports
223
233
  const oldImports = collectImports(oldParsed);
224
234
  const newExistingImports = collectExistingImports(newParsed);
225
- const neededIdentifiers = new Set();
235
+ const neededIdentifiers = new Set<string>();
226
236
 
227
237
  // 3. Apply to new file & Collect needed identifiers
228
- const edits = [];
238
+ const edits: any[] = [];
229
239
  const newSchemaObj = findSchemaObject(newParsed);
230
240
 
231
241
  if (newSchemaObj) {
232
- traverseSchema(newSchemaObj, '', (node, path) => {
242
+ traverseSchema(newSchemaObj, '', (node: any, path: string) => {
233
243
  const { typeParams, baseCall } = analyzeChain(node);
234
244
  const stored = schemaMap.get(path);
235
245
 
@@ -290,7 +300,7 @@ export function mergeSchema(oldFile, newFile) {
290
300
  }
291
301
  }
292
302
 
293
- const importBlocks = [];
303
+ const importBlocks: string[] = [];
294
304
 
295
305
  for (const [source, info] of importsToAdd) {
296
306
  // Check if source exists in new file to merge?
@@ -299,7 +309,7 @@ export function mergeSchema(oldFile, newFile) {
299
309
 
300
310
  // If we have named imports
301
311
  if (info.named.size > 0) {
302
- const namedImports = Array.from(info.named.values());
312
+ const namedImports: any[] = Array.from(info.named.values());
303
313
  const allTypes = namedImports.every((x) => x.isType);
304
314
 
305
315
  if (allTypes) {
@@ -1,5 +1,6 @@
1
1
  import chalk from 'chalk';
2
- import { ModifyOutputFn, Prompt, SelectState } from '../ui/lib.js';
2
+ import { Prompt, SelectState } from '../ui/lib.ts';
3
+ import type { ModifyOutputFn } from '../ui/lib.ts';
3
4
  import { isRenamePromptItem } from '@instantdb/platform';
4
5
 
5
6
  export interface RenamePromptItem<T> {
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
6
+ "rewriteRelativeImportExtensions": true,
7
+ "sourceMap": true,
8
+ "verbatimModuleSyntax": true,
9
+ "strict": true,
10
+ "skipLibCheck": true, // `unconfig` currently imports a broken type from `@antfu/utils`,
11
+ "plugins": [
12
+ {
13
+ "name": "@effect/language-service"
14
+ }
15
+ ],
16
+ "strictNullChecks": true
17
+ },
18
+ "include": ["src"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
package/tsconfig.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
+ "$schema": "https://raw.githubusercontent.com/Effect-TS/language-service/refs/heads/main/schema.json",
2
3
  "extends": "../../tsconfig.base.json",
3
4
  "compilerOptions": {
4
5
  "outDir": "dist",
5
- "rootDir": "src",
6
+ "rewriteRelativeImportExtensions": true,
6
7
  "sourceMap": true,
7
- "skipLibCheck": true, // `unconfig` currently imports a broken type from `@antfu/utils`,
8
- "strictNullChecks": true
9
- // remove once fixed
8
+ "skipLibCheck": true,
9
+ "incremental": true,
10
+ "composite": true,
11
+ "moduleDetection": "force",
12
+ "verbatimModuleSyntax": true,
13
+ "strictNullChecks": true,
14
+ "strict": true,
15
+ "plugins": [
16
+ {
17
+ "name": "@effect/language-service"
18
+ }
19
+ ]
10
20
  },
11
- "include": ["src"],
21
+ "include": ["src", "__tests__"],
12
22
  "exclude": ["node_modules", "dist"]
13
23
  }
package/vitest.config.ts CHANGED
@@ -7,13 +7,14 @@ export default defineConfig({
7
7
  test: {
8
8
  name: 'unit',
9
9
  include: ['**/*.test.ts'],
10
- exclude: ['**/*.e2e.test.ts'],
10
+ exclude: ['**/*.e2e.test.ts', '**/node_modules/**'],
11
11
  },
12
12
  },
13
13
  {
14
14
  test: {
15
15
  name: 'e2e',
16
16
  include: ['**/*.e2e.test.ts'],
17
+ exclude: ['**/node_modules/**'],
17
18
  },
18
19
  },
19
20
  ],
@@ -1,3 +0,0 @@
1
- export function detectPackageManager(destPath: any): Promise<any>;
2
- export function getInstallCommand(packageManager: any, moduleName: any): string;
3
- //# sourceMappingURL=packageManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageManager.d.ts","sourceRoot":"","sources":["../../src/util/packageManager.js"],"names":[],"mappings":"AAOA,kEAoCC;AA0BD,gFAMC"}
@@ -1,70 +0,0 @@
1
- // Note:
2
- // Extracted the main logic for `detectPackageManager` from:
3
- // https://github.com/vercel/vercel/blob/eb7fe8a9266563cfeaf275cd77cd9fad3f17c92b/packages/build-utils/src/fs/run-user-scripts.ts
4
- import { pathExists, readJsonFile } from './fs.js';
5
- import path from 'path';
6
- async function detectPackageManager(destPath) {
7
- const lockfileNames = {
8
- 'yarn.lock': 'yarn',
9
- 'package-lock.json': 'npm',
10
- 'pnpm-lock.yaml': 'pnpm',
11
- 'bun.lockb': 'bun',
12
- 'bun.lock': 'bun',
13
- };
14
- for (const dir of traverseUpDirectories(destPath)) {
15
- for (const [lockfileName, cliType] of Object.entries(lockfileNames)) {
16
- const lockfilePath = path.join(dir, lockfileName);
17
- if (await pathExists(lockfilePath)) {
18
- return cliType;
19
- }
20
- }
21
- const packageJsonPath = path.join(dir, 'package.json');
22
- if (await pathExists(packageJsonPath)) {
23
- const packageJson = await readJsonFile(packageJsonPath);
24
- if (packageJson.packageManager) {
25
- const corepackPackageManager = parsePackageManagerField(packageJson.packageManager);
26
- if (corepackPackageManager) {
27
- return corepackPackageManager.packageName;
28
- }
29
- }
30
- }
31
- if (dir === path.parse(dir).root) {
32
- break;
33
- }
34
- }
35
- return 'npm';
36
- }
37
- function* traverseUpDirectories(start) {
38
- let current = path.resolve(start);
39
- while (true) {
40
- yield current;
41
- const parent = path.dirname(current);
42
- if (parent === current) {
43
- break;
44
- }
45
- current = parent;
46
- }
47
- }
48
- function parsePackageManagerField(packageManager) {
49
- if (!packageManager)
50
- return null;
51
- const atIndex = packageManager.lastIndexOf('@');
52
- if (atIndex <= 0)
53
- return null; // '@' at position 0 is invalid
54
- const packageName = packageManager.slice(0, atIndex);
55
- const packageVersion = packageManager.slice(atIndex + 1);
56
- if (!packageName || !packageVersion) {
57
- return null;
58
- }
59
- return { packageName, packageVersion };
60
- }
61
- function getInstallCommand(packageManager, moduleName) {
62
- if (packageManager === 'npm') {
63
- return `npm install ${moduleName}`;
64
- }
65
- else {
66
- return `${packageManager} add ${moduleName}`;
67
- }
68
- }
69
- export { detectPackageManager, getInstallCommand };
70
- //# sourceMappingURL=packageManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageManager.js","sourceRoot":"","sources":["../../src/util/packageManager.js"],"names":[],"mappings":"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","sourcesContent":["// Note:\n// Extracted the main logic for `detectPackageManager` from:\n// https://github.com/vercel/vercel/blob/eb7fe8a9266563cfeaf275cd77cd9fad3f17c92b/packages/build-utils/src/fs/run-user-scripts.ts\n\nimport { pathExists, readJsonFile } from './fs.js';\nimport path from 'path';\n\nasync function detectPackageManager(destPath) {\n const lockfileNames = {\n 'yarn.lock': 'yarn',\n 'package-lock.json': 'npm',\n 'pnpm-lock.yaml': 'pnpm',\n 'bun.lockb': 'bun',\n 'bun.lock': 'bun',\n };\n\n for (const dir of traverseUpDirectories(destPath)) {\n for (const [lockfileName, cliType] of Object.entries(lockfileNames)) {\n const lockfilePath = path.join(dir, lockfileName);\n if (await pathExists(lockfilePath)) {\n return cliType;\n }\n }\n\n const packageJsonPath = path.join(dir, 'package.json');\n if (await pathExists(packageJsonPath)) {\n const packageJson = await readJsonFile(packageJsonPath);\n if (packageJson.packageManager) {\n const corepackPackageManager = parsePackageManagerField(\n packageJson.packageManager,\n );\n if (corepackPackageManager) {\n return corepackPackageManager.packageName;\n }\n }\n }\n\n if (dir === path.parse(dir).root) {\n break;\n }\n }\n\n return 'npm';\n}\n\nfunction* traverseUpDirectories(start) {\n let current = path.resolve(start);\n while (true) {\n yield current;\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n}\n\nfunction parsePackageManagerField(packageManager) {\n if (!packageManager) return null;\n const atIndex = packageManager.lastIndexOf('@');\n if (atIndex <= 0) return null; // '@' at position 0 is invalid\n const packageName = packageManager.slice(0, atIndex);\n const packageVersion = packageManager.slice(atIndex + 1);\n if (!packageName || !packageVersion) {\n return null;\n }\n return { packageName, packageVersion };\n}\n\nfunction getInstallCommand(packageManager, moduleName) {\n if (packageManager === 'npm') {\n return `npm install ${moduleName}`;\n } else {\n return `${packageManager} add ${moduleName}`;\n }\n}\n\nexport { detectPackageManager, getInstallCommand };\n"]}
@@ -1,4 +0,0 @@
1
- import { OptionValues } from 'commander';
2
- import { UI } from '../ui/index.js';
3
- export declare function promptOk(props: UI.ConfirmationProps, opts?: OptionValues, defaultValue?: boolean): Promise<boolean>;
4
- //# sourceMappingURL=promptOk.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promptOk.d.ts","sourceRoot":"","sources":["../../src/util/promptOk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAgB,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGlD,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,EAAE,CAAC,iBAAiB,EAC3B,IAAI,CAAC,EAAE,YAAY,EACnB,YAAY,GAAE,OAAc,oBAkB7B"}
@@ -1,18 +0,0 @@
1
- import { renderUnwrap, UI } from '../ui/index.js';
2
- import boxen from 'boxen';
3
- export async function promptOk(props, opts, defaultValue = true) {
4
- if (opts?.yes)
5
- return defaultValue;
6
- return await renderUnwrap(new UI.Confirmation({
7
- modifyOutput: (out) => boxen(out, {
8
- dimBorder: true,
9
- padding: {
10
- left: 1,
11
- right: 1,
12
- },
13
- }),
14
- ...props,
15
- defaultValue,
16
- })).catch(() => defaultValue);
17
- }
18
- //# sourceMappingURL=promptOk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promptOk.js","sourceRoot":"","sources":["../../src/util/promptOk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAA2B,EAC3B,IAAmB,EACnB,eAAwB,IAAI;IAE5B,IAAI,IAAI,EAAE,GAAG;QAAE,OAAO,YAAY,CAAC;IAEnC,OAAO,MAAM,YAAY,CACvB,IAAI,EAAE,CAAC,YAAY,CAAC;QAClB,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CACpB,KAAK,CAAC,GAAG,EAAE;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,CAAC;aACT;SACF,CAAC;QACJ,GAAG,KAAK;QACR,YAAY;KACb,CAAC,CACH,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { OptionValues } from 'commander';\nimport { renderUnwrap, UI } from '../ui/index.js';\nimport boxen from 'boxen';\n\nexport async function promptOk(\n props: UI.ConfirmationProps,\n opts?: OptionValues,\n defaultValue: boolean = true,\n) {\n if (opts?.yes) return defaultValue;\n\n return await renderUnwrap(\n new UI.Confirmation({\n modifyOutput: (out) =>\n boxen(out, {\n dimBorder: true,\n padding: {\n left: 1,\n right: 1,\n },\n }),\n ...props,\n defaultValue,\n }),\n ).catch(() => defaultValue);\n}\n"]}