Skip to content

Commit aab3f30

Browse files
authored
feat: add filename formatter and directory workflow (#76)
1 parent 69767aa commit aab3f30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+107
-27
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Directory/Filename Formatter workflow
2+
on: [push, pull_request]
3+
4+
jobs:
5+
main:
6+
name: (Directory) Formatter
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@main
10+
- name: Setup Git configuration
11+
run: |
12+
git config --global user.name 'autoprettier'
13+
git config --global user.email '[email protected]'
14+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
15+
- name: Filename Formatter
16+
run: |
17+
IFS=$'\n'
18+
for fname in `find . -type f -name '*.ts' -o -name '*.ts'`
19+
do
20+
echo "${fname}"
21+
new_fname=`echo ${fname} | tr ' ' '_'`
22+
echo " ${new_fname}"
23+
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
24+
echo " ${new_fname}"
25+
new_fname=`echo ${new_fname} | tr '-' '_'`
26+
echo " ${new_fname}"
27+
if [ ${fname} != ${new_fname} ]
28+
then
29+
echo " ${fname} --> ${new_fname}"
30+
git "mv" "${fname}" ${new_fname}
31+
fi
32+
done
33+
git commit -am "Formatting filenames ${GITHUB_SHA::8}" || true
34+
- name: Update DIRECTORY.md
35+
run: |
36+
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
37+
python3 build_directory_md.py TypeScript . .ts jest.config.ts,sorts/test,search/test,maths/test,dynamic_programming/test,data_structures/test,ciphers/test > DIRECTORY.md
38+
39+
git diff
40+
git commit -m "Update DIRECTORY.md" DIRECTORY.md || true
41+
git push --force origin HEAD:$GITHUB_REF || true

DIRECTORY.md

+39

Ciphers/test/XORCipher.test.ts renamed to ciphers/test/xor_cipher.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { XORCipher } from '../XORCipher';
1+
import { XORCipher } from '../xor_cipher';
22

33
describe('Testing XORCipher function', () => {
44
it('passing a string & number as an argument', () => {
File renamed without changes.
File renamed without changes.

Data-Structures/test/Stack.test.ts renamed to data_structures/test/stack.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Stack } from '../Stack';
1+
import { Stack } from '../stack';
22

33
describe('Testing Stack data structure', () => {
44
it('push should add a new element to the stack', () => {
File renamed without changes.

dynamic_programing/test/Knapsack.test.ts renamed to dynamic_programming/test/knapsack.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { knapsack } from "../Knapsack";
1+
import { knapsack } from "../knapsack";
22

33
const cases: [number, number[], number[], number][] = [
44
[15, [6, 5, 6, 6, 3, 7], [5, 6, 4, 6, 5, 2], 17],
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Maths/test/AbsoluteValue.test.ts renamed to maths/test/absolute_value.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AbsoluteValue } from "../AbsoluteValue";
1+
import { AbsoluteValue } from "../absolute_value";
22

33
describe("AbsoluteValue", () => {
44
it("should return the absolute value of zero", () => {

Maths/test/AliquotSum.test.ts renamed to maths/test/aliquot_sum.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AliquotSum } from "../AliquotSum";
1+
import { AliquotSum } from "../aliquot_sum";
22

33
test.each([[15, 9], [18, 21], [28, 28], [100, 117], [169, 14], [1729, 511], [15625, 3906]])("Aliquot Sum of %i is %i", (num, expected) => {
44
expect(AliquotSum(num)).toBe(expected)

Maths/test/ArmstrongNumber.test.ts renamed to maths/test/armstrong_number.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArmstrongNumber } from "../ArmstrongNumber"
1+
import { ArmstrongNumber } from "../armstrong_number"
22

33
test.each([[9, true], [-310, false], [0, false], [407, true], [420, false], [92727, true], [13579, false]])('i is an Armstrong number or not', (num, expected) => {
44
expect(ArmstrongNumber(num)).toBe(expected)

Maths/test/BinaryConvert.test.ts renamed to maths/test/binary_convert.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BinaryConvert } from '../BinaryConvert'
1+
import { BinaryConvert } from '../binary_convert'
22

33
describe('BinaryConvert', () => {
44
it('should return the correct value', () => {

Maths/test/CalculateMean.test.ts renamed to maths/test/calculate_mean.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { calculateMean } from "../CalculateMean";
1+
import { calculateMean } from "../calculate_mean";
22

33
describe("Tests for AverageMean", () => {
44
it("should be a function", () => {

Maths/test/DegreesToRadians.test.ts renamed to maths/test/degrees_to_radians.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {degreesToRadians} from '../DegreesToRadians';
1+
import {degreesToRadians} from '../degrees_to_radians';
22

33
test("DegreesToRadians", () => {
44
expect(degreesToRadians(0)).toBe(0);

Maths/test/DigitSum.test.ts renamed to maths/test/digit_sum.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DigitSum } from "../DigitSum";
1+
import { DigitSum } from "../digit_sum";
22

33
describe("DigitSum", () => {
44
test.each([-42, -0.1, -1, 0.2, 3.3, NaN, -Infinity, Infinity])(

Maths/test/Factorial.test.ts renamed to maths/test/factorial.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Factorial } from "../Factorial";
1+
import { Factorial } from "../factorial";
22

33
describe("Factorial", () => {
44
test.each([-0.1, -1, -2, -42, 0.01, 0.42, 0.5, 1.337])(

Maths/test/Fibonacci.test.ts renamed to maths/test/fibonacci.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {nthFibonacci} from '../Fibonacci';
1+
import {nthFibonacci} from '../fibonacci';
22

33
describe('nthFibonacci', () => {
44
test('should return correct value', () => {

Maths/test/FindMin.test.ts renamed to maths/test/find_min.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FindMin } from "../FindMin";
1+
import { FindMin } from "../find_min";
22

33
describe("FindMin", () => {
44
test.each([[[1,2,3,4,5,6], 1], [[87,6,13,999], 6], [[0.8,0.2,0.3,0.5], 0.2], [[1,0.1,-1], -1]])(

Maths/test/GreatestCommonFactor.test.ts renamed to maths/test/greatest_common_factor.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { binaryGCF, greatestCommonFactor } from "../GreatestCommonFactor";
1+
import { binaryGCF, greatestCommonFactor } from "../greatest_common_factor";
22

33
describe("binaryGCF", () => {
44
test.each([[12, 8, 4], [1, 199, 1], [88, 40, 8], [288, 160, 32]])(

Maths/test/IsDivisible.test.ts renamed to maths/test/is_divisible.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsDivisible } from "../IsDivisible";
1+
import { IsDivisible } from "../is_divisible";
22

33
describe("IsDivisible", () => {
44
test.each([

Maths/test/IsEven.test.ts renamed to maths/test/is_even.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsEven } from "../IsEven";
1+
import { IsEven } from "../is_even";
22

33
describe("IsEven", () => {
44
test.each([[2, true], [1, false], [0, true], [-1, false], [-2, true]])(

Maths/test/IsLeapYear.test.ts renamed to maths/test/is_leap_year.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsLeapYear } from "../IsLeapYear";
1+
import { IsLeapYear } from "../is_leap_year";
22

33
describe("IsLeapYear", () => {
44
test.each([4, 8, 12, 2004])(

Maths/test/IsOdd.test.ts renamed to maths/test/is_odd.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsOdd } from "../IsOdd";
1+
import { IsOdd } from "../is_odd";
22

33
describe("IsOdd", () => {
44
test.each([[2, false], [1, true], [0, false], [-1, true], [-2, false]])(

Maths/test/PerfectSquare.test.ts renamed to maths/test/perfect_square.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PerfectSquare } from "../PerfectSquare";
1+
import { PerfectSquare } from "../perfect_square";
22

33
test("Check perfect square", () => {
44
expect(PerfectSquare(16)).toBe(true);

Maths/test/RadiansToDegrees.test.ts renamed to maths/test/radians_to_degrees.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {radiansToDegrees} from '../RadiansToDegrees';
1+
import {radiansToDegrees} from '../radians_to_degrees';
22

33
test("RadiansToDegrees", () => {
44
expect(radiansToDegrees(0)).toBe(0);

Maths/test/SieveOfEratosthenes.test.ts renamed to maths/test/sieve_of_eratosthenes.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SieveOfEratosthenes } from "../SieveOfEratosthenes";
1+
import { SieveOfEratosthenes } from "../sieve_of_eratosthenes";
22

33

44
describe("Sieve of Eratosthenes", () => {
File renamed without changes.

Search/test/BinarySearch.test.ts renamed to search/test/binary_search.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { binarySearchIterative, binarySearchRecursive } from "../BinarySearch";
1+
import { binarySearchIterative, binarySearchRecursive } from "../binary_search";
22

33
describe("BinarySearch", () => {
44
const testArray: number[] = [1,2,3,4];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Sorts/test/BubbleSort.test.ts renamed to sorts/test/bubble_sort.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {bubbleSort} from "../BubbleSort"
1+
import {bubbleSort} from "../bubble_sort"
22

33
describe("BubbleSort", () => {
44
 it("should return the correct value for average case", () => {

Sorts/test/GnomeSort.test.ts renamed to sorts/test/gnome_sort.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { gnomeSort } from '../GnomeSort';
1+
import { gnomeSort } from '../gnome_sort';
22

33
describe('Testing Gnome sort', () => {
44
const testCases: number[][] = [

Sorts/test/InsertionSort.test.ts renamed to sorts/test/insertion_sort.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { insertionSort } from "../InsertionSort";
1+
import { insertionSort } from "../insertion_sort";
22

33
describe("Insertion Sort", () => {
44
it("should return the correct value for average case", () => {

Sorts/test/MergeSort.test.ts renamed to sorts/test/merge_sort.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MergeSort } from "../MergeSort";
1+
import { MergeSort } from "../merge_sort";
22

33
describe("Merge Sort", () => {
44
it("generating array with variable length and comparing with sorted array", () => {

Sorts/test/QuickSort.test.ts renamed to sorts/test/quick_sort.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { QuickSort } from "../QuickSort";
1+
import { QuickSort } from "../quick_sort";
22

33
describe("Quick Sort", () => {
44
it("should return the correct value for average case", () => {

0 commit comments

Comments
 (0)