@open-audio-stack/core 0.0.8 → 0.0.10

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.
@@ -19,9 +19,10 @@ export declare function fileDelete(filePath: string): boolean | void;
19
19
  export declare function fileExec(filePath: string): void;
20
20
  export declare function fileExists(filePath: string): boolean;
21
21
  export declare function fileJsonCreate(filePath: string, data: object): void;
22
+ export declare function fileHash(filePath: string, algorithm?: string): string;
22
23
  export declare function fileMove(filePath: string, newPath: string): void | boolean;
23
24
  export declare function fileOpen(filePath: string): Buffer;
24
- export declare function fileRead(filePath: string): Buffer;
25
+ export declare function fileRead(filePath: string): string;
25
26
  export declare function fileReadJson(filePath: string): any;
26
27
  export declare function fileReadString(filePath: string): string;
27
28
  export declare function fileReadYaml(filePath: string): unknown;
@@ -1,6 +1,7 @@
1
1
  import AdmZip from 'adm-zip';
2
2
  import { execSync } from 'child_process';
3
3
  import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'fs';
4
+ import { createHash } from 'crypto';
4
5
  import { globSync } from 'glob';
5
6
  import { moveSync } from 'fs-extra/esm';
6
7
  import os from 'os';
@@ -125,6 +126,11 @@ export function fileExists(filePath) {
125
126
  export function fileJsonCreate(filePath, data) {
126
127
  return fileCreate(filePath, JSON.stringify(data, null, 2));
127
128
  }
129
+ export function fileHash(filePath, algorithm = 'sha256') {
130
+ const fileData = fileReadString(filePath);
131
+ const fileNormalized = fileData.replace(/\r\n/g, '\n');
132
+ return createHash(algorithm).update(fileNormalized, 'utf8').digest('hex');
133
+ }
128
134
  export function fileMove(filePath, newPath) {
129
135
  if (fileExists(filePath)) {
130
136
  console.log('-', filePath);
@@ -148,18 +154,18 @@ export function fileOpen(filePath) {
148
154
  }
149
155
  export function fileRead(filePath) {
150
156
  console.log('⎋', filePath);
151
- return readFileSync(filePath);
157
+ return readFileSync(filePath, 'utf8');
152
158
  }
153
159
  export function fileReadJson(filePath) {
154
160
  if (fileExists(filePath)) {
155
161
  console.log('⎋', filePath);
156
- return JSON.parse(readFileSync(filePath).toString());
162
+ return JSON.parse(readFileSync(filePath, 'utf8').toString());
157
163
  }
158
164
  return false;
159
165
  }
160
166
  export function fileReadString(filePath) {
161
167
  console.log('⎋', filePath);
162
- return readFileSync(filePath).toString();
168
+ return readFileSync(filePath, 'utf8').toString();
163
169
  }
164
170
  export function fileReadYaml(filePath) {
165
171
  const file = fileReadString(filePath);
@@ -1,5 +1,6 @@
1
1
  export * from './Config.js';
2
2
  export * from './Registry.js';
3
+ export * from './helpers/api.js';
3
4
  export * from './helpers/utils.js';
4
5
  export * from './types/Architecture.js';
5
6
  export * from './types/Config.js';
@@ -6,6 +6,7 @@
6
6
  export * from './Config.js';
7
7
  export * from './Registry.js';
8
8
  // Helpers
9
+ export * from './helpers/api.js';
9
10
  // export * from './helpers/file.js';
10
11
  export * from './helpers/utils.js';
11
12
  // Types
package/build/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './Config.js';
2
2
  export * from './Registry.js';
3
+ export * from './helpers/api.js';
3
4
  export * from './helpers/file.js';
4
5
  export * from './helpers/utils.js';
5
6
  export * from './types/Architecture.js';
package/build/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  export * from './Config.js';
7
7
  export * from './Registry.js';
8
8
  // Helpers
9
+ export * from './helpers/api.js';
9
10
  export * from './helpers/file.js';
10
11
  export * from './helpers/utils.js';
11
12
  // Types
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-audio-stack/core",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Open-source audio plugin management software",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",