@akinon/projectzero 2.0.0-beta.1 → 2.0.0-beta.11

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 (107) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/app-template/.env.example +5 -0
  3. package/app-template/.gitignore +2 -0
  4. package/app-template/CHANGELOG.md +251 -0
  5. package/app-template/README.md +6 -0
  6. package/app-template/config/prebuild-tests.json +5 -0
  7. package/app-template/docs/plugins.md +60 -25
  8. package/app-template/jest.config.ts +2 -2
  9. package/app-template/{next.config.mjs → next.config.ts} +6 -3
  10. package/app-template/package.json +30 -27
  11. package/app-template/postcss.config.mjs +8 -0
  12. package/app-template/public/locales/en/account.json +4 -0
  13. package/app-template/public/locales/en/common.json +10 -0
  14. package/app-template/public/locales/tr/account.json +4 -0
  15. package/app-template/public/locales/tr/common.json +10 -0
  16. package/app-template/src/__tests__/middleware-matcher.test.ts +135 -0
  17. package/app-template/src/app/[commerce]/[locale]/[currency]/account/orders/[id]/cancellation/page.tsx +99 -7
  18. package/app-template/src/app/[commerce]/[locale]/[currency]/account/orders/[id]/page.tsx +112 -47
  19. package/app-template/src/app/[commerce]/[locale]/[currency]/account/page.tsx +1 -1
  20. package/app-template/src/app/[commerce]/[locale]/[currency]/address/stores/page.tsx +2 -2
  21. package/app-template/src/app/[commerce]/[locale]/[currency]/auth/page.tsx +1 -1
  22. package/app-template/src/app/[commerce]/[locale]/[currency]/basket/page.tsx +2 -2
  23. package/app-template/src/app/[commerce]/[locale]/[currency]/error.tsx +12 -15
  24. package/app-template/src/app/[commerce]/[locale]/[currency]/forms/[pk]/generate/page.tsx +1 -1
  25. package/app-template/src/app/[commerce]/[locale]/[currency]/{pz-not-found/page.tsx → not-found.tsx} +2 -2
  26. package/app-template/src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx +7 -4
  27. package/app-template/src/app/[commerce]/[locale]/[currency]/xml-sitemap/[node]/route.ts +47 -1
  28. package/app-template/src/assets/globals.scss +162 -34
  29. package/app-template/src/components/__tests__/badge.test.tsx +2 -2
  30. package/app-template/src/components/accordion.tsx +1 -1
  31. package/app-template/src/components/button.tsx +50 -35
  32. package/app-template/src/components/checkbox.tsx +1 -0
  33. package/app-template/src/components/file-input.tsx +44 -2
  34. package/app-template/src/components/input.tsx +3 -3
  35. package/app-template/src/components/modal.tsx +1 -1
  36. package/app-template/src/components/select.tsx +2 -2
  37. package/app-template/src/components/shimmer.tsx +1 -1
  38. package/app-template/src/components/tabs.tsx +2 -2
  39. package/app-template/src/components/types/index.ts +4 -1
  40. package/app-template/src/middleware.ts +1 -0
  41. package/app-template/src/plugins.js +2 -1
  42. package/app-template/src/redux/middlewares/category.ts +1 -1
  43. package/app-template/src/redux/reducers/category.ts +1 -1
  44. package/app-template/src/redux/store.ts +4 -3
  45. package/app-template/src/utils/convert-facet-search-params.ts +1 -1
  46. package/app-template/src/views/account/contact-form.tsx +3 -8
  47. package/app-template/src/views/account/content-header.tsx +2 -3
  48. package/app-template/src/views/account/order.tsx +11 -9
  49. package/app-template/src/views/account/orders/order-cancellation-item.tsx +5 -4
  50. package/app-template/src/views/anonymous-tracking/order-detail/index.tsx +45 -38
  51. package/app-template/src/views/basket/basket-item.tsx +1 -0
  52. package/app-template/src/views/category/category-active-filters.tsx +1 -1
  53. package/app-template/src/views/category/category-header.tsx +12 -6
  54. package/app-template/src/views/category/category-info.tsx +4 -4
  55. package/app-template/src/views/category/filters/index.tsx +2 -2
  56. package/app-template/src/views/checkout/auth.tsx +1 -1
  57. package/app-template/src/views/checkout/layout/header.tsx +1 -1
  58. package/app-template/src/views/checkout/steps/payment/index.tsx +1 -1
  59. package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +1 -1
  60. package/app-template/src/views/checkout/steps/payment/options/redirection.tsx +5 -1
  61. package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +4 -4
  62. package/app-template/src/views/checkout/steps/shipping/address-box.tsx +3 -3
  63. package/app-template/src/views/checkout/steps/shipping/addresses.tsx +1 -1
  64. package/app-template/src/views/checkout/summary.tsx +2 -2
  65. package/app-template/src/views/header/action-menu.tsx +11 -4
  66. package/app-template/src/views/header/band.tsx +2 -2
  67. package/app-template/src/views/header/mini-basket.tsx +15 -4
  68. package/app-template/src/views/header/mobile-menu.tsx +6 -6
  69. package/app-template/src/views/header/navbar.tsx +1 -1
  70. package/app-template/src/views/header/pwa-back-button.tsx +1 -1
  71. package/app-template/src/views/header/search/index.tsx +16 -4
  72. package/app-template/src/views/header/search/results.tsx +1 -1
  73. package/app-template/src/views/header/user-menu.tsx +3 -1
  74. package/app-template/src/views/installment-options/index.tsx +1 -1
  75. package/app-template/src/views/login/index.tsx +30 -6
  76. package/app-template/src/views/otp-login/index.tsx +12 -14
  77. package/app-template/src/views/product/price-wrapper.tsx +7 -2
  78. package/app-template/src/views/product/product-info.tsx +35 -5
  79. package/app-template/src/views/product/slider.tsx +1 -1
  80. package/app-template/src/views/product-pointer-banner-item.tsx +1 -1
  81. package/app-template/src/views/register/index.tsx +29 -4
  82. package/app-template/src/views/sales-contract-modal/index.tsx +17 -17
  83. package/app-template/src/widgets/footer-info.tsx +1 -1
  84. package/app-template/src/widgets/footer-menu.tsx +1 -1
  85. package/app-template/src/widgets/footer-subscription/index.tsx +1 -1
  86. package/app-template/src/widgets/home-stories-eng.tsx +1 -1
  87. package/app-template/tailwind.config.js +2 -134
  88. package/codemods/sentry-9/index.js +30 -0
  89. package/codemods/sentry-9/remove-sentry-configs.js +14 -0
  90. package/codemods/sentry-9/remove-sentry-dependency.js +25 -0
  91. package/codemods/sentry-9/replace-error-page.js +32 -0
  92. package/codemods/update-tailwind-config/index.js +30 -0
  93. package/codemods/update-tailwind-config/transform.js +102 -0
  94. package/commands/codemod.ts +17 -0
  95. package/commands/index.ts +3 -1
  96. package/commands/plugins.ts +24 -30
  97. package/dist/codemods/sentry-9/templates/error.js +14 -0
  98. package/dist/commands/codemod.js +15 -0
  99. package/dist/commands/index.js +3 -1
  100. package/dist/commands/plugins.js +23 -20
  101. package/package.json +3 -2
  102. package/app-template/postcss.config.js +0 -6
  103. package/app-template/sentry.client.config.ts +0 -16
  104. package/app-template/sentry.edge.config.ts +0 -3
  105. package/app-template/sentry.properties +0 -4
  106. package/app-template/sentry.server.config.ts +0 -3
  107. package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/loading.tsx +0 -67
