@graphcommerce/next-config 9.0.0-canary.99 → 9.0.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 (69) hide show
  1. package/CHANGELOG.md +219 -1151
  2. package/__tests__/commands/copyFiles.ts +512 -0
  3. package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +6 -0
  4. package/__tests__/config/utils/mergeEnvIntoConfig.ts +9 -20
  5. package/__tests__/config/utils/rewriteLegancyEnv.ts +32 -36
  6. package/__tests__/interceptors/findPlugins.ts +76 -78
  7. package/__tests__/interceptors/generateInterceptors.ts +78 -135
  8. package/__tests__/interceptors/parseStructure.ts +2 -2
  9. package/__tests__/utils/resolveDependenciesSync.ts +11 -10
  10. package/dist/commands/codegen.js +18 -0
  11. package/dist/commands/copyFiles.js +292 -0
  12. package/dist/commands/copyRoutes.js +20 -0
  13. package/dist/config/commands/exportConfig.js +1 -1
  14. package/dist/config/commands/generateConfig.js +2 -2
  15. package/dist/config/demoConfig.js +2 -2
  16. package/dist/config/utils/mergeEnvIntoConfig.js +18 -20
  17. package/dist/config/utils/rewriteLegacyEnv.js +2 -2
  18. package/dist/generated/config.js +13 -1
  19. package/dist/index.js +3 -1
  20. package/dist/interceptors/InterceptorPlugin.js +4 -3
  21. package/dist/interceptors/Visitor.js +5 -9
  22. package/dist/interceptors/commands/codegenInterceptors.js +2 -2
  23. package/dist/interceptors/extractExports.js +9 -54
  24. package/dist/interceptors/findOriginalSource.js +2 -1
  25. package/dist/interceptors/findPlugins.js +5 -8
  26. package/dist/interceptors/generateInterceptor.js +12 -10
  27. package/dist/interceptors/generateInterceptors.js +3 -2
  28. package/dist/interceptors/parseStructure.js +1 -1
  29. package/dist/interceptors/writeInterceptors.js +2 -2
  30. package/dist/utils/TopologicalSort.js +4 -0
  31. package/dist/utils/isMonorepo.js +40 -6
  32. package/dist/utils/resolveDependenciesSync.js +9 -2
  33. package/dist/utils/sig.js +34 -0
  34. package/dist/withGraphCommerce.js +3 -2
  35. package/package.json +17 -16
  36. package/src/commands/codegen.ts +18 -0
  37. package/src/commands/copyFiles.ts +328 -0
  38. package/src/config/commands/exportConfig.ts +1 -1
  39. package/src/config/commands/generateConfig.ts +3 -3
  40. package/src/config/demoConfig.ts +5 -5
  41. package/src/config/index.ts +1 -1
  42. package/src/config/utils/exportConfigToEnv.ts +1 -1
  43. package/src/config/utils/mergeEnvIntoConfig.ts +22 -25
  44. package/src/config/utils/replaceConfigInString.ts +1 -1
  45. package/src/config/utils/rewriteLegacyEnv.ts +5 -4
  46. package/src/generated/config.ts +36 -0
  47. package/src/index.ts +6 -5
  48. package/src/interceptors/InterceptorPlugin.ts +10 -7
  49. package/src/interceptors/RenameVisitor.ts +1 -1
  50. package/src/interceptors/Visitor.ts +10 -15
  51. package/src/interceptors/commands/codegenInterceptors.ts +2 -2
  52. package/src/interceptors/extractExports.ts +4 -46
  53. package/src/interceptors/findOriginalSource.ts +5 -4
  54. package/src/interceptors/findPlugins.ts +8 -9
  55. package/src/interceptors/generateInterceptor.ts +15 -12
  56. package/src/interceptors/generateInterceptors.ts +7 -13
  57. package/src/interceptors/parseStructure.ts +4 -4
  58. package/src/interceptors/swc.ts +2 -1
  59. package/src/interceptors/writeInterceptors.ts +3 -3
  60. package/src/utils/TopologicalSort.ts +4 -0
  61. package/src/utils/isMonorepo.ts +46 -5
  62. package/src/utils/packageRoots.ts +1 -1
  63. package/src/utils/resolveDependenciesSync.ts +14 -2
  64. package/src/utils/sig.ts +37 -0
  65. package/src/withGraphCommerce.ts +7 -5
  66. package/dist/config/commands/generateIntercetors.js +0 -9
  67. package/dist/interceptors/commands/generateIntercetors.js +0 -9
  68. package/dist/runtimeCachingOptimizations.js +0 -28
  69. package/src/runtimeCachingOptimizations.ts +0 -27
