@akinon/next 2.0.10-rc.0 → 2.0.10

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.
@@ -14,17 +14,9 @@ export const installmentOptionMiddleware: Middleware = ({
14
14
  return result;
15
15
  }
16
16
 
17
- const { installmentOptions, cardType } = getState().checkout;
17
+ const { installmentOptions } = getState().checkout;
18
18
  const { endpoints: apiEndpoints } = checkoutApi;
19
19
 
20
- const isCreditCardPayment =
21
- preOrder?.payment_option?.payment_type === 'credit_card' ||
22
- preOrder?.payment_option?.payment_type === 'masterpass';
23
-
24
- if (isCreditCardPayment && !cardType) {
25
- return result;
26
- }
27
-
28
20
  if (
29
21
  !preOrder?.installment &&
30
22
  preOrder?.payment_option?.payment_type !== 'saved_card' &&
package/types/index.ts CHANGED
@@ -85,12 +85,6 @@ export interface Settings {
85
85
  };
86
86
  usePrettyUrlRoute?: boolean;
87
87
  commerceUrl: string;
88
- /**
89
- * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
90
- *
91
- * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
92
- */
93
- sentryDsn?: string;
94
88
  redis: {
95
89
  defaultExpirationTime: number;
96
90
  };
@@ -223,7 +217,6 @@ export interface Settings {
223
217
  separator?: string;
224
218
  segments: PzSegmentDefinition[];
225
219
  };
226
- payloadOptimization?: import('../utils/payload-optimizer').PayloadOptimizationConfig;
227
220
  }
228
221
 
229
222
  export interface CacheOptions {
package/with-pz-config.js CHANGED
@@ -69,8 +69,7 @@ const defaultConfig = {
69
69
  acc[`@akinon/${plugin}`] = false;
70
70
  return acc;
71
71
  }, {}),
72
- translations: false,
73
- '@opentelemetry/exporter-jaeger': false
72
+ translations: false
74
73
  };
75
74
  // Ensure webpack can resolve deps from the app's node_modules when
