@datapos/datapos-development 0.3.40 â 0.3.41
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/dist/index.js +122 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +3 -3
- package/dist/datapos-development.es.js +0 -65
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { exec as exec$1 } from "child_process";
|
|
2
|
+
import { promises } from "fs";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
import { CONNECTOR_DESTINATION_OPERATIONS, CONNECTOR_SOURCE_OPERATIONS } from "@datapos/datapos-shared";
|
|
5
|
+
const exec = promisify(exec$1);
|
|
6
|
+
async function buildConnectorConfig() {
|
|
7
|
+
try {
|
|
8
|
+
console.log("đ Building connector configuration...");
|
|
9
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
10
|
+
const configJSON = JSON.parse(await promises.readFile("config.json", "utf8"));
|
|
11
|
+
const indexCode = await promises.readFile("src/index.ts", "utf8");
|
|
12
|
+
let destinationOperations = false;
|
|
13
|
+
let sourceOperations = false;
|
|
14
|
+
const regex = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm;
|
|
15
|
+
const operations = [...indexCode.matchAll(regex)].filter((m) => !m[1] && m[2] !== "constructor").map((m) => {
|
|
16
|
+
const operation = m[2];
|
|
17
|
+
destinationOperations = destinationOperations || CONNECTOR_DESTINATION_OPERATIONS.includes(operation);
|
|
18
|
+
sourceOperations = sourceOperations || CONNECTOR_SOURCE_OPERATIONS.includes(operation);
|
|
19
|
+
return operation;
|
|
20
|
+
});
|
|
21
|
+
if (operations.length > 0) console.log(`âšī¸ Implements ${operations.length} operations.`);
|
|
22
|
+
else console.log("â ī¸ Implements no operations.");
|
|
23
|
+
const usageId = sourceOperations && destinationOperations ? "bidirectional" : sourceOperations ? "source" : destinationOperations ? "destination" : null;
|
|
24
|
+
if (usageId) console.log(`âšī¸ Supports ${usageId} usage.`);
|
|
25
|
+
else console.log("â ī¸ No usage identified.");
|
|
26
|
+
if (packageJSON.name) configJSON.id = packageJSON.name;
|
|
27
|
+
configJSON.operations = operations;
|
|
28
|
+
configJSON.usageId = usageId;
|
|
29
|
+
if (packageJSON.version) configJSON.version = packageJSON.version;
|
|
30
|
+
await promises.writeFile("config.json", JSON.stringify(configJSON, void 0, 4), "utf8");
|
|
31
|
+
console.log("â
Connector configuration built.");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn("â Error building connector configuration.", error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function buildContextConfig() {
|
|
37
|
+
try {
|
|
38
|
+
console.log("đ Building context configuration...");
|
|
39
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
40
|
+
const configJSON = JSON.parse(await promises.readFile("config.json", "utf8"));
|
|
41
|
+
const indexCode = await promises.readFile("src/index.ts", "utf8");
|
|
42
|
+
const regex = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm;
|
|
43
|
+
const operations = [...indexCode.matchAll(regex)].filter((m) => !m[1] && m[2] !== "constructor").map((m) => m[2]);
|
|
44
|
+
if (packageJSON.name) configJSON.id = packageJSON.name;
|
|
45
|
+
configJSON.operations = operations;
|
|
46
|
+
if (packageJSON.version) configJSON.version = packageJSON.version;
|
|
47
|
+
await promises.writeFile("config.json", JSON.stringify(configJSON, void 0, 4), "utf8");
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.warn("â Error building context configuration.", error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function buildInformerConfig() {
|
|
53
|
+
try {
|
|
54
|
+
console.log("đ Building informer configuration...");
|
|
55
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
56
|
+
const configJSON = JSON.parse(await promises.readFile("config.json", "utf8"));
|
|
57
|
+
const indexCode = await promises.readFile("src/index.ts", "utf8");
|
|
58
|
+
const regex = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm;
|
|
59
|
+
const operations = [...indexCode.matchAll(regex)].filter((m) => !m[1] && m[2] !== "constructor").map((m) => m[2]);
|
|
60
|
+
if (packageJSON.name) configJSON.id = packageJSON.name;
|
|
61
|
+
configJSON.operations = operations;
|
|
62
|
+
if (packageJSON.version) configJSON.version = packageJSON.version;
|
|
63
|
+
await promises.writeFile("config.json", JSON.stringify(configJSON, void 0, 4), "utf8");
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn("â Error building informer configuration.", error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function buildPresenterConfig() {
|
|
69
|
+
try {
|
|
70
|
+
console.log("đ Building presenter configuration...");
|
|
71
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
72
|
+
const configJSON = JSON.parse(await promises.readFile("config.json", "utf8"));
|
|
73
|
+
const indexCode = await promises.readFile("src/index.ts", "utf8");
|
|
74
|
+
const regex = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm;
|
|
75
|
+
const operations = [...indexCode.matchAll(regex)].filter((m) => !m[1] && m[2] !== "constructor").map((m) => m[2]);
|
|
76
|
+
if (packageJSON.name) configJSON.id = packageJSON.name;
|
|
77
|
+
configJSON.operations = operations;
|
|
78
|
+
if (packageJSON.version) configJSON.version = packageJSON.version;
|
|
79
|
+
await promises.writeFile("config.json", JSON.stringify(configJSON, void 0, 4), "utf8");
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.warn("â Error building context configuration.", error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function bumpVersion() {
|
|
85
|
+
try {
|
|
86
|
+
console.log("đ Bumping version...");
|
|
87
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
88
|
+
if (packageJSON.version) {
|
|
89
|
+
const oldVersion = packageJSON.version;
|
|
90
|
+
const versionSegments = packageJSON.version.split(".");
|
|
91
|
+
packageJSON.version = `${versionSegments[0]}.${versionSegments[1]}.${Number(versionSegments[2]) + 1}`;
|
|
92
|
+
await promises.writeFile("package.json", JSON.stringify(packageJSON, void 0, 4), "utf8");
|
|
93
|
+
console.log(`â
Version bumped from ${oldVersion} to ${packageJSON.version}.`);
|
|
94
|
+
} else {
|
|
95
|
+
packageJSON.version = "0.0.001";
|
|
96
|
+
await promises.writeFile("package.json", JSON.stringify(packageJSON, void 0, 4), "utf8");
|
|
97
|
+
console.log(`â ī¸ Version initialised to ${packageJSON.version}.`);
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn("â Error bumping package version.", error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function syncWithGitHub() {
|
|
104
|
+
try {
|
|
105
|
+
console.log("đ Synchronising with GitHub....");
|
|
106
|
+
const packageJSON = JSON.parse(await promises.readFile("package.json", "utf8"));
|
|
107
|
+
await exec("git add .");
|
|
108
|
+
await exec(`git commit -m "v${packageJSON.version}"`);
|
|
109
|
+
await exec("git push origin main:main");
|
|
110
|
+
console.log(`â
Synchronised version ${packageJSON.version} with GitHub.`);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.warn("â Error synchronising with GitHub.", error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
buildConnectorConfig,
|
|
117
|
+
buildContextConfig,
|
|
118
|
+
buildInformerConfig,
|
|
119
|
+
buildPresenterConfig,
|
|
120
|
+
bumpVersion,
|
|
121
|
+
syncWithGitHub
|
|
122
|
+
};
|
|
@@ -6,3 +6,4 @@ export declare function buildContextConfig(): Promise<void>;
|
|
|
6
6
|
export declare function buildInformerConfig(): Promise<void>;
|
|
7
7
|
export declare function buildPresenterConfig(): Promise<void>;
|
|
8
8
|
export declare function bumpVersion(): Promise<void>;
|
|
9
|
+
export declare function syncWithGitHub(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.41",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"scripts": {
|
|
39
39
|
"audit": "npm audit",
|
|
40
40
|
"build": "vite build",
|
|
41
|
-
"bumpVersion": "node -e \"import('./index.js').then(m => m.bumpVersion())\"",
|
|
41
|
+
"bumpVersion": "node -e \"import('./dist/index.js').then(m => m.bumpVersion())\"",
|
|
42
42
|
"check": "npm outdated; npm-check-updates -i && retire",
|
|
43
43
|
"document": "license-report --only=prod,peer > LICENSES.json && license-report-check --source ./LICENSES.json --allowed 'MIT' --allowed 'n/a' --allowed 'Apache-2.0' --output=table",
|
|
44
44
|
"format": "prettier --write *.ts",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"test": "echo \"***** TEST SCRIPT NOT IMPLEMENTED. *****\"",
|
|
50
50
|
"updateDependencies": "echo \"***** UPDATE DEPENDENCIES SCRIPT NOT IMPLEMENTED. *****\""
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { promises as n } from "fs";
|
|
2
|
-
const f = ["createObject", "dropObject", "removeRecords", "upsertRecords"], u = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"];
|
|
3
|
-
async function p() {
|
|
4
|
-
try {
|
|
5
|
-
console.log("đ Building connector configuration...");
|
|
6
|
-
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), t = await n.readFile("src/index.ts", "utf8");
|
|
7
|
-
let r = !1, s = !1;
|
|
8
|
-
const i = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, c = [...t.matchAll(i)].filter((a) => !a[1] && a[2] !== "constructor").map((a) => {
|
|
9
|
-
const g = a[2];
|
|
10
|
-
return r = r || f.includes(g), s = s || u.includes(g), g;
|
|
11
|
-
});
|
|
12
|
-
c.length > 0 ? console.log(`âšī¸ Implements ${c.length} operations.`) : console.log("â ī¸ Implements no operations.");
|
|
13
|
-
const l = s && r ? "bidirectional" : s ? "source" : r ? "destination" : null;
|
|
14
|
-
console.log(l ? `âšī¸ Supports ${l} usage.` : "â ī¸ No usage identified."), o.name && (e.id = o.name), e.operations = c, e.usageId = l, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("â
Connector configuration built.");
|
|
15
|
-
} catch (o) {
|
|
16
|
-
console.warn("â Error building connector configuration.", o);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function v() {
|
|
20
|
-
try {
|
|
21
|
-
console.log("đ Building context configuration...");
|
|
22
|
-
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), t = await n.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((i) => !i[1] && i[2] !== "constructor").map((i) => i[2]);
|
|
23
|
-
o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
|
|
24
|
-
} catch (o) {
|
|
25
|
-
console.warn("â Error building context configuration.", o);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function w() {
|
|
29
|
-
try {
|
|
30
|
-
console.log("đ Building informer configuration...");
|
|
31
|
-
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), t = await n.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((i) => !i[1] && i[2] !== "constructor").map((i) => i[2]);
|
|
32
|
-
o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
|
|
33
|
-
} catch (o) {
|
|
34
|
-
console.warn("â Error building informer configuration.", o);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function m() {
|
|
38
|
-
try {
|
|
39
|
-
console.log("đ Building presenter configuration...");
|
|
40
|
-
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), t = await n.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((i) => !i[1] && i[2] !== "constructor").map((i) => i[2]);
|
|
41
|
-
o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
|
|
42
|
-
} catch (o) {
|
|
43
|
-
console.warn("â Error building context configuration.", o);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async function O() {
|
|
47
|
-
try {
|
|
48
|
-
console.log("đ Bumping version...");
|
|
49
|
-
const o = JSON.parse(await n.readFile("package.json", "utf8"));
|
|
50
|
-
if (o.version) {
|
|
51
|
-
const e = o.version, t = o.version.split(".");
|
|
52
|
-
o.version = `${t[0]}.${t[1]}.${Number(t[2]) + 1}`, await n.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`â
Version bumped from ${e} to ${o.version}.`);
|
|
53
|
-
} else
|
|
54
|
-
o.version = "0.0.001", await n.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`â ī¸ Version initialised to ${o.version}.`);
|
|
55
|
-
} catch (o) {
|
|
56
|
-
console.warn("â Error bumping package version.", o);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
p as buildConnectorConfig,
|
|
61
|
-
v as buildContextConfig,
|
|
62
|
-
w as buildInformerConfig,
|
|
63
|
-
m as buildPresenterConfig,
|
|
64
|
-
O as bumpVersion
|
|
65
|
-
};
|