@toa.io/norm 1.0.0-alpha.5 → 1.0.0-alpha.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/norm",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "Toa declarations normalization and validation",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
24
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
25
|
-
"@toa.io/schema": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
27
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
23
|
+
"@toa.io/core": "1.0.0-alpha.7",
|
|
24
|
+
"@toa.io/generic": "1.0.0-alpha.7",
|
|
25
|
+
"@toa.io/schema": "1.0.0-alpha.7",
|
|
26
|
+
"@toa.io/schemas": "1.0.0-alpha.7",
|
|
27
|
+
"@toa.io/yaml": "1.0.0-alpha.7"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "4f5ac0bc342d4b7bd469fbe5c74266f050b55c9f"
|
|
30
30
|
}
|
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const { join } = require('node:path')
|
|
4
|
+
const { createHash } = require('node:crypto')
|
|
5
|
+
const fs = require('node:fs/promises')
|
|
6
|
+
const { createReadStream } = require('node:fs')
|
|
7
|
+
const { once } = require('node:events')
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
async function version (manifest) {
|
|
10
|
+
manifest.version ??= await hash(manifest.path)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function hash (path) {
|
|
14
|
+
const hash = await hashd(path)
|
|
15
|
+
|
|
16
|
+
return hash.digest('hex').slice(0, 8)
|
|
17
|
+
}
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} path
|
|
21
|
+
* @param {import('node:crypto').Hash} hash
|
|
22
|
+
*/
|
|
23
|
+
async function hashd (path, hash = createHash('sha256')) {
|
|
24
|
+
const stat = await fs.stat(path)
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
if (stat.isFile()) {
|
|
27
|
+
const stream = createReadStream(path)
|
|
28
|
+
|
|
29
|
+
stream.pipe(hash, { end: false })
|
|
30
|
+
|
|
31
|
+
return await once(stream, 'end')
|
|
15
32
|
}
|
|
16
33
|
|
|
34
|
+
if (stat.isDirectory()) {
|
|
35
|
+
const entries = await fs.opendir(path)
|
|
36
|
+
|
|
37
|
+
for await (const entry of entries) {
|
|
38
|
+
await hashd(join(path, entry.name), hash)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return hash
|
|
42
|
+
}
|
|
17
43
|
}
|
|
18
44
|
|
|
19
45
|
exports.version = version
|
package/src/.component/expand.js
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
version
|
|
12
12
|
} = require('./.expand')
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
async function expand (manifest) {
|
|
15
15
|
entity(manifest)
|
|
16
16
|
bridge(manifest)
|
|
17
17
|
operations(manifest)
|
|
@@ -19,7 +19,8 @@ const expand = (manifest) => {
|
|
|
19
19
|
receivers(manifest)
|
|
20
20
|
properties(manifest)
|
|
21
21
|
extensions(manifest)
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
await version(manifest)
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
exports.expand = expand
|