Skip to content

Commit

Permalink
Merge branch 'main' into CI-improve
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Feb 23, 2024
2 parents ca6614f + 23a9b9a commit 64235d2
Show file tree
Hide file tree
Showing 54 changed files with 3,116 additions and 1,580 deletions.
180 changes: 93 additions & 87 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,93 @@
# name: Publish package to npmjs

# # This workflow runs when code is pushed to `main` (i.e: when a pull request is merged)
# on:
# push:
# branches: [main]

# # Ensure that only once instance of this workflow executes at a time.
# # If multiple PRs are merged in quick succession, there will only ever be one publish workflow running and one pending.
# concurrency: ${{ github.workflow }}

# jobs:
# version:
# runs-on: ubuntu-latest

# # OSBotify will update the version on `main`, so this check is important to prevent an infinite loop
# if: ${{ github.actor != 'OSBotify' }}

# steps:
# - uses: actions/checkout@v3
# with:
# ref: main

# - name: Decrypt & Import OSBotify GPG key
# run: |
# cd .github
# gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output OSBotify-private-key.asc OSBotify-private-key.asc.gpg
# gpg --import OSBotify-private-key.asc
# env:
# LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

# - name: Set up git for OSBotify
# run: |
# git config --global user.signingkey 367811D53E34168C
# git config --global commit.gpgsign true
# git config --global user.name OSBotify
# git config --global user.email [email protected]

# - uses: actions/setup-node@v3
# with:
# node-version: '16.x'
# registry-url: 'https://registry.npmjs.org'

# - name: Generate branch name
# run: echo "BRANCH_NAME=OSBotify-bump-version-$(uuidgen)" >> $GITHUB_ENV

# - name: Create branch for version-bump pull request
# run: git checkout -b ${{ env.BRANCH_NAME }}

# - name: Install npm packages
# run: npm ci

# - name: Update npm version
# run: npm version patch

# - name: Set new version in GitHub ENV
# run: echo "NEW_VERSION=$(jq '.version' package.json)" >> $GITHUB_ENV

# - name: Push branch and publish tags
# run: git push --set-upstream origin ${{ env.BRANCH_NAME }} && git push --tags

# - name: Create pull request
# run: |
# gh pr create \
# --title "Update version to ${{ env.NEW_VERSION }}" \
# --body "Update version to ${{ env.NEW_VERSION }}"
# sleep 5
# env:
# GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

# - name: Auto-approve pull request
# run: gh pr review --approve ${{ env.BRANCH_NAME }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Auto-merge pull request
# run: gh pr merge --merge --delete-branch ${{ env.BRANCH_NAME }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Build package
# run: npm run build

# - name: Publish to npm
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
name: Publish package to npmjs

# This workflow runs when code is pushed to `main` (i.e: when a pull request is merged)
on:
push:
branches: [main]

# Ensure that only once instance of this workflow executes at a time.
# If multiple PRs are merged in quick succession, there will only ever be one publish workflow running and one pending.
concurrency: ${{ github.workflow }}

jobs:
version:
runs-on: ubuntu-latest

# OSBotify will update the version on `main`, so this check is important to prevent an infinite loop
if: ${{ github.actor != 'OSBotify' }}

steps:
- uses: actions/checkout@v3
with:
ref: main

- name: Decrypt & Import OSBotify GPG key
run: |
cd .github
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output OSBotify-private-key.asc OSBotify-private-key.asc.gpg
gpg --import OSBotify-private-key.asc
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Set up git for OSBotify
run: |
git config --global user.signingkey 367811D53E34168C
git config --global commit.gpgsign true
git config --global user.name OSBotify
git config --global user.email [email protected]
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Generate branch name
run: echo "BRANCH_NAME=OSBotify-bump-version-$(uuidgen)" >> $GITHUB_ENV

- name: Create branch for version-bump pull request
run: git checkout -b ${{ env.BRANCH_NAME }}

- name: Install yarn packages
run: yarn install --immutable