@@ -0,0 +1,37 @@
1
+ // import necessary modules
2
+ import crypto from 'crypto'
3
+
4
+ declare global {
5
+ // eslint-disable-next-line vars-on-top, no-var
6
+ var gcl: string[] | undefined
7
+ }
8
+
9
+ // Function to generate a license key based on input data
10
+ export function g(data: string[]) {
11
+ const iv = crypto.randomBytes(16) // Initialization vector
12
+ const cipher = crypto.createCipheriv('aes-256-cbc', 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN', iv)
13
+ let encrypted = cipher.update(JSON.stringify(data), 'utf-8', 'hex')
14
+ encrypted += cipher.final('hex')
15
+ // Return the IV and the encrypted data as a single string, encoded in base64
16
+ return Buffer.from(`${iv.toString('hex')}:${encrypted}`).toString()
17
+ }
18
+
19
+ // Function to validate and decode the license key
20
+ export function sig() {
21
+ const l = process.env[atob('R0NfTElDRU5TRQ==')]
22
+ if (!l) return
23
+
24
+ if (!globalThis.gcl)
25
+ try {
26
+ const decipher = crypto.createDecipheriv(
27
+ 'aes-256-cbc',
28
+ 'BbcFEkUydGw3nE9ZPm7gbxTIIBQ9IiKN',
29
+ Buffer.from(l.split(':')[0], 'hex'),
30
+ )
31
+ let decrypted = decipher.update(l.split(':')[1], 'hex', 'utf-8')
32
+ decrypted += decipher.final('utf-8')
33
+ globalThis.gcl = JSON.parse(decrypted) // Parse and return the decoded data
34
+ } catch (error) {
35
+ // Silent
36
+ }
37
+ }
@@ -1,11 +1,12 @@
1
1
  // import CircularDependencyPlugin from 'circular-dependency-plugin'
2
2
  import { DuplicatesPlugin } from 'inspectpack/plugin'
3
3
  import type { NextConfig } from 'next'
4
- import { DomainLocale } from 'next/dist/server/config'
5
- import { DefinePlugin, Configuration } from 'webpack'
4
+ import type { DomainLocale } from 'next/dist/server/config'
5
+ import type { Configuration } from 'webpack'
6
+ import { DefinePlugin } from 'webpack'
6
7
  import { loadConfig } from './config/loadConfig'
7
8
  import { configToImportMeta } from './config/utils/configToImportMeta'
8
- import { GraphCommerceConfig } from './generated/config'
9
+ import type { GraphCommerceConfig } from './generated/config'
9
10
  import { InterceptorPlugin } from './interceptors/InterceptorPlugin'
10
11
  import { resolveDependenciesSync } from './utils/resolveDependenciesSync'
11
12
 
@@ -40,7 +41,7 @@ function domains(config: GraphCommerceConfig): DomainLocale[] {
40
41
  * module.exports = withGraphCommerce(nextConfig)
41
42
  * ```
42
43
  */
43
- export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConfig {
44
+ export function withGraphCommerce(nextConfig: NextConfig, cwd: string = process.cwd()): NextConfig {
44
45
  graphcommerceConfig ??= loadConfig(cwd)
45
46
  const importMetaPaths = configToImportMeta(graphcommerceConfig)
46
47
 
@@ -53,10 +54,10 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
53
54
 
54
55
  return {
55
56
  ...nextConfig,
57
+ bundlePagesRouterDependencies: true,
56
58
  experimental: {
57
59
  ...nextConfig.experimental,
58
60
  scrollRestoration: true,
59
- bundlePagesExternals: true,
60
61
  swcPlugins: [...(nextConfig.experimental?.swcPlugins ?? []), ['@lingui/swc-plugin', {}]],
61
62
  },
62
63
  i18n: {
@@ -71,6 +72,7 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
71
72
  remotePatterns: [
72
73
  { hostname: new URL(graphcommerceConfig.magentoEndpoint).hostname },
73
74
  { hostname: 'media.graphassets.com' },
75
+ { hostname: '*.graphcommerce.org' },
74
76
  ...(nextConfig.images?.remotePatterns ?? []),
75
77
  ],
76
78
  },
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportConfig = void 0;
4
- const loadConfig_1 = require("../loadConfig");
5
- // eslint-disable-next-line @typescript-eslint/require-await
6
- async function exportConfig() {
7
- const conf = (0, loadConfig_1.loadConfig)(process.cwd());
8
- }
9
- exports.exportConfig = exportConfig;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportConfig = void 0;
4
- const loadConfig_1 = require("../../config/loadConfig");
5
- // eslint-disable-next-line @typescript-eslint/require-await
6
- async function exportConfig() {
7
- const conf = (0, loadConfig_1.loadConfig)(process.cwd());
8
- }
9
- exports.exportConfig = exportConfig;
@@ -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
- ]