generated from maxgfr/typescript-swc-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
3,264 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
name: Publish package to npm | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install | ||
run: yarn install --frozen-lockfile | ||
- name: Build | ||
run: yarn build | ||
- name: Release | ||
run: yarn release |
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,17 @@ | ||
{ | ||
"branches": [ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"main", | ||
"next", | ||
"next-major", | ||
{ "name": "beta", "prerelease": true }, | ||
{ "name": "alpha", "prerelease": true } | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/npm", | ||
"@semantic-release/github", | ||
"@semantic-release/git" | ||
] | ||
} |
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,37 +1,15 @@ | ||
# typescript-swc-starter | ||
# insta-who-unfollowed-me | ||
|
||
A simple node boilerplate made in typescript using swc. | ||
Utility to make it easy to track unfollowers on Instagram. | ||
|
||
> NOTE : A version without rust compiler [swc](https://swc.rs/) is available [here](https://github.com/maxgfr/boilerplate-typescript-node). | ||
![Alt Text](https://raw.githubusercontent.com/maxgfr/insta-who-unfollowed-me/main/.github/assets/main.gif) | ||
|
||
## Clone repository and install dependencies | ||
## Usage | ||
|
||
```sh | ||
git clone https://github.com/maxgfr/typescript-swc-starter # For cloning the repository | ||
cd typescript-swc-starter # To navigate to the repository root | ||
yarn # Install dependencies | ||
cp .env.example .env | ||
``` | ||
|
||
## Running the code | ||
|
||
```sh | ||
yarn build # For building the code with typechecking | ||
yarn build:swc # For building without typechecking | ||
yarn start # For running the code builded | ||
``` | ||
|
||
Or in `development` mode: | ||
npm install -g insta-who-unfollowed-me | ||
insta-who-unfollowed-me | ||
|
||
```sh | ||
yarn dev # For running the code in development thanks to swc and nodemon | ||
``` | ||
|
||
> **:warning: No typechecking made in dev mode** | ||
## Testing the code | ||
|
||
```sh | ||
yarn test # For running unit test | ||
yarn test:watch # For watching unit test | ||
# or by using npx | ||
npx insta-who-unfollowed-me | ||
``` |
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 was deleted.
Oops, something went wrong.
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,47 @@ | ||
import prompts from 'prompts'; | ||
import { Command } from 'commander'; | ||
|
||
type PromptResult = { | ||
username: string; | ||
password: string; | ||
}; | ||
|
||
const questions: Array<prompts.PromptObject> = [ | ||
{ | ||
type: 'text', | ||
name: 'username', | ||
message: 'My instagram username:', | ||
}, | ||
{ | ||
type: 'password', | ||
name: 'password', | ||
message: 'My instagram password:', | ||
}, | ||
]; | ||
|
||
async function promptUser(): Promise<Partial<PromptResult>> { | ||
const { username, password } = await prompts( | ||
questions, | ||
); | ||
return { username, password }; | ||
} | ||
|
||
async function processUserInformations() { | ||
const { username, password } = await promptUser(); | ||
if (!username || !password) { | ||
console.log('Missing informations 😭'); | ||
return; | ||
} | ||
|
||
} | ||
|
||
export async function runCommand() { | ||
const program = new Command(); | ||
|
||
program | ||
.name('insta-who-unfollowed-me') | ||
.description('Utility to make it easy to track unfollowers on Instagram') | ||
.action(() => processUserInformations()); | ||
|
||
program.parse(); | ||
} |
This file was deleted.
Oops, something went wrong.
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,8 +1,6 @@ | ||
import 'dotenv/config'; // To use our .env | ||
import { sayHello } from './hello'; | ||
#! /usr/bin/env node | ||
import { runCommand } from './cli'; | ||
|
||
async function main() { | ||
sayHello(); | ||
} | ||
|
||
main(); | ||
if (require.main === module) { | ||
runCommand(); | ||
} |
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,24 @@ | ||
import { IgApiClient, Feed } from 'instagram-private-api'; | ||
|
||
export async function getNotFollowingUsers(username: string, password: string): Promise<string[]> { | ||
const ig = new IgApiClient(); | ||
ig.state.generateDevice(username); | ||
await ig.simulate.preLoginFlow(); | ||
await ig.account.login(username, password); | ||
const followersFeed = ig.feed.accountFollowers(ig.state.cookieUserId); | ||
const followingFeed = ig.feed.accountFollowing(ig.state.cookieUserId); | ||
const followers = await getAllItemsFromFeed(followersFeed); | ||
const following = await getAllItemsFromFeed(followingFeed); | ||
const followersUsername = new Set(followers.map(({ username }) => username)); | ||
const notFollowingYou = following.filter(({ username }) => !followersUsername.has(username)); | ||
return notFollowingYou.map(({ username }) => username); | ||
} | ||
|
||
async function getAllItemsFromFeed<T>(feed: Feed<any, T>): Promise<T[]> { | ||
let items: any = []; | ||
do { | ||
items = items.concat(await feed.items()); | ||
} while (feed.isMoreAvailable()); | ||
return items; | ||
|
||
} |
Oops, something went wrong.