76
75
  // compiling transpiled packages (e.g. @akinon/next) whose imports
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require('path');
4
- const { migrate } = require(path.join(__dirname, '..', 'codemods', 'migrate-eslint-flat'));
5
-
6
- migrate(process.argv[2]);
@@ -1,247 +0,0 @@
1
- /**
2
- * ESLint flat config migration codemod.
3
- *
4
- * Converts a brand project from legacy `.eslintrc.js` to ESLint v9 flat config
5
- * (`eslint.config.mjs`), consuming the shared base from
6
- * `@akinon/next/eslint.config.base.mjs`.
7
- *
8
- * Idempotent: re-running on an already migrated project is a no-op for
9
- * already-applied steps.
10
- *
11
- * Steps:
12
- * 1. Read .eslintrc.js (if present) to detect brand-specific settings
13
- * (settings.next.rootDir, custom rules).
14
- * 2. Read .eslintignore (if present) to collect ignore patterns.
15
- * 3. Write eslint.config.mjs (skipped if already exists).
16
- * 4. Delete .eslintrc.js and .eslintignore.
17
- * 5. Rewrite .lintstagedrc.js to use `eslint --fix` instead of `next lint`.
18
- * 6. Patch package.json:
19
- * - scripts.lint: "next lint" -> "eslint ."
20
- * - eslint: ^8.x -> ^9.39.4
21
- * - eslint-config-prettier: ^8.x -> ^10.1.1
22
- * - remove @typescript-eslint/eslint-plugin and @typescript-eslint/parser
23
- * (now provided by eslint-config-next/typescript).
24
- */
25
-
26
- 'use strict';
27
-
28
- const fs = require('fs');
29
- const path = require('path');
30
-
31
- const ESLINT_TARGET = '9.39.4';
32
- const ESLINT_CONFIG_PRETTIER_TARGET = '10.1.1';
33
- const TYPESCRIPT_ESLINT_DROP = [
34
- '@typescript-eslint/eslint-plugin',
35
- '@typescript-eslint/parser'
36
- ];
37
-
38
- function buildFlatConfig({ rootDir, ignores, customRules }) {
39
- const lines = [
40
- "import { defineConfig, globalIgnores } from 'eslint/config';",
41
- "import baseConfig from '@akinon/next/eslint.config.base.mjs';",
42
- '',
43
- 'export default defineConfig([',
44
- ' ...baseConfig'
45
- ];
46
-
47
- if (rootDir) {
48
- lines[lines.length - 1] += ',';
49
- lines.push(
50
- ' {',
51
- ' settings: {',
52
- ' next: {',
53
- ` rootDir: ${JSON.stringify(rootDir)}`,
54
- ' }',
55
- ' }',
56
- ' }'
57
- );
58
- }
59
-
60
- if (customRules) {
61
- lines[lines.length - 1] += ',';
62
- const indented = JSON.stringify(customRules, null, 2)
63
- .split('\n')
64
- .map((l, i) => (i === 0 ? ' rules: ' + l : ' ' + l))
65
- .join('\n');
66
- lines.push(' {', indented, ' }');
67
- }
68
-
69
- if (ignores && ignores.length) {
70
- lines[lines.length - 1] += ',';
71
- lines.push(` globalIgnores(${JSON.stringify(ignores)})`);
72
- }
73
-
74
- lines.push(']);', '');
75
-
76
- return lines.join('\n');
77
- }
78
-
79
- const LINT_STAGED_TEMPLATE = `const path = require('path');
80
-
81
- const buildEslintCommand = (filenames) =>
82
- \`eslint --fix \${filenames
83
- .map((f) => \`"\${path.relative(process.cwd(), f)}"\`)
84
- .join(' ')}\`;
85
-
86
- module.exports = {
87
- '**/*.(ts|tsx)': () => 'yarn tsc --noEmit',
88
- '*.{js,jsx,ts,tsx}': [buildEslintCommand, 'prettier --write'],
89
- '*.{css,scss}': [
90
- 'stylelint --fix --allow-empty-input',
91
- 'prettier --write',
92
- 'stylelint --allow-empty-input'
93
- ]
94
- };
95
- `;
96
-
97
- function loadLegacyConfig(eslintrcPath) {
98
- try {
99
- delete require.cache[require.resolve(eslintrcPath)];
100
- return require(eslintrcPath);
101
- } catch (err) {
102
- return { __parseError: err.message };
103
- }
104
- }
105
-
106
- function readIgnoreFile(eslintignorePath) {
107
- if (!fs.existsSync(eslintignorePath)) return [];
108
- const raw = fs.readFileSync(eslintignorePath, 'utf8');
109
- return raw
110
- .split(/\r?\n/)
111
- .map((line) => line.trim())
112
- .filter((line) => line && !line.startsWith('#'))
113
- .map((pattern) => (pattern.endsWith('/**') ? pattern : pattern + '/**'));
114
- }
115
-
116
- function patchPackageJson(pkgPath) {
117
- const raw = fs.readFileSync(pkgPath, 'utf8');
118
- const pkg = JSON.parse(raw);
119
- const changes = [];
120
-
121
- if (pkg.scripts && typeof pkg.scripts.lint === 'string') {
122
- if (/^next\s+lint\b/.test(pkg.scripts.lint.trim())) {
123
- pkg.scripts.lint = 'eslint .';
124
- changes.push('scripts.lint -> "eslint ."');
125
- }
126
- }
127
-
128
- const bumpDev = (name, target) => {
129
- if (!pkg.devDependencies || !pkg.devDependencies[name]) return;
130
- const current = pkg.devDependencies[name].replace(/^\^|^~/, '');
131
- if (current === target) return;
132
- pkg.devDependencies[name] = target;
133
- changes.push(`devDependencies.${name} ${current} -> ${target}`);
134
- };
135
-
136
- bumpDev('eslint', ESLINT_TARGET);
137
- bumpDev('eslint-config-prettier', ESLINT_CONFIG_PRETTIER_TARGET);
138
-
139
- for (const dep of TYPESCRIPT_ESLINT_DROP) {
140
- if (pkg.devDependencies && pkg.devDependencies[dep]) {
141
- delete pkg.devDependencies[dep];
142
- changes.push(`removed devDependencies.${dep}`);
143
- }
144
- }
145
-
146
- if (changes.length === 0) return { changed: false, changes };
147
-
148
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
149
- return { changed: true, changes };
150
- }
151
-
152
- function migrate(projectRoot) {
153
- const root = path.resolve(projectRoot || process.cwd());
154
- const eslintrcPath = path.join(root, '.eslintrc.js');
155
- const eslintignorePath = path.join(root, '.eslintignore');
156
- const flatConfigPath = path.join(root, 'eslint.config.mjs');
157
- const lintStagedPath = path.join(root, '.lintstagedrc.js');
158
- const packageJsonPath = path.join(root, 'package.json');
159
-
160
- if (!fs.existsSync(packageJsonPath)) {
161
- console.error(`[migrate-eslint-flat] No package.json found in ${root}`);
162
- process.exit(1);
163
- }
164
-
165
- console.log(`[migrate-eslint-flat] Project root: ${root}`);
166
- const summary = [];
167
-
168
- const legacyConfig = fs.existsSync(eslintrcPath)
169
- ? loadLegacyConfig(eslintrcPath)
170
- : null;
171
-
172
- if (legacyConfig && legacyConfig.__parseError) {
173
- console.warn(
174
- `[migrate-eslint-flat] Could not parse .eslintrc.js: ${legacyConfig.__parseError}`
175
- );
176
- console.warn('Continuing with default brand-template settings.');
177
- }
178
-
179
- const rootDir = legacyConfig?.settings?.next?.rootDir;
180
- const customRules =
181
- legacyConfig && legacyConfig.rules && Object.keys(legacyConfig.rules).length
182
- ? legacyConfig.rules
183
- : null;
184
-
185
- let ignores = readIgnoreFile(eslintignorePath);
186
- if (ignores.length === 0) ignores = ['public/**'];
187
-
188
- if (!fs.existsSync(flatConfigPath)) {
189
- fs.writeFileSync(
190
- flatConfigPath,
191
- buildFlatConfig({ rootDir, ignores, customRules }),
192
- 'utf8'
193
- );
194
- summary.push('created eslint.config.mjs');
195
- } else {
196
- summary.push('eslint.config.mjs already exists (skipped)');
197
- }
198
-
199
- if (fs.existsSync(eslintrcPath)) {
200
- fs.unlinkSync(eslintrcPath);
201
- summary.push('removed .eslintrc.js');
202
- }
203
-
204
- if (fs.existsSync(eslintignorePath)) {
205
- fs.unlinkSync(eslintignorePath);
206
- summary.push('removed .eslintignore');
207
- }
208
-
209
- if (fs.existsSync(lintStagedPath)) {
210
- const before = fs.readFileSync(lintStagedPath, 'utf8');
211
- if (before !== LINT_STAGED_TEMPLATE) {
212
- fs.writeFileSync(lintStagedPath, LINT_STAGED_TEMPLATE, 'utf8');
213
- summary.push('rewrote .lintstagedrc.js');
214
- } else {
215
- summary.push('.lintstagedrc.js already up to date (skipped)');
216
- }
217
- }
218
-
219
- const pkgResult = patchPackageJson(packageJsonPath);
220
- if (pkgResult.changed) {
221
- summary.push(`patched package.json (${pkgResult.changes.join(', ')})`);
222
- } else {
223
- summary.push('package.json already up to date (skipped)');
224
- }
225
-
226
- console.log('\nESLint flat config migration summary:');
227
- for (const line of summary) console.log(` - ${line}`);
228
-
229
- if (customRules) {
230
- console.log(
231
- `\nNote: ${Object.keys(customRules).length} custom rule(s) from the old ` +
232
- '.eslintrc.js were carried over into eslint.config.mjs.\nReview if ' +
233
- 'they are still needed (some may already be covered by the base config).'
234
- );
235
- }
236
-
237
- console.log('\nNext steps:');
238
- console.log(' 1. yarn install');
239
- console.log(' 2. yarn lint # expect 0 errors (warnings ok)');
240
- console.log(' 3. yarn build # smoke test');
241
- }
242
-
243
- if (require.main === module) {
244
- migrate(process.argv[2]);
245
- }
246
-
247
- module.exports = { migrate };