@vltpkg/cli-sdk 0.0.0-2 → 0.0.0-21

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 (153) hide show
  1. package/README.md +3 -0
  2. package/dist/esm/commands/cache.d.ts +65 -0
  3. package/dist/esm/commands/cache.d.ts.map +1 -0
  4. package/dist/esm/commands/cache.js +257 -0
  5. package/dist/esm/commands/cache.js.map +1 -0
  6. package/dist/esm/commands/ci.d.ts +10 -0
  7. package/dist/esm/commands/ci.d.ts.map +1 -0
  8. package/dist/esm/commands/ci.js +29 -0
  9. package/dist/esm/commands/ci.js.map +1 -0
  10. package/dist/esm/commands/config.d.ts.map +1 -1
  11. package/dist/esm/commands/config.js +2 -52
  12. package/dist/esm/commands/config.js.map +1 -1
  13. package/dist/esm/commands/exec-cache.d.ts +49 -0
  14. package/dist/esm/commands/exec-cache.d.ts.map +1 -0
  15. package/dist/esm/commands/exec-cache.js +134 -0
  16. package/dist/esm/commands/exec-cache.js.map +1 -0
  17. package/dist/esm/commands/exec-local.d.ts +6 -0
  18. package/dist/esm/commands/exec-local.d.ts.map +1 -0
  19. package/dist/esm/commands/exec-local.js +24 -0
  20. package/dist/esm/commands/exec-local.js.map +1 -0
  21. package/dist/esm/commands/exec.d.ts +4 -0
  22. package/dist/esm/commands/exec.d.ts.map +1 -1
  23. package/dist/esm/commands/exec.js +69 -10
  24. package/dist/esm/commands/exec.js.map +1 -1
  25. package/dist/esm/commands/gui.d.ts.map +1 -1
  26. package/dist/esm/commands/gui.js +1 -2
  27. package/dist/esm/commands/gui.js.map +1 -1
  28. package/dist/esm/commands/help.d.ts +1 -1
  29. package/dist/esm/commands/help.d.ts.map +1 -1
  30. package/dist/esm/commands/help.js +25 -3
  31. package/dist/esm/commands/help.js.map +1 -1
  32. package/dist/esm/commands/init.d.ts +4 -5
  33. package/dist/esm/commands/init.d.ts.map +1 -1
  34. package/dist/esm/commands/init.js +95 -9
  35. package/dist/esm/commands/init.js.map +1 -1
  36. package/dist/esm/commands/install/reporter.d.ts.map +1 -1
  37. package/dist/esm/commands/install/reporter.js +2 -1
  38. package/dist/esm/commands/install/reporter.js.map +1 -1
  39. package/dist/esm/commands/install.d.ts +5 -2
  40. package/dist/esm/commands/install.d.ts.map +1 -1
  41. package/dist/esm/commands/install.js +7 -1
  42. package/dist/esm/commands/install.js.map +1 -1
  43. package/dist/esm/commands/list.d.ts +2 -2
  44. package/dist/esm/commands/list.d.ts.map +1 -1
  45. package/dist/esm/commands/list.js +108 -31
  46. package/dist/esm/commands/list.js.map +1 -1
  47. package/dist/esm/commands/pack.d.ts +20 -0
  48. package/dist/esm/commands/pack.d.ts.map +1 -0
  49. package/dist/esm/commands/pack.js +81 -0
  50. package/dist/esm/commands/pack.js.map +1 -0
  51. package/dist/esm/commands/pkg.d.ts +2 -3
  52. package/dist/esm/commands/pkg.d.ts.map +1 -1
  53. package/dist/esm/commands/pkg.js +136 -34
  54. package/dist/esm/commands/pkg.js.map +1 -1
  55. package/dist/esm/commands/publish.d.ts +21 -0
  56. package/dist/esm/commands/publish.d.ts.map +1 -0
  57. package/dist/esm/commands/publish.js +169 -0
  58. package/dist/esm/commands/publish.js.map +1 -0
  59. package/dist/esm/commands/query.d.ts +2 -2
  60. package/dist/esm/commands/query.d.ts.map +1 -1
  61. package/dist/esm/commands/query.js +134 -21
  62. package/dist/esm/commands/query.js.map +1 -1
  63. package/dist/esm/commands/run-exec.d.ts +1 -0
  64. package/dist/esm/commands/run-exec.d.ts.map +1 -1
  65. package/dist/esm/commands/run-exec.js +1 -0
  66. package/dist/esm/commands/run-exec.js.map +1 -1
  67. package/dist/esm/commands/run.d.ts +1 -0
  68. package/dist/esm/commands/run.d.ts.map +1 -1
  69. package/dist/esm/commands/run.js +13 -16
  70. package/dist/esm/commands/run.js.map +1 -1
  71. package/dist/esm/commands/uninstall.d.ts +7 -1
  72. package/dist/esm/commands/uninstall.d.ts.map +1 -1
  73. package/dist/esm/commands/uninstall.js +7 -1
  74. package/dist/esm/commands/uninstall.js.map +1 -1
  75. package/dist/esm/commands/update.d.ts +10 -0
  76. package/dist/esm/commands/update.d.ts.map +1 -0
  77. package/dist/esm/commands/update.js +25 -0
  78. package/dist/esm/commands/update.js.map +1 -0
  79. package/dist/esm/commands/version.d.ts +22 -0
  80. package/dist/esm/commands/version.d.ts.map +1 -0
  81. package/dist/esm/commands/version.js +151 -0
  82. package/dist/esm/commands/version.js.map +1 -0
  83. package/dist/esm/commands/whoami.d.ts +4 -2
  84. package/dist/esm/commands/whoami.d.ts.map +1 -1
  85. package/dist/esm/commands/whoami.js +1 -1
  86. package/dist/esm/commands/whoami.js.map +1 -1
  87. package/dist/esm/config/definition.d.ts +85 -7
  88. package/dist/esm/config/definition.d.ts.map +1 -1
  89. package/dist/esm/config/definition.js +152 -23
  90. package/dist/esm/config/definition.js.map +1 -1
  91. package/dist/esm/config/index.d.ts +46 -40
  92. package/dist/esm/config/index.d.ts.map +1 -1
  93. package/dist/esm/config/index.js +124 -176
  94. package/dist/esm/config/index.js.map +1 -1
  95. package/dist/esm/config/merge.d.ts +3 -1
  96. package/dist/esm/config/merge.d.ts.map +1 -1
  97. package/dist/esm/config/merge.js +11 -6
  98. package/dist/esm/config/merge.js.map +1 -1
  99. package/dist/esm/config/usage.d.ts +3 -2
  100. package/dist/esm/config/usage.d.ts.map +1 -1
  101. package/dist/esm/config/usage.js.map +1 -1
  102. package/dist/esm/exec-command.d.ts +32 -14
  103. package/dist/esm/exec-command.d.ts.map +1 -1
  104. package/dist/esm/exec-command.js +195 -63
  105. package/dist/esm/exec-command.js.map +1 -1
  106. package/dist/esm/index.d.ts +1 -14
  107. package/dist/esm/index.d.ts.map +1 -1
  108. package/dist/esm/index.js +46 -20
  109. package/dist/esm/index.js.map +1 -1
  110. package/dist/esm/load-command.d.ts +16 -0
  111. package/dist/esm/load-command.d.ts.map +1 -0
  112. package/dist/esm/load-command.js +21 -0
  113. package/dist/esm/load-command.js.map +1 -0
  114. package/dist/esm/output.d.ts +6 -10
  115. package/dist/esm/output.d.ts.map +1 -1
  116. package/dist/esm/output.js +62 -32
  117. package/dist/esm/output.js.map +1 -1
  118. package/dist/esm/pack-tarball.d.ts +22 -0
  119. package/dist/esm/pack-tarball.d.ts.map +1 -0
  120. package/dist/esm/pack-tarball.js +247 -0
  121. package/dist/esm/pack-tarball.js.map +1 -0
  122. package/dist/esm/parse-add-remove-args.d.ts +1 -1
  123. package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
  124. package/dist/esm/parse-add-remove-args.js +1 -1
  125. package/dist/esm/parse-add-remove-args.js.map +1 -1
  126. package/dist/esm/print-err.d.ts +12 -1
  127. package/dist/esm/print-err.d.ts.map +1 -1
  128. package/dist/esm/print-err.js +157 -26
  129. package/dist/esm/print-err.js.map +1 -1
  130. package/dist/esm/start-gui.d.ts +7 -33
  131. package/dist/esm/start-gui.d.ts.map +1 -1
  132. package/dist/esm/start-gui.js +33 -347
  133. package/dist/esm/start-gui.js.map +1 -1
  134. package/dist/esm/view.d.ts +2 -3
  135. package/dist/esm/view.d.ts.map +1 -1
  136. package/dist/esm/view.js.map +1 -1
  137. package/package.json +69 -44
  138. package/dist/esm/commands/install-exec.d.ts +0 -4
  139. package/dist/esm/commands/install-exec.d.ts.map +0 -1
  140. package/dist/esm/commands/install-exec.js +0 -13
  141. package/dist/esm/commands/install-exec.js.map +0 -1
  142. package/dist/esm/ignored-homedir-folder-names.d.ts +0 -7
  143. package/dist/esm/ignored-homedir-folder-names.d.ts.map +0 -1
  144. package/dist/esm/ignored-homedir-folder-names.js +0 -35
  145. package/dist/esm/ignored-homedir-folder-names.js.map +0 -1
  146. package/dist/esm/project-info.d.ts +0 -32
  147. package/dist/esm/project-info.d.ts.map +0 -1
  148. package/dist/esm/project-info.js +0 -90
  149. package/dist/esm/project-info.js.map +0 -1
  150. package/dist/esm/read-project-folders.d.ts +0 -27
  151. package/dist/esm/read-project-folders.d.ts.map +0 -1
  152. package/dist/esm/read-project-folders.js +0 -66
  153. package/dist/esm/read-project-folders.js.map +0 -1
