@vltpkg/cli-sdk 0.0.0-3 → 0.0.0-31

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 (169) hide show
  1. package/README.md +3 -0
  2. package/dist/esm/commands/build.d.ts +25 -0
  3. package/dist/esm/commands/build.d.ts.map +1 -0
  4. package/dist/esm/commands/build.js +102 -0
  5. package/dist/esm/commands/build.js.map +1 -0
  6. package/dist/esm/commands/cache.d.ts +65 -0
  7. package/dist/esm/commands/cache.d.ts.map +1 -0
  8. package/dist/esm/commands/cache.js +257 -0
  9. package/dist/esm/commands/cache.js.map +1 -0
  10. package/dist/esm/commands/ci.d.ts +11 -0
  11. package/dist/esm/commands/ci.d.ts.map +1 -0
  12. package/dist/esm/commands/ci.js +32 -0
  13. package/dist/esm/commands/ci.js.map +1 -0
  14. package/dist/esm/commands/config.d.ts +3 -2
  15. package/dist/esm/commands/config.d.ts.map +1 -1
  16. package/dist/esm/commands/config.js +372 -101
  17. package/dist/esm/commands/config.js.map +1 -1
  18. package/dist/esm/commands/exec-cache.d.ts +49 -0
  19. package/dist/esm/commands/exec-cache.d.ts.map +1 -0
  20. package/dist/esm/commands/exec-cache.js +146 -0
  21. package/dist/esm/commands/exec-cache.js.map +1 -0
  22. package/dist/esm/commands/exec-local.d.ts +6 -0
  23. package/dist/esm/commands/exec-local.d.ts.map +1 -0
  24. package/dist/esm/commands/exec-local.js +24 -0
  25. package/dist/esm/commands/exec-local.js.map +1 -0
  26. package/dist/esm/commands/exec.d.ts +4 -0
  27. package/dist/esm/commands/exec.d.ts.map +1 -1
  28. package/dist/esm/commands/exec.js +75 -10
  29. package/dist/esm/commands/exec.js.map +1 -1
  30. package/dist/esm/commands/help.d.ts +1 -1
  31. package/dist/esm/commands/help.d.ts.map +1 -1
  32. package/dist/esm/commands/help.js +25 -3
  33. package/dist/esm/commands/help.js.map +1 -1
  34. package/dist/esm/commands/init.d.ts +4 -5
  35. package/dist/esm/commands/init.d.ts.map +1 -1
  36. package/dist/esm/commands/init.js +95 -9
  37. package/dist/esm/commands/init.js.map +1 -1
  38. package/dist/esm/commands/install/reporter.d.ts +3 -2
  39. package/dist/esm/commands/install/reporter.d.ts.map +1 -1
  40. package/dist/esm/commands/install/reporter.js +43 -15
  41. package/dist/esm/commands/install/reporter.js.map +1 -1
  42. package/dist/esm/commands/install.d.ts +24 -3
  43. package/dist/esm/commands/install.d.ts.map +1 -1
  44. package/dist/esm/commands/install.js +27 -3
  45. package/dist/esm/commands/install.js.map +1 -1
  46. package/dist/esm/commands/list.d.ts +1 -1
  47. package/dist/esm/commands/list.d.ts.map +1 -1
  48. package/dist/esm/commands/list.js +150 -42
  49. package/dist/esm/commands/list.js.map +1 -1
  50. package/dist/esm/commands/pack.d.ts +32 -0
  51. package/dist/esm/commands/pack.d.ts.map +1 -0
  52. package/dist/esm/commands/pack.js +147 -0
  53. package/dist/esm/commands/pack.js.map +1 -0
  54. package/dist/esm/commands/pkg.d.ts +2 -3
  55. package/dist/esm/commands/pkg.d.ts.map +1 -1
  56. package/dist/esm/commands/pkg.js +123 -38
  57. package/dist/esm/commands/pkg.js.map +1 -1
  58. package/dist/esm/commands/publish.d.ts +22 -0
  59. package/dist/esm/commands/publish.d.ts.map +1 -0
  60. package/dist/esm/commands/publish.js +239 -0
  61. package/dist/esm/commands/publish.js.map +1 -0
  62. package/dist/esm/commands/query.d.ts +1 -1
  63. package/dist/esm/commands/query.d.ts.map +1 -1
  64. package/dist/esm/commands/query.js +171 -32
  65. package/dist/esm/commands/query.js.map +1 -1
  66. package/dist/esm/commands/run-exec.d.ts +1 -0
  67. package/dist/esm/commands/run-exec.d.ts.map +1 -1
  68. package/dist/esm/commands/run-exec.js +1 -0
  69. package/dist/esm/commands/run-exec.js.map +1 -1
  70. package/dist/esm/commands/run.d.ts +1 -0
  71. package/dist/esm/commands/run.d.ts.map +1 -1
  72. package/dist/esm/commands/run.js +13 -16
  73. package/dist/esm/commands/run.js.map +1 -1
  74. package/dist/esm/commands/serve.d.ts +14 -0
  75. package/dist/esm/commands/serve.d.ts.map +1 -0
  76. package/dist/esm/commands/serve.js +103 -0
  77. package/dist/esm/commands/serve.js.map +1 -0
  78. package/dist/esm/commands/uninstall.d.ts +13 -1
  79. package/dist/esm/commands/uninstall.d.ts.map +1 -1
  80. package/dist/esm/commands/uninstall.js +12 -1
  81. package/dist/esm/commands/uninstall.js.map +1 -1
  82. package/dist/esm/commands/update.d.ts +14 -0
  83. package/dist/esm/commands/update.d.ts.map +1 -0
  84. package/dist/esm/commands/update.js +41 -0
  85. package/dist/esm/commands/update.js.map +1 -0
  86. package/dist/esm/commands/version.d.ts +26 -0
  87. package/dist/esm/commands/version.d.ts.map +1 -0
  88. package/dist/esm/commands/version.js +226 -0
  89. package/dist/esm/commands/version.js.map +1 -0
  90. package/dist/esm/commands/whoami.d.ts +4 -2
  91. package/dist/esm/commands/whoami.d.ts.map +1 -1
  92. package/dist/esm/commands/whoami.js +1 -1
  93. package/dist/esm/commands/whoami.js.map +1 -1
  94. package/dist/esm/config/definition.d.ts +117 -10
  95. package/dist/esm/config/definition.d.ts.map +1 -1
  96. package/dist/esm/config/definition.js +203 -31
  97. package/dist/esm/config/definition.js.map +1 -1
  98. package/dist/esm/config/index.d.ts +46 -40
  99. package/dist/esm/config/index.d.ts.map +1 -1
  100. package/dist/esm/config/index.js +126 -176
  101. package/dist/esm/config/index.js.map +1 -1
  102. package/dist/esm/config/merge.d.ts +3 -1
  103. package/dist/esm/config/merge.d.ts.map +1 -1
  104. package/dist/esm/config/merge.js +11 -6
  105. package/dist/esm/config/merge.js.map +1 -1
  106. package/dist/esm/config/usage.d.ts +3 -2
  107. package/dist/esm/config/usage.d.ts.map +1 -1
  108. package/dist/esm/config/usage.js.map +1 -1
  109. package/dist/esm/exec-command.d.ts +33 -14
  110. package/dist/esm/exec-command.d.ts.map +1 -1
  111. package/dist/esm/exec-command.js +214 -65
  112. package/dist/esm/exec-command.js.map +1 -1
  113. package/dist/esm/index.d.ts +1 -14
  114. package/dist/esm/index.d.ts.map +1 -1
  115. package/dist/esm/index.js +46 -20
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/load-command.d.ts +16 -0
  118. package/dist/esm/load-command.d.ts.map +1 -0
  119. package/dist/esm/load-command.js +21 -0
  120. package/dist/esm/load-command.js.map +1 -0
  121. package/dist/esm/output.d.ts +6 -10
  122. package/dist/esm/output.d.ts.map +1 -1
  123. package/dist/esm/output.js +63 -33
  124. package/dist/esm/output.js.map +1 -1
  125. package/dist/esm/pack-tarball.d.ts +22 -0
  126. package/dist/esm/pack-tarball.d.ts.map +1 -0
  127. package/dist/esm/pack-tarball.js +247 -0
  128. package/dist/esm/pack-tarball.js.map +1 -0
  129. package/dist/esm/parse-add-remove-args.d.ts +1 -1
  130. package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
  131. package/dist/esm/parse-add-remove-args.js +1 -1
  132. package/dist/esm/parse-add-remove-args.js.map +1 -1
  133. package/dist/esm/print-err.d.ts +12 -1
  134. package/dist/esm/print-err.d.ts.map +1 -1
  135. package/dist/esm/print-err.js +157 -26
  136. package/dist/esm/print-err.js.map +1 -1
  137. package/dist/esm/query-host-contexts.d.ts +16 -0
  138. package/dist/esm/query-host-contexts.d.ts.map +1 -0
  139. package/dist/esm/query-host-contexts.js +135 -0
  140. package/dist/esm/query-host-contexts.js.map +1 -0
  141. package/dist/esm/start-gui.d.ts +7 -33
  142. package/dist/esm/start-gui.d.ts.map +1 -1
  143. package/dist/esm/start-gui.js +51 -349
  144. package/dist/esm/start-gui.js.map +1 -1
  145. package/dist/esm/view.d.ts +2 -3
  146. package/dist/esm/view.d.ts.map +1 -1
  147. package/dist/esm/view.js +1 -1
  148. package/dist/esm/view.js.map +1 -1
  149. package/package.json +73 -45
  150. package/dist/esm/commands/gui.d.ts +0 -6
  151. package/dist/esm/commands/gui.d.ts.map +0 -1
  152. package/dist/esm/commands/gui.js +0 -14
  153. package/dist/esm/commands/gui.js.map +0 -1
  154. package/dist/esm/commands/install-exec.d.ts +0 -4
  155. package/dist/esm/commands/install-exec.d.ts.map +0 -1
  156. package/dist/esm/commands/install-exec.js +0 -13
  157. package/dist/esm/commands/install-exec.js.map +0 -1
  158. package/dist/esm/ignored-homedir-folder-names.d.ts +0 -7
  159. package/dist/esm/ignored-homedir-folder-names.d.ts.map +0 -1
  160. package/dist/esm/ignored-homedir-folder-names.js +0 -35
  161. package/dist/esm/ignored-homedir-folder-names.js.map +0 -1
  162. package/dist/esm/project-info.d.ts +0 -32
  163. package/dist/esm/project-info.d.ts.map +0 -1
  164. package/dist/esm/project-info.js +0 -90
  165. package/dist/esm/project-info.js.map +0 -1
  166. package/dist/esm/read-project-folders.d.ts +0 -27
  167. package/dist/esm/read-project-folders.d.ts.map +0 -1
  168. package/dist/esm/read-project-folders.js +0 -66
  169. package/dist/esm/read-project-folders.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,0DAA0D;CACxE,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAEd;IACF,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QACpC,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,kDAAkD;QAClD,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7D,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,IAAI;;EAExC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;CAC9B,CAAC,CAAA;QACE,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;;2CAE2B,CAAC,CAAA;QACxC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,IAAI,EAAE,CAC5D,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { ViewFn, Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'init',\n usage: '',\n description: `Create a new package.json file in the current directory.`,\n })\n\nexport const views: Views<InitFileResults> & {\n human: ViewFn<InitFileResults>\n} = {\n human: (results, _options, _config) => {\n const output: string[] = []\n // TODO: colorize the JSON if config.options.color\n for (const [type, { path, data }] of Object.entries(results)) {\n output.push(`Wrote ${type} to ${path}:\n\n${JSON.stringify(data, null, 2)}\n`)\n }\n output.push(`Modify/add properties using \\`vlt pkg\\`. For example:\n\n vlt pkg set \"description=My new project\"`)\n return output.join('\\n')\n },\n}\n\nexport const command: CommandFn<InitFileResults> = async () =>\n await init({ cwd: process.cwd() })\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,IAAI,E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C,CAAA;AACrC,CAAC,CAAA","sourcesContent":["import { mkdirSync } from 'node:fs'\nimport { relative, resolve } from 'node:path'\nimport { minimatch } from 'minimatch'\nimport { init } from '@vltpkg/init'\nimport { load, save } from '@vltpkg/vlt-json'\nimport { assertWSConfig, asWSConfig } from '@vltpkg/workspaces'\nimport { commandUsage } from '../config/usage.ts'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'init',\n usage: '',\n description: `Create a new package.json file in the current directory.`,\n })\n\n// TODO: colorize the JSON if config.options.color\nexport const views = {\n human: (results: InitFileResults | InitFileResults[]) => {\n const output: string[] = []\n // if results is an array, it means multiple workspaces were initialized\n if (Array.isArray(results)) {\n for (const result of results) {\n for (const [type, { path }] of Object.entries(result)) {\n output.push(`Wrote ${type} to ${path}:`)\n }\n }\n } else {\n // otherwise, it's a single result\n for (const [type, { path, data }] of Object.entries(results)) {\n output.push(`Wrote ${type} to ${path}:\n\n${JSON.stringify(data, null, 2)}`)\n }\n }\n output.push(`\\nModify/add properties using \\`vlt pkg\\`. For example:\n\n vlt pkg set \"description=My new project\"`)\n return output.join('\\n')\n },\n} as const satisfies Views<InitFileResults>\n\nexport const command: CommandFn<\n InitFileResults | InitFileResults[]\n> = async conf => {\n if (conf.values.workspace?.length) {\n const workspacesConfig = load('workspaces', assertWSConfig)\n const parsedWSConfig = asWSConfig(workspacesConfig ?? {})\n const results: InitFileResults[] = []\n const addToConfig: string[] = []\n\n // create a new package.json file for every workspace\n // defined as cli --workspace options\n for (const workspace of conf.values.workspace) {\n // cwd is the resolved location of the workspace\n const cwd = resolve(conf.options.projectRoot, workspace)\n\n // create the folder in case it's missing\n mkdirSync(cwd, { recursive: true })\n\n // run the initialization script and collect results\n results.push(await init({ cwd }))\n\n // Check if this workspace path is covered by existing workspace patterns\n const isMatched = Object.values(parsedWSConfig).some(\n (patterns: string[]) => {\n return patterns.some(pattern =>\n minimatch(workspace, pattern),\n )\n },\n )\n\n // When a workspace is not matched we track it for insertion later\n if (!isMatched) {\n addToConfig.push(\n relative(conf.options.projectRoot, cwd).replace(/\\\\/g, '/'),\n )\n }\n }\n\n // if there are workspaces that were not matched by existing\n // patterns, we add them to the workspaces config\n if (addToConfig.length > 0) {\n let workspaces = workspacesConfig\n // if the original workspaces config is a string, we'll need\n // to convert it to an array in order to append the recently\n // added workspaces\n if (typeof workspacesConfig === 'string') {\n workspaces = [workspacesConfig, ...addToConfig]\n } else if (Array.isArray(workspacesConfig)) {\n // if the original workspaces config is an array, we simply\n // append the missing items to it\n workspaces = [...workspacesConfig, ...addToConfig]\n } else {\n // otherwise we assume it's an Record<string, string[]> object\n // and we'll add the new workspaces to the `packages` keys\n workspaces = (workspacesConfig ?? {}) as Record<\n string,\n string[]\n >\n // if the `packages` key is not being used\n if (!workspaces.packages) {\n workspaces.packages = addToConfig\n } else {\n // if the `packages` key is defined as a string, we\n // convert it to an array to append the new items\n if (typeof workspaces.packages === 'string') {\n workspaces.packages = [\n workspaces.packages,\n ...addToConfig,\n ]\n } else {\n // if it is, we simply append the new workspaces\n workspaces.packages = [\n ...workspaces.packages,\n ...addToConfig,\n ]\n }\n }\n }\n // finally, we add the new workspaces to the config file\n save('workspaces', workspaces)\n }\n return results\n }\n\n return init({ cwd: process.cwd() })\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  import { ViewClass } from '../../view.ts';
2
+ import type { InstallResult } from '../install.ts';
2
3
  export declare class InstallReporter extends ViewClass {
3
4
  #private;
4
5
  start(): void;
5
- done(_result: unknown, { time }: {
6
+ done(_result: InstallResult, { time }: {
6
7
  time: number;
7
- }): undefined;
8
+ }): Promise<undefined>;
8
9
  error(err: unknown): void;
9
10
  }
10
11
  //# sourceMappingURL=reporter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAgFzC,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIL,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAMjD,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAqGlD,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAe7D,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
@@ -1,20 +1,26 @@
1
1
  import { emitter } from '@vltpkg/output';
2
2
  import { Box, render, Text } from 'ink';
3
3
  import Spinner from 'ink-spinner';
4
- import { createElement as $, Fragment, useLayoutEffect, useState, } from 'react';
5
- import { stdout } from "../../output.js";
4
+ import { createElement as $, Fragment, useEffect, useState, } from 'react';
6
5
  import { ViewClass } from "../../view.js";
6
+ import { asError } from '@vltpkg/types';
7
+ const labels = {
8
+ build: 'resolving dependencies',
9
+ actual: '',
10
+ reify: 'extracting files',
11
+ };
7
12
  const GraphStep = ({ text, step }) => {
8
13
  if (step.state === 'waiting') {
9
14
  return $(Text, { color: 'gray' }, text);
10
15
  }
11
16
  if (step.state === 'in_progress') {
12
- return $(Text, { color: 'yellow' }, text, $(Spinner, { type: 'dots' }));
17
+ return $(Text, { color: 'yellow' }, text + ' ', $(Spinner, { type: 'dots' }));
13
18
  }
14
19
  return $(Text, { color: 'green' }, text, ' ✓');
15
20
  };
16
- const App = () => {
21
+ const App = ({ trailer }) => {
17
22
  const [requests, setRequests] = useState(0);
23
+ const [cacheHit, setCacheHit] = useState(0);
18
24
  const [steps, setSteps] = useState({
19
25
  build: {
20
26
  state: 'waiting',
@@ -26,12 +32,19 @@ const App = () => {
26
32
  state: 'waiting',
27
33
  },
28
34
  });
29
- useLayoutEffect(() => {
30
- const update = () => setRequests(p => p + 1);
31
- emitter.on('request', update);
32
- return () => emitter.off('request', update);
35
+ useEffect(() => {
36
+ const updateRequests = ({ state }) => {
37
+ if (state === 'start') {
38
+ setRequests(p => p + 1);
39
+ }
40
+ else if (state === 'cache' || state === 'stale') {
41
+ setCacheHit(p => p + 1);
42
+ }
43
+ };
44
+ emitter.on('request', updateRequests);
45
+ return () => emitter.off('request', updateRequests);
33
46
  }, []);
34
- useLayoutEffect(() => {
47
+ useEffect(() => {
35
48
  const update = ({ step, state }) => {
36
49
  setSteps(p => ({
37
50
  ...p,
@@ -46,21 +59,36 @@ const App = () => {
46
59
  }, []);
47
60
  return $(Fragment, null, $(Box, null, ...['build', 'actual', 'reify'].map((step, idx, list) => {
48
61
  const separator = idx === list.length - 1 ? '' : ' > ';
49
- return $(Text, { key: step }, $(GraphStep, { text: step, step: steps[step] }), $(Text, { color: 'gray' }, separator));
50
- })), requests > 0 ? $(Text, null, `${requests} requests`) : null);
62
+ const label = labels[step];
63
+ if (!label)
64
+ return null;
65
+ return $(Text, { key: step }, $(GraphStep, { text: label, step: steps[step] }), $(Text, { color: 'gray' }, separator));
66
+ })), cacheHit > 0 ?
67
+ $(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)
68
+ : null, requests > 0 ?
69
+ $(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)
70
+ : null, trailer ? $(Text, null, trailer) : null);
51
71
  };
52
72
  export class InstallReporter extends ViewClass {
53
73
  #instance = null;
54
74
  start() {
55
75
  this.#instance = render($(App));
56
76
  }
57
- done(_result, { time }) {
58
- this.#instance?.unmount();
59
- stdout(`Done in ${time}ms`);
77
+ async done(_result, { time }) {
78
+ let out = `Done in ${time}ms`;
79
+ // prints a very complete message explaining users the next steps
80
+ // in case there are packages to be built
81
+ if (_result.buildQueue?.length) {
82
+ out += `\n\n📦 ${_result.buildQueue.length} packages have install scripts defined & were not fully built\n`;
83
+ out += '🔎 Run `vlt query :scripts` to list them\n';
84
+ out +=
85
+ '🔨 Run `vlt build` to run all required scripts to build installed packages.\n';
86
+ }
87
+ this.#instance?.rerender($(App, { trailer: out }));
60
88
  return undefined;
61
89
  }
62
90
  error(err) {
63
- this.#instance?.unmount(err);
91
+ this.#instance?.unmount(asError(err));
64
92
  }
65
93
  }
66
94
  //# sourceMappingURL=reporter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,eAAe,EACf,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAMzC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAgC,EAAE,EAAE;IACjE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;QACjC,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,KAAK,EAAE,QAAQ,EAAE,EACnB,IAA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C,WAAW,IAAI,IAAI,CAAC,CAAA;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAY,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useLayoutEffect,\n useState,\n} from 'react'\nimport { stdout } from '../../output.ts'\nimport { ViewClass } from '../../view.ts'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text,\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = () => {\n const [requests, setRequests] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useLayoutEffect(() => {\n const update = () => setRequests(p => p + 1)\n emitter.on('request', update)\n return () => emitter.off('request', update)\n }, [])\n\n useLayoutEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: step, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n requests > 0 ? $(Text, null, `${requests} requests`) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n done(_result: unknown, { time }: { time: number }) {\n this.#instance?.unmount()\n stdout(`Done in ${time}ms`)\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(err as Error)\n }\n}\n"]}
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAOvC,MAAM,MAAM,GAAgD;IAC1D,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,kBAAkB;CAC1B,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAgC,EAAE,EAAE;IACjE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;QACjC,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,KAAK,EAAE,QAAQ,EAAE,EACnB,IAAI,GAAG,GAAG,EACV,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC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C,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useEffect,\n useState,\n} from 'react'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/types'\nimport type { InstallResult } from '../install.ts'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst labels: Record<Events['graphStep']['step'], string> = {\n build: 'resolving dependencies',\n actual: '',\n reify: 'extracting files',\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text + ' ',\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = ({ trailer }: { trailer?: string }) => {\n const [requests, setRequests] = useState(0)\n const [cacheHit, setCacheHit] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useEffect(() => {\n const updateRequests = ({ state }: Events['request']) => {\n if (state === 'start') {\n setRequests(p => p + 1)\n } else if (state === 'cache' || state === 'stale') {\n setCacheHit(p => p + 1)\n }\n }\n emitter.on('request', updateRequests)\n return () => emitter.off('request', updateRequests)\n }, [])\n\n useEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n const label = labels[step]\n if (!label) return null\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: label, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n cacheHit > 0 ?\n $(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)\n : null,\n requests > 0 ?\n $(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)\n : null,\n trailer ? $(Text, null, trailer) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n async done(_result: InstallResult, { time }: { time: number }) {\n let out = `Done in ${time}ms`\n\n // prints a very complete message explaining users the next steps\n // in case there are packages to be built\n if (_result.buildQueue?.length) {\n out += `\\n\\n📦 ${_result.buildQueue.length} packages have install scripts defined & were not fully built\\n`\n out += '🔎 Run `vlt query :scripts` to list them\\n'\n out +=\n '🔨 Run `vlt build` to run all required scripts to build installed packages.\\n'\n }\n this.#instance?.rerender($(App, { trailer: out }))\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
@@ -1,7 +1,28 @@
1
+ import { InstallReporter } from './install/reporter.ts';
2
+ import type { DepID } from '@vltpkg/dep-id';
1
3
  import type { Graph } from '@vltpkg/graph';
2
4
  import type { CommandFn, CommandUsage } from '../index.ts';
3
- import type { Views } from '../view.ts';
5
+ /**
6
+ * The resulting object of an install operation. To be used by the view impl.
7
+ */
8
+ export type InstallResult = {
9
+ /**
10
+ * A queue of package IDs that need to be built after the install is complete.
11
+ */
12
+ buildQueue?: DepID[];
13
+ /**
14
+ * The resulting graph structure at the end of an install.
15
+ */
16
+ graph: Graph;
17
+ };
4
18
  export declare const usage: CommandUsage;
5
- export declare const views: Views<Graph>;
6
- export declare const command: CommandFn<Graph>;
19
+ export declare const views: {
20
+ readonly json: (i: InstallResult) => {
21
+ graph: import("@vltpkg/graph").LockfileData;
22
+ buildQueue?: DepID[] | undefined;
23
+ message?: string | undefined;
24
+ };
25
+ readonly human: typeof InstallReporter;
26
+ };
27
+ export declare const command: CommandFn<InstallResult>;
7
28
  //# sourceMappingURL=install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGvC,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAG9B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CAKpC,CAAA"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAyB5C,CAAA"}
@@ -9,13 +9,37 @@ export const usage = () => commandUsage({
9
9
  vlt-lock.json appropriately.`,
10
10
  });
11
11
  export const views = {
12
- json: g => g.toJSON(),
12
+ json: i => ({
13
+ ...(i.buildQueue?.length ?
14
+ {
15
+ buildQueue: i.buildQueue,
16
+ message: `${i.buildQueue.length} packages that will need to be built, run "vlt build" to complete the install.`,
17
+ }
18
+ : null),
19
+ graph: i.graph.toJSON(),
20
+ }),
13
21
  human: InstallReporter,
14
22
  };
15
23
  export const command = async (conf) => {
24
+ // TODO: we should probably throw an error if the user
25
+ // tries to install using either view=mermaid or view=gui
16
26
  const monorepo = conf.options.monorepo;
17
27
  const { add } = parseAddArgs(conf, monorepo);
18
- const { graph } = await install(conf.options, add);
19
- return graph;
28
+ const frozenLockfile = conf.options['frozen-lockfile'];
29
+ const expectLockfile = conf.options['expect-lockfile'];
30
+ const lockfileOnly = conf.options['lockfile-only'];
31
+ /* c8 ignore start */
32
+ const allowScripts = conf.get('allow-scripts') ?
33
+ String(conf.get('allow-scripts'))
34
+ : ':not(*)';
35
+ /* c8 ignore stop */
36
+ const { buildQueue, graph } = await install({
37
+ ...conf.options,
38
+ frozenLockfile,
39
+ expectLockfile,
40
+ allowScripts,
41
+ lockfileOnly,
42
+ }, add);
43
+ return { buildQueue, graph };
20
44
  };
21
45
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE;+CAC8B;CAC5C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAiB;IACjC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACvB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAqB,KAAK,EAAC,IAAI,EAAC,EAAE;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAClD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport type { Views } from '../view.ts'\nimport { InstallReporter } from './install/reporter.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views: Views<Graph> = {\n json: g => g.toJSON(),\n human: InstallReporter,\n}\n\nexport const command: CommandFn<Graph> = async conf => {\n const monorepo = conf.options.monorepo\n const { add } = parseAddArgs(conf, monorepo)\n const { graph } = await install(conf.options, add)\n return graph\n}\n"]}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAoBvD,MAAM,CAAC,MAAM,KAAK,GAAi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AAC,OAAO;QACf,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;KACb,EACD,GAAG,CACJ,CAAA;IACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { Graph } from '@vltpkg/graph'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n/**\n * The resulting object of an install operation. To be used by the view impl.\n */\nexport type InstallResult = {\n /**\n * A queue of package IDs that need to be built after the install is complete.\n */\n buildQueue?: DepID[]\n /**\n * The resulting graph structure at the end of an install.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: i => ({\n ...(i.buildQueue?.length ?\n {\n buildQueue: i.buildQueue,\n message: `${i.buildQueue.length} packages that will need to be built, run \"vlt build\" to complete the install.`,\n }\n : null),\n graph: i.graph.toJSON(),\n }),\n human: InstallReporter,\n} as const satisfies Views<InstallResult>\n\nexport const command: CommandFn<InstallResult> = async conf => {\n // TODO: we should probably throw an error if the user\n // tries to install using either view=mermaid or view=gui\n const monorepo = conf.options.monorepo\n const { add } = parseAddArgs(conf, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const lockfileOnly = conf.options['lockfile-only']\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { buildQueue, graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n allowScripts,\n lockfileOnly,\n },\n add,\n )\n return { buildQueue, graph }\n}\n"]}
@@ -9,7 +9,7 @@ export declare const views: {
9
9
  readonly json: typeof jsonOutput;
10
10
  readonly mermaid: typeof mermaidOutput;
11
11
  readonly human: typeof humanReadableOutput;
12
- readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").LoadedConfig) => Promise<void>;
12
+ readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
13
13
  };
14
14
  export declare const command: CommandFn<ListResult>;
15
15
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAkChB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAWoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAwDzC,CAAA"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;AAQtB,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAGnB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,eAAO,MAAM,KAAK,EAAE,YAyDhB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CA+JzC,CAAA"}
@@ -1,31 +1,57 @@
1
- import { actual, humanReadableOutput, jsonOutput, mermaidOutput, } from '@vltpkg/graph';
1
+ import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
2
+ import LZString from 'lz-string';
2
3
  import { Query } from '@vltpkg/query';
4
+ import { SecurityArchive } from '@vltpkg/security-archive';
5
+ import { error } from '@vltpkg/error-cause';
3
6
  import { commandUsage } from "../config/usage.js";
4
7
  import { startGUI } from "../start-gui.js";
8
+ import { createHostContextsMap } from "../query-host-contexts.js";
5
9
  export const usage = () => commandUsage({
6
10
  command: 'ls',
7
- usage: ['', '<query> --view=[human | json | mermaid | gui]'],
8
- description: `List installed dependencies matching the provided query.
9
- Defaults to listing direct dependencies of a project and
10
- any configured workspace.`,
11
+ usage: [
12
+ '',
13
+ '[package-names...] [--view=human | json | mermaid | gui]',
14
+ '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]',
15
+ ],
16
+ description: `List installed dependencies matching given package names or query selectors.
17
+
18
+ Package names provided as positional arguments will be used to filter
19
+ the results to show only dependencies with those names.
20
+
21
+ The --scope and --target options accepts DSS query selectors to filter
22
+ packages. Using --scope, you can specify which packages to treat as the
23
+ top-level items in the output graph. The --target option allows you to
24
+ filter what dependencies to include in the output. Using both options
25
+ allows you to render subgraphs of the dependency graph.
26
+
27
+ Defaults to listing direct dependencies of a project and any configured
28
+ workspace.`,
11
29
  examples: {
12
30
  '': {
13
31
  description: 'List direct dependencies of the current project / workspace',
14
32
  },
15
- '*': {
16
- description: 'List all dependencies for the current project / workspace',
17
- },
18
33
  'foo bar baz': {
19
34
  description: `List all dependencies named 'foo', 'bar', or 'baz'`,
20
35
  },
21
- [`'[name="@scoped/package"] > *'`]: {
22
- description: 'Lists direct dependencies of a specific package',
36
+ '--scope=":root > #dependency-name"': {
37
+ description: 'Defines a direct dependency as the output top-level scope',
38
+ },
39
+ '--target="*"': {
40
+ description: 'List all dependencies using a query selector',
23
41
  },
24
- [`'*.workspace > *.peer'`]: {
42
+ '--target=":workspace > *:peer"': {
25
43
  description: 'List all peer dependencies of all workspaces',
26
44
  },
27
45
  },
28
46
  options: {
47
+ scope: {
48
+ value: '<query>',
49
+ description: 'Query selector to select top-level packages using the DSS query language syntax.',
50
+ },
51
+ target: {
52
+ value: '<query>',
53
+ description: 'Query selector to filter packages using the DSS query language syntax.',
54
+ },
29
55
  view: {
30
56
  value: '[human | json | mermaid | gui]',
31
57
  description: 'Output format. Defaults to human-readable or json if no tty.',
@@ -37,55 +63,137 @@ export const views = {
37
63
  mermaid: mermaidOutput,
38
64
  human: humanReadableOutput,
39
65
  gui: async ({ queryString }, _, conf) => {
40
- await startGUI({
41
- conf,
42
- startingRoute: '/explore?query=' + encodeURIComponent(queryString),
43
- });
66
+ await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
44
67
  },
45
68
  };
46
69
  export const command = async (conf) => {
70
+ const modifiers = GraphModifier.maybeLoad(conf.options);
47
71
  const monorepo = conf.options.monorepo;
48
- const mainManifest = conf.options.packageJson.read(conf.options.projectRoot);
49
- const graph = actual.load({
50
- ...conf.options,
51
- mainManifest,
52
- monorepo,
53
- loadManifests: true,
54
- });
55
- const queryString = conf.positionals
56
- .map(k => (/^[@\w-]/.test(k) ? `#${k.replace(/\//, '\\/')}` : k))
72
+ const mainManifest = conf.options.packageJson.maybeRead(conf.options.projectRoot);
73
+ let graph;
74
+ let securityArchive;
75
+ // optionally load the cwd graph if we found a package.json file
76
+ if (mainManifest) {
77
+ graph = actual.load({
78
+ ...conf.options,
79
+ mainManifest,
80
+ modifiers,
81
+ monorepo,
82
+ loadManifests: true,
83
+ });
84
+ securityArchive = await SecurityArchive.start({
85
+ nodes: [...graph.nodes.values()],
86
+ });
87
+ }
88
+ // Validate positional arguments - only allow package names, not direct queries
89
+ for (const arg of conf.positionals) {
90
+ if (!/^[@\w-]/.test(arg)) {
91
+ throw error(`Direct queries are not supported as positional arguments. Use package names only.`, {
92
+ code: 'EUSAGE',
93
+ cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.`,
94
+ });
95
+ }
96
+ }
97
+ // retrieve default values and set up host contexts
98
+ const positionalQueryString = conf.positionals
99
+ .map(k => `#${k.replace(/\//, '\\/')}`)
57
100
  .join(', ');
58
- const query = new Query({ graph, specOptions: conf.options });
59
- const projectQueryString = ':project, :project > *';
101
+ const targetQueryString = conf.get('target');
102
+ const scopeQueryString = conf.get('scope');
103
+ const queryString = targetQueryString || positionalQueryString;
104
+ const projectQueryString = ':workspace, :project > *';
60
105
  const selectImporters = [];
106
+ const hostContexts = await createHostContextsMap(conf);
61
107
  const importers = new Set();
62
- if (monorepo) {
63
- for (const workspace of monorepo.filter(conf.values)) {
64
- const w = graph.nodes.get(workspace.id);
65
- if (w) {
66
- importers.add(w);
67
- selectImporters.push(`[name="${w.name}"]`);
68
- selectImporters.push(`[name="${w.name}"] > *`);
69
- }
108
+ const scopeIDs = [];
109
+ // handle --scope option to add scope nodes as importers
110
+ let scopeNodes;
111
+ if (scopeQueryString) {
112
+ // run scope query to get all matching nodes
113
+ /* c8 ignore start */
114
+ const edges = graph?.edges ?? new Set();
115
+ const nodes = graph?.nodes ?
116
+ new Set(graph.nodes.values())
117
+ : new Set();
118
+ const importers = graph?.importers ?? new Set();
119
+ /* c8 ignore stop */
120
+ const scopeQuery = new Query({
121
+ nodes,
122
+ edges,
123
+ importers,
124
+ securityArchive,
125
+ hostContexts,
126
+ });
127
+ const { nodes: resultNodes } = await scopeQuery.search(scopeQueryString, {
128
+ signal: new AbortController().signal,
129
+ });
130
+ scopeNodes = resultNodes;
131
+ }
132
+ if (scopeQueryString && scopeNodes) {
133
+ // Add all scope nodes to importers Set (treat them as top-level items)
134
+ for (const queryNode of scopeNodes) {
135
+ importers.add(asNode(queryNode));
70
136
  }
71
137
  }
72
- if (importers.size === 0) {
73
- for (const importer of graph.importers) {
74
- importers.add(importer);
138
+ else if ('workspace' in conf.values) {
139
+ // if in a workspace environment, select only the specified
140
+ // workspaces as top-level items
141
+ if (monorepo && graph) {
142
+ for (const workspace of monorepo.filter(conf.values)) {
143
+ const w = graph.nodes.get(workspace.id);
144
+ if (w) {
145
+ importers.add(w);
146
+ selectImporters.push(`[name="${w.name}"]`);
147
+ selectImporters.push(`[name="${w.name}"] > *`);
148
+ scopeIDs.push(workspace.id);
149
+ }
150
+ }
75
151
  }
76
152
  }
153
+ // build a default query string to use in the target search
77
154
  const selectImportersQueryString = selectImporters.join(', ');
78
- const defaultQueryString = (selectImporters.length &&
155
+ const defaultProjectQueryString = (graph &&
156
+ selectImporters.length &&
79
157
  selectImporters.length < graph.importers.size) ?
80
158
  selectImportersQueryString
81
159
  : projectQueryString;
82
- const { edges, nodes } = await query.search(queryString || defaultQueryString);
160
+ const defaultLocalScopeQueryString = ':host(local) :root > *';
161
+ // retrieve the selected nodes and edges
162
+ /* c8 ignore start */
163
+ const edges_ = graph?.edges ?? new Set();
164
+ const nodes_ = graph?.nodes ?
165
+ new Set(graph.nodes.values())
166
+ : new Set();
167
+ const importers_ = importers.size === 0 && graph ?
168
+ new Set([graph.mainImporter])
169
+ : importers;
170
+ /* c8 ignore stop */
171
+ const q = new Query({
172
+ nodes: nodes_,
173
+ edges: edges_,
174
+ importers: importers_,
175
+ securityArchive,
176
+ hostContexts,
177
+ });
178
+ const query = queryString ||
179
+ /* c8 ignore next */
180
+ (graph ? defaultProjectQueryString : defaultLocalScopeQueryString);
181
+ const { edges, nodes, importers: queryResultImporters, } = await q.search(query, {
182
+ signal: new AbortController().signal,
183
+ scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,
184
+ });
83
185
  return {
84
- importers,
186
+ importers: importers.size === 0 ?
187
+ new Set(queryResultImporters)
188
+ : importers,
85
189
  edges,
86
190
  nodes,
87
- queryString: queryString || defaultQueryString,
88
- highlightSelection: !!queryString,
191
+ highlightSelection: !!(targetQueryString || positionalQueryString),
192
+ queryString: queryString ||
193
+ (graph ?
194
+ /* c8 ignore next 2 */
195
+ defaultProjectQueryString
196
+ : defaultLocalScopeQueryString),
89
197
  };
90
198
  };
91
199
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAA;AAOtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,CAAC,EAAE,EAAE,+CAA+C,CAAC;IAC5D,WAAW,EAAE;;4CAE2B;IACxC,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EACT,6DAA6D;SAChE;QACD,GAAG,EAAE;YACH,WAAW,EACT,2DAA2D;SAC9D;QACD,aAAa,EAAE;YACb,WAAW,EAAE,oDAAoD;SAClE;QACD,CAAC,gCAAgC,CAAC,EAAE;YAClC,WAAW,EACT,iDAAiD;SACpD;QACD,CAAC,wBAAwB,CAAC,EAAE;YAC1B,WAAW,EAAE,8CAA8C;SAC5D;KACF;IACD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,KAAK,EAAE,gCAAgC;YACvC,WAAW,EACT,8DAA8D;SACjE;KACF;CACF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put,\n} from '@vltpkg/graph'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: ['', '<query> --view=[human | json | mermaid | gui]'],\n description: `List installed dependencies matching the provided query.\n Defaults to listing direct dependencies of a project and\n any configured workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n '*': {\n description:\n 'List all dependencies for the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n [`'[name=\"@scoped/package\"] > *'`]: {\n description:\n 'Lists direct dependencies of a specific package',\n },\n [`'*.workspace > *.peer'`]: {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\nexport type ListResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI({\n conf,\n startingRoute:\n '/explore?query=' + encodeURIComponent(queryString),\n })\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const queryString = conf.positionals\n .map(k => (/^[@\\w-]/.test(k) ? `#${k.replace(/\\//, '\\\\/')}` : k))\n .join(', ')\n const query = new Query({ graph, specOptions: conf.options })\n const projectQueryString = ':project, :project > *'\n const selectImporters: string[] = []\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n selectImporters.push(`[name=\"${w.name}\"]`)\n selectImporters.push(`[name=\"${w.name}\"] > *`)\n }\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultQueryString =\n (\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n return {\n importers,\n edges,\n nodes,\n queryString: queryString || defaultQueryString,\n highlightSelection: !!queryString,\n }\n}\n"]}
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAajE,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE;QACL,EAAE;QACF,0DAA0D;QAC1D,4EAA4E;KAC7E;IACD,WAAW,EAAE;;;;;;;;;;;;iBAYA;IACb,QAAQ,EAAE;QACR,EAAE,E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CAAA;IACF,MAAM,KAAK,GACT,WAAW;QACX,oBAAoB;QACpB,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,sBAAsB;gBACtB,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport LZString from 'lz-string'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport { startGUI } from '../start-gui.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: [\n '',\n '[package-names...] [--view=human | json | mermaid | gui]',\n '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]',\n ],\n description: `List installed dependencies matching given package names or query selectors.\n\n Package names provided as positional arguments will be used to filter\n the results to show only dependencies with those names.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option allows you to\n filter what dependencies to include in the output. Using both options\n allows you to render subgraphs of the dependency graph.\n\n Defaults to listing direct dependencies of a project and any configured\n workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n '--target=\"*\"': {\n description: 'List all dependencies using a query selector',\n },\n '--target=\":workspace > *:peer\"': {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using the DSS query language syntax.',\n },\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\nexport type ListResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`,\n )\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // Validate positional arguments - only allow package names, not direct queries\n for (const arg of conf.positionals) {\n if (!/^[@\\w-]/.test(arg)) {\n throw error(\n `Direct queries are not supported as positional arguments. Use package names only.`,\n {\n code: 'EUSAGE',\n cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.`,\n },\n )\n }\n }\n\n // retrieve default values and set up host contexts\n const positionalQueryString = conf.positionals\n .map(k => `#${k.replace(/\\//, '\\\\/')}`)\n .join(', ')\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const projectQueryString = ':workspace, :project > *'\n const selectImporters: string[] = []\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n nodes,\n edges,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n selectImporters.push(`[name=\"${w.name}\"]`)\n selectImporters.push(`[name=\"${w.name}\"] > *`)\n scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // build a default query string to use in the target search\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultProjectQueryString =\n (\n graph &&\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n const defaultLocalScopeQueryString = ':host(local) :root > *'\n\n // retrieve the selected nodes and edges\n /* c8 ignore start */\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n /* c8 ignore stop */\n const q = new Query({\n nodes: nodes_,\n edges: edges_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n /* c8 ignore next */\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n /* c8 ignore next 2 */\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ import type { LoadedConfig } from '../config/index.ts';
3
+ export declare const usage: CommandUsage;
4
+ export type CommandResultSingle = {
5
+ id: string;
6
+ name: string;
7
+ version: string;
8
+ filename: string;
9
+ files: string[];
10
+ size: number;
11
+ unpackedSize: number;
12
+ shasum?: string;
13
+ integrity?: string;
14
+ };
15
+ export type CommandResult = CommandResultSingle | CommandResultSingle[];
16
+ export declare const views: {
17
+ readonly human: (results: CommandResult) => string;
18
+ readonly json: (r: CommandResult) => CommandResult;
19
+ };
20
+ export declare const command: CommandFn<CommandResult>;
21
+ export declare const commandSingle: (location: string, conf: LoadedConfig) => Promise<{
22
+ id: string;
23
+ name: string;
24
+ version: string;
25
+ filename: string;
26
+ files: string[];
27
+ size: number;
28
+ unpackedSize: number;
29
+ shasum: string | undefined;
30
+ integrity: string | undefined;
31
+ }>;
32
+ //# sourceMappingURL=pack.d.ts.map