@motionscript/cli 0.0.0-stage → 0.1.0-alpha.0

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 (48) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +201 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +78 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/registry/add.d.ts +8 -0
  8. package/dist/registry/add.d.ts.map +1 -0
  9. package/dist/registry/add.js +93 -0
  10. package/dist/registry/add.js.map +1 -0
  11. package/dist/registry/config.d.ts +28 -0
  12. package/dist/registry/config.d.ts.map +1 -0
  13. package/dist/registry/config.js +55 -0
  14. package/dist/registry/config.js.map +1 -0
  15. package/dist/registry/diff.d.ts +16 -0
  16. package/dist/registry/diff.d.ts.map +1 -0
  17. package/dist/registry/diff.js +83 -0
  18. package/dist/registry/diff.js.map +1 -0
  19. package/dist/registry/fetch.d.ts +16 -0
  20. package/dist/registry/fetch.d.ts.map +1 -0
  21. package/dist/registry/fetch.js +59 -0
  22. package/dist/registry/fetch.js.map +1 -0
  23. package/dist/registry/init.d.ts +15 -0
  24. package/dist/registry/init.d.ts.map +1 -0
  25. package/dist/registry/init.js +69 -0
  26. package/dist/registry/init.js.map +1 -0
  27. package/dist/registry/install.d.ts +37 -0
  28. package/dist/registry/install.d.ts.map +1 -0
  29. package/dist/registry/install.js +105 -0
  30. package/dist/registry/install.js.map +1 -0
  31. package/dist/registry/list.d.ts +13 -0
  32. package/dist/registry/list.d.ts.map +1 -0
  33. package/dist/registry/list.js +61 -0
  34. package/dist/registry/list.js.map +1 -0
  35. package/dist/registry/lock.d.ts +73 -0
  36. package/dist/registry/lock.d.ts.map +1 -0
  37. package/dist/registry/lock.js +104 -0
  38. package/dist/registry/lock.js.map +1 -0
  39. package/dist/registry/package-manager.d.ts +28 -0
  40. package/dist/registry/package-manager.d.ts.map +1 -0
  41. package/dist/registry/package-manager.js +61 -0
  42. package/dist/registry/package-manager.js.map +1 -0
  43. package/dist/registry/protocol.d.ts +135 -0
  44. package/dist/registry/protocol.d.ts.map +1 -0
  45. package/dist/registry/protocol.js +88 -0
  46. package/dist/registry/protocol.js.map +1 -0
  47. package/package.json +64 -3
  48. package/README.md +0 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @motionscript/cli
