@astryxdesign/cli 0.6.0 → 0.6.1

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 (219) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +76 -67
  3. package/api/build/build.test.mjs +37 -0
  4. package/api/build/build.type.mjs +1 -1
  5. package/api/build/kit/kit.mjs +31 -1
  6. package/api/component/_adapter.mjs +14 -28
  7. package/api/component/integration-import-agreement.test.mjs +318 -0
  8. package/api/doctor/doctor.d.mts +32 -3
  9. package/api/doctor/doctor.doc.mjs +2 -1
  10. package/api/doctor/doctor.mjs +97 -4
  11. package/api/doctor/doctor.test.mjs +90 -1
  12. package/api/gap-report/gap-report-worker.d.mts +4 -0
  13. package/api/gap-report/gap-report-worker.mjs +73 -0
  14. package/api/gap-report/gap-report.d.mts +81 -0
  15. package/api/gap-report/gap-report.doc.d.mts +9 -0
  16. package/api/gap-report/gap-report.doc.mjs +127 -0
  17. package/api/gap-report/gap-report.mjs +707 -0
  18. package/api/gap-report/gap-report.test.mjs +1210 -0
  19. package/api/gap-report/gap-report.type.d.mts +88 -0
  20. package/api/gap-report/gap-report.type.mjs +69 -0
  21. package/api/index.d.mts +8 -1
  22. package/api/index.mjs +24 -1
  23. package/api/integration/add-contribution.d.mts +44 -0
  24. package/api/integration/add-contribution.mjs +1160 -0
  25. package/api/integration/add-contribution.test.mjs +733 -0
  26. package/api/integration/add-helpers.d.mts +80 -0
  27. package/api/integration/add-helpers.mjs +333 -0
  28. package/api/integration/add-helpers.test.mjs +161 -0
  29. package/api/integration/add-theme.d.mts +10 -0
  30. package/api/integration/add-theme.mjs +332 -0
  31. package/api/integration/add-theme.test.mjs +194 -0
  32. package/api/integration/integration-authoring.type.d.mts +55 -0
  33. package/api/integration/integration-authoring.type.mjs +76 -0
  34. package/api/integration/integration-block-exports.test.mjs +4 -0
  35. package/api/integration/integrationAdd.doc.d.mts +5 -0
  36. package/api/integration/integrationAdd.doc.mjs +100 -0
  37. package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
  38. package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
  39. package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
  40. package/api/integration/integrationAddCodemod.doc.mjs +55 -0
  41. package/api/integration/integrationAddComponent.doc.d.mts +5 -0
  42. package/api/integration/integrationAddComponent.doc.mjs +49 -0
  43. package/api/integration/integrationAddDoc.doc.d.mts +5 -0
  44. package/api/integration/integrationAddDoc.doc.mjs +59 -0
  45. package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
  46. package/api/integration/integrationAddTemplate.doc.mjs +55 -0
  47. package/api/integration/integrationAddTheme.doc.d.mts +5 -0
  48. package/api/integration/integrationAddTheme.doc.mjs +85 -0
  49. package/api/integration/integrationPackCheck.doc.d.mts +5 -0
  50. package/api/integration/integrationPackCheck.doc.mjs +35 -0
  51. package/api/integration/pack-check.d.mts +27 -0
  52. package/api/integration/pack-check.mjs +795 -0
  53. package/api/integration/pack-check.test.mjs +569 -0
  54. package/api/integration/pack-check.type.d.mts +45 -0
  55. package/api/integration/pack-check.type.mjs +56 -0
  56. package/api/integration/public-api.test.mjs +21 -0
  57. package/api/integration/validate-integration.mjs +221 -11
  58. package/api/integration/validate-integration.test.mjs +189 -5
  59. package/api/integration/validateIntegration.doc.mjs +2 -2
  60. package/api/json/index.ts +1 -0
  61. package/api/search/search.mjs +19 -1
  62. package/api/theme/_adapter.d.mts +26 -28
  63. package/api/theme/_adapter.mjs +101 -38
  64. package/api/theme/add/add.d.mts +2 -1
  65. package/api/theme/add/add.mjs +56 -20
  66. package/api/theme/add/add.test.mjs +1 -0
  67. package/api/theme/build/build.d.mts +25 -0
  68. package/api/theme/build/build.mjs +101 -70
  69. package/api/theme/build/build.test.mjs +77 -44
  70. package/api/theme/integration-themes.test.mjs +183 -0
  71. package/api/theme/list/list.d.mts +10 -2
  72. package/api/theme/list/list.mjs +31 -10
  73. package/api/theme/list/list.test.mjs +102 -23
  74. package/api/theme/listThemes.doc.d.mts +1 -5
  75. package/api/theme/listThemes.doc.mjs +6 -13
  76. package/api/theme/targets/targets.test.mjs +22 -8
  77. package/api/theme/theme.d.mts +1 -1
  78. package/api/theme/theme.mjs +1 -1
  79. package/api/theme/theme.type.d.mts +9 -0
  80. package/api/theme/theme.type.mjs +3 -1
  81. package/api/theme/themeAdd.doc.d.mts +1 -4
  82. package/api/theme/themeAdd.doc.mjs +31 -31
  83. package/api/theme/themeBuild.doc.mjs +1 -1
  84. package/api/theme/themeList.doc.d.mts +1 -4
  85. package/api/theme/themeList.doc.mjs +7 -15
  86. package/api/theme/themeListAvailable.doc.d.mts +8 -0
  87. package/api/theme/themeListAvailable.doc.mjs +57 -0
  88. package/api/theme/themeTargets.doc.mjs +21 -7
  89. package/api/upgrade/_adapter.d.mts +2 -0
  90. package/api/upgrade/_adapter.mjs +1 -0
  91. package/api/upgrade/registry/registry.d.mts +40 -0
  92. package/api/upgrade/registry/registry.mjs +1154 -0
  93. package/api/upgrade/registry/registry.test.mjs +826 -0
  94. package/api/upgrade/run/run.mjs +49 -8
  95. package/api/upgrade/status/status.d.mts +6 -4
  96. package/api/upgrade/status/status.mjs +26 -8
  97. package/api/upgrade/upgrade.d.mts +2 -2
  98. package/api/upgrade/upgrade.doc.mjs +33 -9
  99. package/api/upgrade/upgrade.mjs +34 -7
  100. package/api/upgrade/upgrade.test.mjs +198 -8
  101. package/api/upgrade/upgrade.type.d.mts +90 -1
  102. package/api/upgrade/upgrade.type.mjs +51 -2
  103. package/assets/docs/cli-integrations.doc.mjs +152 -28
  104. package/assets/docs/getting-started.doc.mjs +1 -1
  105. package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
  106. package/assets/docs/styling.doc.mjs +3 -3
  107. package/assets/docs/theme.doc.dense.mjs +2 -2
  108. package/assets/docs/theme.doc.mjs +23 -13
  109. package/assets/docs/theme.doc.zh.mjs +1 -1
  110. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
  111. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
  112. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
  113. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
  114. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
  115. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
  116. package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
  117. package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
  118. package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
  119. package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
  120. package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
  121. package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
  122. package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
  123. package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
  124. package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
  125. package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
  126. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
  127. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
  128. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
  129. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
  130. package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
  131. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
  132. package/assets/templates/themes/butter/butterTheme.ts +3 -3
  133. package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
  134. package/assets/templates/themes/stone/stoneTheme.ts +3 -3
  135. package/assets/theme.template.ts +4 -7
  136. package/authoring/config/config.doc.mjs +9 -1
  137. package/authoring/config/parse.d.mts +2 -0
  138. package/authoring/config/parse.mjs +28 -3
  139. package/authoring/config/parse.test.mjs +25 -3
  140. package/authoring/config/type.ts +3 -0
  141. package/authoring/doctypes/_schema.d.mts +3 -0
  142. package/authoring/doctypes/_schema.mjs +6 -1
  143. package/authoring/doctypes/base/type.ts +6 -6
  144. package/authoring/doctypes/component/component.doc.mjs +6 -0
  145. package/authoring/doctypes/component/type.ts +2 -0
  146. package/authoring/gap-report/parse.d.mts +63 -0
  147. package/authoring/gap-report/parse.mjs +121 -0
  148. package/authoring/gap-report/parse.test.mjs +172 -0
  149. package/authoring/gap-report/type.ts +107 -0
  150. package/authoring/index.d.mts +1 -0
  151. package/authoring/index.d.ts +12 -0
  152. package/authoring/index.mjs +4 -0
  153. package/authoring/integration/integration.doc.mjs +14 -2
  154. package/authoring/integration/parse.test.mjs +9 -4
  155. package/authoring/integration/schema.d.mts +2 -0
  156. package/authoring/integration/schema.mjs +1 -0
  157. package/authoring/integration/type.ts +23 -6
  158. package/authoring/shadcn/receipt.d.mts +219 -0
  159. package/authoring/shadcn/receipt.mjs +248 -0
  160. package/authoring/shadcn/receipt.test.mjs +187 -0
  161. package/authoring/shadcn/source-variants.d.mts +28 -0
  162. package/authoring/shadcn/source-variants.mjs +176 -0
  163. package/authoring/shadcn/source-variants.test.mjs +120 -0
  164. package/clients/cli/commands/build-theme.mjs +54 -19
  165. package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
  166. package/clients/cli/commands/component/index.mjs +1 -1
  167. package/clients/cli/commands/docs.test.mjs +1 -0
  168. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  169. package/clients/cli/commands/gap-report.doc.mjs +73 -0
  170. package/clients/cli/commands/gap-report.mjs +114 -0
  171. package/clients/cli/commands/gap-report.test.mjs +198 -0
  172. package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
  173. package/clients/cli/commands/integration-add.doc.mjs +88 -0
  174. package/clients/cli/commands/integration-authoring.test.mjs +177 -0
  175. package/clients/cli/commands/integration-pack.doc.mjs +34 -0
  176. package/clients/cli/commands/integration-real-world.test.mjs +618 -0
  177. package/clients/cli/commands/integration.doc.mjs +28 -0
  178. package/clients/cli/commands/integration.mjs +153 -0
  179. package/clients/cli/commands/theme-add.doc.mjs +11 -6
  180. package/clients/cli/commands/theme-list.doc.mjs +21 -5
  181. package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
  182. package/clients/cli/commands/theme.doc.mjs +2 -2
  183. package/clients/cli/commands/upgrade.doc.mjs +17 -4
  184. package/clients/cli/commands/upgrade.mjs +12 -1
  185. package/clients/cli/commands/upgrade.test.mjs +41 -0
  186. package/clients/cli/index.mjs +5 -0
  187. package/clients/cli/lib/component-format.mjs +42 -26
  188. package/clients/cli/lib/component-format.test.mjs +34 -3
  189. package/clients/cli/lib/manifest.mjs +12 -0
  190. package/foundation/config/project-themes.test.mjs +127 -0
  191. package/foundation/config/project.d.mts +23 -4
  192. package/foundation/config/project.mjs +96 -9
  193. package/foundation/config/project.test.mjs +132 -6
  194. package/foundation/discovery/component-discovery.d.mts +36 -0
  195. package/foundation/discovery/component-discovery.mjs +96 -0
  196. package/foundation/discovery/theme-discovery.d.mts +39 -0
  197. package/foundation/discovery/theme-discovery.mjs +650 -0
  198. package/foundation/discovery/theme-discovery.test.mjs +375 -0
  199. package/foundation/discovery/theming-targets.d.mts +16 -0
  200. package/foundation/discovery/theming-targets.mjs +39 -3
  201. package/foundation/discovery/theming-targets.test.mjs +139 -0
  202. package/foundation/integrations/autolink.d.mts +96 -0
  203. package/foundation/integrations/autolink.mjs +265 -0
  204. package/foundation/integrations/autolink.test.mjs +430 -0
  205. package/foundation/integrations/contribution-inventory.d.mts +152 -0
  206. package/foundation/integrations/contribution-inventory.mjs +497 -0
  207. package/foundation/integrations/contribution-inventory.test.mjs +361 -0
  208. package/foundation/integrations/integrations.d.mts +73 -9
  209. package/foundation/integrations/integrations.mjs +158 -8
  210. package/foundation/integrations/integrations.test.mjs +152 -29
  211. package/foundation/integrations/manifest-writer.d.mts +56 -0
  212. package/foundation/integrations/manifest-writer.mjs +328 -0
  213. package/foundation/integrations/manifest-writer.test.mjs +229 -0
  214. package/foundation/integrations/validate-contributions.mjs +81 -6
  215. package/foundation/response/error-codes.d.mts +4 -1
  216. package/foundation/response/error-codes.doc.mjs +16 -1
  217. package/foundation/response/error-codes.mjs +10 -1
  218. package/foundation/response/response-types.doc.mjs +23 -2
  219. package/package.json +8 -1
