create-jwn-js 1.0.21 → 1.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jwn-js",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "license": "PRIVATE",
5
5
  "author": "Webigorkiev",
6
6
  "bin": {
@@ -22,5 +22,19 @@
22
22
  "margv": "^1.1.2",
23
23
  "prompts": "^2.4.2"
24
24
  },
25
- "devDependencies": {}
25
+ "devDependencies": {
26
+ "@jwn-js/common": "^2.1.15",
27
+ "@types/memjs": "^1.3.3",
28
+ "@types/node": "18",
29
+ "buildmsql": "^1.6.9",
30
+ "chalk": "4",
31
+ "cross-fetch": "3",
32
+ "easy-ash": "^1.1.14",
33
+ "jsdom": "^24.0.0",
34
+ "memjs": "^1.3.2",
35
+ "typescript": "^5.3.3",
36
+ "vite": "4",
37
+ "vitepress": "0.22.4",
38
+ "vitest": "^1.2.2"
39
+ }
26
40
  }
@@ -4,13 +4,22 @@
4
4
  "mode": "development",
5
5
  "https": false,
6
6
  "port": 3000,
7
- "host": "localhost"
7
+ "host": "localhost",
8
+ "url": "http://127.0.0.1"
8
9
  },
9
10
  "production": {
10
11
  "mode": "production",
12
+ "https": false,
11
13
  "port": 3000,
12
14
  "host": "127.0.0.1",
13
15
  "url": "http://127.0.0.1"
16
+ },
17
+ "test": {
18
+ "mode": "development",
19
+ "https": false,
20
+ "port": 3000,
21
+ "host": "localhost",
22
+ "url": "http://127.0.0.1"
14
23
  }
15
24
  },
16
25
  "db": {
@@ -7,27 +7,30 @@
7
7
  "main": "./index.ts",
8
8
  "scripts": {
9
9
  "dev": "vite",
10
+ "serve": "vite",
10
11
  "build": "vite build",
11
12
  "test": "vitest run",
13
+ "test:production": "vitest run -c vitest.config.production.ts",
12
14
  "docs:dev": "vitepress dev docs",
13
15
  "docs:build": "vitepress build docs",
14
16
  "docs:serve": "vitepress serve docs"
15
17
  },
16
18
  "devDependencies": {
17
- "@types/memjs": "^1.3.0",
18
- "@types/node": "^20.2.5",
19
- "typescript": "^5.1.3",
20
- "vite": "^4.3.9",
21
- "vitepress": "^1.0.0-beta.1",
22
- "vitest": "^0.32.0"
19
+ "@types/memjs": "^1.2.4",
20
+ "@types/node": "18",
21
+ "typescript": "^5.3.3",
22
+ "vite": "4",
23
+ "vitest": "^1.2.2",
24
+ "vitepress": "0.22.4",
25
+ "jsdom": "^24.0.0",
26
+ "chalk": "4"
23
27
  },
24
28
  "dependencies": {
25
- "@jwn-js/common": "^2.0.7",
26
- "buildmsql": "^1.3.2",
27
- "cross-fetch": "^3.1.4",
28
- "easy-ash": "^1.1.5",
29
- "margv": "^1.1.2",
30
- "mariadb": "^3.1.2",
31
- "memjs": "^1.3.0"
29
+ "@jwn-js/common": "2.1.15",
30
+ "buildmsql": "1.6.9",
31
+ "cross-fetch": "3",
32
+ "easy-ash": "1.1.14",
33
+ "margv": "1.1.2",
34
+ "memjs": "1.3.2"
32
35
  }
33
36
  }
@@ -5,8 +5,9 @@ const args = margv();
5
5
  * Config for server
6
6
  * @param config
7
7
  */