@@ -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,IAAI,EACJ,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAC7B,CAAA;IACH,CAAC;IACD,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,GAAG,EAAE;IACf,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAE3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAEhC;Q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AM,SAAS,GAAG,GAAG,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;QACtD,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,GAAG,EAAE,IAAI,EAAE,EACb,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAC/C,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,CACtC,CAAA;IACH,CAAC,CACF,CACF,EACD,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAC5D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,SAAS,GAAoB,IAAI,CAAA;IAEjC,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,CAAC,OAAgB,EAAE,EAAE,IAAI,EAAoB;QAC/C,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAA;QACzB,MAAM,CAAC,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,E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J,EAAE,GAAG,EAAE,IAAI,EAAE,EACb,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAC/C,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,CACtC,CAAA;IACH,CAAC,CACF,CACF,EACD,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAC5D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,SAAS,GAAoB,IAAI,CAAA;IAEjC,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,CAAC,OAAgB,EAAE,EAAE,IAAI,EAAoB;QAC/C,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAA;QACzB,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,CAAA;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,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'\nimport { asError } from '@vltpkg/types'\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(asError(err))\n }\n}\n"]}
@@ -1,7 +1,10 @@
1
1
  import type { Graph } from '@vltpkg/graph';
2
2
  import type { CommandFn, CommandUsage } from '../index.ts';