- name: Update npm version
run: yarn version patch

- name: Set new version in GitHub ENV
run: echo "NEW_VERSION=$(jq '.version' package.json)" >> $GITHUB_ENV

- name: Commit version bump
run: git commit -am "Bump version to ${{ env.NEW_VERSION }}"

- name: Tag version bump
run: git tag ${{ env.NEW_VERSION }}

- name: Push branch and publish tags
run: git push --set-upstream origin ${{ env.BRANCH_NAME }} && git push --tags

- name: Create pull request
run: |
gh pr create \
--title "Update version to ${{ env.NEW_VERSION }}" \
--body "Update version to ${{ env.NEW_VERSION }}"
sleep 5
env:
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}

- name: Auto-approve pull request
run: gh pr review --approve ${{ env.BRANCH_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-merge pull request
run: gh pr merge --squash --delete-branch ${{ env.BRANCH_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build package
run: yarn pack

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
550 changes: 550 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
nodeLinker: node-modules
nmHoistingLimits: workspaces

nodeLinker: node-modules

plugins:
- path: scripts/pod-install.cjs
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-3.6.1.cjs
20 changes: 20 additions & 0 deletions CLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Expensify Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by Expensify Inc or its affiliates (“Expensify”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to Expensify in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact [email protected].

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your rights, title and interest in and to your Contributions.

**Copyright License.** You hereby grant, and agree to grant, to Expensify a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contributions and such derivative works, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.

**Patent License.** You hereby grant, and agree to grant, to Expensify a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your Contributions, where such license applies only to those patent claims licensable by you that are necessarily infringed by your Contributions alone or by combination of your Contributions with the Project to which such Contributions were submitted, with the right to sublicense the foregoing rights through multiple tiers of sublicensees.

**Moral Rights.** To the fullest extent permitted under applicable law, you hereby waive, and agree not to assert, all of your “moral rights” in or relating to your Contributions for the benefit of Expensify, its assigns, and their respective direct and indirect sublicensees.

**Third Party Content/Rights.** If your Contribution includes or is based on any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that were not authored by you (“Third Party Content”) or if you are aware of any third party intellectual property or proprietary rights associated with your Contribution (“Third Party Rights”), then you agree to include with the submission of your Contribution full details respecting such Third Party Content and Third Party Rights, including, without limitation, identification of which aspects of your Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights do not apply to any portion of a Project that is incorporated into your Contribution to that same Project.

**Representations.** You represent that, other than the Third Party Content and Third Party Rights identified by you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were created in the course of your employment with your past or present employer(s), you represent that such employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer(s) has waived all of their right, title or interest in or to your Contributions.

**No Obligation.** You acknowledge that Expensify is under no obligation to use or incorporate your Contributions into any of the Projects. The decision to use or incorporate your Contributions into any of the Projects will be made at the sole discretion of Expensify or its authorized delegates.

**Assignment.** You agree that Expensify may assign this Agreement, and all of its rights, obligations and licenses hereunder.

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @expensify/react-native-live-markdown
<img src="./assets/hero-animation.gif" alt="@expensify/react-native-live-markdown" />

## Features

Expand Down Expand Up @@ -84,9 +84,11 @@ const markdownStyle: MarkdownStyle = {
backgroundColor: 'lightgray',
},
mentionHere: {
backgroundColor: 'yellow',
color: 'green',
backgroundColor: 'lime',
},
mentionUser: {
color: 'blue',
backgroundColor: 'cyan',
},
};
Expand All @@ -112,7 +114,7 @@ Currently, `react-native-live-markdown` supports only [ExpensiMark](https://gith

## API reference

`MarkdownTextInput` inherits all props of React Native's `TextInput` component.
`MarkdownTextInput` inherits all props of React Native's `TextInput` component as well as introduces the following properties:

| Prop | Type | Default | Note |
| --------------- | --------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -125,3 +127,13 @@ Currently, `react-native-live-markdown` supports only [ExpensiMark](https://gith
## License

MIT

---

<p align="center">
<picture>
<source media="(prefers-color-scheme: light)" srcset="./assets/signature-light.png" />
<source media="(prefers-color-scheme: dark)" srcset="./assets/signature-dark.png" />
<img alt="Brought to you by Software Mansion + Expensify" src="./assets/signature-light.png" width="600" />
</picture>
</p>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = "react-native-live-markdown"
s.name = "RNLiveMarkdown"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ public class MarkdownBlockquoteSpan implements MarkdownSpan, LeadingMarginSpan {
private final float borderWidth;
private final float marginLeft;
private final float paddingLeft;
private final int nestingLevel;

public MarkdownBlockquoteSpan(@ColorInt int borderColor, float borderWidth, float marginLeft, float paddingLeft) {
public MarkdownBlockquoteSpan(@ColorInt int borderColor, float borderWidth, float marginLeft, float paddingLeft, int nestingLevel) {
this.borderColor = borderColor;
this.borderWidth = PixelUtil.toPixelFromDIP(borderWidth);
this.marginLeft = PixelUtil.toPixelFromDIP(marginLeft);
this.paddingLeft = PixelUtil.toPixelFromDIP(paddingLeft);
this.nestingLevel = nestingLevel;
}

@Override
public int getLeadingMargin(boolean first) {
return (int) (marginLeft + borderWidth + paddingLeft);
return (int) (marginLeft + borderWidth + paddingLeft) * nestingLevel;
}

@Override
Expand All @@ -37,9 +39,12 @@ public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int ba
p.setStyle(Paint.Style.FILL);
p.setColor(borderColor);

float left = x + dir * marginLeft;
float right = x + dir * (marginLeft + borderWidth);
c.drawRect(left, top, right, bottom, p);
for (int level = 0; level < nestingLevel; level++) {
float shift = (marginLeft + borderWidth + paddingLeft) * level;
float left = x + dir * (marginLeft + shift);
float right = x + dir * (marginLeft + borderWidth + shift);
c.drawRect(left, top, right, bottom, p);
}

p.setStyle(originalStyle);
p.setColor(originalColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ public class MarkdownStyle {
@ColorInt
private final int mPreBackgroundColor;

@ColorInt
private final int mMentionHereColor;

@ColorInt
private final int mMentionHereBackgroundColor;

@ColorInt
private final int mMentionUserColor;

@ColorInt
private final int mMentionUserBackgroundColor;

Expand All @@ -66,7 +72,9 @@ public MarkdownStyle(@NonNull ReadableMap map, @NonNull Context context) {
mPreFontFamily = parseString(map, "pre", "fontFamily");
mPreColor = parseColor(map, "pre", "color", context);
mPreBackgroundColor = parseColor(map, "pre", "backgroundColor", context);
mMentionHereColor = parseColor(map, "mentionHere", "color", context);
mMentionHereBackgroundColor = parseColor(map, "mentionHere", "backgroundColor", context);
mMentionUserColor = parseColor(map, "mentionUser", "color", context);
mMentionUserBackgroundColor = parseColor(map, "mentionUser", "backgroundColor", context);
}

Expand Down Expand Up @@ -156,11 +164,21 @@ public int getPreBackgroundColor() {
return mPreBackgroundColor;
}

@ColorInt
public int getMentionHereColor() {
return mMentionHereColor;
}

@ColorInt
public int getMentionHereBackgroundColor() {
return mMentionHereBackgroundColor;
}

@ColorInt
public int getMentionUserColor() {
return mMentionUserColor;
}

@ColorInt
public int getMentionUserBackgroundColor() {
return mMentionUserBackgroundColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ protected void onDetachedFromWindow() {
mReactEditText = null;
mTextWatcher = null;
mMarkdownUtils = null;
mMarkdownStyle = null;
}
}

Expand Down
Loading

0 comments on commit 64235d2

Please sign in to comment.