@open-audio-stack/core 0.0.16 → 0.0.18

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.
@@ -3,7 +3,6 @@ import { execSync } from 'child_process';
3
3
  import { createReadStream, chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
4
4
  import { createHash } from 'crypto';
5
5
  import stream from 'stream/promises';
6
- import { Transform } from 'stream';
7
6
  import { globSync } from 'glob';
8
7
  import { moveSync } from 'fs-extra/esm';
9
8
  import os from 'os';
@@ -130,15 +129,10 @@ export function fileJsonCreate(filePath, data) {
130
129
  return fileCreate(filePath, JSON.stringify(data, null, 2));
131
130
  }
132
131
  export async function fileHash(filePath, algorithm = 'sha256') {
133
- const normalizeLineEndings = new Transform({
134
- transform(chunk, encoding, callback) {
135
- const normalized = chunk.toString('utf8').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
136
- callback(null, Buffer.from(normalized));
137
- },
138
- });
132
+ console.log('⎋', filePath);
139
133
  const input = createReadStream(filePath);
140
134
  const hash = createHash(algorithm);
141
- await stream.pipeline(input, normalizeLineEndings, hash);
135
+ await stream.pipeline(input, hash);
142
136
  return hash.digest('hex');
143
137
  }
144
138
  export function fileMove(filePath, newPath) {
@@ -1,3 +1,5 @@
1
+ import { PluginFile, PresetFile, ProjectFile } from '../index-browser.js';
1
2
  import { PackageValidationError, PackageValidationRec, PackageVersionType } from '../types/Package.js';
2
3
  export declare function packageRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
4
+ export declare function packageRecommendationsUrl(obj: PackageVersionType | PluginFile | PresetFile | ProjectFile, recs: PackageValidationRec[], field: string): void;
3
5
  export declare function packageValidate(pkgVersion: PackageVersionType): PackageValidationError[];
@@ -3,27 +3,17 @@ import { PackageValidation, } from '../types/Package.js';
3
3
  // TODO refactor all this using a proper validation library.
4
4
  export function packageRecommendations(pkgVersion) {
5
5
  const recs = [];
6
- // Urls
7
- if (!pkgVersion.url.startsWith('https://')) {
8
- recs.push({
9
- field: 'url',
10
- rec: 'should use https url',
11
- });
12
- }
13
- if (!pkgVersion.url.includes('github.com') && !pkgVersion.url.includes('github.io')) {
14
- recs.push({
15
- field: 'url',
16
- rec: 'should point to GitHub',
17
- });
18
- }
6
+ packageRecommendationsUrl(pkgVersion, recs, 'audio');
7
+ packageRecommendationsUrl(pkgVersion, recs, 'image');
8
+ packageRecommendationsUrl(pkgVersion, recs, 'url');
19
9
  // Image/audio previews
20
- if (pkgVersion.image && pkgVersion.image.includes('png')) {
10
+ if (pkgVersion.image && pkgVersion.image.endsWith('png')) {
21
11
  recs.push({
22
12
  field: 'image',
23
13
  rec: 'should use the jpg format',
24
14
  });
25
15
  }
26
- if (pkgVersion.audio && pkgVersion.audio.includes('wav')) {
16
+ if (pkgVersion.audio && pkgVersion.audio.endsWith('wav')) {
27
17
  recs.push({
28
18
  field: 'audio',
29
19
  rec: 'should use the flac format',
@@ -39,11 +29,12 @@ export function packageRecommendations(pkgVersion) {
39
29
  file.systems.forEach(system => {
40
30
  supportedSystems[system.type] = true;
41
31
  });
32
+ packageRecommendationsUrl(file, recs, 'url');
42
33
  });
43
34
  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' });
35
+ recs.push({ field: 'architectures', rec: 'should support arm64' });
36
+ if (!supportedArchitectures.x64)
37
+ recs.push({ field: 'architectures', rec: 'should support x64' });
47
38
  if (!supportedSystems.linux)
48
39
  recs.push({ field: 'systems', rec: 'should support Linux' });
49
40
  if (!supportedSystems.mac)
@@ -63,6 +54,24 @@ export function packageRecommendations(pkgVersion) {
63
54
  }
64
55
  return recs;
65
56
  }
57
+ export function packageRecommendationsUrl(obj, recs, field) {
58
+ // @ts-expect-error indexing a field with multiple package types.
59
+ const val = obj[field];
60
+ if (typeof val !== 'string')
61
+ return;
62
+ if (!val.startsWith('https://')) {
63
+ recs.push({
64
+ field,
65
+ rec: 'should use https url',
66
+ });
67
+ }
68
+ if (!val.includes('github.com') && !val.includes('github.io')) {
69
+ recs.push({
70
+ field,
71
+ rec: 'should point to GitHub',
72
+ });
73
+ }
74
+ }
66
75
  export function packageValidate(pkgVersion) {
67
76
  const fields = [
68
77
  { name: 'audio', type: 'string' },
@@ -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.16",
3
+ "version": "0.0.18",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",