Skip to content

Commit

Permalink
add build action and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Jan 8, 2024
1 parent daf61f3 commit 708d21e
Show file tree
Hide file tree
Showing 12 changed files with 315 additions and 2,244 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Setup
description: Setup Node.js and install dependencies

runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: npm
cache-dependency-path: '**/package.json'

- name: Install dependencies
run: |
npm ci
shell: bash
51 changes: 0 additions & 51 deletions .github/workflows/onBuild.yaml

This file was deleted.

125 changes: 125 additions & 0 deletions .github/workflows/onPullRequestMerged.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Pull Request Merge Workflow
on:
pull_request:
branches:
- master
types: [ closed ]
env:
CI: true
jobs:
lint:
if: "!contains(join(github.event.pull_request.labels.*.name, ','), 'Release') && github.event.pull_request.merged == true"
name: 'Lint and Typecheck'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: yarn lint

- name: Typecheck files
run: yarn typecheck

- name: Check licenses
id: check_licenses
run: |
npm install -g license-checker
license-checker --failOn "AGPL-1.0-only;AGPL-1.0-or-later;AGPL-3.0-only;AGPL-3.0-or-later;GPL-1.0-only;GPL-1.0-or-later;GPL-2.0-only;GPL-2.0-or-later;GPL-3.0-only;GPL-3.0-or-later;LGPL-2.0-only;LGPL-2.0-or-later;LGPL-2.1-only;LGPL-2.1-or-later;LGPL-3.0-only;LGPL-3.0-or-later;LGPLLR;MPL-1.1"
createReleasePullRequest:
if: "!contains(join(github.event.pull_request.labels.*.name, ','), 'Release') && github.event.pull_request.merged == true"
name: 'Create Release Pull Request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Git Identity
run: |
git config --global user.name 'frontegg'
git config --global user.email '[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate with Registry
run: |
yarn logout
echo "init-author-name=Frontegg LTD" > .npmrc
echo "[email protected]" >> .npmrc
echo "init-author-url=https://frontegg.com" >> .npmrc
echo "init-license=MIT" >> .npmrc
echo "always-auth=true" >> .npmrc
echo "registry=https://registry.npmjs.org" >> .npmrc
echo "_authToken=$NPM_TOKEN" >> .npmrc
echo "@frontegg:registry=https://registry.npmjs.org" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Commit Version UP
run: |
yarn version --patch --no-git-tag-version --no-commit-hooks
- name: Pack Package
run: |
yarn pack
- name: "Set incremented version"
uses: actions/github-script@v6
id: 'incremented-version'
with:
result-encoding: string
script: |
const {default: fs} = await import('fs');
const {version} = JSON.parse(fs.readFileSync('./package.json', {encoding: "utf-8"}));
return version;
- name: Commit changes
shell: bash -ex {0}
run: |
git add . && git commit -m "chore(release): publish ${{ steps.incremented-version.outputs.result }}"
- name: Create Release Pull Request
id: cpr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ secrets.GITHUB_WORKSPACE }}
commit-message: "Update v${{ steps.incremented-version.outputs.result }}"
committer: GitHub <[email protected]>
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
title: 'v${{ steps.incremented-version.outputs.result }}'
body: |
# v${{ steps.incremented-version.outputs.result }}
labels: "Type: Release"
branch: "release/next"

- name: Publish Pre-Release version to NPM
id: publish_pre_release_version
run: |
version=$(node -p 'require("./package.json").version')
echo "::set-output name=LIB_VERSION::${version}"
echo "Publishing DEV version - v${version}-alpha.${{ github.run_id }}"
yarn version --new-version "${version}-alpha.${{ github.run_id }}" --no-git-tag-version --no-commit-hooks
git add .
git commit -m "chore: prelrease version"
yarn pack
npm publish --tag next
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name : Notify Slack on alpha version deployment
uses : rtCamp/action-slack-notify@v2
env :
SLACK_CHANNEL : frontegg-alpha-versions
SLACK_COLOR : ${{ job.status }}
SLACK_ICON : https://avatars.githubusercontent.com/u/67857107?s=40&v=4
SLACK_MESSAGE : '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }} has been released :rocket:'
SLACK_TITLE : 'A new @frontegg/react alpha version!'
SLACK_USERNAME : ${{ github.actor }}
SLACK_WEBHOOK : ${{ secrets.ROTEM_SLACK_WEBHOOK }}
MSG_MINIMAL : true
34 changes: 34 additions & 0 deletions .github/workflows/onPush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Push Workflow
on:
# When commit pushed to branches not master nad release/next
push:
branches-ignore:
- 'master'
- 'release/next'
env:
CI: true
jobs:
lint:
name: 'Lint | Typecheck'
runs-on: macos-12
steps:
- name: Setup
uses: ./.github/actions/setup

- name: Lint files
run: npm run lint

