@open-audio-stack/core 0.0.10 → 0.0.12
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/build/Registry.js +1 -1
- package/build/helpers/file.d.ts +5 -1
- package/build/helpers/file.js +21 -0
- package/build/helpers/utils.d.ts +4 -0
- package/build/helpers/utils.js +22 -0
- package/build/types/Package.d.ts +2 -2
- package/package.json +2 -1
package/build/Registry.js
CHANGED
package/build/helpers/file.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { PackageInterface } from '../types/Package.js';
|
|
1
|
+
import { PackageInterface, PackageValidationError } from '../types/Package.js';
|
|
2
|
+
import { PluginFile } from '../types/Plugin.js';
|
|
3
|
+
import { PresetFile } from '../types/Preset.js';
|
|
4
|
+
import { ProjectFile } from '../types/Project.js';
|
|
2
5
|
export declare function dirApp(): string;
|
|
3
6
|
export declare function dirCreate(dir: string): string | false;
|
|
4
7
|
export declare function dirDelete(dir: string): false | void;
|
|
@@ -27,5 +30,6 @@ export declare function fileReadJson(filePath: string): any;
|
|
|
27
30
|
export declare function fileReadString(filePath: string): string;
|
|
28
31
|
export declare function fileReadYaml(filePath: string): unknown;
|
|
29
32
|
export declare function fileSize(filePath: string): number;
|
|
33
|
+
export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): PackageValidationError[];
|
|
30
34
|
export declare function zipCreate(filesPath: string, zipPath: string): void;
|
|
31
35
|
export declare function zipExtract(content: any, dirPath: string): void;
|
package/build/helpers/file.js
CHANGED
|
@@ -7,6 +7,7 @@ import { moveSync } from 'fs-extra/esm';
|
|
|
7
7
|
import os from 'os';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import yaml from 'js-yaml';
|
|
10
|
+
import { PackageValidation } from '../types/Package.js';
|
|
10
11
|
export function dirApp() {
|
|
11
12
|
if (process.platform === 'win32')
|
|
12
13
|
return process.env.APPDATA || os.homedir();
|
|
@@ -174,6 +175,26 @@ export function fileReadYaml(filePath) {
|
|
|
174
175
|
export function fileSize(filePath) {
|
|
175
176
|
return statSync(filePath).size;
|
|
176
177
|
}
|
|
178
|
+
export function fileValidateMetadata(filePath, fileMetadata) {
|
|
179
|
+
const errors = [];
|
|
180
|
+
if (fileMetadata.hash !== fileHash(filePath)) {
|
|
181
|
+
errors.push({
|
|
182
|
+
field: 'hash',
|
|
183
|
+
error: PackageValidation.INVALID_VALUE,
|
|
184
|
+
valueExpected: fileHash(filePath),
|
|
185
|
+
valueReceived: fileMetadata.hash,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (fileMetadata.size !== fileSize(filePath)) {
|
|
189
|
+
errors.push({
|
|
190
|
+
field: 'size',
|
|
191
|
+
error: PackageValidation.INVALID_VALUE,
|
|
192
|
+
valueExpected: String(fileSize(filePath)),
|
|
193
|
+
valueReceived: String(fileMetadata.size),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return errors;
|
|
197
|
+
}
|
|
177
198
|
export function zipCreate(filesPath, zipPath) {
|
|
178
199
|
if (fileExists(zipPath)) {
|
|
179
200
|
unlinkSync(zipPath);
|
package/build/helpers/utils.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { PackageValidationError, PackageValidationRec } from '../types/Package.js';
|
|
2
|
+
export declare function logReport(info: string, errors?: PackageValidationError[], recs?: PackageValidationRec[]): void;
|
|
3
|
+
export declare function logErrors(errors: PackageValidationError[]): void;
|
|
4
|
+
export declare function logRecommendations(recs: PackageValidationRec[]): void;
|
|
1
5
|
export declare function pathGetExt(path: string, sep?: string): string;
|
|
2
6
|
export declare function pathGetDirectory(path: string, sep?: string): string;
|
|
3
7
|
export declare function pathGetFilename(path: string, sep?: string): string;
|
package/build/helpers/utils.js
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export function logReport(info, errors, recs) {
|
|
3
|
+
if (errors) {
|
|
4
|
+
console.log(chalk.red(`X ${info}`));
|
|
5
|
+
logErrors(errors);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
console.log(chalk.green(`✓ ${info}`));
|
|
9
|
+
}
|
|
10
|
+
if (recs)
|
|
11
|
+
logRecommendations(recs);
|
|
12
|
+
}
|
|
13
|
+
export function logErrors(errors) {
|
|
14
|
+
errors.forEach(error => {
|
|
15
|
+
console.log(chalk.red(`- ${error.field} (${error.error}) received '${error.valueReceived}' expected '${error.valueExpected}'`));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function logRecommendations(recs) {
|
|
19
|
+
recs.forEach(rec => {
|
|
20
|
+
console.log(chalk.yellow(`- ${rec.field} ${rec.rec}`));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
1
23
|
export function pathGetExt(path, sep = '.') {
|
|
2
24
|
return path.substring(path.lastIndexOf(sep) + 1);
|
|
3
25
|
}
|
package/build/types/Package.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export interface PackageValidationField {
|
|
|
35
35
|
export interface PackageValidationError {
|
|
36
36
|
field: string;
|
|
37
37
|
error: PackageValidation;
|
|
38
|
-
valueExpected: string;
|
|
39
|
-
valueReceived: string;
|
|
38
|
+
valueExpected: boolean | number | string;
|
|
39
|
+
valueReceived: boolean | number | string;
|
|
40
40
|
}
|
|
41
41
|
export interface PackageValidationRec {
|
|
42
42
|
field: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-audio-stack/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "Open-source audio plugin management software",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"adm-zip": "^0.5.16",
|
|
55
|
+
"chalk": "^5.3.0",
|
|
55
56
|
"fs-extra": "^11.2.0",
|
|
56
57
|
"glob": "^11.0.0",
|
|
57
58
|
"js-yaml": "^4.1.0",
|