@datapos/datapos-development 0.3.41 → 0.3.45

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 CHANGED
@@ -3,14 +3,14 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@datapos/datapos-development.svg)](https://www.npmjs.com/package/@datapos/datapos-development)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
5
5
 
6
- A library of JavaScript operations for managing the Data Positioning repositories.
6
+ A TypeScript library of utilities for managing the Data Positioning repositories.
7
7
 
8
8
  ## Requirements
9
9
 
10
10
  Ensure your environment meets the following prerequisites before using this library:
11
11
 
12
- - **Node.js** version `>=18.0.0`,
13
- - **npm** version `>=9.0.0`,
12
+ - **Node.js** version `>=22.0.0`,
13
+ - **npm** version `>=11.0.0`,
14
14
  - A Unix-like shell (for command shortcuts, e.g., `bash`, `zsh`, or Git Bash on Windows),
15
15
  - Access to the [npm registry](https://www.npmjs.com/) and [GitHub](https://github.com/) for publishing and syncing.
16
16
 
@@ -22,13 +22,17 @@ Install as a development (dev) dependency:
22
22
  npm install --save-dev @datapos/datapos-development
23
23
  ```
24
24
 
25
- ## Operations
25
+ ## Utilities
26
26
 
27
- The 'index.js' file exposes the following operations:
27
+ The `src/index.ts' file exposes the following utilities:
28
28
 
29
29
  | Name | Notes |
30
30
  | ------------------------- | ------------------------------------------------------------------------ |
31
31
  | buildConfig | Build the config.json file for the repository. |
32
+ | buildConnectorConfig | |
33
+ | buildContextConfig | |
34
+ | buildInformerConfig | |
35
+ | buildPresenterConfig | |
32
36
  | buildPublicDirectoryIndex | Build an index for the repositories public directory. |
33
37
  | bumpVersion | Bump the repositories version number. |
34
38
  | clearDirectory | Clear the specified directory. |
@@ -46,15 +50,18 @@ For detailed implementation, see the `scripts` section in the `package.json` fil
46
50
  | Name | Key Code | Notes |
47
51
  | ------------------ | ---------------- | ---------------------------------------------------------------------------------------------------------- |
48
52
  | audit | alt+ctrl+shift+a | Audit the project's dependencies for known security vulnerabilities. |
49
- | build | alt+ctrl+shift+b | NOT implemented. |
53
+ | build | alt+ctrl+shift+b | Build the package using Vite. |
54
+ | build...Config | | ❌ Not implemented. |
55
+ | bumpVersion | alt+ctrl+shift+v | |
50
56
  | check | alt+ctrl+shift+c | List outdated dependencies and run retire scanner. |
51
57
  | document | alt+ctrl+shift+d | Identify licenses of the project's production and peer dependencies. See [LICENSES.json](./LICENSES.json). |
52
58
  | format | alt+ctrl+shift+f | Enforce formatting style rules. |
53
59
  | lint | alt+ctrl+shift+l | Check the code for errors and enforce coding style rules. |
60
+ | publishToNPM | alt+ctrl+shift+p | |
54
61
  | release | alt+ctrl+shift+r | Bump version, synchronise local repository with the main GitHub repository and publish to npm. |
55
62
  | syncWithGitHub | alt+ctrl+shift+s | Bump version and synchronise local repository with the main GitHub repository. |
56
- | test | alt+ctrl+shift+t | NOT implemented. |
57
- | updateDependencies | alt+ctrl+shift+u | NOT implemented. |
63
+ | test | alt+ctrl+shift+t | Not implemented. |
64
+ | updateDependencies | alt+ctrl+shift+u | Not implemented. |
58
65
 
59
66
  ## Compliance
60
67
 
@@ -0,0 +1,77 @@
1
+ import { exec as u } from "child_process";
2
+ import { promises as i } from "fs";
3
+ import { promisify as d } from "util";
4
+ const p = ["createObject", "dropObject", "removeRecords", "upsertRecords"], m = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], f = d(u);
5
+ async function S() {
6
+ try {
7
+ console.log("🚀 Building connector configuration...");
8
+ const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.readFile("src/index.ts", "utf8");
9
+ let r = !1, s = !1;
10
+ const n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, c = [...t.matchAll(n)].filter((a) => !a[1] && a[2] !== "constructor").map((a) => {
11
+ const g = a[2];
12
+ return r = r || p.includes(g), s = s || m.includes(g), g;
13
+ });
14
+ c.length > 0 ? console.log(`ℹ️ Implements ${c.length} operations.`) : console.log("⚠️ Implements no operations.");
15
+ const l = s && r ? "bidirectional" : s ? "source" : r ? "destination" : null;
16
+ 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 i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("✅ Connector configuration built.");
17
+ } catch (o) {
18
+ console.warn("❌ Error building connector configuration.", o);
19
+ }
20
+ }
21
+ async function N() {
22
+ try {
23
+ console.log("🚀 Building context configuration...");
24
+ const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.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((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
25
+ o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
26
+ } catch (o) {
27
+ console.warn("❌ Error building context configuration.", o);
28
+ }
29
+ }
30
+ async function y() {
31
+ try {
32
+ console.log("🚀 Building informer configuration...");
33
+ const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.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((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
34
+ o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
35
+ } catch (o) {
36
+ console.warn("❌ Error building informer configuration.", o);
37
+ }
38
+ }
39
+ async function b() {
40
+ try {
41
+ console.log("🚀 Building presenter configuration...");
42
+ const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.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((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
43
+ o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
44
+ } catch (o) {
45
+ console.warn("❌ Error building context configuration.", o);
46
+ }
47
+ }
48
+ async function J() {
49
+ try {
50
+ console.log("🚀 Bumping version...");
51
+ const o = JSON.parse(await i.readFile("package.json", "utf8"));
52
+ if (o.version) {
53
+ const e = o.version, t = o.version.split(".");
54
+ o.version = `${t[0]}.${t[1]}.${Number(t[2]) + 1}`, await i.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`✅ Version bumped from ${e} to ${o.version}.`);
55
+ } else
56
+ o.version = "0.0.001", await i.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`⚠️ Version initialised to ${o.version}.`);
57
+ } catch (o) {
58
+ console.warn("❌ Error bumping package version.", o);
59
+ }
60
+ }
61
+ async function h() {
62
+ try {
63
+ console.log("🚀 Synchronising with GitHub....");
64
+ const o = JSON.parse(await i.readFile("package.json", "utf8"));
65
+ await f("git add ."), await f(`git commit -m "v${o.version}"`), await f("git push origin main:main"), console.log(`✅ Synchronised version ${o.version} with GitHub.`);
66
+ } catch (o) {
67
+ console.warn("❌ Error synchronising with GitHub.", o);
68
+ }
69
+ }
70
+ export {
71
+ S as buildConnectorConfig,
72
+ N as buildContextConfig,
73
+ y as buildInformerConfig,
74
+ b as buildPresenterConfig,
75
+ J as bumpVersion,
76
+ h as syncWithGitHub
77
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "private": false,
5
5
  "type": "module",
6
- "version": "0.3.41",
6
+ "version": "0.3.45",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
@@ -38,14 +38,15 @@
38
38
  "scripts": {
39
39
  "audit": "npm audit",
40
40
  "build": "vite build",
41
- "bumpVersion": "node -e \"import('./dist/index.js').then(m => m.bumpVersion())\"",
41
+ "buildConfig": "echo \"***** BUILD CONFIG SCRIPT NOT IMPLEMENTED. *****\"",
42
+ "bumpVersion": "node -e \"import('./dist/datapos-development.es.js').then(m => m.bumpVersion())\"",
42
43
  "check": "npm outdated; npm-check-updates -i && retire",
43
44
  "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
- "format": "prettier --write *.ts",
45
- "lint": "eslint src/",
45
+ "format": "prettier --write src/",
46
+ "lint": "eslint . --ext .ts --fix --ignore-path .gitignore",
46
47
  "publishToNPM": "npm publish --access public",
47
48
  "release": "npm run syncWithGitHub && npm run publishToNPM",
48
- "syncWithGitHub": "npm run bumpVersion && node -e \"import('./index.js').then(m => m.syncWithGitHub())\"",
49
+ "syncWithGitHub": "npm run bumpVersion && node -e \"import('./dist/datapos-development.es.js').then(m => m.syncWithGitHub())\"",
49
50
  "test": "echo \"***** TEST SCRIPT NOT IMPLEMENTED. *****\"",
50
51
  "updateDependencies": "echo \"***** UPDATE DEPENDENCIES SCRIPT NOT IMPLEMENTED. *****\""
51
52
  }
package/dist/index.js DELETED
@@ -1,122 +0,0 @@
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
- };