create-jwn-js 1.1.4 → 1.2.1

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.
Files changed (78) hide show
  1. package/index.mjs +5 -0
  2. package/package.json +1 -1
  3. package/template-lambda-http-api-mts/package.json +2 -2
  4. package/template-lambda-rest-api-mts/package.json +2 -2
  5. package/template-vite-node-mts/src/scripts/test.setup.mts +4 -3
  6. package/template-vite-vue3-mts/.nvmrc +1 -0
  7. package/template-vite-vue3-mts/.ws-context +9 -0
  8. package/template-vite-vue3-mts/CHANGELOG.md +3 -0
  9. package/template-vite-vue3-mts/{cron.mjs → cron.js} +8 -18
  10. package/template-vite-vue3-mts/package.json +6 -5
  11. package/template-vite-vue3-mts/src/backend/server/helpers/createMariadb.mts +1 -6
  12. package/template-vite-vue3-mts/src/backend/server/helpers/createMemcached.mts +0 -1
  13. package/template-vite-vue3-mts/src/backend/server/helpers/readJson5ConfigsSync.mts +0 -1
  14. package/template-vite-vue3-mts/src/backend/server/helpers/readManifest.mts +0 -5
  15. package/template-vite-vue3-mts/src/backend/server/index.mts +3 -3
  16. package/template-vite-vue3-mts/src/backend/server/site-schema.mts +1 -1
  17. package/template-vite-vue3-mts/src/backend/server/types.mts +3 -5
  18. package/template-vite-vue3-mts/src/frontend/routes/index.mts +3 -11
  19. package/template-vite-vue3-mts/src/frontend/store/fetch.mts +0 -1
  20. package/template-vite-vue3-mts/src/frontend/views/Index/Index.vue +1 -1
  21. package/template-vite-vue3-mts/tsconfig.json +8 -9
  22. package/template-vite-vue3-mts/yarn.lock +542 -127
  23. package/template-vite-vue3-pinia-mts/.gitignore +6 -0
  24. package/template-vite-vue3-pinia-mts/.nvmrc +1 -0
  25. package/template-vite-vue3-pinia-mts/.ws-context +9 -0
  26. package/template-vite-vue3-pinia-mts/CHANGELOG.md +3 -0
  27. package/template-vite-vue3-pinia-mts/common.json5 +28 -0
  28. package/template-vite-vue3-pinia-mts/connect.json5 +5 -0
  29. package/template-vite-vue3-pinia-mts/cron.mjs +115 -0
  30. package/template-vite-vue3-pinia-mts/dist/client/.vite/ssr-manifest.json +71 -0
  31. package/template-vite-vue3-pinia-mts/dist/client/assets/index-B8XEaJMM.css +1 -0
  32. package/template-vite-vue3-pinia-mts/dist/client/assets/index-DJNddzdM.js +224 -0
  33. package/template-vite-vue3-pinia-mts/dist/server/assets/IndexController-CrHs13mM.mjs +27 -0
  34. package/template-vite-vue3-pinia-mts/dist/server/entry-server.mjs +809 -0
  35. package/template-vite-vue3-pinia-mts/dist/server/package.json +11 -0
  36. package/template-vite-vue3-pinia-mts/index.html +18 -0
  37. package/template-vite-vue3-pinia-mts/index.mts +0 -0
  38. package/template-vite-vue3-pinia-mts/package.json +59 -0
  39. package/template-vite-vue3-pinia-mts/postcss.config.js +19 -0
  40. package/template-vite-vue3-pinia-mts/public/robots.txt +2 -0
  41. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/__tests__/helpers.spec.mts +51 -0
  42. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/__tests__/nameFormatters.spec.mts +14 -0
  43. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/createConfigServer.mts +14 -0
  44. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/createMariadb.mts +11 -0
  45. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/nameFormatters.mts +9 -0
  46. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/readJson5ConfigsSync.mts +10 -0
  47. package/template-vite-vue3-pinia-mts/src/backend/server/helpers/readManifest.mts +11 -0
  48. package/template-vite-vue3-pinia-mts/src/backend/server/index.mts +50 -0
  49. package/template-vite-vue3-pinia-mts/src/backend/server/site-schema.mts +21 -0
  50. package/template-vite-vue3-pinia-mts/src/backend/server/types.mts +5 -0
  51. package/template-vite-vue3-pinia-mts/src/backend/server/web-routes/index.mts +9 -0
  52. package/template-vite-vue3-pinia-mts/src/backend/views/Index/IndexController.mts +16 -0
  53. package/template-vite-vue3-pinia-mts/src/frontend/App.vue +25 -0
  54. package/template-vite-vue3-pinia-mts/src/frontend/css/breakpoints.css +6 -0
  55. package/template-vite-vue3-pinia-mts/src/frontend/css/index.css +38 -0
  56. package/template-vite-vue3-pinia-mts/src/frontend/css/reset.css +1 -0
  57. package/template-vite-vue3-pinia-mts/src/frontend/entry-client.mts +5 -0
  58. package/template-vite-vue3-pinia-mts/src/frontend/entry-options.mts +89 -0
  59. package/template-vite-vue3-pinia-mts/src/frontend/entry-server.mts +6 -0
  60. package/template-vite-vue3-pinia-mts/src/frontend/helpers/customerPrefetchPinia.mts +42 -0
  61. package/template-vite-vue3-pinia-mts/src/frontend/pinia/useBaseStore.mts +141 -0
  62. package/template-vite-vue3-pinia-mts/src/frontend/routes/index.mts +34 -0
  63. package/template-vite-vue3-pinia-mts/src/frontend/shims-plugins.d.mts +34 -0
  64. package/template-vite-vue3-pinia-mts/src/frontend/views/Error/Error.vue +66 -0
  65. package/template-vite-vue3-pinia-mts/src/frontend/views/Index/Index.vue +30 -0
  66. package/template-vite-vue3-pinia-mts/src/frontend/views/Index/__tests__/Index.spec.ts +29 -0
  67. package/template-vite-vue3-pinia-mts/src/frontend/vite-env.d.mts +1 -0
  68. package/template-vite-vue3-pinia-mts/src/helpers/langLink.mts +10 -0
  69. package/template-vite-vue3-pinia-mts/src/helpers/parseLang.mts +4 -0
  70. package/template-vite-vue3-pinia-mts/src/scripts/test.setup.mts +25 -0
  71. package/template-vite-vue3-pinia-mts/src/scripts/vitest.global.setup.mts +29 -0
  72. package/template-vite-vue3-pinia-mts/tsconfig.json +49 -0
  73. package/template-vite-vue3-pinia-mts/vite.config.ts +87 -0
  74. package/template-vite-vue3-pinia-mts/vitest.config.mts +43 -0
  75. package/template-vite-vue3-pinia-mts/vitest.config.production.mts +41 -0
  76. package/template-vite-vue3-pinia-mts/yarn.lock +2367 -0
  77. /package/template-vite-vue3-mts/{connect-template.json → connect-template.json5} +0 -0
  78. /package/{template-vite-vue3-mts/connect.json5 → template-vite-vue3-pinia-mts/connect-template.json5} +0 -0
