Skip to content

feat: add filename formatter and directory workflow #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/directory_formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Directory/Filename Formatter workflow
on: [push, pull_request]

jobs:
main:
name: (Directory) Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Setup Git configuration
run: |
git config --global user.name 'autoprettier'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
- name: Filename Formatter
run: |
IFS=$'\n'
for fname in `find . -type f -name '*.ts' -o -name '*.ts'`
do
echo "${fname}"
new_fname=`echo ${fname} | tr ' ' '_'`
echo " ${new_fname}"
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
echo " ${new_fname}"
new_fname=`echo ${new_fname} | tr '-' '_'`
echo " ${new_fname}"
if [ ${fname} != ${new_fname} ]
then
echo " ${fname} --> ${new_fname}"
git "mv" "${fname}" ${new_fname}
fi
done
git commit -am "Formatting filenames ${GITHUB_SHA::8}" || true
- name: Update DIRECTORY.md
run: |
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
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

git diff
git commit -m "Update DIRECTORY.md" DIRECTORY.md || true
git push --force origin HEAD:$GITHUB_REF || true
39 changes: 39 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

## Ciphers
* [Xor Cipher](https://github.com/TheAlgorithms/TypeScript/blob/master/ciphers/xor_cipher.ts)

## Data Structures
* [Stack](https://github.com/TheAlgorithms/TypeScript/blob/master/data_structures/stack.ts)

## Dynamic Programming
* [Knapsack](https://github.com/TheAlgorithms/TypeScript/blob/master/dynamic_programming/knapsack.ts)

## Maths
* [Absolute Value](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/absolute_value.ts)
* [Aliquot Sum](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/aliquot_sum.ts)
* [Armstrong Number](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/armstrong_number.ts)
* [Binary Convert](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/binary_convert.ts)
* [Calculate Mean](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/calculate_mean.ts)
* [Degrees To Radians](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/degrees_to_radians.ts)
* [Digit Sum](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/digit_sum.ts)
* [Factorial](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/factorial.ts)
* [Fibonacci](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/fibonacci.ts)
* [Find Min](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/find_min.ts)
* [Greatest Common Factor](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/greatest_common_factor.ts)
* [Is Divisible](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/is_divisible.ts)
* [Is Even](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/is_even.ts)
* [Is Leap Year](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/is_leap_year.ts)
* [Is Odd](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/is_odd.ts)
* [Perfect Square](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/perfect_square.ts)
* [Radians To Degrees](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/radians_to_degrees.ts)
* [Sieve Of Eratosthenes](https://github.com/TheAlgorithms/TypeScript/blob/master/maths/sieve_of_eratosthenes.ts)

## Search
* [Binary Search](https://github.com/TheAlgorithms/TypeScript/blob/master/search/binary_search.ts)

## Sorts
* [Bubble Sort](https://github.com/TheAlgorithms/TypeScript/blob/master/sorts/bubble_sort.ts)
* [Gnome Sort](https://github.com/TheAlgorithms/TypeScript/blob/master/sorts/gnome_sort.ts)
* [Insertion Sort](https://github.com/TheAlgorithms/TypeScript/blob/master/sorts/insertion_sort.ts)
* [Merge Sort](https://github.com/TheAlgorithms/TypeScript/blob/master/sorts/merge_sort.ts)
* [Quick Sort](https://github.com/TheAlgorithms/TypeScript/blob/master/sorts/quick_sort.ts)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XORCipher } from '../XORCipher';
import { XORCipher } from '../xor_cipher';

describe('Testing XORCipher function', () => {
it('passing a string & number as an argument', () => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack } from '../Stack';
import { Stack } from '../stack';

describe('Testing Stack data structure', () => {
it('push should add a new element to the stack', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { knapsack } from "../Knapsack";
import { knapsack } from "../knapsack";

const cases: [number, number[], number[], number][] = [
[15, [6, 5, 6, 6, 3, 7], [5, 6, 4, 6, 5, 2], 17],
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbsoluteValue } from "../AbsoluteValue";
import { AbsoluteValue } from "../absolute_value";

describe("AbsoluteValue", () => {
it("should return the absolute value of zero", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AliquotSum } from "../AliquotSum";
import { AliquotSum } from "../aliquot_sum";

test.each([[15, 9], [18, 21], [28, 28], [100, 117], [169, 14], [1729, 511], [15625, 3906]])("Aliquot Sum of %i is %i", (num, expected) => {
expect(AliquotSum(num)).toBe(expected)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArmstrongNumber } from "../ArmstrongNumber"
import { ArmstrongNumber } from "../armstrong_number"

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) => {
expect(ArmstrongNumber(num)).toBe(expected)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BinaryConvert } from '../BinaryConvert'
import { BinaryConvert } from '../binary_convert'

describe('BinaryConvert', () => {
it('should return the correct value', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { calculateMean } from "../CalculateMean";
import { calculateMean } from "../calculate_mean";

describe("Tests for AverageMean", () => {
it("should be a function", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {degreesToRadians} from '../DegreesToRadians';
import {degreesToRadians} from '../degrees_to_radians';

test("DegreesToRadians", () => {
expect(degreesToRadians(0)).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DigitSum } from "../DigitSum";
import { DigitSum } from "../digit_sum";

describe("DigitSum", () => {
test.each([-42, -0.1, -1, 0.2, 3.3, NaN, -Infinity, Infinity])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Factorial } from "../Factorial";
import { Factorial } from "../factorial";

describe("Factorial", () => {
test.each([-0.1, -1, -2, -42, 0.01, 0.42, 0.5, 1.337])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {nthFibonacci} from '../Fibonacci';
import {nthFibonacci} from '../fibonacci';

describe('nthFibonacci', () => {
test('should return correct value', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FindMin } from "../FindMin";
import { FindMin } from "../find_min";

describe("FindMin", () => {
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]])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { binaryGCF, greatestCommonFactor } from "../GreatestCommonFactor";
import { binaryGCF, greatestCommonFactor } from "../greatest_common_factor";

describe("binaryGCF", () => {
test.each([[12, 8, 4], [1, 199, 1], [88, 40, 8], [288, 160, 32]])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsDivisible } from "../IsDivisible";
import { IsDivisible } from "../is_divisible";

describe("IsDivisible", () => {
test.each([
Expand Down
2 changes: 1 addition & 1 deletion Maths/test/IsEven.test.ts → maths/test/is_even.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsEven } from "../IsEven";
import { IsEven } from "../is_even";

describe("IsEven", () => {
test.each([[2, true], [1, false], [0, true], [-1, false], [-2, true]])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsLeapYear } from "../IsLeapYear";
import { IsLeapYear } from "../is_leap_year";

describe("IsLeapYear", () => {
test.each([4, 8, 12, 2004])(
Expand Down
2 changes: 1 addition & 1 deletion Maths/test/IsOdd.test.ts → maths/test/is_odd.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsOdd } from "../IsOdd";
import { IsOdd } from "../is_odd";

describe("IsOdd", () => {
test.each([[2, false], [1, true], [0, false], [-1, true], [-2, false]])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PerfectSquare } from "../PerfectSquare";
import { PerfectSquare } from "../perfect_square";

test("Check perfect square", () => {
expect(PerfectSquare(16)).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {radiansToDegrees} from '../RadiansToDegrees';
import {radiansToDegrees} from '../radians_to_degrees';

test("RadiansToDegrees", () => {
expect(radiansToDegrees(0)).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SieveOfEratosthenes } from "../SieveOfEratosthenes";
import { SieveOfEratosthenes } from "../sieve_of_eratosthenes";


describe("Sieve of Eratosthenes", () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { binarySearchIterative, binarySearchRecursive } from "../BinarySearch";
import { binarySearchIterative, binarySearchRecursive } from "../binary_search";

describe("BinarySearch", () => {
const testArray: number[] = [1,2,3,4];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {bubbleSort} from "../BubbleSort"
import {bubbleSort} from "../bubble_sort"

describe("BubbleSort", () => {
 it("should return the correct value for average case", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gnomeSort } from '../GnomeSort';
import { gnomeSort } from '../gnome_sort';

describe('Testing Gnome sort', () => {
const testCases: number[][] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { insertionSort } from "../InsertionSort";
import { insertionSort } from "../insertion_sort";

describe("Insertion Sort", () => {
it("should return the correct value for average case", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MergeSort } from "../MergeSort";
import { MergeSort } from "../merge_sort";

describe("Merge Sort", () => {
it("generating array with variable length and comparing with sorted array", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuickSort } from "../QuickSort";
import { QuickSort } from "../quick_sort";

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