- name: Check licenses
id: check_licenses
run: |
npm install -g license-checker
license-checker --failOn "AGPL-1.0-only;AGPL-1.0-or-later;AGPL-3.0-only;AGPL-3.0-or-later;GPL-1.0-only;GPL-1.0-or-later;GPL-2.0-only;GPL-2.0-or-later;GPL-3.0-only;GPL-3.0-or-later;LGPL-2.0-only;LGPL-2.0-or-later;LGPL-2.1-only;LGPL-2.1-or-later;LGPL-3.0-only;LGPL-3.0-or-later;LGPLLR;MPL-1.1"
build:
name: 'Install | Build'
runs-on: macos-12
steps:
- name: Setup
uses: ./.github/actions/setup
- name: Build Package
run: |
npm run build
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
build
dist

.*

example

android
ios
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
"verify:android": "cd android && ./gradlew clean build test && cd ..",
"verify:web": "npm run build",
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
"lint": "npm run eslint && npm run prettier -- --check",
"fmt": "npm run eslint -- --fix && npm run prettier -- --write",
"eslint": "eslint . --ext ts",
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"swiftlint": "node-swiftlint",
Expand Down
17 changes: 10 additions & 7 deletions scripts/postpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ const exec = require('child_process').execSync;
const rootDir = path.join(__dirname, '../');
fs.readdirSync(rootDir).forEach(file => {
if (file.startsWith('frontegg-ionic-capacitor-') && file.endsWith('.tgz')) {
console.log(file)
if(fs.existsSync(path.join(rootDir, 'frontegg-ionic-capacitor.tgz'))) {
console.log(file);
if (fs.existsSync(path.join(rootDir, 'frontegg-ionic-capacitor.tgz'))) {
fs.unlinkSync(path.join(rootDir, 'frontegg-ionic-capacitor.tgz'));
}
fs.renameSync(path.join(rootDir, file), path.join(rootDir, 'frontegg-ionic-capacitor.tgz'));
fs.renameSync(
path.join(rootDir, file),
path.join(rootDir, 'frontegg-ionic-capacitor.tgz'),
);
}
})
});



exec('cd example && npm install ../frontegg-ionic-capacitor.tgz', { stdio: 'inherit' });
exec('cd example && npm install ../frontegg-ionic-capacitor.tgz', {
stdio: 'inherit',
});
35 changes: 17 additions & 18 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { ITenantsResponse, IUserProfile } from '@frontegg/rest-api';

export type User = IUserProfile & {
tenants: ITenantsResponse[];
activeTenant: ITenantsResponse
}
activeTenant: ITenantsResponse;
};

export interface FronteggState {
accessToken: string | null;
Expand All @@ -15,23 +15,24 @@ export interface FronteggState {
selectedRegion: string | null;
}


export type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void
export type SubscribeFunc<T, K extends keyof T> = (value: T[K]) => void;
export type SubscribeMap<T> = {
[K in keyof T]: Set<SubscribeFunc<T, K>>
}

[K in keyof T]: Set<SubscribeFunc<T, K>>;
};

export interface FronteggConstants {
baseUrl: string;
clientId: string;
bundleId: string;
isRegional: boolean;
regionData?: { key: string, baseUrl: string, clientId: string }[]
regionData?: { key: string; baseUrl: string; clientId: string }[];
}

export interface FronteggNativePlugin {
addListener(eventName: string, listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle
addListener(
eventName: string,
listenerFunc: ListenerCallback,
): Promise<PluginListenerHandle> & PluginListenerHandle;

getConstants(): Promise<FronteggConstants>;

Expand All @@ -52,22 +53,18 @@ export interface FronteggNativePlugin {
initWithRegion(payload: { regionKey: string }): Promise<void>;

refreshToken(): Promise<void>;

}


export type RegionConfig = {
key: string;
baseUrl: string;
clientId: string;
};


type FronteggNativeStandardOptions = {
baseUrl: string;
clientId: string;

}
};
type FronteggNativeRegionOptions = {
/**
* This is an array of regions to be used as frontegg app.
Expand All @@ -76,9 +73,11 @@ type FronteggNativeRegionOptions = {
* @example [{key: "us", baseUrl: "https://us-api.frontegg.com", clientId: "us-client-id"}]
*/
regions: RegionConfig[];
}
type FronteggNativeOptions = (FronteggNativeStandardOptions | FronteggNativeRegionOptions) & {

};
type FronteggNativeOptions = (
| FronteggNativeStandardOptions
| FronteggNativeRegionOptions
) & {
/**
* Weather to handle login with social login in external browser.
* If set to false, the plugin will navigate to the social login page with application webview.
Expand All @@ -103,7 +102,7 @@ type FronteggNativeOptions = (FronteggNativeStandardOptions | FronteggNativeRegi
* @default true
*/
useAssetLinks?: boolean;
}
};
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
declare module '@capacitor/cli' {
Expand Down
Loading

0 comments on commit 708d21e

Please sign in to comment.