Skip to content

Commit

Permalink
feat: metadata and metadataCallback settings (#915)
Browse files Browse the repository at this point in the history
* chore: update ci workflows

* feat: add `metadata` and `metadataCallback` settings

* chore: sync package lock

* chore: format codestyle

* chore: add warnings when wrong types are passed

* chore: format codestyle

* refactor: metadata request object assign

* refactor: custom metadata iterator

* refactor: metadata iteration
  • Loading branch information
nd0ut committed Jul 25, 2022
1 parent 3710413 commit c7e1dc4
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 331 deletions.
46 changes: 5 additions & 41 deletions .github/workflows/shipjs-manual-prepare.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
name: Ship js Manual Prepare
on:
issue_comment:
types: [created]
on: workflow_dispatch
jobs:
manual_prepare:
if: |
github.event_name == 'issue_comment' &&
(github.event.comment.author_association == 'member' || github.event.comment.author_association == 'owner') &&
startsWith(github.event.comment.body, '@shipjs prepare')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm ci
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -22,36 +19,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}

create_done_comment:
if: success()
needs: manual_prepare
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "@${{ github.actor }} `shipjs prepare` done"
})
create_fail_comment:
if: cancelled() || failure()
needs: manual_prepare
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "@${{ github.actor }} `shipjs prepare` fail"
})
22 changes: 0 additions & 22 deletions .github/workflows/shipjs-schedule-prepare.yml

This file was deleted.

18 changes: 11 additions & 7 deletions .github/workflows/shipjs-trigger.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Ship js trigger
on:
push:
branches:
- master
pull_request:
types:
- closed
jobs:
build:
name: Build
name: Release
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v')
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v2
with:
registry-url: "https://registry.npmjs.org"
- run: git switch master
node-version: '16'
- run: npm ci
- run: npm run release:trigger
env:
Expand Down
1 change: 1 addition & 0 deletions dummy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
<li><a href="/live.html">live</a></li>
<li><a href="/nft.html">nft</a></li>
<li><a href="/logout.html">logout</a></li>
<li><a href="/metadata.html">metadata</a></li>
</ul>
33 changes: 33 additions & 0 deletions dummy/metadata.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<meta charset="UTF-8" />
<meta content="width=device-width,initial-scale=1" name="viewport"/>
<script>
UPLOADCARE_PUBLIC_KEY = 'demopublickey'
UPLOADCARE_DEBUG_UPLOADS = true
UPLOADCARE_METADATA = {
globalObject: 'value'
}
UPLOADCARE_METADATA_CALLBACK = () => ({
globalCallback: 'value'
})
</script>
<script src="./uploadcare.full.js"></script>

<p>
Widget:
<input type="hidden" role="uploadcare-uploader" />
</p>

<button>open dialog</button>

<script>
const btn = document.querySelectorAll('button')

btn[0].addEventListener('click', () => {
uploadcare.openDialog(null, {
metadata: {dialogObject: 'value'},
metadataCallback: () => ({dialogCallback: 'value'})
}).done(function(file) {
console.log(file)
})
})
</script>

0 comments on commit c7e1dc4

Please sign in to comment.