8
- export const createConfigServer = (config: Record<string, any>) => {
9
- const configServer = process.env.NODE_ENV === "production" ? config.server.production : config.server.development;
8
+ export const createConfigServer = (config: Record<string, any>, nodeEnv?: "development"|"production"|"test") => {
9
+ const env = (nodeEnv || process.env.NODE_ENV || "development") as "development"|"production"|"test";
10
+ const configServer = config.server[env];
10
11
 
11
12
  configServer.https = args.https ?? configServer.https;
12
13
  configServer.protocol = configServer.https ? "https" : "http";
@@ -1,8 +1,14 @@
1
1
  import crossFetch from "cross-fetch";
2
+ // @ts-ignore
2
3
  import config from "../../connect.json";
4
+ <<<<<<< HEAD:template-vite-node-ts/src/scripts/test.setup.ts
5
+ import {createConfigServer} from "../../src/backend/server/helpers/createConfigServer";
6
+ const cnf = createConfigServer(config, process.env.TEST_MODE_APP as "test");
7
+ =======
3
8
  import {createConfigServer} from "@/backend/server/helpers/createConfigServer";
4
9
  const cnf = createConfigServer(config);
5
10
 
11
+ >>>>>>> ad324504e6d98d4d9229b45f1d428d8a9ce37811:template-vite-node-ts/src/scripts/test.config.ts
6
12
  const apiUrl = `${cnf.protocol}://${cnf.host}:${cnf.port}`;
7
13
  const defaultHeaders = {
8
14
  headers: {
@@ -0,0 +1,24 @@
1
+ import crossFetch from "cross-fetch";
2
+ // @ts-ignore
3
+ import config from "../../connect.json";
4
+ <<<<<<< HEAD:template-vite-node-ts/src/scripts/test.setup.ts
5
+ import {createConfigServer} from "../../src/backend/server/helpers/createConfigServer";
6
+ const cnf = createConfigServer(config, process.env.TEST_MODE_APP as "test");
7
+ =======
8
+ import {createConfigServer} from "@/backend/server/helpers/createConfigServer";
9
+ const cnf = createConfigServer(config);
10
+
11
+ >>>>>>> ad324504e6d98d4d9229b45f1d428d8a9ce37811:template-vite-node-ts/src/scripts/test.config.ts
12
+ const apiUrl = `${cnf.protocol}://${cnf.host}:${cnf.port}`;
13
+ const defaultHeaders = {
14
+ headers: {
15
+ "user-agent": "fetch-tests",
16
+ "content-type": "application/json"
17
+ }
18
+ }
19
+ const fetch = async(
20
+ input: RequestInfo,
21
+ init: RequestInit = {}
22
+ ) => crossFetch(input, Object.assign({}, defaultHeaders, init));
23
+
24
+ export {fetch, apiUrl};
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "types": [
25
25
  "vite/client",
26
- "node"
26
+ "node",
27
27
  ],
28
28
  "baseUrl": ".",
29
29
  "paths": {
@@ -33,9 +33,11 @@
33
33
  }
34
34
  },
35
35
  "include": [
36
- "./node_modules/vitest/globals.d.ts",
37
- "./src/**/*.ts",
38
- "./src/**/*.d.ts",
36
+ "src/**/*.ts",
37
+ "src/**/*.d.ts",
38
+ "src/**/*.tsx",
39
+ "src/**/*.vue",
40
+ "node_modules/vitest/globals.d.ts"
39
41
  ],
40
42
  "exclude": [
41
43
  "dist"
@@ -1,12 +1,13 @@
1
1
  import * as path from "path";
2
+ import chalk from "chalk";
2
3
  import {build, defineConfig, mergeConfig, Plugin, ResolvedConfig} from "vite";
3
4
  import fetch from "cross-fetch";
4
-
5
- //@ts-ignore
5
+ // @ts-ignore
6
6
  import config from "./connect.json";
7
7
  import {createConfigServer} from "./src/backend/server/helpers/createConfigServer";
8
8
  import {createMemcached} from "./src/backend/server/helpers/createMemcached";
9
9
  import {createMariadb} from "./src/backend/server/helpers/createMariadb";
10
+ import {performance} from "perf_hooks";
10
11
 
11
12
  declare var process: any;
12
13
  interface Options {
@@ -28,6 +29,19 @@ const node = (opt: Options): Plugin => {
28
29
  });
29
30
  },
30
31
  async configResolved(config:ResolvedConfig) {
32
+ const time = performance.now();
33
+ const start = async(resolve: CallableFunction) => {
34
+ try {
35
+ await fetch(`${cnf.protocol}://${cnf.host}:${cnf.port}/start-server`);
36
+ const interval = Math.round((performance.now() - time)/10)/100;
37
+ console.log(chalk.green('dev server running for ') + chalk.red(`${interval}s`) + chalk.green(' at:'));
38
+ console.log(`${cnf.protocol}://${cnf.host}:${cnf.port}`);
39
+ resolve();
40
+ } catch(e: any) {
41
+ await start(resolve);
42
+ }
43
+ };
44
+
31
45
  if(config.command === "build") {
32
46
 
33
47
  // @ts-ignore
@@ -49,22 +63,15 @@ const node = (opt: Options): Plugin => {
49
63
  memcached,
50
64
  memcachedClient
51
65
  };
52
-
53
- const start = async(resolve: CallableFunction) => {
54
- try {
55
- await fetch(`${cnf.protocol}://${cnf.host}:${cnf.port}/start-server`);
56
- resolve();
57
- } catch(e: any) {
58
- await start(resolve);
59
- }
60
- };
66
+ console.log();
67
+ console.log(chalk.green('dev server starting...'));
61
68
  new Promise(resolve => start(resolve));
62
69
  }
63
70
  },
64
71
  async closeBundle() {
65
72
  process.server?.memcachedClient && process.server.memcachedClient.close();
66
73
  process.server?.db?.home && await process.server.db.home.end();
67
- process.server.app && await process.server.app.close();
74
+ process.server?.app && await process.server.app.close();
68
75
  }
69
76
  }
70
77
  }
@@ -0,0 +1,41 @@
1
+ /// <reference types="vitest" />
2
+ import path from 'node:path';
3
+ import {defineConfig} from 'vitest/config';
4
+ import vue from '@vitejs/plugin-vue';
5
+
6
+ process.env.TEST_MODE_APP = "production";
7
+
8
+ export default defineConfig({
9
+ resolve: {
10
+ alias: [
11
+ {
12
+ find: /^~(.+)/,
13
+ replacement: path.resolve('./node_modules') + '/$1',
14
+ },
15
+ {
16
+ find: /@\/(.*)/,
17
+ replacement: path.resolve('./src') + '/$1',
18
+ },
19
+ ],
20
+ },
21
+ plugins: [
22
+ //@ts-ignore
23
+ vue(),
24
+ ],
25
+ test: {
26
+ root: "./",
27
+ include: ["**/__its__/**/*.[jt]s?(x)"],
28
+ exclude: ["**/node_modules/**", "./src/certs/**", "./src/scripts/**", "./src/sql/**", "./src/estimation-client/**"],
29
+ environment: "jsdom",
30
+ globals: true,
31
+ testTimeout: 15000,
32
+ hookTimeout: 15000,
33
+ // @ts-ignore
34
+ singleThread: true,
35
+ poolOptions: {
36
+ threads: {
37
+ singleThread: true
38
+ }
39
+ }
40
+ }
41
+ });
@@ -1,19 +1,43 @@
1
- import {defineConfig} from "vitest/config";
2
- import * as path from "path";
1
+ /// <reference types="vitest" />
2
+ import path from 'node:path';
3
+ import { defineConfig } from 'vitest/config';
4
+ import vue from '@vitejs/plugin-vue';
5
+
6
+ process.env.TEST_MODE_APP = "test";
3
7
 
4
8
  export default defineConfig({
5
- resolve: {
6
- alias: [
7
- {
8
- find: /^~(.+)/,
9
- replacement: path.resolve("./node_modules") + "/$1"
10
- },
11
- {
12
- find: /@\/(.*)/,
13
- replacement: path.resolve("./src") + "/$1"
14
- }
15
- ],
16
- },
17
- plugins: [
18
- ]
19
- });
9
+ resolve: {
10
+ alias: [
11
+ {
12
+ find: /^~(.+)/,
13
+ replacement: path.resolve('./node_modules') + '/$1',
14
+ },
15
+ {
16
+ find: /@\/(.*)/,
17
+ replacement: path.resolve('./src') + '/$1',
18
+ },
19
+ ],
20
+ },
21
+ plugins: [
22
+ //@ts-ignore
23
+ vue(),
24
+ ],
25
+ test: {
26
+ root: "./",
27
+ include: ["**/__its__/**/*.[jt]s?(x)", "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
28
+ exclude: ["**/node_modules/**", "./src/certs/**", "./src/scripts/**", "./src/sql/**", "./src/estimation-client/**"],
29
+ environment: "jsdom",
30
+ globals: true,
31
+ globalSetup: ["./src/scripts/vitest.global.setup.ts"],
32
+ testTimeout: 15000,
33
+ hookTimeout: 15000,
34
+ // threads: false
35
+ // @ts-ignore
36
+ singleThread: true,
37
+ poolOptions: {
38
+ threads: {
39
+ singleThread: true
40
+ }
41
+ }
42
+ },
43
+ });
@@ -1,34 +0,0 @@
1
- {
2
- "server": {
3
- "development": {
4
- "mode": "development",
5
- "https": false,
6
- "port": 3000,
7
- "host": "localhost"
8
- },
9
- "production": {
10
- "mode": "production",
11
- "port": 3000,
12
- "host": "127.0.0.1",
13
- "url": "http://127.0.0.1"
14
- }
15
- },
16
- "db": {
17
- "home": {
18
- "engine": "mysql",
19
- "host": "localhost",
20
- "user": "",
21
- "password": "",
22
- "database": "",
23
- "connectTimeout": 10000,
24
- "acquireTimeout": 10000,
25
- "connectionLimit": 2,
26
- "charset": "utf8",
27
- "compress": true,
28
- "port": 3306,
29
- "multipleStatements": true,
30
- "namedPlaceholders": true,
31
- "dateStrings": true
32
- }
33
- }
34
- }
@@ -1,37 +0,0 @@
1
- export default {
2
- moduleFileExtensions: [
3
- "js",
4
- "ts",
5
- "json",
6
- "vue",
7
- "node"
8
- ],
9
- transform: {
10
- "^.+\\.ts$": "ts-jest"
11
- },
12
- moduleNameMapper: {
13
- "@/(.*)$": "<rootDir>/src/$1"
14
- },
15
- setupFiles: ["./src/scripts/jest.setup.ts"],
16
- globalSetup: "./src/scripts/jest.global.setup.ts",
17
- globalTeardown: "./src/scripts/jest.global.teardown.ts",
18
- testTimeout: 35000,
19
- globals: {
20
- 'ts-jest': {
21
- tsconfig: './tsconfig.json',
22
- diagnostics: false
23
- }
24
- },
25
- testEnvironment: "jsdom",
26
- maxWorkers: 2,
27
- testMatch: [ "**/__its__/**/*.[jt]s?(x)", "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ],
28
- testPathIgnorePatterns: ["<rootDir>/src/scripts",],
29
- collectCoverageFrom: [
30
- "**/src/**/*.{ts}",
31
- "!**/src/**/*.d.ts",
32
- "!**/src/**/index.ts",
33
- "!**/src/scripts/**",
34
- "!**/src/sql/**",
35
- "!**/src/backend/server/web-routes/**",
36
- ]
37
- };
@@ -1,20 +0,0 @@
1
- import {defineWorkspace} from "vitest/config";
2
-
3
- export default defineWorkspace([
4
-
5
- {
6
- extends: "./vitest.config.ts",
7
- test: {
8
- name: 'node-main',
9
- root: "./src",
10
- include: ["**/__its__/**/*.[jt]s?(x)", "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
11
- exclude: ["**/node_modules/**", "./src/certs/**", "./src/scripts/**", "./src/sql/**", "./src/estimation-client/**"],
12
- environment: "node",
13
- globals: true,
14
- globalSetup: ["./src/scripts/vitest.global.setup.ts"],
15
- testTimeout: 15000,
16
- hookTimeout: 15000,
17
- threads: false
18
- },
19
- }
20
- ])