@akinon/next 1.89.0-rc.3 → 1.89.0-rc.4

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,5 +1,15 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.89.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - bf354de: ZERO-3321: add babel compiler for akinon/next test
8
+ - 448adef: ZERO-3321: move csp test to akinon-next
9
+ - 6c3629c: ZERO-3321: fix jest tests in akinon-next for standalone projects
10
+ - acf0320: ZERO-3321: remove babel config
11
+ - b2ee69b: ZERO-3321: delete unnecessary files
12
+
3
13
  ## 1.89.0-rc.3
4
14
 
5
15
  ### Minor Changes
@@ -0,0 +1,83 @@
1
+ import { resolve } from 'path';
2
+ import type { NextConfig } from 'next';
3
+
4
+ function findBaseDir() {
5
+ const insideNodeModules = __dirname.includes('node_modules');
6
+
7
+ if (insideNodeModules) {
8
+ return resolve(__dirname, '../../../../');
9
+ } else {
10
+ return resolve(__dirname, '../../../apps/projectzeronext');
11
+ }
12
+ }
13
+
14
+ const baseDir = findBaseDir();
15
+
16
+ jest.mock('next-pwa', () => {
17
+ return () => (config: NextConfig) => config;
18
+ });
19
+
20
+ jest.mock('@sentry/nextjs', () => ({
21
+ withSentryConfig: (config: NextConfig) => config
22
+ }));
23
+
24
+ jest.mock('../with-pz-config.js', () => {
25
+ return (config: NextConfig) => {
26
+ const originalHeaders = config.headers;
27
+
28
+ config.headers = async () => {
29
+ const originalHeadersResult = (await originalHeaders?.()) ?? [];
30
+
31
+ return [
32
+ {
33
+ source: '/(.*)',
34
+ headers: [
35
+ {
36
+ key: 'Content-Security-Policy',
37
+ value: 'https://*.akifast.com akifast.com'
38
+ }
39
+ ]
40
+ },
41
+ ...originalHeadersResult
42
+ ];
43
+ };
44
+ return config;
45
+ };
46
+ });
47
+
48
+ interface Header {
49
+ key: string;
50
+ value: string;
51
+ }
52
+
53
+ interface HeaderGroup {
54
+ source: string;
55
+ headers: Header[];
56
+ }
57
+
58
+ const nextConfigPath = resolve(baseDir, 'next.config.mjs');
59
+ let nextConfig: any;
60
+
61
+ beforeAll(async () => {
62
+ nextConfig = await import(nextConfigPath);
63
+ });
64
+
65
+ describe('Next.js Configuration', () => {
66
+ it('should contain Content-Security-Policy header with akifast domain values', async () => {
67
+ const headers = nextConfig.default.headers;
68
+ expect(headers).toBeDefined();
69
+
70
+ const headersResult = await headers();
71
+
72
+ const cspHeaders = headersResult
73
+ .flatMap((headerGroup: HeaderGroup) => headerGroup.headers)
74
+ .filter((header: Header) => header.key === 'Content-Security-Policy');
75
+
76
+ expect(cspHeaders.length).toBeGreaterThan(0);
77
+
78
+ const lastCspHeader = cspHeaders[cspHeaders.length - 1];
79
+
80
+ expect(lastCspHeader.value).toContain('akifast.com');
81
+ expect(lastCspHeader.value).toContain('https://*.akifast.com');
82
+ });
83
+ });
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "Default",
4
+ "compilerOptions": {
5
+ "composite": false,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "inlineSources": false,
11
+ "isolatedModules": true,
12
+ "moduleResolution": "node",
13
+ "noUnusedLocals": false,
14
+ "noUnusedParameters": false,
15
+ "preserveWatchOutput": true,
16
+ "skipLibCheck": true,
17
+ "strict": true,
18
+ "jsx": "react-jsx"
19
+ },
20
+ "exclude": ["node_modules"],
21
+ "include": [".", "../."]
22
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', { targets: { node: 'current' } }],
4
+ '@babel/preset-typescript'
5
+ ]
6
+ };
@@ -2,6 +2,7 @@
2
2
 
3
3
  const runScript = require('./run-script');
4
4
 
5
+ runScript('pz-run-tests.js');
5
6
  runScript('pz-install-theme.js');
6
7
  runScript('pz-pre-check-dist.js');