2
+
3
+ ## 0.1.0-alpha.0
4
+
5
+ Initial release.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ import kleur from 'kleur';
3
+ import minimist from 'minimist';
4
+ import { runAdd } from './registry/add.js';
5
+ import { runDiff } from './registry/diff.js';
6
+ import { runInit } from './registry/init.js';
7
+ import { runList } from './registry/list.js';
8
+ /**
9
+ * `ms` — the component CLI.
10
+ *
11
+ * Some Motion Script components do not ship as a dependency you import. Their
12
+ * source is copied into your project, so you own it: you can read it, change
13
+ * it, and delete the half you do not want. The cost is that fixes arrive
14
+ * manually, which is what `ms list` and `ms diff` exist to make bearable.
15
+ *
16
+ * This is deliberately only the registry half of the CLI that used to live
17
+ * here. Rendering from Node is `@motionscript/headless`'s job: a host imports
18
+ * it and renders a project entry in a headless Chromium page.
19
+ */
20
+ const HELP = `
21
+ ${kleur.bold('ms')} — Motion Script components
22
+
23
+ ${kleur.bold('ms init')} write motionscript.json and wire the @/components alias
24
+ ${kleur.bold('ms add')} [name...] copy a component's source into this project
25
+ ${kleur.bold('ms list')} what is installed, and whether it has been edited
26
+ ${kleur.bold('ms diff')} [name] what changed upstream, and on which side
27
+
28
+ ${kleur.bold('Options')}
29
+ --yes skip prompts and accept defaults
30
+ --overwrite overwrite existing files without asking
31
+ --skip-install do not install npm dependencies after adding
32
+ --registry <url> override the default registry (a URL or a local path)
33
+ --check (list) ask each registry whether a newer version exists
34
+
35
+ ${kleur.bold('Registries')}
36
+ A bare name resolves against ${kleur.dim('https://motionscript.dev/r')}. Additional or
37
+ private registries go under motionscript.json's "registries", keyed by
38
+ @namespace, and are reached as ${kleur.dim('ms add @acme/gauge')}.
39
+ `;
40
+ async function main() {
41
+ const argv = minimist(process.argv.slice(2), {
42
+ boolean: ['yes', 'overwrite', 'skip-install', 'check', 'help', 'version'],
43
+ string: ['registry'],
44
+ alias: { y: 'yes', h: 'help', v: 'version' },
45
+ });
46
+ const command = argv._[0];
47
+ if (argv.help || (!command && !argv.version)) {
48
+ console.log(HELP);
49
+ return;
50
+ }
51
+ const projectRoot = process.cwd();
52
+ switch (command) {
53
+ case 'init':
54
+ // `runInit` hands back the config it wrote, which only `runAdd`
55
+ // wants; here the command is done when it returns.
56
+ await runInit(projectRoot, argv);
57
+ return;
58
+ case 'add':
59
+ return runAdd(projectRoot, argv);
60
+ case 'list':
61
+ case 'ls':
62
+ return runList(projectRoot, argv);
63
+ case 'diff':
64
+ return runDiff(projectRoot, argv);
65
+ default:
66
+ console.error(kleur.red(`Unknown command "${String(command)}".`), `\nRun ${kleur.bold('ms --help')} for what this does.`);
67
+ process.exitCode = 1;
68
+ }
69
+ }
70
+ main().catch((error) => {
71
+ // A message, not a stack. Every throw on these paths is a condition the
72
+ // user can act on — an unreachable registry, a namespace that is not
73
+ // configured, a malformed item — and a stack trace buries the sentence
74
+ // that says which.
75
+ console.error(kleur.red(error instanceof Error ? error.message : String(error)));
76
+ process.exitCode = 1;
77
+ });
78
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"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AAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO;IACX,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC,QAAQ,OAAO,EAAE,CAAC;QACd,KAAK,MAAM;YACP,gEAAgE;YAChE,mDAAmD;YACnD,MAAM,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACjC,OAAO;QACX,KAAK,KAAK;YACN,OAAO,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACrC,KAAK,MAAM,CAAC;QACZ,KAAK,IAAI;YACL,OAAO,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACtC,KAAK,MAAM;YACP,OAAO,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACtC;YACI,OAAO,CAAC,KAAK,CACT,KAAK,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAClD,SAAS,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,sBAAsB,CACzD,CAAC;YACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5B,wEAAwE;IACxE,qEAAqE;IACrE,uEAAuE;IACvE,mBAAmB;IACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport kleur from 'kleur';\nimport minimist from 'minimist';\nimport { runAdd } from './registry/add.js';\nimport { runDiff } from './registry/diff.js';\nimport { runInit } from './registry/init.js';\nimport { runList } from './registry/list.js';\n\n/**\n * `ms` — the component CLI.\n *\n * Some Motion Script components do not ship as a dependency you import. Their\n * source is copied into your project, so you own it: you can read it, change\n * it, and delete the half you do not want. The cost is that fixes arrive\n * manually, which is what `ms list` and `ms diff` exist to make bearable.\n *\n * This is deliberately only the registry half of the CLI that used to live\n * here. Rendering from Node is `@motionscript/headless`'s job: a host imports\n * it and renders a project entry in a headless Chromium page.\n */\n\nconst HELP = `\n${kleur.bold('ms')} — Motion Script components\n\n ${kleur.bold('ms init')} write motionscript.json and wire the @/components alias\n ${kleur.bold('ms add')} [name...] copy a component's source into this project\n ${kleur.bold('ms list')} what is installed, and whether it has been edited\n ${kleur.bold('ms diff')} [name] what changed upstream, and on which side\n\n${kleur.bold('Options')}\n --yes skip prompts and accept defaults\n --overwrite overwrite existing files without asking\n --skip-install do not install npm dependencies after adding\n --registry <url> override the default registry (a URL or a local path)\n --check (list) ask each registry whether a newer version exists\n\n${kleur.bold('Registries')}\n A bare name resolves against ${kleur.dim('https://motionscript.dev/r')}. Additional or\n private registries go under motionscript.json's \"registries\", keyed by\n @namespace, and are reached as ${kleur.dim('ms add @acme/gauge')}.\n`;\n\nasync function main(): Promise<void> {\n const argv = minimist(process.argv.slice(2), {\n boolean: ['yes', 'overwrite', 'skip-install', 'check', 'help', 'version'],\n string: ['registry'],\n alias: { y: 'yes', h: 'help', v: 'version' },\n });\n\n const command = argv._[0];\n if (argv.help || (!command && !argv.version)) {\n console.log(HELP);\n return;\n }\n\n const projectRoot = process.cwd();\n switch (command) {\n case 'init':\n // `runInit` hands back the config it wrote, which only `runAdd`\n // wants; here the command is done when it returns.\n await runInit(projectRoot, argv);\n return;\n case 'add':\n return runAdd(projectRoot, argv);\n case 'list':\n case 'ls':\n return runList(projectRoot, argv);\n case 'diff':\n return runDiff(projectRoot, argv);\n default:\n console.error(\n kleur.red(`Unknown command \"${String(command)}\".`),\n `\\nRun ${kleur.bold('ms --help')} for what this does.`,\n );\n process.exitCode = 1;\n }\n}\n\nmain().catch((error: unknown) => {\n // A message, not a stack. Every throw on these paths is a condition the\n // user can act on — an unreachable registry, a namespace that is not\n // configured, a malformed item — and a stack trace buries the sentence\n // that says which.\n console.error(kleur.red(error instanceof Error ? error.message : String(error)));\n process.exitCode = 1;\n});\n"]}
@@ -0,0 +1,8 @@
1
+ import type minimist from 'minimist';
2
+ /**
3
+ * `ms add [name...]` — copy one or more registry components' source into
4
+ * this project, following any `registryDependencies` first, then install the
5
+ * npm packages they need.
6
+ */
7
+ export declare function runAdd(projectRoot: string, argv: minimist.ParsedArgs): Promise<void>;
8
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/registry/add.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAQrC;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA0F1F"}
@@ -0,0 +1,93 @@
1
+ import path from 'node:path';
2
+ import kleur from 'kleur';
3
+ import prompts from 'prompts';
4
+ import { componentsConfigExists, loadComponentsConfig } from './config.js';
5
+ import { fetchRegistryIndex, resolveItemUrl } from './fetch.js';
6
+ import { resolveComponents, writeComponentFiles, collectDependencies } from './install.js';
7
+ import { detectPackageManager, installDependencies } from './package-manager.js';
8
+ import { runInit } from './init.js';
9
+ import { loadLock, recordInstall, writeLock } from './lock.js';
10
+ /**
11
+ * `ms add [name...]` — copy one or more registry components' source into
12
+ * this project, following any `registryDependencies` first, then install the
13
+ * npm packages they need.
14
+ */
15
+ export async function runAdd(projectRoot, argv) {
16
+ if (!componentsConfigExists(projectRoot)) {
17
+ if (!argv.yes) {
18
+ const { proceed } = await prompts({
19
+ type: 'confirm',
20
+ name: 'proceed',
21
+ message: 'No motionscript.json found. Run `ms init` now?',
22
+ initial: true,
23
+ });
24
+ if (!proceed) {
25
+ console.log(kleur.dim('Aborted.'));
26
+ return;
27
+ }
28
+ }
29
+ await runInit(projectRoot, argv);
30
+ }
31
+ const config = loadComponentsConfig(projectRoot);
32
+ if (!config)
33
+ throw new Error('motionscript.json could not be loaded after init.');
34
+ const defaultRegistryUrl = typeof argv.registry === 'string' ? argv.registry : undefined;
35
+ let names = argv._.slice(1).filter(Boolean);
36
+ if (names.length === 0) {
37
+ const index = await fetchRegistryIndex(defaultRegistryUrl);
38
+ if (index.length === 0) {
39
+ console.log(kleur.yellow('The registry has no components to add.'));
40
+ return;
41
+ }
42
+ const { selected } = await prompts({
43
+ type: 'multiselect',
44
+ name: 'selected',
45
+ message: 'Select components to add',
46
+ choices: index.map(entry => ({
47
+ title: entry.name,
48
+ description: entry.description,
49
+ value: entry.name,
50
+ })),
51
+ min: 1,
52
+ });
53
+ if (!selected || selected.length === 0) {
54
+ console.log(kleur.dim('Aborted.'));
55
+ return;
56
+ }
57
+ names = selected;
58
+ }
59
+ console.log(kleur.bold(`Adding ${names.join(', ')}...`));
60
+ const items = await resolveComponents(names, config, defaultRegistryUrl);
61
+ const lock = loadLock(projectRoot);
62
+ for (const item of items) {
63
+ // The name as typed, so `@acme/gauge` is recorded under its namespace
64
+ // rather than under the bare `gauge` two registries could both publish.
65
+ const requested = names.find((n) => n.endsWith(item.name)) ?? item.name;
66
+ const { written, skipped, recorded } = await writeComponentFiles(item, config, projectRoot, {
67
+ // --yes is "fully non-interactive": it also answers the overwrite
68
+ // prompt, so a scripted `ms add --yes` never blocks on stdin.
69
+ force: Boolean(argv.overwrite || argv.yes),
70
+ previous: lock.components[requested],
71
+ });
72
+ if (Object.keys(recorded).length > 0) {
73
+ recordInstall(lock, requested, item, resolveItemUrl(requested, config, defaultRegistryUrl).url, recorded);
74
+ }
75
+ for (const file of written) {
76
+ console.log(` ${kleur.green('✓')} ${path.relative(projectRoot, file)}`);
77
+ }
78
+ for (const file of skipped) {
79
+ console.log(` ${kleur.dim('–')} ${path.relative(projectRoot, file)} ${kleur.dim('(skipped)')}`);
80
+ }
81
+ }
82
+ if (!argv['skip-install']) {
83
+ const dependencies = collectDependencies(items);
84
+ if (Object.keys(dependencies).length > 0) {
85
+ const pm = detectPackageManager(projectRoot);
86
+ console.log(kleur.bold(`Installing dependencies with ${pm}...`));
87
+ installDependencies(pm, dependencies, projectRoot);
88
+ }
89
+ }
90
+ writeLock(projectRoot, lock);
91
+ console.log(kleur.green(`Done. Added: ${items.map(i => i.name).join(', ')}.`));
92
+ }
93
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/registry/add.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,WAAmB,EAAE,IAAyB;IACvE,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACZ,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC;gBAC9B,IAA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AAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import path from 'node:path';\nimport kleur from 'kleur';\nimport prompts from 'prompts';\nimport type minimist from 'minimist';\nimport { componentsConfigExists, loadComponentsConfig } from './config.js';\nimport { fetchRegistryIndex, resolveItemUrl } from './fetch.js';\nimport { resolveComponents, writeComponentFiles, collectDependencies } from './install.js';\nimport { detectPackageManager, installDependencies } from './package-manager.js';\nimport { runInit } from './init.js';\nimport { loadLock, recordInstall, writeLock } from './lock.js';\n\n/**\n * `ms add [name...]` — copy one or more registry components' source into\n * this project, following any `registryDependencies` first, then install the\n * npm packages they need.\n */\nexport async function runAdd(projectRoot: string, argv: minimist.ParsedArgs): Promise<void> {\n if (!componentsConfigExists(projectRoot)) {\n if (!argv.yes) {\n const { proceed } = await prompts({\n type: 'confirm',\n name: 'proceed',\n message: 'No motionscript.json found. Run `ms init` now?',\n initial: true,\n });\n if (!proceed) {\n console.log(kleur.dim('Aborted.'));\n return;\n }\n }\n await runInit(projectRoot, argv);\n }\n\n const config = loadComponentsConfig(projectRoot);\n if (!config) throw new Error('motionscript.json could not be loaded after init.');\n\n const defaultRegistryUrl = typeof argv.registry === 'string' ? argv.registry : undefined;\n\n let names = (argv._.slice(1) as string[]).filter(Boolean);\n if (names.length === 0) {\n const index = await fetchRegistryIndex(defaultRegistryUrl);\n if (index.length === 0) {\n console.log(kleur.yellow('The registry has no components to add.'));\n return;\n }\n const { selected } = await prompts({\n type: 'multiselect',\n name: 'selected',\n message: 'Select components to add',\n choices: index.map(entry => ({\n title: entry.name,\n description: entry.description,\n value: entry.name,\n })),\n min: 1,\n });\n if (!selected || (selected as string[]).length === 0) {\n console.log(kleur.dim('Aborted.'));\n return;\n }\n names = selected as string[];\n }\n\n console.log(kleur.bold(`Adding ${names.join(', ')}...`));\n const items = await resolveComponents(names, config, defaultRegistryUrl);\n const lock = loadLock(projectRoot);\n\n for (const item of items) {\n // The name as typed, so `@acme/gauge` is recorded under its namespace\n // rather than under the bare `gauge` two registries could both publish.\n const requested = names.find((n) => n.endsWith(item.name)) ?? item.name;\n const { written, skipped, recorded } = await writeComponentFiles(item, config, projectRoot, {\n // --yes is \"fully non-interactive\": it also answers the overwrite\n // prompt, so a scripted `ms add --yes` never blocks on stdin.\n force: Boolean(argv.overwrite || argv.yes),\n previous: lock.components[requested],\n });\n if (Object.keys(recorded).length > 0) {\n recordInstall(\n lock,\n requested,\n item,\n resolveItemUrl(requested, config, defaultRegistryUrl).url,\n recorded,\n );\n }\n for (const file of written) {\n console.log(` ${kleur.green('✓')} ${path.relative(projectRoot, file)}`);\n }\n for (const file of skipped) {\n console.log(` ${kleur.dim('–')} ${path.relative(projectRoot, file)} ${kleur.dim('(skipped)')}`);\n }\n }\n\n if (!argv['skip-install']) {\n const dependencies = collectDependencies(items);\n if (Object.keys(dependencies).length > 0) {\n const pm = detectPackageManager(projectRoot);\n console.log(kleur.bold(`Installing dependencies with ${pm}...`));\n installDependencies(pm, dependencies, projectRoot);\n }\n }\n\n writeLock(projectRoot, lock);\n\n console.log(kleur.green(`Done. Added: ${items.map(i => i.name).join(', ')}.`));\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { ComponentsConfig } from './protocol.js';
2
+ export declare const COMPONENTS_CONFIG_FILENAME = "motionscript.json";
3
+ /**
4
+ * What this file used to be called, oldest first. Both still read, never written.
5
+ *
6
+ * `components.json` was renamed because it holds more than components now —
7
+ * the project entry, asset and shader locations — and because that name at a
8
+ * project root is shadcn/ui's, which a project may well also have.
9
+ * `motion-script.json` was the dashed-scope-era name.
10
+ */
11
+ export declare const LEGACY_CONFIG_FILENAMES: string[];
12
+ /** The registry bare (unnamespaced) component names resolve against, e.g. `ms add code`. */
13
+ export declare const DEFAULT_REGISTRY_URL = "https://motionscript.dev/r";
14
+ export declare const DEFAULT_COMPONENTS_ALIAS = "@/components";
15
+ export declare const DEFAULT_COMPONENTS_PATH = "src/components";
16
+ export declare function componentsConfigExists(projectRoot: string): boolean;
17
+ /**
18
+ * Load `motionscript.json` from a project root, falling back to either legacy
19
+ * name. Returns null when absent, mirroring how the CLI probes for
20
+ * `src/project.ts` elsewhere — presence, not requirement, since most commands
21
+ * treat this file as optional context rather than something every project must
22
+ * have.
23
+ */
24
+ export declare function loadComponentsConfig(projectRoot: string): ComponentsConfig | null;
25
+ /** Write `motionscript.json`, pretty-printed like the toolchain's other generated JSON files. */
26
+ export declare function writeComponentsConfig(projectRoot: string, config: ComponentsConfig): void;
27
+ export declare function defaultComponentsConfig(overrides?: Partial<Pick<ComponentsConfig, 'project'>>): ComponentsConfig;
28
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/registry/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,eAAO,MAAM,0BAA0B,sBAAsB,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,UAA4C,CAAC;AAWjF,4FAA4F;AAC5F,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AAEjE,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAIjF;AAED,iGAAiG;AACjG,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAGzF;AAED,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,GAAG,gBAAgB,CAOhH"}
@@ -0,0 +1,55 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export const COMPONENTS_CONFIG_FILENAME = 'motionscript.json';
4
+ /**
5
+ * What this file used to be called, oldest first. Both still read, never written.
6
+ *
7
+ * `components.json` was renamed because it holds more than components now —
8
+ * the project entry, asset and shader locations — and because that name at a
9
+ * project root is shadcn/ui's, which a project may well also have.
10
+ * `motion-script.json` was the dashed-scope-era name.
11
+ */
12
+ export const LEGACY_CONFIG_FILENAMES = ['motion-script.json', 'components.json'];
13
+ /** The config file actually present, preferring the current name. */
14
+ function configPathIn(projectRoot) {
15
+ for (const name of [COMPONENTS_CONFIG_FILENAME, ...LEGACY_CONFIG_FILENAMES]) {
16
+ const candidate = path.join(projectRoot, name);
17
+ if (fs.existsSync(candidate))
18
+ return candidate;
19
+ }
20
+ return null;
21
+ }
22
+ /** The registry bare (unnamespaced) component names resolve against, e.g. `ms add code`. */
23
+ export const DEFAULT_REGISTRY_URL = 'https://motionscript.dev/r';
24
+ export const DEFAULT_COMPONENTS_ALIAS = '@/components';
25
+ export const DEFAULT_COMPONENTS_PATH = 'src/components';
26
+ export function componentsConfigExists(projectRoot) {
27
+ return configPathIn(projectRoot) !== null;
28
+ }
29
+ /**
30
+ * Load `motionscript.json` from a project root, falling back to either legacy
31
+ * name. Returns null when absent, mirroring how the CLI probes for
32
+ * `src/project.ts` elsewhere — presence, not requirement, since most commands
33
+ * treat this file as optional context rather than something every project must
34
+ * have.
35
+ */
36
+ export function loadComponentsConfig(projectRoot) {
37
+ const configPath = configPathIn(projectRoot);
38
+ if (!configPath)
39
+ return null;
40
+ return JSON.parse(fs.readFileSync(configPath, 'utf8'));
41
+ }
42
+ /** Write `motionscript.json`, pretty-printed like the toolchain's other generated JSON files. */
43
+ export function writeComponentsConfig(projectRoot, config) {
44
+ const configPath = path.join(projectRoot, COMPONENTS_CONFIG_FILENAME);
45
+ fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
46
+ }
47
+ export function defaultComponentsConfig(overrides) {
48
+ return {
49
+ $schema: 'https://motionscript.dev/schema/motionscript.json',
50
+ project: overrides?.project ?? 'src/project.ts',
51
+ aliases: { components: DEFAULT_COMPONENTS_ALIAS },
52
+ paths: { components: DEFAULT_COMPONENTS_PATH },
53
+ };
54
+ }
55
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/registry/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;AAEjF,qEAAqE;AACrE,SAAS,YAAY,CAAC,WAAmB;IACrC,KAAK,MAAM,IAAI,IAAI,CAAC,0BAA0B,EAAE,GAAG,uBAAuB,CAAC,EAAE,CAAC;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAEjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAExD,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACtD,OAAO,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACpD,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAqB,CAAC;AAC/E,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,MAAwB;IAC/E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;IACtE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,SAAsD;IAC1F,OAAO;QACH,OAAO,EAAE,mDAAmD;QAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,gBAAgB;QAC/C,OAAO,EAAE,EAAE,UAAU,EAAE,wBAAwB,EAAE;QACjD,KAAK,EAAE,EAAE,UAAU,EAAE,uBAAuB,EAAE;KACjD,CAAC;AACN,CAAC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type { ComponentsConfig } from './protocol.js';\n\nexport const COMPONENTS_CONFIG_FILENAME = 'motionscript.json';\n\n/**\n * What this file used to be called, oldest first. Both still read, never written.\n *\n * `components.json` was renamed because it holds more than components now —\n * the project entry, asset and shader locations — and because that name at a\n * project root is shadcn/ui's, which a project may well also have.\n * `motion-script.json` was the dashed-scope-era name.\n */\nexport const LEGACY_CONFIG_FILENAMES = ['motion-script.json', 'components.json'];\n\n/** The config file actually present, preferring the current name. */\nfunction configPathIn(projectRoot: string): string | null {\n for (const name of [COMPONENTS_CONFIG_FILENAME, ...LEGACY_CONFIG_FILENAMES]) {\n const candidate = path.join(projectRoot, name);\n if (fs.existsSync(candidate)) return candidate;\n }\n return null;\n}\n\n/** The registry bare (unnamespaced) component names resolve against, e.g. `ms add code`. */\nexport const DEFAULT_REGISTRY_URL = 'https://motionscript.dev/r';\n\nexport const DEFAULT_COMPONENTS_ALIAS = '@/components';\nexport const DEFAULT_COMPONENTS_PATH = 'src/components';\n\nexport function componentsConfigExists(projectRoot: string): boolean {\n return configPathIn(projectRoot) !== null;\n}\n\n/**\n * Load `motionscript.json` from a project root, falling back to either legacy\n * name. Returns null when absent, mirroring how the CLI probes for\n * `src/project.ts` elsewhere — presence, not requirement, since most commands\n * treat this file as optional context rather than something every project must\n * have.\n */\nexport function loadComponentsConfig(projectRoot: string): ComponentsConfig | null {\n const configPath = configPathIn(projectRoot);\n if (!configPath) return null;\n return JSON.parse(fs.readFileSync(configPath, 'utf8')) as ComponentsConfig;\n}\n\n/** Write `motionscript.json`, pretty-printed like the toolchain's other generated JSON files. */\nexport function writeComponentsConfig(projectRoot: string, config: ComponentsConfig): void {\n const configPath = path.join(projectRoot, COMPONENTS_CONFIG_FILENAME);\n fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`);\n}\n\nexport function defaultComponentsConfig(overrides?: Partial<Pick<ComponentsConfig, 'project'>>): ComponentsConfig {\n return {\n $schema: 'https://motionscript.dev/schema/motionscript.json',\n project: overrides?.project ?? 'src/project.ts',\n aliases: { components: DEFAULT_COMPONENTS_ALIAS },\n paths: { components: DEFAULT_COMPONENTS_PATH },\n };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type minimist from 'minimist';
2
+ /**
3
+ * `ms diff [name]` — what upstream changed under your feet.
4
+ *
5
+ * The counterpart to `ms list`: that one answers "did I change this", this one
6
+ * answers "did they". Both are only answerable because the lockfile recorded
7
+ * the bytes that were written, which is what gives a three-way comparison a
8
+ * middle term — yours, theirs, and the common ancestor they diverged from.
9
+ *
10
+ * Deliberately prints a summary rather than a unified diff. A component is
11
+ * files on disk in a project that already has a diff tool and a version control
12
+ * system with better ones; what the CLI uniquely knows is *which* files moved
13
+ * and in which direction, and that is what it says.
14
+ */
15
+ export declare function runDiff(projectRoot: string, argv: minimist.ParsedArgs): Promise<void>;
16
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/registry/diff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAKrC;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAoE3F"}
@@ -0,0 +1,83 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import kleur from 'kleur';
4
+ import { loadComponentsConfig } from './config.js';
5
+ import { fetchRegistryItem } from './fetch.js';
6
+ import { hashContent, loadLock } from './lock.js';
7
+ /**
8
+ * `ms diff [name]` — what upstream changed under your feet.
9
+ *
10
+ * The counterpart to `ms list`: that one answers "did I change this", this one
11
+ * answers "did they". Both are only answerable because the lockfile recorded
12
+ * the bytes that were written, which is what gives a three-way comparison a
13
+ * middle term — yours, theirs, and the common ancestor they diverged from.
14
+ *
15
+ * Deliberately prints a summary rather than a unified diff. A component is
16
+ * files on disk in a project that already has a diff tool and a version control
17
+ * system with better ones; what the CLI uniquely knows is *which* files moved
18
+ * and in which direction, and that is what it says.
19
+ */
20
+ export async function runDiff(projectRoot, argv) {
21
+ const lock = loadLock(projectRoot);
22
+ const config = loadComponentsConfig(projectRoot);
23
+ const defaultRegistryUrl = typeof argv.registry === 'string' ? argv.registry : undefined;
24
+ const requested = argv._.slice(1).filter(Boolean);
25
+ const names = requested.length > 0 ? requested : Object.keys(lock.components);
26
+ if (names.length === 0) {
27
+ console.log(kleur.dim('No components installed.'));
28
+ return;
29
+ }
30
+ for (const name of names) {
31
+ const entry = lock.components[name];
32
+ if (!entry) {
33
+ console.log(`${kleur.bold(name)} ${kleur.red('not installed')}`);
34
+ continue;
35
+ }
36
+ let upstream;
37
+ try {
38
+ upstream = await fetchRegistryItem(name, config, defaultRegistryUrl);
39
+ }
40
+ catch (error) {
41
+ console.log(`${kleur.bold(name)} ${kleur.red('unreachable')} ${kleur.dim(String(error))}`);
42
+ continue;
43
+ }
44
+ const header = [kleur.bold(name)];
45
+ if (entry.version || upstream.version) {
46
+ header.push(kleur.dim(`${entry.version ?? '?'} → ${upstream.version ?? '?'}`));
47
+ }
48
+ console.log(header.join(' '));
49
+ const seen = new Set();
50
+ for (const file of upstream.files) {
51
+ seen.add(file.path);
52
+ const locked = entry.files[file.path];
53
+ if (!locked) {
54
+ console.log(` ${kleur.green('+')} ${file.path} ${kleur.dim('(new upstream)')}`);
55
+ continue;
56
+ }
57
+ const onDisk = path.join(projectRoot, locked.target);
58
+ const local = fs.existsSync(onDisk) ? fs.readFileSync(onDisk, 'utf8') : null;
59
+ const upstreamChanged = hashContent(file.content) !== locked.installed;
60
+ const localChanged = local !== null && hashContent(local) !== locked.installed;
61
+ if (local === null) {
62
+ console.log(` ${kleur.red('-')} ${file.path} ${kleur.dim('(missing locally)')}`);
63
+ }
64
+ else if (upstreamChanged && localChanged) {
65
+ // The only state that needs a person: both moved, so
66
+ // re-installing loses work and not re-installing keeps a bug.
67
+ console.log(` ${kleur.yellow('!')} ${file.path} ${kleur.dim('(changed both sides)')}`);
68
+ }
69
+ else if (upstreamChanged) {
70
+ console.log(` ${kleur.cyan('↑')} ${file.path} ${kleur.dim('(changed upstream)')}`);
71
+ }
72
+ else if (localChanged) {
73
+ console.log(` ${kleur.yellow('~')} ${file.path} ${kleur.dim('(changed locally)')}`);
74
+ }
75
+ }
76
+ for (const declared of Object.keys(entry.files)) {
77
+ if (!seen.has(declared)) {
78
+ console.log(` ${kleur.dim('×')} ${declared} ${kleur.dim('(dropped upstream)')}`);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ //# sourceMappingURL=diff.js.map