Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-matrixreq authored Jun 27, 2024
0 parents commit b0d7dc4
Show file tree
Hide file tree
Showing 41 changed files with 9,391 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Your local development path to the Matrix custom js folder
WEBPACK_DEVELOPMENT_MATRIX_PATH=/Users/{USERNAME}/Sites/matrix/matrix-docker/devstack/data/home/clouds/ROOT/custom/js
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react-hooks", "@tanstack/query", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:@tanstack/eslint-plugin-query/recommended",
"plugin:storybook/recommended",
"prettier",
],
ignorePatterns: ["*.js"],
rules: {
"prettier/prettier": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/ban-ts-comment": "off",
// "@typescript-eslint/no-unused-vars":"off",
// "no-unused-vars": ['warn', { 'argsIgnorePattern': '.*' }],
// allow that = this
"@typescript-eslint/no-this-alias": [
"error",
{
allowDestructuring: true,
// Allow `const { props, state } = this`; false by default
allowedNames: ["that"], // Allow `const that= this`; `[]` by default
},
],

// allow empty arrow functions, e.g. ml.UI.addDropdownToValue(something, "Select", options, "w1", weights, false, false, () => { });
"@typescript-eslint/no-empty-function": [
"error",
{
allow: ["arrowFunctions"],
},
],
"no-prototype-builtins": "off",
"no-self-assign": "off",
// allow stuff like window.location.href = window.location.href
"prefer-const": "off",
// allow let rather than enforcing const
"no-empty": "off",
// allow empty functions, i.e. () => {}
"@typescript-eslint/no-empty-interface": "off",
},
};
64 changes: 64 additions & 0 deletions .github/rename_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

#!/usr/bin/env bash
while getopts a:n:u:d:p: flag
do
case "${flag}" in
a) author=${OPTARG};;
n) name=${OPTARG};;
u) urlname=${OPTARG};;
d) description=${OPTARG};;
p) prefix=${OPTARG};;
esac
done

echo "Author: $author";
echo "Project Name: $name";
echo "Project URL name: $urlname";
echo "Description: $description";
echo "Prefix: $prefix";

#remove ui-plugin

pageName=$(sed -r 's/(ui-plugin-)(.*)/\2/g' <<< "$urlname")
cameCase=$(sed -r 's/(^|-)(\w)/\U\2/g' <<<"$pageName")

echo "$cameCase $namespace $prefix"
echo "Renaming project..."

original_author="MatrixRequirements"
original_name="matrix-ui-plugin-boilerplate-24"
original_description=" matrix-ui-plugin-boilerplate-24 created by someone"
original_pageid="BPP"



sed -i "s/$original_pageid/$prefix/g" "package.json"
sed -i "s/$original_pageid/$prefix/g" "webpack.config.js"


for filename in $(git ls-files)
do
echo "Processing $filename"
[[ $filename = .github* ]] && echo "Skipping $filename"
[[ $filename != .github* ]] && sed -i "s/$original_name/$name/g" "$filename"
[[ $filename != .github* ]] && sed -i "s/$original_author/$author/g" "$filename"
[[ $filename != .github* ]] && sed -i "s/$original_description/$description/g" "$filename"
[[ $filename != .github* ]] && sed -i "s/$original_pageid/$prefix/g" "$filename"
[[ $filename != .github* ]] && echo "$filename fixed"
done

cd src

git config --local user.email action@github.com
git config --local user.name GitHub Action
cd ..

git mv ./src/BPP ./src/$prefix

git rm .github/rename_project.sh
git rm .github/workflows/template.yaml

git commit -m "Rename template to project $cameCase" -a


# This command runs only once on GHA!
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install dependencies and check for correct matrix.json file
run: |
npm install
npm run check:metadata
- name: Extract id from matrix.json
uses: sergeysova/jq-action@v2
id: id
with:
cmd: 'jq ".id" resources/matrix.json -r'

- name: Extract version from matrix.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq ".version" resources/matrix.json -r'

- name: Extract name from package.json
uses: sergeysova/jq-action@v2
id: name
with:
cmd: 'jq ".name" resources/matrix.json -r'

- name: Patch build info into files
run: |
echo "Plugin info: ${{steps.id.outputs.value}} ${{steps.name.outputs.value}} ${{steps.version.outputs.value}}"
find src -type f -exec sed -i "s/<PLUGIN_NAME_PLACEHOLDER>/${{steps.name.outputs.value}}/g" {} +
find resources -type f -exec sed -i "s/<PLUGIN_NAME_PLACEHOLDER>/${{steps.name.outputs.value}}/g" {} +
find src -type f -exec sed -i "s/<PLUGIN_VERSION_PLACEHOLDER>/${{steps.version.outputs.value}}_${{github.run_number}}/g" {} +
find resources -type f -exec sed -i "s/<PLUGIN_VERSION_PLACEHOLDER>/${{steps.version.outputs.value}}_${{github.run_number}}/g" {} +
find src -type f -exec sed -i "s|<VERSION_INFO_PLACEHOLDER>|${{steps.name.outputs.value}} ${{steps.version.outputs.value}}_${{github.run_number}} from $GITHUB_REPOSITORY|g" {} +
find resources -type f -exec sed -i "s|<VERSION_INFO_PLACEHOLDER>|${{steps.name.outputs.value}} ${{steps.version.outputs.value}}_${{github.run_number}} from $GITHUB_REPOSITORY|g" {} +
- name: Build
run: |
npm run build
- name: Lint the code
run: |
npm run eslint
- name: Copy the build result
run: |
TARGETDIR="dist/js/${{steps.id.outputs.value}}"
mkdir -p $TARGETDIR
mv dist/*.js "$TARGETDIR/"
mv dist/*.js.map "$TARGETDIR/"
cp resources/matrix.json "$TARGETDIR/"
- uses: actions/upload-artifact@v2
with:
name: ${{steps.id.outputs.value}}-${{steps.version.outputs.value}}_${{github.run_number}}
path: |
dist
!dist/plugin.tsbuildinfo
38 changes: 38 additions & 0 deletions .github/workflows/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Rename from matrix-ui-plugin-boilerplate-24 to new project name

on:
workflow_dispatch:
inputs:
prefix:
description: 'Please specify a 3 letters prefix for your plugin '
required: true
type: string
jobs:
rename-project:
if: ${{ github.repository != 'MatrixRequirements/matrix-ui-plugin-boilerplate-24' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
ref: ${{ github.head_ref }}

- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
shell: bash

- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash

- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
shell: bash

- name: Rename the project
run: |
echo Renaming the project with -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -p ${{ inputs.prefix }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }}"
bash .github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n ${{ env.REPOSITORY_NAME }} -p ${{ inputs.prefix }} -u ${{ env.REPOSITORY_URLNAME }} -d "Awesome ${{ env.REPOSITORY_NAME }} created by ${{ env.REPOSITORY_OWNER }} "
- name: Push to master
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
node_modules
matrix-example.iml
build
.cache
.parcel-cache
.idea
Proxy.env
dev-proxy/chrome-profile
.DS_Store
.env
Loading

0 comments on commit b0d7dc4

Please sign in to comment.