Skip to content
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

Refactor Plugin + add missed typing #35

Merged
merged 14 commits into from
Oct 28, 2024
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
26 changes: 26 additions & 0 deletions .github/actions/setup-node-pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ✍️ Description:
# This is a composite action, which means it can be used in other actions.
# It is used in almost all workflows to set up the environment and install dependencies.
# Updating the package manager or Node version here will be reflected in all workflows.

# 👀 Example usage:
# - name : 📦 Setup Node + PNPM + install deps
# uses: ./.github/actions/setup-node-pnpm-install

name: 'Setup Node + PNPM + Install Dependencies'
description: 'Setup Node + PNPM + Install Dependencies'
runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v4
with:
run_install: false
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: 📦 Install Project Dependencies
run: pnpm install --frozen-lockfile
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/new-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
contents: write
steps:
- name: 📦 Checkout project repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/publish-pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
- name: 📦 Checkout project repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
Expand All @@ -40,17 +40,8 @@ jobs:
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: 📦 Install Project Dependencies
run: pnpm install --frozen-lockfile
- name : 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install

- name: 🏃‍♂️ Create tag
run: |
Expand Down
82 changes: 4 additions & 78 deletions .github/workflows/validate-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name : 📦 Checkout project repo
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'


- name: 📦 Install Project Dependencies
run: pnpm install --frozen-lockfile
uses: actions/checkout@v4
- name : 📦 Setup Node + PNPM + install deps
uses: ./.github/actions/setup-node-pnpm-install
- name: 🏃‍♂️ Run TypeScript
run : pnpm run type-check

# - name: 🏃‍♂️ Run TypeScript # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m
# run: |
# yarn type-check | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee
# env:
# REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# lint:
# name: Lint TS (eslint, prettier)
# runs-on: ubuntu-latest

# steps:
# - name : 📦 Checkout project repo
# uses: actions/checkout@v3
# - uses: pnpm/action-setup@v2
# with:
# version: 8
# - uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'pnpm'


# - name: 📦 Install Project Dependencies
# run: pnpm install --frozen-lockfile
# - name: 🏃‍♂️ Run ESLint
# run : pnpm run lint
# - name: 🏃‍♂️ Run ESLint
# uses: reviewdog/action-eslint@v1
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# reporter: github-pr-review
# eslint_flags: '. --ext .js,.jsx,.ts,.tsx'

# test:
# name: Tests (jest)
# runs-on: ubuntu-latest

# steps:
# - name : 📦 Checkout project repo
# uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'yarn'

# - name: 📦 Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

# - name: 📦 Restore Project Dependencies (node_modules)
# uses: actions/cache@v3
# id: yarn-cache
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-

# - name: 📦 Install Project Dependencies
# run: yarn install --immutable

# - name: 🏃‍♂️ Run Tests
# run: yarn test:ci
run : pnpm run type-check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ assets/*.*.png
example/*.*.png
dist
.DS_Store
ios/
android/
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"endOfLine": "auto"
"endOfLine": "auto",
"trailingComma": "es5"
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ Commands:
use-config <configPath> use json file as a config
help [command] display help for command
```

- **add-badge command**

```
Usage: app-icon-badge add-badge [options] <iconPath>

Expand All @@ -169,10 +171,13 @@ Options:
-b, --background <background> badge background color
-c, --color <color> badge color (choices: "white", "black", default: "white")
```

#### example

```
npx app-icon-badge ./example/icon.png --type=banner --text=hello --position=top --background=#45f4ee --color=black
```

## 🚧 RoadMap

The library is still in its early stages. We have a lot of ideas to improve it and make it more useful. Here are some of the things we have already had the chance to implement, as well as our plans for additions in the future:
Expand Down
96 changes: 0 additions & 96 deletions app.plugin.ts

This file was deleted.

2 changes: 1 addition & 1 deletion cli/parse-arguments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseBadgeJsonConfigFile } from './parse-badge-json-config-file';
import { IconConfig } from './icon-config';
import { addBadge } from '..';
import { addBadge } from '../src/index';
import { Badge } from '../types';
import { Command, Option } from 'commander';

Expand Down
2 changes: 1 addition & 1 deletion cli/parse-badge-json-config-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Params } from '../types';
import { validateConfig } from './config-validation';
import path from 'path';
import chalk from 'chalk';
import { addBadge } from '../index';
import { addBadge } from '../src/index';

export function parseBadgeJsonConfigFile(filePath: string) {
const resolvedPath = path.resolve(filePath);
Expand Down
25 changes: 1 addition & 24 deletions cli/types.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
export type Banner = {
type: 'banner';
text: string;
position?: 'top' | 'bottom';
color?: 'white' | 'black';
background?: string;
};

export type Ribbon = {
type: 'ribbon';
text: string;
position?: 'left' | 'right';
color?: 'white' | 'black';
background?: string;
};

export type Badge = Banner | Ribbon;

export type Params = {
icon: string;
dstPath?: string;
badges: Array<Badge>;
isAdaptiveIcon?: boolean;
};
export * from '../types';
16 changes: 16 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules/
.expo/
dist/
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/
ios/
android/

# macOS
.DS_Store
1 change: 1 addition & 0 deletions demo/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
Loading