@leyyo/common 1.3.10 → 1.3.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/dist/function/index.d.ts +1 -1
- package/dist/function/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -1
- package/dist/sys/index.d.ts +4 -0
- package/dist/sys/index.js +4 -0
- package/dist/sys/index.types.d.ts +13 -0
- package/dist/sys/index.types.js +1 -0
- package/dist/sys/leyyo-config.d.ts +2 -0
- package/dist/sys/leyyo-config.js +19 -0
- package/dist/sys/package-json.d.ts +3 -0
- package/dist/sys/package-json.js +39 -0
- package/dist/sys/sys-all.d.ts +2 -0
- package/dist/sys/sys-all.js +8 -0
- package/package.json +3 -1
package/dist/function/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './index.types.js';
|
|
2
|
+
export * from './define-loader.js';
|
|
2
3
|
export * from './delay.js';
|
|
3
4
|
export * from './delete-prop.js';
|
|
4
5
|
export * from './empty-fn.js';
|
|
@@ -18,7 +19,6 @@ export * from './is-obj.js';
|
|
|
18
19
|
export * from './is-text.js';
|
|
19
20
|
export * from './is-anonymous-name.js';
|
|
20
21
|
export * from './jitter-interval.js';
|
|
21
|
-
export * from './define-loader.js';
|
|
22
22
|
export * from './stamp-loader.js';
|
|
23
23
|
export * from './one-or-more.js';
|
|
24
24
|
export * from './opt-add.js';
|
package/dist/function/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './index.types.js';
|
|
2
|
+
export * from './define-loader.js';
|
|
2
3
|
export * from './delay.js';
|
|
3
4
|
export * from './delete-prop.js';
|
|
4
5
|
export * from './empty-fn.js';
|
|
@@ -18,7 +19,6 @@ export * from './is-obj.js';
|
|
|
18
19
|
export * from './is-text.js';
|
|
19
20
|
export * from './is-anonymous-name.js';
|
|
20
21
|
export * from './jitter-interval.js';
|
|
21
|
-
export * from './define-loader.js';
|
|
22
22
|
export * from './stamp-loader.js';
|
|
23
23
|
export * from './one-or-more.js';
|
|
24
24
|
export * from './opt-add.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/internal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FQN
|
|
1
|
+
export declare const NME: string, FQN: string, VER: string, CNF: import("./sys/index.types.js").LeyyoConfig;
|
package/dist/internal.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { sysAll } from "./sys/index.js";
|
|
2
|
+
export const { pck: { name: NME, fqn: FQN, version: VER }, config: CNF } = sysAll(import.meta.url);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface PackageJson {
|
|
2
|
+
fqn: string;
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
[k: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface LeyyoConfig {
|
|
8
|
+
[fqn: string]: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface LeyyoSysAll<C extends LeyyoConfig = LeyyoConfig, P extends PackageJson = PackageJson> {
|
|
11
|
+
config: C;
|
|
12
|
+
pck: P;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
|
+
export function leyyoConfig(url) {
|
|
7
|
+
try {
|
|
8
|
+
const __dirname = dirname(dirname(fileURLToPath(url)));
|
|
9
|
+
const yamlPath = path.normalize(__dirname + '/.leyyo.yaml');
|
|
10
|
+
if (fs.existsSync(yamlPath)) {
|
|
11
|
+
const input = fs.readFileSync(yamlPath, 'utf8');
|
|
12
|
+
return yaml.load(input);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
console.log(`[leyyoConfig] ${e.name} => ${e.message}`);
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
const _empty = { fqn: 'leyyo.unknown', name: '@leyyo/unknown', version: '0.0.0' };
|
|
6
|
+
const _map = new Map();
|
|
7
|
+
export function packageJson(url, full) {
|
|
8
|
+
try {
|
|
9
|
+
const __dirname = dirname(dirname(fileURLToPath(url)));
|
|
10
|
+
const jsonPath = path.normalize(__dirname + '/package.json');
|
|
11
|
+
if (fs.existsSync(jsonPath)) {
|
|
12
|
+
const jsonData = JSON.parse(fs.readFileSync(jsonPath, { encoding: 'utf-8', flag: 'r' }));
|
|
13
|
+
if (jsonData) {
|
|
14
|
+
if (!jsonData?.name) {
|
|
15
|
+
return _empty;
|
|
16
|
+
}
|
|
17
|
+
const name = jsonData.name;
|
|
18
|
+
const version = jsonData.version;
|
|
19
|
+
if (_map.has(name)) {
|
|
20
|
+
console.error(`Same package[${name}] duplicated, versions: ['${_map.get(name)}', '${version}']`);
|
|
21
|
+
}
|
|
22
|
+
_map.set(name, version);
|
|
23
|
+
const fqn = jsonData?.name.split('/').join('.').split('@').join('');
|
|
24
|
+
if (full) {
|
|
25
|
+
return { ...jsonData, fqn };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
fqn,
|
|
29
|
+
name: jsonData?.name,
|
|
30
|
+
version: jsonData?.version,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
console.log(`[packageJson] ${e.name} => ${e.message}`);
|
|
37
|
+
return _empty;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leyyo/common",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "Leyyo common library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"common"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@eslint/js": "^9.33.0",
|
|
38
38
|
"@jest/globals": "^29.7.0",
|
|
39
39
|
"@types/jest": "^30.0.0",
|
|
40
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
41
|
"@types/node": "^24.2.1",
|
|
41
42
|
"@typescript-eslint/eslint-plugin": "^8.39.1",
|
|
42
43
|
"@typescript-eslint/parser": "^8.39.1",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
66
|
+
"js-yaml": "^4.1.1",
|
|
65
67
|
"stacktrace-parser": "^0.1.11"
|
|
66
68
|
}
|
|
67
69
|
}
|