win_webview2 1.1.10 → 1.1.11

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.
@@ -7,6 +7,7 @@ exports.buildForServer = buildForServer;
7
7
  const prompts_1 = __importDefault(require("prompts"));
8
8
  const builder_init_1 = require("./builder_init");
9
9
  const userExec_1 = require("./userExec");
10
+ const versiontool_1 = require("./versiontool");
10
11
  let ww2Choise = {
11
12
  "init_win_webview2": {
12
13
  description: "init win_webview2",
@@ -16,6 +17,8 @@ let ww2Choise = {
16
17
  }
17
18
  };
18
19
  async function buildForServer() {
20
+ let version = await (0, versiontool_1.getWWvVersion)();
21
+ console.log("win_webview2 : " + version);
19
22
  let userChoise = await (0, userExec_1.readUserScripts)();
20
23
  if (userChoise != null) {
21
24
  ww2Choise = {
@@ -0,0 +1,4 @@
1
+ /** Ini hanya bisa dipakai dengan cara tidak bundle
2
+ karena package json mungkin gak ada
3
+ */
4
+ export declare function getWWvVersion(): Promise<string>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWWvVersion = getWWvVersion;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const dirnameTool_1 = require("../tsExport/dirnameTool");
9
+ const promises_1 = require("node:fs/promises");
10
+ /** Ini hanya bisa dipakai dengan cara tidak bundle
11
+ karena package json mungkin gak ada
12
+ */
13
+ async function getWWvVersion() {
14
+ let result = "";
15
+ try {
16
+ let jsonPath = node_path_1.default.join((0, dirnameTool_1.getWw2Dirname)().ww2ModulePath, "package.json");
17
+ let jsontxt = await (0, promises_1.readFile)(jsonPath, "utf-8");
18
+ let jsonObj = JSON.parse(jsontxt);
19
+ result = jsonObj.version;
20
+ }
21
+ catch (error) {
22
+ }
23
+ return result;
24
+ }
@@ -11,4 +11,4 @@ export declare function getWw2Dirname(): {
11
11
  _filename: string;
12
12
  ww2ModulePath: string;
13
13
  };
14
- export declare function findUserProjectRoot(currentDir?: string): string | null;
14
+ export declare function findUserProjectRoot(): string | null;
@@ -58,7 +58,7 @@ function getWw2Dirname() {
58
58
  let ww2ModulePath = node_path_1.default.join(_dirname, "../../../");
59
59
  return { _dirname, _filename, ww2ModulePath };
60
60
  }
61
- function findUserProjectRoot(currentDir = process.cwd()) {
61
+ function findUserProjectRootRecrusive(currentDir = process.cwd()) {
62
62
  const packagePath = node_path_1.default.join(currentDir, 'package.json');
63
63
  if ((0, node_fs_1.existsSync)(packagePath)) {
64
64
  return currentDir;
@@ -67,5 +67,13 @@ function findUserProjectRoot(currentDir = process.cwd()) {
67
67
  if (parentDir === currentDir) {
68
68
  return null;
69
69
  }
70
- return findUserProjectRoot(parentDir);
70
+ return findUserProjectRootRecrusive(parentDir);
71
+ }
72
+ function findUserProjectRoot() {
73
+ // - Deployed Condition
74
+ const packagePath = node_path_1.default.join(node_path_1.default.dirname(process.execPath), 'package.json');
75
+ if ((0, node_fs_1.existsSync)(packagePath)) {
76
+ return node_path_1.default.dirname(packagePath);
77
+ }
78
+ return findUserProjectRootRecrusive(process.cwd());
71
79
  }
@@ -4,4 +4,4 @@ export type ConfigWW2 = {
4
4
  outdir: string;
5
5
  platform: 'Win32' | 'x64';
6
6
  };
7
- export declare function readConfig(): Promise<ConfigWW2 | null>;
7
+ export declare function readConfig(): Promise<ConfigWW2>;
@@ -7,16 +7,12 @@ exports.readConfig = readConfig;
7
7
  const promises_1 = require("node:fs/promises");
8
8
  const dirnameTool_1 = require("./dirnameTool");
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
- const node_fs_1 = require("node:fs");
11
10
  const jsonConfigFilePath = "./win_webview2.json";
12
11
  async function readConfig() {
13
- let jsonPath = node_path_1.default.join(__dirname, jsonConfigFilePath);
14
- if (!(0, node_fs_1.existsSync)(jsonPath)) {
15
- let userDir = (0, dirnameTool_1.findUserProjectRoot)();
16
- if (userDir == null)
17
- return null;
18
- jsonPath = node_path_1.default.join(userDir, jsonConfigFilePath);
19
- }
12
+ let userDir = (0, dirnameTool_1.findUserProjectRoot)();
13
+ if (userDir == null)
14
+ throw "readConfig() => findProjectUser failed";
15
+ let jsonPath = node_path_1.default.join(userDir, jsonConfigFilePath);
20
16
  let str = await (0, promises_1.readFile)(jsonPath);
21
17
  let jsonObj = JSON.parse(str.toString());
22
18
  return jsonObj;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "win_webview2",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nnttoo/win_webview2"
@@ -2,6 +2,7 @@
2
2
  import prompts from 'prompts';
3
3
  import { ww2Init } from './builder_init';
4
4
  import { readUserScripts } from './userExec';
5
+ import { getWWvVersion } from './versiontool';
5
6
 
6
7
  interface ChoiseItem {
7
8
  fun: () => any;
@@ -28,6 +29,9 @@ type promChoise = {
28
29
  }
29
30
 
30
31
  export async function buildForServer() {
32
+ let version = await getWWvVersion();
33
+ console.log("win_webview2 : " + version);
34
+
31
35
  let userChoise = await readUserScripts();
32
36
  if(userChoise != null){
33
37
  ww2Choise = {
@@ -0,0 +1,25 @@
1
+ import path from "node:path";
2
+ import { getWw2Dirname } from "../tsExport/dirnameTool";
3
+ import { readFile } from "node:fs/promises";
4
+
5
+
6
+ /** Ini hanya bisa dipakai dengan cara tidak bundle
7
+ karena package json mungkin gak ada
8
+ */
9
+ export async function getWWvVersion(){
10
+ let result = "";
11
+
12
+ try {
13
+ let jsonPath = path.join(getWw2Dirname().ww2ModulePath,"package.json");
14
+ let jsontxt = await readFile(jsonPath,"utf-8");
15
+ let jsonObj = JSON.parse(jsontxt) as { version : string};
16
+
17
+ result = jsonObj.version;
18
+
19
+ } catch (error) {
20
+
21
+ }
22
+
23
+ return result;
24
+ }
25
+
@@ -29,7 +29,7 @@ export function getWw2Dirname() {
29
29
  return { _dirname, _filename , ww2ModulePath};
30
30
  }
31
31
 
32
- export function findUserProjectRoot(currentDir : string = process.cwd()) {
32
+ function findUserProjectRootRecrusive(currentDir : string = process.cwd()) {
33
33
 
34
34
  const packagePath = path.join(currentDir, 'package.json');
35
35
  if (existsSync(packagePath)) {
@@ -39,6 +39,15 @@ export function findUserProjectRoot(currentDir : string = process.cwd()) {
39
39
  if (parentDir === currentDir) {
40
40
  return null;
41
41
  }
42
- return findUserProjectRoot(parentDir);
42
+ return findUserProjectRootRecrusive(parentDir);
43
+ }
44
+
45
+ export function findUserProjectRoot() {
46
+
47
+ // - Deployed Condition
48
+ const packagePath = path.join(path.dirname(process.execPath), 'package.json');
49
+ if (existsSync(packagePath)) {
50
+ return path.dirname(packagePath);
51
+ }
52
+ return findUserProjectRootRecrusive(process.cwd());
43
53
  }
44
-
@@ -1,5 +1,5 @@
1
1
  import { readFile } from "node:fs/promises";
2
- import { findUserProjectRoot } from "./dirnameTool";
2
+ import { findUserProjectRoot, getWw2Dirname } from "./dirnameTool";
3
3
  import path from "node:path";
4
4
  import { existsSync } from "node:fs";
5
5
 
@@ -13,15 +13,11 @@ export type ConfigWW2 = {
13
13
 
14
14
  const jsonConfigFilePath = "./win_webview2.json";
15
15
  export async function readConfig() {
16
- let jsonPath = path.join(__dirname, jsonConfigFilePath);
17
- if (!existsSync(jsonPath)) {
18
- let userDir = findUserProjectRoot();
19
- if (userDir == null) return null;
20
- jsonPath = path.join(userDir, jsonConfigFilePath);
21
- }
22
-
16
+ let userDir = findUserProjectRoot();
17
+ if (userDir == null) throw "readConfig() => findProjectUser failed"
23
18
 
19
+ let jsonPath = path.join(userDir, jsonConfigFilePath);
24
20
  let str = await readFile(jsonPath);
25
- let jsonObj = JSON.parse(str.toString());
21
+ let jsonObj = JSON.parse(str.toString());
26
22
  return jsonObj as ConfigWW2;
27
23
  }