@akinon/next 1.28.0-rc.1 → 1.29.0
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 +3 -5
- package/bin/pz-install-plugins.js +7 -1
- package/bin/pz-install-theme.js +10 -1
- package/bin/pz-prebuild.js +0 -2
- package/data/client/user.ts +2 -2
- package/package.json +2 -2
- package/utils/redirect.ts +30 -0
- package/bin/pz-copy-template.js +0 -43
- package/bin/pz-pre-check-dist.js +0 -14
- package/utils/find-base-dir.js +0 -13
- package/utils/hash-directory.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
4
|
-
|
|
5
|
-
## 1.28.0-rc.0
|
|
3
|
+
## 1.29.0
|
|
6
4
|
|
|
7
5
|
### Minor Changes
|
|
8
6
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- a7e432f: ZERO-2534: Fix for recapthca regex for replacing the special chars.
|
|
8
|
+
- f76f079: ZERO-2493: Add redirect util function
|
|
11
9
|
|
|
12
10
|
## 1.27.0
|
|
13
11
|
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
function findBaseDir() {
|
|
6
|
+
const insideNodeModules = __dirname.includes('node_modules');
|
|
7
|
+
return insideNodeModules
|
|
8
|
+
? process.cwd()
|
|
9
|
+
: path.resolve(__dirname, '../../../apps/projectzeronext');
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
const BASE_DIR = findBaseDir();
|
|
7
13
|
const getFullPath = (relativePath) => path.join(BASE_DIR, relativePath);
|
package/bin/pz-install-theme.js
CHANGED
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const spawn = require('cross-spawn');
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
function findBaseDir() {
|
|
8
|
+
const insideNodeModules = __dirname.includes('node_modules');
|
|
9
|
+
|
|
10
|
+
if (insideNodeModules) {
|
|
11
|
+
return path.resolve(__dirname, '../../../../');
|
|
12
|
+
} else {
|
|
13
|
+
return path.resolve(__dirname, '../../../apps/projectzeronext');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
const BASE_DIR = findBaseDir();
|
|
9
18
|
|
package/bin/pz-prebuild.js
CHANGED
package/data/client/user.ts
CHANGED
|
@@ -22,9 +22,9 @@ const userApi = api.injectEndpoints({
|
|
|
22
22
|
getCaptcha: build.query<GetCaptchaResponse, void>({
|
|
23
23
|
query: () => buildClientRequestUrl(user.captcha),
|
|
24
24
|
transformResponse: (response: { html: string }) => {
|
|
25
|
-
const siteKeyMatch = response.html.match(/sitekey=["|']
|
|
25
|
+
const siteKeyMatch = response.html.match(/sitekey=["|'][^"']+/gi);
|
|
26
26
|
const csrfTokenMatch = response.html.match(
|
|
27
|
-
/name=['|"]csrfmiddlewaretoken['|"] value=['|"]
|
|
27
|
+
/name=['|"]csrfmiddlewaretoken['|"] value=['|"][^'"]+/gi
|
|
28
28
|
);
|
|
29
29
|
const siteKey = siteKeyMatch?.[0].replace(/sitekey=["|']/, '') || '';
|
|
30
30
|
const csrfToken =
|
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.
|
|
4
|
+
"version": "1.29.0",
|
|
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.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.29.0",
|
|
36
36
|
"eslint-config-prettier": "8.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { redirect as nextRedirect, RedirectType } from 'next/navigation';
|
|
2
|
+
import Settings from 'settings';
|
|
3
|
+
import { headers } from 'next/headers';
|
|
4
|
+
import { ServerVariables } from '@akinon/next/utils/server-variables';
|
|
5
|
+
import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
|
|
6
|
+
|
|
7
|
+
export const redirect = (path: string, type?: RedirectType) => {
|
|
8
|
+
const nextHeaders = headers();
|
|
9
|
+
const pageUrl = new URL(
|
|
10
|
+
nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const currentLocale = Settings.localization.locales.find(
|
|
14
|
+
(locale) => locale.value === ServerVariables.locale
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const callbackUrl = pageUrl.pathname;
|
|
18
|
+
const redirectUrlWithLocale = getUrlPathWithLocale(
|
|
19
|
+
path,
|
|
20
|
+
currentLocale.localePath ?? currentLocale.value
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const redirectUrl = `${redirectUrlWithLocale}?callbackUrl=${callbackUrl}`;
|
|
24
|
+
|
|
25
|
+
if (type) {
|
|
26
|
+
return nextRedirect(redirectUrl, type);
|
|
27
|
+
} else {
|
|
28
|
+
return nextRedirect(redirectUrl);
|
|
29
|
+
}
|
|
30
|
+
};
|
package/bin/pz-copy-template.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const projectZeroNextDir = path.join(
|
|
4
|
-
__dirname,
|
|
5
|
-
'../../../apps/projectzeronext'
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
const templatesDir = path.join(
|
|
9
|
-
__dirname,
|
|
10
|
-
'../../../packages/projectzero-cli/app-template'
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
if (fs.existsSync(templatesDir)) {
|
|
14
|
-
fs.rmdirSync(templatesDir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function copyRecursively(src, dest) {
|
|
18
|
-
if (path.basename(src) === 'node_modules') {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (fs.existsSync(src) && fs.statSync(src).isDirectory()) {
|
|
23
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
24
|
-
fs.readdirSync(src).forEach((childItemName) => {
|
|
25
|
-
const childSrcPath = path.join(src, childItemName);
|
|
26
|
-
const childDestPath = path.join(dest, childItemName);
|
|
27
|
-
copyRecursively(childSrcPath, childDestPath);
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
fs.copyFileSync(src, dest);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!fs.existsSync(templatesDir)) {
|
|
35
|
-
fs.mkdirSync(templatesDir, { recursive: true });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
copyRecursively(projectZeroNextDir, templatesDir);
|
|
39
|
-
|
|
40
|
-
console.log(
|
|
41
|
-
'\x1b[33m%s\x1b[0m',
|
|
42
|
-
'projectzeronext content has been copied to templates.'
|
|
43
|
-
);
|
package/bin/pz-pre-check-dist.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const hashDirectory = require('../utils/hash-directory');
|
|
4
|
-
|
|
5
|
-
const packageDistPath = path.join(
|
|
6
|
-
__dirname,
|
|
7
|
-
'../../../packages/projectzero-cli/dist/commands'
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
const hash = hashDirectory(packageDistPath);
|
|
11
|
-
fs.writeFileSync(
|
|
12
|
-
path.join(__dirname, '../../../packages/projectzero-cli/dist/dist-hash.txt'),
|
|
13
|
-
hash
|
|
14
|
-
);
|
package/utils/find-base-dir.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
function findBaseDir() {
|
|
4
|
-
const insideNodeModules = __dirname.includes('node_modules');
|
|
5
|
-
|
|
6
|
-
if (insideNodeModules) {
|
|
7
|
-
return path.resolve(__dirname, '../../../../');
|
|
8
|
-
} else {
|
|
9
|
-
return path.resolve(__dirname, '../../../apps/projectzeronext');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = findBaseDir;
|
package/utils/hash-directory.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { createHash } = require('crypto');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
function hashDirectory(directory) {
|
|
6
|
-
const files = fs.readdirSync(directory).sort();
|
|
7
|
-
const hash = createHash('sha256');
|
|
8
|
-
files.forEach((file) => {
|
|
9
|
-
const filePath = path.join(directory, file);
|
|
10
|
-
if (fs.statSync(filePath).isFile()) {
|
|
11
|
-
const fileBuffer = fs.readFileSync(filePath);
|
|
12
|
-
hash.update(fileBuffer);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return hash.digest('hex');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = hashDirectory;
|