@akinon/projectzero 1.126.17-v1-rc.14 → 1.126.17

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 CHANGED
@@ -1,10 +1,14 @@
1
1
  # @akinon/projectzero
2
2
 
3
- ## 1.126.17-v1-rc.14
3
+ ## 1.126.17
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - a34bb1b: ZERO-5168: Post the attribute-based shipping selection to the page name Commerce reports
7
+ - 0fe8ab7: ZERO-5209: Close the theme editor's package and CLI gaps on the v1 line
8
+
9
+ - `@akinon/pz-list-hover-image` is published on the v1 line, registered in the plugin list and in `PluginModule` (`Component.ListHoverImage`), and offered by `projectzero --plugins`. Until now `pz-install-plugins` asked for `@akinon/pz-list-hover-image@<@akinon/next version>`, which never existed for 1.x, so the plugin could not be installed on a v1 project.
10
+ - `projectzero codemod --codemod=composable-auth` is available on the v1 CLI. It moves the login page into an `auth/(login)` route group and mounts the theme editor's login slot there. It leaves a project without `@akinon/pz-theme` (or with one older than 2.0.41) untouched instead of writing a layout that cannot build.
11
+ - `@akinon/pz-theme` and `@akinon/theme-contract` are transpiled by `withPzConfig`, and `pz-postinstall` no longer removes `@akinon/pz-theme` when it is missing from `src/plugins.js`, as on main. Brands that added both packages to `transpilePackages` by hand can drop that override. Keep `'pz-theme'` in `src/plugins.js` unless `tailwind.config.js` lists pz-theme's sources itself: that entry is also what puts them in Tailwind's `content`.
8
12
 
9
13
  ## 1.126.16
10
14
 
@@ -1,40 +1,36 @@
1
1
  # projectzeronext
2
2
 
3
- ## 1.126.17-v1-rc.14
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [560e209]
8
- - Updated dependencies [d4809417]
9
- - Updated dependencies [a34bb1b]
10
- - Updated dependencies [560e209]
11
- - Updated dependencies [182a639b]
12
- - @akinon/pz-tamara-extension@1.126.17-v1-rc.14
13
- - @akinon/pz-masterpass-rest@1.126.17-v1-rc.14
14
- - @akinon/next@1.126.17-v1-rc.14
15
- - @akinon/pz-virtual-try-on@1.126.17-v1-rc.14
16
- - @akinon/pz-akifast@1.126.17-v1-rc.14
17
- - @akinon/pz-apple-pay@1.126.17-v1-rc.14
18
- - @akinon/pz-b2b@1.126.17-v1-rc.14
19
- - @akinon/pz-basket-gift-pack@1.126.17-v1-rc.14
20
- - @akinon/pz-bkm@1.126.17-v1-rc.14
21
- - @akinon/pz-checkout-gift-pack@1.126.17-v1-rc.14
22
- - @akinon/pz-click-collect@1.126.17-v1-rc.14
23
- - @akinon/pz-credit-payment@1.126.17-v1-rc.14
24
- - @akinon/pz-cybersource-uc@1.126.17-v1-rc.14
25
- - @akinon/pz-flow-payment@1.126.17-v1-rc.14
26
- - @akinon/pz-google-pay@1.126.17-v1-rc.14
27
- - @akinon/pz-gpay@1.126.17-v1-rc.14
28
- - @akinon/pz-haso@1.126.17-v1-rc.14
29
- - @akinon/pz-hepsipay@1.126.17-v1-rc.14
30
- - @akinon/pz-masterpass@1.126.17-v1-rc.14
31
- - @akinon/pz-multi-basket@1.126.17-v1-rc.14
32
- - @akinon/pz-one-click-checkout@1.126.17-v1-rc.14
33
- - @akinon/pz-otp@1.126.17-v1-rc.14
34
- - @akinon/pz-pay-on-delivery@1.126.17-v1-rc.14
35
- - @akinon/pz-saved-card@1.126.17-v1-rc.14
36
- - @akinon/pz-similar-products@1.126.17-v1-rc.14
37
- - @akinon/pz-tabby-extension@1.126.17-v1-rc.14
3
+ ## 1.126.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0fe8ab7]
8
+ - @akinon/next@1.126.17
9
+ - @akinon/pz-virtual-try-on@1.126.17
10
+ - @akinon/pz-akifast@1.126.17
11
+ - @akinon/pz-apple-pay@1.126.17
12
+ - @akinon/pz-b2b@1.126.17
13
+ - @akinon/pz-basket-gift-pack@1.126.17
14
+ - @akinon/pz-bkm@1.126.17
15
+ - @akinon/pz-checkout-gift-pack@1.126.17
16
+ - @akinon/pz-click-collect@1.126.17
17
+ - @akinon/pz-credit-payment@1.126.17
18
+ - @akinon/pz-cybersource-uc@1.126.17
19
+ - @akinon/pz-flow-payment@1.126.17
20
+ - @akinon/pz-google-pay@1.126.17
21
+ - @akinon/pz-gpay@1.126.17
22
+ - @akinon/pz-haso@1.126.17
23
+ - @akinon/pz-hepsipay@1.126.17
24
+ - @akinon/pz-masterpass@1.126.17
25
+ - @akinon/pz-masterpass-rest@1.126.17
26
+ - @akinon/pz-multi-basket@1.126.17
27
+ - @akinon/pz-one-click-checkout@1.126.17
28
+ - @akinon/pz-otp@1.126.17
29
+ - @akinon/pz-pay-on-delivery@1.126.17
30
+ - @akinon/pz-saved-card@1.126.17
31
+ - @akinon/pz-similar-products@1.126.17
32
+ - @akinon/pz-tabby-extension@1.126.17
33
+ - @akinon/pz-tamara-extension@1.126.17
38
34
 
