@sanity/cli 6.0.0-alpha.6 → 6.0.0-alpha.8

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 (209) hide show
  1. package/README.md +2907 -109
  2. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +2 -1
  3. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +1 -1
  4. package/dist/actions/init/bootstrapLocalTemplate.d.ts +13 -0
  5. package/dist/actions/init/bootstrapLocalTemplate.js +136 -0
  6. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -0
  7. package/dist/actions/init/bootstrapRemoteTemplate.d.ts +12 -0
  8. package/dist/actions/init/bootstrapRemoteTemplate.js +109 -0
  9. package/dist/actions/init/bootstrapRemoteTemplate.js.map +1 -0
  10. package/dist/actions/init/bootstrapTemplate.d.ts +18 -0
  11. package/dist/actions/init/bootstrapTemplate.js +32 -0
  12. package/dist/actions/init/bootstrapTemplate.js.map +1 -0
  13. package/dist/actions/init/checkNextJsReactCompatibility.d.ts +9 -0
  14. package/dist/actions/init/checkNextJsReactCompatibility.js +21 -0
  15. package/dist/actions/init/checkNextJsReactCompatibility.js.map +1 -0
  16. package/dist/actions/init/countNestedFolders.d.ts +1 -0
  17. package/dist/actions/init/countNestedFolders.js +6 -0
  18. package/dist/actions/init/countNestedFolders.js.map +1 -0
  19. package/dist/actions/init/createAppCliConfig.d.ts +5 -0
  20. package/dist/actions/init/createAppCliConfig.js +19 -0
  21. package/dist/actions/init/createAppCliConfig.js.map +1 -0
  22. package/dist/actions/init/createCliConfig.d.ts +6 -0
  23. package/dist/actions/init/createCliConfig.js +27 -0
  24. package/dist/actions/init/createCliConfig.js.map +1 -0
  25. package/dist/actions/init/createPackageManifest.d.ts +6 -0
  26. package/dist/actions/init/createPackageManifest.js +86 -0
  27. package/dist/actions/init/createPackageManifest.js.map +1 -0
  28. package/dist/actions/init/createStudioConfig.d.ts +13 -0
  29. package/dist/actions/init/createStudioConfig.js +41 -0
  30. package/dist/actions/init/createStudioConfig.js.map +1 -0
  31. package/dist/actions/init/env/createOrAppendEnvVars.d.ts +12 -0
  32. package/dist/actions/init/env/createOrAppendEnvVars.js +25 -0
  33. package/dist/actions/init/env/createOrAppendEnvVars.js.map +1 -0
  34. package/dist/actions/init/env/parseAndUpdateEnvVars.d.ts +9 -0
  35. package/dist/actions/init/env/parseAndUpdateEnvVars.js +42 -0
  36. package/dist/actions/init/env/parseAndUpdateEnvVars.js.map +1 -0
  37. package/dist/actions/init/env/writeEnvVarsToFile.d.ts +12 -0
  38. package/dist/actions/init/env/writeEnvVarsToFile.js +49 -0
  39. package/dist/actions/init/env/writeEnvVarsToFile.js.map +1 -0
  40. package/dist/actions/init/fetchPostInitPrompt.d.ts +6 -0
  41. package/dist/actions/init/fetchPostInitPrompt.js +30 -0
  42. package/dist/actions/init/fetchPostInitPrompt.js.map +1 -0
  43. package/dist/actions/init/git.d.ts +1 -0
  44. package/dist/actions/init/git.js +65 -0
  45. package/dist/actions/init/git.js.map +1 -0
  46. package/dist/actions/init/processTemplate.d.ts +7 -0
  47. package/dist/actions/init/processTemplate.js +56 -0
  48. package/dist/actions/init/processTemplate.js.map +1 -0
  49. package/dist/actions/init/remoteTemplate.d.ts +0 -3
  50. package/dist/actions/init/remoteTemplate.js +2 -40
  51. package/dist/actions/init/remoteTemplate.js.map +1 -1
  52. package/dist/actions/init/resolvePackageManager.d.ts +10 -0
  53. package/dist/actions/init/resolvePackageManager.js +20 -0
  54. package/dist/actions/init/resolvePackageManager.js.map +1 -0
  55. package/dist/actions/init/setupMCP.d.ts +21 -0
  56. package/dist/actions/init/setupMCP.js +258 -0
  57. package/dist/actions/init/setupMCP.js.map +1 -0
  58. package/dist/actions/init/templates/appQuickstart.d.ts +3 -0
  59. package/dist/actions/init/templates/appQuickstart.js +28 -0
  60. package/dist/actions/init/templates/appQuickstart.js.map +1 -0
  61. package/dist/actions/init/templates/appSanityUi.d.ts +3 -0
  62. package/dist/actions/init/templates/appSanityUi.js +30 -0
  63. package/dist/actions/init/templates/appSanityUi.js.map +1 -0
  64. package/dist/actions/init/templates/blog.d.ts +3 -0
  65. package/dist/actions/init/templates/blog.js +4 -0
  66. package/dist/actions/init/templates/blog.js.map +1 -0
  67. package/dist/actions/init/templates/clean.d.ts +3 -0
  68. package/dist/actions/init/templates/clean.js +4 -0
  69. package/dist/actions/init/templates/clean.js.map +1 -0
  70. package/dist/actions/init/templates/getStarted.d.ts +3 -0
  71. package/dist/actions/init/templates/getStarted.js +35 -0
  72. package/dist/actions/init/templates/getStarted.js.map +1 -0
  73. package/dist/actions/init/templates/index.d.ts +3 -0
  74. package/dist/actions/init/templates/index.js +23 -0
  75. package/dist/actions/init/templates/index.js.map +1 -0
  76. package/dist/actions/init/templates/moviedb.d.ts +3 -0
  77. package/dist/actions/init/templates/moviedb.js +34 -0
  78. package/dist/actions/init/templates/moviedb.js.map +1 -0
  79. package/dist/actions/init/templates/nextjs/index.d.ts +6 -0
  80. package/dist/actions/init/templates/nextjs/index.js +213 -0
  81. package/dist/actions/init/templates/nextjs/index.js.map +1 -0
  82. package/dist/actions/init/templates/nextjs/schemaTypes/blog.d.ts +3 -0
  83. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js +247 -0
  84. package/dist/actions/init/templates/nextjs/schemaTypes/blog.js.map +1 -0
  85. package/dist/actions/init/templates/quickstart.d.ts +3 -0
  86. package/dist/actions/init/templates/quickstart.js +4 -0
  87. package/dist/actions/init/templates/quickstart.js.map +1 -0
  88. package/dist/actions/init/templates/shopify.d.ts +3 -0
  89. package/dist/actions/init/templates/shopify.js +77 -0
  90. package/dist/actions/init/templates/shopify.js.map +1 -0
  91. package/dist/actions/init/templates/shopifyOnline.d.ts +3 -0
  92. package/dist/actions/init/templates/shopifyOnline.js +49 -0
  93. package/dist/actions/init/templates/shopifyOnline.js.map +1 -0
  94. package/dist/actions/init/types.d.ts +15 -0
  95. package/dist/actions/init/types.js +3 -0
  96. package/dist/actions/init/types.js.map +1 -0
  97. package/dist/actions/init/updateInitialTemplateMetadata.d.ts +1 -0
  98. package/dist/actions/init/updateInitialTemplateMetadata.js +17 -0
  99. package/dist/actions/init/updateInitialTemplateMetadata.js.map +1 -0
  100. package/dist/actions/telemetry/resolveConsent.d.ts +1 -9
  101. package/dist/actions/telemetry/resolveConsent.js +2 -2
  102. package/dist/actions/telemetry/resolveConsent.js.map +1 -1
  103. package/dist/actions/telemetry/setConsent.d.ts +1 -4
  104. package/dist/actions/telemetry/setConsent.js +4 -8
  105. package/dist/actions/telemetry/setConsent.js.map +1 -1
  106. package/dist/commands/init.d.ts +24 -14
  107. package/dist/commands/init.js +544 -26
  108. package/dist/commands/init.js.map +1 -1
  109. package/dist/commands/telemetry/disable.js +0 -1
  110. package/dist/commands/telemetry/disable.js.map +1 -1
  111. package/dist/commands/telemetry/enable.js +0 -1
  112. package/dist/commands/telemetry/enable.js.map +1 -1
  113. package/dist/commands/telemetry/status.js +1 -3
  114. package/dist/commands/telemetry/status.js.map +1 -1
  115. package/dist/hooks/prerun/flushTelemetry.worker.d.ts +2 -0
  116. package/dist/hooks/prerun/flushTelemetry.worker.js +22 -0
  117. package/dist/hooks/prerun/flushTelemetry.worker.js.map +1 -0
  118. package/dist/hooks/prerun/setupTelemetry.js +65 -1
  119. package/dist/hooks/prerun/setupTelemetry.js.map +1 -1
  120. package/dist/prompts/init/nextjs.d.ts +5 -0
  121. package/dist/prompts/init/nextjs.js +56 -0
  122. package/dist/prompts/init/nextjs.js.map +1 -0
  123. package/dist/prompts/init/promptForTypescript.d.ts +0 -1
  124. package/dist/prompts/init/promptForTypescript.js +0 -6
  125. package/dist/prompts/init/promptForTypescript.js.map +1 -1
  126. package/dist/services/mcp.d.ts +10 -0
  127. package/dist/services/mcp.js +16 -0
  128. package/dist/services/mcp.js.map +1 -1
  129. package/dist/services/projects.d.ts +5 -2
  130. package/dist/services/projects.js +37 -0
  131. package/dist/services/projects.js.map +1 -1
  132. package/dist/services/telemetry.d.ts +2 -0
  133. package/dist/services/telemetry.js +20 -0
  134. package/dist/services/telemetry.js.map +1 -0
  135. package/dist/studioDependencies.d.ts +16 -0
  136. package/dist/studioDependencies.js +24 -0
  137. package/dist/studioDependencies.js.map +1 -0
  138. package/dist/telemetry/cli.telemetry.d.ts +20 -0
  139. package/dist/telemetry/cli.telemetry.js +8 -0
  140. package/dist/telemetry/cli.telemetry.js.map +1 -0
  141. package/dist/telemetry/store/cleanupOldTelemetryFiles.d.ts +5 -0
  142. package/dist/telemetry/store/cleanupOldTelemetryFiles.js +30 -0
  143. package/dist/telemetry/store/cleanupOldTelemetryFiles.js.map +1 -0
  144. package/dist/telemetry/store/createTelemetryStore.d.ts +39 -0
  145. package/dist/telemetry/store/createTelemetryStore.js +95 -0
  146. package/dist/telemetry/store/createTelemetryStore.js.map +1 -0
  147. package/dist/telemetry/store/createTraceId.d.ts +10 -0
  148. package/dist/telemetry/store/createTraceId.js +10 -0
  149. package/dist/telemetry/store/createTraceId.js.map +1 -0
  150. package/dist/telemetry/store/debug.d.ts +5 -0
  151. package/dist/telemetry/store/debug.js +7 -0
  152. package/dist/telemetry/store/debug.js.map +1 -0
  153. package/dist/telemetry/store/findTelemetryFiles.d.ts +13 -0
  154. package/dist/telemetry/store/findTelemetryFiles.js +34 -0
  155. package/dist/telemetry/store/findTelemetryFiles.js.map +1 -0
  156. package/dist/telemetry/store/flushTelemetryFiles.d.ts +20 -0
  157. package/dist/telemetry/store/flushTelemetryFiles.js +107 -0
  158. package/dist/telemetry/store/flushTelemetryFiles.js.map +1 -0
  159. package/dist/telemetry/store/generateTelemetryFilePath.d.ts +17 -0
  160. package/dist/telemetry/store/generateTelemetryFilePath.js +30 -0
  161. package/dist/telemetry/store/generateTelemetryFilePath.js.map +1 -0
  162. package/dist/telemetry/store/getTelemetryBaseInfo.d.ts +27 -0
  163. package/dist/telemetry/store/getTelemetryBaseInfo.js +34 -0
  164. package/dist/telemetry/store/getTelemetryBaseInfo.js.map +1 -0
  165. package/dist/telemetry/store/logger.d.ts +6 -0
  166. package/dist/telemetry/store/logger.js +54 -0
  167. package/dist/telemetry/store/logger.js.map +1 -0
  168. package/dist/telemetry/store/trace.d.ts +6 -0
  169. package/dist/telemetry/store/trace.js +150 -0
  170. package/dist/telemetry/store/trace.js.map +1 -0
  171. package/dist/telemetry/utils/readNDJSON.d.ts +10 -0
  172. package/dist/telemetry/utils/readNDJSON.js +18 -0
  173. package/dist/telemetry/utils/readNDJSON.js.map +1 -0
  174. package/dist/types.d.ts +33 -0
  175. package/dist/types.js.map +1 -1
  176. package/dist/typings/deepSortObject.d.js +2 -0
  177. package/dist/typings/deepSortObject.d.js.map +1 -0
  178. package/dist/util/copy.d.ts +5 -0
  179. package/dist/util/copy.js +37 -0
  180. package/dist/util/copy.js.map +1 -0
  181. package/dist/util/detectRuntime.d.ts +8 -0
  182. package/dist/util/detectRuntime.js +20 -0
  183. package/dist/util/detectRuntime.js.map +1 -0
  184. package/dist/util/frameworkPort.d.ts +12 -0
  185. package/dist/util/frameworkPort.js +61 -0
  186. package/dist/util/frameworkPort.js.map +1 -0
  187. package/dist/util/fsUtils.d.ts +2 -0
  188. package/dist/util/fsUtils.js +34 -0
  189. package/dist/util/fsUtils.js.map +1 -0
  190. package/dist/util/getProjectDefaults.d.ts +11 -0
  191. package/dist/util/getProjectDefaults.js +77 -0
  192. package/dist/util/getProjectDefaults.js.map +1 -0
  193. package/dist/util/isStaging.d.ts +7 -0
  194. package/dist/util/isStaging.js +10 -0
  195. package/dist/util/isStaging.js.map +1 -0
  196. package/dist/util/packageManager/packageManagerChoice.d.ts +2 -0
  197. package/dist/util/packageManager/packageManagerChoice.js +8 -0
  198. package/dist/util/packageManager/packageManagerChoice.js.map +1 -1
  199. package/dist/util/parseArguments.d.ts +35 -0
  200. package/dist/util/parseArguments.js +42 -0
  201. package/dist/util/parseArguments.js.map +1 -0
  202. package/dist/util/readdirRecursive.d.ts +5 -0
  203. package/dist/util/readdirRecursive.js +24 -0
  204. package/dist/util/readdirRecursive.js.map +1 -0
  205. package/dist/util/resolveLatestVersions.d.ts +7 -0
  206. package/dist/util/resolveLatestVersions.js +21 -0
  207. package/dist/util/resolveLatestVersions.js.map +1 -0
  208. package/oclif.manifest.json +154 -141
  209. package/package.json +26 -14
