win_webview2 1.1.9 → 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.
- package/README.md +13 -0
- package/dist/node/builder/builder_promps.js +3 -0
- package/dist/node/builder/versiontool.d.ts +4 -0
- package/dist/node/builder/versiontool.js +24 -0
- package/dist/node/tsExport/dirnameTool.d.ts +1 -1
- package/dist/node/tsExport/dirnameTool.js +10 -2
- package/dist/node/tsExport/ww2_config.d.ts +1 -1
- package/dist/node/tsExport/ww2_config.js +4 -8
- package/package.json +1 -1
- package/src/srcNode/builder/builder_promps.ts +4 -0
- package/src/srcNode/builder/versiontool.ts +25 -0
- package/src/srcNode/tsExport/dirnameTool.ts +12 -3
- package/src/srcNode/tsExport/ww2_config.ts +5 -9
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ npm install win_webview2
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
## Interactive Project Management
|
|
18
19
|
The win_webview2 CLI is designed to be your single point of control for the entire development lifecycle.
|
|
19
20
|
## 1. Scaffolding (First time)
|
|
@@ -23,6 +24,12 @@ To download the boilerplate and set up your project, simply run:
|
|
|
23
24
|
npx win_webview2
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
or
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npx wwv
|
|
31
|
+
```
|
|
32
|
+
|
|
26
33
|
## 2. Develop, Watch, and Build
|
|
27
34
|
After the initial setup, you don't need to remember complex commands. Just run the same command again:
|
|
28
35
|
|
|
@@ -32,6 +39,12 @@ After the initial setup, you don't need to remember complex commands. Just run t
|
|
|
32
39
|
npx win_webview2
|
|
33
40
|
```
|
|
34
41
|
|
|
42
|
+
or
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npx wwv
|
|
46
|
+
```
|
|
47
|
+
|
|
35
48
|
What it does:
|
|
36
49
|
It opens an interactive menu where you can manage your project. You can simply use your arrow keys (↑/↓) to select common tasks:
|
|
37
50
|
|
|
@@ -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,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
|
+
}
|
|
@@ -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
|
|
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
|
|
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
|
}
|
|
@@ -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
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
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
|
@@ -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
|
-
|
|
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
|
|
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
|
|
17
|
-
if (
|
|
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
|
}
|