@akinon/projectzero 2.0.50-beta.0 → 2.0.50

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,6 +1,10 @@
1
1
  # @akinon/projectzero
2
2
 
3
- ## 2.0.50-beta.0
3
+ ## 2.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - 79d611c: ZERO-4745: Mount the login body slot and anchor the auth route rules to segment boundaries
4
8
 
5
9
  ## 2.0.49
6
10
 
@@ -1,37 +1,37 @@
1
1
  # projectzeronext
2
2
 
3
- ## 2.0.50-beta.0
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [cbbbfd75]
8
- - @akinon/next@2.0.50-beta.0
9
- - @akinon/pz-theme@2.0.50-beta.0
10
- - @akinon/pz-virtual-try-on@2.0.50-beta.0
11
- - @akinon/pz-akifast@2.0.50-beta.0
12
- - @akinon/pz-apple-pay@2.0.50-beta.0
13
- - @akinon/pz-b2b@2.0.50-beta.0
14
- - @akinon/pz-basket-gift-pack@2.0.50-beta.0
15
- - @akinon/pz-bkm@2.0.50-beta.0
16
- - @akinon/pz-checkout-gift-pack@2.0.50-beta.0
17
- - @akinon/pz-click-collect@2.0.50-beta.0
18
- - @akinon/pz-credit-payment@2.0.50-beta.0
19
- - @akinon/pz-cybersource-uc@2.0.50-beta.0
20
- - @akinon/pz-flow-payment@2.0.50-beta.0
21
- - @akinon/pz-google-pay@2.0.50-beta.0
22
- - @akinon/pz-gpay@2.0.50-beta.0
23
- - @akinon/pz-haso@2.0.50-beta.0
24
- - @akinon/pz-hepsipay@2.0.50-beta.0
25
- - @akinon/pz-masterpass@2.0.50-beta.0
26
- - @akinon/pz-masterpass-rest@2.0.50-beta.0
27
- - @akinon/pz-multi-basket@2.0.50-beta.0
28
- - @akinon/pz-one-click-checkout@2.0.50-beta.0
29
- - @akinon/pz-otp@2.0.50-beta.0
30
- - @akinon/pz-pay-on-delivery@2.0.50-beta.0
31
- - @akinon/pz-saved-card@2.0.50-beta.0
32
- - @akinon/pz-similar-products@2.0.50-beta.0
33
- - @akinon/pz-tabby-extension@2.0.50-beta.0
34
- - @akinon/pz-tamara-extension@2.0.50-beta.0
3
+ ## 2.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [79d611c]
8
+ - @akinon/pz-theme@2.0.50
9
+ - @akinon/next@2.0.50
10
+ - @akinon/pz-akifast@2.0.50
11
+ - @akinon/pz-apple-pay@2.0.50
12
+ - @akinon/pz-b2b@2.0.50
13
+ - @akinon/pz-basket-gift-pack@2.0.50
14
+ - @akinon/pz-bkm@2.0.50
15
+ - @akinon/pz-checkout-gift-pack@2.0.50
16
+ - @akinon/pz-click-collect@2.0.50
17
+ - @akinon/pz-credit-payment@2.0.50
18
+ - @akinon/pz-cybersource-uc@2.0.50
19
+ - @akinon/pz-flow-payment@2.0.50
20
+ - @akinon/pz-google-pay@2.0.50
21
+ - @akinon/pz-gpay@2.0.50
22
+ - @akinon/pz-haso@2.0.50
23
+ - @akinon/pz-hepsipay@2.0.50
24
+ - @akinon/pz-masterpass@2.0.50
25
+ - @akinon/pz-masterpass-rest@2.0.50
26
+ - @akinon/pz-multi-basket@2.0.50
27
+ - @akinon/pz-one-click-checkout@2.0.50
28
+ - @akinon/pz-otp@2.0.50
29
+ - @akinon/pz-pay-on-delivery@2.0.50
30
+ - @akinon/pz-saved-card@2.0.50
31
+ - @akinon/pz-similar-products@2.0.50
32
+ - @akinon/pz-tabby-extension@2.0.50
33
+ - @akinon/pz-tamara-extension@2.0.50
34
+ - @akinon/pz-virtual-try-on@2.0.50
35
35
 
36
36
  ## 2.0.49
37
37
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "2.0.50-beta.0",
3
+ "version": "2.0.50",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -24,33 +24,33 @@
24
24
  "test:middleware": "jest middleware-matcher.test.ts --bail"
25
25
  },
