Skip to content

Commit

Permalink
v0.0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jan 4, 2024
1 parent 0af7ae4 commit 3c7e0a2
Show file tree
Hide file tree
Showing 24 changed files with 595 additions and 62 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.33
0.0.35
11 changes: 11 additions & 0 deletions dist/js/class/DirectoryScanner.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare class DirectoryScanner {
/**
* Scans a directory and returns a list of file paths.
* Can optionally scan directories recursively.
* @param dirPath The directory to scan.
* @param recursive Whether to scan directories recursively.
* @returns A promise that resolves to an array of file paths.
*/
scanDirectory(dirPath: string, recursive?: boolean): Promise<string[]>;
}
export default DirectoryScanner;
53 changes: 53 additions & 0 deletions dist/js/class/DirectoryScanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"use strict";
// class/DirectoryScanner.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 promises_1 = __importDefault(require("fs/promises"));
var path_1 = __importDefault(require("path"));
// ============================================================================
// Classes
// ============================================================================
class DirectoryScanner {
/**
* Scans a directory and returns a list of file paths.
* Can optionally scan directories recursively.
* @param dirPath The directory to scan.
* @param recursive Whether to scan directories recursively.
* @returns A promise that resolves to an array of file paths.
*/
async scanDirectory(dirPath, recursive = false) {
try {
const entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
const files = await Promise.all(entries.map(async (entry) => {
const resolvedPath = path_1.default.resolve(dirPath, entry.name);
return entry.isDirectory() && recursive
? this.scanDirectory(resolvedPath, true)
: resolvedPath;
}));
return files.flat();
}
catch (error) {
console.error(`Error scanning directory: ${dirPath}`, error);
throw error;
}
}
}
// ============================================================================
// Export
// ============================================================================
exports.default = DirectoryScanner;
9 changes: 9 additions & 0 deletions dist/js/class/FilenameExtractor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare class FilenameExtractor {
/**
* Extracts the filename without its extension from a file path.
* @param filePath The full path of the file.
* @returns The filename without its extension.
*/
getFilenameWithoutExtension(filePath: string): string;
}
export default FilenameExtractor;
37 changes: 37 additions & 0 deletions dist/js/class/FilenameExtractor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
// class/FilenameExtractor.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 path_1 = __importDefault(require("path"));
// ============================================================================
// Classes
// ============================================================================
class FilenameExtractor {
/**
* Extracts the filename without its extension from a file path.
* @param filePath The full path of the file.
* @returns The filename without its extension.
*/
getFilenameWithoutExtension(filePath) {
return path_1.default.basename(filePath, path_1.default.extname(filePath));
}
}
// ============================================================================
// Export
// ============================================================================
exports.default = FilenameExtractor;
16 changes: 15 additions & 1 deletion dist/js/class/FontGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ class FontGenerator {
// },
// ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions;
// svg?: SvgOptions; // type SvgOptions = Omit<SvgIcons2FontOptions, 'fontName' | 'fontHeight' | 'descent' | 'normalize'>;
json: { indent: 4 }
json: {
indent: 4
},
ts: {
// select what kind of types you want to generate
// (default `['enum', 'constant', 'literalId', 'literalKey']`)
types: ['enum', 'constant', 'literalId', 'literalKey'],
// render the types with `'` instead of `"` (default is `"`)
singleQuotes: false,
// customise names used for the generated types and constants
enumName: 'icon_gl',
constantName: 'MY_CODEPOINTS'
// literalIdName: 'IconId',
// literalKeyName: 'IconKey'
}
},
pathOptions: {
json: './dist/font/icon.gl.json',
Expand Down
9 changes: 9 additions & 0 deletions dist/js/class/SvgReader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare class SvgReader {
/**
* Reads the content of an SVG file asynchronously.
* @param filePath The path to the SVG file.
* @returns A promise that resolves to the content of the SVG file.
*/
readSVG(filePath: string): Promise<string>;
}
export default SvgReader;
41 changes: 41 additions & 0 deletions dist/js/class/SvgReader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";
// class/SvgReader.ts
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");
// ============================================================================
// Classes
// ============================================================================
class SvgReader {
/**
* Reads the content of an SVG file asynchronously.
* @param filePath The path to the SVG file.
* @returns A promise that resolves to the content of the SVG file.
*/
async readSVG(filePath) {
try {
const data = await fs_1.promises.readFile(filePath, 'utf-8');
return data;
}
catch (error) {
console.error(`Error reading SVG file: ${filePath}`, error);
throw error; // Rethrow the error for further handling if necessary
}
}
}
// ============================================================================
// Export
// ============================================================================
exports.default = SvgReader;
9 changes: 6 additions & 3 deletions dist/js/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import DirectoryScanner from './class/DirectoryScanner';
import DirectoryCleaner from './class/DirectoryCleaner';
import DirectoryCopier from './class/DirectoryCopier';
import DirectoryCreator from './class/DirectoryCreator';
import FileCopier from './class/FileCopier';
import FileRenamer from './class/FileRenamer';
import FilenameExtractor from './class/FilenameExtractor';
import FontGenerator from './class/FontGenerator.js';
import PackageCreator from './class/PackageCreator.js';
import SvgPackager from "./class/SvgPackager.js";
import StyleProcessor from "./class/StyleProcessor.js";
import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js";
import VersionWriter from './class/VersionWriter.js';
import TypeScriptCompiler from './class/TypeScriptCompiler.js';
import JavaScriptMinifier from './class/JavaScriptMinifier.js';
import NpmCommandRunner from './class/NpmCommandRunner.js';
import StylizedLogger from './class/StylizedLogger.js';
import TemplateWriter from './class/TemplateWriter.js';
import SvgReader from './class/SvgReader.js';
import SvgToPngConverter from './class/SvgToPngConverter.js';
import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js";
import SvgPackager from "./class/SvgPackager.js";
import gl_installer from './function/gl_installer';
import cleanDirectory from './function/clean_directory';
import readPackageJson from "./function/readPackageJson.js";
export { DirectoryCleaner, DirectoryCopier, DirectoryCreator, FileCopier, FileRenamer, FontGenerator, PackageCreator, SvgPackager, StyleProcessor, SvgSpriteGenerator, VersionWriter, TypeScriptCompiler, JavaScriptMinifier, NpmCommandRunner, StylizedLogger, TemplateWriter, SvgToPngConverter, gl_installer, cleanDirectory, readPackageJson, };
export { DirectoryScanner, DirectoryCleaner, DirectoryCopier, DirectoryCreator, FileCopier, FileRenamer, FilenameExtractor, FontGenerator, PackageCreator, StyleProcessor, VersionWriter, TypeScriptCompiler, JavaScriptMinifier, NpmCommandRunner, StylizedLogger, TemplateWriter, SvgReader, SvgToPngConverter, SvgSpriteGenerator, SvgPackager, gl_installer, cleanDirectory, readPackageJson, };
16 changes: 11 additions & 5 deletions dist/js/index.js
Original file line number Diff line number Diff line change
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.SvgToPngConverter = exports.TemplateWriter = exports.StylizedLogger = exports.NpmCommandRunner = exports.JavaScriptMinifier = exports.TypeScriptCompiler = exports.VersionWriter = exports.SvgSpriteGenerator = exports.StyleProcessor = exports.SvgPackager = exports.PackageCreator = exports.FontGenerator = exports.FileRenamer = exports.FileCopier = exports.DirectoryCreator = exports.DirectoryCopier = exports.DirectoryCleaner = void 0;
exports.readPackageJson = exports.cleanDirectory = exports.gl_installer = exports.SvgPackager = exports.SvgSpriteGenerator = exports.SvgToPngConverter = exports.SvgReader = exports.TemplateWriter = exports.StylizedLogger = exports.NpmCommandRunner = exports.JavaScriptMinifier = exports.TypeScriptCompiler = 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 All @@ -19,6 +19,8 @@ exports.readPackageJson = exports.cleanDirectory = exports.gl_installer = export
// Import
// ============================================================================
// Import | Utility Classes
var DirectoryScanner_1 = __importDefault(require("./class/DirectoryScanner"));
exports.DirectoryScanner = DirectoryScanner_1.default;
var DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner"));
exports.DirectoryCleaner = DirectoryCleaner_1.default;
var DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier"));
Expand All @@ -29,17 +31,15 @@ var FileCopier_1 = __importDefault(require("./class/FileCopier"));
exports.FileCopier = FileCopier_1.default;
var FileRenamer_1 = __importDefault(require("./class/FileRenamer"));
exports.FileRenamer = FileRenamer_1.default;
var FilenameExtractor_1 = __importDefault(require("./class/FilenameExtractor"));
exports.FilenameExtractor = FilenameExtractor_1.default;
// Import | Internal Classes
var FontGenerator_js_1 = __importDefault(require("./class/FontGenerator.js"));
exports.FontGenerator = FontGenerator_js_1.default;
var PackageCreator_js_1 = __importDefault(require("./class/PackageCreator.js"));
exports.PackageCreator = PackageCreator_js_1.default;
var SvgPackager_js_1 = __importDefault(require("./class/SvgPackager.js"));
exports.SvgPackager = SvgPackager_js_1.default;
var StyleProcessor_js_1 = __importDefault(require("./class/StyleProcessor.js"));
exports.StyleProcessor = StyleProcessor_js_1.default;
var SvgSpriteGenerator_js_1 = __importDefault(require("./class/SvgSpriteGenerator.js"));
exports.SvgSpriteGenerator = SvgSpriteGenerator_js_1.default;
var VersionWriter_js_1 = __importDefault(require("./class/VersionWriter.js"));
exports.VersionWriter = VersionWriter_js_1.default;
var TypeScriptCompiler_js_1 = __importDefault(require("./class/TypeScriptCompiler.js"));
Expand All @@ -52,8 +52,14 @@ var StylizedLogger_js_1 = __importDefault(require("./class/StylizedLogger.js"));
exports.StylizedLogger = StylizedLogger_js_1.default;
var TemplateWriter_js_1 = __importDefault(require("./class/TemplateWriter.js"));
exports.TemplateWriter = TemplateWriter_js_1.default;
var SvgReader_js_1 = __importDefault(require("./class/SvgReader.js"));
exports.SvgReader = SvgReader_js_1.default;
var SvgToPngConverter_js_1 = __importDefault(require("./class/SvgToPngConverter.js"));
exports.SvgToPngConverter = SvgToPngConverter_js_1.default;
var SvgSpriteGenerator_js_1 = __importDefault(require("./class/SvgSpriteGenerator.js"));
exports.SvgSpriteGenerator = SvgSpriteGenerator_js_1.default;
var SvgPackager_js_1 = __importDefault(require("./class/SvgPackager.js"));
exports.SvgPackager = SvgPackager_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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pack.gl",
"version": "0.0.33",
"version": "0.0.35",
"description": "Package Builder.",
"keywords": [
"pack.gl",
Expand Down
1 change: 0 additions & 1 deletion dist/ts/class/DirectoryCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { promises as fsPromises } from 'fs';
import path from 'path';



// ============================================================================
// Classes
// ============================================================================
Expand Down
65 changes: 65 additions & 0 deletions dist/ts/class/DirectoryScanner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// class/DirectoryScanner.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 fs from 'fs/promises';
import path from 'path';


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

class DirectoryScanner {

/**
* Scans a directory and returns a list of file paths.
* Can optionally scan directories recursively.
* @param dirPath The directory to scan.
* @param recursive Whether to scan directories recursively.
* @returns A promise that resolves to an array of file paths.
*/
async scanDirectory(
dirPath: string,
recursive: boolean = false
): Promise<string[]> {
try {
const entries = await fs.readdir(dirPath, { withFileTypes: true });
const files = await Promise.all(entries.map(async (entry) => {
const resolvedPath = path.resolve(dirPath, entry.name);
return entry.isDirectory() && recursive
? this.scanDirectory(resolvedPath, true)
: resolvedPath;
}));

return files.flat();
} catch (error) {
console.error(`Error scanning directory: ${dirPath}`, error);
throw error;
}
}

}

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

export default DirectoryScanner;
Loading

0 comments on commit 3c7e0a2

Please sign in to comment.