@open-audio-stack/core 0.0.23 → 0.1.0

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.
Files changed (48) hide show
  1. package/README.md +18 -4
  2. package/build/classes/Config.d.ts +41 -0
  3. package/build/{Config.js → classes/Config.js} +20 -13
  4. package/build/classes/ConfigLocal.d.ts +10 -0
  5. package/build/classes/ConfigLocal.js +32 -0
  6. package/build/classes/Manager.d.ts +20 -0
  7. package/build/classes/Manager.js +85 -0
  8. package/build/classes/ManagerLocal.d.ts +11 -0
  9. package/build/classes/ManagerLocal.js +135 -0
  10. package/build/classes/Package.d.ts +13 -0
  11. package/build/classes/Package.js +50 -0
  12. package/build/classes/Registry.d.ts +14 -0
  13. package/build/classes/Registry.js +37 -0
  14. package/build/helpers/admin.d.ts +9 -0
  15. package/build/helpers/admin.js +28 -0
  16. package/build/helpers/config.d.ts +2 -0
  17. package/build/helpers/config.js +11 -0
  18. package/build/helpers/configLocal.d.ts +2 -0
  19. package/build/helpers/configLocal.js +11 -0
  20. package/build/helpers/file.d.ts +9 -3
  21. package/build/helpers/file.js +117 -29
  22. package/build/helpers/package.d.ts +25 -23
  23. package/build/helpers/package.js +32 -2
  24. package/build/helpers/registry.d.ts +2 -0
  25. package/build/helpers/registry.js +10 -0
  26. package/build/helpers/utils.d.ts +11 -1
  27. package/build/helpers/utils.js +53 -3
  28. package/build/index-browser.d.ts +6 -2
  29. package/build/index-browser.js +10 -2
  30. package/build/index.d.ts +9 -2
  31. package/build/index.js +10 -2
  32. package/build/types/Config.d.ts +10 -0
  33. package/build/types/Package.d.ts +4 -8
  34. package/build/types/Package.js +1 -6
  35. package/build/types/Plugin.d.ts +2 -2
  36. package/build/types/PluginFormat.d.ts +5 -1
  37. package/build/types/PluginFormat.js +23 -6
  38. package/build/types/Preset.d.ts +2 -2
  39. package/build/types/PresetFormat.d.ts +5 -1
  40. package/build/types/PresetFormat.js +15 -1
  41. package/build/types/Project.d.ts +2 -2
  42. package/build/types/ProjectFormat.d.ts +4 -0
  43. package/build/types/ProjectFormat.js +14 -0
  44. package/build/types/Registry.d.ts +3 -3
  45. package/package.json +6 -2
  46. package/build/Config.d.ts +0 -39
  47. package/build/Registry.d.ts +0 -23
  48. package/build/Registry.js +0 -82
@@ -1,20 +1,49 @@
1
1
  import AdmZip from 'adm-zip';
2
- import { execSync } from 'child_process';
2
+ import { execFileSync, 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
+ import { unpack } from '7zip-min';
5
6
  import stream from 'stream/promises';
6
7
  import { globSync } from 'glob';
7
8
  import { moveSync } from 'fs-extra/esm';
8
9
  import os from 'os';
9
- import path from 'path';
10
+ import * as tar from 'tar';
11
+ import path, { dirname } from 'path';
10
12
  import yaml from 'js-yaml';
11
13
  import { ZodIssueCode } from 'zod';
12
- export function dirApp() {
13
- if (process.platform === 'win32')
14
- return process.env.APPDATA || os.homedir();
15
- else if (process.platform === 'darwin')
16
- return path.join(os.homedir(), 'Library', 'Preferences');
17
- return path.join(os.homedir(), '.local', 'share');
14
+ import { SystemType } from '../types/SystemType.js';
15
+ import { fileURLToPath } from 'url';
16
+ import sudoPrompt from '@vscode/sudo-prompt';
17
+ import { getSystem, log } from './utils.js';
18
+ export async function archiveExtract(filePath, dirPath) {
19
+ console.log('', dirPath);
20
+ const ext = path.extname(filePath).trim().toLowerCase();
21
+ if (ext === '.zip') {
22
+ const zip = new AdmZip(filePath);
23
+ return zip.extractAllTo(dirPath);
24
+ }
25
+ else if (ext === '.tar' || ext === '.tar.gz' || ext === '.tgz') {
26
+ return await tar.x({
27
+ file: filePath,
28
+ cwd: dirPath,
29
+ });
30
+ }
31
+ else if (ext === '.7z') {
32
+ return unpack(filePath, dirPath, err => {
33
+ if (err)
34
+ throw new Error(`7z extraction failed: ${err.message}`);
35
+ });
36
+ }
37
+ }
38
+ export function dirApp(dirName = 'open-audio-stack') {
39
+ if (getSystem() === SystemType.Windows)
40
+ return process.env.APPDATA || path.join(os.homedir(), dirName);
41
+ else if (getSystem() === SystemType.Macintosh)
42
+ return path.join(os.homedir(), 'Library', 'Preferences', dirName);
43
+ return path.join(os.homedir(), '.local', 'share', dirName);
44
+ }
45
+ export function dirContains(parentDir, childDir) {
46
+ return path.normalize(childDir).startsWith(path.normalize(parentDir));
18
47
  }
19
48
  export function dirCreate(dir) {
20
49
  if (!dirExists(dir)) {
@@ -52,10 +81,10 @@ export function dirMove(dir, dirNew) {
52
81
  export function dirOpen(dir) {
53
82
  let command = '';
54
83
  if (process.env.CI)
55
- return new Buffer('');
56
- if (process.platform === 'win32')
84
+ return Buffer.from('');
85
+ if (getSystem() === SystemType.Windows)
57
86
  command = 'start ""';
58
- else if (process.platform === 'darwin')
87
+ else if (getSystem() === SystemType.Macintosh)
59
88
  command = 'open';
60
89
  else
61
90
  command = 'xdg-open';
@@ -68,25 +97,25 @@ export function dirPackage(pkg) {
68
97
  return path.join(...parts);
69
98
  }
70
99
  export function dirPlugins() {
71
- if (process.platform === 'win32')
100
+ if (getSystem() === SystemType.Windows)
72
101
  return path.join('Program Files', 'Common Files');
73
- else if (process.platform === 'darwin')
102
+ else if (getSystem() === SystemType.Macintosh)
74
103
  return path.join(os.homedir(), 'Library', 'Audio', 'Plug-ins');
75
104
  return path.join('usr', 'local', 'lib');
76
105
  }
77
106
  export function dirPresets() {
78
- if (process.platform === 'win32')
107
+ if (getSystem() === SystemType.Windows)
79
108
  return path.join(os.homedir(), 'Documents', 'VST3 Presets');
80
- else if (process.platform === 'darwin')
109
+ else if (getSystem() === SystemType.Macintosh)
81
110
  return path.join(os.homedir(), 'Library', 'Audio', 'Presets');
82
111
  return path.join(os.homedir(), '.vst3', 'presets');
83
112
  }
84
113
  export function dirProjects() {
85
114
  // Windows throws permissions errors if you scan hidden folders
86
115
  // Therefore set to a more specific path than Documents
87
- if (process.platform === 'win32')
116
+ if (getSystem() === SystemType.Windows)
88
117
  return path.join(os.homedir(), 'Documents', 'Audio');
89
- else if (process.platform === 'darwin')
118
+ else if (getSystem() === SystemType.Macintosh)
90
119
  return path.join(os.homedir(), 'Documents', 'Audio');
91
120
  return path.join(os.homedir(), 'Documents', 'Audio');
92
121
  }
@@ -94,7 +123,7 @@ export function dirRead(dir, options) {
94
123
  console.log('⌕', dir);
95
124
  // Glob now expects forward slashes on Windows
96
125
  // Convert backslashes from path.join() to forwardslashes
97
- if (process.platform === 'win32') {
126
+ if (getSystem() === SystemType.Windows) {
98
127
  dir = dir.replace(/\\/g, '/');
99
128
  }
100
129
  return globSync(dir, options);
@@ -109,6 +138,9 @@ export function fileCreate(filePath, data) {
109
138
  console.log('+', filePath);
110
139
  return writeFileSync(filePath, data);
111
140
  }
141
+ export function fileCreateJson(filePath, data) {
142
+ return fileCreate(filePath, JSON.stringify(data, null, 2));
143
+ }
112
144
  export function fileDate(filePath) {
113
145
  return statSync(filePath).mtime;
114
146
  }
@@ -125,9 +157,6 @@ export function fileExec(filePath) {
125
157
  export function fileExists(filePath) {
126
158
  return existsSync(filePath);
127
159
  }
128
- export function fileJsonCreate(filePath, data) {
129
- return fileCreate(filePath, JSON.stringify(data, null, 2));
130
- }
131
160
  export async function fileHash(filePath, algorithm = 'sha256') {
132
161
  console.log('⎋', filePath);
133
162
  const input = createReadStream(filePath);
@@ -143,13 +172,35 @@ export function fileMove(filePath, newPath) {
143
172
  }
144
173
  return false;
145
174
  }
175
+ export function filesMove(dirSource, dirTarget, dirSub, formatDir) {
176
+ // Read files from source directory, ignoring Mac Contents files.
177
+ const files = dirRead(`${dirSource}/**/*.*`, {
178
+ ignore: [`${dirSource}/**/Contents/**/*`],
179
+ });
180
+ const filesMoved = [];
181
+ // For each file, move to correct folder based on type
182
+ files.forEach((fileSource) => {
183
+ const fileExt = path.extname(fileSource).slice(1).toLowerCase();
184
+ const fileExtTarget = formatDir[fileExt];
185
+ // If this is not a supported file format, then ignore.
186
+ if (!fileExtTarget)
187
+ return;
188
+ const fileTarget = path.join(dirTarget, fileExtTarget, dirSub, path.basename(fileSource));
189
+ if (fileExists(fileTarget))
190
+ return;
191
+ dirCreate(path.dirname(fileTarget));
192
+ fileMove(fileSource, fileTarget);
193
+ filesMoved.push(fileTarget);
194
+ });
195
+ return filesMoved;
196
+ }
146
197
  export function fileOpen(filePath) {
147
198
  let command = '';
148
199
  if (process.env.CI)
149
- return new Buffer('');
150
- if (process.platform === 'win32')
200
+ return Buffer.from('');
201
+ if (getSystem() === SystemType.Windows)
151
202
  command = 'open';
152
- else if (process.platform === 'darwin')
203
+ else if (getSystem() === SystemType.Macintosh)
153
204
  command = 'start ""';
154
205
  else
155
206
  command = 'xdg-open';
@@ -178,6 +229,20 @@ export function fileReadYaml(filePath) {
178
229
  export function fileSize(filePath) {
179
230
  return statSync(filePath).size;
180
231
  }
232
+ export function isAdmin() {
233
+ if (process.platform === 'win32') {
234
+ try {
235
+ execFileSync('net', ['session'], { stdio: 'ignore' });
236
+ return true;
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ }
242
+ else {
243
+ return process && process.getuid ? process.getuid() === 0 : false;
244
+ }
245
+ }
181
246
  export async function fileValidateMetadata(filePath, fileMetadata) {
182
247
  const errors = [];
183
248
  const hash = await fileHash(filePath);
@@ -201,6 +266,34 @@ export async function fileValidateMetadata(filePath, fileMetadata) {
201
266
  }
202
267
  return errors;
203
268
  }
269
+ export function getPlatform() {
270
+ if (getSystem() === SystemType.Windows)
271
+ return SystemType.Windows;
272
+ else if (getSystem() === SystemType.Macintosh)
273
+ return SystemType.Macintosh;
274
+ return SystemType.Linux;
275
+ }
276
+ export function runCliAsAdmin(args) {
277
+ return new Promise((resolve, reject) => {
278
+ const filename = fileURLToPath(import.meta.url).replace('src/', 'build/');
279
+ const dirPathClean = dirname(filename).replace('app.asar', 'app.asar.unpacked');
280
+ log(`node "${dirPathClean}${path.sep}helpers${path.sep}admin.js" ${args}`);
281
+ sudoPrompt.exec(`node "${dirPathClean}${path.sep}helpers${path.sep}admin.js" ${args}`, { name: 'Open Audio Stack' }, (error, stdout, stderr) => {
282
+ if (stdout) {
283
+ log('runCliAsAdmin', stdout);
284
+ }
285
+ if (stderr) {
286
+ log('runCliAsAdmin', stderr);
287
+ }
288
+ if (error) {
289
+ reject(error);
290
+ }
291
+ else {
292
+ resolve(stdout?.toString() || '');
293
+ }
294
+ });
295
+ });
296
+ }
204
297
  export function zipCreate(filesPath, zipPath) {
205
298
  if (fileExists(zipPath)) {
206
299
  unlinkSync(zipPath);
@@ -224,8 +317,3 @@ export function zipCreate(filesPath, zipPath) {
224
317
  console.log('+', zipPath);
225
318
  return zip.writeZip(zipPath);
226
319
  }
227
- export function zipExtract(content, dirPath) {
228
- console.log('⎋', dirPath);
229
- const zip = new AdmZip(content);
230
- return zip.extractAllTo(dirPath);
231
- }
@@ -10,7 +10,9 @@ import { PresetType } from '../types/PresetType.js';
10
10
  import { ProjectFile } from '../types/Project.js';
11
11
  import { ProjectType } from '../types/ProjectType.js';
12
12
  import { SystemType } from '../types/SystemType.js';
13
- import { PackageValidationRec, PackageVersionType } from '../types/Package.js';
13
+ import { PackageInterface, PackageValidationRec, PackageVersion } from '../types/Package.js';
14
+ export declare function packageCompatibleFiles(pkg: PackageVersion): (PluginFile | PresetFile | ProjectFile)[];
15
+ export declare function packageVersionLatest(pkg: PackageInterface): string;
14
16
  export declare const PackageSystemValidator: z.ZodObject<{
15
17
  max: z.ZodOptional<z.ZodNumber>;
16
18
  min: z.ZodOptional<z.ZodNumber>;
@@ -45,7 +47,6 @@ export declare const PackageFileValidator: z.ZodObject<{
45
47
  type: z.ZodNativeEnum<typeof FileType>;
46
48
  url: z.ZodString;
47
49
  }, "strip", z.ZodTypeAny, {
48
- url: string;
49
50
  type: FileType;
50
51
  architectures: Architecture[];
51
52
  format: FileFormat;
@@ -56,8 +57,8 @@ export declare const PackageFileValidator: z.ZodObject<{
56
57
  max?: number | undefined;
57
58
  min?: number | undefined;
58
59
  }[];
59
- }, {
60
60
  url: string;
61
+ }, {
61
62
  type: FileType;
62
63
  architectures: Architecture[];
63
64
  format: FileFormat;
@@ -68,6 +69,7 @@ export declare const PackageFileValidator: z.ZodObject<{
68
69
  max?: number | undefined;
69
70
  min?: number | undefined;
70
71
  }[];
72
+ url: string;
71
73
  }>;
72
74
  export declare const PackageTypeObj: {
73
75
  Audiobook: ProjectType.Audiobook;
@@ -117,7 +119,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
117
119
  type: z.ZodNativeEnum<typeof FileType>;
118
120
  url: z.ZodString;
119
121
  }, "strip", z.ZodTypeAny, {
120
- url: string;
121
122
  type: FileType;
122
123
  architectures: Architecture[];
123
124
  format: FileFormat;
@@ -128,8 +129,8 @@ export declare const PackageVersionValidator: z.ZodObject<{
128
129
  max?: number | undefined;
129
130
  min?: number | undefined;
130
131
  }[];
131
- }, {
132
132
  url: string;
133
+ }, {
133
134
  type: FileType;
134
135
  architectures: Architecture[];
135
136
  format: FileFormat;
@@ -140,6 +141,7 @@ export declare const PackageVersionValidator: z.ZodObject<{
140
141
  max?: number | undefined;
141
142
  min?: number | undefined;
142
143
  }[];
144
+ url: string;
143
145
  }>, "many">;
144
146
  image: z.ZodString;
145
147
  license: z.ZodNativeEnum<typeof License>;
@@ -168,19 +170,14 @@ export declare const PackageVersionValidator: z.ZodObject<{
168
170
  }>;
169
171
  url: z.ZodString;
170
172
  }, "strip", z.ZodTypeAny, {
173
+ date: string;
174
+ type: PluginType | PresetType | ProjectType;
175
+ url: string;
171
176
  audio: string;
172
177
  author: string;
173
178
  changes: string;
174
- date: string;
175
179
  description: string;
176
- image: string;
177
- license: License;
178
- name: string;
179
- tags: string[];
180
- url: string;
181
- type: PluginType | PresetType | ProjectType;
182
180
  files: {
183
- url: string;
184
181
  type: FileType;
185
182
  architectures: Architecture[];
186
183
  format: FileFormat;
@@ -191,21 +188,21 @@ export declare const PackageVersionValidator: z.ZodObject<{
191
188
  max?: number | undefined;
192
189
  min?: number | undefined;
193
190
  }[];
191
+ url: string;
194
192
  }[];
195
- }, {
196
- audio: string;
197
- author: string;
198
- changes: string;
199
- date: string;
200
- description: string;
201
193
  image: string;
202
194
  license: License;
203
195
  name: string;
204
196
  tags: string[];
205
- url: string;
197
+ }, {
198
+ date: string;
206
199
  type: PluginType | PresetType | ProjectType;
200
+ url: string;
201
+ audio: string;
202
+ author: string;
203
+ changes: string;
204
+ description: string;
207
205
  files: {
208
- url: string;
209
206
  type: FileType;
210
207
  architectures: Architecture[];
211
208
  format: FileFormat;
@@ -216,7 +213,12 @@ export declare const PackageVersionValidator: z.ZodObject<{
216
213
  max?: number | undefined;
217
214
  min?: number | undefined;
218
215
  }[];
216
+ url: string;
219
217
  }[];
218
+ image: string;
219
+ license: License;
220
+ name: string;
221
+ tags: string[];
220
222
  }>;
221
- export declare function packageRecommendations(pkgVersion: PackageVersionType): PackageValidationRec[];
222
- export declare function packageRecommendationsUrl(obj: PackageVersionType | PluginFile | PresetFile | ProjectFile, recs: PackageValidationRec[], field: string): void;
223
+ export declare function packageRecommendations(pkgVersion: PackageVersion): PackageValidationRec[];
224
+ export declare function packageRecommendationsUrl(obj: PackageVersion | PluginFile | PresetFile | ProjectFile, recs: PackageValidationRec[], field: string): void;
@@ -1,3 +1,4 @@
1
+ import * as semver from 'semver';
1
2
  import { z } from 'zod';
2
3
  import { Architecture } from '../types/Architecture.js';
3
4
  import { FileFormat } from '../types/FileFormat.js';
@@ -7,6 +8,21 @@ import { PluginType } from '../types/PluginType.js';
7
8
  import { PresetType } from '../types/PresetType.js';
8
9
  import { ProjectType } from '../types/ProjectType.js';
9
10
  import { SystemType } from '../types/SystemType.js';
11
+ import { getArchitecture, getSystem } from './utils.js';
12
+ export function packageCompatibleFiles(pkg) {
13
+ return pkg.files.filter((file) => {
14
+ const archMatches = file.architectures.filter(architecture => {
15
+ return architecture === getArchitecture();
16
+ });
17
+ const sysMatches = file.systems.filter(system => {
18
+ return system.type === getSystem();
19
+ });
20
+ return archMatches.length && sysMatches.length;
21
+ });
22
+ }
23
+ export function packageVersionLatest(pkg) {
24
+ return Array.from(Object.keys(pkg.versions)).sort(semver.rcompare)[0] || '0.0.0';
25
+ }
10
26
  // This is a first version using zod library for validation.
11
27
  // If it works well, consider updating all types to infer from Zod objects.
12
28
  // This will remove duplicatation of code between types and validators.
@@ -58,9 +74,9 @@ export function packageRecommendations(pkgVersion) {
58
74
  rec: 'should use the flac format',
59
75
  });
60
76
  }
61
- // Architectures/systems
62
77
  const supportedArchitectures = {};
63
78
  const supportedSystems = {};
79
+ const supportedFileFormats = {};
64
80
  pkgVersion.files.forEach(file => {
65
81
  file.architectures.forEach(architecture => {
66
82
  supportedArchitectures[architecture] = true;
@@ -68,20 +84,34 @@ export function packageRecommendations(pkgVersion) {
68
84
  file.systems.forEach(system => {
69
85
  supportedSystems[system.type] = true;
70
86
  });
87
+ supportedFileFormats[file.format] = true;
71
88
  packageRecommendationsUrl(file, recs, 'url');
72
89
  });
90
+ // Architectures
73
91
  if (!supportedArchitectures.arm64)
74
92
  recs.push({ field: 'architectures', rec: 'should support arm64' });
75
93
  if (!supportedArchitectures.x64)
76
94
  recs.push({ field: 'architectures', rec: 'should support x64' });
95
+ // Systems
77
96
  if (!supportedSystems.linux)
78
97
  recs.push({ field: 'systems', rec: 'should support Linux' });
79
98
  if (!supportedSystems.mac)
80
99
  recs.push({ field: 'systems', rec: 'should support Mac' });
81
100
  if (!supportedSystems.win)
82
101
  recs.push({ field: 'systems', rec: 'should support Windows' });
102
+ // Formats
103
+ if (supportedFileFormats.deb)
104
+ recs.push({
105
+ field: 'format',
106
+ rec: 'should support all Linux distributions, consider using AppImage or Tarball instead',
107
+ });
108
+ if (supportedFileFormats.rpm)
109
+ recs.push({
110
+ field: 'format',
111
+ rec: 'should support all Linux distributions, consider using AppImage or Tarball instead',
112
+ });
83
113
  // Tags
84
- const pluginTags = pkgVersion.tags.map(tag => tag.toLowerCase());
114
+ const pluginTags = pkgVersion.tags.map(tag => tag.trim().toLowerCase());
85
115
  if (pluginTags.length < 2)
86
116
  recs.push({ field: 'tags', rec: 'should have more items' });
87
117
  // Licence
@@ -0,0 +1,2 @@
1
+ import { RegistryInterface } from '../types/Registry.js';
2
+ export declare function registryDefaults(): RegistryInterface;
@@ -0,0 +1,10 @@
1
+ export function registryDefaults() {
2
+ return {
3
+ name: 'Open Audio Registry',
4
+ plugins: {},
5
+ presets: {},
6
+ projects: {},
7
+ url: 'https://open-audio-stack.github.io/open-audio-stack-registry',
8
+ version: '1.0.0',
9
+ };
10
+ }
@@ -1,10 +1,20 @@
1
1
  import { PackageValidationRec } from '../types/Package.js';
2
2
  import { ZodIssue } from 'zod';
3
+ import { SystemType } from '../types/SystemType.js';
4
+ import { Architecture } from '../types/Architecture.js';
5
+ export declare function getArchitecture(): Architecture;
6
+ export declare function getSystem(): SystemType;
7
+ export declare function inputGetParts(input: string): string[];
8
+ export declare function isTests(): boolean;
9
+ export declare function log(...args: any): boolean;
10
+ export declare function logEnable(): boolean;
11
+ export declare function logDisable(): boolean;
3
12
  export declare function logReport(info: string, errors?: ZodIssue[], recs?: PackageValidationRec[]): void;
4
13
  export declare function logErrors(errors: ZodIssue[]): void;
5
14
  export declare function logRecommendations(recs: PackageValidationRec[]): void;
6
- export declare function pathGetExt(path: string, sep?: string): string;
7
15
  export declare function pathGetDirectory(path: string, sep?: string): string;
16
+ export declare function pathGetExt(path: string, sep?: string): string;
8
17
  export declare function pathGetFilename(path: string, sep?: string): string;
9
18
  export declare function pathGetSlug(path: string, sep?: string): string;
10
19
  export declare function pathGetVersion(path: string, sep?: string): string;
20
+ export declare function isValidSlug(slug: string): boolean;
@@ -1,4 +1,44 @@
1
1
  import chalk from 'chalk';
2
+ import { SystemType } from '../types/SystemType.js';
3
+ import { Architecture } from '../types/Architecture.js';
4
+ let LOGGING_ENABLED = false;
5
+ export function getArchitecture() {
6
+ if (process.arch === 'arm')
7
+ return Architecture.Arm32;
8
+ if (process.arch === 'arm64')
9
+ return Architecture.Arm64;
10
+ if (process.arch === 'ia32')
11
+ return Architecture.X32;
12
+ return Architecture.X64;
13
+ }
14
+ export function getSystem() {
15
+ if (process.platform === 'win32')
16
+ return SystemType.Windows;
17
+ else if (process.platform === 'darwin')
18
+ return SystemType.Macintosh;
19
+ return SystemType.Linux;
20
+ }
21
+ export function inputGetParts(input) {
22
+ return input.split('@');
23
+ }
24
+ export function isTests() {
25
+ const jest = process.env.JEST_WORKER_ID !== undefined;
26
+ const vitest = process.env.VITEST_WORKER_ID !== undefined;
27
+ return jest || vitest;
28
+ }
29
+ export function log(...args) {
30
+ if (LOGGING_ENABLED) {
31
+ console.log(...args);
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ export function logEnable() {
37
+ return (LOGGING_ENABLED = true);
38
+ }
39
+ export function logDisable() {
40
+ return (LOGGING_ENABLED = false);
41
+ }
2
42
  export function logReport(info, errors, recs) {
3
43
  if (errors && errors.length > 0) {
4
44
  console.log(chalk.red(`X ${info}`));
@@ -28,12 +68,12 @@ export function logRecommendations(recs) {
28
68
  console.log(chalk.yellow(`- ${rec.field} ${rec.rec}`));
29
69
  });
30
70
  }
31
- export function pathGetExt(path, sep = '.') {
32
- return path.substring(path.lastIndexOf(sep) + 1);
33
- }
34
71
  export function pathGetDirectory(path, sep = '/') {
35
72
  return path.substring(0, path.lastIndexOf(sep));
36
73
  }
74
+ export function pathGetExt(path, sep = '.') {
75
+ return path.substring(path.lastIndexOf(sep) + 1);
76
+ }
37
77
  export function pathGetFilename(path, sep = '/') {
38
78
  return path.substring(path.lastIndexOf(sep) + 1);
39
79
  }
@@ -45,3 +85,13 @@ export function pathGetVersion(path, sep = '/') {
45
85
  const parts = path.split(sep);
46
86
  return parts[parts.length - 2];
47
87
  }
88
+ export function isValidSlug(slug) {
89
+ let valid = true;
90
+ // Must have exactly one slash.
91
+ if (slug.split('/').length !== 2)
92
+ valid = false;
93
+ // Must be lowercase.
94
+ if (slug !== slug.toLowerCase())
95
+ valid = false;
96
+ return valid;
97
+ }
@@ -1,7 +1,11 @@
1
- export * from './Config.js';
2
- export * from './Registry.js';
1
+ export * from './classes/Config.js';
2
+ export * from './classes/Package.js';
3
+ export * from './classes/Manager.js';
4
+ export * from './classes/Registry.js';
3
5
  export * from './helpers/api.js';
6
+ export * from './helpers/config.js';
4
7
  export * from './helpers/package.js';
8
+ export * from './helpers/registry.js';
5
9
  export * from './helpers/utils.js';
6
10
  export * from './types/Architecture.js';
7
11
  export * from './types/Config.js';
@@ -3,12 +3,20 @@
3
3
  // This file configures which code is exported for browser runtimes.
4
4
  // Comment out any files which are not browser compatible.
5
5
  // Classes
6
- export * from './Config.js';
7
- export * from './Registry.js';
6
+ export * from './classes/Config.js';
7
+ // export * from './classes/ConfigLocal.js';
8
+ export * from './classes/Package.js';
9
+ export * from './classes/Manager.js';
10
+ // export * from './classes/ManagerLocal.js';
11
+ export * from './classes/Registry.js';
8
12
  // Helpers
13
+ // export * from './helpers/admin.js'; // Admin is an independent script which should not be imported here.
9
14
  export * from './helpers/api.js';
15
+ export * from './helpers/config.js';
16
+ // export * from './helpers/configLocal.js';
10
17
  // export * from './helpers/file.js';
11
18
  export * from './helpers/package.js';
19
+ export * from './helpers/registry.js';
12
20
  export * from './helpers/utils.js';
13
21
  // Types
14
22
  export * from './types/Architecture.js';
package/build/index.d.ts CHANGED
@@ -1,8 +1,15 @@
1
- export * from './Config.js';
2
- export * from './Registry.js';
1
+ export * from './classes/Config.js';
2
+ export * from './classes/ConfigLocal.js';
3
+ export * from './classes/Package.js';
4
+ export * from './classes/Manager.js';
5
+ export * from './classes/ManagerLocal.js';
6
+ export * from './classes/Registry.js';
3
7
  export * from './helpers/api.js';
8
+ export * from './helpers/config.js';
9
+ export * from './helpers/configLocal.js';
4
10
  export * from './helpers/file.js';
5
11
  export * from './helpers/package.js';
12
+ export * from './helpers/registry.js';
6
13
  export * from './helpers/utils.js';
7
14
  export * from './types/Architecture.js';
8
15
  export * from './types/Config.js';
package/build/index.js CHANGED
@@ -3,12 +3,20 @@
3
3
  // This file configures which code is exported for server/NodeJS.
4
4
  // Comment out any files which are not NodeJS compatible.
5
5
  // Classes
6
- export * from './Config.js';
7
- export * from './Registry.js';
6
+ export * from './classes/Config.js';
7
+ export * from './classes/ConfigLocal.js';
8
+ export * from './classes/Package.js';
9
+ export * from './classes/Manager.js';
10
+ export * from './classes/ManagerLocal.js';
11
+ export * from './classes/Registry.js';
8
12
  // Helpers
13
+ // export * from './helpers/admin.js'; // Admin is an independent script which should not be imported here.
9
14
  export * from './helpers/api.js';
15
+ export * from './helpers/config.js';
16
+ export * from './helpers/configLocal.js';
10
17
  export * from './helpers/file.js';
11
18
  export * from './helpers/package.js';
19
+ export * from './helpers/registry.js';
12
20
  export * from './helpers/utils.js';
13
21
  // Types
14
22
  export * from './types/Architecture.js';
@@ -1,2 +1,12 @@
1
1
  export interface ConfigInterface {
2
+ appDir?: string;
3
+ pluginsDir?: string;
4
+ presetsDir?: string;
5
+ projectsDir?: string;
6
+ registries?: ConfigRegistry[];
7
+ version?: string;
8
+ }
9
+ export interface ConfigRegistry {
10
+ name: string;
11
+ url: string;
2
12
  }
@@ -8,26 +8,22 @@ export interface PackageInterface {
8
8
  versions: PackageVersions;
9
9
  }
10
10
  export interface PackageVersions {
11
- [version: string]: PackageVersionType;
11
+ [version: string]: PackageVersion;
12
12
  }
13
- export interface PackageVersion {
13
+ export interface PackageBase {
14
14
  audio: string;
15
15
  author: string;
16
16
  changes: string;
17
17
  date: string;
18
18
  description: string;
19
19
  image: string;
20
+ installed?: boolean;
20
21
  license: License;
21
22
  name: string;
22
23
  tags: string[];
23
24
  url: string;
24
25
  }
25
- export type PackageVersionType = PluginInterface | PresetInterface | ProjectInterface;
26
- export declare enum PackageValidation {
27
- MISSING_FIELD = "missing-field",
28
- INVALID_TYPE = "invalid-type",
29
- INVALID_VALUE = "invalid-value"
30
- }
26
+ export type PackageVersion = PluginInterface | PresetInterface | ProjectInterface;
31
27
  export interface PackageValidationField {
32
28
  name: string;
33
29
  type: string;