26
26
  "dependencies": {
27
- "@akinon/next": "2.0.50-beta.0",
28
- "@akinon/pz-akifast": "2.0.50-beta.0",
29
- "@akinon/pz-apple-pay": "2.0.50-beta.0",
30
- "@akinon/pz-b2b": "2.0.50-beta.0",
31
- "@akinon/pz-basket-gift-pack": "2.0.50-beta.0",
32
- "@akinon/pz-bkm": "2.0.50-beta.0",
33
- "@akinon/pz-checkout-gift-pack": "2.0.50-beta.0",
34
- "@akinon/pz-click-collect": "2.0.50-beta.0",
35
- "@akinon/pz-credit-payment": "2.0.50-beta.0",
36
- "@akinon/pz-cybersource-uc": "2.0.50-beta.0",
37
- "@akinon/pz-flow-payment": "2.0.50-beta.0",
38
- "@akinon/pz-google-pay": "2.0.50-beta.0",
39
- "@akinon/pz-gpay": "2.0.50-beta.0",
40
- "@akinon/pz-haso": "2.0.50-beta.0",
41
- "@akinon/pz-hepsipay": "2.0.50-beta.0",
42
- "@akinon/pz-masterpass": "2.0.50-beta.0",
43
- "@akinon/pz-masterpass-rest": "2.0.50-beta.0",
44
- "@akinon/pz-multi-basket": "2.0.50-beta.0",
45
- "@akinon/pz-one-click-checkout": "2.0.50-beta.0",
46
- "@akinon/pz-otp": "2.0.50-beta.0",
47
- "@akinon/pz-pay-on-delivery": "2.0.50-beta.0",
48
- "@akinon/pz-saved-card": "2.0.50-beta.0",
49
- "@akinon/pz-similar-products": "2.0.50-beta.0",
50
- "@akinon/pz-tabby-extension": "2.0.50-beta.0",
51
- "@akinon/pz-tamara-extension": "2.0.50-beta.0",
52
- "@akinon/pz-theme": "2.0.50-beta.0",
53
- "@akinon/pz-virtual-try-on": "2.0.50-beta.0",
27
+ "@akinon/next": "2.0.50",
28
+ "@akinon/pz-akifast": "2.0.50",
29
+ "@akinon/pz-apple-pay": "2.0.50",
30
+ "@akinon/pz-b2b": "2.0.50",
31
+ "@akinon/pz-basket-gift-pack": "2.0.50",
32
+ "@akinon/pz-bkm": "2.0.50",
33
+ "@akinon/pz-checkout-gift-pack": "2.0.50",
34
+ "@akinon/pz-click-collect": "2.0.50",
35
+ "@akinon/pz-credit-payment": "2.0.50",
36
+ "@akinon/pz-cybersource-uc": "2.0.50",
37
+ "@akinon/pz-flow-payment": "2.0.50",
38
+ "@akinon/pz-google-pay": "2.0.50",
39
+ "@akinon/pz-gpay": "2.0.50",
40
+ "@akinon/pz-haso": "2.0.50",
41
+ "@akinon/pz-hepsipay": "2.0.50",
42
+ "@akinon/pz-masterpass": "2.0.50",
43
+ "@akinon/pz-masterpass-rest": "2.0.50",
44
+ "@akinon/pz-multi-basket": "2.0.50",
45
+ "@akinon/pz-one-click-checkout": "2.0.50",
46
+ "@akinon/pz-otp": "2.0.50",
47
+ "@akinon/pz-pay-on-delivery": "2.0.50",
48
+ "@akinon/pz-saved-card": "2.0.50",
49
+ "@akinon/pz-similar-products": "2.0.50",
50
+ "@akinon/pz-tabby-extension": "2.0.50",
51
+ "@akinon/pz-tamara-extension": "2.0.50",
52
+ "@akinon/pz-theme": "2.0.50",
53
+ "@akinon/pz-virtual-try-on": "2.0.50",
54
54
  "@hookform/resolvers": "2.9.0",
55
55
  "@next/third-parties": "16.2.6",
56
56
  "@react-google-maps/api": "2.17.1",
@@ -74,7 +74,7 @@
74
74
  "yup": "0.32.11"
75
75
  },
