@akinon/next 1.24.0-rc.5 → 1.24.0-rc.7
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 +15 -0
- package/api/auth.ts +2 -2
- package/bin/pz-check-dependencies.js +62 -1
- package/bin/pz-install-extensions.js +27 -0
- package/bin/pz-install-plugins.js +0 -0
- package/bin/pz-install-theme.js +0 -0
- package/bin/pz-postbuild.js +0 -0
- package/bin/pz-postdev.js +0 -0
- package/bin/pz-postinstall.js +0 -0
- package/bin/pz-poststart.js +0 -0
- package/bin/pz-prebuild.js +0 -0
- package/bin/pz-predev.js +2 -0
- package/bin/pz-prestart.js +0 -0
- package/data/client/user.ts +12 -0
- package/data/urls.ts +1 -0
- package/package.json +2 -2
- package/utils/log.ts +30 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.24.0-rc.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6d4aadb9: ZERO-2476: Auto install recommendenent extension
|
|
8
|
+
- 3690d3bd: ZERO-2485: Eslint version dynamically adds as a peerdependinciey and checks the version
|
|
9
|
+
|
|
10
|
+
## 1.24.0-rc.6
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- e20b27f: ZERO-2454:add otp login
|
|
15
|
+
- a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
|
|
16
|
+
- 1ec9775: ZERO-2462:add custom span to logs
|
|
17
|
+
|
|
3
18
|
## 1.24.0-rc.5
|
|
4
19
|
|
|
5
20
|
## 1.24.0-rc.4
|
package/api/auth.ts
CHANGED
|
@@ -199,8 +199,8 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
199
199
|
);
|
|
200
200
|
|
|
201
201
|
const localeResults = req.headers.referer
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
?.replace(baseUrl, '')
|
|
203
|
+
?.match(urlLocaleMatcherRegex);
|
|
204
204
|
|
|
205
205
|
return `${baseUrl}${localeResults?.[0] || ''}${pathnameWithoutLocale}`;
|
|
206
206
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const semver = require('semver');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
6
7
|
|
|
7
8
|
function checkDir() {
|
|
8
9
|
let currentDir = __dirname;
|
|
@@ -21,8 +22,50 @@ function checkDir() {
|
|
|
21
22
|
return path.resolve(__dirname, '../../../../');
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
function getCurrentBranchName() {
|
|
26
|
+
try {
|
|
27
|
+
return execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error(`Error fetching current branch name: ${error}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function fetchLatestPackageVersion(packageName) {
|
|
35
|
+
const currentBranch = getCurrentBranchName();
|
|
36
|
+
let npmShowCommand = `npm show ${packageName} version`;
|
|
37
|
+
|
|
38
|
+
if (currentBranch === 'rc') {
|
|
39
|
+
npmShowCommand = `npm show ${packageName}@rc version`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
return execSync(npmShowCommand).toString().trim();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(
|
|
46
|
+
`Error fetching latest version for package ${packageName}: ${error}`
|
|
47
|
+
);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
24
52
|
const BASE_DIR = checkDir();
|
|
25
53
|
|
|
54
|
+
function getProjectZeroNextPackagePath() {
|
|
55
|
+
const possiblePaths = [
|
|
56
|
+
path.join(BASE_DIR, 'apps/projectzeronext/package.json'),
|
|
57
|
+
path.join(BASE_DIR, 'package.json')
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
for (const packagePath of possiblePaths) {
|
|
61
|
+
if (fs.existsSync(packagePath)) {
|
|
62
|
+
return packagePath;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
throw new Error('Unable to find package.json in expected locations.');
|
|
67
|
+
}
|
|
68
|
+
|
|
26
69
|
try {
|
|
27
70
|
const akinonNextPackagePath = fs.existsSync(
|
|
28
71
|
path.join(BASE_DIR, 'packages/akinon-next/package.json')
|
|
@@ -34,12 +77,30 @@ try {
|
|
|
34
77
|
fs.readFileSync(akinonNextPackagePath, 'utf8')
|
|
35
78
|
);
|
|
36
79
|
|
|
37
|
-
const projectZeroNextPackagePath =
|
|
80
|
+
const projectZeroNextPackagePath = getProjectZeroNextPackagePath();
|
|
38
81
|
|
|
39
82
|
const projectZeroNextPackage = JSON.parse(
|
|
40
83
|
fs.readFileSync(projectZeroNextPackagePath, 'utf8')
|
|
41
84
|
);
|
|
42
85
|
|
|
86
|
+
const eslintPluginLatestVersion = fetchLatestPackageVersion(
|
|
87
|
+
'@akinon/eslint-plugin-projectzero'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
akinonNextPackage.peerDependencies = {
|
|
91
|
+
...akinonNextPackage.peerDependencies,
|
|
92
|
+
'@akinon/eslint-plugin-projectzero': `${eslintPluginLatestVersion}`
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
fs.writeFileSync(
|
|
96
|
+
akinonNextPackagePath,
|
|
97
|
+
JSON.stringify(akinonNextPackage, null, 2) + '\n'
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
console.log(
|
|
101
|
+
'@akinon/next peerDependencies updated with the latest @akinon/eslint-plugin-projectzero version'
|
|
102
|
+
);
|
|
103
|
+
|
|
43
104
|
const { peerDependencies } = akinonNextPackage;
|
|
44
105
|
|
|
45
106
|
let hasErrors = false;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
function findBaseDir() {
|
|
6
|
+
let currentDir = __dirname;
|
|
7
|
+
while (currentDir !== path.resolve(currentDir, '..')) {
|
|
8
|
+
if (fs.existsSync(path.join(currentDir, 'turbo.json'))) {
|
|
9
|
+
return currentDir;
|
|
10
|
+
}
|
|
11
|
+
currentDir = path.resolve(currentDir, '..');
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BASE_DIR = findBaseDir();
|
|
17
|
+
|
|
18
|
+
if (BASE_DIR) {
|
|
19
|
+
const extensions = ['bilal-akinon.pznext'];
|
|
20
|
+
extensions.forEach((extension) => {
|
|
21
|
+
try {
|
|
22
|
+
execSync(`code --install-extension ${extension}`, { stdio: 'inherit' });
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(`Error installing ${extension}:`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
File without changes
|
package/bin/pz-install-theme.js
CHANGED
|
File without changes
|
package/bin/pz-postbuild.js
CHANGED
|
File without changes
|
package/bin/pz-postdev.js
CHANGED
|
File without changes
|
package/bin/pz-postinstall.js
CHANGED
|
File without changes
|
package/bin/pz-poststart.js
CHANGED
|
File without changes
|
package/bin/pz-prebuild.js
CHANGED
|
File without changes
|
package/bin/pz-predev.js
CHANGED
package/bin/pz-prestart.js
CHANGED
|
File without changes
|
package/data/client/user.ts
CHANGED
|
@@ -71,6 +71,17 @@ const userApi = api.injectEndpoints({
|
|
|
71
71
|
body
|
|
72
72
|
})
|
|
73
73
|
}),
|
|
74
|
+
otpLogin: build.mutation<void, { phone: string }>({
|
|
75
|
+
query: ({ phone }) => ({
|
|
76
|
+
url: buildClientRequestUrl(user.otpLogin, {
|
|
77
|
+
contentType: 'application/json'
|
|
78
|
+
}),
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: {
|
|
81
|
+
phone
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
74
85
|
changeEmailVerification: build.query<void, string>({
|
|
75
86
|
query: (token) => ({
|
|
76
87
|
url: buildClientRequestUrl(user.changeEmailVerification(token), {
|
|
@@ -110,6 +121,7 @@ export const {
|
|
|
110
121
|
useConfirmEmailVerificationQuery,
|
|
111
122
|
useValidateCaptchaMutation,
|
|
112
123
|
useLogoutMutation,
|
|
124
|
+
useOtpLoginMutation,
|
|
113
125
|
useForgotPasswordMutation,
|
|
114
126
|
useGetAnonymousTrackingMutation
|
|
115
127
|
} = userApi;
|
package/data/urls.ts
CHANGED
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.24.0-rc.
|
|
4
|
+
"version": "1.24.0-rc.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
33
33
|
"@typescript-eslint/parser": "6.7.4",
|
|
34
34
|
"eslint": "^8.14.0",
|
|
35
|
-
"@akinon/eslint-plugin-projectzero": "1.24.0-rc.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.24.0-rc.7",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/utils/log.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { trace } from '@opentelemetry/api';
|
|
2
|
+
|
|
1
3
|
enum LogLevel {
|
|
2
4
|
TRACE = 'trace',
|
|
3
5
|
DEBUG = 'debug',
|
|
@@ -78,61 +80,42 @@ const writeMsg = ({ level, message, payload }: Message) => {
|
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
message,
|
|
85
|
-
payload
|
|
86
|
-
});
|
|
87
|
-
};
|
|
83
|
+
function createCustomSpan({ level, message, payload }: Message) {
|
|
84
|
+
const tracer = trace.getTracer('pz-next-app');
|
|
85
|
+
const span = tracer.startSpan('custom-operation-log');
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
payload
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const warn: LoggerFn = (message, payload) => {
|
|
98
|
-
writeMsg({
|
|
99
|
-
level: LogLevel.WARN,
|
|
100
|
-
message,
|
|
101
|
-
payload
|
|
87
|
+
span.setAttributes({
|
|
88
|
+
level: level,
|
|
89
|
+
message: message,
|
|
90
|
+
payload: payload
|
|
102
91
|
});
|
|
103
|
-
};
|
|
104
92
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
level: LogLevel.DEBUG,
|
|
108
|
-
message,
|
|
109
|
-
payload
|
|
110
|
-
});
|
|
111
|
-
};
|
|
93
|
+
span.end();
|
|
94
|
+
}
|
|
112
95
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
level
|
|
96
|
+
const createLogAndSpan = (level: LogLevel, message: string, payload?: any) => {
|
|
97
|
+
const content = {
|
|
98
|
+
level,
|
|
116
99
|
message,
|
|
117
|
-
payload
|
|
118
|
-
}
|
|
119
|
-
};
|
|
100
|
+
payload: JSON.stringify(payload)
|
|
101
|
+
};
|
|
120
102
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
level: LogLevel.FATAL,
|
|
124
|
-
message,
|
|
125
|
-
payload
|
|
126
|
-
});
|
|
103
|
+
writeMsg(content);
|
|
104
|
+
createCustomSpan(content);
|
|
127
105
|
};
|
|
128
106
|
|
|
129
|
-
const logger = {
|
|
130
|
-
trace,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
107
|
+
const logger: Record<LogLevel, LoggerFn> = {
|
|
108
|
+
trace: (message, payload) =>
|
|
109
|
+
createLogAndSpan(LogLevel.TRACE, message, payload),
|
|
110
|
+
debug: (message, payload) =>
|
|
111
|
+
createLogAndSpan(LogLevel.DEBUG, message, payload),
|
|
112
|
+
info: (message, payload) => createLogAndSpan(LogLevel.INFO, message, payload),
|
|
113
|
+
warn: (message, payload) => createLogAndSpan(LogLevel.WARN, message, payload),
|
|
114
|
+
error: (message, payload) =>
|
|
115
|
+
createLogAndSpan(LogLevel.ERROR, message, payload),
|
|
116
|
+
fatal: (message, payload) =>
|
|
117
|
+
createLogAndSpan(LogLevel.FATAL, message, payload),
|
|
118
|
+
silent: () => {}
|
|
136
119
|
};
|
|
137
120
|
|
|
138
121
|
export default logger;
|