-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
595 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.33 | ||
0.0.35 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.