@open-audio-stack/core 0.0.15 → 0.0.17

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 CHANGED
@@ -12,6 +12,8 @@ export class Registry {
12
12
  });
13
13
  }
14
14
  packageVersionAdd(slug, type, version, pkgVersion) {
15
+ if (!semver.valid(version))
16
+ throw Error(`${version} is not a valid Semantic version`);
15
17
  let pkg = this.package(slug, type);
16
18
  if (!pkg) {
17
19
  pkg = this.packageAdd(slug, type);
@@ -35,6 +37,8 @@ export class Registry {
35
37
  return registryFiltered;
36
38
  }
37
39
  packageLatest(slug, type, version) {
40
+ if (version && !semver.valid(version))
41
+ throw Error(`${version} is not a valid Semantic version`);
38
42
  const pkg = this.package(slug, type);
39
43
  const pkgVersion = this.packageVersionLatest(pkg.versions);
40
44
  return pkg.versions[version || pkgVersion];
@@ -64,6 +68,8 @@ export class Registry {
64
68
  delete this.registry[type][slug];
65
69
  }
66
70
  packageVersionRemove(slug, type, version) {
71
+ if (!semver.valid(version))
72
+ throw Error(`${version} is not a valid Semantic version`);
67
73
  const pkg = this.package(slug, type);
68
74
  if (pkg && pkg.versions[version]) {
69
75
  delete pkg.versions[version];
@@ -22,7 +22,7 @@ export declare function fileDelete(filePath: string): boolean | void;
22
22
  export declare function fileExec(filePath: string): void;
23
23
  export declare function fileExists(filePath: string): boolean;
24
24
  export declare function fileJsonCreate(filePath: string, data: object): void;
25
- export declare function fileHash(filePath: string, algorithm?: string): string;
25
+ export declare function fileHash(filePath: string, algorithm?: string): Promise<string>;
26
26
  export declare function fileMove(filePath: string, newPath: string): void | boolean;
27
27
  export declare function fileOpen(filePath: string): Buffer;
28
28
  export declare function fileRead(filePath: string): string;
@@ -30,6 +30,6 @@ export declare function fileReadJson(filePath: string): any;
30
30
  export declare function fileReadString(filePath: string): string;
31
31
  export declare function fileReadYaml(filePath: string): unknown;
32
32
  export declare function fileSize(filePath: string): number;
33
- export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): PackageValidationError[];
33
+ export declare function fileValidateMetadata(filePath: string, fileMetadata: PluginFile | PresetFile | ProjectFile): Promise<PackageValidationError[]>;
34
34
  export declare function zipCreate(filesPath: string, zipPath: string): void;
35
35
  export declare function zipExtract(content: any, dirPath: string): void;
@@ -1,7 +1,8 @@
1
1
  import AdmZip from 'adm-zip';
2
2
  import { execSync } from 'child_process';
3
- import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
3
+ import { createReadStream, chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
4
4
  import { createHash } from 'crypto';
5
+ import stream from 'stream/promises';
5
6
  import { globSync } from 'glob';
6
7
  import { moveSync } from 'fs-extra/esm';
7
8
  import os from 'os';
@@ -127,10 +128,12 @@ export function fileExists(filePath) {
127
128
  export function fileJsonCreate(filePath, data) {
128
129
  return fileCreate(filePath, JSON.stringify(data, null, 2));
129
130
  }
130
- export function fileHash(filePath, algorithm = 'sha256') {
131
- const fileData = fileReadString(filePath);
132
- const fileNormalized = fileData.replace(/\r\n/g, '\n');
133
- return createHash(algorithm).update(fileNormalized, 'utf8').digest('hex');
131
+ export async function fileHash(filePath, algorithm = 'sha256') {
132
+ console.log('⎋', filePath);
133
+ const input = createReadStream(filePath);
134
+ const hash = createHash(algorithm);
135
+ await stream.pipeline(input, hash);
136
+ return hash.digest('hex');
134
137
  }
135
138
  export function fileMove(filePath, newPath) {
136
139
  if (fileExists(filePath)) {
@@ -175,13 +178,14 @@ export function fileReadYaml(filePath) {
175
178
  export function fileSize(filePath) {
176
179
  return statSync(filePath).size;
177
180
  }
178
- export function fileValidateMetadata(filePath, fileMetadata) {
181
+ export async function fileValidateMetadata(filePath, fileMetadata) {
179
182
  const errors = [];
180
- if (fileMetadata.sha256 !== fileHash(filePath)) {
183
+ const hash = await fileHash(filePath);
184
+ if (fileMetadata.sha256 !== hash) {
181
185
  errors.push({
182
186
  field: 'sha256',
183
187
  error: PackageValidation.INVALID_VALUE,
184
- valueExpected: fileHash(filePath),
188
+ valueExpected: hash,
185
189
  valueReceived: fileMetadata.sha256,
186
190
  });
187
191
  }
@@ -41,9 +41,9 @@ export function packageRecommendations(pkgVersion) {
41
41
  });
42
42
  });
43
43
  if (!supportedArchitectures.arm64)
44
- recs.push({ field: 'architectures', rec: 'should support Arm64' });
45
- if (!supportedArchitectures.bit64)
46
- recs.push({ field: 'architectures', rec: 'should support Bit64' });
44
+ recs.push({ field: 'architectures', rec: 'should support arm64' });
45
+ if (!supportedArchitectures.x64)
46
+ recs.push({ field: 'architectures', rec: 'should support x64' });
47
47
  if (!supportedSystems.linux)
48
48
  recs.push({ field: 'systems', rec: 'should support Linux' });
49
49
  if (!supportedSystems.mac)
@@ -1,8 +1,8 @@
1
1
  export declare enum Architecture {
2
2
  Arm32 = "arm32",
3
3
  Arm64 = "arm64",
4
- Bit32 = "bit32",
5
- Bit64 = "bit64"
4
+ X32 = "x32",
5
+ X64 = "x64"
6
6
  }
7
7
  export interface ArchitectureOption {
8
8
  description: string;
@@ -2,8 +2,8 @@ export var Architecture;
2
2
  (function (Architecture) {
3
3
  Architecture["Arm32"] = "arm32";
4
4
  Architecture["Arm64"] = "arm64";
5
- Architecture["Bit32"] = "bit32";
6
- Architecture["Bit64"] = "bit64";
5
+ Architecture["X32"] = "x32";
6
+ Architecture["X64"] = "x64";
7
7
  })(Architecture || (Architecture = {}));
8
8
  export const architectures = [
9
9
  {
@@ -18,12 +18,12 @@ export const architectures = [
18
18
  },
19
19
  {
20
20
  description: 'X86 processors are commonly used in desktop computers and laptops.',
21
- value: Architecture.Bit32,
21
+ value: Architecture.X32,
22
22
  name: 'x86 machine - 32-bit',
23
23
  },
24
24
  {
25
25
  description: 'X86 processors are commonly used in desktop computers and laptops.',
26
- value: Architecture.Bit64,
26
+ value: Architecture.X64,
27
27
  name: 'x86 machine - 64-bit',
28
28
  },
29
29
  ];
@@ -7,7 +7,8 @@ export declare enum FileFormat {
7
7
  Tarball = "tar.gz",
8
8
  TarballLegacy = "tgz",
9
9
  WindowsInstaller = "msi",
10
- Zip = "zip"
10
+ Zip = "zip",
11
+ Zip7 = "7z"
11
12
  }
12
13
  export interface FileFormatOption {
13
14
  description: string;
@@ -9,6 +9,7 @@ export var FileFormat;
9
9
  FileFormat["TarballLegacy"] = "tgz";
10
10
  FileFormat["WindowsInstaller"] = "msi";
11
11
  FileFormat["Zip"] = "zip";
12
+ FileFormat["Zip7"] = "7z";
12
13
  })(FileFormat || (FileFormat = {}));
13
14
  export const fileFormats = [
14
15
  {
@@ -56,4 +57,9 @@ export const fileFormats = [
56
57
  value: FileFormat.Zip,
57
58
  name: 'Zip',
58
59
  },
60
+ {
61
+ description: 'Archive file format which compresses files and folders into a single file.',
62
+ value: FileFormat.Zip7,
63
+ name: '7-Zip',
64
+ },
59
65
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",