package/index.mjs CHANGED
@@ -40,6 +40,11 @@ const FRAMEWORKS = [
40
40
  name: 'vite-vue3-mts',
41
41
  display: 'TypeScript',
42
42
  color: blue
43
+ },
44
+ {
45
+ name: 'vite-vue3-pinia-mts',
46
+ display: 'TypeScript',
47
+ color: blue
43
48
  }
44
49
  ]
45
50
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jwn-js",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "license": "PRIVATE",
5
5
  "author": "Webigorkiev",
6
6
  "bin": {
@@ -8,10 +8,10 @@
8
8
  "scripts": {
9
9
  "dev": "vite",
10
10
  "serve": "vite",
11
- "build": "vite build && cd ./dist && yarn",
11
+ "build": "vite build && cd ./dist && npm install --cpu=arm64 --os=linux --libc=glibc --omit=dev",
12
12
  "test": "vitest run",
13
13
  "test:production": "vitest run -c vitest.config.production.mts",
14
- "deploy": "yarn build && cd dist && zip -r ../dist.zip ."
14
+ "deploy": "yarn build && rm -f dist.zip && cd dist && zip -r ../dist.zip ."
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/aws-lambda": "8",
@@ -8,10 +8,10 @@
8
8
  "scripts": {
9
9
  "dev": "vite",
10
10
  "serve": "vite",
11
- "build": "vite build && cd ./dist && yarn",
11
+ "build": "vite build && cd ./dist && npm install --cpu=arm64 --os=linux --libc=glibc --omit=dev",
12
12
  "test": "vitest run",
13
13
  "test:production": "vitest run -c vitest.config.production.mts",
14
- "deploy": "yarn build && cd dist && zip -r ../dist.zip ."
14
+ "deploy": "yarn build && rm -f dist.zip && cd dist && zip -r ../dist.zip ."
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/aws-lambda": "8",
@@ -1,6 +1,7 @@
1
- import {createConfigServer} from "@/backend/server/helpers/createConfigServer";
2
- import type {server} from "@/backend/server/types";
3
- import {readJson5ConfigsSync} from "@/backend/server/helpers/readJson5ConfigsSync";
1
+ import {createConfigServer} from "@/backend/server/helpers/createConfigServer.mjs";
2
+ import type {server} from "@/backend/server/types.mjs";
3
+ import {readJson5ConfigsSync} from "@/backend/server/helpers/readJson5ConfigsSync.mjs";
4
+ import {omit} from "easy-ash";
4
5
  const config = readJson5ConfigsSync<server.Config>(["./connect.json5", "./common.json5"]);
5
6
  const cnf = createConfigServer(config, process.env.TEST_MODE_APP as "test");
6
7
  const apiUrl = `${cnf.protocol}://${cnf.host}:${cnf.port}`;
@@ -0,0 +1 @@
1
+ v20.19.3
@@ -0,0 +1,9 @@
1
+ {
2
+ "framework": "vue",
3
+ "src/**/*.mts": {
4
+ "framework": null
5
+ },
6
+ "src/frontend/**/*.mts": {
7
+ "framework": "vue"
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ [1.0.1]
2
+
3
+ * Initial commit
@@ -1,27 +1,26 @@
1
1
  const {appendFileSync} = require("fs");
2
2
  const {performance} = require("perf_hooks");
3
3
  const margv = require("margv");
4
- const fetch = require("cross-fetch");
5
4
  const chalk = require("chalk");
6
5
  const fs = require("fs");
7
6
  const path = require("path");
8
-
9
- const logFile = "/var/www/tehnoskarb/logs/cron/skarb.works.log";
7
+ const JSON5 = require("json5");
8
+ const logFile = "/var/www/test.log"; // path to log file
10
9
  const two = (value) => ("0" + value).slice(-2);
11
10
  const toMysqlDatetime = (date) => `${date.getFullYear()}-${two(date.getMonth()+1)}-${two(date.getDate())} ${two(date.getHours())}:${two(date.getMinutes())}:${two(date.getSeconds())}`;
12
-
13
11
  (async() => {
14
12
  const start = performance.now();
15
13
  const args = margv();
16
-
17
14
  if(args.help) {
18
15
  console.log(`// $ cron.js -c=<controller> -s=<subaction> -p={} -m=<method> -h={} --development`);
19
-
20
16
  return;
21
17
  }
22
-
23
- const connect = path.resolve(__dirname, './connect.json');
24
- const config = JSON.parse(fs.readFileSync(connect, 'utf8'));
18
+ const connect = path.resolve(__dirname, './connect.json5');
19
+ const common = path.resolve(__dirname, './common.json5');
20
+ const config = Object.assign(
21
+ JSON5.parse(fs.readFileSync(common, 'utf8')),
22
+ JSON5.parse(fs.readFileSync(connect, 'utf8'))
23
+ );
25
24
  const host = args.development || args.d
26
25
  ? `http://${config.server.development.host}:${config.server.development.port}/web`
27
26
  : `http://${config.server.production.host}:${config.server.production.port}/web`;
@@ -32,18 +31,13 @@ const toMysqlDatetime = (date) => `${date.getFullYear()}-${two(date.getMonth()+1
32
31
  const headers = args.headers || args.h || {};
33
32
  const adminToken = config.cron["admin-token"];
34
33
  const apiToken = config.cron["api-token"];
35
-
36
34
  console.log(chalk.green(host));
37
-
38
35
  if(!controller) {
39
36
  console.log(chalk.red("required --controller=<controller>"));
40
-
41
37
  return;
42
38
  }
43
-
44
39
  if(!subaction) {
45
40
  console.log(chalk.red("required --subaction=<subaction>"));
46
-
47
41
  return;
48
42
  }
49
43
 
@@ -57,20 +51,17 @@ const toMysqlDatetime = (date) => `${date.getFullYear()}-${two(date.getMonth()+1
57
51
  ...headers
58
52
  }
59
53
  }
60
-
61
54
  if(method.toLowerCase() === "get") {
62
55
  url.search = new URLSearchParams(Object.assign(params, {controller, subaction, token: apiToken})).toString();
63
56
  } else {
64
57
  options.body = JSON.stringify(Object.assign(params, {controller, subaction, token: apiToken}));
65
58
  }
66
-
67
59
  console.log(chalk.green(`send params to ${controller} ${subaction}`));
68
60
  const response = await fetch(url.toString(), options);
69
61
  const text = decodeURIComponent(await response.text());
70
62
  const time = Math.round(performance.now() - start)/1000;
71
63
  const logParams = (JSON.stringify(Object.assign(params, {subaction}))
72
64
  .substring(0, 512));
73
-
74
65
  try {
75
66
  appendFileSync(
76
67
  logFile,
@@ -79,7 +70,6 @@ const toMysqlDatetime = (date) => `${date.getFullYear()}-${two(date.getMonth()+1
79
70
  } catch(e) {
80
71
  console.log(chalk.red( `No log file ${logFile}`));
81
72
  }
82
-
83
73
  if(response.ok) {
84
74
  console.log(chalk.green("response ok."));
85
75
  console.log(chalk.green(text));
@@ -31,21 +31,22 @@
31
31
  "postcss-plugin": "^1.0.0",
32
32
  "postcss-scss": "^4.0.9",
33
33
  "typescript": "^5.6.3",
34
- "vite": "^5.4.10",
34
+ "vite": "^7.0.4",
35
35
  "vite-svg-loader": "^5.1.0",
36
36
  "vitepress": "^1.4.1",
37
- "vitest": "^2.1.4"
37
+ "vitest": "^3.2.4"
38
38
  },
39
39
  "dependencies": {
40
- "@jwn-js/common": "^2.2.17",
40
+ "@jwn-js/common": "^2.3.9",
41
41
  "@jwn-js/plugins": "^1.0.16",
42
42
  "@primevue/themes": "^4.1.1",
43
43
  "@vue/server-renderer": "^3.5.12",
44
- "@vuemod/prefetch": "^1.0.10",
44
+ "@vuemod/prefetch": "^1.1.1",
45
45
  "amitt": "^1.0.20",
46
46
  "buildmsql": "^1.7.0",
47
47
  "chalk": "4",
48
- "easy-ash": "^1.1.14",
48
+ "easy-ash": "^1.1.16",
49
+ "json5": "^2.2.3",
49
50
  "margv": "^1.1.2",
50
51
  "memjs": "^1.3.2",
51
52
  "primevue": "^4.1.1",
@@ -1,16 +1,11 @@
1
1
  import {Query} from "buildmsql";
2
2
 
3
- /**
4
- * Create mariadb pool
5
- * @param config
6
- */
3
+
7
4
  export const createMariadb = (config: Record<string, any>) => {
8
5
  if(config.db?.home) {
9
6
  const home = new Query({debug: process.env.NODE_ENV === "production" ? 0 : 1});
10
7
  const homePool = home.createPool(config.db.home);
11
-
12
8
  return {homePool, home};
13
9
  }
14
-
15
10
  return {};
16
11
  }
@@ -10,6 +10,5 @@ export const createMemcached = () => {
10
10
  }
11
11
  });
12
12
  const memcached = new Memcached(memcachedClient);
13
-
14
13
  return {memcachedClient, memcached};
15
14
  }
@@ -6,6 +6,5 @@ export const readJson5ConfigsSync = <T extends Record<string, any>>(configs: str
6
6
  const filePath = path.resolve(config);
7
7
  Object.assign(input, JSON5.parse(fs.readFileSync(filePath).toString()));
8
8
  }
9
-
10
9
  return input as T;
11
10
  }
@@ -1,16 +1,11 @@
1
1
  import {helpers} from "@jwn-js/common";
2
2
 
3
- /**
4
- * Read ssr manifest
5
- */
6
3
  export const readManifest = () => {
7
4
  let manifest = {};
8
-
9
5
  try {
10
6
  manifest = helpers.readConfigSync("./dist/client/ssr-manifest.json");
11
7
  } catch(e: any) {
12
8
  // console.log(e.message);
13
9
  }
14
-
15
10
  return manifest;
16
11
  }
@@ -1,13 +1,13 @@
1
- import {Server, helpers, Web, Ssr, OptionsWeb, OptionsSsr} from "@jwn-js/common";
1
+ import {Server, helpers, Web, Ssr, type OptionsWeb, type OptionsSsr} from "@jwn-js/common";
2
2
  import {createConfigServer} from "./helpers/createConfigServer.mjs";
3
3
  import {schema} from "./site-schema.mjs";
4
4
  import {webRoutes} from "./web-routes/index.mjs";
5
5
  import {createMariadb} from "./helpers/createMariadb.mjs";
6
6
  import {createMemcached} from "./helpers/createMemcached.mjs";
7
7
  import {readManifest} from "@/backend/server/helpers/readManifest.mjs";
8
- import entry from "@/frontend/entry-server";
8
+ import entry from "@/frontend/entry-server.mjs";
9
9
  import {readJson5ConfigsSync} from "@/backend/server/helpers/readJson5ConfigsSync.mjs";
10
- import {server} from "@/backend/server/types.mjs";
10
+ import type * as server from "@/backend/server/types.mjs";
11
11
  declare var process: any;
12
12
 
13
13
  const {readConfigSync} = helpers;
@@ -1,4 +1,4 @@
1
- import {Schema} from "@jwn-js/common";
1
+ import type {Schema} from "@jwn-js/common";
2
2
 
3
3
  export const schema: Schema = {
4
4
  actions: [
@@ -1,7 +1,5 @@
1
- import {Config as _Config} from "@jwn-js/common";
1
+ import {type Config as _Config} from "@jwn-js/common";
2
2
 
3
- export namespace server {
4
- export interface Config extends _Config {
3
+ export interface Config extends _Config {
5
4
 
6
- }
7
- }
5
+ }
@@ -23,19 +23,11 @@ export default (opt: Record<string, any>) => createRouter({
23
23
  },
24
24
  ],
25
25
  async scrollBehavior(to, from, savedPosition) {
26
-
27
- // Scroll to element
28
- if(to.query?.el) {
26
+ if (to.query?.el) { // Scroll to element
29
27
  const el: string = to.query.el as string;
30
-
31
- return {
32
- el
33
- };
28
+ return {el};
34
29
  }
35
-
36
- // meta scrollToTop
37
- if(to.meta.scrollToTop) {
38
-
30
+ if (to.meta.scrollToTop) { // meta scrollToTop
39
31
  return {left: 0, top: 0};
40
32
  }
41
33
  }
@@ -1,5 +1,4 @@
1
1
  import {isBrowser} from "easy-ash";
2
- import fetch from "cross-fetch";
3
2
  import {ApiError} from "@jwn-js/common/ApiError";
4
3
  import type {ActionContext} from "vuex";
5
4
 
@@ -7,7 +7,7 @@
7
7
  <script lang="ts">
8
8
  import {defineComponent} from "vue";
9
9
  import {mapState} from "vuex";
10
- import {customerPrefetch} from "@/frontend/helpers/customerPrefetch";
10
+ import {customerPrefetch} from "@/frontend/helpers/customerPrefetch.mts";
11
11
 
12
12
  export default defineComponent({
13
13
  name: "Index",
@@ -18,15 +18,16 @@
18
18
  "experimentalDecorators": true,
19
19
  "emitDecoratorMetadata": true,
20
20
  "allowImportingTsExtensions": true,
21
+ "moduleDetection": "force",
22
+ "isolatedModules": true,
23
+ "verbatimModuleSyntax": true,
21
24
  "lib": [
22
25
  "esnext",
23
26
  "dom"
24
27
  ],
25
28
  "types": [
26
29
  "vite/client",
27
- "@types/jest",
28
- "node",
29
- "jest-environment-puppeteer"
30
+ "node"
30
31
  ],
31
32
  "baseUrl": ".",
32
33
  "paths": {
@@ -36,15 +37,13 @@
36
37
  }
37
38
  },
38
39
  "include": [
39
- "src/**/*.ts",
40
40
  "src/**/*.mts",
41
- "src/**/*.d.ts",
42
- "src/**/*.d.mts",
43
- "src/**/*.tsx",
44
- "src/**/*.vue"
41
+ "src/**/*.spec.mts",
42
+ "src/**/*.ts",
43
+ "src/**/*.vue",
44
+ "node_modules/vitest/globals.d.ts"
45
45
  ],
46
46
  "exclude": [
47
- "node_modules",
48
47
  "dist"
49
48
  ]
50
49
  }