Skip to content

Commit

Permalink
chore: prepare to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed May 10, 2024
1 parent 67b13f1 commit 70bf2fd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ jobs:
id: process
with:
rootDir: './example'

env:
EXAMPLE: 'World'
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gh-action-example",
"name": "prp-preprocessor",
"version": "1.0.0",
"description": "",
"description": "A GitHub Action that preprocesses files",
"main": "index.js",
"scripts": {
"clean": "rimraf dist pnpm-lock.yaml node_modules",
Expand All @@ -13,13 +13,23 @@
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .",
"package": "pnpm ncc build src/index.ts -o dist --source-map --license licenses.txt",
"package:watch": "pnpm run package --watch",
"test": "pnpm jest --coverage --verbose",
"test": "pnpm jest --coverage",
"prepublishOnly": "pnpm run clean && pnpm install && pnpm run build",
"preflight": "pnpm install && pnpm run format:write && pnpm run lint && pnpm run test && pnpm run package",
"preflight": "pnpm install && pnpm run format:write && pnpm run lint && pnpm run package",
"prepare": "husky"
},
"keywords": [],
"author": "",
"keywords": [
"github",
"action",
"preprocessor",
"replace",
"variables"
],
"author": "Breno A.",
"homepage": "https://github.com/CIFriends/prp-preprocessor#readme",
"bugs": {
"url": "https://github.com/CIFriends/prp-preprocessor/issues"
},
"license": "Apache-2.0",
"packageManager": "[email protected]",
"jest": {
Expand Down
18 changes: 9 additions & 9 deletions src/utils/ExtensionFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ export function getFilesByExtension(params: GetFilesParams): string[] {
}
}

interface GetFilesParams {
dir: string;
extension: string;
includeSubDir?: boolean;
ignoredDir?: string[];
fsModule?: typeof fs;
pathModule?: typeof path;
}

/**
* Generate a regular expression with a wildcard pattern
* @param extension
Expand All @@ -100,3 +91,12 @@ const ignoredDefault: string[] = [
".vscode",
".idea"
];

interface GetFilesParams {
dir: string;
extension: string;
includeSubDir?: boolean;
ignoredDir?: string[];
fsModule?: typeof fs;
pathModule?: typeof path;
}
10 changes: 10 additions & 0 deletions src/utils/FileProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import fs from "fs";

/**
* Process files and replace variables
* @param params - Files parameters see {@link FilesParams}
*/
export function processFiles(params: FilesParams): void {
const { files, encodings, variables, fsModule = fs, extension } = params;

Expand All @@ -23,6 +27,12 @@ export function processFiles(params: FilesParams): void {
}
}

/**
* Replace variables in content
* @param variables - Map of variables
* @param content - Content to replace variables
* @returns {string} Content with replaced variables
*/
export function replaceVariables(
variables: Map<string, string>,
content: string
Expand Down
4 changes: 4 additions & 0 deletions src/utils/VariableManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function getEnvVariables(ignored: string[]): Map<string, string> {
);
}

/**
* Get all input parameters
* @returns {InputParams} Input parameters
*/
export function getInputParams(): InputParams {
const rootDir: string = core.getInput("rootDir", required);
const extension: string = core.getInput("extension", required);
Expand Down

0 comments on commit 70bf2fd

Please sign in to comment.