@akanjs/config 0.0.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/README.md +11 -0
- package/index.d.ts +1 -0
- package/index.js +27 -0
- package/package.json +76 -0
- package/src/PageAgent.d.ts +13 -0
- package/src/PageAgent.js +67 -0
- package/src/PageAgent.ts +42 -0
- package/src/jest.config.base.d.ts +2 -0
- package/src/jest.config.base.js +49 -0
- package/src/jest.config.base.ts +25 -0
- package/src/jest.globalSetup.d.ts +4 -0
- package/src/jest.globalSetup.js +38 -0
- package/src/jest.globalSetup.ts +27 -0
- package/src/jest.globalTeardown.d.ts +3 -0
- package/src/jest.globalTeardown.js +30 -0
- package/src/jest.globalTeardown.ts +12 -0
- package/src/jest.preset.js +3 -0
- package/src/jest.setupFilesAfterEnv.d.ts +1 -0
- package/src/jest.setupFilesAfterEnv.js +10 -0
- package/src/jest.setupFilesAfterEnv.ts +17 -0
- package/src/next.base.js +127 -0
- package/src/playwright.config.base.d.ts +9 -0
- package/src/playwright.config.base.js +80 -0
- package/src/playwright.config.base.ts +71 -0
- package/src/tailwind.base.js +351 -0
- package/src/testServer.d.ts +12 -0
- package/src/testServer.js +139 -0
- package/src/testServer.ts +105 -0
- package/src/tsconfig.backend.json +24 -0
- package/src/webpack.backend.base.js +42 -0
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const config = true;
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var config_exports = {};
|
|
19
|
+
__export(config_exports, {
|
|
20
|
+
config: () => config
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(config_exports);
|
|
23
|
+
const config = true;
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
config
|
|
27
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@akanjs/config",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/akan-team/akanjs.git",
|
|
11
|
+
"directory": "pkgs/@akanjs/config"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@apollo/server": "4.11.2",
|
|
15
|
+
"@inquirer/prompts": "7.2.1",
|
|
16
|
+
"@nestjs/apollo": "12.2.2",
|
|
17
|
+
"@nestjs/bull": "10.2.3",
|
|
18
|
+
"@nestjs/common": "10.4.15",
|
|
19
|
+
"@nestjs/core": "10.4.15",
|
|
20
|
+
"@nestjs/graphql": "12.2.2",
|
|
21
|
+
"@nestjs/mongoose": "10.1.0",
|
|
22
|
+
"@nestjs/passport": "10.0.3",
|
|
23
|
+
"@nestjs/platform-express": "10.4.15",
|
|
24
|
+
"@nestjs/platform-socket.io": "10.4.15",
|
|
25
|
+
"@nestjs/schedule": "4.1.2",
|
|
26
|
+
"@nestjs/websockets": "10.4.15",
|
|
27
|
+
"@next/bundle-analyzer": "15.1.3",
|
|
28
|
+
"@nx/next": "20.4.0",
|
|
29
|
+
"@socket.io/redis-adapter": "8.3.0",
|
|
30
|
+
"@tailwindcss/container-queries": "0.1.1",
|
|
31
|
+
"@tailwindcss/typography": "0.5.15",
|
|
32
|
+
"@urql/core": "5.1.0",
|
|
33
|
+
"apple-signin": "1.0.9",
|
|
34
|
+
"body-parser": "1.20.3",
|
|
35
|
+
"bull": "4.16.5",
|
|
36
|
+
"class-transformer": "0.5.1",
|
|
37
|
+
"class-validator": "0.14.1",
|
|
38
|
+
"cookie-parser": "1.4.7",
|
|
39
|
+
"dataloader": "2.2.3",
|
|
40
|
+
"dayjs": "1.11.13",
|
|
41
|
+
"dotenv": "16.4.7",
|
|
42
|
+
"express": "4.21.2",
|
|
43
|
+
"graphql": "16.10.0",
|
|
44
|
+
"graphql-type-json": "0.3.2",
|
|
45
|
+
"graphql-upload": "12.0.0",
|
|
46
|
+
"iap": "1.1.1",
|
|
47
|
+
"immer": "10.1.1",
|
|
48
|
+
"jsonwebtoken": "9.0.2",
|
|
49
|
+
"lodash": "4.17.21",
|
|
50
|
+
"meilisearch": "0.47.0",
|
|
51
|
+
"mongoose": "8.9.3",
|
|
52
|
+
"next": "15.1.3",
|
|
53
|
+
"next-pwa": "5.6.0",
|
|
54
|
+
"passport": "0.7.0",
|
|
55
|
+
"passport-apple": "2.0.2",
|
|
56
|
+
"passport-facebook": "3.0.0",
|
|
57
|
+
"passport-github": "1.1.0",
|
|
58
|
+
"passport-google-oauth20": "2.0.0",
|
|
59
|
+
"passport-kakao": "1.0.1",
|
|
60
|
+
"passport-naver": "1.0.6",
|
|
61
|
+
"picocolors": "1.1.1",
|
|
62
|
+
"pluralize": "8.0.0",
|
|
63
|
+
"react": "18.2.0",
|
|
64
|
+
"react-dom": "18.2.0",
|
|
65
|
+
"redis": "4.7.0",
|
|
66
|
+
"reflect-metadata": "0.2.2",
|
|
67
|
+
"rxjs": "7.8.1",
|
|
68
|
+
"socket.io": "4.8.1",
|
|
69
|
+
"socket.io-client": "4.8.1",
|
|
70
|
+
"tailwindcss": "3.4.17",
|
|
71
|
+
"tailwindcss-radix": "3.0.5",
|
|
72
|
+
"tunnel-ssh": "5.2.0",
|
|
73
|
+
"ua-parser-js": "1.0.40"
|
|
74
|
+
},
|
|
75
|
+
"main": "./index.js"
|
|
76
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Page } from "@playwright/test";
|
|
2
|
+
import { test } from "@playwright/test";
|
|
3
|
+
export { expect } from "@playwright/test";
|
|
4
|
+
export { test };
|
|
5
|
+
export declare class PageAgent {
|
|
6
|
+
#private;
|
|
7
|
+
readonly page: Page;
|
|
8
|
+
constructor(page: Page);
|
|
9
|
+
goto(path: string): Promise<void>;
|
|
10
|
+
waitForPathChange(path?: string): Promise<unknown>;
|
|
11
|
+
wait(ms?: number): Promise<void>;
|
|
12
|
+
url(): string;
|
|
13
|
+
}
|
package/src/PageAgent.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var PageAgent_exports = {};
|
|
19
|
+
__export(PageAgent_exports, {
|
|
20
|
+
PageAgent: () => PageAgent,
|
|
21
|
+
expect: () => import_test3.expect,
|
|
22
|
+
test: () => import_test2.test
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(PageAgent_exports);
|
|
25
|
+
var import_test2 = require("@playwright/test");
|
|
26
|
+
var import_test3 = require("@playwright/test");
|
|
27
|
+
class PageAgent {
|
|
28
|
+
page;
|
|
29
|
+
#defaultWaitMs = 500;
|
|
30
|
+
#isInitialized = false;
|
|
31
|
+
constructor(page) {
|
|
32
|
+
this.page = page;
|
|
33
|
+
}
|
|
34
|
+
async goto(path) {
|
|
35
|
+
await Promise.all([this.page.goto(path), this.waitForPathChange(path)]);
|
|
36
|
+
if (!this.#isInitialized) {
|
|
37
|
+
this.#isInitialized = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async waitForPathChange(path) {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const timeout = setTimeout(() => {
|
|
43
|
+
reject(new Error("Timeout waiting for pathChange message"));
|
|
44
|
+
}, 3e4);
|
|
45
|
+
this.page.on("console", (msg) => {
|
|
46
|
+
if (msg.type() === "log" && msg.text().startsWith(`%cpathChange-finished:${path ?? ""}`)) {
|
|
47
|
+
clearInterval(timeout);
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
resolve(true);
|
|
50
|
+
}, this.#defaultWaitMs);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async wait(ms = this.#defaultWaitMs) {
|
|
56
|
+
await this.page.waitForTimeout(ms);
|
|
57
|
+
}
|
|
58
|
+
url() {
|
|
59
|
+
return "/" + this.page.url().split("/").slice(4).join("/");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
PageAgent,
|
|
65
|
+
expect,
|
|
66
|
+
test
|
|
67
|
+
});
|
package/src/PageAgent.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Page } from "@playwright/test";
|
|
2
|
+
import { test } from "@playwright/test";
|
|
3
|
+
|
|
4
|
+
export { expect } from "@playwright/test";
|
|
5
|
+
export { test };
|
|
6
|
+
|
|
7
|
+
export class PageAgent {
|
|
8
|
+
readonly page: Page;
|
|
9
|
+
readonly #defaultWaitMs = 500;
|
|
10
|
+
#isInitialized = false;
|
|
11
|
+
constructor(page: Page) {
|
|
12
|
+
this.page = page;
|
|
13
|
+
}
|
|
14
|
+
async goto(path: string) {
|
|
15
|
+
await Promise.all([this.page.goto(path), this.waitForPathChange(path)]);
|
|
16
|
+
if (!this.#isInitialized) {
|
|
17
|
+
// await this.page.waitForEvent("websocket");
|
|
18
|
+
this.#isInitialized = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async waitForPathChange(path?: string) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const timeout = setTimeout(() => {
|
|
24
|
+
reject(new Error("Timeout waiting for pathChange message"));
|
|
25
|
+
}, 30000);
|
|
26
|
+
this.page.on("console", (msg) => {
|
|
27
|
+
if (msg.type() === "log" && msg.text().startsWith(`%cpathChange-finished:${path ?? ""}`)) {
|
|
28
|
+
clearInterval(timeout);
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
resolve(true);
|
|
31
|
+
}, this.#defaultWaitMs);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async wait(ms = this.#defaultWaitMs) {
|
|
37
|
+
await this.page.waitForTimeout(ms);
|
|
38
|
+
}
|
|
39
|
+
url() {
|
|
40
|
+
return "/" + this.page.url().split("/").slice(4).join("/");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var jest_config_base_exports = {};
|
|
19
|
+
__export(jest_config_base_exports, {
|
|
20
|
+
withBase: () => withBase
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(jest_config_base_exports);
|
|
23
|
+
var import_dotenv = require("dotenv");
|
|
24
|
+
const withBase = (name) => {
|
|
25
|
+
(0, import_dotenv.config)();
|
|
26
|
+
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
27
|
+
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
28
|
+
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
29
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
30
|
+
return {
|
|
31
|
+
displayName: name,
|
|
32
|
+
preset: "../../pkgs/@akanjs/config/src/jest.preset.js",
|
|
33
|
+
globalSetup: "../../pkgs/@akanjs/config/src/jest.globalSetup.ts",
|
|
34
|
+
setupFilesAfterEnv: ["../../pkgs/@akanjs/config/src/jest.setupFilesAfterEnv.ts"],
|
|
35
|
+
globalTeardown: "../../pkgs/@akanjs/config/src/jest.globalTeardown.ts",
|
|
36
|
+
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
37
|
+
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
38
|
+
maxWorkers: 1,
|
|
39
|
+
transform: {
|
|
40
|
+
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
41
|
+
},
|
|
42
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
43
|
+
coverageDirectory: `../../coverage/libs/${name}`
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
withBase
|
|
49
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Config } from "@jest/types";
|
|
2
|
+
import { config } from "dotenv";
|
|
3
|
+
|
|
4
|
+
export const withBase = (name: string): Config.InitialOptions => {
|
|
5
|
+
config();
|
|
6
|
+
process.env.NEXT_PUBLIC_ENV = "testing";
|
|
7
|
+
process.env.NEXT_PUBLIC_OPERATION_MODE = "local";
|
|
8
|
+
process.env.NEXT_PUBLIC_APP_NAME = name;
|
|
9
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
10
|
+
return {
|
|
11
|
+
displayName: name,
|
|
12
|
+
preset: "../../pkgs/@akanjs/config/src/jest.preset.js",
|
|
13
|
+
globalSetup: "../../pkgs/@akanjs/config/src/jest.globalSetup.ts",
|
|
14
|
+
setupFilesAfterEnv: ["../../pkgs/@akanjs/config/src/jest.setupFilesAfterEnv.ts"],
|
|
15
|
+
globalTeardown: "../../pkgs/@akanjs/config/src/jest.globalTeardown.ts",
|
|
16
|
+
testMatch: ["**/?(*.)+(test).ts?(x)"],
|
|
17
|
+
testPathIgnorePatterns: ["/node_modules/", "/app/"],
|
|
18
|
+
maxWorkers: 1,
|
|
19
|
+
transform: {
|
|
20
|
+
"signal\\.(test)\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }],
|
|
21
|
+
},
|
|
22
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
23
|
+
coverageDirectory: `../../coverage/libs/${name}`,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var jest_globalSetup_exports = {};
|
|
19
|
+
__export(jest_globalSetup_exports, {
|
|
20
|
+
default: () => jest_globalSetup_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(jest_globalSetup_exports);
|
|
23
|
+
var import_register = require("tsconfig-paths/register");
|
|
24
|
+
var import_testServer = require("./testServer");
|
|
25
|
+
const setup = async (globalConfig, projectConfig) => {
|
|
26
|
+
const { env } = require(`${globalConfig.rootDir}/env/env.server.testing`);
|
|
27
|
+
const { fetch, registerModules } = require(`${globalConfig.rootDir}/server`);
|
|
28
|
+
const maxWorkers = globalConfig.maxWorkers;
|
|
29
|
+
if (!maxWorkers)
|
|
30
|
+
throw new Error("maxWorkers is not defined");
|
|
31
|
+
const testServers = new Array(maxWorkers).fill(0).map((_, idx) => new import_testServer.TestServer(registerModules, env, idx + 1));
|
|
32
|
+
await Promise.all(testServers.map((server) => server.init()));
|
|
33
|
+
global.__TEST_SERVERS__ = testServers;
|
|
34
|
+
global.fetch = fetch;
|
|
35
|
+
global.env = env;
|
|
36
|
+
global.registerModules = registerModules;
|
|
37
|
+
};
|
|
38
|
+
var jest_globalSetup_default = setup;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
+
|
|
4
|
+
import "tsconfig-paths/register";
|
|
5
|
+
|
|
6
|
+
import type { BackendEnv } from "@akanjs/base";
|
|
7
|
+
import type { Config } from "@jest/types";
|
|
8
|
+
import type { DynamicModule } from "@nestjs/common";
|
|
9
|
+
|
|
10
|
+
import { TestServer } from "./testServer";
|
|
11
|
+
|
|
12
|
+
const setup = async (globalConfig: Config.InitialOptions, projectConfig) => {
|
|
13
|
+
const { env } = require(`${globalConfig.rootDir}/env/env.server.testing`);
|
|
14
|
+
const { fetch, registerModules } = require(`${globalConfig.rootDir}/server`);
|
|
15
|
+
const maxWorkers = globalConfig.maxWorkers;
|
|
16
|
+
if (!maxWorkers) throw new Error("maxWorkers is not defined");
|
|
17
|
+
const testServers = new Array(maxWorkers)
|
|
18
|
+
.fill(0)
|
|
19
|
+
.map((_, idx) => new TestServer(registerModules as (options: any) => DynamicModule[], env as BackendEnv, idx + 1));
|
|
20
|
+
await Promise.all(testServers.map((server) => server.init()));
|
|
21
|
+
global.__TEST_SERVERS__ = testServers;
|
|
22
|
+
global.fetch = fetch;
|
|
23
|
+
global.env = env;
|
|
24
|
+
global.registerModules = registerModules;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default setup;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var jest_globalTeardown_exports = {};
|
|
19
|
+
__export(jest_globalTeardown_exports, {
|
|
20
|
+
default: () => jest_globalTeardown_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(jest_globalTeardown_exports);
|
|
23
|
+
var import_register = require("tsconfig-paths/register");
|
|
24
|
+
const teardown = async (globalConfig, projectConfig) => {
|
|
25
|
+
const testServers = global.__TEST_SERVERS__;
|
|
26
|
+
if (!testServers)
|
|
27
|
+
throw new Error("Test servers are not defined");
|
|
28
|
+
await Promise.all(testServers.map((server) => server.terminate()));
|
|
29
|
+
};
|
|
30
|
+
var jest_globalTeardown_default = teardown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
import "tsconfig-paths/register";
|
|
3
|
+
|
|
4
|
+
import { TestServer } from "./testServer";
|
|
5
|
+
|
|
6
|
+
const teardown = async (globalConfig, projectConfig) => {
|
|
7
|
+
const testServers: TestServer[] | undefined = global.__TEST_SERVERS__;
|
|
8
|
+
if (!testServers) throw new Error("Test servers are not defined");
|
|
9
|
+
await Promise.all(testServers.map((server) => server.terminate()));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default teardown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var import_testServer = require("./testServer");
|
|
2
|
+
const { env, fetch } = global;
|
|
3
|
+
jest.setTimeout(3e4);
|
|
4
|
+
global.beforeAll(async () => {
|
|
5
|
+
import_testServer.TestServer.initClient(env);
|
|
6
|
+
await fetch.cleanup();
|
|
7
|
+
});
|
|
8
|
+
global.afterAll(async () => {
|
|
9
|
+
await fetch.client.terminate();
|
|
10
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
+
import type { BackendEnv } from "@akanjs/base";
|
|
5
|
+
|
|
6
|
+
import { TestServer } from "./testServer";
|
|
7
|
+
|
|
8
|
+
const { env, fetch } = global as any;
|
|
9
|
+
jest.setTimeout(30000);
|
|
10
|
+
global.beforeAll(async () => {
|
|
11
|
+
TestServer.initClient(env as BackendEnv);
|
|
12
|
+
await fetch.cleanup();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
global.afterAll(async () => {
|
|
16
|
+
await fetch.client.terminate();
|
|
17
|
+
});
|
package/src/next.base.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const { composePlugins, withNx } = require("@nx/next");
|
|
2
|
+
const withAnalyze = require("@next/bundle-analyzer")({ enabled: process.env.ANALYZE === "true" });
|
|
3
|
+
const runtimeCaching = require("next-pwa/cache");
|
|
4
|
+
const commandType = process.env.NX_TASK_TARGET_TARGET?.includes("serve")
|
|
5
|
+
? "serve"
|
|
6
|
+
: process.env.NX_TASK_TARGET_TARGET?.includes("build")
|
|
7
|
+
? "build"
|
|
8
|
+
: "deploy";
|
|
9
|
+
const withPWA = require("next-pwa")({
|
|
10
|
+
dest: "public",
|
|
11
|
+
register: true,
|
|
12
|
+
skipWaiting: true,
|
|
13
|
+
runtimeCaching,
|
|
14
|
+
// disable: commandType === "serve",
|
|
15
|
+
});
|
|
16
|
+
const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
|
|
17
|
+
const libs = ["game", "mint", "platform", "social", "shared", "util"];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type { (config: import('@nx/next/plugins/with-nx').WithNxOptions) => import('@nx/next/plugins/with-nx').WithNxOptions }
|
|
21
|
+
**/
|
|
22
|
+
const withBase = (appName, config, routes = []) => {
|
|
23
|
+
return composePlugins(
|
|
24
|
+
withNx,
|
|
25
|
+
withAnalyze,
|
|
26
|
+
withPWA
|
|
27
|
+
// ...(commandType !== "serve" ? [withPWA] : [])
|
|
28
|
+
)({
|
|
29
|
+
...config,
|
|
30
|
+
env: {
|
|
31
|
+
...config.env,
|
|
32
|
+
basePaths: routes.map(({ basePath }) => basePath).join(","),
|
|
33
|
+
},
|
|
34
|
+
transpilePackages: ["swiper", "ssr-window", "dom7"],
|
|
35
|
+
reactStrictMode: commandType === "serve" ? false : true,
|
|
36
|
+
nx: { svgr: false },
|
|
37
|
+
modularizeImports: {
|
|
38
|
+
"react-icons/?(((\\w*)?/?)*)": {
|
|
39
|
+
transform: "@react-icons/all-files/{{ matches.[1] }}/{{member}}",
|
|
40
|
+
skipDefaultConversion: true,
|
|
41
|
+
},
|
|
42
|
+
lodash: { transform: "lodash/{{member}}", preventFullImport: true },
|
|
43
|
+
...Object.fromEntries(
|
|
44
|
+
[appName, ...libs].reduce(
|
|
45
|
+
(acc, lib) => [
|
|
46
|
+
...acc,
|
|
47
|
+
[`@${lib}/ui`, { transform: `@${lib}/ui/{{member}}`, skipDefaultConversion: true }],
|
|
48
|
+
[`@${lib}/next`, { transform: `@${lib}/next/{{member}}`, skipDefaultConversion: true }],
|
|
49
|
+
[`@${lib}/common`, { transform: `@${lib}/common/{{member}}`, skipDefaultConversion: true }],
|
|
50
|
+
[`@${lib}/client`, { transform: `@${lib}/lib/{{ camelCase member }}`, skipDefaultConversion: true }],
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
["@contract", { transform: `@contract/src/{{member}}`, skipDefaultConversion: true }],
|
|
54
|
+
[`@akanjs/next`, { transform: `@akanjs/next/{{member}}`, skipDefaultConversion: true }],
|
|
55
|
+
[`@akanjs/common`, { transform: `@akanjs/common/{{member}}`, skipDefaultConversion: true }],
|
|
56
|
+
]
|
|
57
|
+
)
|
|
58
|
+
),
|
|
59
|
+
...(config.modularizeImports ?? {}),
|
|
60
|
+
},
|
|
61
|
+
images: {
|
|
62
|
+
formats: ["image/avif", "image/webp"],
|
|
63
|
+
...(config.images ?? {}),
|
|
64
|
+
remotePatterns: [
|
|
65
|
+
...(config.images?.remotePatterns ?? []),
|
|
66
|
+
...routes
|
|
67
|
+
.map(({ domains }) => [
|
|
68
|
+
...(domains?.main?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
69
|
+
...(domains?.develop?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
70
|
+
...(domains?.debug?.map((domain) => ({ protocol: "https", hostname: `**.${domain}` })) ?? []),
|
|
71
|
+
])
|
|
72
|
+
.flat(),
|
|
73
|
+
{ protocol: "https", hostname: `**.${devDomain}` },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
webpack: (config) => {
|
|
77
|
+
// react-pdf error fix
|
|
78
|
+
config.resolve.alias.canvas = false;
|
|
79
|
+
config.resolve.alias.encoding = false;
|
|
80
|
+
return config;
|
|
81
|
+
},
|
|
82
|
+
async redirects() {
|
|
83
|
+
return routes
|
|
84
|
+
.map(({ basePath, domains }) => [
|
|
85
|
+
{ basePath, domain: `${basePath}-debug.${devDomain}` },
|
|
86
|
+
{ basePath, domain: `${basePath}-develop.${devDomain}` },
|
|
87
|
+
{ basePath, domain: `${basePath}-main.${devDomain}` },
|
|
88
|
+
...(domains?.main?.map((domain) => ({ basePath, domain })) ?? []),
|
|
89
|
+
...(domains?.develop?.map((domain) => ({ basePath, domain })) ?? []),
|
|
90
|
+
...(domains?.debug?.map((domain) => ({ basePath, domain })) ?? []),
|
|
91
|
+
])
|
|
92
|
+
.flat()
|
|
93
|
+
.map(({ basePath, domain }) => ({
|
|
94
|
+
source: `/:locale/${basePath}/:path*`,
|
|
95
|
+
has: [{ type: "host", value: domain }],
|
|
96
|
+
permanent: true,
|
|
97
|
+
destination: "/:locale/:path*",
|
|
98
|
+
}));
|
|
99
|
+
},
|
|
100
|
+
async rewrites() {
|
|
101
|
+
return routes
|
|
102
|
+
.map(({ basePath, domains }) => [
|
|
103
|
+
{ basePath, domain: `${basePath}-debug.${devDomain}` },
|
|
104
|
+
{ basePath, domain: `${basePath}-develop.${devDomain}` },
|
|
105
|
+
{ basePath, domain: `${basePath}-main.${devDomain}` },
|
|
106
|
+
...(domains?.main?.map((domain) => ({ basePath, domain })) ?? []),
|
|
107
|
+
...(domains?.develop?.map((domain) => ({ basePath, domain })) ?? []),
|
|
108
|
+
...(domains?.debug?.map((domain) => ({ basePath, domain })) ?? []),
|
|
109
|
+
])
|
|
110
|
+
.flat()
|
|
111
|
+
.map(({ basePath, domain }) => [
|
|
112
|
+
{
|
|
113
|
+
source: "/:locale",
|
|
114
|
+
has: [{ type: "host", value: domain }],
|
|
115
|
+
destination: `/:locale/${basePath}`,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
source: `/:locale/:path((?!${basePath}$)(?!admin(?:/|$)).*)`,
|
|
119
|
+
has: [{ type: "host", value: domain }],
|
|
120
|
+
destination: `/:locale/${basePath}/:path*`,
|
|
121
|
+
},
|
|
122
|
+
])
|
|
123
|
+
.flat();
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
module.exports = { withBase };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PlaywrightTestConfig } from "@playwright/test";
|
|
2
|
+
/**
|
|
3
|
+
* Read environment variables from file.
|
|
4
|
+
* https://github.com/motdotla/dotenv
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare const withBase: (filename: string, config?: PlaywrightTestConfig) => PlaywrightTestConfig<{}, {}>;
|