Skip to content

Commit

Permalink
fixed tests and added workflows/issues-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannchb-pro committed Nov 4, 2024
1 parent 5157aec commit 9e69831
Show file tree
Hide file tree
Showing 43 changed files with 458 additions and 301 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
ignorePatterns: ['node_modules/', 'dist'],
overrides: [
{
files: ['src/**/*'],
rules: {
'@typescript-eslint/no-explicit-any': 'off'
}
}
]
};
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Bug Report
about: Report a bug or issue with the software.
title: '[BUG]'
labels: 'bug'
assignees: ''
---

## Bug Report

**Description of the Bug**
A clear and concise description of the bug.

**Steps to Reproduce**

1. Step 1
2. Step 2
3. ...

**Expected Behavior**
A clear and concise description of what you expected to happen.

**Actual Behavior**
A clear and concise description of what actually happens.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Tried Solutions**
Have you tried anything to solve the problem? If yes, what?

**Additional Context**
Add any other context about the problem here.

**Additional Information**
Add any other information you think is relevant.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature Request
about: Suggest a new feature or enhancement for the project.
title: '[FEATURE]'
labels: 'enhancement'
assignees: ''
---

## Feature Request

**Description of the Feature**
A clear and concise description of the feature you'd like to see added.

**Motivation**
An explanation of the motivation behind this feature. How would it improve the user experience or utility of the software?

**Screenshot (Optional)**
If possible, add a screenshot or illustration of the feature you're proposing.

**Additional Context**
Add any other context or information about the feature that you think is relevant.

**Additional Information**
Add any other information you think is relevant.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/HELP_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Help Request
about: Use this template to request help or support.
title: '[HELP]'
labels: help
assignees: ''
---

## Help Request

**Issue Summary**

[Summarize the issue you are facing concisely.]

**Describe the problem**

[Describe what is the problem]

**Environment**

- Operating System: [Your OS]
- Browser: [Your Browser]
- Version: [Version Number]
- Any other relevant information

### Screenshots

[Include any relevant screenshots if they can help illustrate the issue.]

### Additional Information

[Any additional information that may be helpful in diagnosing the issue.]
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Pull Request

**Description**
A brief description of the changes in this pull request.

**Related Issue**

- Fixes # (issue number)
- Addresses # (issue number)

**Changes Made**
Describe the changes you've made. Provide a high-level overview of what has been done in this pull request.

**Screenshots (if applicable)**
Add screenshots or GIFs to demonstrate the changes, if applicable.

**Checklist**

- [ ] I have tested the changes locally.
- [ ] I have updated the documentation accordingly.
- [ ] I have added necessary comments to the code.
- [ ] All tests pass successfully.

**Additional Notes**
Add any additional notes or comments about the pull request here.

**Reviewer(s)**
@username1, @username2
45 changes: 45 additions & 0 deletions .github/workflows/test-prettier-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test, Lint and Format Code

on:
push:
pull_request:

jobs:
test-lint-and-format:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Clear cache and Install dependencies
run: |
rm -rf node_modules package-lock.json
npm install
- name: Run Build
run: npm run fastBuild

- name: Run Tests
run: npm run test

- name: Run Prettier
run: npm run prettier

- name: Run Linter
run: npm run lint

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'WORKFLOW: Apply code formatting'
branch: ${{ github.head_ref }}
file_pattern: '.'
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"printWidth": 100,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto"
}
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const {
GOOGLE_IMG_SCRAP,
GOOGLE_IMG_INVERSE_ENGINE_URL,
GOOGLE_IMG_INVERSE_ENGINE_UPLOAD,
GOOGLE_QUERY,
} = require("google-img-scrap");
GOOGLE_QUERY
} = require('google-img-scrap');
// OR
import {
GOOGLE_IMG_SCRAP,
GOOGLE_IMG_INVERSE_ENGINE_URL,
GOOGLE_IMG_INVERSE_ENGINE_UPLOAD,
GOOGLE_QUERY,
} from "google-img-scrap";
GOOGLE_QUERY
} from 'google-img-scrap';
```

## Options definition
Expand Down Expand Up @@ -84,7 +84,7 @@ Search cats images

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
search: 'cats'
});

console.log(test);
Expand All @@ -98,7 +98,7 @@ The second parameter is like GOOGLE_IMG_SCRAP it include all type of options omi

```js
const test = await GOOGLE_IMG_INVERSE_ENGINE_URL(
"https://upload.wikimedia.org/wikipedia/commons/1/15/Cat_August_2010-4.jpg",
'https://upload.wikimedia.org/wikipedia/commons/1/15/Cat_August_2010-4.jpg',
{ limit: 5 }
);