39
35
  ## 1.126.16
40
36
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "1.126.17-v1-rc.14",
3
+ "version": "1.126.17",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -24,32 +24,32 @@
24
24
  "test:middleware": "jest middleware-matcher.test.ts --bail"
25
25
  },
26
26
  "dependencies": {
27
- "@akinon/next": "1.126.17-v1-rc.14",
28
- "@akinon/pz-akifast": "1.126.17-v1-rc.14",
29
- "@akinon/pz-apple-pay": "1.126.17-v1-rc.14",
30
- "@akinon/pz-b2b": "1.126.17-v1-rc.14",
31
- "@akinon/pz-basket-gift-pack": "1.126.17-v1-rc.14",
32
- "@akinon/pz-bkm": "1.126.17-v1-rc.14",
33
- "@akinon/pz-checkout-gift-pack": "1.126.17-v1-rc.14",
34
- "@akinon/pz-click-collect": "1.126.17-v1-rc.14",
35
- "@akinon/pz-credit-payment": "1.126.17-v1-rc.14",
36
- "@akinon/pz-cybersource-uc": "1.126.17-v1-rc.14",
37
- "@akinon/pz-flow-payment": "1.126.17-v1-rc.14",
38
- "@akinon/pz-google-pay": "1.126.17-v1-rc.14",
39
- "@akinon/pz-gpay": "1.126.17-v1-rc.14",
40
- "@akinon/pz-haso": "1.126.17-v1-rc.14",
41
- "@akinon/pz-hepsipay": "1.126.17-v1-rc.14",
42
- "@akinon/pz-masterpass": "1.126.17-v1-rc.14",
43
- "@akinon/pz-masterpass-rest": "1.126.17-v1-rc.14",
44
- "@akinon/pz-multi-basket": "1.126.17-v1-rc.14",
45
- "@akinon/pz-one-click-checkout": "1.126.17-v1-rc.14",
46
- "@akinon/pz-otp": "1.126.17-v1-rc.14",
47
- "@akinon/pz-pay-on-delivery": "1.126.17-v1-rc.14",
48
- "@akinon/pz-saved-card": "1.126.17-v1-rc.14",
49
- "@akinon/pz-similar-products": "1.126.17-v1-rc.14",
50
- "@akinon/pz-tabby-extension": "1.126.17-v1-rc.14",
51
- "@akinon/pz-tamara-extension": "1.126.17-v1-rc.14",
52
- "@akinon/pz-virtual-try-on": "1.126.17-v1-rc.14",
27
+ "@akinon/next": "1.126.17",
28
+ "@akinon/pz-akifast": "1.126.17",
29
+ "@akinon/pz-apple-pay": "1.126.17",
30
+ "@akinon/pz-b2b": "1.126.17",
31
+ "@akinon/pz-basket-gift-pack": "1.126.17",
32
+ "@akinon/pz-bkm": "1.126.17",
33
+ "@akinon/pz-checkout-gift-pack": "1.126.17",
34
+ "@akinon/pz-click-collect": "1.126.17",
35
+ "@akinon/pz-credit-payment": "1.126.17",
36
+ "@akinon/pz-cybersource-uc": "1.126.17",
37
+ "@akinon/pz-flow-payment": "1.126.17",
38
+ "@akinon/pz-google-pay": "1.126.17",
39
+ "@akinon/pz-gpay": "1.126.17",
40
+ "@akinon/pz-haso": "1.126.17",
41
+ "@akinon/pz-hepsipay": "1.126.17",
42
+ "@akinon/pz-masterpass": "1.126.17",
43
+ "@akinon/pz-masterpass-rest": "1.126.17",
44
+ "@akinon/pz-multi-basket": "1.126.17",
45
+ "@akinon/pz-one-click-checkout": "1.126.17",
46
+ "@akinon/pz-otp": "1.126.17",
47
+ "@akinon/pz-pay-on-delivery": "1.126.17",
48
+ "@akinon/pz-saved-card": "1.126.17",
49
+ "@akinon/pz-similar-products": "1.126.17",
50
+ "@akinon/pz-tabby-extension": "1.126.17",
51
+ "@akinon/pz-tamara-extension": "1.126.17",
52
+ "@akinon/pz-virtual-try-on": "1.126.17",
53
53
  "@hookform/resolvers": "2.9.0",
54
54
  "@next/third-parties": "14.1.0",
55
55
  "@react-google-maps/api": "2.17.1",
@@ -72,7 +72,7 @@
72
72
  "yup": "0.32.11"
73
73
  },
