kschema-fs-read-config 1.3.1 → 1.4.2
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/LICENSE +21 -21
- package/README.md +81 -81
- package/bin/core/getLatestVersion.js +12 -12
- package/bin/core/loadRunner.js +8 -8
- package/bin/v3/adventure/blacksmith.js +14 -14
- package/bin/v3/adventure/oracle.js +14 -14
- package/bin/v3/adventure/scout.js +16 -16
- package/bin/v3/getConfig.js +24 -24
- package/bin/v3/index.js +33 -33
- package/bin/{v2 → v4}/adventure/blacksmith.js +14 -14
- package/bin/{v2 → v4}/adventure/oracle.js +14 -14
- package/bin/{v2 → v4}/adventure/scout.js +16 -16
- package/bin/v4/getConfig.js +24 -0
- package/bin/v4/index.js +42 -0
- package/index.js +50 -50
- package/package.json +36 -36
- package/bin/v2/alterConfig.js +0 -15
- package/bin/v2/getAllJsons.js +0 -27
- package/bin/v2/getConfig.js +0 -14
- package/bin/v2/index.js +0 -12
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 KeshavSoft
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to do so, subject to the
|
|
10
|
-
following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeshavSoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to do so, subject to the
|
|
10
|
+
following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
# kschema-fs-ui-alter-config
|
|
2
|
-
|
|
3
|
-
> Find JSON files in your UI directory structure and inject/alter their column configurations automatically.
|
|
4
|
-
|
|
5
|
-
`kschema-fs-ui-alter-config` is a lightweight, configuration-driven utility designed to synchronize table column configurations (`columnsConfig`) from a master schema JSON to target UI configuration files (specifically matching `**/configs/showAll.json`).
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- 🔍 **Automated Discovery**: Recursively searches the workspace to locate `showAll.json` files within `configs/` folders.
|
|
12
|
-
- ⚙️ **Config Ingestion**: Extracts column definitions from a master JSON configuration file.
|
|
13
|
-
- ⚡ **Seamless Mutation**: Updates target JSON configuration files in-place with the retrieved column configuration.
|
|
14
|
-
- 📦 **Version-Isolated Runtimes**: Employs a dynamic runner system that loads the latest runtime version (currently `v3`).
|
|
15
|
-
- 📖 **Story-Driven Architecture**: The latest execution engine (`v3`) is structured as a clear narrative using concepts of a Scout, an Oracle, and a Blacksmith for self-documenting code.
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install kschema-fs-ui-alter-config
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
### Programmatic API
|
|
30
|
-
|
|
31
|
-
Import the default function and invoke it with target options:
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
import load from "kschema-fs-ui-alter-config";
|
|
35
|
-
import path from "node:path";
|
|
36
|
-
|
|
37
|
-
load({
|
|
38
|
-
// The directory tree containing UI json configurations to alter
|
|
39
|
-
toPath: path.join(process.cwd(), "ui", "doctors"),
|
|
40
|
-
|
|
41
|
-
// Path to the master JSON configuration schema containing the columnsConfig
|
|
42
|
-
configPath: path.join(process.cwd(), "Config", "Schemas", "doctors.json"),
|
|
43
|
-
|
|
44
|
-
// The action to perform (currently supports "Crud")
|
|
45
|
-
inAction: "Crud"
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Architecture & Code Story (v3)
|
|
52
|
-
|
|
53
|
-
In version 3, the codebase behaves like an adventure quest rather than standard dry modules:
|
|
54
|
-
|
|
55
|
-
1. **The Scout** (`scout.js`): Recursively searches the specified realm (`toPath`) to locate target gems (`showAll.json` under `configs/` subdirectories).
|
|
56
|
-
2. **The Oracle** (`oracle.js`): Consults the ancient scrolls (`configPath`) to fetch the master `columnsConfig`.
|
|
57
|
-
3. **The Blacksmith** (`blacksmith.js`): Transmutes/forges the target files in-place by infusing them with the columns configuration.
|
|
58
|
-
4. **The Chronicle** (`index.js`): Directs the journey, orchestrating the steps from scouting to transmuting.
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Local Development & Testing
|
|
63
|
-
|
|
64
|
-
Clone the repository:
|
|
65
|
-
```bash
|
|
66
|
-
git clone https://github.com/keshavsoft/kschema-fs-ui-alter-config.git
|
|
67
|
-
cd kschema-fs-ui-alter-config
|
|
68
|
-
npm install
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
To run the local validation tests:
|
|
72
|
-
```bash
|
|
73
|
-
cd test/v3
|
|
74
|
-
node test.js
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## License
|
|
80
|
-
|
|
81
|
-
MIT
|
|
1
|
+
# kschema-fs-ui-alter-config
|
|
2
|
+
|
|
3
|
+
> Find JSON files in your UI directory structure and inject/alter their column configurations automatically.
|
|
4
|
+
|
|
5
|
+
`kschema-fs-ui-alter-config` is a lightweight, configuration-driven utility designed to synchronize table column configurations (`columnsConfig`) from a master schema JSON to target UI configuration files (specifically matching `**/configs/showAll.json`).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🔍 **Automated Discovery**: Recursively searches the workspace to locate `showAll.json` files within `configs/` folders.
|
|
12
|
+
- ⚙️ **Config Ingestion**: Extracts column definitions from a master JSON configuration file.
|
|
13
|
+
- ⚡ **Seamless Mutation**: Updates target JSON configuration files in-place with the retrieved column configuration.
|
|
14
|
+
- 📦 **Version-Isolated Runtimes**: Employs a dynamic runner system that loads the latest runtime version (currently `v3`).
|
|
15
|
+
- 📖 **Story-Driven Architecture**: The latest execution engine (`v3`) is structured as a clear narrative using concepts of a Scout, an Oracle, and a Blacksmith for self-documenting code.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install kschema-fs-ui-alter-config
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Programmatic API
|
|
30
|
+
|
|
31
|
+
Import the default function and invoke it with target options:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import load from "kschema-fs-ui-alter-config";
|
|
35
|
+
import path from "node:path";
|
|
36
|
+
|
|
37
|
+
load({
|
|
38
|
+
// The directory tree containing UI json configurations to alter
|
|
39
|
+
toPath: path.join(process.cwd(), "ui", "doctors"),
|
|
40
|
+
|
|
41
|
+
// Path to the master JSON configuration schema containing the columnsConfig
|
|
42
|
+
configPath: path.join(process.cwd(), "Config", "Schemas", "doctors.json"),
|
|
43
|
+
|
|
44
|
+
// The action to perform (currently supports "Crud")
|
|
45
|
+
inAction: "Crud"
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Architecture & Code Story (v3)
|
|
52
|
+
|
|
53
|
+
In version 3, the codebase behaves like an adventure quest rather than standard dry modules:
|
|
54
|
+
|
|
55
|
+
1. **The Scout** (`scout.js`): Recursively searches the specified realm (`toPath`) to locate target gems (`showAll.json` under `configs/` subdirectories).
|
|
56
|
+
2. **The Oracle** (`oracle.js`): Consults the ancient scrolls (`configPath`) to fetch the master `columnsConfig`.
|
|
57
|
+
3. **The Blacksmith** (`blacksmith.js`): Transmutes/forges the target files in-place by infusing them with the columns configuration.
|
|
58
|
+
4. **The Chronicle** (`index.js`): Directs the journey, orchestrating the steps from scouting to transmuting.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Local Development & Testing
|
|
63
|
+
|
|
64
|
+
Clone the repository:
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/keshavsoft/kschema-fs-ui-alter-config.git
|
|
67
|
+
cd kschema-fs-ui-alter-config
|
|
68
|
+
npm install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To run the local validation tests:
|
|
72
|
+
```bash
|
|
73
|
+
cd test/v3
|
|
74
|
+
node test.js
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
|
|
7
|
-
export default function getLatestVersion() {
|
|
8
|
-
const versions = fs.readdirSync(path.join(__dirname, ".."))
|
|
9
|
-
.filter(n => /^v\d+$/.test(n))
|
|
10
|
-
.sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
|
|
11
|
-
|
|
12
|
-
return versions.at(-1);
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default function getLatestVersion() {
|
|
8
|
+
const versions = fs.readdirSync(path.join(__dirname, ".."))
|
|
9
|
+
.filter(n => /^v\d+$/.test(n))
|
|
10
|
+
.sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
|
|
11
|
+
|
|
12
|
+
return versions.at(-1);
|
|
13
13
|
};
|
package/bin/core/loadRunner.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default async function loadRunner(version) {
|
|
2
|
-
const mod = await import(`../${version}/start.js`);
|
|
3
|
-
|
|
4
|
-
if (typeof mod.default !== "function") {
|
|
5
|
-
throw new Error(`Invalid start.js in ${version}`);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return mod.default;
|
|
1
|
+
export default async function loadRunner(version) {
|
|
2
|
+
const mod = await import(`../${version}/start.js`);
|
|
3
|
+
|
|
4
|
+
if (typeof mod.default !== "function") {
|
|
5
|
+
throw new Error(`Invalid start.js in ${version}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return mod.default;
|
|
9
9
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
function transmuteGemsWithWisdom({ gems, wisdom }) {
|
|
4
|
-
gems.forEach(gemPath => {
|
|
5
|
-
const rawGem = fs.readFileSync(gemPath, "utf-8");
|
|
6
|
-
const parsedGem = JSON.parse(rawGem);
|
|
7
|
-
|
|
8
|
-
parsedGem.columnsConfig = wisdom;
|
|
9
|
-
|
|
10
|
-
fs.writeFileSync(gemPath, JSON.stringify(parsedGem), "utf-8");
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { transmuteGemsWithWisdom };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
function transmuteGemsWithWisdom({ gems, wisdom }) {
|
|
4
|
+
gems.forEach(gemPath => {
|
|
5
|
+
const rawGem = fs.readFileSync(gemPath, "utf-8");
|
|
6
|
+
const parsedGem = JSON.parse(rawGem);
|
|
7
|
+
|
|
8
|
+
parsedGem.columnsConfig = wisdom;
|
|
9
|
+
|
|
10
|
+
fs.writeFileSync(gemPath, JSON.stringify(parsedGem), "utf-8");
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { transmuteGemsWithWisdom };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
function consultTheAncientScrolls({ scrollPath }) {
|
|
4
|
-
if (!fs.existsSync(scrollPath)) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const scrollContent = fs.readFileSync(scrollPath, "utf-8");
|
|
9
|
-
const decodedScroll = JSON.parse(scrollContent);
|
|
10
|
-
|
|
11
|
-
return decodedScroll.columnsConfig || {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { consultTheAncientScrolls };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
function consultTheAncientScrolls({ scrollPath }) {
|
|
4
|
+
if (!fs.existsSync(scrollPath)) {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const scrollContent = fs.readFileSync(scrollPath, "utf-8");
|
|
9
|
+
const decodedScroll = JSON.parse(scrollContent);
|
|
10
|
+
|
|
11
|
+
return decodedScroll.columnsConfig || {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { consultTheAncientScrolls };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
function scoutTheRealmForTargetJsons(realmPath) {
|
|
5
|
-
const allDiscoveries = fs.readdirSync(realmPath, { recursive: true });
|
|
6
|
-
|
|
7
|
-
const targetGems = allDiscoveries.filter(discovery => {
|
|
8
|
-
const itemName = path.basename(discovery);
|
|
9
|
-
const parentFolderName = path.basename(path.dirname(discovery)).toLowerCase();
|
|
10
|
-
return itemName === "showAll.json" && parentFolderName === "configs";
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return targetGems.map(gem => path.join(realmPath, gem));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { scoutTheRealmForTargetJsons };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
function scoutTheRealmForTargetJsons(realmPath) {
|
|
5
|
+
const allDiscoveries = fs.readdirSync(realmPath, { recursive: true });
|
|
6
|
+
|
|
7
|
+
const targetGems = allDiscoveries.filter(discovery => {
|
|
8
|
+
const itemName = path.basename(discovery);
|
|
9
|
+
const parentFolderName = path.basename(path.dirname(discovery)).toLowerCase();
|
|
10
|
+
return itemName === "showAll.json" && parentFolderName === "configs";
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return targetGems.map(gem => path.join(realmPath, gem));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { scoutTheRealmForTargetJsons };
|
package/bin/v3/getConfig.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
function readAllJsonFilesSync(dirPath) {
|
|
5
|
-
try {
|
|
6
|
-
// Read directory content and filter out non-JSON extensions
|
|
7
|
-
return fs.readdirSync(dirPath)
|
|
8
|
-
.filter(file => path.extname(file).toLowerCase() === '.json')
|
|
9
|
-
.map(file => {
|
|
10
|
-
const fullPath = path.join(dirPath, file);
|
|
11
|
-
const rawContent = fs.readFileSync(fullPath, 'utf8');
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
fileName: file,
|
|
15
|
-
content: JSON.parse(rawContent)
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error('Error scanning folder sync:', error.message);
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default readAllJsonFilesSync;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
function readAllJsonFilesSync(dirPath) {
|
|
5
|
+
try {
|
|
6
|
+
// Read directory content and filter out non-JSON extensions
|
|
7
|
+
return fs.readdirSync(dirPath)
|
|
8
|
+
.filter(file => path.extname(file).toLowerCase() === '.json')
|
|
9
|
+
.map(file => {
|
|
10
|
+
const fullPath = path.join(dirPath, file);
|
|
11
|
+
const rawContent = fs.readFileSync(fullPath, 'utf8');
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
fileName: file,
|
|
15
|
+
content: JSON.parse(rawContent)
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error scanning folder sync:', error.message);
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default readAllJsonFilesSync;
|
package/bin/v3/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import dotenv from "dotenv";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import readAllJsonFilesSync from "./getConfig.js";
|
|
5
|
-
|
|
6
|
-
const getAllFilesContent = ({ rootPath }) => {
|
|
7
|
-
dotenv.config({
|
|
8
|
-
path: path.join(rootPath, ".env")
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
12
|
-
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
13
|
-
|
|
14
|
-
return allJsonData;
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getTableNames = ({ rootPath }) => {
|
|
19
|
-
dotenv.config({
|
|
20
|
-
path: path.join(rootPath, ".env")
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
24
|
-
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
25
|
-
|
|
26
|
-
return allJsonData.map(element => {
|
|
27
|
-
return {
|
|
28
|
-
name: element.fileName,
|
|
29
|
-
tableName: element.content.tableName
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import readAllJsonFilesSync from "./getConfig.js";
|
|
5
|
+
|
|
6
|
+
const getAllFilesContent = ({ rootPath }) => {
|
|
7
|
+
dotenv.config({
|
|
8
|
+
path: path.join(rootPath, ".env")
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
12
|
+
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
13
|
+
|
|
14
|
+
return allJsonData;
|
|
15
|
+
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getTableNames = ({ rootPath }) => {
|
|
19
|
+
dotenv.config({
|
|
20
|
+
path: path.join(rootPath, ".env")
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
24
|
+
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
25
|
+
|
|
26
|
+
return allJsonData.map(element => {
|
|
27
|
+
return {
|
|
28
|
+
name: element.fileName,
|
|
29
|
+
tableName: element.content.tableName
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
34
|
export { getAllFilesContent, getTableNames };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
function transmuteGemsWithWisdom({ gems, wisdom }) {
|
|
4
|
-
gems.forEach(gemPath => {
|
|
5
|
-
const rawGem = fs.readFileSync(gemPath, "utf-8");
|
|
6
|
-
const parsedGem = JSON.parse(rawGem);
|
|
7
|
-
|
|
8
|
-
parsedGem.columnsConfig = wisdom;
|
|
9
|
-
|
|
10
|
-
fs.writeFileSync(gemPath, JSON.stringify(parsedGem), "utf-8");
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { transmuteGemsWithWisdom };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
function transmuteGemsWithWisdom({ gems, wisdom }) {
|
|
4
|
+
gems.forEach(gemPath => {
|
|
5
|
+
const rawGem = fs.readFileSync(gemPath, "utf-8");
|
|
6
|
+
const parsedGem = JSON.parse(rawGem);
|
|
7
|
+
|
|
8
|
+
parsedGem.columnsConfig = wisdom;
|
|
9
|
+
|
|
10
|
+
fs.writeFileSync(gemPath, JSON.stringify(parsedGem), "utf-8");
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { transmuteGemsWithWisdom };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
function consultTheAncientScrolls({ scrollPath }) {
|
|
4
|
-
if (!fs.existsSync(scrollPath)) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const scrollContent = fs.readFileSync(scrollPath, "utf-8");
|
|
9
|
-
const decodedScroll = JSON.parse(scrollContent);
|
|
10
|
-
|
|
11
|
-
return decodedScroll.columnsConfig || {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { consultTheAncientScrolls };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
function consultTheAncientScrolls({ scrollPath }) {
|
|
4
|
+
if (!fs.existsSync(scrollPath)) {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const scrollContent = fs.readFileSync(scrollPath, "utf-8");
|
|
9
|
+
const decodedScroll = JSON.parse(scrollContent);
|
|
10
|
+
|
|
11
|
+
return decodedScroll.columnsConfig || {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { consultTheAncientScrolls };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
function scoutTheRealmForTargetJsons(realmPath) {
|
|
5
|
-
const allDiscoveries = fs.readdirSync(realmPath, { recursive: true });
|
|
6
|
-
|
|
7
|
-
const targetGems = allDiscoveries.filter(discovery => {
|
|
8
|
-
const itemName = path.basename(discovery);
|
|
9
|
-
const parentFolderName = path.basename(path.dirname(discovery)).toLowerCase();
|
|
10
|
-
return itemName === "showAll.json" && parentFolderName === "configs";
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return targetGems.map(gem => path.join(realmPath, gem));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { scoutTheRealmForTargetJsons };
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
function scoutTheRealmForTargetJsons(realmPath) {
|
|
5
|
+
const allDiscoveries = fs.readdirSync(realmPath, { recursive: true });
|
|
6
|
+
|
|
7
|
+
const targetGems = allDiscoveries.filter(discovery => {
|
|
8
|
+
const itemName = path.basename(discovery);
|
|
9
|
+
const parentFolderName = path.basename(path.dirname(discovery)).toLowerCase();
|
|
10
|
+
return itemName === "showAll.json" && parentFolderName === "configs";
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return targetGems.map(gem => path.join(realmPath, gem));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { scoutTheRealmForTargetJsons };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
function readAllJsonFilesSync(dirPath) {
|
|
5
|
+
try {
|
|
6
|
+
// Read directory content and filter out non-JSON extensions
|
|
7
|
+
return fs.readdirSync(dirPath)
|
|
8
|
+
.filter(file => path.extname(file).toLowerCase() === '.json')
|
|
9
|
+
.map(file => {
|
|
10
|
+
const fullPath = path.join(dirPath, file);
|
|
11
|
+
const rawContent = fs.readFileSync(fullPath, 'utf8');
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
fileName: file,
|
|
15
|
+
content: JSON.parse(rawContent)
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error scanning folder sync:', error.message);
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default readAllJsonFilesSync;
|
package/bin/v4/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import readAllJsonFilesSync from "./getConfig.js";
|
|
5
|
+
|
|
6
|
+
const getAllFilesContent = (rootPath) => {
|
|
7
|
+
dotenv.config({
|
|
8
|
+
path: path.join(rootPath, ".env")
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
12
|
+
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
13
|
+
|
|
14
|
+
return allJsonData;
|
|
15
|
+
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getTableNames = (rootPath) => {
|
|
19
|
+
dotenv.config({
|
|
20
|
+
path: path.join(rootPath, ".env")
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const schemaPath = path.join(rootPath, process.env.SchemaPath);
|
|
24
|
+
const allJsonData = readAllJsonFilesSync(schemaPath);
|
|
25
|
+
|
|
26
|
+
return allJsonData.map(element => {
|
|
27
|
+
return {
|
|
28
|
+
name: element.fileName,
|
|
29
|
+
tableName: element.content.tableName
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getPort = (rootPath) => {
|
|
35
|
+
dotenv.config({
|
|
36
|
+
path: path.join(rootPath, ".env")
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return process.env.PORT;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { getAllFilesContent, getTableNames, getPort };
|
package/index.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
const rootDir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const binDir = join(rootDir, "bin");
|
|
7
|
-
|
|
8
|
-
const latestVersion = readdirSync(binDir, { withFileTypes: true })
|
|
9
|
-
.filter((entry) => entry.isDirectory() && /^v\d+$/.test(entry.name))
|
|
10
|
-
.filter(({ name }) => existsSync(join(binDir, name, "index.js")))
|
|
11
|
-
.map(({ name }) => ({ name, version: Number(name.slice(1)) }))
|
|
12
|
-
.sort((a, b) => b.version - a.version)
|
|
13
|
-
.at(0);
|
|
14
|
-
|
|
15
|
-
if (!latestVersion) {
|
|
16
|
-
throw new Error("No versioned bin/v*/index.js entry found.");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
20
|
-
|
|
21
|
-
const latestModulePath = join(binDir, latestVersion.name, "index.js");
|
|
22
|
-
const latestModule = await import(pathToFileURL(latestModulePath).href);
|
|
23
|
-
|
|
24
|
-
// Auto-export synchronization
|
|
25
|
-
const exportKeys = Object.keys(latestModule).filter(key => key !== "default").sort();
|
|
26
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
27
|
-
const currentContent = readFileSync(currentFile, "utf-8");
|
|
28
|
-
|
|
29
|
-
const expectedExportLine = `export const { ${exportKeys.join(", ")} } = latestModule;`;
|
|
30
|
-
const regex = /export const \{[^}]*\}\s*=\s*latestModule;/;
|
|
31
|
-
|
|
32
|
-
const match = currentContent.match(regex);
|
|
33
|
-
if (!match || match[0] !== expectedExportLine) {
|
|
34
|
-
let newContent;
|
|
35
|
-
if (match) {
|
|
36
|
-
newContent = currentContent.replace(regex, expectedExportLine);
|
|
37
|
-
} else {
|
|
38
|
-
newContent = currentContent.trimEnd() + `\n\n${expectedExportLine}\n`;
|
|
39
|
-
}
|
|
40
|
-
writeFileSync(currentFile, newContent, "utf-8");
|
|
41
|
-
console.log(`\x1b[32m[kschema-fs-read-config] Automatically updated root index.js exports to match ${latestVersion.name}: [${exportKeys.join(", ")}]\x1b[0m`);
|
|
42
|
-
console.log(`\x1b[33mPlease re-run your command.\x1b[0m`);
|
|
43
|
-
process.exit(0);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { latestModule };
|
|
47
|
-
|
|
48
|
-
export const { getAllFilesContent, getTableNames } = latestModule;
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const rootDir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const binDir = join(rootDir, "bin");
|
|
7
|
+
|
|
8
|
+
const latestVersion = readdirSync(binDir, { withFileTypes: true })
|
|
9
|
+
.filter((entry) => entry.isDirectory() && /^v\d+$/.test(entry.name))
|
|
10
|
+
.filter(({ name }) => existsSync(join(binDir, name, "index.js")))
|
|
11
|
+
.map(({ name }) => ({ name, version: Number(name.slice(1)) }))
|
|
12
|
+
.sort((a, b) => b.version - a.version)
|
|
13
|
+
.at(0);
|
|
14
|
+
|
|
15
|
+
if (!latestVersion) {
|
|
16
|
+
throw new Error("No versioned bin/v*/index.js entry found.");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
20
|
+
|
|
21
|
+
const latestModulePath = join(binDir, latestVersion.name, "index.js");
|
|
22
|
+
const latestModule = await import(pathToFileURL(latestModulePath).href);
|
|
23
|
+
|
|
24
|
+
// Auto-export synchronization
|
|
25
|
+
const exportKeys = Object.keys(latestModule).filter(key => key !== "default").sort();
|
|
26
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
27
|
+
const currentContent = readFileSync(currentFile, "utf-8");
|
|
28
|
+
|
|
29
|
+
const expectedExportLine = `export const { ${exportKeys.join(", ")} } = latestModule;`;
|
|
30
|
+
const regex = /export const \{[^}]*\}\s*=\s*latestModule;/;
|
|
31
|
+
|
|
32
|
+
const match = currentContent.match(regex);
|
|
33
|
+
if (!match || match[0] !== expectedExportLine) {
|
|
34
|
+
let newContent;
|
|
35
|
+
if (match) {
|
|
36
|
+
newContent = currentContent.replace(regex, expectedExportLine);
|
|
37
|
+
} else {
|
|
38
|
+
newContent = currentContent.trimEnd() + `\n\n${expectedExportLine}\n`;
|
|
39
|
+
}
|
|
40
|
+
writeFileSync(currentFile, newContent, "utf-8");
|
|
41
|
+
console.log(`\x1b[32m[kschema-fs-read-config] Automatically updated root index.js exports to match ${latestVersion.name}: [${exportKeys.join(", ")}]\x1b[0m`);
|
|
42
|
+
console.log(`\x1b[33mPlease re-run your command.\x1b[0m`);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { latestModule };
|
|
47
|
+
|
|
48
|
+
export const { getAllFilesContent, getPort, getTableNames } = latestModule;
|
|
49
|
+
|
|
50
|
+
|
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "kschema-fs-read-config",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "read the env file to arrive the location of schemas in config",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"cli",
|
|
7
|
-
"scaffold",
|
|
8
|
-
"templates",
|
|
9
|
-
"node",
|
|
10
|
-
"project-generator"
|
|
11
|
-
],
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"dotenv": "^17.4.2"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"sync": "node bin/core/syncExports.js",
|
|
17
|
-
"prepublishOnly": "npm run sync"
|
|
18
|
-
},
|
|
19
|
-
"type": "module",
|
|
20
|
-
"exports": {
|
|
21
|
-
".": "./index.js"
|
|
22
|
-
},
|
|
23
|
-
"files": [
|
|
24
|
-
"bin/",
|
|
25
|
-
"index.js",
|
|
26
|
-
"README.md",
|
|
27
|
-
"LICENSE"
|
|
28
|
-
],
|
|
29
|
-
"homepage": "https://cli.keshavsoft.com",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/keshavsoft/kschema-fs-read-config"
|
|
33
|
-
},
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/keshavsoft/kschema-fs-read-config/issues"
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "kschema-fs-read-config",
|
|
3
|
+
"version": "1.4.2",
|
|
4
|
+
"description": "read the env file to arrive the location of schemas in config",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"templates",
|
|
9
|
+
"node",
|
|
10
|
+
"project-generator"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"dotenv": "^17.4.2"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"sync": "node bin/core/syncExports.js",
|
|
17
|
+
"prepublishOnly": "npm run sync"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./index.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/",
|
|
25
|
+
"index.js",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"homepage": "https://cli.keshavsoft.com",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/keshavsoft/kschema-fs-read-config"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/keshavsoft/kschema-fs-read-config/issues"
|
|
36
|
+
}
|
|
37
37
|
}
|
package/bin/v2/alterConfig.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
function startFunc({ inFilePaths, inColumnsConfig }) {
|
|
5
|
-
inFilePaths.forEach(element => {
|
|
6
|
-
|
|
7
|
-
const schema = JSON.parse(fs.readFileSync(element, "utf-8"));
|
|
8
|
-
console.log(schema);
|
|
9
|
-
schema.columnsConfig = inColumnsConfig;
|
|
10
|
-
|
|
11
|
-
fs.writeFileSync(element, JSON.stringify(schema), 'utf8');
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default startFunc;
|
package/bin/v2/getAllJsons.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
function getJsonFiles(dirPath) {
|
|
5
|
-
// Read all files and folders recursively
|
|
6
|
-
const files = fs.readdirSync(dirPath, { recursive: true });
|
|
7
|
-
|
|
8
|
-
// Filter out only files ending with '.json' and turn them into full paths
|
|
9
|
-
return files
|
|
10
|
-
.filter(file => path.extname(file) === '.json')
|
|
11
|
-
.map(file => path.join(dirPath, file));
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function getJsonFilesNeeded(dirPath) {
|
|
15
|
-
// Read all files and folders recursively
|
|
16
|
-
const files = fs.readdirSync(dirPath, { recursive: true });
|
|
17
|
-
|
|
18
|
-
// Filter out only files ending with '.json' and turn them into full paths
|
|
19
|
-
return files
|
|
20
|
-
.filter(file =>
|
|
21
|
-
path.basename(file) === "showAll.json" &&
|
|
22
|
-
path.basename(path.dirname(file)).toLowerCase() === "configs"
|
|
23
|
-
)
|
|
24
|
-
.map(file => path.join(dirPath, file));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { getJsonFiles, getJsonFilesNeeded };
|
package/bin/v2/getConfig.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const startFunc = ({ configPath }) => {
|
|
5
|
-
const schemaPath = configPath;
|
|
6
|
-
|
|
7
|
-
if (!fs.existsSync(schemaPath)) return "{}";
|
|
8
|
-
|
|
9
|
-
const schema = JSON.parse(fs.readFileSync(schemaPath, "utf-8"));
|
|
10
|
-
|
|
11
|
-
return schema.columnsConfig;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default startFunc;
|
package/bin/v2/index.js
DELETED