@@ -0,0 +1,826 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
4
+ import * as fs from 'node:fs';
5
+ import * as os from 'node:os';
6
+ import * as path from 'node:path';
7
+ import {
8
+ createShadcnPrecompiledDeclaration,
9
+ shadcnJavaScriptTarget,
10
+ shadcnPrecompiledDeclarationTarget,
11
+ transformShadcnJavaScriptSource,
12
+ } from '../../../authoring/shadcn/source-variants.mjs';
13
+ import {
14
+ createRegistryReceipt,
15
+ registryReceiptTarget,
16
+ serializeRegistryReceipt,
17
+ } from '../../../authoring/shadcn/receipt.mjs';
18
+ import {
19
+ discoverRegistryReceipts,
20
+ reconcileRegistryCompositions,
21
+ } from './registry.mjs';
22
+
23
+ const ITEM = {
24
+ name: 'example-button-basic',
25
+ path: 'examples/button/basic',
26
+ aliases: [],
27
+ kind: 'example',
28
+ };
29
+ const SOURCE_TARGET = 'components/astryx/examples/ButtonBasic.tsx';
30
+ const REGISTRY_PATH = 'registry/example-button-basic/ButtonBasic.tsx';
31
+ const RECEIPT_TARGET = registryReceiptTarget(SOURCE_TARGET, ITEM.name);
32
+ const JAVASCRIPT_TARGET = shadcnJavaScriptTarget(SOURCE_TARGET);
33
+
34
+ function javascriptVariant(content) {
35
+ return {
36
+ format: 'javascript',
37
+ target: JAVASCRIPT_TARGET,
38
+ content: transformShadcnJavaScriptSource(content),
39
+ };
40
+ }
41
+
42
+ let project;
43
+ let root;
44
+
45
+ function receipt(content, overrides = {}) {
46
+ const target = overrides.target ?? SOURCE_TARGET;
47
+ const registryPath = overrides.registryPath ?? REGISTRY_PATH;
48
+ const item = overrides.item ?? ITEM;
49
+ const receiptTarget =
50
+ overrides.receiptTarget ?? registryReceiptTarget(target, item.name);
51
+ return createRegistryReceipt({
52
+ item,
53
+ sourceVersion: overrides.version ?? '0.5.0',
54
+ receiptTarget,
55
+ files: [
56
+ {
57
+ id: 'primary',
58
+ target,
59
+ registryPath,
60
+ content,
61
+ variants: overrides.variants ?? [],
62
+ },
63
+ ],
64
+ });
65
+ }
66
+
67
+ function seed({
68
+ base,
69
+ current = base,
70
+ receiptValue = receipt(base),
71
+ sourceTarget = SOURCE_TARGET,
72
+ receiptTarget = RECEIPT_TARGET,
73
+ }) {
74
+ const sourcePath = path.join(root, sourceTarget);
75
+ const receiptPath = path.join(root, receiptTarget);
76
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
77
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
78
+ if (current !== null) fs.writeFileSync(sourcePath, current, 'utf8');
79
+ fs.writeFileSync(
80
+ receiptPath,
81
+ typeof receiptValue === 'string'
82
+ ? receiptValue
83
+ : serializeRegistryReceipt(receiptValue),
84
+ 'utf8',
85
+ );
86
+ return {sourcePath, receiptPath};
87
+ }
88
+
89
+ function remote(latest, overrides = {}) {
90
+ const itemIdentity = overrides.item ?? ITEM;
91
+ const target = overrides.target ?? SOURCE_TARGET;
92
+ const registryPath = overrides.registryPath ?? REGISTRY_PATH;
93
+ const receiptBaseTarget = registryReceiptTarget(target, itemIdentity.name);
94
+ const receiptFiles = [
95
+ {
96
+ id: 'primary',
97
+ target,
98
+ registryPath,
99
+ content: latest,
100
+ variants: overrides.variants ?? [],
101
+ },
102
+ ...(overrides.extraFiles ?? []),
103
+ ];
104
+ const nextReceipt = createRegistryReceipt({
105
+ item: itemIdentity,
106
+ sourceVersion: overrides.version ?? '0.6.0',
107
+ receiptTarget: receiptBaseTarget,
108
+ files: receiptFiles,
109
+ });
110
+ const item = {
111
+ name: nextReceipt.item.name,
112
+ type: nextReceipt.item.kind === 'page' ? 'registry:page' : 'registry:block',
113
+ files: [
114
+ ...receiptFiles.map(file => ({
115
+ path: file.registryPath,
116
+ type: file.id === 'types' ? 'registry:file' : 'registry:block',
117
+ target: file.target,
118
+ content:
119
+ file.id === 'primary'
120
+ ? (overrides.sourceContent ?? file.content)
121
+ : file.content,
122
+ })),
123
+ {
124
+ path: `registry/${itemIdentity.name}/astryx-receipt.json`,
125
+ type: 'registry:file',
126
+ target: overrides.receiptTarget ?? receiptBaseTarget,
127
+ content: serializeRegistryReceipt(nextReceipt),
128
+ },
129
+ ],
130
+ };
131
+ return vi.fn(
132
+ async () => new globalThis.Response(JSON.stringify(item), {status: 200}),
133
+ );
134
+ }
135
+
136
+ async function reconcile(options = {}, context = {}) {
137
+ return reconcileRegistryCompositions(
138
+ {path: 'src', ...options},
139
+ {cwd: project, registryOrigin: 'https://registry.example.test', ...context},
140
+ );
141
+ }
142
+
143
+ beforeEach(() => {
144
+ project = fs.mkdtempSync(
145
+ path.join(os.tmpdir(), 'astryx-composition-upgrade-'),
146
+ );
147
+ root = path.join(project, 'src');
148
+ fs.mkdirSync(root, {recursive: true});
149
+ });
150
+
151
+ afterEach(() => {
152
+ fs.rmSync(project, {recursive: true, force: true});
153
+ });
154
+
155
+ describe('registry composition upgrades', () => {
156
+ it('discovers only JSON receipts inside .astryx directories', () => {
157
+ const {receiptPath} = seed({base: 'base\n'});
158
+ fs.writeFileSync(
159
+ path.join(path.dirname(receiptPath), 'notes.txt'),
160
+ 'ignore',
161
+ );
162
+ fs.mkdirSync(path.join(root, 'node_modules', 'x', '.astryx'), {
163
+ recursive: true,
164
+ });
165
+ fs.writeFileSync(
166
+ path.join(root, 'node_modules', 'x', '.astryx', 'ignored.json'),
167
+ '{}',
168
+ );
169
+
170
+ expect(discoverRegistryReceipts(root)).toEqual([receiptPath]);
171
+ });
172
+
173
+ it('bounds concurrent registry fetches', async () => {
174
+ const remoteItems = new Map();
175
+ for (let index = 0; index < 12; index++) {
176
+ const item = {
177
+ name: `example-test-${index}`,
178
+ path: `examples/test/item-${index}`,
179
+ aliases: [],
180
+ kind: 'example',
181
+ };
182
+ const sourceTarget = `components/astryx/examples/Test${index}.tsx`;
183
+ const registryPath = `registry/${item.name}/Test${index}.tsx`;
184
+ const receiptTarget = registryReceiptTarget(sourceTarget, item.name);
185
+ const installed = createRegistryReceipt({
186
+ item,
187
+ sourceVersion: '0.5.0',
188
+ receiptTarget,
189
+ files: [
190
+ {
191
+ id: 'primary',
192
+ target: sourceTarget,
193
+ registryPath,
194
+ content: 'old\n',
195
+ },
196
+ ],
197
+ });
198
+ const latest = createRegistryReceipt({
199
+ item,
200
+ sourceVersion: '0.6.0',
201
+ receiptTarget,
202
+ files: [
203
+ {
204
+ id: 'primary',
205
+ target: sourceTarget,
206
+ registryPath,
207
+ content: 'new\n',
208
+ },
209
+ ],
210
+ });
211
+ const sourcePath = path.join(root, sourceTarget);
212
+ const receiptPath = path.join(root, receiptTarget);
213
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
214
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
215
+ fs.writeFileSync(sourcePath, 'old\n');
216
+ fs.writeFileSync(receiptPath, serializeRegistryReceipt(installed));
217
+ remoteItems.set(
218
+ `/${item.path}.json`,
219
+ JSON.stringify({
220
+ name: item.name,
221
+ type: 'registry:block',
222
+ files: [
223
+ {
224
+ path: registryPath,
225
+ type: 'registry:block',
226
+ target: sourceTarget,
227
+ content: 'new\n',
228
+ },
229
+ {
230
+ path: `registry/${item.name}/astryx-receipt.json`,
231
+ type: 'registry:file',
232
+ target: receiptTarget,
233
+ content: serializeRegistryReceipt(latest),
234
+ },
235
+ ],
236
+ }),
237
+ );
238
+ }
239
+
240
+ let active = 0;
241
+ let maximum = 0;
242
+ const fetchImpl = vi.fn(async url => {
243
+ active++;
244
+ maximum = Math.max(maximum, active);
245
+ await new Promise(resolve => setTimeout(resolve, 5));
246
+ active--;
247
+ const body = remoteItems.get(new URL(url).pathname);
248
+ return new globalThis.Response(body ?? 'not found', {
249
+ status: body ? 200 : 404,
250
+ });
251
+ });
252
+ const result = await reconcile({}, {fetchImpl});
253
+
254
+ expect(result.summary).toMatchObject({found: 12, wouldUpdate: 12});
255
+ expect(maximum).toBe(8);
256
+ });
257
+
258
+ it('reports a current pristine source without writing', async () => {
259
+ const {sourcePath, receiptPath} = seed({base: 'same\n'});
260
+ const before = fs.readFileSync(receiptPath, 'utf8');
261
+ const result = await reconcile(
262
+ {},
263
+ {fetchImpl: remote('same\n', {version: '0.5.0'})},
264
+ );
265
+
266
+ expect(result.summary).toMatchObject({
267
+ applied: false,
268
+ found: 1,
269
+ current: 1,
270
+ conflicts: 0,
271
+ failed: 0,
272
+ });
273
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('same\n');
274
+ expect(fs.readFileSync(receiptPath, 'utf8')).toBe(before);
275
+ });
276
+
277
+ it('refuses source from a different Astryx release', async () => {
278
+ const {sourcePath} = seed({base: 'old\n'});
279
+ const result = await reconcile(
280
+ {apply: true},
281
+ {fetchImpl: remote('new\n'), expectedVersion: '0.5.0'},
282
+ );
283
+
284
+ expect(result.summary).toMatchObject({ok: false, failed: 1, updated: 0});
285
+ expect(result.summary.items[0].message).toMatch(/project has 0\.5\.0/);
286
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
287
+ });
288
+
289
+ it('accepts canary source for an installed canary release', async () => {
290
+ const {sourcePath} = seed({base: 'old\n'});
291
+ const result = await reconcile(
292
+ {apply: true},
293
+ {
294
+ fetchImpl: remote('new\n', {version: 'canary'}),
295
+ expectedVersion: '0.6.0-canary.42',
296
+ },
297
+ );
298
+
299
+ expect(result.summary).toMatchObject({ok: true, updated: 1});
300
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('new\n');
301
+ });
302
+
303
+ it('previews a pristine update without writing', async () => {
304
+ const {sourcePath, receiptPath} = seed({base: 'old\n'});
305
+ const before = fs.readFileSync(receiptPath, 'utf8');
306
+ const result = await reconcile({}, {fetchImpl: remote('new\n')});
307
+
308
+ expect(result.summary).toMatchObject({
309
+ found: 1,
310
+ wouldUpdate: 1,
311
+ updated: 0,
312
+ });
313
+ expect(result.summary.items[0].action).toBe('would-update');
314
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
315
+ expect(fs.readFileSync(receiptPath, 'utf8')).toBe(before);
316
+ });
317
+
318
+ it('updates a pristine source and advances its receipt', async () => {
319
+ const {sourcePath, receiptPath} = seed({base: 'old\n'});
320
+ fs.writeFileSync(`${sourcePath}.astryx-conflict`, 'stale\n');
321
+ const result = await reconcile({apply: true}, {fetchImpl: remote('new\n')});
322
+
323
+ expect(result.summary).toMatchObject({
324
+ applied: true,
325
+ found: 1,
326
+ wouldUpdate: 0,
327
+ updated: 1,
328
+ conflicts: 0,
329
+ items: [{action: 'updated'}],
330
+ });
331
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('new\n');
332
+ expect(fs.existsSync(`${sourcePath}.astryx-conflict`)).toBe(false);
333
+ expect(
334
+ JSON.parse(fs.readFileSync(receiptPath, 'utf8')).source.version,
335
+ ).toBe('0.6.0');
336
+ });
337
+
338
+ it('updates the JavaScript install variant selected by stock ShadCN', async () => {
339
+ const base = "export const value: string = 'old';\n";
340
+ const latest = "export const value: string = 'new';\n";
341
+ const installedReceipt = receipt(base, {
342
+ variants: [javascriptVariant(base)],
343
+ });
344
+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);
345
+ const receiptPath = path.join(root, RECEIPT_TARGET);
346
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
347
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
348
+ fs.writeFileSync(sourcePath, transformShadcnJavaScriptSource(base), 'utf8');
349
+ fs.writeFileSync(
350
+ receiptPath,
351
+ serializeRegistryReceipt(installedReceipt),
352
+ 'utf8',
353
+ );
354
+
355
+ const result = await reconcile(
356
+ {apply: true},
357
+ {
358
+ fetchImpl: remote(latest, {
359
+ variants: [javascriptVariant(latest)],
360
+ }),
361
+ },
362
+ );
363
+
364
+ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});
365
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
366
+ transformShadcnJavaScriptSource(latest),
367
+ );
368
+ expect(fs.existsSync(path.join(root, SOURCE_TARGET))).toBe(false);
369
+ const nextReceipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));
370
+ expect(nextReceipt.schemaVersion).toBe(2);
371
+ expect(nextReceipt.files[0].variants[0].registryTarget).toBe(
372
+ JAVASCRIPT_TARGET,
373
+ );
374
+ });
375
+
376
+ it('treats printer-only JavaScript drift as pristine', async () => {
377
+ const base = "export const value: string = 'old';\n";
378
+ const latest = "export const value: string = 'new';\n";
379
+ const installedReceipt = receipt(base, {
380
+ variants: [javascriptVariant(base)],
381
+ });
382
+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);
383
+ const receiptPath = path.join(root, RECEIPT_TARGET);
384
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
385
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
386
+ fs.writeFileSync(sourcePath, 'export const value = "old";\n', 'utf8');
387
+ fs.writeFileSync(
388
+ receiptPath,
389
+ serializeRegistryReceipt(installedReceipt),
390
+ 'utf8',
391
+ );
392
+
393
+ const result = await reconcile(
394
+ {apply: true},
395
+ {
396
+ fetchImpl: remote(latest, {
397
+ variants: [javascriptVariant(latest)],
398
+ }),
399
+ },
400
+ );
401
+
402
+ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});
403
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
404
+ transformShadcnJavaScriptSource(latest),
405
+ );
406
+ });
407
+
408
+ it('three-way merges edits in a JavaScript install variant', async () => {
409
+ const base =
410
+ "const title: string = 'title';\n" +
411
+ "const body: string = 'body';\n" +
412
+ "const spacer: string = 'spacer';\n" +
413
+ "const footer: string = 'footer';\n" +
414
+ 'export {title, body, spacer, footer};\n';
415
+ const latest = base.replace("'footer'", "'new footer'");
416
+ const current = transformShadcnJavaScriptSource(base).replace(
417
+ "'title'",
418
+ "'custom title'",
419
+ );
420
+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);
421
+ const receiptPath = path.join(root, RECEIPT_TARGET);
422
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
423
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
424
+ fs.writeFileSync(sourcePath, current, 'utf8');
425
+ fs.writeFileSync(
426
+ receiptPath,
427
+ serializeRegistryReceipt(
428
+ receipt(base, {variants: [javascriptVariant(base)]}),
429
+ ),
430
+ 'utf8',
431
+ );
432
+
433
+ const result = await reconcile(
434
+ {apply: true},
435
+ {
436
+ fetchImpl: remote(latest, {
437
+ variants: [javascriptVariant(latest)],
438
+ }),
439
+ },
440
+ );
441
+
442
+ expect(result.summary).toMatchObject({merged: 1, conflicts: 0});
443
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
444
+ transformShadcnJavaScriptSource(latest).replace(
445
+ "'title'",
446
+ "'custom title'",
447
+ ),
448
+ );
449
+ });
450
+
451
+ it('repairs a version 1 JavaScript install on its first upgrade', async () => {
452
+ const base = "export const value: string = 'old';\n";
453
+ const latest = "export const value: string = 'new';\n";
454
+ const currentReceipt = receipt(base);
455
+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];
456
+ const legacyReceipt = {
457
+ ...currentReceipt,
458
+ schemaVersion: 1,
459
+ files: [legacyFile],
460
+ };
461
+ const sourcePath = path.join(root, JAVASCRIPT_TARGET);
462
+ const receiptPath = path.join(root, RECEIPT_TARGET);
463
+ fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
464
+ fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
465
+ fs.writeFileSync(sourcePath, transformShadcnJavaScriptSource(base), 'utf8');
466
+ fs.writeFileSync(
467
+ receiptPath,
468
+ serializeRegistryReceipt(legacyReceipt),
469
+ 'utf8',
470
+ );
471
+
472
+ const result = await reconcile(
473
+ {apply: true},
474
+ {
475
+ fetchImpl: remote(latest, {
476
+ variants: [javascriptVariant(latest)],
477
+ }),
478
+ },
479
+ );
480
+
481
+ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});
482
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
483
+ transformShadcnJavaScriptSource(latest),
484
+ );
485
+ expect(JSON.parse(fs.readFileSync(receiptPath, 'utf8')).schemaVersion).toBe(
486
+ 2,
487
+ );
488
+ });
489
+
490
+ it('adds a strict TypeScript declaration while upgrading legacy precompiled JSX', async () => {
491
+ const target = 'components/astryx/examples/CompiledExample.jsx';
492
+ const registryPath = 'registry/example-button-basic/CompiledExample.jsx';
493
+ const receiptTarget = registryReceiptTarget(target, ITEM.name);
494
+ const base =
495
+ "export default function CompiledExample() { return 'old'; }\n";
496
+ const latest =
497
+ "export default function CompiledExample() { return 'new'; }\n";
498
+ const currentReceipt = receipt(base, {target, registryPath, receiptTarget});
499
+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];
500
+ const legacyReceipt = {
501
+ ...currentReceipt,
502
+ schemaVersion: 1,
503
+ files: [legacyFile],
504
+ };
505
+ const {sourcePath, receiptPath} = seed({
506
+ base,
507
+ receiptValue: legacyReceipt,
508
+ sourceTarget: target,
509
+ receiptTarget,
510
+ });
511
+ const typesTarget = shadcnPrecompiledDeclarationTarget(target);
512
+ const typesContent = createShadcnPrecompiledDeclaration(target);
513
+
514
+ const result = await reconcile(
515
+ {apply: true},
516
+ {
517
+ fetchImpl: remote(latest, {
518
+ target,
519
+ registryPath,
520
+ extraFiles: [
521
+ {
522
+ id: 'types',
523
+ target: typesTarget,
524
+ registryPath: 'registry/example-button-basic/astryx-types.d.mts',
525
+ content: typesContent,
526
+ variants: [],
527
+ },
528
+ ],
529
+ }),
530
+ },
531
+ );
532
+
533
+ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});
534
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(latest);
535
+ expect(fs.readFileSync(path.join(root, typesTarget), 'utf8')).toBe(
536
+ typesContent,
537
+ );
538
+ expect(result.writtenFiles).toContain(path.join(root, typesTarget));
539
+ const nextReceipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));
540
+ expect(nextReceipt.schemaVersion).toBe(2);
541
+ expect(nextReceipt.files.map(file => file.id)).toEqual([
542
+ 'primary',
543
+ 'types',
544
+ ]);
545
+ });
546
+
547
+ it('reports an unreadable generated declaration target without aborting the run', async () => {
548
+ const target = 'components/astryx/examples/CompiledExample.jsx';
549
+ const registryPath = 'registry/example-button-basic/CompiledExample.jsx';
550
+ const receiptTarget = registryReceiptTarget(target, ITEM.name);
551
+ const base =
552
+ "export default function CompiledExample() { return 'old'; }\n";
553
+ const currentReceipt = receipt(base, {target, registryPath, receiptTarget});
554
+ const {variants: _variants, ...legacyFile} = currentReceipt.files[0];
555
+ seed({
556
+ base,
557
+ receiptValue: {...currentReceipt, schemaVersion: 1, files: [legacyFile]},
558
+ sourceTarget: target,
559
+ receiptTarget,
560
+ });
561
+ const typesTarget = shadcnPrecompiledDeclarationTarget(target);
562
+ fs.mkdirSync(path.join(root, typesTarget), {recursive: true});
563
+
564
+ const result = await reconcile(
565
+ {apply: true},
566
+ {
567
+ fetchImpl: remote(base, {
568
+ target,
569
+ registryPath,
570
+ extraFiles: [
571
+ {
572
+ id: 'types',
573
+ target: typesTarget,
574
+ registryPath: 'registry/example-button-basic/astryx-types.d.mts',
575
+ content: createShadcnPrecompiledDeclaration(target),
576
+ variants: [],
577
+ },
578
+ ],
579
+ }),
580
+ },
581
+ );
582
+
583
+ expect(result.summary).toMatchObject({invalid: 1, conflicts: 1, failed: 0});
584
+ expect(fs.lstatSync(path.join(root, typesTarget)).isDirectory()).toBe(true);
585
+ });
586
+
587
+ it('rolls back source when the receipt write fails', async () => {
588
+ if (process.platform === 'win32') return;
589
+ const {sourcePath, receiptPath} = seed({base: 'old\n'});
590
+ const receiptDir = path.dirname(receiptPath);
591
+ fs.chmodSync(receiptDir, 0o500);
592
+ try {
593
+ const result = await reconcile(
594
+ {apply: true},
595
+ {fetchImpl: remote('new\n')},
596
+ );
597
+
598
+ expect(result.summary).toMatchObject({
599
+ ok: false,
600
+ updated: 0,
601
+ failed: 1,
602
+ items: [{action: 'write-error'}],
603
+ });
604
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
605
+ expect(
606
+ JSON.parse(fs.readFileSync(receiptPath, 'utf8')).source.version,
607
+ ).toBe('0.5.0');
608
+ } finally {
609
+ fs.chmodSync(receiptDir, 0o700);
610
+ }
611
+ });
612
+
613
+ it('preserves CRLF when updating a pristine source', async () => {
614
+ const {sourcePath} = seed({
615
+ base: 'first\nsecond\n',
616
+ current: 'first\r\nsecond\r\n',
617
+ });
618
+ const result = await reconcile(
619
+ {apply: true},
620
+ {fetchImpl: remote('first\nupdated\n')},
621
+ );
622
+
623
+ expect(result.summary).toMatchObject({updated: 1, conflicts: 0});
624
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('first\r\nupdated\r\n');
625
+ });
626
+
627
+ it('three-way merges non-overlapping user and upstream edits', async () => {
628
+ const base = 'title\nbody\nfooter\n';
629
+ const current = 'custom title\nbody\nfooter\n';
630
+ const latest = 'title\nbody\nnew footer\n';
631
+ const {sourcePath} = seed({base, current});
632
+ const result = await reconcile({apply: true}, {fetchImpl: remote(latest)});
633
+
634
+ expect(result.summary).toMatchObject({
635
+ merged: 1,
636
+ conflicts: 0,
637
+ items: [{action: 'merged'}],
638
+ });
639
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
640
+ 'custom title\nbody\nnew footer\n',
641
+ );
642
+ });
643
+
644
+ it('preserves CRLF when three-way merging', async () => {
645
+ const base = 'title\nbody\nfooter\n';
646
+ const current = 'custom title\r\nbody\r\nfooter\r\n';
647
+ const latest = 'title\nbody\nnew footer\n';
648
+ const {sourcePath} = seed({base, current});
649
+ const result = await reconcile({apply: true}, {fetchImpl: remote(latest)});
650
+
651
+ expect(result.summary).toMatchObject({merged: 1, conflicts: 0});
652
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
653
+ 'custom title\r\nbody\r\nnew footer\r\n',
654
+ );
655
+ });
656
+
657
+ it('leaves edited source and receipt untouched on conflict', async () => {
658
+ const base = 'value = 1\n';
659
+ const current = 'value = local\n';
660
+ const latest = 'value = upstream\n';
661
+ const {sourcePath, receiptPath} = seed({base, current});
662
+ const beforeReceipt = fs.readFileSync(receiptPath, 'utf8');
663
+ const result = await reconcile({apply: true}, {fetchImpl: remote(latest)});
664
+ const conflictPath = `${sourcePath}.astryx-conflict`;
665
+
666
+ expect(result.summary).toMatchObject({conflicts: 1, updated: 0, merged: 0});
667
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(current);
668
+ expect(fs.readFileSync(receiptPath, 'utf8')).toBe(beforeReceipt);
669
+ expect(fs.readFileSync(conflictPath, 'utf8')).toContain(
670
+ '<<<<<<< current project',
671
+ );
672
+ expect(fs.readFileSync(conflictPath, 'utf8')).toContain(
673
+ '>>>>>>> latest 0.6.0',
674
+ );
675
+ });
676
+
677
+ it('does not recreate a deleted or moved source', async () => {
678
+ const {sourcePath} = seed({base: 'old\n', current: null});
679
+ const result = await reconcile({apply: true}, {fetchImpl: remote('new\n')});
680
+
681
+ expect(result.summary).toMatchObject({missing: 1, conflicts: 1});
682
+ expect(fs.existsSync(sourcePath)).toBe(false);
683
+ });
684
+
685
+ it('does not replace a symbolic-link source', async () => {
686
+ if (process.platform === 'win32') return;
687
+ const {sourcePath} = seed({base: 'old\n'});
688
+ const linkedPath = path.join(root, 'linked.tsx');
689
+ fs.writeFileSync(linkedPath, 'linked\n', 'utf8');
690
+ fs.rmSync(sourcePath);
691
+ fs.symlinkSync(linkedPath, sourcePath);
692
+
693
+ const result = await reconcile({apply: true}, {fetchImpl: remote('new\n')});
694
+
695
+ expect(result.summary).toMatchObject({invalid: 1, conflicts: 1});
696
+ expect(fs.lstatSync(sourcePath).isSymbolicLink()).toBe(true);
697
+ expect(fs.readFileSync(linkedPath, 'utf8')).toBe('linked\n');
698
+ });
699
+
700
+ it('accepts an installed route that became an alias', async () => {
701
+ seed({base: 'old\n'});
702
+ const fetchImpl = remote('new\n', {
703
+ item: {
704
+ ...ITEM,
705
+ path: 'examples/button/new-basic',
706
+ aliases: [ITEM.path],
707
+ },
708
+ });
709
+ const result = await reconcile({apply: true}, {fetchImpl});
710
+
711
+ expect(result.summary.updated).toBe(1);
712
+ expect(fetchImpl.mock.calls[0][0]).toBe(
713
+ 'https://registry.example.test/examples/button/basic.json',
714
+ );
715
+ });
716
+
717
+ it('refuses an upstream source-set change', async () => {
718
+ const {sourcePath} = seed({base: 'old\n'});
719
+ const result = await reconcile(
720
+ {apply: true},
721
+ {
722
+ fetchImpl: remote('new\n', {
723
+ extraFiles: [
724
+ {
725
+ id: 'secondary',
726
+ target: 'components/astryx/examples/Helper.ts',
727
+ registryPath: 'registry/example-button-basic/Helper.ts',
728
+ content: 'export const helper = true;\n',
729
+ },
730
+ ],
731
+ }),
732
+ },
733
+ );
734
+
735
+ expect(result.summary).toMatchObject({conflicts: 1, updated: 0});
736
+ expect(result.summary.items[0].message).toMatch(/source set/);
737
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
738
+ });
739
+
740
+ it('rejects a corrupt installed base before fetching or writing', async () => {
741
+ const value = receipt('base\n');
742
+ value.files[0].sha256 = '0'.repeat(64);
743
+ const {sourcePath} = seed({base: 'base\n', receiptValue: value});
744
+ const fetchImpl = remote('new\n');
745
+ const result = await reconcile({apply: true}, {fetchImpl});
746
+
747
+ expect(result.summary).toMatchObject({invalid: 1, failed: 0});
748
+ expect(fetchImpl).not.toHaveBeenCalled();
749
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('base\n');
750
+ });
751
+
752
+ it('rejects a receipt target that escapes the source root', async () => {
753
+ const value = receipt('base\n');
754
+ value.files[0].target = '../../../outside.tsx';
755
+ const outside = path.join(project, 'outside.tsx');
756
+ seed({base: 'base\n', receiptValue: value});
757
+ const result = await reconcile({apply: true}, {fetchImpl: remote('new\n')});
758
+
759
+ expect(result.summary.invalid).toBe(1);
760
+ expect(fs.existsSync(outside)).toBe(false);
761
+ });
762
+
763
+ it('rejects an oversized registry item before reading its body', async () => {
764
+ seed({base: 'old\n'});
765
+ const fetchImpl = vi.fn(
766
+ async () =>
767
+ new globalThis.Response('{}', {
768
+ status: 200,
769
+ headers: {'content-length': String(16 * 1024 * 1024 + 1)},
770
+ }),
771
+ );
772
+ const result = await reconcile({apply: true}, {fetchImpl});
773
+
774
+ expect(result.summary.failed).toBe(1);
775
+ expect(result.summary.items[0].message).toMatch(/exceeds/);
776
+ });
777
+
778
+ it('rejects a remote receipt installed under the wrong target', async () => {
779
+ const {sourcePath} = seed({base: 'old\n'});
780
+ const result = await reconcile(
781
+ {apply: true},
782
+ {
783
+ fetchImpl: remote('new\n', {
784
+ receiptTarget: 'components/astryx/.astryx/wrong.json',
785
+ }),
786
+ },
787
+ );
788
+
789
+ expect(result.summary.failed).toBe(1);
790
+ expect(result.summary.items[0].message).toMatch(/misplaced/);
791
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
792
+ });
793
+
794
+ it('rejects a remote JavaScript variant that disagrees with canonical source', async () => {
795
+ const base = "export const value: string = 'old';\n";
796
+ const latest = "export const value: string = 'new';\n";
797
+ const {sourcePath} = seed({base});
798
+ const result = await reconcile(
799
+ {apply: true},
800
+ {
801
+ fetchImpl: remote(latest, {
802
+ variants: [
803
+ javascriptVariant("export const value: string = 'tampered';\n"),
804
+ ],
805
+ }),
806
+ },
807
+ );
808
+
809
+ expect(result.summary.failed).toBe(1);
810
+ expect(result.summary.items[0].message).toMatch(
811
+ /invalid javascript variant/,
812
+ );
813
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe(base);
814
+ });
815
+
816
+ it('rejects a remote receipt that disagrees with shipped source', async () => {
817
+ const {sourcePath} = seed({base: 'old\n'});
818
+ const result = await reconcile(
819
+ {apply: true},
820
+ {fetchImpl: remote('new\n', {sourceContent: 'tampered\n'})},
821
+ );
822
+
823
+ expect(result.summary.failed).toBe(1);
824
+ expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
825
+ });
826
+ });