@vltpkg/cli-sdk 0.0.0-2

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 (136) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +20 -0
  3. package/dist/esm/commands/config.d.ts +5 -0
  4. package/dist/esm/commands/config.d.ts.map +1 -0
  5. package/dist/esm/commands/config.js +153 -0
  6. package/dist/esm/commands/config.js.map +1 -0
  7. package/dist/esm/commands/exec.d.ts +5 -0
  8. package/dist/esm/commands/exec.d.ts.map +1 -0
  9. package/dist/esm/commands/exec.js +22 -0
  10. package/dist/esm/commands/exec.js.map +1 -0
  11. package/dist/esm/commands/gui.d.ts +6 -0
  12. package/dist/esm/commands/gui.d.ts.map +1 -0
  13. package/dist/esm/commands/gui.js +14 -0
  14. package/dist/esm/commands/gui.js.map +1 -0
  15. package/dist/esm/commands/help.d.ts +4 -0
  16. package/dist/esm/commands/help.d.ts.map +1 -0
  17. package/dist/esm/commands/help.js +10 -0
  18. package/dist/esm/commands/help.js.map +1 -0
  19. package/dist/esm/commands/init.d.ts +9 -0
  20. package/dist/esm/commands/init.d.ts.map +1 -0
  21. package/dist/esm/commands/init.js +25 -0
  22. package/dist/esm/commands/init.js.map +1 -0
  23. package/dist/esm/commands/install/reporter.d.ts +10 -0
  24. package/dist/esm/commands/install/reporter.d.ts.map +1 -0
  25. package/dist/esm/commands/install/reporter.js +66 -0
  26. package/dist/esm/commands/install/reporter.js.map +1 -0
  27. package/dist/esm/commands/install-exec.d.ts +4 -0
  28. package/dist/esm/commands/install-exec.d.ts.map +1 -0
  29. package/dist/esm/commands/install-exec.js +13 -0
  30. package/dist/esm/commands/install-exec.js.map +1 -0
  31. package/dist/esm/commands/install.d.ts +7 -0
  32. package/dist/esm/commands/install.d.ts.map +1 -0
  33. package/dist/esm/commands/install.js +21 -0
  34. package/dist/esm/commands/install.js.map +1 -0
  35. package/dist/esm/commands/list.d.ts +15 -0
  36. package/dist/esm/commands/list.d.ts.map +1 -0
  37. package/dist/esm/commands/list.js +91 -0
  38. package/dist/esm/commands/list.js.map +1 -0
  39. package/dist/esm/commands/login.d.ts +4 -0
  40. package/dist/esm/commands/login.d.ts.map +1 -0
  41. package/dist/esm/commands/login.js +13 -0
  42. package/dist/esm/commands/login.js.map +1 -0
  43. package/dist/esm/commands/logout.d.ts +4 -0
  44. package/dist/esm/commands/logout.d.ts.map +1 -0
  45. package/dist/esm/commands/logout.js +13 -0
  46. package/dist/esm/commands/logout.js.map +1 -0
  47. package/dist/esm/commands/pkg.d.ts +8 -0
  48. package/dist/esm/commands/pkg.d.ts.map +1 -0
  49. package/dist/esm/commands/pkg.js +121 -0
  50. package/dist/esm/commands/pkg.js.map +1 -0
  51. package/dist/esm/commands/query.d.ts +16 -0
  52. package/dist/esm/commands/query.d.ts.map +1 -0
  53. package/dist/esm/commands/query.js +75 -0
  54. package/dist/esm/commands/query.js.map +1 -0
  55. package/dist/esm/commands/run-exec.d.ts +5 -0
  56. package/dist/esm/commands/run-exec.d.ts.map +1 -0
  57. package/dist/esm/commands/run-exec.js +13 -0
  58. package/dist/esm/commands/run-exec.js.map +1 -0
  59. package/dist/esm/commands/run.d.ts +5 -0
  60. package/dist/esm/commands/run.d.ts.map +1 -0
  61. package/dist/esm/commands/run.js +39 -0
  62. package/dist/esm/commands/run.js.map +1 -0
  63. package/dist/esm/commands/token.d.ts +4 -0
  64. package/dist/esm/commands/token.d.ts.map +1 -0
  65. package/dist/esm/commands/token.js +30 -0
  66. package/dist/esm/commands/token.js.map +1 -0
  67. package/dist/esm/commands/uninstall.d.ts +4 -0
  68. package/dist/esm/commands/uninstall.d.ts.map +1 -0
  69. package/dist/esm/commands/uninstall.js +15 -0
  70. package/dist/esm/commands/uninstall.js.map +1 -0
  71. package/dist/esm/commands/whoami.d.ts +11 -0
  72. package/dist/esm/commands/whoami.d.ts.map +1 -0
  73. package/dist/esm/commands/whoami.js +19 -0
  74. package/dist/esm/commands/whoami.js.map +1 -0
  75. package/dist/esm/config/definition.d.ts +286 -0
  76. package/dist/esm/config/definition.d.ts.map +1 -0
  77. package/dist/esm/config/definition.js +475 -0
  78. package/dist/esm/config/definition.js.map +1 -0
  79. package/dist/esm/config/index.d.ts +213 -0
  80. package/dist/esm/config/index.d.ts.map +1 -0
  81. package/dist/esm/config/index.js +504 -0
  82. package/dist/esm/config/index.js.map +1 -0
  83. package/dist/esm/config/merge.d.ts +2 -0
  84. package/dist/esm/config/merge.d.ts.map +1 -0
  85. package/dist/esm/config/merge.js +23 -0
  86. package/dist/esm/config/merge.js.map +1 -0
  87. package/dist/esm/config/usage.d.ts +18 -0
  88. package/dist/esm/config/usage.d.ts.map +1 -0
  89. package/dist/esm/config/usage.js +40 -0
  90. package/dist/esm/config/usage.js.map +1 -0
  91. package/dist/esm/exec-command.d.ts +34 -0
  92. package/dist/esm/exec-command.d.ts.map +1 -0
  93. package/dist/esm/exec-command.js +159 -0
  94. package/dist/esm/exec-command.js.map +1 -0
  95. package/dist/esm/ignored-homedir-folder-names.d.ts +7 -0
  96. package/dist/esm/ignored-homedir-folder-names.d.ts.map +1 -0
  97. package/dist/esm/ignored-homedir-folder-names.js +35 -0
  98. package/dist/esm/ignored-homedir-folder-names.js.map +1 -0
  99. package/dist/esm/index.d.ts +17 -0
  100. package/dist/esm/index.d.ts.map +1 -0
  101. package/dist/esm/index.js +47 -0
  102. package/dist/esm/index.js.map +1 -0
  103. package/dist/esm/output.d.ts +25 -0
  104. package/dist/esm/output.d.ts.map +1 -0
  105. package/dist/esm/output.js +86 -0
  106. package/dist/esm/output.js.map +1 -0
  107. package/dist/esm/package.json +3 -0
  108. package/dist/esm/parse-add-remove-args.d.ts +22 -0
  109. package/dist/esm/parse-add-remove-args.d.ts.map +1 -0
  110. package/dist/esm/parse-add-remove-args.js +71 -0
  111. package/dist/esm/parse-add-remove-args.js.map +1 -0
  112. package/dist/esm/print-err.d.ts +3 -0
  113. package/dist/esm/print-err.d.ts.map +1 -0
  114. package/dist/esm/print-err.js +47 -0
  115. package/dist/esm/print-err.js.map +1 -0
  116. package/dist/esm/project-info.d.ts +32 -0
  117. package/dist/esm/project-info.d.ts.map +1 -0
  118. package/dist/esm/project-info.js +90 -0
  119. package/dist/esm/project-info.js.map +1 -0
  120. package/dist/esm/read-password.d.ts +8 -0
  121. package/dist/esm/read-password.d.ts.map +1 -0
  122. package/dist/esm/read-password.js +33 -0
  123. package/dist/esm/read-password.js.map +1 -0
  124. package/dist/esm/read-project-folders.d.ts +27 -0
  125. package/dist/esm/read-project-folders.d.ts.map +1 -0
  126. package/dist/esm/read-project-folders.js +66 -0
  127. package/dist/esm/read-project-folders.js.map +1 -0
  128. package/dist/esm/start-gui.d.ts +36 -0
  129. package/dist/esm/start-gui.d.ts.map +1 -0
  130. package/dist/esm/start-gui.js +357 -0
  131. package/dist/esm/start-gui.js.map +1 -0
  132. package/dist/esm/view.d.ts +31 -0
  133. package/dist/esm/view.d.ts.map +1 -0
  134. package/dist/esm/view.js +31 -0
  135. package/dist/esm/view.js.map +1 -0
  136. package/package.json +107 -0
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright (c) vlt technology, Inc.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7
+ Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:
8
+
9
+ (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or
10
+ (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution.
11
+ Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise.
12
+
13
+ DISCLAIMER
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ ![vlt](https://github.com/user-attachments/assets/345949ff-7150-4b97-856d-c7e42c2a4db5)
2
+
3
+ # @vltpkg/cli-sdk
4
+
5
+ The SDK for the `vlt` command line interface.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import vlt from '@vltpkg/cli-sdk'
11
+ process.argv.splice(2, 0, '--version')
12
+ await vlt()
13
+ ```
14
+
15
+ ```ts
16
+ import vlt from '@vltpkg/cli-sdk'
17
+ process.chdir('/some/vlt/project')
18
+ process.argv.splice(2, 0, 'install')
19
+ await vlt()
20
+ ```
@@ -0,0 +1,5 @@
1
+ import type { RecordPairs } from '../config/index.ts';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ export declare const usage: CommandUsage;
4
+ export declare const command: CommandFn<string | number | boolean | void | string[] | RecordPairs>;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,WAAW,EACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YA8ChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAC7B,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,WAAW,CA+B1D,CAAA"}
@@ -0,0 +1,153 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { spawnSync } from 'child_process';
3
+ import { definition, isRecordField, pairsToRecords, recordsToPairs, } from "../config/index.js";
4
+ import { commandUsage } from "../config/usage.js";
5
+ export const usage = () => commandUsage({
6
+ command: 'config',
7
+ usage: '<command> [flags]',
8
+ description: 'Work with vlt configuration',
9
+ subcommands: {
10
+ get: {
11
+ usage: '<key> [<key> ...]',
12
+ description: 'Print the named config value',
13
+ },
14
+ list: {
15
+ description: 'Print all configuration settings currently in effect',
16
+ },
17
+ set: {
18
+ usage: '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',
19
+ description: `Set config values. By default, these are
20
+ written to the project config file, \`vlt.json\`
21
+ in the root of the project. To set things for all
22
+ projects, run with \`--config=user\``,
23
+ },
24
+ del: {
25
+ usage: '<key> [<key> ...] [--config=<user | project>]',
26
+ description: `Delete the named config fields. If no values remain in
27
+ the config file, delete the file as well. By default,
28
+ operates on the \`vlt.json\` file in the root of the
29
+ current project. To delete a config field from the user
30
+ config file, specify \`--config=user\`.`,
31
+ },
32
+ edit: {
33
+ usage: '[--config=<user | project>]',
34
+ description: 'Edit the configuration file',
35
+ },
36
+ help: {
37
+ usage: '[field ...]',
38
+ description: `Get information about a config field, or show a list
39
+ of known config field names.`,
40
+ },
41
+ },
42
+ });
43
+ export const command = async (conf) => {
44
+ const sub = conf.positionals[0];
45
+ switch (sub) {
46
+ case 'set':
47
+ return set(conf);
48
+ case 'get':
49
+ return get(conf);
50
+ case 'ls':
51
+ case 'list':
52
+ return list(conf);
53
+ case 'edit':
54
+ return edit(conf);
55
+ case 'help':
56
+ return help(conf);
57
+ case 'del':
58
+ return del(conf);
59
+ default: {
60
+ throw error('Unrecognized config command', {
61
+ code: 'EUSAGE',
62
+ found: sub,
63
+ validOptions: ['set', 'get', 'list', 'edit', 'help', 'del'],
64
+ });
65
+ }
66
+ }
67
+ };
68
+ const help = (conf) => {
69
+ const j = definition.toJSON();
70
+ const fields = conf.positionals.slice(1);
71
+ if (!fields.length) {
72
+ return [
73
+ 'Specify one or more options to see information:',
74
+ ...Object.keys(j)
75
+ .sort((a, b) => a.localeCompare(b, 'en'))
76
+ .map(c => ` ${c}`),
77
+ ].join('\n');
78
+ }
79
+ // TODO: some kind of fuzzy search?
80
+ const res = [];
81
+ for (const f of fields) {
82
+ const def = j[f];
83
+ if (!def) {
84
+ res.push(`unknown config field: ${f}`);
85
+ }
86
+ else {
87
+ const hint = def.hint ? `=<${def.hint}>` : '';
88
+ const type = isRecordField(f) ?
89
+ 'Record<string, string>'
90
+ : def.type + (def.multiple ? '[]' : '');
91
+ res.push(`--${f}${hint}`);
92
+ res.push(` type: ${type}`);
93
+ if (def.default) {
94
+ res.push(` default: ${JSON.stringify(def.default)}`);
95
+ }
96
+ if (def.description) {
97
+ res.push(def.description);
98
+ }
99
+ }
100
+ }
101
+ return res.join('\n');
102
+ };
103
+ const list = (conf) => {
104
+ return recordsToPairs(conf.options);
105
+ };
106
+ const del = async (conf) => {
107
+ const fields = conf.positionals.slice(1);
108
+ if (!fields.length) {
109
+ throw error('At least one key is required', {
110
+ code: 'EUSAGE',
111
+ });
112
+ }
113
+ await conf.deleteConfigKeys(conf.get('config'), fields);
114
+ };
115
+ const get = async (conf) => {
116
+ const keys = conf.positionals.slice(1);
117
+ const k = keys[0];
118
+ if (!k || keys.length > 1) {
119
+ throw error('Exactly one key is required', {
120
+ code: 'EUSAGE',
121
+ });
122
+ }
123
+ return conf.get(k);
124
+ };
125
+ const edit = async (conf) => {
126
+ const [command, ...args] = conf.get('editor').split(' ');
127
+ if (!command) {
128
+ throw error(`editor is empty`);
129
+ }
130
+ await conf.editConfigFile(conf.get('config'), file => {
131
+ args.push(file);
132
+ const res = spawnSync(command, args, {
133
+ stdio: 'inherit',
134
+ });
135
+ if (res.status !== 0) {
136
+ throw error(`${command} command failed`, {
137
+ ...res,
138
+ command,
139
+ args,
140
+ });
141
+ }
142
+ });
143
+ };
144
+ const set = async (conf) => {
145
+ const pairs = conf.positionals.slice(1);
146
+ if (!pairs.length) {
147
+ throw error('At least one key=value pair is required', {
148
+ code: 'EUSAGE',
149
+ });
150
+ }
151
+ await conf.addConfigToFile(conf.get('config'), pairsToRecords(conf.jack.parseRaw(pairs.map(kv => `--${kv}`)).values));
152
+ };
153
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,6BAA6B;IAE1C,WA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,CAAC,EAClB,cAAc,CACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACtD,CACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { spawnSync } from 'child_process'\nimport {\n definition,\n isRecordField,\n pairsToRecords,\n recordsToPairs,\n} from '../config/index.ts'\nimport type {\n ConfigDefinitions,\n LoadedConfig,\n RecordPairs,\n} from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'config',\n usage: '<command> [flags]',\n description: 'Work with vlt configuration',\n\n subcommands: {\n get: {\n usage: '<key> [<key> ...]',\n description: 'Print the named config value',\n },\n\n list: {\n description:\n 'Print all configuration settings currently in effect',\n },\n\n set: {\n usage:\n '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',\n description: `Set config values. By default, these are\n written to the project config file, \\`vlt.json\\`\n in the root of the project. To set things for all\n projects, run with \\`--config=user\\``,\n },\n\n del: {\n usage: '<key> [<key> ...] [--config=<user | project>]',\n description: `Delete the named config fields. If no values remain in\n the config file, delete the file as well. By default,\n operates on the \\`vlt.json\\` file in the root of the\n current project. To delete a config field from the user\n config file, specify \\`--config=user\\`.`,\n },\n\n edit: {\n usage: '[--config=<user | project>]',\n description: 'Edit the configuration file',\n },\n\n help: {\n usage: '[field ...]',\n description: `Get information about a config field, or show a list\n of known config field names.`,\n },\n },\n })\n\nexport const command: CommandFn<\n string | number | boolean | void | string[] | RecordPairs\n> = async conf => {\n const sub = conf.positionals[0]\n switch (sub) {\n case 'set':\n return set(conf)\n\n case 'get':\n return get(conf)\n\n case 'ls':\n case 'list':\n return list(conf)\n\n case 'edit':\n return edit(conf)\n\n case 'help':\n return help(conf)\n\n case 'del':\n return del(conf)\n\n default: {\n throw error('Unrecognized config command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['set', 'get', 'list', 'edit', 'help', 'del'],\n })\n }\n }\n}\n\nconst help = (conf: LoadedConfig) => {\n const j = definition.toJSON()\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n return [\n 'Specify one or more options to see information:',\n ...Object.keys(j)\n .sort((a, b) => a.localeCompare(b, 'en'))\n .map(c => ` ${c}`),\n ].join('\\n')\n }\n\n // TODO: some kind of fuzzy search?\n const res: string[] = []\n for (const f of fields) {\n const def = j[f]\n if (!def) {\n res.push(`unknown config field: ${f}`)\n } else {\n const hint = def.hint ? `=<${def.hint}>` : ''\n const type =\n isRecordField(f) ?\n 'Record<string, string>'\n : def.type + (def.multiple ? '[]' : '')\n\n res.push(`--${f}${hint}`)\n res.push(` type: ${type}`)\n if (def.default) {\n res.push(` default: ${JSON.stringify(def.default)}`)\n }\n if (def.description) {\n res.push(def.description)\n }\n }\n }\n return res.join('\\n')\n}\n\nconst list = (conf: LoadedConfig) => {\n return recordsToPairs(conf.options)\n}\n\nconst del = async (conf: LoadedConfig) => {\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n throw error('At least one key is required', {\n code: 'EUSAGE',\n })\n }\n await conf.deleteConfigKeys(conf.get('config'), fields)\n}\n\nconst get = async (conf: LoadedConfig) => {\n const keys = conf.positionals.slice(1)\n const k = keys[0]\n if (!k || keys.length > 1) {\n throw error('Exactly one key is required', {\n code: 'EUSAGE',\n })\n }\n return conf.get(k as keyof ConfigDefinitions)\n}\n\nconst edit = async (conf: LoadedConfig) => {\n const [command, ...args] = conf.get('editor').split(' ')\n if (!command) {\n throw error(`editor is empty`)\n }\n await conf.editConfigFile(conf.get('config'), file => {\n args.push(file)\n const res = spawnSync(command, args, {\n stdio: 'inherit',\n })\n if (res.status !== 0) {\n throw error(`${command} command failed`, {\n ...res,\n command,\n args,\n })\n }\n })\n}\n\nconst set = async (conf: LoadedConfig) => {\n const pairs = conf.positionals.slice(1)\n if (!pairs.length) {\n throw error('At least one key=value pair is required', {\n code: 'EUSAGE',\n })\n }\n await conf.addConfigToFile(\n conf.get('config'),\n pairsToRecords(\n conf.jack.parseRaw(pairs.map(kv => `--${kv}`)).values,\n ),\n )\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ExecResult } from '../exec-command.ts';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ export declare const usage: CommandUsage;
4
+ export declare const command: CommandFn<ExecResult>;
5
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAehB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAEzC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { exec, execFG } from '@vltpkg/run';
2
+ import { commandUsage } from "../config/usage.js";
3
+ import { ExecCommand } from "../exec-command.js";
4
+ export const usage = () => commandUsage({
5
+ command: 'exec',
6
+ usage: '[command]',
7
+ description: `Run an arbitrary command, with the local installed packages
8
+ first in the PATH. Ie, this will run your locally installed
9
+ package bins.
10
+
11
+ If no command is provided, then a shell is spawned in the
12
+ current working directory, with the locally installed package
13
+ bins first in the PATH.
14
+
15
+ Note that any vlt configs must be specified *before* the
16
+ command, as the remainder of the command line options are
17
+ provided to the exec process.`,
18
+ });
19
+ export const command = async (conf) => {
20
+ return await new ExecCommand(conf, exec, execFG).run();
21
+ };
22
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE;;;;;;;;;;gDAU+B;CAC7C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[command]',\n description: `Run an arbitrary command, with the local installed packages\n first in the PATH. Ie, this will run your locally installed\n package bins.\n\n If no command is provided, then a shell is spawned in the\n current working directory, with the locally installed package\n bins first in the PATH.\n\n Note that any vlt configs must be specified *before* the\n command, as the remainder of the command line options are\n provided to the exec process.`,\n })\n\nexport const command: CommandFn<ExecResult> = async conf => {\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ import type { ViewFn } from '../view.ts';
3
+ export declare const views: ViewFn<null>;
4
+ export declare const usage: CommandUsage;
5
+ export declare const command: CommandFn;
6
+ //# sourceMappingURL=gui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gui.d.ts","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGxC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,IAAI,CAG9B,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAA4B,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ import { startGUI } from "../start-gui.js";
3
+ // this command is only a view, it doesn't actually do anything at this time
4
+ export const views = async (_, __, conf) => {
5
+ await startGUI({ conf });
6
+ return '';
7
+ };
8
+ export const usage = () => commandUsage({
9
+ command: 'gui',
10
+ usage: '',
11
+ description: 'Launch a graphical user interface in a browser',
12
+ });
13
+ export const command = async () => null;
14
+ //# sourceMappingURL=gui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gui.js","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,KAAK,GAAiB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACvD,MAAM,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACxB,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,gDAAgD;CAC9D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAc,KAAK,IAAI,EAAE,CAAC,IAAI,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { ViewFn } from '../view.ts'\n\n// this command is only a view, it doesn't actually do anything at this time\nexport const views: ViewFn<null> = async (_, __, conf) => {\n await startGUI({ conf })\n return ''\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'gui',\n usage: '',\n description: 'Launch a graphical user interface in a browser',\n })\n\nexport const command: CommandFn = async () => null\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ export declare const command: CommandFn<string>;
4
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,MAAM,CAErC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ export const usage = () => commandUsage({
3
+ command: 'help',
4
+ usage: '',
5
+ description: 'Print the full help output for the CLI',
6
+ });
7
+ export const command = async (conf) => {
8
+ return conf.jack.usage();
9
+ };
10
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,wCAAwC;CACtD,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAsB,KAAK,EAAC,IAAI,EAAC,EAAE;IACrD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;AAC1B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'help',\n usage: '',\n description: 'Print the full help output for the CLI',\n })\n\nexport const command: CommandFn<string> = async conf => {\n return conf.jack.usage()\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ import type { InitFileResults } from '@vltpkg/init';
3
+ import type { ViewFn, Views } from '../view.ts';
4
+ export declare const usage: CommandUsage;
5
+ export declare const views: Views<InitFileResults> & {
6
+ human: ViewFn<InitFileResults>;
7
+ };
8
+ export declare const command: CommandFn<InitFileResults>;
9
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC,eAAe,CAAC,CAAA;CAgB/B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,eAAe,CACX,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ import { init } from '@vltpkg/init';
3
+ export const usage = () => commandUsage({
4
+ command: 'init',
5
+ usage: '',
6
+ description: `Create a new package.json file in the current directory.`,
7
+ });
8
+ export const views = {
9
+ human: (results, _options, _config) => {
10
+ const output = [];
11
+ // TODO: colorize the JSON if config.options.color
12
+ for (const [type, { path, data }] of Object.entries(results)) {
13
+ output.push(`Wrote ${type} to ${path}:
14
+
15
+ ${JSON.stringify(data, null, 2)}
16
+ `);
17
+ }
18
+ output.push(`Modify/add properties using \`vlt pkg\`. For example:
19
+
20
+ vlt pkg set "description=My new project"`);
21
+ return output.join('\n');
22
+ },
23
+ };
24
+ export const command = async () => await init({ cwd: process.cwd() });
25
+ //# sourceMappingURL=init.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,10 @@
1
+ import { ViewClass } from '../../view.ts';
2
+ export declare class InstallReporter extends ViewClass {
3
+ #private;
4
+ start(): void;
5
+ done(_result: unknown, { time }: {
6
+ time: number;
7
+ }): undefined;
8
+ error(err: unknown): void;
9
+ }
10
+ //# sourceMappingURL=reporter.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,66 @@
1
+ import { emitter } from '@vltpkg/output';
2
+ import { Box, render, Text } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
+ import { createElement as $, Fragment, useLayoutEffect, useState, } from 'react';
5
+ import { stdout } from "../../output.js";
6
+ import { ViewClass } from "../../view.js";
7
+ const GraphStep = ({ text, step }) => {
8
+ if (step.state === 'waiting') {
9
+ return $(Text, { color: 'gray' }, text);
10
+ }
11
+ if (step.state === 'in_progress') {
12
+ return $(Text, { color: 'yellow' }, text, $(Spinner, { type: 'dots' }));
13
+ }
14
+ return $(Text, { color: 'green' }, text, ' ✓');
15
+ };
16
+ const App = () => {
17
+ const [requests, setRequests] = useState(0);
18
+ const [steps, setSteps] = useState({
19
+ build: {
20
+ state: 'waiting',
21
+ },
22
+ actual: {
23
+ state: 'waiting',
24
+ },
25
+ reify: {
26
+ state: 'waiting',
27
+ },
28
+ });
29
+ useLayoutEffect(() => {
30
+ const update = () => setRequests(p => p + 1);
31
+ emitter.on('request', update);
32
+ return () => emitter.off('request', update);
33
+ }, []);
34
+ useLayoutEffect(() => {
35
+ const update = ({ step, state }) => {
36
+ setSteps(p => ({
37
+ ...p,
38
+ [step]: {
39
+ ...p[step],
40
+ state: state === 'start' ? 'in_progress' : 'completed',
41
+ },
42
+ }));
43
+ };
44
+ emitter.on('graphStep', update);
45
+ return () => emitter.off('graphStep', update);
46
+ }, []);
47
+ return $(Fragment, null, $(Box, null, ...['build', 'actual', 'reify'].map((step, idx, list) => {
48
+ 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);
51
+ };
52
+ export class InstallReporter extends ViewClass {
53
+ #instance = null;
54
+ start() {
55
+ this.#instance = render($(App));
56
+ }
57
+ done(_result, { time }) {
58
+ this.#instance?.unmount();
59
+ stdout(`Done in ${time}ms`);
60
+ return undefined;
61
+ }
62
+ error(err) {
63
+ this.#instance?.unmount(err);
64
+ }
65
+ }
66
+ //# sourceMappingURL=reporter.js.map
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AAC,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"]}
@@ -0,0 +1,4 @@
1
+ import type { CommandFn, CommandUsage } from '../index.ts';
2
+ export declare const usage: CommandUsage;
3
+ export declare const command: CommandFn<string>;
4
+ //# sourceMappingURL=install-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/install-exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,MAAM,CAKrC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ export const usage = () => commandUsage({
3
+ command: 'install-exec',
4
+ usage: '[--package=<pkg>] [command...]',
5
+ description: 'Run a command defined by a package, installing it if necessary',
6
+ });
7
+ export const command = async (conf) => {
8
+ return [
9
+ 'TODO: exec, but install if not present',
10
+ ...conf.positionals,
11
+ ].join('\n');
12
+ };
13
+ //# sourceMappingURL=install-exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-exec.js","sourceRoot":"","sources":["../../../src/commands/install-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,cAAc;IACvB,KAAK,EAAE,gCAAgC;IACvC,WAAW,EACT,gEAAgE;CACnE,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAsB,KAAK,EAAC,IAAI,EAAC,EAAE;IACrD,OAAO;QACL,wCAAwC;QACxC,GAAG,IAAI,CAAC,WAAW;KACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install-exec',\n usage: '[--package=<pkg>] [command...]',\n description:\n 'Run a command defined by a package, installing it if necessary',\n })\n\nexport const command: CommandFn<string> = async conf => {\n return [\n 'TODO: exec, but install if not present',\n ...conf.positionals,\n ].join('\\n')\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Graph } from '@vltpkg/graph';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ import type { Views } from '../view.ts';
4
+ export declare const usage: CommandUsage;
5
+ export declare const views: Views<Graph>;
6
+ export declare const command: CommandFn<Graph>;
7
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,21 @@
1
+ import { commandUsage } from "../config/usage.js";
2
+ import { install } from '@vltpkg/graph';
3
+ import { parseAddArgs } from "../parse-add-remove-args.js";
4
+ import { InstallReporter } from "./install/reporter.js";
5
+ export const usage = () => commandUsage({
6
+ command: 'install',
7
+ usage: '[packages ...]',
8
+ description: `Install the specified packages, updating package.json and
9
+ vlt-lock.json appropriately.`,
10
+ });
11
+ export const views = {
12
+ json: g => g.toJSON(),
13
+ human: InstallReporter,
14
+ };
15
+ export const command = async (conf) => {
16
+ const monorepo = conf.options.monorepo;
17
+ const { add } = parseAddArgs(conf, monorepo);
18
+ const { graph } = await install(conf.options, add);
19
+ return graph;
20
+ };
21
+ //# sourceMappingURL=install.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,15 @@
1
+ import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
2
+ import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
3
+ import type { CommandFn, CommandUsage } from '../index.ts';
4
+ export declare const usage: CommandUsage;
5
+ export type ListResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
6
+ queryString: string;
7
+ };
8
+ export declare const views: {
9
+ readonly json: typeof jsonOutput;
10
+ readonly mermaid: typeof mermaidOutput;
11
+ readonly human: typeof humanReadableOutput;
12
+ readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").LoadedConfig) => Promise<void>;
13
+ };
14
+ export declare const command: CommandFn<ListResult>;
15
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +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"}