@open-audio-stack/core 0.0.12 → 0.0.14
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.d.ts +1 -3
- package/build/Registry.js +0 -102
- package/build/helpers/package.d.ts +3 -0
- package/build/helpers/package.js +102 -0
- package/build/helpers/utils.js +1 -1
- package/build/index-browser.d.ts +1 -0
- package/build/index-browser.js +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/package.json +1 -1
package/build/Registry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PackageInterface,
|
|
1
|
+
import { PackageInterface, 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';
|
|
@@ -23,6 +23,4 @@ export declare class Registry {
|
|
|
23
23
|
version(): string;
|
|
24
24
|
packageRemove(slug: string): void;
|
|
25
25
|
packageVersionRemove(slug: string, version: string): void;
|
|
26
|
-
packageVersionValidate(pkgVersion: PackageVersionType): PackageValidationError[];
|
|
27
|
-
packageVersionRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
|
|
28
26
|
}
|
package/build/Registry.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as semver from 'semver';
|
|
2
|
-
import { PackageValidation, } from './types/Package.js';
|
|
3
|
-
import { License } from './types/License.js';
|
|
4
2
|
export class Registry {
|
|
5
3
|
registry;
|
|
6
4
|
constructor(registry) {
|
|
@@ -74,104 +72,4 @@ export class Registry {
|
|
|
74
72
|
this.packageRemove(slug);
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
|
-
packageVersionValidate(pkgVersion) {
|
|
78
|
-
const fields = [
|
|
79
|
-
{ name: 'audio', type: 'string' },
|
|
80
|
-
{ name: 'author', type: 'string' },
|
|
81
|
-
{ name: 'changes', type: 'string' },
|
|
82
|
-
{ name: 'date', type: 'string' },
|
|
83
|
-
{ name: 'description', type: 'string' },
|
|
84
|
-
{ name: 'files', type: 'object' },
|
|
85
|
-
{ name: 'image', type: 'string' },
|
|
86
|
-
{ name: 'license', type: 'string' },
|
|
87
|
-
{ name: 'name', type: 'string' },
|
|
88
|
-
{ name: 'tags', type: 'object' },
|
|
89
|
-
{ name: 'type', type: 'string' },
|
|
90
|
-
{ name: 'url', type: 'string' },
|
|
91
|
-
];
|
|
92
|
-
const errors = [];
|
|
93
|
-
fields.forEach((field) => {
|
|
94
|
-
const versionField = pkgVersion[field.name];
|
|
95
|
-
if (versionField === undefined) {
|
|
96
|
-
errors.push({
|
|
97
|
-
field: field.name,
|
|
98
|
-
error: PackageValidation.MISSING_FIELD,
|
|
99
|
-
valueExpected: field.type,
|
|
100
|
-
valueReceived: 'undefined',
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else if (typeof versionField !== field.type) {
|
|
104
|
-
errors.push({
|
|
105
|
-
field: field.name,
|
|
106
|
-
error: PackageValidation.INVALID_TYPE,
|
|
107
|
-
valueExpected: field.type,
|
|
108
|
-
valueReceived: typeof versionField,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return errors;
|
|
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
|
-
}
|
|
177
75
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PackageValidationError, PackageValidationRec, PackageVersionType } from '../types/Package.js';
|
|
2
|
+
export declare function packageRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
|
|
3
|
+
export declare function packageValidate(pkgVersion: PackageVersionType): PackageValidationError[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { License } from '../types/License.js';
|
|
2
|
+
import { PackageValidation, } from '../types/Package.js';
|
|
3
|
+
// TODO refactor all this using a proper validation library.
|
|
4
|
+
export function packageRecommendations(pkgVersion) {
|
|
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
|
+
}
|
|
19
|
+
// Image/audio previews
|
|
20
|
+
if (pkgVersion.image && pkgVersion.image.includes('png')) {
|
|
21
|
+
recs.push({
|
|
22
|
+
field: 'image',
|
|
23
|
+
rec: 'should use the jpg format',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (pkgVersion.audio && pkgVersion.audio.includes('wav')) {
|
|
27
|
+
recs.push({
|
|
28
|
+
field: 'audio',
|
|
29
|
+
rec: 'should use the flac format',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Architectures/systems
|
|
33
|
+
const supportedArchitectures = {};
|
|
34
|
+
const supportedSystems = {};
|
|
35
|
+
pkgVersion.files.forEach(file => {
|
|
36
|
+
file.architectures.forEach(architecture => {
|
|
37
|
+
supportedArchitectures[architecture] = true;
|
|
38
|
+
});
|
|
39
|
+
file.systems.forEach(system => {
|
|
40
|
+
supportedSystems[system.type] = true;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
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' });
|
|
47
|
+
if (!supportedSystems.linux)
|
|
48
|
+
recs.push({ field: 'systems', rec: 'should support Linux' });
|
|
49
|
+
if (!supportedSystems.mac)
|
|
50
|
+
recs.push({ field: 'systems', rec: 'should support Mac' });
|
|
51
|
+
if (!supportedSystems.win)
|
|
52
|
+
recs.push({ field: 'systems', rec: 'should support Windows' });
|
|
53
|
+
// Tags
|
|
54
|
+
const pluginTags = pkgVersion.tags.map(tag => tag.toLowerCase());
|
|
55
|
+
if (pluginTags.length < 2)
|
|
56
|
+
recs.push({ field: 'tags', rec: 'should have more items' });
|
|
57
|
+
// Licence
|
|
58
|
+
if (!Object.values(License).includes(pkgVersion.license)) {
|
|
59
|
+
recs.push({ field: 'license', rec: 'should be from the supported list' });
|
|
60
|
+
}
|
|
61
|
+
else if (pkgVersion.license === License.Other) {
|
|
62
|
+
recs.push({ field: 'license', rec: 'should be more specific' });
|
|
63
|
+
}
|
|
64
|
+
return recs;
|
|
65
|
+
}
|
|
66
|
+
export function packageValidate(pkgVersion) {
|
|
67
|
+
const fields = [
|
|
68
|
+
{ name: 'audio', type: 'string' },
|
|
69
|
+
{ name: 'author', type: 'string' },
|
|
70
|
+
{ name: 'changes', type: 'string' },
|
|
71
|
+
{ name: 'date', type: 'string' },
|
|
72
|
+
{ name: 'description', type: 'string' },
|
|
73
|
+
{ name: 'files', type: 'object' },
|
|
74
|
+
{ name: 'image', type: 'string' },
|
|
75
|
+
{ name: 'license', type: 'string' },
|
|
76
|
+
{ name: 'name', type: 'string' },
|
|
77
|
+
{ name: 'tags', type: 'object' },
|
|
78
|
+
{ name: 'type', type: 'string' },
|
|
79
|
+
{ name: 'url', type: 'string' },
|
|
80
|
+
];
|
|
81
|
+
const errors = [];
|
|
82
|
+
fields.forEach((field) => {
|
|
83
|
+
const versionField = pkgVersion[field.name];
|
|
84
|
+
if (versionField === undefined) {
|
|
85
|
+
errors.push({
|
|
86
|
+
field: field.name,
|
|
87
|
+
error: PackageValidation.MISSING_FIELD,
|
|
88
|
+
valueExpected: field.type,
|
|
89
|
+
valueReceived: 'undefined',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (typeof versionField !== field.type) {
|
|
93
|
+
errors.push({
|
|
94
|
+
field: field.name,
|
|
95
|
+
error: PackageValidation.INVALID_TYPE,
|
|
96
|
+
valueExpected: field.type,
|
|
97
|
+
valueReceived: typeof versionField,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return errors;
|
|
102
|
+
}
|
package/build/helpers/utils.js
CHANGED
package/build/index-browser.d.ts
CHANGED
package/build/index-browser.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './Config.js';
|
|
|
2
2
|
export * from './Registry.js';
|
|
3
3
|
export * from './helpers/api.js';
|
|
4
4
|
export * from './helpers/file.js';
|
|
5
|
+
export * from './helpers/package.js';
|
|
5
6
|
export * from './helpers/utils.js';
|
|
6
7
|
export * from './types/Architecture.js';
|
|
7
8
|
export * from './types/Config.js';
|
package/build/index.js
CHANGED