@graphcommerce/next-config 10.0.4-canary.1 → 10.1.0-canary.13
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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.1.0-canary.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2621](https://github.com/graphcommerce-org/graphcommerce/pull/2621) [`4eccccd`](https://github.com/graphcommerce-org/graphcommerce/commit/4eccccdad9418e713cb6959b20e9cde6ab26d9ae) - `graphcommerce cleanup-interceptors` now actually finds and restores `.original.tsx` / `.original.ts` files when run from a consumer project. Previously `findDotOriginalFiles` walked up looking for a `@graphcommerce/*` parent package; from a consumer project (where there is no such parent) `parentPath` ended up `null` and the glob expanded to literally `null/**/*.original.tsx`, so the command silently restored nothing. Now it falls back to `cwd` and `cwd/node_modules/@graphcommerce` where interceptors actually live for consumers.
|
|
8
|
+
|
|
9
|
+
Also fixes a display bug — the final `X files restored from .original` line printed an always-`0` counter (`restoredCount` was declared but never incremented; the now-removed `removedCount` was the one being incremented). Counter and message are now consistent. ([@paales](https://github.com/paales))
|
|
10
|
+
|
|
11
|
+
## 10.1.0-canary.12
|
|
12
|
+
|
|
13
|
+
## 10.1.0-canary.11
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#2621](https://github.com/graphcommerce-org/graphcommerce/pull/2621) [`4eccccd`](https://github.com/graphcommerce-org/graphcommerce/commit/4eccccdad9418e713cb6959b20e9cde6ab26d9ae) - `graphcommerce cleanup-interceptors` now actually finds and restores `.original.tsx` / `.original.ts` files when run from a consumer project. Previously `findDotOriginalFiles` walked up looking for a `@graphcommerce/*` parent package; from a consumer project (where there is no such parent) `parentPath` ended up `null` and the glob expanded to literally `null/**/*.original.tsx`, so the command silently restored nothing. Now it falls back to `cwd` and `cwd/node_modules/@graphcommerce` where interceptors actually live for consumers.
|
|
18
|
+
|
|
19
|
+
Also fixes a display bug — the final `X files restored from .original` line printed an always-`0` counter (`restoredCount` was declared but never incremented; the now-removed `removedCount` was the one being incremented). Counter and message are now consistent. ([@paales](https://github.com/paales))
|
|
20
|
+
|
|
21
|
+
## 10.1.0-canary.10
|
|
22
|
+
|
|
23
|
+
## 10.1.0-canary.9
|
|
24
|
+
|
|
25
|
+
## 10.1.0-canary.8
|
|
26
|
+
|
|
27
|
+
## 10.1.0-canary.7
|
|
28
|
+
|
|
29
|
+
## 10.1.0-canary.6
|
|
30
|
+
|
|
31
|
+
## 10.1.0-canary.5
|
|
32
|
+
|
|
33
|
+
## 10.1.0-canary.4
|
|
34
|
+
|
|
35
|
+
## 10.1.0-canary.3
|
|
36
|
+
|
|
37
|
+
## 10.0.4-canary.2
|
|
38
|
+
|
|
3
39
|
## 10.0.4-canary.1
|
|
4
40
|
|
|
5
41
|
## 10.0.4-canary.0
|
|
@@ -75,7 +75,8 @@ it('it generates an interceptor', async () => {
|
|
|
75
75
|
type PluginAddMollieMethodsProps = OmitPrev<
|
|
76
76
|
React.ComponentProps<typeof PluginAddMollieMethods>,
|
|
77
77
|
'Prev'
|
|
78
|
-
>
|
|
78
|
+
> &
|
|
79
|
+
PluginAddBraintreeMethodsProps
|
|
79
80
|
|
|
80
81
|
const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
|
|
81
82
|
<PluginAddMollieMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
|
|
@@ -91,7 +92,9 @@ it('it generates an interceptor', async () => {
|
|
|
91
92
|
* @see {PluginAddBraintreeMethods} for source of applied plugin
|
|
92
93
|
* @see {PluginAddMollieMethods} for source of applied plugin
|
|
93
94
|
*/
|
|
94
|
-
export const PaymentMethodContextProvider =
|
|
95
|
+
export const PaymentMethodContextProvider =
|
|
96
|
+
PluginAddMollieMethodsInterceptor as typeof PaymentMethodContextProviderOriginal &
|
|
97
|
+
React.FC<PluginAddMollieMethodsProps>
|
|
95
98
|
"
|
|
96
99
|
`)
|
|
97
100
|
})
|
|
@@ -176,7 +179,8 @@ it('it can apply multiple plugins to a single export', async () => {
|
|
|
176
179
|
type PluginAddMollieMethodsProps = OmitPrev<
|
|
177
180
|
React.ComponentProps<typeof PluginAddMollieMethods>,
|
|
178
181
|
'Prev'
|
|
179
|
-
>
|
|
182
|
+
> &
|
|
183
|
+
PluginAddAdyenMethodsProps
|
|
180
184
|
|
|
181
185
|
const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
|
|
182
186
|
<PluginAddMollieMethods {...props} Prev={PluginAddAdyenMethodsInterceptor} />
|
|
@@ -192,7 +196,9 @@ it('it can apply multiple plugins to a single export', async () => {
|
|
|
192
196
|
* @see {PluginAddAdyenMethods} for source of applied plugin
|
|
193
197
|
* @see {PluginAddMollieMethods} for source of applied plugin
|
|
194
198
|
*/
|
|
195
|
-
export const PaymentMethodContextProvider =
|
|
199
|
+
export const PaymentMethodContextProvider =
|
|
200
|
+
PluginAddMollieMethodsInterceptor as typeof PaymentMethodContextProviderOriginal &
|
|
201
|
+
React.FC<PluginAddMollieMethodsProps>
|
|
196
202
|
"
|
|
197
203
|
`)
|
|
198
204
|
})
|
|
@@ -245,7 +251,8 @@ it('it handles on duplicates gracefully', async () => {
|
|
|
245
251
|
type PluginAddBraintreeMethodsProps = OmitPrev<
|
|
246
252
|
React.ComponentProps<typeof PluginAddBraintreeMethods>,
|
|
247
253
|
'Prev'
|
|
248
|
-
>
|
|
254
|
+
> &
|
|
255
|
+
PluginAddBraintreeMethodsProps
|
|
249
256
|
|
|
250
257
|
const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
|
|
251
258
|
<PluginAddBraintreeMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
|
|
@@ -261,7 +268,9 @@ it('it handles on duplicates gracefully', async () => {
|
|
|
261
268
|
* @see {PluginAddBraintreeMethods} for source of applied plugin
|
|
262
269
|
* @see {PluginAddBraintreeMethods} for source of applied plugin
|
|
263
270
|
*/
|
|
264
|
-
export const PaymentMethodContextProvider =
|
|
271
|
+
export const PaymentMethodContextProvider =
|
|
272
|
+
PluginAddBraintreeMethodsInterceptor as typeof PaymentMethodContextProviderOriginal &
|
|
273
|
+
React.FC<PluginAddBraintreeMethodsProps>
|
|
265
274
|
"
|
|
266
275
|
`)
|
|
267
276
|
})
|
|
@@ -636,7 +645,9 @@ export const Plugin = ConfigurableProductPageName
|
|
|
636
645
|
* @see {ProductPageNameMyPlugin} for source of replaced component
|
|
637
646
|
* @see {PluginConfigurableProductPageName} for source of applied plugin
|
|
638
647
|
*/
|
|
639
|
-
export const ProductPageName =
|
|
648
|
+
export const ProductPageName =
|
|
649
|
+
PluginConfigurableProductPageNameInterceptor as typeof ProductPageNameMyPlugin &
|
|
650
|
+
React.FC<PluginConfigurableProductPageNameProps>
|
|
640
651
|
"
|
|
641
652
|
`)
|
|
642
653
|
})
|
package/dist/index.js
CHANGED
|
@@ -52,9 +52,12 @@ async function findDotOriginalFiles(cwd) {
|
|
|
52
52
|
if (p) parentPath = p;
|
|
53
53
|
else break;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const roots = parentPath ? [parentPath] : [cwd, `${cwd}/node_modules/@graphcommerce`];
|
|
56
|
+
const patterns = roots.flatMap((root) => [
|
|
57
|
+
`${root}/**/*.original.tsx`,
|
|
58
|
+
`${root}/**/*.original.ts`
|
|
59
|
+
]);
|
|
60
|
+
return Promise.all((await glob(patterns, { cwd })).map((file) => fs.realpath(file)));
|
|
58
61
|
}
|
|
59
62
|
async function writeInterceptors(interceptors, cwd = process.cwd()) {
|
|
60
63
|
const processedFiles = [];
|
|
@@ -105,13 +108,12 @@ dotenv.config({ quiet: true });
|
|
|
105
108
|
async function cleanupInterceptors(cwd = process.cwd()) {
|
|
106
109
|
console.info("\u{1F9F9} Starting interceptor cleanup...");
|
|
107
110
|
let restoredCount = 0;
|
|
108
|
-
let removedCount = 0;
|
|
109
111
|
const originalFiles = await findDotOriginalFiles(cwd);
|
|
110
112
|
console.info(`\u{1F4C2} Found ${originalFiles.length} .original files to restore`);
|
|
111
113
|
for (const originalFile of originalFiles) {
|
|
112
114
|
try {
|
|
113
115
|
await restoreOriginalFile(originalFile);
|
|
114
|
-
|
|
116
|
+
restoredCount++;
|
|
115
117
|
} catch (error) {
|
|
116
118
|
console.error(`\u274C Failed to restore ${originalFile}:`, error);
|
|
117
119
|
}
|
|
@@ -428,7 +430,7 @@ function extractValue(node, path, optional = false) {
|
|
|
428
430
|
}
|
|
429
431
|
}
|
|
430
432
|
function extractExports(module) {
|
|
431
|
-
const exports
|
|
433
|
+
const exports = {};
|
|
432
434
|
const errors = [];
|
|
433
435
|
for (const moduleItem of module.body) {
|
|
434
436
|
switch (moduleItem.type) {
|
|
@@ -442,19 +444,19 @@ function extractExports(module) {
|
|
|
442
444
|
switch (moduleItem.declaration.type) {
|
|
443
445
|
case "ClassDeclaration":
|
|
444
446
|
case "FunctionDeclaration":
|
|
445
|
-
exports
|
|
447
|
+
exports[moduleItem.declaration.identifier.value] = RUNTIME_VALUE;
|
|
446
448
|
break;
|
|
447
449
|
case "VariableDeclaration":
|
|
448
450
|
moduleItem.declaration.declarations.forEach((decl) => {
|
|
449
451
|
if (isIdentifier(decl.id) && decl.init) {
|
|
450
|
-
exports
|
|
452
|
+
exports[decl.id.value] = extractValue(decl.init, void 0, true);
|
|
451
453
|
}
|
|
452
454
|
});
|
|
453
455
|
break;
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
|
-
return [exports
|
|
459
|
+
return [exports, errors];
|
|
458
460
|
}
|
|
459
461
|
|
|
460
462
|
const pluginConfigParsed = z.object({
|
|
@@ -468,7 +470,7 @@ function nonNullable(value) {
|
|
|
468
470
|
}
|
|
469
471
|
const isObject = (input) => typeof input === "object" && input !== null && !Array.isArray(input);
|
|
470
472
|
function parseStructure(ast, gcConfig, sourceModule) {
|
|
471
|
-
const [exports
|
|
473
|
+
const [exports, errors] = extractExports(ast);
|
|
472
474
|
if (errors.length) console.error("Plugin error for", errors.join("\n"));
|
|
473
475
|
const {
|
|
474
476
|
config: moduleConfig,
|
|
@@ -479,7 +481,7 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
479
481
|
plugin,
|
|
480
482
|
Plugin,
|
|
481
483
|
...rest
|
|
482
|
-
} = exports
|
|
484
|
+
} = exports;
|
|
483
485
|
const exportVals = Object.keys(rest);
|
|
484
486
|
if (component && !moduleConfig) exportVals.push("Plugin");
|
|
485
487
|
if (func && !moduleConfig) exportVals.push("plugin");
|
|
@@ -513,7 +515,7 @@ function parseStructure(ast, gcConfig, sourceModule) {
|
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
517
|
const val = {
|
|
516
|
-
targetExport: exports
|
|
518
|
+
targetExport: exports.component || exports.func || parsed.data.export,
|
|
517
519
|
sourceModule,
|
|
518
520
|
sourceExport: parsed.data.export,
|
|
519
521
|
targetModule: parsed.data.module,
|
|
@@ -623,12 +625,12 @@ function parseAndFindExport(resolved, findExport, resolve) {
|
|
|
623
625
|
}
|
|
624
626
|
}
|
|
625
627
|
}
|
|
626
|
-
const exports
|
|
628
|
+
const exports = ast.body.filter((node) => node.type === "ExportAllDeclaration").sort((a, b) => {
|
|
627
629
|
const probablyA = a.source.value.includes(findExport);
|
|
628
630
|
const probablyB = b.source.value.includes(findExport);
|
|
629
631
|
return probablyA === probablyB ? 0 : probablyA ? -1 : 1;
|
|
630
632
|
});
|
|
631
|
-
for (const node of exports
|
|
633
|
+
for (const node of exports) {
|
|
632
634
|
const isRelative = node.source.value.startsWith(".");
|
|
633
635
|
if (isRelative) {
|
|
634
636
|
const d = resolved.dependency === resolved.denormalized ? resolved.dependency.substring(0, resolved.dependency.lastIndexOf("/")) : resolved.dependency;
|
|
@@ -1485,7 +1487,7 @@ async function createConfigSectionFile(sectionName, sectionValue, targetDir, tar
|
|
|
1485
1487
|
for (const key of schemaKeys) {
|
|
1486
1488
|
completeSectionValue[key] = sectionValue[key];
|
|
1487
1489
|
}
|
|
1488
|
-
const exports
|
|
1490
|
+
const exports = Object.entries(completeSectionValue).map(([key, value]) => {
|
|
1489
1491
|
const valueStr = generateValueLiteral(value);
|
|
1490
1492
|
const propertyPath = `'${sectionName}.${key}'`;
|
|
1491
1493
|
const typeAnnotation = `: Get<GraphCommerceConfig, ${propertyPath}>`;
|
|
@@ -1496,7 +1498,7 @@ import type { Get } from 'type-fest'` ;
|
|
|
1496
1498
|
const content = `// Auto-generated by 'yarn graphcommerce codegen-config-values'
|
|
1497
1499
|
${imports}
|
|
1498
1500
|
|
|
1499
|
-
${exports
|
|
1501
|
+
${exports}
|
|
1500
1502
|
`;
|
|
1501
1503
|
const formattedContent = await prettier.format(content, {
|
|
1502
1504
|
...prettierConf,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-config",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.0
|
|
5
|
+
"version": "10.1.0-canary.13",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@apollo/client": "*",
|
|
66
|
-
"@graphcommerce/prettier-config-pwa": "^10.0
|
|
66
|
+
"@graphcommerce/prettier-config-pwa": "^10.1.0-canary.13",
|
|
67
67
|
"@lingui/loader": "*",
|
|
68
68
|
"@lingui/macro": "*",
|
|
69
69
|
"@lingui/react": "*",
|
|
@@ -7,7 +7,6 @@ export async function cleanupInterceptors(cwd: string = process.cwd()) {
|
|
|
7
7
|
console.info('🧹 Starting interceptor cleanup...')
|
|
8
8
|
|
|
9
9
|
let restoredCount = 0
|
|
10
|
-
let removedCount = 0
|
|
11
10
|
|
|
12
11
|
const originalFiles = await findDotOriginalFiles(cwd)
|
|
13
12
|
console.info(`📂 Found ${originalFiles.length} .original files to restore`)
|
|
@@ -15,7 +14,7 @@ export async function cleanupInterceptors(cwd: string = process.cwd()) {
|
|
|
15
14
|
for (const originalFile of originalFiles) {
|
|
16
15
|
try {
|
|
17
16
|
await restoreOriginalFile(originalFile)
|
|
18
|
-
|
|
17
|
+
restoredCount++
|
|
19
18
|
} catch (error) {
|
|
20
19
|
console.error(`❌ Failed to restore ${originalFile}:`, error)
|
|
21
20
|
}
|
|
@@ -40,11 +40,18 @@ export async function findDotOriginalFiles(cwd: string) {
|
|
|
40
40
|
else break
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
// Called from inside a @graphcommerce package (upstream dev) → scan from the
|
|
44
|
+
// outermost @graphcommerce parent. Called from a consumer project (no
|
|
45
|
+
// @graphcommerce parent) → scan the project AND node_modules/@graphcommerce,
|
|
46
|
+
// because the interceptor system writes .original files alongside the
|
|
47
|
+
// installed packages there.
|
|
48
|
+
const roots = parentPath ? [parentPath] : [cwd, `${cwd}/node_modules/@graphcommerce`]
|
|
49
|
+
const patterns = roots.flatMap((root) => [
|
|
50
|
+
`${root}/**/*.original.tsx`,
|
|
51
|
+
`${root}/**/*.original.ts`,
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
return Promise.all((await glob(patterns, { cwd })).map((file) => fs.realpath(file)))
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export async function writeInterceptors(
|