74
74
  "devDependencies": {
75
- "@akinon/eslint-plugin-projectzero": "1.126.17-v1-rc.14",
75
+ "@akinon/eslint-plugin-projectzero": "1.126.17",
76
76
  "@semantic-release/changelog": "6.0.2",
77
77
  "@semantic-release/exec": "6.0.3",
78
78
  "@semantic-release/git": "10.0.1",
@@ -0,0 +1,292 @@
1
+ /**
2
+ * composable-auth
3
+ *
4
+ * Opens the brand's login screen to the theme editor without adding a route.
5
+ *
6
+ * What it does, per `auth` route directory found under src/app:
7
+ * 1. moves `auth/page.tsx` into `auth/(login)/page.tsx` (a route group — the
8
+ * URL does not change);
9
+ * 2. writes `auth/(login)/layout.tsx`, which mounts the login body slot with
10
+ * the page itself as the fallback.
11
+ *
12
+ * Why the route group: the slot has to sit in a layout, because a ChromeSlot is
13
+ * an async server component and the login page is a client one. A layout at
14
+ * `auth/layout.tsx` would also wrap `auth/oauth-login`, the OAuth callback —
15
+ * whose whole job is a `signIn()` effect and which renders no markup at all, so
16
+ * a login composition placed over it would break social sign-in with nothing on
17
+ * screen to notice. The group scopes the mount to the login screen alone.
18
+ *
19
+ * Login and register stay on this one screen; whether they read as tabs or as
20
+ * two forms side by side is composed in the editor (starter templates ship both
21
+ * shapes), so no `/auth/register` route is created here.
22
+ *
23
+ * A brand that already owns an `auth/layout.tsx` is triaged rather than refused
24
+ * wholesale. Nested layouts compose, so when that layout simply wraps
25
+ * `children` the group layout goes underneath it and the brand's frame keeps
26
+ * rendering around the composition. Two shapes cannot be handled and are
27
+ * reported instead of touched: a layout that imports `./page` itself (moving the
28
+ * page would break the import) and a layout that never renders `children` (the
29
+ * nested slot would never render). Both mean the "layout" is really the page.
30
+ *
31
+ * The layout it writes is a pz-theme component, and a project does not always
32
+ * have pz-theme: the v1 app template ships without it. Such a project is left
33
+ * untouched, because the written layout would break its build on the import.
34
+ *
35
+ * Usage:
36
+ * node codemods/composable-auth/index.js [--dry-run]
37
+ * npx @akinon/projectzero codemod --codemod=composable-auth [--dry-run]
38
+ */
39
+
40
+ const path = require('path');
41
+ const fs = require('fs');
42
+
43
+ const GROUP_DIR = '(login)';
44
+
45
+ // The first @akinon/pz-theme with every API the layout below uses:
46
+ // `PLACEHOLDER_SLUGS.auth` arrived in 2.0.38, ChromeSlot's
47
+ // `fallbackClassName` in 2.0.41.
48
+ const MIN_PZ_THEME_VERSION = '2.0.41';
49
+
50
+ const LAYOUT_SOURCE = `import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
51
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
52
+
53
+ /**
54
+ * The login screen is handed to the theme editor here rather than in page.tsx,
55
+ * because the slot is an async server component and the page is a client one.
56
+ * With no composition published the slot renders the page untouched.
57
+ *
58
+ * The slot lives in a \`(login)\` route group so the composition covers exactly
59
+ * this screen: \`auth/oauth-login\` is a provider callback, and a login body
60
+ * mounted one level up would replace it too.
61
+ *
62
+ * No \`pageContext\`: an auth screen fetches no commerce data, and the blocks a
63
+ * designer rebuilds it from (\`auth-form\`, \`register-form\`, \`oauth-buttons\`)
64
+ * read the session client-side.
65
+ */
66
+ export default function LoginLayout({
67
+ children
68
+ }: {
69
+ children: React.ReactNode;
70
+ }) {
71
+ return (
72
+ // \`contents\` on both wrappers keeps the slot chain layout-transparent, so
73
+ // an uncomposed login page keeps its own box model even where a brand's
74
+ // <main> is a flex or grid container.
75
+ <ChromeSlot
76
+ slug={PLACEHOLDER_SLUGS.auth}
77
+ fallback={children}
78
+ className="contents"
79
+ fallbackClassName="contents"
80
+ />
81
+ );
82
+ }
83
+ `;
84
+
85
+ function log(msg) {
86
+ const ts = new Date().toISOString().replace('T', ' ').slice(0, 19);
87
+ console.log(`[${ts}] ${msg}`);
88
+ }
89
+
90
+ /**
91
+ * Every directory named `auth` that holds a login page, anywhere under src/app.
92
+ * An already-migrated brand keeps its page inside the group, so both spellings
93
+ * count — otherwise a second run would report "nothing to do" and a brand whose
94
+ * layout went missing could never be repaired.
95
+ */
96
+ function findAuthPageDirs(appRoot) {
97
+ const found = [];
98
+
99
+ const visit = (dir) => {
100
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
101
+ if (!entry.isDirectory()) continue;
102
+
103
+ const entryPath = path.join(dir, entry.name);
104
+
105
+ if (
106
+ entry.name === 'auth' &&
107
+ (fs.existsSync(path.join(entryPath, 'page.tsx')) ||
108
+ fs.existsSync(path.join(entryPath, GROUP_DIR, 'page.tsx')))
109
+ ) {
110
+ found.push(entryPath);
111
+ }
112
+
113
+ visit(entryPath);
114
+ }
115
+ };
116
+
117
+ visit(appRoot);
118
+
119
+ return found;
120
+ }
121
+
122
+ function readJson(filePath) {
123
+ try {
124
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
125
+ } catch (error) {
126
+ return null;
127
+ }
128
+ }
129
+
130
+ function isOlderVersion(version, minimum) {
131
+ const parts = (value) => value.split('.').map((part) => parseInt(part, 10));
132
+ const [a, b] = [parts(version), parts(minimum)];
133
+
134
+ for (let i = 0; i < 3; i++) {
135
+ if (a[i] !== b[i]) return a[i] < b[i];
136
+ }
137
+
138
+ return false;
139
+ }
140
+
141
+ /**
142
+ * Why the project cannot take the mount yet, or null when it can. The
143
+ * installed copy is what the build will compile, so its version wins over the
144
+ * range in package.json; the range only answers before an install.
145
+ */
146
+ function findPzThemeProblem(cwd) {
147
+ const pkg = readJson(path.join(cwd, 'package.json')) || {};
148
+ const declared = {
149
+ ...pkg.dependencies,
150
+ ...pkg.devDependencies
151
+ }['@akinon/pz-theme'];
152
+
153
+ if (!declared) {
154
+ return (
155
+ '@akinon/pz-theme is not a dependency of this project, and the login ' +
156
+ 'slot is a pz-theme component. Add pz-theme first (on @akinon/next 1.x, ' +
157
+ 'version 2.0.106 or later), then run this codemod again.'
158
+ );
159
+ }
160
+
161
+ const installed = readJson(
162
+ path.join(cwd, 'node_modules', '@akinon', 'pz-theme', 'package.json')
163
+ );
164
+ const version =
165
+ (installed && installed.version) ||
166
+ (String(declared).match(/\d+\.\d+\.\d+/) || [])[0];
167
+
168
+ if (version && isOlderVersion(version, MIN_PZ_THEME_VERSION)) {
169
+ return (
170
+ `@akinon/pz-theme ${version} predates the login slot API ` +
171
+ `(${MIN_PZ_THEME_VERSION}). Upgrade pz-theme, then run this codemod again.`
172
+ );
173
+ }
174
+
175
+ return null;
176
+ }
177
+
178
+ const transform = () => {
179
+ const cwd = path.resolve(process.cwd());
180
+ const dryRun = process.argv.includes('--dry-run');
181
+ const appRoot = path.join(cwd, 'src', 'app');
182
+
183
+ if (!fs.existsSync(appRoot)) {
184
+ log(`composable-auth: no src/app at ${cwd}, skipping`);
185
+ return;
186
+ }
187
+
188
+ const authDirs = findAuthPageDirs(appRoot);
189
+
190
+ if (authDirs.length === 0) {
191
+ log('composable-auth: no auth/page.tsx found, nothing to do');
192
+ return;
193
+ }
194
+
195
+ const pzThemeProblem = findPzThemeProblem(cwd);
196
+
197
+ if (pzThemeProblem) {
198
+ log(`composable-auth: ${pzThemeProblem} Nothing was changed.`);
199
+ return;
200
+ }
201
+
202
+ let mounted = 0;
203
+ let already = 0;
204
+ let manual = 0;
205
+
206
+ for (const authDir of authDirs) {
207
+ const relative = path.relative(cwd, authDir).split(path.sep).join('/');
208
+ const groupDir = path.join(authDir, GROUP_DIR);
209
+ const layoutPath = path.join(groupDir, 'layout.tsx');
210
+ const groupPagePath = path.join(groupDir, 'page.tsx');
211
+ const pagePath = path.join(authDir, 'page.tsx');
212
+
213
+ if (fs.existsSync(groupPagePath) && fs.existsSync(layoutPath)) {
214
+ log(`composable-auth: ${relative} already mounted, skipping`);
215
+ already++;
216
+ continue;
217
+ }
218
+
219
+ const brandLayoutPath = path.join(authDir, 'layout.tsx');
220
+ let nestsUnderBrandLayout = false;
221
+
222
+ if (fs.existsSync(brandLayoutPath)) {
223
+ const brandLayout = fs.readFileSync(brandLayoutPath, 'utf8');
224
+
225
+ if (/(from|require\()\s*['"]\.\/page['"]/.test(brandLayout)) {
226
+ log(
227
+ `composable-auth: ${relative}/layout.tsx imports ./page itself, so ` +
228
+ 'moving the page would break that import. Mount the slot inside ' +
229
+ 'that file by hand. Skipping.'
230
+ );
231
+ manual++;
232
+ continue;
233
+ }
234
+
235
+ if (!brandLayout.includes('children')) {
236
+ log(
237
+ `composable-auth: ${relative}/layout.tsx never renders children — it ` +
238
+ 'is the login screen wearing a layout filename, so a nested slot ' +
239
+ 'would never render. Mount the slot inside that file by hand. ' +
240
+ 'Skipping.'
241
+ );
242
+ manual++;
243
+ continue;
244
+ }
245
+
246
+ // Nested layouts compose: the brand's frame stays outside the slot and
247
+ // keeps wrapping whatever the designer composes.
248
+ nestsUnderBrandLayout = true;
249
+ }
250
+
251
+ const needsMove = !fs.existsSync(groupPagePath);
252
+
253
+ if (dryRun) {
254
+ log(
255
+ needsMove
256
+ ? `composable-auth: would move ${relative}/page.tsx into ` +
257
+ `${GROUP_DIR}/ and write ${GROUP_DIR}/layout.tsx`
258
+ : `composable-auth: would write the missing ${relative}/${GROUP_DIR}/layout.tsx`
259
+ );
260
+ mounted++;
261
+ continue;
262
+ }
263
+
264
+ fs.mkdirSync(groupDir, { recursive: true });
265
+
266
+ if (needsMove) {
267
+ fs.renameSync(pagePath, groupPagePath);
268
+ }
269
+
270
+ fs.writeFileSync(layoutPath, LAYOUT_SOURCE, 'utf8');
271
+
272
+ log(
273
+ nestsUnderBrandLayout
274
+ ? `composable-auth: mounted the login body slot in ${relative}, nested ` +
275
+ 'under the existing auth layout — that frame still renders around ' +
276
+ 'the composition'
277
+ : `composable-auth: mounted the login body slot in ${relative}`
278
+ );
279
+ mounted++;
280
+ }
281
+
282
+ log(
283
+ `composable-auth: ${mounted} mounted, ${already} already done, ` +
284
+ `${manual} need a manual merge${dryRun ? ' (dry-run, nothing written)' : ''}`
285
+ );
286
+ };
287
+
288
+ module.exports = { transform };
289
+
290
+ if (require.main === module) {
291
+ transform();
292
+ }
@@ -191,6 +191,10 @@ export default async () => {
191
191
  {
192
192
  name: 'Google Pay',
193
193
  value: 'pz-google-pay'
194
+ },
195
+ {
196
+ name: 'List Hover Image',
197
+ value: 'pz-list-hover-image'
194
198
  }
195
199
  ];
196
200
 
@@ -179,6 +179,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
179
179
  {
180
180
  name: 'Google Pay',
181
181
  value: 'pz-google-pay'
182
+ },
183
+ {
184
+ name: 'List Hover Image',
185
+ value: 'pz-list-hover-image'
182
186
  }
183
187
  ];
184
188
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.126.17-v1-rc.14",
3
+ "version": "1.126.17",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {