@open-audio-stack/core 0.1.12 → 0.1.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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  </h1>
6
6
  <p>Audio registry specification and API with searchable list of packages</p>
7
7
  <p>
8
- <a href="https://github.com/open-audio-stack/open-audio-stack-core/wiki/Open-Audio-Stack-%E2%80%90-Manager-%E2%80%90-Specification-1.0.0">Manager Specification</a>
8
+ <a href="specification.md">Manager Specification</a>
9
9
  ⦁︎
10
10
  <a href="https://open-audio-stack.github.io/open-audio-stack-registry">Registry API</a>
11
11
  ⦁︎
@@ -0,0 +1,11 @@
1
+ import { PackageValidationRec } from '../types/Package.js';
2
+ import { ZodIssue } from 'zod';
3
+ export declare class Base {
4
+ debug: boolean;
5
+ log(...args: any): void;
6
+ logEnable(): boolean;
7
+ logDisable(): boolean;
8
+ logErrors(errors: ZodIssue[]): void;
9
+ logRecommendations(recs: PackageValidationRec[]): void;
10
+ logReport(info: string, errors?: ZodIssue[], recs?: PackageValidationRec[]): void;
11
+ }
@@ -0,0 +1,43 @@
1
+ import chalk from 'chalk';
2
+ export class Base {
3
+ debug = false;
4
+ log(...args) {
5
+ if (this.debug)
6
+ console.log(...args);
7
+ }
8
+ logEnable() {
9
+ return (this.debug = true);
10
+ }
11
+ logDisable() {
12
+ return (this.debug = false);
13
+ }
14
+ logErrors(errors) {
15
+ errors.forEach(error => {
16
+ // @ts-expect-error need to filter by code.
17
+ if (error.received) {
18
+ this.log(chalk.red(
19
+ // @ts-expect-error need to filter by code.
20
+ `- ${error.path} (${error.message}) received '${error.received}' expected '${error.expected}'`));
21
+ }
22
+ else {
23
+ this.log(chalk.red(`- ${error.path} (${error.message})`));
24
+ }
25
+ });
26
+ }
27
+ logRecommendations(recs) {
28
+ recs.forEach(rec => {
29
+ this.log(chalk.yellow(`- ${rec.field} ${rec.rec}`));
30
+ });
31
+ }
32
+ logReport(info, errors, recs) {
33
+ if (errors && errors.length > 0) {
34
+ this.log(chalk.red(`X ${info}`));
35
+ this.logErrors(errors);
36
+ }
37
+ else {
38
+ this.log(chalk.green(`✓ ${info}`));
39
+ }
40
+ if (recs)
41
+ this.logRecommendations(recs);
42
+ }
43
+ }
@@ -11,7 +11,8 @@ import { ProjectFormat } from '../types/ProjectFormat.js';
11
11
  import { ProjectType } from '../types/ProjectType.js';
12
12
  import { SystemType } from '../types/SystemType.js';
13
13
  import { PluginCategoryEffect, PluginCategoryInstrument } from '../types/PluginCategory.js';
14
- export declare class Config {
14
+ import { Base } from './Base.js';
15
+ export declare class Config extends Base {
15
16
  config: ConfigInterface;
16
17
  constructor(config?: ConfigInterface);
17
18
  get(key: keyof ConfigInterface): string | import("../types/Config.js").ConfigRegistry[] | undefined;
@@ -11,9 +11,11 @@ import { projectFormats } from '../types/ProjectFormat.js';
11
11
  import { projectTypes } from '../types/ProjectType.js';
12
12
  import { systemTypes } from '../types/SystemType.js';
13
13
  import { pluginCategoryEffects, pluginCategoryInstruments, } from '../types/PluginCategory.js';
14
- export class Config {
14
+ import { Base } from './Base.js';
15
+ export class Config extends Base {
15
16
  config;
16
17
  constructor(config) {
18
+ super();
17
19
  this.config = { ...configDefaults(), ...config };
18
20
  }
19
21
  get(key) {
@@ -3,7 +3,8 @@ import { ConfigInterface } from '../types/Config.js';
3
3
  import { Package } from './Package.js';
4
4
  import { PackageVersion } from '../types/Package.js';
5
5
  import { RegistryPackages, RegistryType } from '../types/Registry.js';
6
- export declare class Manager {
6
+ import { Base } from './Base.js';
7
+ export declare class Manager extends Base {
7
8
  protected config: Config;
8
9
  protected packages: Map<string, Package>;
9
10
  type: RegistryType;
@@ -1,11 +1,13 @@
1
1
  import { apiJson } from '../helpers/api.js';
2
2
  import { Config } from './Config.js';
3
3
  import { Package } from './Package.js';
4
- export class Manager {
4
+ import { Base } from './Base.js';
5
+ export class Manager extends Base {
5
6
  config;
6
7
  packages;
7
8
  type;
8
9
  constructor(type, config) {
10
+ super();
9
11
  this.config = new Config(config);
10
12
  this.packages = new Map();
11
13
  this.type = type;
@@ -106,10 +106,10 @@ export class ManagerLocal extends Manager {
106
106
  if (this.type === RegistryType.Presets || this.type === RegistryType.Projects) {
107
107
  pkgVersionAnswers.plugins = [];
108
108
  }
109
- console.log(pkgVersionAnswers);
109
+ this.log(pkgVersionAnswers);
110
110
  const pkg = new Package(`${pkgAnswers.org}/${pkgAnswers.package}`);
111
111
  pkg.addVersion(pkgAnswers.version, pkgVersionAnswers);
112
- console.log(JSON.stringify(pkg.getReport(), null, 2));
112
+ this.log(JSON.stringify(pkg.getReport(), null, 2));
113
113
  this.addPackage(pkg);
114
114
  }
115
115
  scan(ext = 'json', installable = true) {
@@ -1,5 +1,6 @@
1
1
  import { PackageReport, PackageVersion, PackageVersions } from '../types/Package.js';
2
- export declare class Package {
2
+ import { Base } from './Base.js';
3
+ export declare class Package extends Base {
3
4
  reports: Map<string, PackageReport>;
4
5
  slug: string;
5
6
  version: string;
@@ -1,12 +1,14 @@
1
1
  import * as semver from 'semver';
2
2
  import { packageErrors, packageRecommendations } from '../helpers/package.js';
3
3
  import { isValidSlug } from '../helpers/utils.js';
4
- export class Package {
4
+ import { Base } from './Base.js';
5
+ export class Package extends Base {
5
6
  reports;
6
7
  slug;
7
8
  version;
8
9
  versions;
9
10
  constructor(slug, versions) {
11
+ super();
10
12
  if (!isValidSlug(slug))
11
13
  console.error('Invalid package slug', slug);
12
14
  this.reports = new Map();
@@ -25,8 +27,10 @@ export class Package {
25
27
  };
26
28
  if (Object.keys(report).length > 0)
27
29
  this.reports.set(num, report);
28
- if (errors.length > 0)
30
+ if (errors.length > 0) {
31
+ console.error(errors);
29
32
  return;
33
+ }
30
34
  this.versions.set(num, version);
31
35
  this.version = this.latestVersion();
32
36
  }
@@ -1,6 +1,7 @@
1
1
  import { Manager } from './Manager.js';
2
2
  import { RegistryInterface, RegistryType } from '../types/Registry.js';
3
- export declare class Registry {
3
+ import { Base } from './Base.js';
4
+ export declare class Registry extends Base {
4
5
  name: string;
5
6
  url: string;
6
7
  version: string;
@@ -1,9 +1,11 @@
1
- export class Registry {
1
+ import { Base } from './Base.js';
2
+ export class Registry extends Base {
2
3
  name;
3
4
  url;
4
5
  version;
5
6
  managers;
6
7
  constructor(name, url, version) {
8
+ super();
7
9
  this.name = name;
8
10
  this.url = url;
9
11
  this.version = version;
@@ -22,7 +22,7 @@ export async function adminInit() {
22
22
  await manager.uninstall(argv.id, argv.ver);
23
23
  }
24
24
  else {
25
- console.log('Missing --operation argument');
25
+ console.error('Missing --operation argument');
26
26
  }
27
27
  }
28
28
  adminInit();
@@ -344,7 +344,7 @@ export function zipCreate(filesPath, zipPath) {
344
344
  }
345
345
  }
346
346
  catch (error) {
347
- console.log(error);
347
+ console.error(error);
348
348
  }
349
349
  });
350
350
  console.log('+', zipPath);
@@ -30,7 +30,6 @@ export declare const PackageSystemValidator: z.ZodObject<{
30
30
  }>;
31
31
  export declare const PackageFileValidator: z.ZodObject<{
32
32
  architectures: z.ZodArray<z.ZodNativeEnum<typeof Architecture>, "many">;
33
- format: z.ZodNativeEnum<typeof FileFormat>;
34
33
  sha256: z.ZodString;
35
34
  size: z.ZodNumber;
36
35
  systems: z.ZodArray<z.ZodObject<{
@@ -51,7 +50,6 @@ export declare const PackageFileValidator: z.ZodObject<{
51
50
  }, "strip", z.ZodTypeAny, {
52
51
  type: FileType;
53
52
  architectures: Architecture[];
54
- format: FileFormat;
55
53
  sha256: string;
56
54
  size: number;
57
55
  systems: {
@@ -63,7 +61,6 @@ export declare const PackageFileValidator: z.ZodObject<{
63
61
  }, {
64
62
  type: FileType;
65
63
  architectures: Architecture[];
66
- format: FileFormat;
67
64
  sha256: string;
68
65
  size: number;
69
66
  systems: {
@@ -102,7 +99,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
102
99
  description: z.ZodString;
103
100
  files: z.ZodArray<z.ZodObject<{
104
101
  architectures: z.ZodArray<z.ZodNativeEnum<typeof Architecture>, "many">;
105
- format: z.ZodNativeEnum<typeof FileFormat>;
106
102
  sha256: z.ZodString;
107
103
  size: z.ZodNumber;
108
104
  systems: z.ZodArray<z.ZodObject<{
@@ -123,7 +119,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
123
119
  }, "strip", z.ZodTypeAny, {
124
120
  type: FileType;
125
121
  architectures: Architecture[];
126
- format: FileFormat;
127
122
  sha256: string;
128
123
  size: number;
129
124
  systems: {
@@ -135,7 +130,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
135
130
  }, {
136
131
  type: FileType;
137
132
  architectures: Architecture[];
138
- format: FileFormat;
139
133
  sha256: string;
140
134
  size: number;
141
135
  systems: {
@@ -180,7 +174,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
180
174
  files: {
181
175
  type: FileType;
182
176
  architectures: Architecture[];
183
- format: FileFormat;
184
177
  sha256: string;
185
178
  size: number;
186
179
  systems: {
@@ -205,7 +198,6 @@ export declare const PackageVersionValidator: z.ZodObject<{
205
198
  files: {
206
199
  type: FileType;
207
200
  architectures: Architecture[];
208
- format: FileFormat;
209
201
  sha256: string;
210
202
  size: number;
211
203
  systems: {
@@ -48,7 +48,6 @@ export const PackageSystemValidator = z.object({
48
48
  });
49
49
  export const PackageFileValidator = z.object({
50
50
  architectures: z.nativeEnum(Architecture).array(),
51
- format: z.nativeEnum(FileFormat),
52
51
  sha256: z.string().length(64),
53
52
  size: z.number().min(0).max(9999999999),
54
53
  systems: PackageSystemValidator.array(),
@@ -1,12 +1,4 @@
1
- import { PackageValidationRec } from '../types/Package.js';
2
- import { ZodIssue } from 'zod';
3
1
  export declare function inputGetParts(input: string): string[];
4
- export declare function log(...args: any): boolean;
5
- export declare function logEnable(): boolean;
6
- export declare function logDisable(): boolean;
7
- export declare function logReport(info: string, errors?: ZodIssue[], recs?: PackageValidationRec[]): void;
8
- export declare function logErrors(errors: ZodIssue[]): void;
9
- export declare function logRecommendations(recs: PackageValidationRec[]): void;
10
2
  export declare function pathGetDirectory(path: string, sep?: string): string;
11
3
  export declare function pathGetExt(path: string, sep?: string): string;
12
4
  export declare function pathGetFilename(path: string, sep?: string): string;
@@ -1,53 +1,9 @@
1
- import chalk from 'chalk';
2
1
  import * as semver from 'semver';
3
2
  import slugify from 'slugify';
4
- let LOGGING_ENABLED = false;
5
3
  const URLSAFE_REGEX = /[^\w\s$*_+~.()'"!\-:@/]+/g;
6
4
  export function inputGetParts(input) {
7
5
  return input.split('@');
8
6
  }
9
- export function log(...args) {
10
- if (LOGGING_ENABLED) {
11
- console.log(...args);
12
- return true;
13
- }
14
- return false;
15
- }
16
- export function logEnable() {
17
- return (LOGGING_ENABLED = true);
18
- }
19
- export function logDisable() {
20
- return (LOGGING_ENABLED = false);
21
- }
22
- export function logReport(info, errors, recs) {
23
- if (errors && errors.length > 0) {
24
- console.log(chalk.red(`X ${info}`));
25
- logErrors(errors);
26
- }
27
- else {
28
- console.log(chalk.green(`✓ ${info}`));
29
- }
30
- if (recs)
31
- logRecommendations(recs);
32
- }
33
- export function logErrors(errors) {
34
- errors.forEach(error => {
35
- // @ts-expect-error need to filter by code.
36
- if (error.received) {
37
- console.log(chalk.red(
38
- // @ts-expect-error need to filter by code.
39
- `- ${error.path} (${error.message}) received '${error.received}' expected '${error.expected}'`));
40
- }
41
- else {
42
- console.log(chalk.red(`- ${error.path} (${error.message})`));
43
- }
44
- });
45
- }
46
- export function logRecommendations(recs) {
47
- recs.forEach(rec => {
48
- console.log(chalk.yellow(`- ${rec.field} ${rec.rec}`));
49
- });
50
- }
51
7
  export function pathGetDirectory(path, sep = '/') {
52
8
  return path.substring(0, path.lastIndexOf(sep));
53
9
  }
@@ -1,3 +1,4 @@
1
+ export * from './classes/Base.js';
1
2
  export * from './classes/Config.js';
2
3
  export * from './classes/Manager.js';
3
4
  export * from './classes/Package.js';
@@ -3,6 +3,7 @@
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 './classes/Base.js';
6
7
  export * from './classes/Config.js';
7
8
  // export * from './classes/ConfigLocal.js';
8
9
  export * from './classes/Manager.js';
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './classes/Base.js';
1
2
  export * from './classes/Config.js';
2
3
  export * from './classes/ConfigLocal.js';
3
4
  export * from './classes/Manager.js';
package/build/index.js CHANGED
@@ -3,6 +3,7 @@
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 './classes/Base.js';
6
7
  export * from './classes/Config.js';
7
8
  export * from './classes/ConfigLocal.js';
8
9
  export * from './classes/Manager.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",