@open-audio-stack/core 0.0.6 → 0.0.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.
@@ -1,4 +1,4 @@
1
- import { PackageInterface, PackageValidationError, PackageVersions, PackageVersionType } from './types/Package.js';
1
+ import { PackageInterface, PackageValidationError, PackageValidationRec, PackageVersions, PackageVersionType } from './types/Package.js';
2
2
  import { RegistryInterface, RegistryPackages } from './types/Registry.js';
3
3
  import { PluginType } from './types/PluginType.js';
4
4
  import { PresetType } from './types/PresetType.js';
@@ -24,4 +24,5 @@ export declare class Registry {
24
24
  packageRemove(slug: string): void;
25
25
  packageVersionRemove(slug: string, version: string): void;
26
26
  packageVersionValidate(pkgVersion: PackageVersionType): PackageValidationError[];
27
+ packageVersionRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
27
28
  }
package/build/Registry.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as semver from 'semver';
2
2
  import { PackageValidation, } from './types/Package.js';
3
+ import { License } from './index-browser.js';
3
4
  export class Registry {
4
5
  registry;
5
6
  constructor(registry) {
@@ -110,4 +111,67 @@ export class Registry {
110
111
  });
111
112
  return errors;
112
113
  }
114
+ // TODO refactor all this using a proper validation library.
115
+ packageVersionRecommendations(pkgVersion) {
116
+ const recs = [];
117
+ // Urls
118
+ if (!pkgVersion.url.startsWith('https://')) {
119
+ recs.push({
120
+ field: 'url',
121
+ rec: 'should use https url',
122
+ });
123
+ }
124
+ if (!pkgVersion.url.includes('github.com') && !pkgVersion.url.includes('github.io')) {
125
+ recs.push({
126
+ field: 'url',
127
+ rec: 'should point to GitHub',
128
+ });
129
+ }
130
+ // Image/audio previews
131
+ if (pkgVersion.image && pkgVersion.image.includes('png')) {
132
+ recs.push({
133
+ field: 'image',
134
+ rec: 'should use the jpg format',
135
+ });
136
+ }
137
+ if (pkgVersion.audio && pkgVersion.audio.includes('wav')) {
138
+ recs.push({
139
+ field: 'audio',
140
+ rec: 'should use the flac format',
141
+ });
142
+ }
143
+ // Architectures/systems
144
+ const supportedArchitectures = {};
145
+ const supportedSystems = {};
146
+ pkgVersion.files.forEach(file => {
147
+ file.architectures.forEach(architecture => {
148
+ supportedArchitectures[architecture] = true;
149
+ });
150
+ file.systems.forEach(system => {
151
+ supportedSystems[system.type] = true;
152
+ });
153
+ });
154
+ if (!supportedArchitectures.arm64)
155
+ recs.push({ field: 'architectures', rec: 'should support Arm64' });
156
+ if (!supportedArchitectures.bit64)
157
+ recs.push({ field: 'architectures', rec: 'should support Bit64' });
158
+ if (!supportedSystems.linux)
159
+ recs.push({ field: 'systems', rec: 'should support Linux' });
160
+ if (!supportedSystems.mac)
161
+ recs.push({ field: 'systems', rec: 'should support Mac' });
162
+ if (!supportedSystems.win)
163
+ recs.push({ field: 'systems', rec: 'should support Windows' });
164
+ // Tags
165
+ const pluginTags = pkgVersion.tags.map(tag => tag.toLowerCase());
166
+ if (pluginTags.length < 2)
167
+ recs.push({ field: 'tags', rec: 'should have more items' });
168
+ // Licence
169
+ if (!Object.values(License).includes(pkgVersion.license)) {
170
+ recs.push({ field: 'license', rec: 'should be from the supported list' });
171
+ }
172
+ else if (pkgVersion.license === License.Other) {
173
+ recs.push({ field: 'license', rec: 'should be more specific' });
174
+ }
175
+ return recs;
176
+ }
113
177
  }
@@ -38,3 +38,7 @@ export interface PackageValidationError {
38
38
  valueExpected: string;
39
39
  valueReceived: string;
40
40
  }
41
+ export interface PackageValidationRec {
42
+ field: string;
43
+ rec: string;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",