Skip to content

Commit e192cff

Browse files
committed
Initial commit
0 parents  commit e192cff

23 files changed

+11344
-0
lines changed

Diff for: .eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
lib/
3+
node_modules/
4+
jest.config.js

Diff for: .eslintrc.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"plugins": ["jest", "@typescript-eslint"],
3+
"extends": [
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
6+
],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"ecmaVersion": "latest",
10+
"sourceType": "module",
11+
"project": ["./tsconfig.json", "./tsconfig.eslint.json"]
12+
},
13+
"rules": {
14+
"prettier/prettier": [
15+
"error",
16+
{
17+
"endOfLine": "auto"
18+
}
19+
]
20+
},
21+
"env": {
22+
"node": true,
23+
"es6": true,
24+
"jest/globals": true
25+
}
26+
}

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** -diff linguist-generated=true

Diff for: .github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: daily

Diff for: .github/workflows/check-dist.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# `dist/index.js` is a special file in Actions.
2+
# When you reference an action with `uses:` in a workflow,
3+
# `index.js` is the code that will run.
4+
# For our project, we generate this file through a build process from other source files.
5+
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
6+
name: Check dist/
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '**.md'
14+
pull_request:
15+
paths-ignore:
16+
- '**.md'
17+
workflow_dispatch:
18+
19+
jobs:
20+
check-dist:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Set Node.js 16.x
27+
uses: actions/setup-node@v2
28+
with:
29+
node-version: 16.x
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Rebuild the dist/ directory
35+
run: |
36+
npm run build
37+
npm run package
38+
39+
- name: Compare the expected and actual dist/ directories
40+
run: |
41+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
42+
echo "Detected uncommitted changes after build. See status below:"
43+
git diff
44+
exit 1
45+
fi
46+
id: diff
47+
48+
# If index.js was different than expected, upload the expected version as an artifact
49+
- uses: actions/upload-artifact@v2
50+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
51+
with:
52+
name: dist
53+
path: dist/

Diff for: .github/workflows/test.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'build-test'
2+
on: # rebuild any PRs and main branch changes
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
- 'releases/*'
8+
9+
jobs:
10+
build: # make sure build/ci work properly
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- run: |
15+
npm install
16+
- run: |
17+
npm run all
18+
test: # make sure the action works on a clean machine without building
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: ./
23+
with:
24+
milliseconds: 1000

Diff for: .gitignore

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*

Diff for: .prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

Diff for: .prettierrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": false,
7+
"trailingComma": "none",
8+
"bracketSpacing": true,
9+
"bracketSameLine": true
10+
}

Diff for: CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @actions/actions-runtime

Diff for: LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018 GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

Diff for: README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<p align="center">
2+
<a href="https://github.com/plasmo-corp/bpp/actions"><img alt="typescript-action status" src="https://github.com/plasmo-corp/bpp/workflows/build-test/badge.svg"></a>
3+
</p>
4+
5+
# Browser Plugin Publisher
6+
7+
Use this action to publish your browser plugin to any browser plugin marketplace.
8+
9+
## Usage
10+
11+
```yaml
12+
steps:
13+
- uses: plasmo-corp/bpp@v1
14+
with:
15+
zip: build/artifact.zip
16+
client-id: ${{ secrets.CHROME_CLIENT_ID }}
17+
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
18+
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
19+
```

Diff for: __tests__/main.test.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, test } from "@jest/globals"
2+
import * as cp from "child_process"
3+
import * as path from "path"
4+
import * as process from "process"
5+
import { wait } from "../src/wait"
6+
7+
test("throws invalid number", async () => {
8+
const input = parseInt("foo", 10)
9+
await expect(wait(input)).rejects.toThrow("milliseconds not a number")
10+
})
11+
12+
test("wait 500 ms", async () => {
13+
const start = new Date()
14+
await wait(500)
15+
const end = new Date()
16+
const delta = Math.abs(end.getTime() - start.getTime())
17+
expect(delta).toBeGreaterThan(450)
18+
})
19+
20+
// shows how the runner will run a javascript action with env / stdout protocol
21+
test("test runs", () => {
22+
process.env["INPUT_MILLISECONDS"] = "500"
23+
const np = process.execPath
24+
const ip = path.join(__dirname, "..", "lib", "main.js")
25+
const options: cp.ExecFileSyncOptions = {
26+
env: process.env
27+
}
28+
console.log(cp.execFileSync(np, [ip], options).toString())
29+
})

Diff for: action.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: 'Browser Plugin Publisher'
2+
description: 'Publish your browser plugin anywhere using a single action.'
3+
author: 'Plasmo Corp.'
4+
inputs:
5+
milliseconds: # change this
6+
required: true
7+
description: 'input description here'
8+
default: 'default value if applicable'
9+
runs:
10+
using: 'node16'
11+
main: 'dist/index.js'

0 commit comments

Comments
 (0)