3
- import type { Views } from '../view.ts';
3
+ import { InstallReporter } from './install/reporter.ts';
4
4
  export declare const usage: CommandUsage;
5
- export declare const views: Views<Graph>;
5
+ export declare const views: {
6
+ readonly json: (g: Graph) => import("@vltpkg/graph").LockfileData;
7
+ readonly human: typeof InstallReporter;
8
+ };
6
9
  export declare const command: CommandFn<Graph>;
7
10
  //# 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":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CAcpC,CAAA"}
@@ -15,7 +15,13 @@ export const views = {
15
15
  export const command = async (conf) => {
16
16
  const monorepo = conf.options.monorepo;
17
17
  const { add } = parseAddArgs(conf, monorepo);
18
- const { graph } = await install(conf.options, add);
18
+ const frozenLockfile = conf.options['frozen-lockfile'];
19
+ const expectLockfile = conf.options['expect-lockfile'];
20
+ const { graph } = await install({
21
+ ...conf.options,
22
+ frozenLockfile,
23
+ expectLockfile,
24
+ }, add);
19
25
  return graph;
20
26
  };
21
27
  //# 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":"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,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACS,CAAA;AAEjC,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,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACtD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACtD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAC7B;QACE,GAAG,IAAI,CAAC,OAAO;QACf,cAAc;QACd,cAAc;KACf,EACD,GAAG,CACJ,CAAA;IACD,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 = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\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 { graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n },\n add,\n )\n return graph\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
2
1
  import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
2
+ import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
3
3
  import type { CommandFn, CommandUsage } from '../index.ts';
4
4
  export declare const usage: CommandUsage;
5
5
  export type ListResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
@@ -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,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;AAOtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,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,CAwHzC,CAAA"}
@@ -1,31 +1,56 @@
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";
5
8
  export const usage = () => commandUsage({
6
9
  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.`,
10
+ usage: [
11
+ '',
12
+ '[package-names...] [--view=human | json | mermaid | gui]',
13
+ '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]',
14
+ ],
15
+ description: `List installed dependencies matching given package names or query selectors.
16
+
17
+ Package names provided as positional arguments will be used to filter
18
+ the results to show only dependencies with those names.
19
+
20
+ The --scope and --target options accepts DSS query selectors to filter
21
+ packages. Using --scope, you can specify which packages to treat as the
22
+ top-level items in the output graph. The --target option allows you to
23
+ filter what dependencies to include in the output. Using both options
24
+ allows you to render subgraphs of the dependency graph.
25
+
26
+ Defaults to listing direct dependencies of a project and any configured
27
+ workspace.`,
11
28
  examples: {
12
29
  '': {
13
30
  description: 'List direct dependencies of the current project / workspace',
14
31
  },
15
- '*': {
16
- description: 'List all dependencies for the current project / workspace',
17
- },
18
32
  'foo bar baz': {
19
33
  description: `List all dependencies named 'foo', 'bar', or 'baz'`,
20
34
  },
21
- [`'[name="@scoped/package"] > *'`]: {
22
- description: 'Lists direct dependencies of a specific package',
35
+ '--scope=":root > #dependency-name"': {
36
+ description: 'Defines a direct dependency as the output top-level scope',
37
+ },
38
+ '--target="*"': {
39
+ description: 'List all dependencies using a query selector',
23
40
  },
24
- [`'*.workspace > *.peer'`]: {
41
+ '--target=":workspace > *:peer"': {
25
42
  description: 'List all peer dependencies of all workspaces',
26
43
  },
27
44
  },
28
45
  options: {
46
+ scope: {
47
+ value: '<query>',
48
+ description: 'Query selector to select top-level packages using the DSS query language syntax.',
49
+ },
50
+ target: {
51
+ value: '<query>',
52
+ description: 'Query selector to filter packages using the DSS query language syntax.',
53
+ },
29
54
  view: {
30
55
  value: '[human | json | mermaid | gui]',
31
56
  description: 'Output format. Defaults to human-readable or json if no tty.',
@@ -37,55 +62,107 @@ export const views = {
37
62
  mermaid: mermaidOutput,
38
63
  human: humanReadableOutput,
39
64
  gui: async ({ queryString }, _, conf) => {
40
- await startGUI({
41
- conf,
42
- startingRoute: '/explore?query=' + encodeURIComponent(queryString),
43
- });
65
+ await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
44
66
  },
45
67
  };
46
68
  export const command = async (conf) => {
69
+ const modifiers = GraphModifier.maybeLoad(conf.options);
47
70
  const monorepo = conf.options.monorepo;
48
71
  const mainManifest = conf.options.packageJson.read(conf.options.projectRoot);
49
72
  const graph = actual.load({
50
73
  ...conf.options,
51
74
  mainManifest,
75
+ modifiers,
52
76
  monorepo,
53
77
  loadManifests: true,
54
78
  });
55
- const queryString = conf.positionals
56
- .map(k => (/^[@\w-]/.test(k) ? `#${k.replace(/\//, '\\/')}` : k))
79
+ // Validate positional arguments - only allow package names, not direct queries
80
+ for (const arg of conf.positionals) {
81
+ if (!/^[@\w-]/.test(arg)) {
82
+ throw error(`Direct queries are not supported as positional arguments. Use package names only.`, {
83
+ code: 'EUSAGE',
84
+ cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.`,
85
+ });
86
+ }
87
+ }
88
+ const positionalQueryString = conf.positionals
89
+ .map(k => `#${k.replace(/\//, '\\/')}`)
57
90
  .join(', ');
58
- const query = new Query({ graph, specOptions: conf.options });
91
+ const targetQueryString = conf.get('target');
92
+ const queryString = targetQueryString || positionalQueryString;
93
+ const securityArchive = await SecurityArchive.start({
94
+ graph,
95
+ specOptions: conf.options,
96
+ });
97
+ const query = new Query({
98
+ graph,
99
+ specOptions: conf.options,
100
+ securityArchive,
101
+ });
59
102
  const projectQueryString = ':project, :project > *';
60
103
  const selectImporters = [];
61
104
  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
- }
105
+ const scopeIDs = [];
106
+ // handle --scope option to add scope nodes as importers
107
+ const scopeQueryString = conf.get('scope');
108
+ let scopeNodes;
109
+ if (scopeQueryString) {
110
+ // run scope query to get all matching nodes
111
+ const scopeQuery = new Query({
112
+ graph,
113
+ specOptions: conf.options,
114
+ securityArchive,
115
+ });
116
+ const { nodes } = await scopeQuery.search(scopeQueryString, {
117
+ signal: new AbortController().signal,
118
+ });
119
+ scopeNodes = nodes;
120
+ }
121
+ if (scopeQueryString && scopeNodes) {
122
+ // Add all scope nodes to importers Set (treat them as top-level items)
123
+ for (const queryNode of scopeNodes) {
124
+ importers.add(asNode(queryNode));
70
125
  }
71
126
  }
72
- if (importers.size === 0) {
73
- for (const importer of graph.importers) {
74
- importers.add(importer);
127
+ else {
128
+ // if in a workspace environment, select only the specified
129
+ // workspaces as top-level items
130
+ if (monorepo) {
131
+ for (const workspace of monorepo.filter(conf.values)) {
132
+ const w = graph.nodes.get(workspace.id);
133
+ if (w) {
134
+ importers.add(w);
135
+ selectImporters.push(`[name="${w.name}"]`);
136
+ selectImporters.push(`[name="${w.name}"] > *`);
137
+ scopeIDs.push(workspace.id);
138
+ }
139
+ }
140
+ }
141
+ // if no top-level item was set then by default
142
+ // we just set all importers as top-level items
143
+ if (importers.size === 0) {
144
+ for (const importer of graph.importers) {
145
+ importers.add(importer);
146
+ }
75
147
  }
76
148
  }
149
+ // build a default query string to use in the target search
77
150
  const selectImportersQueryString = selectImporters.join(', ');
78
151
  const defaultQueryString = (selectImporters.length &&
79
152
  selectImporters.length < graph.importers.size) ?
80
153
  selectImportersQueryString
81
154
  : projectQueryString;
82
- const { edges, nodes } = await query.search(queryString || defaultQueryString);
155
+ // retrieve the selected nodes and edges
156
+ const { edges, nodes } = await query.search(queryString || defaultQueryString, {
157
+ signal: new AbortController().signal,
158
+ scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,
159
+ });
83
160
  return {
84
161
  importers,
85
162
  edges,
86
163
  nodes,
87
164
  queryString: queryString || defaultQueryString,
88
- highlightSelection: !!queryString,
165
+ highlightSelection: !!(targetQueryString || positionalQueryString),
89
166
  };
90
167
  };
91
168
  //# 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,8D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\n jsonOutput,\n mermaidOutput,\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":"AAMA,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;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,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;QACL,EAAE;QACF,0DAA0D;QAC1D,4EAA4E;KAC7E;IACD,WAAW,EAAE;;;;;;;;;;;;iBAYA;IACb,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EACT,6DAA6D;SA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AAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,2DAA2D;IAC3D,MAAM,0BAA0B,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7D,MAAM,kBAAkB,GACtB,CACE,eAAe,CAAC,MAAM;QACtB,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAC9C,CAAC,CAAC;QACD,0BAA0B;QAC5B,CAAC,CAAC,kBAAkB,CAAA;IAEtB,wCAAwC;IACxC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,EACjC;QACE,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CACF,CAAA;IAED,OAAO;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,WAAW,EAAE,WAAW,IAAI,kBAAkB;QAC9C,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\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 type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\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: [\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.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\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 const positionalQueryString = conf.positionals\n .map(k => `#${k.replace(/\\//, '\\\\/')}`)\n .join(', ')\n const targetQueryString = conf.get('target')\n const queryString = targetQueryString || positionalQueryString\n\n const securityArchive = await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n const projectQueryString = ':project, :project > *'\n const selectImporters: string[] = []\n\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // handle --scope option to add scope nodes as importers\n const scopeQueryString = conf.get('scope')\n let scopeNodes\n if (scopeQueryString) {\n // run scope query to get all matching nodes\n const scopeQuery = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n const { nodes } = await scopeQuery.search(scopeQueryString, {\n signal: new AbortController().signal,\n })\n scopeNodes = nodes\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 {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\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 scopeIDs.push(workspace.id)\n }\n }\n }\n // if no top-level item was set then by default\n // we just set all importers as top-level items\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n }\n\n // build a default query string to use in the target search\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 // retrieve the selected nodes and edges\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n },\n )\n\n return {\n importers,\n edges,\n nodes,\n queryString: queryString || defaultQueryString,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ type CommandResult = {
4
+ id: string;
5
+ name: string;
6
+ version: string;
7
+ filename: string;
8
+ files: string[];
9
+ size: number;
10
+ unpackedSize: number;
11
+ shasum?: string;
12
+ integrity?: string;
13
+ };
14
+ export declare const views: {
15
+ readonly human: (r: CommandResult) => string;
16
+ readonly json: (r: CommandResult) => CommandResult;
17
+ };
18
+ export declare const command: CommandFn<CommandResult>;
19
+ export {};
20
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1D,eAAO,MAAM,KAAK,EAAE,YAchB,CAAA;AAEJ,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,KAAK;;;CAeuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAyD5C,CAAA"}
@@ -0,0 +1,81 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { dirname, join } from 'node:path';
3
+ import assert from 'node:assert';
4
+ import { run } from '@vltpkg/run';
5
+ import { commandUsage } from "../config/usage.js";
6
+ import { packTarball } from "../pack-tarball.js";
7
+ import prettyBytes from 'pretty-bytes';
8
+ export const usage = () => commandUsage({
9
+ command: 'pack',
10
+ usage: '',
11
+ description: `Create a tarball from a package in the current directory or specified folder.
12
+
13
+ The tarball will be saved to the current directory with the name
14
+ <name>-<version>.tgz.`,
15
+ options: {
16
+ 'dry-run': {
17
+ description: 'Show what would be packed without creating a tarball',
18
+ },
19
+ },
20
+ });
21
+ export const views = {
22
+ human: r => {
23
+ const lines = [
24
+ `📦 Package: ${r.id}`,
25
+ `📄 File: ${r.filename}`,
26
+ `📁 ${r.files.length} Files`,
27
+ ...r.files.map(f => ` - ${f}`),
28
+ `📊 Package Size: ${prettyBytes(r.size)}`,
29
+ `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,
30
+ ];
31
+ if (r.shasum)
32
+ lines.push(`🔒 Shasum: ${r.shasum}`);
33
+ if (r.integrity)
34
+ lines.push(`🔐 Integrity: ${r.integrity}`);
35
+ return lines.join('\n');
36
+ },
37
+ json: r => r,
38
+ };
39
+ export const command = async (conf) => {
40
+ const manifestPath = conf.options.packageJson.find();
41
+ assert(manifestPath, 'No package.json found');
42
+ const manifestDir = dirname(manifestPath);
43
+ const manifest = conf.options.packageJson.read(manifestDir);
44
+ const isDryRun = conf.options['dry-run'];
45
+ const runOptions = {
46
+ cwd: manifestDir,
47
+ projectRoot: conf.projectRoot,
48
+ packageJson: conf.options.packageJson,
49
+ manifest,
50
+ ignoreMissing: true,
51
+ ignorePrePost: true,
52
+ };
53
+ await run({
54
+ ...runOptions,
55
+ arg0: 'prepack',
56
+ });
57
+ await run({
58
+ ...runOptions,
59
+ arg0: 'prepare',
60
+ });
61
+ const { name, version, filename, tarballData, unpackedSize, files, integrity, shasum, } = await packTarball(manifest, manifestDir, conf);
62
+ if (!isDryRun) {
63
+ await writeFile(join(manifestDir, filename), tarballData);
64
+ }
65
+ await run({
66
+ ...runOptions,
67
+ arg0: 'postpack',
68
+ });
69
+ return {
70
+ id: `${name}@${version}`,
71
+ name,
72
+ version,
73
+ filename,
74
+ files,
75
+ size: tarballData.length,
76
+ unpackedSize,
77
+ shasum,
78
+ integrity,
79
+ };
80
+ };
81
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../src/commands/pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,WAAW,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;0BAGS;IACtB,OAAO,EAAE;QACP,SAAS,EAAE;YACT,WAAW,EACT,sDAAsD;SACzD;KACF;CACF,CAAC,CAAA;AAcJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,CAAC,EAAE;QACT,MAAM,KAAK,GAAG;YACZ,eAAe,CAAC,CAAC,EAAE,EAAE;YACrB,YAAY,CAAC,CAAC,QAAQ,EAAE;YACxB,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,QAAQ;YAC5B,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,oBAAoB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,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,KAAK,EACL,SAAS,EACT,MAAM,GACP,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;IAElD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,GAAG,CAAC;QACR,GAAG,UAAU;QACb,IAAI,EAAE,UAAU;KACjB,CAAC,CAAA;IAEF,OAAO;QACL,EAAE,EAAE,GAAG,IAAI,IAAI,OAAO,EAAE;QACxB,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,KAAK;QACL,IAAI,EAAE,WAAW,CAAC,MAAM;QACxB,YAAY;QACZ,MAAM;QACN,SAAS;KACV,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport assert from 'node:assert'\nimport { run } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { packTarball } from '../pack-tarball.ts'\nimport type { Views } from '../view.ts'\nimport prettyBytes from 'pretty-bytes'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pack',\n usage: '',\n description: `Create a tarball from a package in the current directory or specified folder.\n \n The tarball will be saved to the current directory with the name\n <name>-<version>.tgz.`,\n options: {\n 'dry-run': {\n description:\n 'Show what would be packed without creating a tarball',\n },\n },\n })\n\ntype CommandResult = {\n id: string\n name: string\n version: string\n filename: string\n files: string[]\n size: number\n unpackedSize: number\n shasum?: string\n integrity?: string\n}\n\nexport const views = {\n human: r => {\n const lines = [\n `📦 Package: ${r.id}`,\n `📄 File: ${r.filename}`,\n `📁 ${r.files.length} Files`,\n ...r.files.map(f => ` - ${f}`),\n `📊 Package Size: ${prettyBytes(r.size)}`,\n `📂 Unpacked Size: ${prettyBytes(r.unpackedSize)}`,\n ]\n if (r.shasum) lines.push(`🔒 Shasum: ${r.shasum}`)\n if (r.integrity) lines.push(`🔐 Integrity: ${r.integrity}`)\n return lines.join('\\n')\n },\n json: r => r,\n} as const satisfies Views<CommandResult>\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const manifestPath = conf.options.packageJson.find()\n assert(manifestPath, 'No package.json found')\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n const isDryRun = conf.options['dry-run']\n const runOptions = {\n cwd: manifestDir,\n projectRoot: conf.projectRoot,\n packageJson: conf.options.packageJson,\n manifest,\n ignoreMissing: true,\n ignorePrePost: true,\n }\n\n await run({\n ...runOptions,\n arg0: 'prepack',\n })\n\n await run({\n ...runOptions,\n arg0: 'prepare',\n })\n\n const {\n name,\n version,\n filename,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n } = await packTarball(manifest, manifestDir, conf)\n\n if (!isDryRun) {\n await writeFile(join(manifestDir, filename), tarballData)\n }\n\n await run({\n ...runOptions,\n arg0: 'postpack',\n })\n\n return {\n id: `${name}@${version}`,\n name,\n version,\n filename,\n files,\n size: tarballData.length,\n unpackedSize,\n shasum,\n integrity,\n }\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import type { CommandFn, CommandUsage } from '../index.ts';
2
- import type { ViewFn, Views } from '../view.ts';
3
- export declare const views: Views & {
4
- human: ViewFn;
2
+ export declare const views: {
3
+ readonly human: (_results: unknown, _options: import("../view.ts").ViewOptions, config: import("../config/index.ts").ParsedConfig) => string;
5
4
  };
6
5
  export declare const usage: CommandUsage;
7
6
  export declare const command: CommandFn;
@@ -1 +1 @@
1
- {"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAG/C,eAAO,MAAM,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAa1C,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA6BrB,CAAA"}
1
+ {"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAoB1D,eAAO,MAAM,KAAK;;CAmBQ,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA8FrB,CAAA"}