@@ -169,19 +169,19 @@ export const SalesContractModal = ({ data }: Props) => {
169
169
  </div>
170
170
  </div>
171
171
 
172
- <table className="w-full border">
172
+ <table className="w-full border border-gray-200">
173
173
  <thead className="text-sm">
174
174
  <tr>
175
- <th className="border font-normal text-left py-2 px-3">
175
+ <th className="border border-gray-200 font-normal text-left py-2 px-3">
176
176
  {t('account.sales_contract.product')}
177
177
  </th>
178
- <th className="border font-normal py-2 px-3">
178
+ <th className="border border-gray-200 font-normal py-2 px-3">
179
179
  {t('account.sales_contract.quantity')}
180
180
  </th>
181
- <th className="border font-normal text-left py-2 px-3">
181
+ <th className="border border-gray-200 font-normal text-left py-2 px-3">
182
182
  {t('account.sales_contract.product_price')}
183
183
  </th>
184
- <th className="border font-normal text-left py-2 px-3">
184
+ <th className="border border-gray-200 font-normal text-left py-2 px-3">
185
185
  {t('account.sales_contract.total_price')}
186
186
  </th>
187
187
  </tr>
@@ -191,20 +191,20 @@ export const SalesContractModal = ({ data }: Props) => {
191
191
  {data.orderitem_set.map((value, index) => {
192
192
  return (
193
193
  <tr key={index.toString()}>
194
- <td className="border font-light text-left py-2 px-3">
194
+ <td className="border border-gray-200 font-light text-left py-2 px-3">
195
195
  {value.product.name}
196
196
  </td>
197
- <td className="border font-light text-center py-2 px-3">
197
+ <td className="border border-gray-200 font-light text-center py-2 px-3">
198
198
  {value.quantity ? value.quantity : '1'}
199
199
  </td>
200
- <td className="border font-light text-center py-2 px-3">
200
+ <td className="border border-gray-200 font-light text-center py-2 px-3">
201
201
  <Price
202
202
  value={
203
203
  value.unit_price ? value.unit_price : value.price
204
204
  }
205
205
  />
206
206
  </td>
207
- <td className="border font-light text-right py-2 px-3">
207
+ <td className="border border-gray-200 font-light text-right py-2 px-3">
208
208
  <Price
209
209
  value={
210
210
  value.total_amount
@@ -222,12 +222,12 @@ export const SalesContractModal = ({ data }: Props) => {
222
222
  <tr>
223
223
  <th
224
224
  colSpan={3}
225
- className="border text-left py-2 px-3 font-normal"
225
+ className="border border-gray-200 text-left py-2 px-3 font-normal"
226
226
  >
227
227
  {t('account.sales_contract.products_total')}
228
228
  </th>
229
229
  <td
230
- className="border text-right py-2 px-3 font-light"
230
+ className="border border-gray-200 text-right py-2 px-3 font-light"
231
231
  colSpan={1}
232
232
  >
233
233
  <Price value={data.discount_amount} />
@@ -237,12 +237,12 @@ export const SalesContractModal = ({ data }: Props) => {
237
237
  <tr>
238
238
  <th
239
239
  colSpan={3}
240
- className="border text-left py-2 px-3 font-normal"
240
+ className="border border-gray-200 text-left py-2 px-3 font-normal"
241
241
  >
242
242
  {t('account.sales_contract.shipping_price')}
243
243
  </th>
244
244
  <td
245
- className="border text-right py-2 px-3 font-light"
245
+ className="border border-gray-200 text-right py-2 px-3 font-light"
246
246
  colSpan={1}
247
247
  >
248
248
  <Price value={data.shipping_amount} />
@@ -252,12 +252,12 @@ export const SalesContractModal = ({ data }: Props) => {
252
252
  <tr>
253
253
  <th
254
254
  colSpan={3}
255
- className="border text-left py-2 px-3 font-normal"
255
+ className="border border-gray-200 text-left py-2 px-3 font-normal"
256
256
  >
257
257
  {t('account.sales_contract.payment_type')}
258
258
  </th>
259
259
  <td
260
- className="border text-right py-2 px-3 font-light"
260
+ className="border border-gray-200 text-right py-2 px-3 font-light"
261
261
  colSpan={1}
262
262
  >
263
263
  {data.payment_option_slug}
@@ -267,12 +267,12 @@ export const SalesContractModal = ({ data }: Props) => {
267
267
  <tr>
268
268
  <th
269
269
  colSpan={3}
270
- className="border text-left py-2 px-3 font-normal"
270
+ className="border border-gray-200 text-left py-2 px-3 font-normal"
271
271
  >
272
272
  {t('account.sales_contract.order_total')}
273
273
  </th>
274
274
  <td
275
- className="border text-right py-2 px-3 font-light"
275
+ className="border border-gray-200 text-right py-2 px-3 font-light"
276
276
  colSpan={1}
277
277
  >
278
278
  <Price value={data.amount} />
@@ -19,7 +19,7 @@ export default async function FooterInfo() {
19
19
  const data = await getWidgetData<FooterInfoType>({ slug: 'footer-info' });
20
20
 
21
21
  return (
22
- <div className="flex flex-col w-full mb-4 pb-4 text-xs border-b md:border-b-0 md:pb-0 md:mb-0 md:w-3/12 lg:w-1/6 md:pr-7">
22
+ <div className="flex flex-col w-full mb-4 pb-4 text-xs border-b border-gray-200 md:border-b-0 md:pb-0 md:mb-0 md:w-3/12 lg:w-1/6 md:pr-7">
23
23
  <div className="flex items-center mb-8">
24
24
  <div className="mr-3">
25
25
  <svg
@@ -50,7 +50,7 @@ export default async function FooterMenu() {
50
50
 
51
51
  return (
52
52
  <div className="flex-1">
53
- <div className="hidden justify-between text-xs md:flex md:px-6 md:py-4 md:border-r md:border-l">
53
+ <div className="hidden justify-between text-xs md:flex md:px-6 md:py-4 md:border-r md:border-l md:border-gray-200">
54
54
  <div>
55
55
  <div className="mb-4 font-medium" data-testid="footer-categories">
56
56
  {data?.attributes?.first_column_title?.value}
@@ -19,7 +19,7 @@ export default async function FooterSubscription() {
19
19
  });
20
20
 
21
21
  return (
22
- <div className="py-4 border-t md:border-t-0 lg:pl-7">
22
+ <div className="py-4 border-t border-gray-200 md:border-t-0 lg:pl-7">
23
23
  <h3 className="mb-1 text-xs font-medium">
24
24
  {data?.attributes?.title?.value}
25
25
  </h3>
@@ -82,7 +82,7 @@ export default async function HomeStoriesEng() {
82
82
  {data?.attributes?.stories?.map((story, index) => {
83
83
  return (
84
84
  <div
85
- className="mr-4 flex-shrink-0 first:ms-4 w-32 md:w-32"
85
+ className="mr-4 shrink-0 first:ms-4 w-32 md:w-32"
86
86
  key={`story__${index}`}
87
87
  >
88
88
  <Link href={story?.value?.url} aria-label={story?.value?.alt}>
@@ -1,5 +1,5 @@
1
+ const getAkinonNextContent = require('@akinon/next/tailwind/content');
1
2
  const deepMerge = require('@akinon/next/utils/deep-merge');
2
- const defaultTheme = require('tailwindcss/defaultTheme');
3
3
  const plugins = require('./src/plugins');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
@@ -26,140 +26,8 @@ const defaultConfig = {
26
26
  './src/widgets/**/*.{js,ts,jsx,tsx}',
27
27
  './src/hooks/**/*.{js,ts,jsx,tsx}',
28
28
  './src/utils/**/*.{js,ts,jsx,tsx}',
29
- ...plugins
30
- .map((plugin) => [
31
- `./node_modules/@akinon/${plugin}/**/*.{js,ts,jsx,tsx}`,
32
- `../../node_modules/@akinon/${plugin}/**/*.{js,ts,jsx,tsx}`
33
- ])
34
- .flat()
29
+ ...getAkinonNextContent(plugins)
35
30
  ],
36
- theme: {
37
- extend: {
38
- fontSize: {
39
- '2xs': '0.5rem'
40
- },
41
- outline: {
42
- off: 'none'
43
- },
44
- width: {
45
- '1/10': '10%',
46
- '2/10': '20%',
47
- '3/10': '30%',
48
- '4/10': '40%',
49
- '5/10': '50%',
50
- '6/10': '60%',
51
- '7/10': '70%',
52
- '8/10': '80%',
53
- '9/10': '90%'
54
- },
55
- transitionProperty: {
56
- 'max-width': 'max-width'
57
- },
58
- backgroundImage: {
59
- 'skeleton-shimmer':
60
- 'linear-gradient(90deg, #d7d7d7 0%, #ebebeb 40%, #eeeeee 60%, #d7d7d7)'
61
- },
62
- keyframes: {
63
- 'skeleton-shimmer': {
64
- '100%': {
65
- transform: 'translateX(100%)'
66
- }
67
- }
68
- },
69
- animation: {
70
- 'skeleton-shimmer': 'skeleton-shimmer 2s linear infinite'
71
- }
72
- },
73
- colors: {
74
- transparent: 'transparent',
75
- white: '#ffffff',
76
- primary: {
77
- DEFAULT: '#000000',
78
- hover: '#181818',
79
- foreground: '#ffffff',
80
- 100: '#525252',
81
- 200: '#404040',
82
- 300: '#3d3d3d',
83
- 400: '#333333',
84
- 500: '#2d2d2d',
85
- 600: '#292929',
86
- 700: '#2b2b2b',
87
- 800: '#181818',
88
- 900: '#000000'
89
- },
90
- secondary: {
91
- DEFAULT: '#e95151',
92
- hover: '#d03838',
93
- foreground: '#ffffff',
94
- 100: '#ffb7b7',
95
- 200: '#ff9e9e',
96
- 300: '#ff8484',
97
- 400: '#ff6b6b',
98
- 500: '#e95151',
99
- 600: '#d72b01',
100
- 700: '#b61e1e',
101
- 800: '#9d0505',
102
- 900: '#830000'
103
- },
104
- black: {
105
- DEFAULT: '#000000',
106
- 100: '#525252',
107
- 200: '#404040',
108
- 300: '#3d3d3d',
109
- 400: '#333333',
110
- 500: '#2d2d2d',
111
- 600: '#292929',
112
- 700: '#2b2b2b',
113
- 800: '#181818',
114
- 900: '#000000'
115
- },
116
- gray: {
117
- DEFAULT: '#ebebeb',
118
- 25: '#fdfdfd',
119
- 50: '#f7f7f7',
120
- 100: '#f5f5f5',
121
- 150: '#f4f4f4',
122
- 200: '#eeeeee',
123
- 300: '#ebebeb',
124
- 400: '#d7d7d7',
125
- 450: '#d4d4d4',
126
- 500: '#c9c9c9',
127
- 600: '#9d9d9d',
128
- 700: '#686868',
129
- 800: '#615f62',
130
- 850: '#58585a',
131
- 900: '#4a4f54',
132
- 950: '#424242'
133
- },
134
- error: {
135
- DEFAULT: '#d72b01',
136
- 100: '#e20008'
137
- },
138
- success: {
139
- DEFAULT: '#7b9d76',
140
- 100: '#7b9d76'
141
- }
142
- },
143
- container: {
144
- center: true,
145
- padding: {
146
- DEFAULT: '0rem',
147
- sm: '2rem',
148
- '2xl': '0rem'
149
- }
150
- },
151
- fontFamily: {
152
- sans: ['Jost'].concat(defaultTheme.fontFamily.sans)
153
- },
154
- screens: {
155
- xs: '575px',
156
- sm: '640px',
157
- md: '768px',
158
- lg: '1024px',
159
- xl: '1170px',
160
- '2xl': '1370px'
161
- }
162
- },
163
31
  plugins: [require('@tailwindcss/typography')]
164
32
  };
165
33
 
@@ -0,0 +1,30 @@
1
+ const path = require('path');
2
+ const { execSync } = require('child_process');
3
+
4
+ const codemodScripts = [
5
+ path.resolve(__dirname, 'remove-sentry-dependency.js'),
6
+ path.resolve(__dirname, 'remove-sentry-configs.js'),
7
+ path.resolve(__dirname, 'replace-error-page.js')
8
+ ];
9
+
10
+ const transform = () => {
11
+ const workingDir = path.resolve(process.cwd());
12
+
13
+ codemodScripts.forEach((script) => {
14
+ try {
15
+ execSync(
16
+ `jscodeshift --ignore-pattern="**/node_modules/**" -t ${script} ${workingDir} --extensions=json,ts,tsx,js,jsx,properties,md`,
17
+ {
18
+ cwd: workingDir,
19
+ stdio: 'inherit'
20
+ }
21
+ );
22
+ } catch (e) {
23
+ console.error(e);
24
+ }
25
+ });
26
+ };
27
+
28
+ module.exports = {
29
+ transform
30
+ };
@@ -0,0 +1,14 @@
1
+ const fs = require('fs');
2
+
3
+ const transform = (fileInfo, api, options) => {
4
+ const filePath = fileInfo.path;
5
+ const regex = /sentry\.\w+\.config\.(ts|js)$|sentry\.properties$/i;
6
+
7
+ if (regex.test(filePath) && fs.existsSync(filePath)) {
8
+ fs.unlinkSync(filePath);
9
+ }
10
+
11
+ return fileInfo.source;
12
+ };
13
+
14
+ module.exports = transform;
@@ -0,0 +1,25 @@
1
+ const transform = (fileInfo, api, options) => {
2
+ if (fileInfo.path.endsWith('package.json')) {
3
+ const packageJson = JSON.parse(fileInfo.source);
4
+
5
+ if (
6
+ packageJson.dependencies &&
7
+ packageJson.dependencies['@sentry/nextjs']
8
+ ) {
9
+ delete packageJson.dependencies['@sentry/nextjs'];
10
+ }
11
+
12
+ if (
13
+ packageJson.devDependencies &&
14
+ packageJson.devDependencies['@sentry/nextjs']
15
+ ) {
16
+ delete packageJson.devDependencies['@sentry/nextjs'];
17
+ }
18
+
19
+ return JSON.stringify(packageJson, null, 2);
20
+ }
21
+
22
+ return fileInfo.source;
23
+ };
24
+
25
+ module.exports = transform;
@@ -0,0 +1,32 @@
1
+ const fs = require('fs');
2
+
3
+ const template = `
4
+ 'use client';
5
+
6
+ import { useSentryUncaughtErrors } from '@akinon/next/hooks';
7
+ import PzErrorPage from '@akinon/next/views/error-page';
8
+
9
+ export default function ErrorPage({
10
+ error,
11
+ reset
12
+ }: {
13
+ error: Error & { digest?: string; isServerError?: boolean };
14
+ reset: () => void;
15
+ }) {
16
+ // DO NOT REMOVE THIS LINE TO REPORT UNCAUGHT ERRORS TO SENTRY
17
+ useSentryUncaughtErrors(error);
18
+
19
+ return <PzErrorPage error={error} reset={reset} />;
20
+ }
21
+
22
+ `;
23
+
24
+ const transform = (fileInfo, api, options) => {
25
+ const filePath = fileInfo.path;
26
+
27
+ if (filePath.endsWith('error.tsx')) {
28
+ fs.writeFileSync(filePath, template, { encoding: 'utf8' });
29
+ }
30
+ };
31
+
32
+ module.exports = transform;
@@ -0,0 +1,30 @@
1
+ const path = require('path');
2
+ const jscodeshift = require('jscodeshift/src/Runner');
3
+
4
+ const codemodScript = path.resolve(__dirname, 'transform.js');
5
+
6
+ const transform = () => {
7
+ const workingDir = path.resolve(process.cwd());
8
+
9
+ jscodeshift
10
+ .run(codemodScript, [workingDir], {
11
+ verbose: 0,
12
+ dry: false,
13
+ print: false,
14
+ extensions: 'js',
15
+ ignorePattern: '**/node_modules/**',
16
+ filter: '**/tailwind.config.js'
17
+ })
18
+ .then(
19
+ (stats) => {
20
+ console.log(`Codemod completed. Stats:`, stats);
21
+ },
22
+ (error) => {
23
+ console.error(`Error executing codemod: ${error.message}`);
24
+ }
25
+ );
26
+ };
27
+
28
+ module.exports = {
29
+ transform
30
+ };
@@ -0,0 +1,102 @@
1
+ function transform(fileInfo, api) {
2
+ const j = api.jscodeshift;
3
+ const root = j(fileInfo.source);
4
+
5
+ if (!fileInfo.path.includes('tailwind.config.js')) {
6
+ return fileInfo.source;
7
+ }
8
+
9
+ console.log(`Processing file: ${fileInfo.path}`);
10
+
11
+ const hasAkinonNextImport = root.find(j.VariableDeclarator, {
12
+ id: { name: 'getAkinonNextContent' }
13
+ });
14
+
15
+ if (hasAkinonNextImport.size() === 0) {
16
+ const requireStatement = j.variableDeclaration('const', [
17
+ j.variableDeclarator(
18
+ j.identifier('getAkinonNextContent'),
19
+ j.callExpression(j.identifier('require'), [
20
+ j.literal('@akinon/next/tailwind/content')
21
+ ])
22
+ )
23
+ ]);
24
+
25
+ root.get().node.program.body.unshift(requireStatement);
26
+
27
+ console.log(`Added getAkinonNextContent import to ${fileInfo.path}`);
28
+ }
29
+
30
+ const defaultConfig = root
31
+ .find(j.VariableDeclarator, {
32
+ id: { name: 'defaultConfig' },
33
+ init: { type: 'ObjectExpression' }
34
+ })
35
+ .paths()[0];
36
+
37
+ if (!defaultConfig) {
38
+ console.log(`No defaultConfig found in ${fileInfo.path}`);
39
+ return fileInfo.source;
40
+ }
41
+
42
+ const contentArray = defaultConfig.value.init.properties.find(
43
+ (prop) =>
44
+ prop.key.name === 'content' && prop.value.type === 'ArrayExpression'
45
+ );
46
+
47
+ if (!contentArray) {
48
+ console.log(`No content array found in defaultConfig`);
49
+ return fileInfo.source;
50
+ }
51
+
52
+ const pluginsVarName = root
53
+ .find(j.VariableDeclarator, {
54
+ id: { name: 'plugins' },
55
+ init: {
56
+ type: 'CallExpression',
57
+ callee: { name: 'require' }
58
+ }
59
+ })
60
+ .paths()[0]?.value.id.name;
61
+
62
+ if (!pluginsVarName) {
63
+ console.log(`No plugins variable found in ${fileInfo.path}`);
64
+ return fileInfo.source;
65
+ }
66
+
67
+ const contentElements = contentArray.value.elements;
68
+
69
+ const filteredElements = contentElements.filter((element) => {
70
+ if (element.type === 'SpreadElement') {
71
+ if (
72
+ element.argument.type === 'CallExpression' &&
73
+ element.argument.callee.object?.callee.object.name === 'plugins'
74
+ ) {
75
+ return false;
76
+ }
77
+
78
+ if (
79
+ element.argument.type === 'CallExpression' &&
80
+ element.argument.callee.name === 'getAkinonNextContent'
81
+ ) {
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ });
87
+
88
+ filteredElements.push(
89
+ j.spreadElement(
90
+ j.callExpression(j.identifier('getAkinonNextContent'), [
91
+ j.identifier(pluginsVarName)
92
+ ])
93
+ )
94
+ );
95
+
96
+ contentArray.value.elements = filteredElements;
97
+
98
+ console.log(`Successfully updated ${fileInfo.path}`);
99
+ return root.toSource();
100
+ }
101
+
102
+ module.exports = transform;
@@ -0,0 +1,17 @@
1
+ import path from 'path';
2
+
3
+ const yargs = require('yargs/yargs');
4
+ const { hideBin } = require('yargs/helpers');
5
+ const args = yargs(hideBin(process.argv)).argv;
6
+
7
+ export default () => {
8
+ const codemodName = args.codemod;
9
+ const codemodPath = path.resolve(
10
+ __dirname,
11
+ `../../codemods/${codemodName}/index.js`
12
+ );
13
+
14
+ const codemod = require(codemodPath);
15
+
16
+ codemod.transform();
17
+ };
package/commands/index.ts CHANGED
@@ -4,6 +4,7 @@ import addLanguage from './add-language';
4
4
  import removeLanguage from './remove-language';
5
5
  import defaultLanguage from './default-language';
6
6
  import plugins from './plugins';
7
+ import codemod from './codemod';
7
8
 
8
9
  export default {
9
10
  commerceUrl,
@@ -11,5 +12,6 @@ export default {
11
12
  addLanguage,
12
13
  removeLanguage,
13
14
  defaultLanguage,
14
- plugins
15
+ plugins,
16
+ codemod
15
17
  };
@@ -2,8 +2,7 @@ import * as fs from 'fs';
2
2
  import path from 'path';
3
3
  import { execSync } from 'child_process';
4
4
  import semver from 'semver';
5
-
6
- const Prompt = require('prompt-checkbox');
5
+ import { checkbox } from '@inquirer/prompts';
7
6
 
8
7
  const rootDir = path.resolve(process.cwd());
9
8
 
@@ -113,39 +112,32 @@ export default async () => {
113
112
  {
114
113
  name: 'Tabby Payment Extension',
115
114
  value: 'pz-tabby-extension'
115
+ },
116
+ {
117
+ name: 'Tamara Payment Extension',
118
+ value: 'pz-tamara-extension'
116
119
  }
117
120
  ];
118
121
 
119
- const prompt = new Prompt({
120
- name: 'plugins',
121
- message: 'Please check/uncheck plugins to install/uninstall.',
122
- type: 'checkbox',
123
- default: installedPlugins.map((p) =>
124
- definedPlugins.findIndex((dp) => dp.value === p)
125
- ),
126
- choices: definedPlugins.map((p, index) => `${index + 1}) ${p.name}`)
127
- });
128
-
129
- prompt.ask(async (answers: Array<string>) => {
130
- const formattedAnswers = answers.map((answer) =>
131
- answer.replace(/\d\)\s/, '')
132
- );
133
-
134
- const values = formattedAnswers.map(
135
- (answer) => definedPlugins.find((p) => p.name === answer)?.value
136
- );
137
-
138
- if (formattedAnswers.length) {
139
- console.log(`\nInstalling ${formattedAnswers.join(', ')}.`);
140
- } else {
141
- console.log(`\nUninstalling all plugins.`);
122
+ try {
123
+ const answers = await checkbox({
124
+ message: 'Please check/uncheck plugins to install/uninstall.',
125
+ choices: definedPlugins.map((plugin) => ({
126
+ name: plugin.name,
127
+ value: plugin.value,
128
+ checked: installedPlugins.includes(plugin.value)
129
+ }))
130
+ });
131
+
132
+ if (!answers.length) {
133
+ console.log('\x1b[33m%s\x1b[0m', `\nUninstalling all plugins.`);
142
134
  }
143
135
 
144
- console.log(`\nPlease wait...`);
136
+ console.log('\x1b[36m%s\x1b[0m', `\nPlease wait...`);
145
137
 
146
138
  fs.writeFileSync(
147
139
  pluginsFilePath,
148
- `module.exports = ${JSON.stringify(values)};\n`,
140
+ `module.exports = ${JSON.stringify(answers)};\n`,
149
141
  {
150
142
  encoding: 'utf-8'
151
143
  }
@@ -155,11 +147,13 @@ export default async () => {
155
147
 
156
148
  console.log(
157
149
  '\x1b[32m%s\x1b[0m',
158
- `\n ✓ ${
159
- formattedAnswers.length
150
+ `\n✓ ${
151
+ answers.length
160
152
  ? 'Installed selected plugins'
161
153
  : 'Uninstalled all plugins'
162
154
  }.\n`
163
155
  );
164
- });
156
+ } catch (error) {
157
+ process.exit(1);
158
+ }
165
159
  };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const hooks_1 = require("@akinon/next/hooks");
8
+ const error_page_1 = __importDefault(require("@akinon/next/views/error-page"));
9
+ function ErrorPage({ error, reset }) {
10
+ // DO NOT REMOVE THIS LINE TO REPORT UNCAUGHT ERRORS TO SENTRY
11
+ (0, hooks_1.useSentryUncaughtErrors)(error);
12
+ return React.createElement(error_page_1.default, { error: error, reset: reset });
13
+ }
14
+ exports.default = ErrorPage;