@graphcommerce/next-config 9.0.0-canary.107 → 9.0.0-canary.109
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 +4 -0
- package/__tests__/interceptors/findPlugins.ts +9 -8
- package/__tests__/utils/resolveDependenciesSync.ts +1 -0
- package/dist/commands/copyFiles.js +1 -2
- package/dist/index.js +0 -1
- package/dist/utils/isMonorepo.js +66 -4
- package/dist/withGraphCommerce.js +1 -1
- package/package.json +4 -2
- package/src/commands/copyFiles.ts +1 -2
- package/src/index.ts +0 -1
- package/src/utils/isMonorepo.ts +79 -4
- package/src/withGraphCommerce.ts +1 -1
- package/dist/runtimeCachingOptimizations.js +0 -28
- package/src/runtimeCachingOptimizations.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -240,14 +240,6 @@ it('finds plugins', () => {
|
|
|
240
240
|
"targetModule": "@graphcommerce/magento-product",
|
|
241
241
|
"type": "component",
|
|
242
242
|
},
|
|
243
|
-
{
|
|
244
|
-
"enabled": true,
|
|
245
|
-
"sourceExport": "ProductPageGallery",
|
|
246
|
-
"sourceModule": "@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageGallery",
|
|
247
|
-
"targetExport": "ProductPageGallery",
|
|
248
|
-
"targetModule": "@graphcommerce/magento-product",
|
|
249
|
-
"type": "component",
|
|
250
|
-
},
|
|
251
243
|
{
|
|
252
244
|
"enabled": true,
|
|
253
245
|
"sourceExport": "CartItemActionCard",
|
|
@@ -668,6 +660,15 @@ it('finds plugins', () => {
|
|
|
668
660
|
"targetModule": "@graphcommerce/magento-product",
|
|
669
661
|
"type": "component",
|
|
670
662
|
},
|
|
663
|
+
{
|
|
664
|
+
"enabled": false,
|
|
665
|
+
"ifConfig": "configurableVariantValues.gallery",
|
|
666
|
+
"sourceExport": "ProductPageGallery",
|
|
667
|
+
"sourceModule": "@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageGallery",
|
|
668
|
+
"targetExport": "ProductPageGallery",
|
|
669
|
+
"targetModule": "@graphcommerce/magento-product",
|
|
670
|
+
"type": "component",
|
|
671
|
+
},
|
|
671
672
|
{
|
|
672
673
|
"enabled": false,
|
|
673
674
|
"ifConfig": "configurableVariantValues.content",
|
|
@@ -31,6 +31,7 @@ it('resolves dependences', () => {
|
|
|
31
31
|
"@graphcommerce/magento-product-virtual" => "packages/magento-product-virtual",
|
|
32
32
|
"@graphcommerce/magento-review" => "packages/magento-review",
|
|
33
33
|
"@graphcommerce/magento-wishlist" => "packages/magento-wishlist",
|
|
34
|
+
"@graphcommerce/service-worker" => "packages/service-worker",
|
|
34
35
|
"@graphcommerce/magento-cart-pickup" => "packages/magento-cart-pickup",
|
|
35
36
|
"@graphcommerce/magento-payment-braintree" => "packages/magento-payment-braintree",
|
|
36
37
|
"@graphcommerce/mollie-magento-payment" => "packages/mollie-magento-payment",
|
|
@@ -192,8 +192,7 @@ Found in packages:
|
|
|
192
192
|
Source: ${sourcePath}`);
|
|
193
193
|
process.exit(1);
|
|
194
194
|
}
|
|
195
|
-
console.log(`Creating new file: ${file}
|
|
196
|
-
Source: ${sourcePath}`);
|
|
195
|
+
console.log(`Creating new file: ${file}\nSource: ${sourcePath}`);
|
|
197
196
|
debug('File does not exist yet');
|
|
198
197
|
}
|
|
199
198
|
// Skip if content is identical (including magic comment)
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ __exportStar(require("./utils/sig"), exports);
|
|
|
21
21
|
__exportStar(require("./withGraphCommerce"), exports);
|
|
22
22
|
__exportStar(require("./generated/config"), exports);
|
|
23
23
|
__exportStar(require("./config"), exports);
|
|
24
|
-
__exportStar(require("./runtimeCachingOptimizations"), exports);
|
|
25
24
|
__exportStar(require("./interceptors/commands/codegenInterceptors"), exports);
|
|
26
25
|
__exportStar(require("./commands/copyFiles"), exports);
|
|
27
26
|
__exportStar(require("./commands/codegen"), exports);
|
package/dist/utils/isMonorepo.js
CHANGED
|
@@ -4,10 +4,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isMonorepo = isMonorepo;
|
|
7
|
+
exports.findParentPath = findParentPath;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
7
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const debug = process.env.DEBUG === '1';
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
const log = (message) => debug && console.log(`isMonorepo: ${message}`);
|
|
13
|
+
function findPackageJson(directory) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJsonPath = node_path_1.default.join(directory, 'package.json');
|
|
16
|
+
const content = node_fs_1.default.readFileSync(packageJsonPath, 'utf8');
|
|
17
|
+
return JSON.parse(content);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Determines if we're running in a monorepo context and how to handle postinstall scripts.
|
|
25
|
+
*
|
|
26
|
+
* If there is a parent `@graphcommerce/*` package, we're in a monorepo.
|
|
27
|
+
*/
|
|
8
28
|
function isMonorepo() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
29
|
+
let currentDir = process.cwd();
|
|
30
|
+
log(`Starting directory: ${currentDir}`);
|
|
31
|
+
// Start from the parent directory to find a parent @graphcommerce package
|
|
32
|
+
currentDir = node_path_1.default.dirname(currentDir);
|
|
33
|
+
log(`Looking for parent packages starting from: ${currentDir}`);
|
|
34
|
+
// Keep going up until we find a root package or hit the filesystem root
|
|
35
|
+
while (currentDir !== node_path_1.default.parse(currentDir).root) {
|
|
36
|
+
const packageJson = findPackageJson(currentDir);
|
|
37
|
+
if (packageJson) {
|
|
38
|
+
log(`Found package.json in: ${currentDir}`);
|
|
39
|
+
log(`Package name: ${packageJson.name}`);
|
|
40
|
+
if (packageJson.name.startsWith('@graphcommerce/')) {
|
|
41
|
+
log('isMonorepo result: true (found parent @graphcommerce package)');
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
currentDir = node_path_1.default.dirname(currentDir);
|
|
46
|
+
}
|
|
47
|
+
log('isMonorepo result: false (no parent @graphcommerce package found)');
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Finds the path of the parent @graphcommerce package if it exists Returns null if no parent
|
|
52
|
+
* package is found
|
|
53
|
+
*/
|
|
54
|
+
function findParentPath(directory) {
|
|
55
|
+
let currentDir = directory;
|
|
56
|
+
log(`Starting directory: ${currentDir}`);
|
|
57
|
+
// Start from the parent directory
|
|
58
|
+
currentDir = node_path_1.default.dirname(currentDir);
|
|
59
|
+
log(`Looking for parent packages starting from: ${currentDir}`);
|
|
60
|
+
// Keep going up until we find a root package or hit the filesystem root
|
|
61
|
+
while (currentDir !== node_path_1.default.parse(currentDir).root) {
|
|
62
|
+
const packageJson = findPackageJson(currentDir);
|
|
63
|
+
if (packageJson) {
|
|
64
|
+
log(`Found package.json in: ${currentDir}`);
|
|
65
|
+
log(`Package name: ${packageJson.name}`);
|
|
66
|
+
if (packageJson.name.startsWith('@graphcommerce/')) {
|
|
67
|
+
log(`Found parent @graphcommerce package at: ${currentDir}`);
|
|
68
|
+
return currentDir;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
currentDir = node_path_1.default.dirname(currentDir);
|
|
72
|
+
}
|
|
73
|
+
log('No parent @graphcommerce package found');
|
|
74
|
+
return null;
|
|
13
75
|
}
|
|
@@ -31,7 +31,7 @@ function domains(config) {
|
|
|
31
31
|
* module.exports = withGraphCommerce(nextConfig)
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
function withGraphCommerce(nextConfig, cwd) {
|
|
34
|
+
function withGraphCommerce(nextConfig, cwd = process.cwd()) {
|
|
35
35
|
graphcommerceConfig ??= (0, loadConfig_1.loadConfig)(cwd);
|
|
36
36
|
const importMetaPaths = (0, configToImportMeta_1.configToImportMeta)(graphcommerceConfig);
|
|
37
37
|
const { storefront } = graphcommerceConfig;
|
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": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.109",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "src/index.ts",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"@lingui/macro": "4.14.0",
|
|
18
18
|
"@lingui/react": "4.14.0",
|
|
19
19
|
"@lingui/swc-plugin": "4.1.0",
|
|
20
|
+
"@serwist/build": "^9.0.10",
|
|
21
|
+
"@serwist/next": "^9.0.10",
|
|
20
22
|
"@swc/core": "1.9.3",
|
|
21
23
|
"@swc/wasm-web": "^1.9.3",
|
|
22
24
|
"@types/circular-dependency-plugin": "^5.0.8",
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
"circular-dependency-plugin": "^5.2.2",
|
|
26
28
|
"fast-glob": "^3.3.2",
|
|
27
29
|
"glob": "^10.4.5",
|
|
28
|
-
"graphql": "^16",
|
|
30
|
+
"graphql": "^16.9.0",
|
|
29
31
|
"inspectpack": "^4.7.1",
|
|
30
32
|
"js-yaml-loader": "^1.2.2",
|
|
31
33
|
"lodash": "^4.17.21",
|
|
@@ -220,8 +220,7 @@ Found in packages:
|
|
|
220
220
|
Source: ${sourcePath}`)
|
|
221
221
|
process.exit(1)
|
|
222
222
|
}
|
|
223
|
-
console.log(`Creating new file: ${file}
|
|
224
|
-
Source: ${sourcePath}`)
|
|
223
|
+
console.log(`Creating new file: ${file}\nSource: ${sourcePath}`)
|
|
225
224
|
debug('File does not exist yet')
|
|
226
225
|
}
|
|
227
226
|
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from './utils/sig'
|
|
|
10
10
|
export * from './withGraphCommerce'
|
|
11
11
|
export * from './generated/config'
|
|
12
12
|
export * from './config'
|
|
13
|
-
export * from './runtimeCachingOptimizations'
|
|
14
13
|
export * from './interceptors/commands/codegenInterceptors'
|
|
15
14
|
export * from './commands/copyFiles'
|
|
16
15
|
export * from './commands/codegen'
|
package/src/utils/isMonorepo.ts
CHANGED
|
@@ -1,8 +1,83 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
1
2
|
import path from 'node:path'
|
|
2
3
|
|
|
4
|
+
const debug = process.env.DEBUG === '1'
|
|
5
|
+
// eslint-disable-next-line no-console
|
|
6
|
+
const log = (message: string) => debug && console.log(`isMonorepo: ${message}`)
|
|
7
|
+
|
|
8
|
+
function findPackageJson(directory: string): { name: string } | null {
|
|
9
|
+
try {
|
|
10
|
+
const packageJsonPath = path.join(directory, 'package.json')
|
|
11
|
+
const content = fs.readFileSync(packageJsonPath, 'utf8')
|
|
12
|
+
return JSON.parse(content)
|
|
13
|
+
} catch {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Determines if we're running in a monorepo context and how to handle postinstall scripts.
|
|
20
|
+
*
|
|
21
|
+
* If there is a parent `@graphcommerce/*` package, we're in a monorepo.
|
|
22
|
+
*/
|
|
3
23
|
export function isMonorepo() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
let currentDir = process.cwd()
|
|
25
|
+
log(`Starting directory: ${currentDir}`)
|
|
26
|
+
|
|
27
|
+
// Start from the parent directory to find a parent @graphcommerce package
|
|
28
|
+
currentDir = path.dirname(currentDir)
|
|
29
|
+
log(`Looking for parent packages starting from: ${currentDir}`)
|
|
30
|
+
|
|
31
|
+
// Keep going up until we find a root package or hit the filesystem root
|
|
32
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
33
|
+
const packageJson = findPackageJson(currentDir)
|
|
34
|
+
|
|
35
|
+
if (packageJson) {
|
|
36
|
+
log(`Found package.json in: ${currentDir}`)
|
|
37
|
+
log(`Package name: ${packageJson.name}`)
|
|
38
|
+
|
|
39
|
+
if (packageJson.name.startsWith('@graphcommerce/')) {
|
|
40
|
+
log('isMonorepo result: true (found parent @graphcommerce package)')
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
currentDir = path.dirname(currentDir)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
log('isMonorepo result: false (no parent @graphcommerce package found)')
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Finds the path of the parent @graphcommerce package if it exists Returns null if no parent
|
|
54
|
+
* package is found
|
|
55
|
+
*/
|
|
56
|
+
export function findParentPath(directory: string): string | null {
|
|
57
|
+
let currentDir = directory
|
|
58
|
+
log(`Starting directory: ${currentDir}`)
|
|
59
|
+
|
|
60
|
+
// Start from the parent directory
|
|
61
|
+
currentDir = path.dirname(currentDir)
|
|
62
|
+
log(`Looking for parent packages starting from: ${currentDir}`)
|
|
63
|
+
|
|
64
|
+
// Keep going up until we find a root package or hit the filesystem root
|
|
65
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
66
|
+
const packageJson = findPackageJson(currentDir)
|
|
67
|
+
|
|
68
|
+
if (packageJson) {
|
|
69
|
+
log(`Found package.json in: ${currentDir}`)
|
|
70
|
+
log(`Package name: ${packageJson.name}`)
|
|
71
|
+
|
|
72
|
+
if (packageJson.name.startsWith('@graphcommerce/')) {
|
|
73
|
+
log(`Found parent @graphcommerce package at: ${currentDir}`)
|
|
74
|
+
return currentDir
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
currentDir = path.dirname(currentDir)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
log('No parent @graphcommerce package found')
|
|
82
|
+
return null
|
|
8
83
|
}
|
package/src/withGraphCommerce.ts
CHANGED
|
@@ -41,7 +41,7 @@ function domains(config: GraphCommerceConfig): DomainLocale[] {
|
|
|
41
41
|
* module.exports = withGraphCommerce(nextConfig)
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConfig {
|
|
44
|
+
export function withGraphCommerce(nextConfig: NextConfig, cwd: string = process.cwd()): NextConfig {
|
|
45
45
|
graphcommerceConfig ??= loadConfig(cwd)
|
|
46
46
|
const importMetaPaths = configToImportMeta(graphcommerceConfig)
|
|
47
47
|
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runtimeCachingOptimizations = void 0;
|
|
4
|
-
exports.runtimeCachingOptimizations = [
|
|
5
|
-
{
|
|
6
|
-
urlPattern: /\/_next\/image\?url=.+$/i,
|
|
7
|
-
handler: 'StaleWhileRevalidate',
|
|
8
|
-
options: {
|
|
9
|
-
cacheName: 'next-image',
|
|
10
|
-
expiration: {
|
|
11
|
-
maxEntries: 1000, // 1000 images
|
|
12
|
-
maxAgeSeconds: 168 * 60 * 60, // 1 week
|
|
13
|
-
matchOptions: { ignoreVary: true },
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
urlPattern: /\/_next\/data\/.+\/.+\.json$/i,
|
|
19
|
-
handler: 'NetworkFirst',
|
|
20
|
-
options: {
|
|
21
|
-
cacheName: 'next-data',
|
|
22
|
-
expiration: {
|
|
23
|
-
maxEntries: 32,
|
|
24
|
-
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
];
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { RuntimeCaching } from 'workbox-build'
|
|
2
|
-
|
|
3
|
-
export const runtimeCachingOptimizations: RuntimeCaching[] = [
|
|
4
|
-
{
|
|
5
|
-
urlPattern: /\/_next\/image\?url=.+$/i,
|
|
6
|
-
handler: 'StaleWhileRevalidate',
|
|
7
|
-
options: {
|
|
8
|
-
cacheName: 'next-image',
|
|
9
|
-
expiration: {
|
|
10
|
-
maxEntries: 1000, // 1000 images
|
|
11
|
-
maxAgeSeconds: 168 * 60 * 60, // 1 week
|
|
12
|
-
matchOptions: { ignoreVary: true },
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
urlPattern: /\/_next\/data\/.+\/.+\.json$/i,
|
|
18
|
-
handler: 'NetworkFirst',
|
|
19
|
-
options: {
|
|
20
|
-
cacheName: 'next-data',
|
|
21
|
-
expiration: {
|
|
22
|
-
maxEntries: 32,
|
|
23
|
-
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
]
|