@akinon/next 1.89.0-rc.9 → 1.89.0-snapshot-ZERO-3363-20250507092133
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 +10 -1145
- package/bin/pz-prebuild.js +0 -1
- package/components/input.tsx +0 -2
- package/components/link.tsx +12 -16
- package/components/price.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +2 -5
- package/instrumentation/node.ts +13 -15
- package/lib/cache.ts +0 -2
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +1 -2
- package/middlewares/complete-masterpass.ts +1 -2
- package/middlewares/redirection-payment.ts +1 -2
- package/middlewares/saved-card-redirection.ts +1 -2
- package/middlewares/three-d-redirection.ts +1 -2
- package/middlewares/url-redirection.ts +15 -9
- package/package.json +4 -15
- package/redux/middlewares/checkout.ts +1 -10
- package/redux/reducers/checkout.ts +1 -7
- package/types/commerce/order.ts +0 -1
- package/utils/app-fetch.ts +2 -2
- package/utils/index.ts +8 -9
- package/__tests__/next-config.test.ts +0 -83
- package/__tests__/tsconfig.json +0 -23
- package/babel.config.js +0 -6
- package/bin/pz-run-tests.js +0 -99
- package/data/server/basket.ts +0 -72
- package/hooks/use-loyalty-availability.ts +0 -21
- package/jest.config.js +0 -19
- package/utils/redirect-ignore.ts +0 -35
package/bin/pz-prebuild.js
CHANGED
package/components/input.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { forwardRef, FocusEvent, useState, Ref } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
4
|
import { PatternFormat, PatternFormatProps } from 'react-number-format';
|
|
7
5
|
import { InputProps } from '../types';
|
|
8
6
|
import { twMerge } from 'tailwind-merge';
|
package/components/link.tsx
CHANGED
|
@@ -10,9 +10,7 @@ type LinkProps = Omit<
|
|
|
10
10
|
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
11
11
|
keyof NextLinkProps
|
|
12
12
|
> &
|
|
13
|
-
NextLinkProps
|
|
14
|
-
href: string;
|
|
15
|
-
};
|
|
13
|
+
NextLinkProps;
|
|
16
14
|
|
|
17
15
|
export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
18
16
|
const { locale, defaultLocaleValue, localeUrlStrategy } = useLocalization();
|
|
@@ -28,21 +26,19 @@ export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
|
28
26
|
return href;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return hrefWithLocale;
|
|
42
|
-
}
|
|
29
|
+
const pathnameWithoutLocale = href.replace(urlLocaleMatcherRegex, '');
|
|
30
|
+
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
31
|
+
|
|
32
|
+
if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) {
|
|
33
|
+
return hrefWithLocale;
|
|
34
|
+
} else if (
|
|
35
|
+
localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale &&
|
|
36
|
+
locale !== defaultLocaleValue
|
|
37
|
+
) {
|
|
38
|
+
return hrefWithLocale;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
return href;
|
|
41
|
+
return href || '#';
|
|
46
42
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
47
43
|
|
|
48
44
|
return (
|
package/components/price.tsx
CHANGED
|
@@ -55,8 +55,8 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
|
55
55
|
: formattedValue;
|
|
56
56
|
|
|
57
57
|
const currentCurrencyDecimalScale = Settings.localization.currencies.find(
|
|
58
|
-
(currency) => currency
|
|
59
|
-
)
|
|
58
|
+
(currency) => currency.code === currencyCode_
|
|
59
|
+
).decimalScale;
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
62
|
<NumericFormat
|
|
@@ -72,13 +72,10 @@ const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
|
72
72
|
const checkRedisVariables = () => {
|
|
73
73
|
const requiredVariableValues = [
|
|
74
74
|
process.env.CACHE_HOST,
|
|
75
|
-
process.env.CACHE_PORT
|
|
75
|
+
process.env.CACHE_PORT,
|
|
76
|
+
process.env.CACHE_SECRET
|
|
76
77
|
];
|
|
77
78
|
|
|
78
|
-
if (!settings.usePrettyUrlRoute) {
|
|
79
|
-
requiredVariableValues.push(process.env.CACHE_SECRET);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
79
|
if (
|
|
83
80
|
!requiredVariableValues.every((v) => v) &&
|
|
84
81
|
process.env.NODE_ENV === 'production'
|
package/instrumentation/node.ts
CHANGED
|
@@ -4,19 +4,17 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
4
4
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
5
5
|
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
7
|
+
const sdk = new NodeSDK({
|
|
8
|
+
resource: new Resource({
|
|
9
|
+
[SemanticResourceAttributes.SERVICE_NAME]: 'pz-next-app'
|
|
10
|
+
}),
|
|
11
|
+
spanProcessor: new SimpleSpanProcessor(
|
|
12
|
+
new OTLPTraceExporter({
|
|
13
|
+
url: `${
|
|
14
|
+
process.env.PZ_DASHBOARD_URL ?? 'http://localhost:3005'
|
|
15
|
+
}/api/traces`
|
|
16
|
+
})
|
|
17
|
+
)
|
|
18
|
+
});
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
sdk.start();
|
package/lib/cache.ts
CHANGED
|
@@ -31,8 +31,6 @@ export const CacheKey = {
|
|
|
31
31
|
`category_${pk}_${encodeURIComponent(
|
|
32
32
|
JSON.stringify(searchParams)
|
|
33
33
|
)}${hashCacheKey(headers)}`,
|
|
34
|
-
Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
|
|
35
|
-
AllBaskets: () => 'all_baskets',
|
|
36
34
|
CategorySlug: (slug: string) => `category_${slug}`,
|
|
37
35
|
SpecialPage: (
|
|
38
36
|
pk: number,
|
|
@@ -64,7 +64,7 @@ const withCheckoutProvider =
|
|
|
64
64
|
const location = request.headers.get('location');
|
|
65
65
|
const redirectUrl = new URL(
|
|
66
66
|
request.headers.get('location'),
|
|
67
|
-
location.startsWith('http') ? '' :
|
|
67
|
+
location.startsWith('http') ? '' : url.origin
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
redirectUrl.pathname = getUrlPathWithLocale(
|
|
@@ -145,8 +145,7 @@ const withCompleteGpay =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'complete-gpay',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withCompleteMasterpass =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'complete-masterpass',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -146,8 +146,7 @@ const withRedirectionPayment =
|
|
|
146
146
|
logger.info('Redirecting to order success page', {
|
|
147
147
|
middleware: 'redirection-payment',
|
|
148
148
|
redirectUrlWithLocale,
|
|
149
|
-
ip
|
|
150
|
-
setCookie: request.headers.get('set-cookie')
|
|
149
|
+
ip
|
|
151
150
|
});
|
|
152
151
|
|
|
153
152
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withSavedCardRedirection =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'saved-card-redirection',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withThreeDRedirection =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'three-d-redirection',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -4,7 +4,6 @@ import { PzNextRequest } from '.';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
7
|
-
import { shouldIgnoreRedirect } from '../utils/redirect-ignore';
|
|
8
7
|
import { ROUTES } from 'routes';
|
|
9
8
|
|
|
10
9
|
// This middleware is used to handle url redirections set in Omnitron
|
|
@@ -51,7 +50,7 @@ const withUrlRedirection =
|
|
|
51
50
|
const location = request.headers.get('location');
|
|
52
51
|
const redirectUrl = new URL(
|
|
53
52
|
request.headers.get('location'),
|
|
54
|
-
location.startsWith('http') ? '' :
|
|
53
|
+
location.startsWith('http') ? '' : url.origin
|
|
55
54
|
);
|
|
56
55
|
|
|
57
56
|
redirectUrl.pathname = getUrlPathWithLocale(
|
|
@@ -61,13 +60,20 @@ const withUrlRedirection =
|
|
|
61
60
|
|
|
62
61
|
const setCookies = request.headers.getSetCookie();
|
|
63
62
|
|
|
64
|
-
if (
|
|
65
|
-
shouldIgnoreRedirect
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
if (settings.commerceRedirectionIgnoreList) {
|
|
64
|
+
const shouldIgnoreRedirect =
|
|
65
|
+
settings.commerceRedirectionIgnoreList.some((ignorePath) =>
|
|
66
|
+
redirectUrl.pathname.startsWith(
|
|
67
|
+
getUrlPathWithLocale(
|
|
68
|
+
ignorePath,
|
|
69
|
+
req.middlewareParams.rewrites.locale
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (shouldIgnoreRedirect) {
|
|
75
|
+
return middleware(req, event);
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
const response = NextResponse.redirect(redirectUrl.toString(), {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.89.0-
|
|
4
|
+
"version": "1.89.0-snapshot-ZERO-3363-20250507092133",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
"pz-predev": "bin/pz-predev.js",
|
|
14
14
|
"pz-postdev": "bin/pz-postdev.js"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "jest"
|
|
18
|
-
},
|
|
19
16
|
"dependencies": {
|
|
20
17
|
"@opentelemetry/exporter-trace-otlp-http": "0.46.0",
|
|
21
18
|
"@opentelemetry/resources": "1.19.0",
|
|
@@ -23,7 +20,7 @@
|
|
|
23
20
|
"@opentelemetry/sdk-trace-node": "1.19.0",
|
|
24
21
|
"@opentelemetry/semantic-conventions": "1.19.0",
|
|
25
22
|
"@reduxjs/toolkit": "1.9.7",
|
|
26
|
-
"@neshca/cache-handler": "1.
|
|
23
|
+
"@neshca/cache-handler": "1.5.1",
|
|
27
24
|
"@sentry/nextjs": "9.5.0",
|
|
28
25
|
"cross-spawn": "7.0.3",
|
|
29
26
|
"generic-pool": "3.9.0",
|
|
@@ -34,21 +31,13 @@
|
|
|
34
31
|
"set-cookie-parser": "2.6.0"
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
|
-
"@akinon/eslint-plugin-projectzero": "1.89.0-
|
|
38
|
-
"@babel/core": "7.26.10",
|
|
39
|
-
"@babel/preset-env": "7.26.9",
|
|
40
|
-
"@babel/preset-typescript": "7.27.0",
|
|
41
|
-
"@types/jest": "29.5.14",
|
|
34
|
+
"@akinon/eslint-plugin-projectzero": "1.89.0-snapshot-ZERO-3363-20250507092133",
|
|
42
35
|
"@types/react-redux": "7.1.30",
|
|
43
36
|
"@types/set-cookie-parser": "2.4.7",
|
|
44
37
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
45
38
|
"@typescript-eslint/parser": "6.7.4",
|
|
46
|
-
"babel-jest": "29.7.0",
|
|
47
39
|
"eslint": "8.56.0",
|
|
48
40
|
"eslint-config-next": "14.2.3",
|
|
49
|
-
"eslint-config-prettier": "8.5.0"
|
|
50
|
-
"jest": "29.7.0",
|
|
51
|
-
"ts-jest": "29.3.2",
|
|
52
|
-
"typescript": "5.2.2"
|
|
41
|
+
"eslint-config-prettier": "8.5.0"
|
|
53
42
|
}
|
|
54
43
|
}
|
|
@@ -20,8 +20,7 @@ import {
|
|
|
20
20
|
setShippingOptions,
|
|
21
21
|
setHepsipayAvailability,
|
|
22
22
|
setWalletPaymentData,
|
|
23
|
-
setPayOnDeliveryOtpModalActive
|
|
24
|
-
setUnavailablePaymentOptions
|
|
23
|
+
setPayOnDeliveryOtpModalActive
|
|
25
24
|
} from '../../redux/reducers/checkout';
|
|
26
25
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
27
26
|
import { checkoutApi } from '../../data/client/checkout';
|
|
@@ -149,14 +148,6 @@ export const contextListMiddleware: Middleware = ({
|
|
|
149
148
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
150
149
|
}
|
|
151
150
|
|
|
152
|
-
if (context.page_context.unavailable_options) {
|
|
153
|
-
dispatch(
|
|
154
|
-
setUnavailablePaymentOptions(
|
|
155
|
-
context.page_context.unavailable_options
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
151
|
if (context.page_context.credit_payment_options) {
|
|
161
152
|
dispatch(
|
|
162
153
|
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
@@ -40,7 +40,6 @@ export interface CheckoutState {
|
|
|
40
40
|
shippingOptions: ShippingOption[];
|
|
41
41
|
dataSourceShippingOptions: DataSource[];
|
|
42
42
|
paymentOptions: PaymentOption[];
|
|
43
|
-
unavailablePaymentOptions: PaymentOption[];
|
|
44
43
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
45
44
|
selectedCreditPaymentPk: number;
|
|
46
45
|
paymentChoices: PaymentChoice[];
|
|
@@ -95,7 +94,6 @@ const initialState: CheckoutState = {
|
|
|
95
94
|
shippingOptions: [],
|
|
96
95
|
dataSourceShippingOptions: [],
|
|
97
96
|
paymentOptions: [],
|
|
98
|
-
unavailablePaymentOptions: [],
|
|
99
97
|
creditPaymentOptions: [],
|
|
100
98
|
selectedCreditPaymentPk: null,
|
|
101
99
|
paymentChoices: [],
|
|
@@ -159,9 +157,6 @@ const checkoutSlice = createSlice({
|
|
|
159
157
|
setPaymentOptions(state, { payload }) {
|
|
160
158
|
state.paymentOptions = payload;
|
|
161
159
|
},
|
|
162
|
-
setUnavailablePaymentOptions(state, { payload }) {
|
|
163
|
-
state.unavailablePaymentOptions = payload;
|
|
164
|
-
},
|
|
165
160
|
setPaymentChoices(state, { payload }) {
|
|
166
161
|
state.paymentChoices = payload;
|
|
167
162
|
},
|
|
@@ -223,10 +218,9 @@ export const {
|
|
|
223
218
|
setShippingOptions,
|
|
224
219
|
setDataSourceShippingOptions,
|
|
225
220
|
setPaymentOptions,
|
|
226
|
-
setUnavailablePaymentOptions,
|
|
227
|
-
setPaymentChoices,
|
|
228
221
|
setCreditPaymentOptions,
|
|
229
222
|
setSelectedCreditPaymentPk,
|
|
223
|
+
setPaymentChoices,
|
|
230
224
|
setCardType,
|
|
231
225
|
setInstallmentOptions,
|
|
232
226
|
setBankAccounts,
|
package/types/commerce/order.ts
CHANGED
package/utils/app-fetch.ts
CHANGED
|
@@ -43,12 +43,12 @@ const appFetch = async <T>({
|
|
|
43
43
|
const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
|
|
44
44
|
|
|
45
45
|
init.headers = {
|
|
46
|
-
cookie: nextCookies.toString(),
|
|
47
46
|
...(init.headers ?? {}),
|
|
48
47
|
...(ServerVariables.globalHeaders ?? {}),
|
|
49
48
|
'Accept-Language': currentLocale.apiValue,
|
|
50
49
|
'x-currency': currency,
|
|
51
|
-
'x-forwarded-for': ip
|
|
50
|
+
'x-forwarded-for': ip,
|
|
51
|
+
cookie: nextCookies.toString()
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
init.next = {
|
package/utils/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import settings from 'settings';
|
|
2
2
|
import { LocaleUrlStrategy } from '../localization';
|
|
3
|
-
import { CDNOptions, ClientRequestOptions } from '../types';
|
|
3
|
+
import { CDNOptions, ClientRequestOptions, Locale } from '../types';
|
|
4
4
|
|
|
5
5
|
export * from './get-currency';
|
|
6
6
|
export * from './menu-generator';
|
|
@@ -155,15 +155,14 @@ export function buildCDNUrl(url: string, config?: CDNOptions) {
|
|
|
155
155
|
const { locales, localeUrlStrategy, defaultLocaleValue } =
|
|
156
156
|
settings.localization;
|
|
157
157
|
|
|
158
|
+
const isLocaleExcluded = (locale: Locale) =>
|
|
159
|
+
![LocaleUrlStrategy.ShowAllLocales, LocaleUrlStrategy.Subdomain].includes(
|
|
160
|
+
localeUrlStrategy
|
|
161
|
+
) && locale.value !== defaultLocaleValue;
|
|
162
|
+
|
|
158
163
|
export const urlLocaleMatcherRegex = new RegExp(
|
|
159
|
-
`^/(${
|
|
160
|
-
.filter((l) =>
|
|
161
|
-
![LocaleUrlStrategy.ShowAllLocales, LocaleUrlStrategy.Subdomain].includes(
|
|
162
|
-
settings.localization.localeUrlStrategy
|
|
163
|
-
)
|
|
164
|
-
? l.value !== settings.localization.defaultLocaleValue
|
|
165
|
-
: l
|
|
166
|
-
)
|
|
164
|
+
`^/(${locales
|
|
165
|
+
.filter((l) => !isLocaleExcluded(l))
|
|
167
166
|
.map((l) => l.value)
|
|
168
167
|
.join('|')})(?=/|$)`
|
|
169
168
|
);
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import type { NextConfig } from 'next';
|
|
3
|
-
|
|
4
|
-
function findBaseDir() {
|
|
5
|
-
const insideNodeModules = __dirname.includes('node_modules');
|
|
6
|
-
|
|
7
|
-
if (insideNodeModules) {
|
|
8
|
-
return resolve(__dirname, '../../../../');
|
|
9
|
-
} else {
|
|
10
|
-
return resolve(__dirname, '../../../apps/projectzeronext');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const baseDir = findBaseDir();
|
|
15
|
-
|
|
16
|
-
jest.mock('next-pwa', () => {
|
|
17
|
-
return () => (config: NextConfig) => config;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
jest.mock('@sentry/nextjs', () => ({
|
|
21
|
-
withSentryConfig: (config: NextConfig) => config
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
jest.mock('../with-pz-config.js', () => {
|
|
25
|
-
return (config: NextConfig) => {
|
|
26
|
-
const originalHeaders = config.headers;
|
|
27
|
-
|
|
28
|
-
config.headers = async () => {
|
|
29
|
-
const originalHeadersResult = (await originalHeaders?.()) ?? [];
|
|
30
|
-
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
source: '/(.*)',
|
|
34
|
-
headers: [
|
|
35
|
-
{
|
|
36
|
-
key: 'Content-Security-Policy',
|
|
37
|
-
value: 'https://*.akifast.com akifast.com'
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
...originalHeadersResult
|
|
42
|
-
];
|
|
43
|
-
};
|
|
44
|
-
return config;
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
interface Header {
|
|
49
|
-
key: string;
|
|
50
|
-
value: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface HeaderGroup {
|
|
54
|
-
source: string;
|
|
55
|
-
headers: Header[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const nextConfigPath = resolve(baseDir, 'next.config.mjs');
|
|
59
|
-
let nextConfig: any;
|
|
60
|
-
|
|
61
|
-
beforeAll(async () => {
|
|
62
|
-
nextConfig = await import(nextConfigPath);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('Next.js Configuration', () => {
|
|
66
|
-
it('should contain Content-Security-Policy header with akifast domain values', async () => {
|
|
67
|
-
const headers = nextConfig.default.headers;
|
|
68
|
-
expect(headers).toBeDefined();
|
|
69
|
-
|
|
70
|
-
const headersResult = await headers();
|
|
71
|
-
|
|
72
|
-
const cspHeaders = headersResult
|
|
73
|
-
.flatMap((headerGroup: HeaderGroup) => headerGroup.headers)
|
|
74
|
-
.filter((header: Header) => header.key === 'Content-Security-Policy');
|
|
75
|
-
|
|
76
|
-
expect(cspHeaders.length).toBeGreaterThan(0);
|
|
77
|
-
|
|
78
|
-
const lastCspHeader = cspHeaders[cspHeaders.length - 1];
|
|
79
|
-
|
|
80
|
-
expect(lastCspHeader.value).toContain('akifast.com');
|
|
81
|
-
expect(lastCspHeader.value).toContain('https://*.akifast.com');
|
|
82
|
-
});
|
|
83
|
-
});
|
package/__tests__/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "Default",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"composite": false,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
"inlineSources": false,
|
|
11
|
-
"isolatedModules": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"noUnusedLocals": false,
|
|
14
|
-
"noUnusedParameters": false,
|
|
15
|
-
"preserveWatchOutput": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"strict": true,
|
|
18
|
-
"jsx": "react-jsx",
|
|
19
|
-
"allowJs": true
|
|
20
|
-
},
|
|
21
|
-
"exclude": ["node_modules"],
|
|
22
|
-
"include": [".", "../."]
|
|
23
|
-
}
|
package/babel.config.js
DELETED
package/bin/pz-run-tests.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const glob = require('glob');
|
|
7
|
-
const findBaseDir = require('../utils/find-base-dir');
|
|
8
|
-
const checkMonorepo = require('../utils/check-monorepo');
|
|
9
|
-
|
|
10
|
-
const IS_MONOREPO = checkMonorepo() !== null;
|
|
11
|
-
const BASE_DIR = findBaseDir();
|
|
12
|
-
const PLUGINS = require(path.join(BASE_DIR, 'src', 'plugins.js'));
|
|
13
|
-
|
|
14
|
-
function findPluginTestFiles(akinonNextPackagePath) {
|
|
15
|
-
const pluginsRootPath = path.join(
|
|
16
|
-
akinonNextPackagePath,
|
|
17
|
-
'..',
|
|
18
|
-
'..',
|
|
19
|
-
IS_MONOREPO ? 'packages' : '@akinon'
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
if (!fs.existsSync(pluginsRootPath)) {
|
|
23
|
-
console.log('Plugins directory not found:', pluginsRootPath);
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return PLUGINS.reduce((testFiles, pluginName) => {
|
|
28
|
-
const pluginDirectoryPath = path.join(pluginsRootPath, pluginName);
|
|
29
|
-
if (fs.existsSync(pluginDirectoryPath)) {
|
|
30
|
-
const pluginTestFiles = glob.sync('**/*.test.ts', {
|
|
31
|
-
cwd: pluginDirectoryPath,
|
|
32
|
-
absolute: true
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return testFiles.concat(pluginTestFiles);
|
|
36
|
-
} else {
|
|
37
|
-
console.log(`Plugin directory not found: ${pluginName}`);
|
|
38
|
-
}
|
|
39
|
-
return testFiles;
|
|
40
|
-
}, []);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function isJestInstalled() {
|
|
44
|
-
try {
|
|
45
|
-
const jestExecutablePath = path.join(
|
|
46
|
-
BASE_DIR,
|
|
47
|
-
'node_modules',
|
|
48
|
-
'.bin',
|
|
49
|
-
'jest'
|
|
50
|
-
);
|
|
51
|
-
return fs.existsSync(jestExecutablePath);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getAkinonNextPackagePath() {
|
|
58
|
-
if (!IS_MONOREPO) {
|
|
59
|
-
return path.resolve(__dirname, '..');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return path.resolve(__dirname, '../../../packages/akinon-next');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!isJestInstalled()) {
|
|
66
|
-
console.error('\x1b[31mError: Jest is not installed in the project!\x1b[0m');
|
|
67
|
-
console.error(
|
|
68
|
-
'Please install all dependencies by running one of the following commands:'
|
|
69
|
-
);
|
|
70
|
-
console.error(' npm install');
|
|
71
|
-
console.error(' yarn install');
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const jestExecutablePath = path.join(BASE_DIR, 'node_modules', '.bin', 'jest');
|
|
76
|
-
const akinonNextPackagePath = getAkinonNextPackagePath();
|
|
77
|
-
|
|
78
|
-
const testFiles = [
|
|
79
|
-
...glob.sync('__tests__/**/*.test.ts', {
|
|
80
|
-
cwd: akinonNextPackagePath,
|
|
81
|
-
absolute: true
|
|
82
|
-
}),
|
|
83
|
-
...findPluginTestFiles(akinonNextPackagePath)
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
console.log(`Found ${testFiles.length} test files to run`);
|
|
87
|
-
|
|
88
|
-
const jestArguments = [
|
|
89
|
-
...testFiles,
|
|
90
|
-
`--config ${path.join(akinonNextPackagePath, 'jest.config.js')}`,
|
|
91
|
-
'--runTestsByPath',
|
|
92
|
-
'--passWithNoTests'
|
|
93
|
-
];
|
|
94
|
-
|
|
95
|
-
spawn(jestExecutablePath, jestArguments, {
|
|
96
|
-
cwd: akinonNextPackagePath,
|
|
97
|
-
stdio: 'inherit',
|
|
98
|
-
shell: true
|
|
99
|
-
});
|