package/dist/types.d.ts CHANGED
@@ -14,3 +14,36 @@ export interface PackageJson {
14
14
  };
15
15
  scripts?: Record<string, string>;
16
16
  }
17
+ export interface CliApiConfig {
18
+ dataset?: string;
19
+ projectId?: string;
20
+ }
21
+ export interface SanityJson {
22
+ __experimental_spaces?: {
23
+ api: {
24
+ dataset?: string;
25
+ projectId?: string;
26
+ };
27
+ default?: true;
28
+ name: string;
29
+ title: string;
30
+ }[];
31
+ api?: CliApiConfig;
32
+ env?: {
33
+ development?: SanityJson;
34
+ production?: SanityJson;
35
+ staging?: SanityJson;
36
+ };
37
+ parts?: {
38
+ description?: string;
39
+ implements?: string;
40
+ name?: string;
41
+ path?: string;
42
+ }[];
43
+ plugins?: string[];
44
+ project?: {
45
+ basePath?: string;
46
+ name?: string;
47
+ };
48
+ root?: boolean;
49
+ }
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface PackageJson {\n name: string\n version: string\n\n author?: string\n\n dependencies?: Record<string, string>\n description?: string\n devDependencies?: Record<string, string>\n license?: string\n\n peerDependencies?: Record<string, string>\n private?: boolean\n repository?: {type: string; url: string}\n\n scripts?: Record<string, string>\n}\n"],"names":[],"mappings":"AAAA,WAgBC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface PackageJson {\n name: string\n version: string\n\n author?: string\n\n dependencies?: Record<string, string>\n description?: string\n devDependencies?: Record<string, string>\n license?: string\n\n peerDependencies?: Record<string, string>\n private?: boolean\n repository?: {type: string; url: string}\n\n scripts?: Record<string, string>\n}\n\nexport interface CliApiConfig {\n dataset?: string\n projectId?: string\n}\n\nexport interface SanityJson {\n __experimental_spaces?: {\n api: {\n dataset?: string\n projectId?: string\n }\n default?: true\n name: string\n title: string\n }[]\n api?: CliApiConfig\n env?: {\n development?: SanityJson\n production?: SanityJson\n staging?: SanityJson\n }\n parts?: {\n description?: string\n implements?: string\n name?: string\n path?: string\n }[]\n plugins?: string[]\n project?: {\n basePath?: string\n name?: string\n }\n root?: boolean\n}\n"],"names":[],"mappings":"AAuBA,WA4BC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=deepSortObject.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/typings/deepSortObject.d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ interface CopyOptions {
2
+ rename?: (originalName: string) => string;
3
+ }
4
+ export declare function copy(srcPath: string, dstPath: string, options?: CopyOptions): Promise<number>;
5
+ export {};
@@ -0,0 +1,37 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { readdirRecursive } from './readdirRecursive.js';
4
+ export async function copy(srcPath, dstPath, options) {
5
+ const rename = options?.rename;
6
+ const content = (await fs.stat(srcPath)).isDirectory() ? await readdirRecursive(srcPath) : [
7
+ {
8
+ isDir: false,
9
+ path: srcPath
10
+ }
11
+ ];
12
+ const directories = content.filter((entry)=>entry.isDir).toSorted((a, b)=>b.path.length - a.path.length).toSorted((a, b)=>a.path.localeCompare(b.path)).map((entry)=>entry.path);
13
+ for (const subDir of directories){
14
+ const relativePath = path.relative(srcPath, subDir);
15
+ const fullDstPath = path.join(dstPath, relativePath);
16
+ await fs.mkdir(fullDstPath, {
17
+ recursive: true
18
+ });
19
+ }
20
+ const files = content.filter((entry)=>!entry.isDir).toSorted((a, b)=>b.path.length - a.path.length).toSorted((a, b)=>a.path.localeCompare(b.path)).map((entry)=>{
21
+ const relativePath = path.relative(srcPath, entry.path);
22
+ const baseName = path.basename(relativePath);
23
+ const dirName = path.dirname(relativePath);
24
+ const dstName = rename ? rename(baseName) : baseName;
25
+ const fullDstPath = path.join(dstPath, dirName, dstName);
26
+ return {
27
+ from: entry.path,
28
+ to: fullDstPath
29
+ };
30
+ });
31
+ for (const file of files){
32
+ await fs.copyFile(file.from, file.to);
33
+ }
34
+ return files.length;
35
+ }
36
+
37
+ //# sourceMappingURL=copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/copy.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {readdirRecursive} from './readdirRecursive.js'\n\ninterface CopyOptions {\n rename?: (originalName: string) => string\n}\n\nexport async function copy(\n srcPath: string,\n dstPath: string,\n options?: CopyOptions,\n): Promise<number> {\n const rename = options?.rename\n const content = (await fs.stat(srcPath)).isDirectory()\n ? await readdirRecursive(srcPath)\n : [{isDir: false, path: srcPath}]\n\n const directories = content\n .filter((entry) => entry.isDir)\n .toSorted((a, b) => b.path.length - a.path.length)\n .toSorted((a, b) => a.path.localeCompare(b.path))\n .map((entry) => entry.path)\n\n for (const subDir of directories) {\n const relativePath = path.relative(srcPath, subDir)\n const fullDstPath = path.join(dstPath, relativePath)\n await fs.mkdir(fullDstPath, {recursive: true})\n }\n\n const files = content\n .filter((entry) => !entry.isDir)\n .toSorted((a, b) => b.path.length - a.path.length)\n .toSorted((a, b) => a.path.localeCompare(b.path))\n .map((entry) => {\n const relativePath = path.relative(srcPath, entry.path)\n const baseName = path.basename(relativePath)\n const dirName = path.dirname(relativePath)\n const dstName = rename ? rename(baseName) : baseName\n const fullDstPath = path.join(dstPath, dirName, dstName)\n return {from: entry.path, to: fullDstPath}\n })\n\n for (const file of files) {\n await fs.copyFile(file.from, file.to)\n }\n\n return files.length\n}\n"],"names":["fs","path","readdirRecursive","copy","srcPath","dstPath","options","rename","content","stat","isDirectory","isDir","directories","filter","entry","toSorted","a","b","length","localeCompare","map","subDir","relativePath","relative","fullDstPath","join","mkdir","recursive","files","baseName","basename","dirName","dirname","dstName","from","to","file","copyFile"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UA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ACV;QAC7B,MAAMW,UAAU1B,SAASA,OAAOsB,YAAYA;QAC5C,MAAML,cAAcvB,KAAKwB,IAAI,CAACpB,SAAS0B,SAASE;QAChD,OAAO;YAACC,MAAMpB,MAAMb,IAAI;YAAEkC,IAAIX;QAAW;IAC3C;IAEF,KAAK,MAAMY,QAAQR,MAAO;QACxB,MAAM5B,GAAGqC,QAAQ,CAACD,KAAKF,IAAI,EAAEE,KAAKD,EAAE;IACtC;IAEA,OAAOP,MAAMV,MAAM;AACrB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Detect the runtime environment.
3
+ *
4
+ * @returns The runtime environment.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare function detectRuntime(): 'bun' | 'deno' | 'node';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Detect the runtime environment.
3
+ *
4
+ * @returns The runtime environment.
5
+ *
6
+ * @internal
7
+ */ export function detectRuntime() {
8
+ if ('Deno' in globalThis) {
9
+ return 'deno';
10
+ }
11
+ if ('Bun' in globalThis) {
12
+ return 'bun';
13
+ }
14
+ // Consider using a more reliable way of detecting that we're actually in Node.js
15
+ // I first attempted using https://www.npmjs.com/package/is-really-node, but it fails
16
+ // due to using top level await.
17
+ return 'node';
18
+ }
19
+
20
+ //# sourceMappingURL=detectRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/detectRuntime.ts"],"sourcesContent":["/**\n * Detect the runtime environment.\n *\n * @returns The runtime environment.\n *\n * @internal\n */\nexport function detectRuntime(): 'bun' | 'deno' | 'node' {\n if ('Deno' in globalThis) {\n return 'deno'\n }\n if ('Bun' in globalThis) {\n return 'bun'\n }\n // Consider using a more reliable way of detecting that we're actually in Node.js\n // I first attempted using https://www.npmjs.com/package/is-really-node, but it fails\n // due to using top level await.\n return 'node'\n}\n"],"names":["detectRuntime","globalThis"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,SAASA;IACd,IAAI,UAAUC,YAAY;QACxB,OAAO;IACT;IACA,IAAI,SAASA,YAAY;QACvB,OAAO;IACT;IACA,iFAAiF;IACjF,qFAAqF;IACrF,gCAAgC;IAChC,OAAO;AACT"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the default development port for a given framework.
3
+ * Contains default ports for all frameworks supported by `@vercel/frameworks`.
4
+ * Falls back to port 3000 if framework is not found or not specified.
5
+ *
6
+ * @see https://github.com/vercel/vercel/blob/main/packages/frameworks/src/frameworks.ts
7
+ * for the complete list of supported frameworks
8
+ *
9
+ * @param frameworkSlug - The framework identifier from `@vercel/frameworks`
10
+ * @returns The default port number for the framework
11
+ */
12
+ export declare function getDefaultPortForFramework(frameworkSlug?: string | null): number;
@@ -0,0 +1,61 @@
1
+ const FALLBACK_PORT = 3000;
2
+ const portMap = {
3
+ angular: 4200,
4
+ astro: 4321,
5
+ blitzjs: 3000,
6
+ brunch: 3333,
7
+ 'create-react-app': 3000,
8
+ docusaurus: 3000,
9
+ 'docusaurus-2': 3000,
10
+ dojo: 3000,
11
+ eleventy: 8080,
12
+ ember: 4200,
13
+ fasthtml: 8000,
14
+ gatsby: 8000,
15
+ gridsome: 8080,
16
+ hexo: 4000,
17
+ hugo: 1313,
18
+ hydrogen: 3000,
19
+ 'ionic-angular': 4200,
20
+ 'ionic-react': 3000,
21
+ jekyll: 4000,
22
+ middleman: 4567,
23
+ nextjs: 3000,
24
+ nuxtjs: 3000,
25
+ parcel: 1234,
26
+ polymer: 8081,
27
+ preact: 8080,
28
+ redwoodjs: 8910,
29
+ remix: 3000,
30
+ saber: 3000,
31
+ sanity: 3333,
32
+ scully: 1668,
33
+ solidstart: 3000,
34
+ 'solidstart-1': 3000,
35
+ stencil: 3333,
36
+ storybook: 6006,
37
+ svelte: 5000,
38
+ sveltekit: 5173,
39
+ 'sveltekit-1': 5173,
40
+ umijs: 8000,
41
+ vite: 5173,
42
+ vitepress: 5173,
43
+ vue: 8080,
44
+ vuepress: 8080,
45
+ zola: 1111
46
+ };
47
+ /**
48
+ * Returns the default development port for a given framework.
49
+ * Contains default ports for all frameworks supported by `@vercel/frameworks`.
50
+ * Falls back to port 3000 if framework is not found or not specified.
51
+ *
52
+ * @see https://github.com/vercel/vercel/blob/main/packages/frameworks/src/frameworks.ts
53
+ * for the complete list of supported frameworks
54
+ *
55
+ * @param frameworkSlug - The framework identifier from `@vercel/frameworks`
56
+ * @returns The default port number for the framework
57
+ */ export function getDefaultPortForFramework(frameworkSlug) {
58
+ return portMap[frameworkSlug ?? ''] ?? FALLBACK_PORT;
59
+ }
60
+
61
+ //# sourceMappingURL=frameworkPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/frameworkPort.ts"],"sourcesContent":["const FALLBACK_PORT = 3000\n\nconst portMap: Record<string, number> = {\n angular: 4200,\n astro: 4321,\n blitzjs: 3000,\n brunch: 3333,\n 'create-react-app': 3000,\n docusaurus: 3000,\n 'docusaurus-2': 3000,\n dojo: 3000,\n eleventy: 8080,\n ember: 4200,\n fasthtml: 8000,\n gatsby: 8000,\n gridsome: 8080,\n hexo: 4000,\n hugo: 1313,\n hydrogen: 3000,\n 'ionic-angular': 4200,\n 'ionic-react': 3000,\n jekyll: 4000,\n middleman: 4567,\n nextjs: 3000,\n nuxtjs: 3000,\n parcel: 1234,\n polymer: 8081,\n preact: 8080,\n redwoodjs: 8910,\n remix: 3000,\n saber: 3000,\n sanity: 3333,\n scully: 1668,\n solidstart: 3000,\n 'solidstart-1': 3000,\n stencil: 3333,\n storybook: 6006,\n svelte: 5000,\n sveltekit: 5173,\n 'sveltekit-1': 5173,\n umijs: 8000,\n vite: 5173,\n vitepress: 5173,\n vue: 8080,\n vuepress: 8080,\n zola: 1111,\n}\n\n/**\n * Returns the default development port for a given framework.\n * Contains default ports for all frameworks supported by `@vercel/frameworks`.\n * Falls back to port 3000 if framework is not found or not specified.\n *\n * @see https://github.com/vercel/vercel/blob/main/packages/frameworks/src/frameworks.ts\n * for the complete list of supported frameworks\n *\n * @param frameworkSlug - The framework identifier from `@vercel/frameworks`\n * @returns The default port number for the framework\n */\nexport function getDefaultPortForFramework(frameworkSlug?: string | null): number {\n return portMap[frameworkSlug ?? ''] ?? FALLBACK_PORT\n}\n"],"names":["FALLBACK_PORT","portMap","angular","astro","blitzjs","brunch","docusaurus","dojo","eleventy","ember","fasthtml","gatsby","gridsome","hexo","hugo","hydrogen","jekyll","middleman","nextjs","nuxtjs","parcel","polymer","preact","redwoodjs","remix","saber","sanity","scully","solidstart","stencil","storybook","svelte","sveltekit","umijs","vite","vitepress","vue","vuepress","zola","getDefaultPortForFramework","frameworkSlug"],"mappings":"AAAA,MAAMA,gBAAgB;AAEtB,MAAMC,UAAkC;IACtCC,SAAS;IACTC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACR,oBAAoB;IACpBC,YAAY;IACZ,gBAAgB;IAChBC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,QAAQ;IACRC,UAAU;IACVC,MAAM;IACNC,MAAM;IACNC,UAAU;IACV,iBAAiB;IACjB,eAAe;IACfC,QAAQ;IACRC,WAAW;IACXC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,SAAS;IACTC,QAAQ;IACRC,WAAW;IACXC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACRC,QAAQ;IACRC,YAAY;IACZ,gBAAgB;IAChBC,SAAS;IACTC,WAAW;IACXC,QAAQ;IACRC,WAAW;IACX,eAAe;IACfC,OAAO;IACPC,MAAM;IACNC,WAAW;IACXC,KAAK;IACLC,UAAU;IACVC,MAAM;AACR;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASC,2BAA2BC,aAA6B;IACtE,OAAOvC,OAAO,CAACuC,iBAAiB,GAAG,IAAIxC;AACzC"}
@@ -0,0 +1,2 @@
1
+ export declare function validateEmptyPath(dir: string): string | true;
2
+ export declare function absolutify(dir: string): string;
@@ -0,0 +1,34 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ export function validateEmptyPath(dir) {
5
+ const checkPath = absolutify(dir);
6
+ return pathIsEmpty(checkPath) ? true : 'Given path is not empty';
7
+ }
8
+ export function absolutify(dir) {
9
+ const pathName = expandHome(dir);
10
+ return path.isAbsolute(pathName) ? pathName : path.resolve(process.cwd(), pathName);
11
+ }
12
+ function pathIsEmpty(dir) {
13
+ try {
14
+ const content = fs.readdirSync(dir);
15
+ return content.length === 0;
16
+ } catch (err) {
17
+ if (err.code === 'ENOENT') {
18
+ return true;
19
+ }
20
+ throw err;
21
+ }
22
+ }
23
+ function expandHome(filePath) {
24
+ if (filePath.codePointAt(0) === 126 /* ~ */ ) {
25
+ if (filePath.codePointAt(1) === 43 /* + */ ) {
26
+ return path.join(process.cwd(), filePath.slice(2));
27
+ }
28
+ const home = os.homedir();
29
+ return home ? path.join(home, filePath.slice(1)) : filePath;
30
+ }
31
+ return filePath;
32
+ }
33
+
34
+ //# sourceMappingURL=fsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/fsUtils.ts"],"sourcesContent":["import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nexport function validateEmptyPath(dir: string): string | true {\n const checkPath = absolutify(dir)\n return pathIsEmpty(checkPath) ? true : 'Given path is not empty'\n}\n\nexport function absolutify(dir: string): string {\n const pathName = expandHome(dir)\n return path.isAbsolute(pathName) ? pathName : path.resolve(process.cwd(), pathName)\n}\n\nfunction pathIsEmpty(dir: string): boolean {\n try {\n const content = fs.readdirSync(dir)\n return content.length === 0\n } catch (err) {\n if (err.code === 'ENOENT') {\n return true\n }\n\n throw err\n }\n}\n\nfunction expandHome(filePath: string): string {\n if (filePath.codePointAt(0) === 126 /* ~ */) {\n if (filePath.codePointAt(1) === 43 /* + */) {\n return path.join(process.cwd(), filePath.slice(2))\n }\n\n const home = os.homedir()\n return home ? path.join(home, filePath.slice(1)) : filePath\n }\n\n return filePath\n}\n"],"names":["fs","os","path","validateEmptyPath","dir","checkPath","absolutify","pathIsEmpty","pathName","expandHome","isAbsolute","resolve","process","cwd","content","readdirSync","length","err","code","filePath","codePointAt","join","slice","home","homedir"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,OAAO,SAASC,kBAAkBC,GAAW;IAC3C,MAAMC,YAAYC,WAAWF;IAC7B,OAAOG,YAAYF,aAAa,OAAO;AACzC;AAEA,OAAO,SAASC,WAAWF,GAAW;IACpC,MAAMI,WAAWC,WAAWL;IAC5B,OAAOF,KAAKQ,UAAU,CAACF,YAAYA,WAAWN,KAAKS,OAAO,CAACC,QAAQC,GAAG,IAAIL;AAC5E;AAEA,SAASD,YAAYH,GAAW;IAC9B,IAAI;QACF,MAAMU,UAAUd,GAAGe,WAAW,CAACX;QAC/B,OAAOU,QAAQE,MAAM,KAAK;IAC5B,EAAE,OAAOC,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,OAAO;QACT;QAEA,MAAMD;IACR;AACF;AAEA,SAASR,WAAWU,QAAgB;IAClC,IAAIA,SAASC,WAAW,CAAC,OAAO,IAAI,KAAK,KAAI;QAC3C,IAAID,SAASC,WAAW,CAAC,OAAO,GAAG,KAAK,KAAI;YAC1C,OAAOlB,KAAKmB,IAAI,CAACT,QAAQC,GAAG,IAAIM,SAASG,KAAK,CAAC;QACjD;QAEA,MAAMC,OAAOtB,GAAGuB,OAAO;QACvB,OAAOD,OAAOrB,KAAKmB,IAAI,CAACE,MAAMJ,SAASG,KAAK,CAAC,MAAMH;IACrD;IAEA,OAAOA;AACT"}
@@ -0,0 +1,11 @@
1
+ export interface ProjectDefaults {
2
+ author: string | undefined;
3
+ description: string;
4
+ gitRemote: string;
5
+ license: string;
6
+ projectName: string;
7
+ }
8
+ export declare function getProjectDefaults({ isPlugin, workDir, }: {
9
+ isPlugin: boolean;
10
+ workDir: string;
11
+ }): Promise<ProjectDefaults>;
@@ -0,0 +1,77 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import getGitConfig from '@rexxars/gitconfiglocal';
4
+ import { getCliToken, subdebug } from '@sanity/cli-core';
5
+ import { getGitUserInfo } from 'git-user-info';
6
+ import promiseProps from 'promise-props-recursive';
7
+ import { getCliUser } from '../services/user.js';
8
+ const debug = subdebug('getProjectDefaults');
9
+ export function getProjectDefaults({ isPlugin, workDir }) {
10
+ const cwd = process.cwd();
11
+ const isSanityRoot = workDir === cwd;
12
+ return promiseProps({
13
+ license: 'UNLICENSED',
14
+ author: getUserInfo(),
15
+ // Don't try to use git remote from main Sanity project for plugins
16
+ gitRemote: isPlugin && isSanityRoot ? '' : resolveGitRemote(cwd),
17
+ // Don't try to guess plugin name if we're initing from Sanity root
18
+ projectName: isPlugin && isSanityRoot ? '' : path.basename(cwd),
19
+ // If we're initing a plugin, don't use description from Sanity readme
20
+ description: getProjectDescription({
21
+ isPlugin,
22
+ isSanityRoot,
23
+ outputDir: cwd
24
+ })
25
+ });
26
+ }
27
+ async function resolveGitRemote(cwd) {
28
+ try {
29
+ await fs.stat(path.join(cwd, '.git'));
30
+ const cfg = await getGitConfig(cwd);
31
+ return cfg.remote && cfg.remote.origin && cfg.remote.origin.url;
32
+ } catch {
33
+ return undefined;
34
+ }
35
+ }
36
+ async function getUserInfo() {
37
+ const user = await getGitUserInfo();
38
+ if (!user) {
39
+ return getSanityUserInfo();
40
+ }
41
+ if (user.name && user.email) {
42
+ return `${user.name} <${user.email}>`;
43
+ }
44
+ return undefined;
45
+ }
46
+ async function getSanityUserInfo() {
47
+ const hasToken = Boolean(getCliToken());
48
+ if (!hasToken) {
49
+ return undefined;
50
+ }
51
+ try {
52
+ const user = await getCliUser();
53
+ return user ? `${user.name} <${user.email}>` : undefined;
54
+ } catch {
55
+ return undefined;
56
+ }
57
+ }
58
+ async function getProjectDescription({ isPlugin, isSanityRoot, outputDir }) {
59
+ const tryResolve = isSanityRoot && !isPlugin;
60
+ if (!tryResolve) {
61
+ return '';
62
+ }
63
+ // Try to grab a project description from a standard GitHub-generated readme
64
+ try {
65
+ const readmePath = path.join(outputDir, 'README.md');
66
+ const readme = await fs.readFile(readmePath, {
67
+ encoding: 'utf8'
68
+ });
69
+ const match = readme.match(/^# .*?\n+(\w.*?)(?:$|\n)/);
70
+ return (match && match[1] || '').replace(/\.$/, '') || '';
71
+ } catch (err) {
72
+ debug(`Error getting project description: ${err}`);
73
+ return '';
74
+ }
75
+ }
76
+
77
+ //# sourceMappingURL=getProjectDefaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/getProjectDefaults.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport getGitConfig from '@rexxars/gitconfiglocal'\nimport {getCliToken, subdebug} from '@sanity/cli-core'\nimport {getGitUserInfo} from 'git-user-info'\nimport promiseProps from 'promise-props-recursive'\n\nimport {getCliUser} from '../services/user.js'\n\nconst debug = subdebug('getProjectDefaults')\n\nexport interface ProjectDefaults {\n author: string | undefined\n description: string\n gitRemote: string\n license: string\n projectName: string\n}\n\nexport function getProjectDefaults({\n isPlugin,\n workDir,\n}: {\n isPlugin: boolean\n workDir: string\n}): Promise<ProjectDefaults> {\n const cwd = process.cwd()\n const isSanityRoot = workDir === cwd\n\n return promiseProps({\n license: 'UNLICENSED',\n\n author: getUserInfo(),\n\n // Don't try to use git remote from main Sanity project for plugins\n gitRemote: isPlugin && isSanityRoot ? '' : resolveGitRemote(cwd),\n\n // Don't try to guess plugin name if we're initing from Sanity root\n projectName: isPlugin && isSanityRoot ? '' : path.basename(cwd),\n\n // If we're initing a plugin, don't use description from Sanity readme\n description: getProjectDescription({isPlugin, isSanityRoot, outputDir: cwd}),\n })\n}\n\nasync function resolveGitRemote(cwd: string): Promise<string | undefined> {\n try {\n await fs.stat(path.join(cwd, '.git'))\n const cfg = await getGitConfig(cwd)\n return cfg.remote && cfg.remote.origin && cfg.remote.origin.url\n } catch {\n return undefined\n }\n}\n\nasync function getUserInfo(): Promise<string | undefined> {\n const user = await getGitUserInfo()\n if (!user) {\n return getSanityUserInfo()\n }\n\n if (user.name && user.email) {\n return `${user.name} <${user.email}>`\n }\n\n return undefined\n}\n\nasync function getSanityUserInfo(): Promise<string | undefined> {\n const hasToken = Boolean(getCliToken())\n if (!hasToken) {\n return undefined\n }\n\n try {\n const user = await getCliUser()\n return user ? `${user.name} <${user.email}>` : undefined\n } catch {\n return undefined\n }\n}\n\nasync function getProjectDescription({\n isPlugin,\n isSanityRoot,\n outputDir,\n}: {\n isPlugin: boolean\n isSanityRoot: boolean\n outputDir: string\n}): Promise<string> {\n const tryResolve = isSanityRoot && !isPlugin\n if (!tryResolve) {\n return ''\n }\n\n // Try to grab a project description from a standard GitHub-generated readme\n try {\n const readmePath = path.join(outputDir, 'README.md')\n const readme = await fs.readFile(readmePath, {encoding: 'utf8'})\n const match = readme.match(/^# .*?\\n+(\\w.*?)(?:$|\\n)/)\n return ((match && match[1]) || '').replace(/\\.$/, '') || ''\n } catch (err) {\n debug(`Error getting project description: ${err}`)\n return ''\n }\n}\n"],"names":["fs","path","getGitConfig","getCliToken","subdebug","getGitUserInfo","promiseProps","getCliUser","debug","getProjectDefaults","isPlugin","workDir","cwd","process","isSanityRoot","license","author","getUserInfo","gitRemote","resolveGitRemote","projectName","basename","description","getProjectDescription","outputDir","stat","join","cfg","remote","origin","url","undefined","user","getSanityUserInfo","name","email","hasToken","Boolean","tryResolve","readmePath","readme","readFile","encoding","match","replace","err"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAE5B,OAAOC,kBAAkB,0BAAyB;AAClD,SAAQC,WAAW,EAAEC,QAAQ,QAAO,mBAAkB;AACtD,SAAQC,cAAc,QAAO,gBAAe;AAC5C,OAAOC,kBAAkB,0BAAyB;AAElD,SAAQC,UAAU,QAAO,sBAAqB;AAE9C,MAAMC,QAAQJ,SAAS;AAUvB,OAAO,SAASK,mBAAmB,EACjCC,QAAQ,EACRC,OAAO,EAIR;IAC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;QACf,OAAO;IACT;IAEA,4EAA4E;IAC5E,IAAI;QACF,MAAMC,aAAatC,KAAKyB,IAAI,CAACF,WAAW;QACxC,MAAMgB,SAAS,MAAMxC,GAAGyC,QAAQ,CAACF,YAAY;YAACG,UAAU;QAAM;QAC9D,MAAMC,QAAQH,OAAOG,KAAK,CAAC;QAC3B,OAAO,AAAC,CAAA,AAACA,SAASA,KAAK,CAAC,EAAE,IAAK,EAAC,EAAGC,OAAO,CAAC,OAAO,OAAO;IAC3D,EAAE,OAAOC,KAAK;QACZrC,MAAM,CAAC,mCAAmC,EAAEqC,KAAK;QACjD,OAAO;IACT;AACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Checks if the environment is staging.
3
+ *
4
+ * @returns True if the environment is staging, false otherwise
5
+ * @internal
6
+ */
7
+ export declare function isStaging(): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks if the environment is staging.
3
+ *
4
+ * @returns True if the environment is staging, false otherwise
5
+ * @internal
6
+ */ export function isStaging() {
7
+ return process.env.SANITY_INTERNAL_ENV === 'staging';
8
+ }
9
+
10
+ //# sourceMappingURL=isStaging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/isStaging.ts"],"sourcesContent":["/**\n * Checks if the environment is staging.\n *\n * @returns True if the environment is staging, false otherwise\n * @internal\n */\nexport function isStaging(): boolean {\n return process.env.SANITY_INTERNAL_ENV === 'staging'\n}\n"],"names":["isStaging","process","env","SANITY_INTERNAL_ENV"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA;IACd,OAAOC,QAAQC,GAAG,CAACC,mBAAmB,KAAK;AAC7C"}
@@ -1,4 +1,6 @@
1
1
  export type PackageManager = 'bun' | 'manual' | 'npm' | 'pnpm' | 'yarn';
2
+ export declare const ALLOWED_PACKAGE_MANAGERS: readonly PackageManager[];
3
+ export declare const allowedPackageManagersString: string;
2
4
  /**
3
5
  * Attempts to resolve the most optimal package manager to use to install/upgrade
4
6
  * packages/dependencies at a given path. It does so by looking for package manager
@@ -7,6 +7,14 @@ import which from 'which';
7
7
  const EXPERIMENTAL = new Set([
8
8
  'bun'
9
9
  ]);
10
+ export const ALLOWED_PACKAGE_MANAGERS = [
11
+ 'npm',
12
+ 'yarn',
13
+ 'pnpm',
14
+ 'bun',
15
+ 'manual'
16
+ ];
17
+ export const allowedPackageManagersString = ALLOWED_PACKAGE_MANAGERS.join(' | ');
10
18
  /**
11
19
  * Attempts to resolve the most optimal package manager to use to install/upgrade
12
20
  * packages/dependencies at a given path. It does so by looking for package manager
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/util/packageManager/packageManagerChoice.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {isInteractive} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n// eslint-disable-next-line unicorn/no-named-default\nimport {default as preferredPM} from 'preferred-pm'\nimport which from 'which'\n\nexport type PackageManager = 'bun' | 'manual' | 'npm' | 'pnpm' | 'yarn'\n\nconst EXPERIMENTAL = new Set(['bun'])\n\n/**\n * Attempts to resolve the most optimal package manager to use to install/upgrade\n * packages/dependencies at a given path. It does so by looking for package manager\n * specific lockfiles. If it finds a lockfile belonging to a certain package manager,\n * it prioritizes this one. However, if that package manager is not installed, it will\n * prompt the user for which one they want to use and hint at the most optimal one\n * not being installed.\n *\n * Note that this function also takes local npm binary paths into account - for instance,\n * `yarn` can be installed as a dependency of the project instead of globally, and it\n * will use that is available.\n *\n * The user can also select 'manual' to skip the process and run their preferred package\n * manager manually. Commands using this function must take this `manual` choice into\n * account and act accordingly if chosen.\n *\n * @param workDir - The working directory where a lockfile is most likely to be present\n * @param options - Pass `interactive: false` to fall back to npm if most optimal is\n * not available, instead of prompting\n * @returns Object of `chosen` and, if a lockfile is found, the `mostOptimal` choice\n */\nexport async function getPackageManagerChoice(\n workDir: string,\n options: {interactive: boolean},\n): Promise<{chosen: PackageManager; mostOptimal?: PackageManager}> {\n const rootDir = workDir || process.cwd()\n const preferred = (await preferredPM(rootDir))?.name\n\n if (preferred && (await hasCommand(preferred, rootDir))) {\n // There is an optimal/preferred package manager, and the user has it installed!\n return {chosen: preferred, mostOptimal: preferred}\n }\n\n const mostLikelyPM = await getMostLikelyInstalledPackageManager(rootDir)\n const interactive =\n typeof options.interactive === 'boolean' ? options.interactive : isInteractive()\n if (!interactive) {\n // We can't ask the user for their preference, so fall back to either the one that is being run\n // or whatever is installed on the system (npm being the preferred choice).\n // Note that the most optimal choice is already picked above if available.\n return {chosen: mostLikelyPM || (await getFallback(rootDir)), mostOptimal: preferred}\n }\n\n // We can ask the user for their preference, hurray!\n const messageSuffix = preferred ? ` (preferred is ${preferred}, but is not installed)` : ''\n const installed = await getAvailablePackageManagers(rootDir)\n const chosen = await select<PackageManager>({\n choices: installed.map((pm) => ({\n name: EXPERIMENTAL.has(pm) ? `${pm} (experimental)` : pm,\n value: pm,\n })),\n default: preferred || mostLikelyPM,\n message: `Package manager to use for installing dependencies?${messageSuffix}`,\n })\n\n return {chosen, mostOptimal: preferred}\n}\n\nasync function getFallback(cwd: string): Promise<PackageManager> {\n if (await hasNpmInstalled(cwd)) {\n return 'npm'\n }\n\n if (await hasYarnInstalled(cwd)) {\n return 'yarn'\n }\n\n if (await hasPnpmInstalled(cwd)) {\n return 'pnpm'\n }\n\n if (await hasBunInstalled(cwd)) {\n return 'bun'\n }\n\n return 'manual'\n}\n\nasync function getAvailablePackageManagers(cwd: string): Promise<PackageManager[]> {\n const [npm, yarn, pnpm, bun] = await Promise.all([\n hasNpmInstalled(cwd),\n hasYarnInstalled(cwd),\n hasPnpmInstalled(cwd),\n hasBunInstalled(cwd),\n ])\n\n const choices = [npm && 'npm', yarn && 'yarn', pnpm && 'pnpm', bun && 'bun', 'manual']\n return choices.filter((pm): pm is PackageManager => pm !== false)\n}\n\nfunction hasNpmInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('npm', cwd)\n}\n\nfunction hasYarnInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('yarn', cwd)\n}\n\nfunction hasPnpmInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('pnpm', cwd)\n}\n\nfunction hasBunInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('bun', cwd)\n}\n\nfunction getNpmRunPath(cwd: string): string {\n let previous\n let cwdPath = path.resolve(cwd)\n const result: string[] = []\n\n while (previous !== cwdPath) {\n result.push(path.join(cwdPath, 'node_modules', '.bin'))\n previous = cwdPath\n cwdPath = path.resolve(cwdPath, '..')\n }\n\n result.push(path.resolve(cwd, process.execPath, '..'))\n\n const pathEnv = process.env[getPathEnvVarKey()]\n return [...result, pathEnv].join(path.delimiter)\n}\n\nexport function getPartialEnvWithNpmPath(cwd: string): NodeJS.ProcessEnv {\n const key = getPathEnvVarKey()\n return {[key]: getNpmRunPath(cwd)}\n}\n\nfunction getPathEnvVarKey(): string {\n if (process.platform !== 'win32') {\n return 'PATH'\n }\n\n return (\n Object.keys(process.env)\n .toReversed()\n .find((key) => key.toUpperCase() === 'PATH') || 'Path'\n )\n}\n\nfunction getCommandPath(cmd: string, cwd?: string): Promise<string | null> {\n const options = cwd ? {path: getNpmRunPath(cwd)} : undefined\n return which(cmd, options).catch(() => null)\n}\n\nfunction hasCommand(cmd: string, cwd?: string): Promise<boolean> {\n return getCommandPath(cmd, cwd).then((cmdPath) => cmdPath !== null)\n}\n\nasync function getMostLikelyInstalledPackageManager(\n rootDir: string,\n): Promise<PackageManager | undefined> {\n const installed = await getAvailablePackageManagers(rootDir)\n const running = getRunningPackageManager()\n return running && installed.includes(running) ? running : undefined\n}\n\nfunction getRunningPackageManager(): PackageManager | undefined {\n // Yes, the env var is lowercase - it is set by the package managers themselves\n const agent = process.env.npm_config_user_agent || ''\n\n if (agent.includes('yarn')) {\n return 'yarn'\n }\n\n if (agent.includes('pnpm')) {\n return 'pnpm'\n }\n\n if (agent.includes('bun')) {\n return 'bun'\n }\n\n // Both yarn and pnpm does a `npm/?` thing, thus the slightly different match here\n // Theoretically not needed since we check for yarn/pnpm above, but in case other\n // package managers do the same thing, we'll (hopefully) catch them here.\n if (/^npm\\/\\d/.test(agent)) {\n return 'npm'\n }\n\n return undefined\n}\n"],"names":["path","isInteractive","select","default","preferredPM","which","EXPERIMENTAL","Set","getPackageManagerChoice","workDir","options","rootDir","process","cwd","preferred","name","hasCommand","chosen","mostOptimal","mostLikelyPM","getMostLikelyInstalledPackageManager","interactive","getFallback","messageSuffix","installed","getAvailablePackageManagers","choices","map","pm","has","value","message","hasNpmInstalled","hasYarnInstalled","hasPnpmInstalled","hasBunInstalled","npm","yarn","pnpm","bun","Promise","all","filter","getNpmRunPath","previous","cwdPath","resolve","result","push","join","execPath","pathEnv","env","getPathEnvVarKey","delimiter","getPartialEnvWithNpmPath","key","platform","Object","keys","toReversed","find","toUpperCase","getCommandPath","cmd","undefined","catch","then","cmdPath","running","getRunningPackageManager","includes","agent","npm_config_user_agent","test"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,MAAM,QAAO,sBAAqB;AAC1C,oDAAoD;AACpD,SAAQC,WAAWC,WAAW,QAAO,eAAc;AACnD,OAAOC,WAAW,QAAO;AAIzB,MAAMC,eAAe,IAAIC,IAAI;IAAC;CAAM;AAEpC;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,eAAeC,wBACpBC,OAAe,EACfC,OAA+B;IAE/B,MAAMC,UAAUF,WAAWG,QAAQC,GAAG;IACtC,MAAMC,YAAa,CAAA,MAAMV,YAAYO,QAAO,GAAII;IAEhD,IAAID,aAAc,MAAME,WAAWF,WAAWH,UAAW;QACvD,gFAAgF;QAChF,OAAO;YAACM,QAAQH;YAAWI,aAAaJ;QAAS;IACnD;IAEA,MAAMK,eAAe,MAAMC,qCAAqCT;IAChE,MAAMU,cACJ,OAAOX,QAAQW,WAAW,KAAK,YAAYX,QAAQW,WAAW,GAAGpB;IACnE,IAAI,CAACoB,aAAa;QAChB,+FAA+F;QAC/F,2EAA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eAAehD,qCACbT,OAAe;IAEf,MAAMa,YAAY,MAAMC,4BAA4Bd;IACpD,MAAM0D,UAAUC;IAChB,OAAOD,WAAW7C,UAAU+C,QAAQ,CAACF,WAAWA,UAAUJ;AAC5D;AAEA,SAASK;IACP,+EAA+E;IAC/E,MAAME,QAAQ5D,QAAQwC,GAAG,CAACqB,qBAAqB,IAAI;IAEnD,IAAID,MAAMD,QAAQ,CAAC,SAAS;QAC1B,OAAO;IACT;IAEA,IAAIC,MAAMD,QAAQ,CAAC,SAAS;QAC1B,OAAO;IACT;IAEA,IAAIC,MAAMD,QAAQ,CAAC,QAAQ;QACzB,OAAO;IACT;IAEA,kFAAkF;IAClF,iFAAiF;IACjF,yEAAyE;IACzE,IAAI,WAAWG,IAAI,CAACF,QAAQ;QAC1B,OAAO;IACT;IAEA,OAAOP;AACT"}
1
+ {"version":3,"sources":["../../../src/util/packageManager/packageManagerChoice.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {isInteractive} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n// eslint-disable-next-line unicorn/no-named-default\nimport {default as preferredPM} from 'preferred-pm'\nimport which from 'which'\n\nexport type PackageManager = 'bun' | 'manual' | 'npm' | 'pnpm' | 'yarn'\n\nconst EXPERIMENTAL = new Set(['bun'])\n\nexport const ALLOWED_PACKAGE_MANAGERS: readonly PackageManager[] = [\n 'npm',\n 'yarn',\n 'pnpm',\n 'bun',\n 'manual',\n] as const\n\nexport const allowedPackageManagersString = ALLOWED_PACKAGE_MANAGERS.join(' | ')\n\n/**\n * Attempts to resolve the most optimal package manager to use to install/upgrade\n * packages/dependencies at a given path. It does so by looking for package manager\n * specific lockfiles. If it finds a lockfile belonging to a certain package manager,\n * it prioritizes this one. However, if that package manager is not installed, it will\n * prompt the user for which one they want to use and hint at the most optimal one\n * not being installed.\n *\n * Note that this function also takes local npm binary paths into account - for instance,\n * `yarn` can be installed as a dependency of the project instead of globally, and it\n * will use that is available.\n *\n * The user can also select 'manual' to skip the process and run their preferred package\n * manager manually. Commands using this function must take this `manual` choice into\n * account and act accordingly if chosen.\n *\n * @param workDir - The working directory where a lockfile is most likely to be present\n * @param options - Pass `interactive: false` to fall back to npm if most optimal is\n * not available, instead of prompting\n * @returns Object of `chosen` and, if a lockfile is found, the `mostOptimal` choice\n */\nexport async function getPackageManagerChoice(\n workDir: string,\n options: {interactive: boolean},\n): Promise<{chosen: PackageManager; mostOptimal?: PackageManager}> {\n const rootDir = workDir || process.cwd()\n const preferred = (await preferredPM(rootDir))?.name\n\n if (preferred && (await hasCommand(preferred, rootDir))) {\n // There is an optimal/preferred package manager, and the user has it installed!\n return {chosen: preferred, mostOptimal: preferred}\n }\n\n const mostLikelyPM = await getMostLikelyInstalledPackageManager(rootDir)\n const interactive =\n typeof options.interactive === 'boolean' ? options.interactive : isInteractive()\n if (!interactive) {\n // We can't ask the user for their preference, so fall back to either the one that is being run\n // or whatever is installed on the system (npm being the preferred choice).\n // Note that the most optimal choice is already picked above if available.\n return {chosen: mostLikelyPM || (await getFallback(rootDir)), mostOptimal: preferred}\n }\n\n // We can ask the user for their preference, hurray!\n const messageSuffix = preferred ? ` (preferred is ${preferred}, but is not installed)` : ''\n const installed = await getAvailablePackageManagers(rootDir)\n const chosen = await select<PackageManager>({\n choices: installed.map((pm) => ({\n name: EXPERIMENTAL.has(pm) ? `${pm} (experimental)` : pm,\n value: pm,\n })),\n default: preferred || mostLikelyPM,\n message: `Package manager to use for installing dependencies?${messageSuffix}`,\n })\n\n return {chosen, mostOptimal: preferred}\n}\n\nasync function getFallback(cwd: string): Promise<PackageManager> {\n if (await hasNpmInstalled(cwd)) {\n return 'npm'\n }\n\n if (await hasYarnInstalled(cwd)) {\n return 'yarn'\n }\n\n if (await hasPnpmInstalled(cwd)) {\n return 'pnpm'\n }\n\n if (await hasBunInstalled(cwd)) {\n return 'bun'\n }\n\n return 'manual'\n}\n\nasync function getAvailablePackageManagers(cwd: string): Promise<PackageManager[]> {\n const [npm, yarn, pnpm, bun] = await Promise.all([\n hasNpmInstalled(cwd),\n hasYarnInstalled(cwd),\n hasPnpmInstalled(cwd),\n hasBunInstalled(cwd),\n ])\n\n const choices = [npm && 'npm', yarn && 'yarn', pnpm && 'pnpm', bun && 'bun', 'manual']\n return choices.filter((pm): pm is PackageManager => pm !== false)\n}\n\nfunction hasNpmInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('npm', cwd)\n}\n\nfunction hasYarnInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('yarn', cwd)\n}\n\nfunction hasPnpmInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('pnpm', cwd)\n}\n\nfunction hasBunInstalled(cwd?: string): Promise<boolean> {\n return hasCommand('bun', cwd)\n}\n\nfunction getNpmRunPath(cwd: string): string {\n let previous\n let cwdPath = path.resolve(cwd)\n const result: string[] = []\n\n while (previous !== cwdPath) {\n result.push(path.join(cwdPath, 'node_modules', '.bin'))\n previous = cwdPath\n cwdPath = path.resolve(cwdPath, '..')\n }\n\n result.push(path.resolve(cwd, process.execPath, '..'))\n\n const pathEnv = process.env[getPathEnvVarKey()]\n return [...result, pathEnv].join(path.delimiter)\n}\n\nexport function getPartialEnvWithNpmPath(cwd: string): NodeJS.ProcessEnv {\n const key = getPathEnvVarKey()\n return {[key]: getNpmRunPath(cwd)}\n}\n\nfunction getPathEnvVarKey(): string {\n if (process.platform !== 'win32') {\n return 'PATH'\n }\n\n return (\n Object.keys(process.env)\n .toReversed()\n .find((key) => key.toUpperCase() === 'PATH') || 'Path'\n )\n}\n\nfunction getCommandPath(cmd: string, cwd?: string): Promise<string | null> {\n const options = cwd ? {path: getNpmRunPath(cwd)} : undefined\n return which(cmd, options).catch(() => null)\n}\n\nfunction hasCommand(cmd: string, cwd?: string): Promise<boolean> {\n return getCommandPath(cmd, cwd).then((cmdPath) => cmdPath !== null)\n}\n\nasync function getMostLikelyInstalledPackageManager(\n rootDir: string,\n): Promise<PackageManager | undefined> {\n const installed = await getAvailablePackageManagers(rootDir)\n const running = getRunningPackageManager()\n return running && installed.includes(running) ? running : undefined\n}\n\nfunction getRunningPackageManager(): PackageManager | undefined {\n // Yes, the env var is lowercase - it is set by the package managers themselves\n const agent = process.env.npm_config_user_agent || ''\n\n if (agent.includes('yarn')) {\n return 'yarn'\n }\n\n if (agent.includes('pnpm')) {\n return 'pnpm'\n }\n\n if (agent.includes('bun')) {\n return 'bun'\n }\n\n // Both yarn and pnpm does a `npm/?` thing, thus the slightly different match here\n // Theoretically not needed since we check for yarn/pnpm above, but in case other\n // package managers do the same thing, we'll (hopefully) catch them here.\n if (/^npm\\/\\d/.test(agent)) {\n return 'npm'\n }\n\n return undefined\n}\n"],"names":["path","isInteractive","select","default","preferredPM","which","EXPERIMENTAL","Set","ALLOWED_PACKAGE_MANAGERS","allowedPackageManagersString","join","getPackageManagerChoice","workDir","options","rootDir","process","cwd","preferred","name","hasCommand","chosen","mostOptimal","mostLikelyPM","getMostLikelyInstalledPackageManager","interactive","getFallback","messageSuffix","installed","getAvailablePackageManagers","choices","map","pm","has","value","message","hasNpmInstalled","hasYarnInstalled","hasPnpmInstalled","hasBunInstalled","npm","yarn","pnpm","bun","Promise","all","filter","getNpmRunPath","previous","cwdPath","resolve","result","push","execPath","pathEnv","env","getPathEnvVarKey","delimiter","getPartialEnvWithNpmPath","key","platform","Object","keys","toReversed","find","toUpperCase","getCommandPath","cmd","undefined","catch","then","cmdPath","running","getRunningPackageManager","includes","agent","npm_config_user_agent","test"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,MAAM,QAAO,sBAAqB;AAC1C,oDAAoD;AACpD,SAAQC,WAAWC,WAAW,QAAO,eAAc;AACnD,OAAOC,WAAW,QAAO;AAIzB,MAAMC,eAAe,IAAIC,IAAI;IAAC;CAAM;AAEpC,OAAO,MAAMC,2BAAsD;IACjE;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV,OAAO,MAAMC,+BAA+BD,yBA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uC;IACP,IAAIxC,QAAQ4C,QAAQ,KAAK,SAAS;QAChC,OAAO;IACT;IAEA,OACEC,OAAOC,IAAI,CAAC9C,QAAQuC,GAAG,EACpBQ,UAAU,GACVC,IAAI,CAAC,CAACL,MAAQA,IAAIM,WAAW,OAAO,WAAW;AAEtD;AAEA,SAASC,eAAeC,GAAW,EAAElD,GAAY;IAC/C,MAAMH,UAAUG,MAAM;QAAChB,MAAM8C,cAAc9B;IAAI,IAAImD;IACnD,OAAO9D,MAAM6D,KAAKrD,SAASuD,KAAK,CAAC,IAAM;AACzC;AAEA,SAASjD,WAAW+C,GAAW,EAAElD,GAAY;IAC3C,OAAOiD,eAAeC,KAAKlD,KAAKqD,IAAI,CAAC,CAACC,UAAYA,YAAY;AAChE;AAEA,eAAe/C,qCACbT,OAAe;IAEf,MAAMa,YAAY,MAAMC,4BAA4Bd;IACpD,MAAMyD,UAAUC;IAChB,OAAOD,WAAW5C,UAAU8C,QAAQ,CAACF,WAAWA,UAAUJ;AAC5D;AAEA,SAASK;IACP,+EAA+E;IAC/E,MAAME,QAAQ3D,QAAQuC,GAAG,CAACqB,qBAAqB,IAAI;IAEnD,IAAID,MAAMD,QAAQ,CAAC,SAAS;QAC1B,OAAO;IACT;IAEA,IAAIC,MAAMD,QAAQ,CAAC,SAAS;QAC1B,OAAO;IACT;IAEA,IAAIC,MAAMD,QAAQ,CAAC,QAAQ;QACzB,OAAO;IACT;IAEA,kFAAkF;IAClF,iFAAiF;IACjF,yEAAyE;IACzE,IAAI,WAAWG,IAAI,CAACF,QAAQ;QAC1B,OAAO;IACT;IAEA,OAAOP;AACT"}
@@ -0,0 +1,35 @@
1
+ interface ParsedArguments<F = Record<string, string>> {
2
+ /**
3
+ * Command arguments, eg any arguments after `sanity <command>` (no flags)
4
+ */
5
+ argsWithoutOptions: string[];
6
+ argv: string[];
7
+ /**
8
+ * Options mostly relevant for the core CLI runner
9
+ */
10
+ coreOptions: {
11
+ debug: boolean;
12
+ help: boolean;
13
+ version: boolean;
14
+ };
15
+ /**
16
+ * Command flags, without the core options (help, debug, version etc)
17
+ */
18
+ extOptions: F;
19
+ /**
20
+ * Arguments after the ended argument list (--)
21
+ */
22
+ extraArguments: string[];
23
+ /**
24
+ * Group or command name, eg `dataset` (`sanity dataset`) or `import` (`sanity dataset import`)
25
+ */
26
+ groupOrCommand: string;
27
+ }
28
+ /**
29
+ * Parse the arguments from the command line
30
+ *
31
+ * @param argv - The arguments from the command line
32
+ * @returns The parsed arguments
33
+ */
34
+ export declare function parseArguments(argv?: string[]): ParsedArguments;
35
+ export {};
@@ -0,0 +1,42 @@
1
+ import minimist from 'minimist';
2
+ /**
3
+ * Parse the arguments from the command line
4
+ *
5
+ * @param argv - The arguments from the command line
6
+ * @returns The parsed arguments
7
+ */ export function parseArguments(argv = process.argv) {
8
+ const args = argv.slice(2);
9
+ const { '--': extraArguments, _, version, ...extOptions } = minimist(args, {
10
+ '--': true,
11
+ boolean: [
12
+ 'version'
13
+ ],
14
+ string: [
15
+ '_'
16
+ ]
17
+ });
18
+ const [groupOrCommand, ...argsWithoutOptions] = _;
19
+ const finalExtraArguments = [
20
+ ...extraArguments || [],
21
+ ...argv.filter((arg)=>arg.startsWith('-'))
22
+ ];
23
+ // oclif allows to run `sanity help` or `sanity help <command>`
24
+ // It does not fire the hooks on `--help` so this is okay to track
25
+ const hasHelp = args.includes('help');
26
+ // We only have global debug via env var
27
+ const hasDebug = !!process.env.DEBUG;
28
+ return {
29
+ groupOrCommand,
30
+ argsWithoutOptions,
31
+ argv,
32
+ extOptions,
33
+ extraArguments: finalExtraArguments,
34
+ coreOptions: {
35
+ debug: hasDebug,
36
+ help: hasHelp,
37
+ version
38
+ }
39
+ };
40
+ }
41
+
42
+ //# sourceMappingURL=parseArguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/parseArguments.ts"],"sourcesContent":["import minimist from 'minimist'\n\ninterface ParsedArguments<F = Record<string, string>> {\n /**\n * Command arguments, eg any arguments after `sanity <command>` (no flags)\n */\n argsWithoutOptions: string[]\n\n // Raw, forwarded arguments, for commands that want to be more explicit about parsing\n argv: string[]\n\n /**\n * Options mostly relevant for the core CLI runner\n */\n coreOptions: {\n debug: boolean\n\n help: boolean\n\n version: boolean\n }\n\n /**\n * Command flags, without the core options (help, debug, version etc)\n */\n extOptions: F\n\n /**\n * Arguments after the ended argument list (--)\n */\n extraArguments: string[]\n\n /**\n * Group or command name, eg `dataset` (`sanity dataset`) or `import` (`sanity dataset import`)\n */\n groupOrCommand: string\n}\n\n/**\n * Parse the arguments from the command line\n *\n * @param argv - The arguments from the command line\n * @returns The parsed arguments\n */\nexport function parseArguments(argv = process.argv): ParsedArguments {\n const args = argv.slice(2)\n\n const {\n '--': extraArguments,\n _,\n version,\n ...extOptions\n } = minimist(args, {\n '--': true,\n boolean: ['version'],\n string: ['_'],\n })\n\n const [groupOrCommand, ...argsWithoutOptions] = _\n\n const finalExtraArguments = [\n ...(extraArguments || []),\n ...argv.filter((arg) => arg.startsWith('-')),\n ]\n\n // oclif allows to run `sanity help` or `sanity help <command>`\n // It does not fire the hooks on `--help` so this is okay to track\n const hasHelp = args.includes('help')\n\n // We only have global debug via env var\n const hasDebug = !!process.env.DEBUG\n\n return {\n groupOrCommand,\n\n argsWithoutOptions,\n argv,\n extOptions,\n extraArguments: finalExtraArguments,\n\n coreOptions: {\n debug: hasDebug,\n help: hasHelp,\n version,\n },\n }\n}\n"],"names":["minimist","parseArguments","argv","process","args","slice","extraArguments","_","version","extOptions","boolean","string","groupOrCommand","argsWithoutOptions","finalExtraArguments","filter","arg","startsWith","hasHelp","includes","hasDebug","env","DEBUG","coreOptions","debug","help"],"mappings":"AAAA,OAAOA,cAAc,WAAU;AAsC/B;;;;;CAKC,GACD,OAAO,SAASC,eAAeC,OAAOC,QAAQD,IAAI;IAChD,MAAME,OAAOF,KAAKG,KAAK,CAAC;IAExB,MAAM,EACJ,MAAMC,cAAc,EACpBC,CAAC,EACDC,OAAO,EACP,GAAGC,YACJ,GAAGT,SAASI,MAAM;QACjB,MAAM;QACNM,SAAS;YAAC;SAAU;QACpBC,QAAQ;YAAC;SAAI;IACf;IAEA,MAAM,CAACC,gBAAgB,GAAGC,mBAAmB,GAAGN;IAEhD,MAAMO,sBAAsB;WACtBR,kBAAkB,EAAE;WACrBJ,KAAKa,MAAM,CAAC,CAACC,MAAQA,IAAIC,UAAU,CAAC;KACxC;IAED,+DAA+D;IAC/D,kEAAkE;IAClE,MAAMC,UAAUd,KAAKe,QAAQ,CAAC;IAE9B,wCAAwC;IACxC,MAAMC,WAAW,CAAC,CAACjB,QAAQkB,GAAG,CAACC,KAAK;IAEpC,OAAO;QACLV;QAEAC;QACAX;QACAO;QACAH,gBAAgBQ;QAEhBS,aAAa;YACXC,OAAOJ;YACPK,MAAMP;YACNV;QACF;IACF;AACF"}
@@ -0,0 +1,5 @@
1
+ export interface ReaddirItem {
2
+ isDir: boolean;
3
+ path: string;
4
+ }
5
+ export declare function readdirRecursive(dir: string): Promise<ReaddirItem[]>;
@@ -0,0 +1,24 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ export async function readdirRecursive(dir) {
4
+ let content = [];
5
+ const currentPath = path.resolve(dir);
6
+ const dirContent = (await fs.readdir(currentPath)).map((item)=>path.join(currentPath, item));
7
+ for (const subPath of dirContent){
8
+ const stat = await fs.stat(subPath);
9
+ const isDir = stat.isDirectory();
10
+ content.push({
11
+ isDir,
12
+ path: subPath
13
+ });
14
+ if (isDir) {
15
+ content = [
16
+ ...content,
17
+ ...await readdirRecursive(subPath)
18
+ ];
19
+ }
20
+ }
21
+ return content;
22
+ }
23
+
24
+ //# sourceMappingURL=readdirRecursive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/readdirRecursive.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nexport interface ReaddirItem {\n isDir: boolean\n path: string\n}\n\nexport async function readdirRecursive(dir: string): Promise<ReaddirItem[]> {\n let content: ReaddirItem[] = []\n\n const currentPath = path.resolve(dir)\n const dirContent = (await fs.readdir(currentPath)).map((item) => path.join(currentPath, item))\n\n for (const subPath of dirContent) {\n const stat = await fs.stat(subPath)\n const isDir = stat.isDirectory()\n content.push({isDir, path: subPath})\n\n if (isDir) {\n content = [...content, ...(await readdirRecursive(subPath))]\n }\n }\n\n return content\n}\n"],"names":["fs","path","readdirRecursive","dir","content","currentPath","resolve","dirContent","readdir","map","item","join","subPath","stat","isDir","isDirectory","push"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAO5B,OAAO,eAAeC,iBAAiBC,GAAW;IAChD,IAAIC,UAAyB,EAAE;IAE/B,MAAMC,cAAcJ,KAAKK,OAAO,CAACH;IACjC,MAAMI,aAAa,AAAC,CAAA,MAAMP,GAAGQ,OAAO,CAACH,YAAW,EAAGI,GAAG,CAAC,CAACC,OAAST,KAAKU,IAAI,CAACN,aAAaK;IAExF,KAAK,MAAME,WAAWL,WAAY;QAChC,MAAMM,OAAO,MAAMb,GAAGa,IAAI,CAACD;QAC3B,MAAME,QAAQD,KAAKE,WAAW;QAC9BX,QAAQY,IAAI,CAAC;YAACF;YAAOb,MAAMW;QAAO;QAElC,IAAIE,OAAO;YACTV,UAAU;mBAAIA;mBAAa,MAAMF,iBAAiBU;aAAU;QAC9D;IACF;IAEA,OAAOR;AACT"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolve the latest versions of given packages within their defined ranges
3
+ *
4
+ * @param pkgs - `{packageName: rangeOrTag}`
5
+ * @returns Object of resolved version numbers
6
+ */
7
+ export declare function resolveLatestVersions(pkgs: Record<string, string>): Promise<Record<string, string>>;