Expand All @@ -108,9 +108,9 @@ console.log(test);
### With a local image (cost: 3 request)

```js
const imageBuffer = fs.readFileSync("demonSlayer.png");
const imageBuffer = fs.readFileSync('demonSlayer.png');
const test = await GOOGLE_IMG_INVERSE_ENGINE_UPLOAD(imageBuffer, {
limit: 5,
limit: 5
});

console.log(test);
Expand All @@ -123,12 +123,12 @@ Find all possible query options below.

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
search: 'cats',
query: {
TYPE: GOOGLE_QUERY.TYPE.CLIPART,
LICENCE: GOOGLE_QUERY.LICENCE.COMMERCIAL_AND_OTHER,
EXTENSION: GOOGLE_QUERY.EXTENSION.JPG,
},
EXTENSION: GOOGLE_QUERY.EXTENSION.JPG
}
});

console.log(test);
Expand All @@ -138,8 +138,8 @@ console.log(test);

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
limit: 5,
search: 'cats',
limit: 5
});

console.log(test);
Expand All @@ -151,12 +151,12 @@ See axios documentation to setup the proxy

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
search: 'cats',
proxy: {
protocol: "https",
host: "example.com",
port: 8080,
},
protocol: 'https',
host: 'example.com',
port: 8080
}
});

console.log(test);
Expand All @@ -168,8 +168,8 @@ Only scrap from a specific domain

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
domains: ["alamy.com", "istockphoto.com", "vecteezy.com"],
search: 'cats',
domains: ['alamy.com', 'istockphoto.com', 'vecteezy.com']
});

console.log(test);
Expand All @@ -179,8 +179,8 @@ console.log(test);

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
excludeDomains: ["istockphoto.com", "alamy.com"],
search: 'cats',
excludeDomains: ['istockphoto.com', 'alamy.com']
});

console.log(test);
Expand All @@ -192,8 +192,8 @@ If you don' like black cats and white cats

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
excludeWords: ["black", "white"], //If you don't like black cats and white cats
search: 'cats',
excludeWords: ['black', 'white'] //If you don't like black cats and white cats
});

console.log(test);
Expand All @@ -203,8 +203,8 @@ console.log(test);

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
safeSearch: false,
search: 'cats',
safeSearch: false
});

console.log(test);
Expand All @@ -214,8 +214,8 @@ console.log(test);

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
custom: "name=content&name2=content2",
search: 'cats',
custom: 'name=content&name2=content2'
});

console.log(test);
Expand All @@ -225,17 +225,17 @@ console.log(test);

```js
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
search: 'cats',
//will build something like this "(draw and white) or (albino and white)"
filterByTitles: [
["draw", "white"],
["albino", "white"],
['draw', 'white'],
['albino', 'white']
],
//will build something like this "(cdn and wikipedia) or (cdn istockphoto)"
urlMatch: [
["cdn", "wikipedia"],
["cdn", "istockphoto"],
],
['cdn', 'wikipedia'],
['cdn', 'istockphoto']
]
});

console.log(test);
Expand Down
6 changes: 3 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { GOOGLE_IMG_SCRAP } = require("../dist");
const { GOOGLE_IMG_SCRAP } = require('../dist');

(async function () {
const test = await GOOGLE_IMG_SCRAP({
search: "cats",
limit: 5,
search: 'cats',
limit: 5
});

console.log(test, test.result.length);
Expand Down
Loading

0 comments on commit 9e69831

Please sign in to comment.