76
76
  "devDependencies": {
77
- "@akinon/eslint-plugin-projectzero": "2.0.50-beta.0",
77
+ "@akinon/eslint-plugin-projectzero": "2.0.50",
78
78
  "@semantic-release/changelog": "6.0.2",
79
79
  "@semantic-release/exec": "6.0.3",
80
80
  "@semantic-release/git": "10.0.1",
@@ -0,0 +1,37 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
3
+
4
+ /**
5
+ * The login screen is handed to the theme editor here rather than in page.tsx,
6
+ * because the slot is an async server component and the page is a client one.
7
+ * With no composition published the slot renders the page untouched.
8
+ *
9
+ * The slot lives in a `(login)` route group so the composition covers exactly
10
+ * this screen: `auth/oauth-login` is a provider callback, and a login body
11
+ * mounted one level up would replace it too.
12
+ *
13
+ * No `pageContext`: an auth screen fetches no commerce data, and the blocks a
14
+ * designer rebuilds it from (`auth-form`, `register-form`, `oauth-buttons`)
15
+ * read the session client-side.
16
+ *
17
+ * Login and register stay on this ONE screen. Whether they read as tabs or as
18
+ * two forms side by side is composed here (the starter templates ship both
19
+ * shapes), so no second route is involved.
20
+ */
21
+ export default function LoginLayout({
22
+ children
23
+ }: {
24
+ children: React.ReactNode;
25
+ }) {
26
+ return (
27
+ // `contents` on both wrappers keeps the slot chain layout-transparent, so
28
+ // an uncomposed login page keeps its own box model even where a brand's
29
+ // <main> is a flex or grid container.
30
+ <ChromeSlot
31
+ slug={PLACEHOLDER_SLUGS.auth}
32
+ fallback={children}
33
+ className="contents"
34
+ fallbackClassName="contents"
35
+ />
36
+ );
37
+ }
@@ -0,0 +1,21 @@
1
+ import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
2
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
3
+
4
+ /**
5
+ * The forgot-password body, handed over the same way as the login screen: the
6
+ * slot is an async server component and the page is a client one. This route
7
+ * holds a single page, so it needs no route group to keep the composition off
8
+ * a sibling screen.
9
+ *
10
+ * Brands that route it at `/auth/forgot-password` instead resolve to the same
11
+ * placeholder, so one composition serves both spellings.
12
+ */
13
+ export default function ForgotPasswordLayout({
14
+ children
15
+ }: {
16
+ children: React.ReactNode;
17
+ }) {
18
+ return (
19
+ <ChromeSlot slug={PLACEHOLDER_SLUGS.forgotPassword} fallback={children} />
20
+ );
21
+ }
@@ -0,0 +1,220 @@
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
+ * Usage:
32
+ * node codemods/composable-auth/index.js [--dry-run]
33
+ * npx @akinon/projectzero codemod --codemod=composable-auth [--dry-run]
34
+ */
35
+
36
+ const path = require('path');
37
+ const fs = require('fs');
38
+
39
+ const GROUP_DIR = '(login)';
40
+
41
+ const LAYOUT_SOURCE = `import ChromeSlot from '@akinon/pz-theme/src/chrome/chrome-slot';
42
+ import { PLACEHOLDER_SLUGS } from '@akinon/pz-theme/src/chrome/placeholder-slugs';
43
+
44
+ /**
45
+ * The login screen is handed to the theme editor here rather than in page.tsx,
46
+ * because the slot is an async server component and the page is a client one.
47
+ * With no composition published the slot renders the page untouched.
48
+ *
49
+ * The slot lives in a \`(login)\` route group so the composition covers exactly
50
+ * this screen: \`auth/oauth-login\` is a provider callback, and a login body
51
+ * mounted one level up would replace it too.
52
+ *
53
+ * No \`pageContext\`: an auth screen fetches no commerce data, and the blocks a
54
+ * designer rebuilds it from (\`auth-form\`, \`register-form\`, \`oauth-buttons\`)
55
+ * read the session client-side.
56
+ */
57
+ export default function LoginLayout({
58
+ children
59
+ }: {
60
+ children: React.ReactNode;
61
+ }) {
62
+ return (
63
+ // \`contents\` on both wrappers keeps the slot chain layout-transparent, so
64
+ // an uncomposed login page keeps its own box model even where a brand's
65
+ // <main> is a flex or grid container.
66
+ <ChromeSlot
67
+ slug={PLACEHOLDER_SLUGS.auth}
68
+ fallback={children}
69
+ className="contents"
70
+ fallbackClassName="contents"
71
+ />
72
+ );
73
+ }
74
+ `;
75
+
76
+ function log(msg) {
77
+ const ts = new Date().toISOString().replace('T', ' ').slice(0, 19);
78
+ console.log(`[${ts}] ${msg}`);
79
+ }
80
+
81
+ /**
82
+ * Every directory named `auth` that holds a login page, anywhere under src/app.
83
+ * An already-migrated brand keeps its page inside the group, so both spellings
84
+ * count — otherwise a second run would report "nothing to do" and a brand whose
85
+ * layout went missing could never be repaired.
86
+ */
87
+ function findAuthPageDirs(appRoot) {
88
+ const found = [];
89
+
90
+ const visit = (dir) => {
91
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
92
+ if (!entry.isDirectory()) continue;
93
+
94
+ const entryPath = path.join(dir, entry.name);
95
+
96
+ if (
97
+ entry.name === 'auth' &&
98
+ (fs.existsSync(path.join(entryPath, 'page.tsx')) ||
99
+ fs.existsSync(path.join(entryPath, GROUP_DIR, 'page.tsx')))
100
+ ) {
101
+ found.push(entryPath);
102
+ }
103
+
104
+ visit(entryPath);
105
+ }
106
+ };
107
+
108
+ visit(appRoot);
109
+
110
+ return found;
111
+ }
112
+
113
+ const transform = () => {
114
+ const cwd = path.resolve(process.cwd());
115
+ const dryRun = process.argv.includes('--dry-run');
116
+ const appRoot = path.join(cwd, 'src', 'app');
117
+
118
+ if (!fs.existsSync(appRoot)) {
119
+ log(`composable-auth: no src/app at ${cwd}, skipping`);
120
+ return;
121
+ }
122
+
123
+ const authDirs = findAuthPageDirs(appRoot);
124
+
125
+ if (authDirs.length === 0) {
126
+ log('composable-auth: no auth/page.tsx found, nothing to do');
127
+ return;
128
+ }
129
+
130
+ let mounted = 0;
131
+ let already = 0;
132
+ let manual = 0;
133
+
134
+ for (const authDir of authDirs) {
135
+ const relative = path.relative(cwd, authDir).split(path.sep).join('/');
136
+ const groupDir = path.join(authDir, GROUP_DIR);
137
+ const layoutPath = path.join(groupDir, 'layout.tsx');
138
+ const groupPagePath = path.join(groupDir, 'page.tsx');
139
+ const pagePath = path.join(authDir, 'page.tsx');
140
+
141
+ if (fs.existsSync(groupPagePath) && fs.existsSync(layoutPath)) {
142
+ log(`composable-auth: ${relative} already mounted, skipping`);
143
+ already++;
144
+ continue;
145
+ }
146
+
147
+ const brandLayoutPath = path.join(authDir, 'layout.tsx');
148
+ let nestsUnderBrandLayout = false;
149
+
150
+ if (fs.existsSync(brandLayoutPath)) {
151
+ const brandLayout = fs.readFileSync(brandLayoutPath, 'utf8');
152
+
153
+ if (/(from|require\()\s*['"]\.\/page['"]/.test(brandLayout)) {
154
+ log(
155
+ `composable-auth: ${relative}/layout.tsx imports ./page itself, so ` +
156
+ 'moving the page would break that import. Mount the slot inside ' +
157
+ 'that file by hand. Skipping.'
158
+ );
159
+ manual++;
160
+ continue;
161
+ }
162
+
163
+ if (!brandLayout.includes('children')) {
164
+ log(
165
+ `composable-auth: ${relative}/layout.tsx never renders children — it ` +
166
+ 'is the login screen wearing a layout filename, so a nested slot ' +
167
+ 'would never render. Mount the slot inside that file by hand. ' +
168
+ 'Skipping.'
169
+ );
170
+ manual++;
171
+ continue;
172
+ }
173
+
174
+ // Nested layouts compose: the brand's frame stays outside the slot and
175
+ // keeps wrapping whatever the designer composes.
176
+ nestsUnderBrandLayout = true;
177
+ }
178
+
179
+ const needsMove = !fs.existsSync(groupPagePath);
180
+
181
+ if (dryRun) {
182
+ log(
183
+ needsMove
184
+ ? `composable-auth: would move ${relative}/page.tsx into ` +
185
+ `${GROUP_DIR}/ and write ${GROUP_DIR}/layout.tsx`
186
+ : `composable-auth: would write the missing ${relative}/${GROUP_DIR}/layout.tsx`
187
+ );
188
+ mounted++;
189
+ continue;
190
+ }
191
+
192
+ fs.mkdirSync(groupDir, { recursive: true });
193
+
194
+ if (needsMove) {
195
+ fs.renameSync(pagePath, groupPagePath);
196
+ }
197
+
198
+ fs.writeFileSync(layoutPath, LAYOUT_SOURCE, 'utf8');
199
+
200
+ log(
201
+ nestsUnderBrandLayout
202
+ ? `composable-auth: mounted the login body slot in ${relative}, nested ` +
203
+ 'under the existing auth layout — that frame still renders around ' +
204
+ 'the composition'
205
+ : `composable-auth: mounted the login body slot in ${relative}`
206
+ );
207
+ mounted++;
208
+ }
209
+
210
+ log(
211
+ `composable-auth: ${mounted} mounted, ${already} already done, ` +
212
+ `${manual} need a manual merge${dryRun ? ' (dry-run, nothing written)' : ''}`
213
+ );
214
+ };
215
+
216
+ module.exports = { transform };
217
+
218
+ if (require.main === module) {
219
+ transform();
220
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "2.0.50-beta.0",
3
+ "version": "2.0.50",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {