diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..7f6ab79 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,30 @@ +name: Node.js CI + +on: + - push + - workflow_dispatch + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js dependencies + uses: bahmutov/npm-install@v1 + + - name: Build + run: npm run build + + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js dependencies + uses: bahmutov/npm-install@v1 + + - name: Lint + run: npm run lint diff --git a/.github/workflows/bump-library.yml b/.github/workflows/bump-library.yml new file mode 100644 index 0000000..0b72e47 --- /dev/null +++ b/.github/workflows/bump-library.yml @@ -0,0 +1,40 @@ +on: [issue_comment] + +jobs: + bump-library: + name: Bump libary version + if: github.event.comment.body == '/bump major' || github.event.comment.body == '/bump minor' || github.event.comment.body == '/bump patch' + + runs-on: ubuntu-latest + + steps: + - name: "Check if user has write access" + uses: "lannonbr/repo-permission-check-action@2.0.0" + with: + permission: "write" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: React to comment + uses: dkershner6/reaction-action@v1 # https://github.com/marketplace/actions/comment-reaction + with: + token: ${{ secrets.GITHUB_TOKEN }} + reaction: "hooray" # +1 | -1 | laugh | confused | heart | hooray | rocket | eyes + + - name: Bump major version + if: github.event.comment.body == '/bump major' + uses: boyum/bump-h5p-version@latest + with: + type: major + + - name: Bump minor version + if: github.event.comment.body == '/bump minor' + uses: boyum/bump-h5p-version@latest + with: + type: minor + + - name: Bump patch boyum/bump-h5p-version + if: github.event.comment.body == '/bump patch' + uses: boyum/bump-h5p-version@latest + with: + type: patch diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8fa7d1a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: Pack and release content type + +on: [push, workflow_dispatch] + +jobs: + pack-and-release: + runs-on: ubuntu-latest + name: Pack and release + steps: + - uses: actions/checkout@v2 + - uses: boyum/pack-h5p-action@0.0.6 + id: release-h5p + - uses: "marvinpinto/action-automatic-releases@latest" # https://github.com/marvinpinto/actions/tree/master/packages/automatic-releases + if: ${{ github.ref == 'refs/heads/main' }} + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{steps.release-h5p.outputs.version}} + prerelease: false + files: | + ${{steps.release-h5p.outputs.filePath}} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3162fd9 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +h5p-editor-uuid.js +h5p-editor-uuid.js.map diff --git a/h5p-editor-uuid.ts b/h5p-editor-uuid.ts index 3dda34b..b3484e2 100644 --- a/h5p-editor-uuid.ts +++ b/h5p-editor-uuid.ts @@ -9,7 +9,7 @@ class UUIDWidget extends H5PWidget implements IH5PWidget { const isTextField = field.type === "text"; if (!isTextField) { console.warn( - `The field \`${field.name}\` has the widget \`uuid\` set, but is of type \`${field.type}\`, not \`text\`` + `The field \`${field.name}\` has the widget \`uuid\` set, but is of type \`${field.type}\`, not \`text\``, ); } diff --git a/package-lock.json b/package-lock.json index 87bbc1e..e20b7a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,8 @@ "devDependencies": { "@tsconfig/strictest": "^1.0.0", "h5p-types": "github:boyum/h5p-types", + "prettier": "^2.6.2", + "prettier-config": "github:boyum/prettier-config", "vite": "^2.8.6" } }, @@ -498,6 +500,27 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/prettier": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz", + "integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-config": { + "version": "1.0.0", + "resolved": "git+ssh://git@github.com/boyum/prettier-config.git#e683c91977387f092b69a4e7069a8bf5afacaf62", + "dev": true, + "license": "ISC" + }, "node_modules/resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -851,6 +874,17 @@ "source-map-js": "^1.0.2" } }, + "prettier": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz", + "integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==", + "dev": true + }, + "prettier-config": { + "version": "git+ssh://git@github.com/boyum/prettier-config.git#e683c91977387f092b69a4e7069a8bf5afacaf62", + "dev": true, + "from": "prettier-config@github:boyum/prettier-config" + }, "resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", diff --git a/package.json b/package.json index aa8da3b..1aa6b49 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "h5p-editor-uuid.js", "scripts": { "start": "vite build --mode=development --watch --minify=false", - "build": "tsc --noEmit && vite build" + "build": "tsc --noEmit && vite build", + "lint": "prettier .", + "lint:fix": "prettier . --write" }, "repository": { "type": "git", @@ -21,9 +23,12 @@ "devDependencies": { "@tsconfig/strictest": "^1.0.0", "h5p-types": "github:boyum/h5p-types", + "prettier": "^2.6.2", + "prettier-config": "github:boyum/prettier-config", "vite": "^2.8.6" }, "dependencies": { "h5p-utils": "github:boyum/h5p-utils" - } + }, + "prettier": "prettier-config" } diff --git a/vite.config.ts b/vite.config.ts index 865cf7b..53bf101 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,7 +2,7 @@ import type { OutputAsset, OutputChunk } from "rollup"; import { defineConfig, PluginOption } from "vite"; const isOutputChunk = ( - chunkOrAsset: OutputChunk | OutputAsset + chunkOrAsset: OutputChunk | OutputAsset, ): chunkOrAsset is OutputChunk => { return chunkOrAsset["code"] != null; };