Skip to content

Commit

Permalink
v0.0.39
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jan 9, 2024
1 parent 725c37c commit 3bb430d
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 23 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.38
0.0.39
21 changes: 21 additions & 0 deletions dist/js/class/JSONLoader.d.ts
@@ -0,0 +1,21 @@
declare class JSONLoader {
/**
* Asynchronously loads JSON data from a file and returns it as an object.
* @param filePath The path to the JSON file.
* @returns A promise that resolves to an object containing the JSON data.
*/
loadJSON<T>(filePath: string): Promise<T>;
/**
* Asynchronously loads all JSON files from a given directory.
* @param dirPath The path to the directory containing JSON files.
* @returns A promise that resolves to an array of objects containing the JSON data.
*/
loadJSONFromDirectory<T>(dirPath: string): Promise<T[]>;
/**
* Merges an array of objects into a single object.
* @param objects An array of objects to merge.
* @returns A single object containing all properties from the input objects.
*/
mergeJSONObjects<T>(objects: T[]): Promise<T>;
}
export default JSONLoader;
70 changes: 70 additions & 0 deletions dist/js/class/JSONLoader.js
@@ -0,0 +1,70 @@
"use strict";
// class/JSONLoader.ts
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// Copyright 2023 Scape Agency BV
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ============================================================================
// Import
// ============================================================================
var fs_1 = require("fs");
var path_1 = __importDefault(require("path"));
// ============================================================================
// Classes
// ============================================================================
class JSONLoader {
/**
* Asynchronously loads JSON data from a file and returns it as an object.
* @param filePath The path to the JSON file.
* @returns A promise that resolves to an object containing the JSON data.
*/
async loadJSON(filePath) {
try {
const data = await fs_1.promises.readFile(filePath, 'utf8');
return JSON.parse(data);
}
catch (error) {
console.error(`Error reading JSON file: ${filePath}`, error);
throw error;
}
}
/**
* Asynchronously loads all JSON files from a given directory.
* @param dirPath The path to the directory containing JSON files.
* @returns A promise that resolves to an array of objects containing the JSON data.
*/
async loadJSONFromDirectory(dirPath) {
try {
const files = await fs_1.promises.readdir(dirPath);
const jsonFiles = files.filter(file => file.endsWith('.json'));
const jsonData = await Promise.all(jsonFiles.map(file => this.loadJSON(path_1.default.join(dirPath, file))));
return jsonData;
}
catch (error) {
console.error(`Error reading JSON files from directory: ${dirPath}`, error);
throw error;
}
}
/**
* Merges an array of objects into a single object.
* @param objects An array of objects to merge.
* @returns A single object containing all properties from the input objects.
*/
async mergeJSONObjects(objects) {
return objects.reduce((acc, obj) => ({ ...acc, ...obj }), {});
}
}
// ============================================================================
// Export
// ============================================================================
exports.default = JSONLoader;
16 changes: 8 additions & 8 deletions dist/js/config/fantasticon.config.js
Expand Up @@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var fantasticon_1 = require("fantasticon");
const fantasticonConfig = {
// RunnerOptionalOptions
name: 'icon.gl',
name: 'icon',
fontTypes: [
fantasticon_1.FontAssetType.TTF, // TTF = "ttf"
fantasticon_1.FontAssetType.WOFF, // WOFF = "woff"
Expand Down Expand Up @@ -59,17 +59,17 @@ const fantasticonConfig = {
woff: './dist/font/icon.gl.woff',
woff2: './dist/font/icon.gl.woff2'
},
// codepoints: {
// 'chevron-left': 57344, // decimal representation of 0xe000
// 'chevron-right': 57345,
// 'thumbs-up': 57358,
// 'thumbs-down': 57359,
// },
codepoints: {
'chevron-left': 57344, // decimal representation of 0xe000
'chevron-right': 57345,
'thumbs-up': 57358,
'thumbs-down': 57359
},
// fontHeight: number;
// descent: number;
// normalize: boolean;
// round: number;
selector: '.igl',
selector: '.i',
// tag: string;
// Use our custom Handlebars templates
// templates: {
Expand Down
3 changes: 2 additions & 1 deletion dist/js/index.d.ts
Expand Up @@ -22,7 +22,8 @@ import SvgPackager from "./class/SvgPackager.js";
import TestRunner from './class/TestRunner.js';
import DocumentationGenerator from './class/DocumentationGenerator.js';
import CodeLinter from './class/CodeLinter.js';
import JSONLoader from './class/JSONLoader.js';
import gl_installer from './function/gl_installer';
import cleanDirectory from './function/clean_directory';
import readPackageJson from "./function/readPackageJson.js";
export { DirectoryScanner, DirectoryCleaner, DirectoryCopier, DirectoryCreator, FileCopier, FileRenamer, FilenameExtractor, FontGenerator, PackageCreator, StyleProcessor, VersionWriter, VersionManager, TypeScriptCompiler, JavaScriptMinifier, NpmCommandRunner, StylizedLogger, TemplateWriter, TestRunner, DocumentationGenerator, CodeLinter, SvgReader, SvgToPngConverter, SvgSpriteGenerator, SvgPackager, gl_installer, cleanDirectory, readPackageJson, };
export { DirectoryScanner, DirectoryCleaner, DirectoryCopier, DirectoryCreator, FileCopier, FileRenamer, FilenameExtractor, FontGenerator, PackageCreator, StyleProcessor, VersionWriter, VersionManager, TypeScriptCompiler, JavaScriptMinifier, NpmCommandRunner, StylizedLogger, TemplateWriter, TestRunner, DocumentationGenerator, CodeLinter, JSONLoader, SvgReader, SvgToPngConverter, SvgSpriteGenerator, SvgPackager, gl_installer, cleanDirectory, readPackageJson, };
4 changes: 3 additions & 1 deletion dist/js/index.js
Expand Up @@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.readPackageJson = exports.cleanDirectory = exports.gl_installer = exports.SvgPackager = exports.SvgSpriteGenerator = exports.SvgToPngConverter = exports.SvgReader = exports.CodeLinter = exports.DocumentationGenerator = exports.TestRunner = exports.TemplateWriter = exports.StylizedLogger = exports.NpmCommandRunner = exports.JavaScriptMinifier = exports.TypeScriptCompiler = exports.VersionManager = exports.VersionWriter = exports.StyleProcessor = exports.PackageCreator = exports.FontGenerator = exports.FilenameExtractor = exports.FileRenamer = exports.FileCopier = exports.DirectoryCreator = exports.DirectoryCopier = exports.DirectoryCleaner = exports.DirectoryScanner = void 0;
exports.readPackageJson = exports.cleanDirectory = exports.gl_installer = exports.SvgPackager = exports.SvgSpriteGenerator = exports.SvgToPngConverter = exports.SvgReader = exports.JSONLoader = exports.CodeLinter = exports.DocumentationGenerator = exports.TestRunner = exports.TemplateWriter = exports.StylizedLogger = exports.NpmCommandRunner = exports.JavaScriptMinifier = exports.TypeScriptCompiler = exports.VersionManager = exports.VersionWriter = exports.StyleProcessor = exports.PackageCreator = exports.FontGenerator = exports.FilenameExtractor = exports.FileRenamer = exports.FileCopier = exports.DirectoryCreator = exports.DirectoryCopier = exports.DirectoryCleaner = exports.DirectoryScanner = void 0;
// Copyright 2023 Scape Agency BV
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,6 +68,8 @@ var DocumentationGenerator_js_1 = __importDefault(require("./class/Documentation
exports.DocumentationGenerator = DocumentationGenerator_js_1.default;
var CodeLinter_js_1 = __importDefault(require("./class/CodeLinter.js"));
exports.CodeLinter = CodeLinter_js_1.default;
var JSONLoader_js_1 = __importDefault(require("./class/JSONLoader.js"));
exports.JSONLoader = JSONLoader_js_1.default;
// Import | Internal Functions
var gl_installer_1 = __importDefault(require("./function/gl_installer"));
exports.gl_installer = gl_installer_1.default;
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
@@ -1,6 +1,6 @@
{
"name": "pack.gl",
"version": "0.0.38",
"version": "0.0.39",
"description": "Package Builder.",
"keywords": [
"pack.gl",
Expand Down
84 changes: 84 additions & 0 deletions dist/ts/class/JSONLoader.ts
@@ -0,0 +1,84 @@
// class/JSONLoader.ts

// Copyright 2023 Scape Agency BV

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


// ============================================================================
// Import
// ============================================================================

import { promises as fs } from 'fs';
import path from 'path';


// ============================================================================
// Classes
// ============================================================================

class JSONLoader {
/**
* Asynchronously loads JSON data from a file and returns it as an object.
* @param filePath The path to the JSON file.
* @returns A promise that resolves to an object containing the JSON data.
*/
async loadJSON<T>(filePath: string): Promise<T> {
try {
const data = await fs.readFile(filePath, 'utf8');
return JSON.parse(data) as T;
} catch (error) {
console.error(`Error reading JSON file: ${filePath}`, error);
throw error;
}
}

/**
* Asynchronously loads all JSON files from a given directory.
* @param dirPath The path to the directory containing JSON files.
* @returns A promise that resolves to an array of objects containing the JSON data.
*/
async loadJSONFromDirectory<T>(dirPath: string): Promise<T[]> {
try {
const files = await fs.readdir(dirPath);
const jsonFiles = files.filter(file => file.endsWith('.json'));

const jsonData = await Promise.all(
jsonFiles.map(file =>
this.loadJSON<T>(path.join(dirPath, file))
)
);

return jsonData;
} catch (error) {
console.error(`Error reading JSON files from directory: ${dirPath}`, error);
throw error;
}
}

/**
* Merges an array of objects into a single object.
* @param objects An array of objects to merge.
* @returns A single object containing all properties from the input objects.
*/
async mergeJSONObjects<T>(objects: T[]): Promise<T> {
return objects.reduce((acc, obj) => ({ ...acc, ...obj }), {} as T);
}
}


// ============================================================================
// Export
// ============================================================================

export default JSONLoader;
17 changes: 9 additions & 8 deletions dist/ts/config/fantasticon.config.ts
Expand Up @@ -27,7 +27,7 @@ import RunnerOptionalOptions from 'fantasticon';
const fantasticonConfig: any = {

// RunnerOptionalOptions
name: 'icon.gl',
name: 'icon',
fontTypes: [
FontAssetType.TTF, // TTF = "ttf"
FontAssetType.WOFF, // WOFF = "woff"
Expand Down Expand Up @@ -72,17 +72,18 @@ const fantasticonConfig: any = {
woff: './dist/font/icon.gl.woff',
woff2: './dist/font/icon.gl.woff2',
},
// codepoints: {
// 'chevron-left': 57344, // decimal representation of 0xe000
// 'chevron-right': 57345,
// 'thumbs-up': 57358,
// 'thumbs-down': 57359,
// },

codepoints: {
'chevron-left': 57344, // decimal representation of 0xe000
'chevron-right': 57345,
'thumbs-up': 57358,
'thumbs-down': 57359,
},
// fontHeight: number;
// descent: number;
// normalize: boolean;
// round: number;
selector: '.igl',
selector: '.i',
// tag: string;
// Use our custom Handlebars templates
// templates: {
Expand Down
2 changes: 2 additions & 0 deletions dist/ts/index.ts
Expand Up @@ -50,6 +50,7 @@ import SvgPackager from "./class/SvgPackager.js";
import TestRunner from './class/TestRunner.js';
import DocumentationGenerator from './class/DocumentationGenerator.js';
import CodeLinter from './class/CodeLinter.js';
import JSONLoader from './class/JSONLoader.js';


// Import | Internal Functions
Expand Down Expand Up @@ -87,6 +88,7 @@ export {
TestRunner,
DocumentationGenerator,
CodeLinter,
JSONLoader,

SvgReader,
SvgToPngConverter,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "pack.gl",
"description": "Package Builder.",
"version": "0.0.38",
"version": "0.0.39",
"config": {
"version_short": "0.0"
},
Expand Down

0 comments on commit 3bb430d

Please sign in to comment.