7
8
  runScript('pz-generate-translations.js');
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const glob = require('glob');
7
+ const findBaseDir = require('../utils/find-base-dir');
8
+
9
+ const BASE_DIR = findBaseDir();
10
+
11
+ function isJestAvailable() {
12
+ try {
13
+ const jestPath = path.join(BASE_DIR, 'node_modules', '.bin', 'jest');
14
+ return fs.existsSync(jestPath);
15
+ } catch (error) {
16
+ return false;
17
+ }
18
+ }
19
+
20
+ function findAkinonNextPath() {
21
+ const insideNodeModules = __dirname.includes('node_modules');
22
+
23
+ if (insideNodeModules) {
24
+ return path.resolve(__dirname, '..');
25
+ }
26
+
27
+ return path.resolve(__dirname, '../../../packages/akinon-next');
28
+ }
29
+
30
+ if (!isJestAvailable()) {
31
+ console.error('\x1b[31mError: Jest is not available!\x1b[0m');
32
+ console.error(
33
+ 'Please make sure you have installed all dependencies by running:'
34
+ );
35
+ console.error(' npm install');
36
+ console.error('or');
37
+ console.error(' yarn install');
38
+ process.exit(1);
39
+ }
40
+
41
+ const jestPath = path.join(BASE_DIR, 'node_modules', '.bin', 'jest');
42
+ const akinonNextPath = findAkinonNextPath();
43
+
44
+ const testFiles = glob.sync('__tests__/**/*.test.ts', {
45
+ cwd: akinonNextPath,
46
+ absolute: true
47
+ });
48
+
49
+ const jestArgs = [
50
+ ...testFiles,
51
+ `--config ${path.join(akinonNextPath, 'jest.config.js')}`,
52
+ '--runTestsByPath',
53
+ '--passWithNoTests'
54
+ ];
55
+
56
+ const jestProcess = spawn(jestPath, jestArgs, {
57
+ cwd: akinonNextPath,
58
+ stdio: 'inherit',
59
+ shell: true
60
+ });
61
+
62
+ jestProcess.on('close', (code) => {
63
+ process.exit(code);
64
+ });
package/jest.config.js ADDED
@@ -0,0 +1,19 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'node',
6
+ rootDir: path.resolve(__dirname),
7
+ roots: [path.resolve(__dirname, '__tests__')],
8
+ testMatch: ['**/*.test.ts'],
9
+ testPathIgnorePatterns: [],
10
+ transformIgnorePatterns: [],
11
+ transform: {
12
+ '^.+\\.(tsx?|jsx?|mjs?)$': [
13
+ 'ts-jest',
14
+ {
15
+ tsconfig: path.resolve(__dirname, '__tests__/tsconfig.json')
16
+ }
17
+ ]
18
+ }
19
+ };
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.89.0-rc.3",
4
+ "version": "1.89.0-rc.4",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -13,6 +13,9 @@
13
13
  "pz-predev": "bin/pz-predev.js",
14
14
  "pz-postdev": "bin/pz-postdev.js"
15
15
  },
16
+ "scripts": {
17
+ "test": "jest"
18
+ },
16
19
  "dependencies": {
17
20
  "@opentelemetry/exporter-trace-otlp-http": "0.46.0",
18
21
  "@opentelemetry/resources": "1.19.0",
@@ -31,13 +34,21 @@
31
34
  "set-cookie-parser": "2.6.0"
32
35
  },
33
36
  "devDependencies": {
34
- "@akinon/eslint-plugin-projectzero": "1.89.0-rc.3",
37
+ "@akinon/eslint-plugin-projectzero": "1.89.0-rc.4",
38
+ "@babel/core": "7.26.10",
39
+ "@babel/preset-env": "7.26.9",
40
+ "@babel/preset-typescript": "7.27.0",
41
+ "@types/jest": "29.5.14",
35
42
  "@types/react-redux": "7.1.30",
36
43
  "@types/set-cookie-parser": "2.4.7",
37
44
  "@typescript-eslint/eslint-plugin": "6.7.4",
38
45
  "@typescript-eslint/parser": "6.7.4",
46
+ "babel-jest": "29.7.0",
39
47
  "eslint": "8.56.0",
40
48
  "eslint-config-next": "14.2.3",
41
- "eslint-config-prettier": "8.5.0"
49
+ "eslint-config-prettier": "8.5.0",
50
+ "jest": "29.7.0",
51
+ "ts-jest": "29.3.2",
52
+ "typescript": "5.2.2"
42
53
  }
43
54
  }