Skip to content

Commit

Permalink
Plugin init
Browse files Browse the repository at this point in the history
  • Loading branch information
franmastromarino committed Jul 5, 2023
1 parent 8d2053e commit bc7e486
Show file tree
Hide file tree
Showing 37 changed files with 802 additions and 1,179 deletions.
20 changes: 13 additions & 7 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
node_modules
jetpack_vendor
vendor
build
test
bin
.plugin
/node_modules
/vendor
/assets
/tests
/jetpack_vendor
/build
/artifacts
/test-results
/playwright-report
/playwright
/.plugin
**/test/**
playwright.config.js
26 changes: 26 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"env": {
"browser": true,
"es2021": true
},
"settings": {
"react": {
"version": "17.0.2"
}
},
"extends": ["plugin:@wordpress/eslint-plugin/recommended"],
"rules": {
"react/prop-types": "off",
"jsdoc/check-tag-names": "off",
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-noninteractive-element-interactions": "off",
"jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/anchor-has-content": "off",
"jsx-a11y/anchor-is-valid": "off",
"import/no-unresolved": "off",
"@wordpress/i18n-translator-comments": "off",
"no-nested-ternary": "off"
}
}
14 changes: 0 additions & 14 deletions .eslintrc.json

This file was deleted.

112 changes: 56 additions & 56 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,68 @@
# https://github.com/marketplace/actions/wordpress-plugin-svn-deploy

on:
push:
tags:
- "v*"
pull_request:
tags:
- "v*"
push:
tags:
- 'v*'
pull_request:
tags:
- 'v*'
jobs:
cache-and-install:
runs-on: ubuntu-latest
cache-and-install:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: |
pnpm install --force
pnpm run build
- name: Install dependencies
run: |
pnpm run setup
pnpm run build
- name: Validate directories
run: |
if [ ! -d "build" ]; then
echo "Build directory does not exist."
exit 1
fi
- name: Validate directories
run: |
if [ ! -d "build" ]; then
echo "Build directory does not exist."
exit 1
fi
- name: Validate directories
run: |
if [ ! -d "vendor" ]; then
echo "Vendor directory does not exist."
exit 1
fi
- name: WordPress Plugin Deploy
uses: nk-o/action-wordpress-plugin-deploy@master
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: perfect-woocommerce-brands
- name: Validate directories
run: |
if [ ! -d "vendor" ]; then
echo "Vendor directory does not exist."
exit 1
fi
- name: WordPress Plugin Deploy
uses: nk-o/action-wordpress-plugin-deploy@master
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: perfect-woocommerce-brands
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# git add -A

case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
npx.cmd lint-staged # bug on Windows/Github Desktop: add `.cmd` extension fixes it
;;
*)
npx lint-staged
;;
esac
24 changes: 24 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Install browsers for PlayWright tests
#npx playwright install
# Execute tests
#npm run test
#./vendor/bin/phpunit phpunit

# # Check if the push includes a tag
# while read local_ref local_sha remote_ref remote_sha; do
# if [[ $remote_ref == refs/tags/* ]]; then
# # This is a tag push, perform necessary actions
# folder="build"
# if [ ! -d "$folder" ]; then
# echo "Error: $folder folder does not exist"
# exit 1
# fi
# # Add the compiled code
# git add build/ -f
# # Amend the tag to include the latest commit
# git tag -f --allow-empty -a "${remote_ref#refs/tags/}" -m "Release: ${remote_ref#refs/tags/}" ${remote_sha}
# fi
# done
19 changes: 0 additions & 19 deletions .ideas/todo.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .lintstagedrc

This file was deleted.

21 changes: 13 additions & 8 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Ignore artifacts:
node_modules
jetpack_vendor
vendor
build
test
bin
.plugin
/node_modules
/vendor
/assets
/tests
/jetpack_vendor
/build
/artifacts
/test-results
/playwright-report
/playwright
/.plugin
**/test/**
playwright.config.js
17 changes: 17 additions & 0 deletions .tools/bin/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const {
copyFileFromTo,
consoleSuccess,
consoleError,
} = require('./helpers/functions');

//Get arguments
const myArgs = process.argv.slice(2);

//Foreach arguments/folders
try {
copyFileFromTo(myArgs[0], myArgs[1]);
consoleSuccess('File copied successfully');
} catch (e) {
consoleError('Can not copy the file, internationalization not found.');
}
5 changes: 2 additions & 3 deletions bin/delete.js → .tools/bin/delete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const { consoleSuccess } = require('./helpers');
const { consoleSuccess } = require('./helpers/console');

//Get arguments
const myArgs = process.argv.slice(2);
Expand All @@ -8,7 +8,6 @@ const myArgs = process.argv.slice(2);
myArgs.forEach((element) => {
//Delete folder/file
fs.rm(element, { recursive: true }, (err) => {
err ?? consoleSuccess(`${element} deleted`)
err ?? consoleSuccess(`${element} deleted`);
});
});

24 changes: 24 additions & 0 deletions .tools/bin/deleteZip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// deleteZip.js
const fs = require('fs');
const path = require('path');

const { pluginName } = require('./helpers/functions');

// Get the base directory of the project
const baseDir = process.cwd();

// Define the zip file
const zipFile = path.join(baseDir, `${pluginName}.zip`);

// Check if the zip file exists

if (fs.existsSync(zipFile)) {
// Delete the zip file
fs.unlink(zipFile, (error) => {
if (error) {
console.error(`Failed to delete ${zipFile}:`, error);
} else {
console.log(`${zipFile} has been deleted.`);
}
});
}
15 changes: 15 additions & 0 deletions .tools/bin/helpers/console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const consoleSuccess = (message) => {
console.log('\x1b[32m%s\x1b[0m', message);
};

const consoleError = (message) => {
console.log('\x1B[31m', message);
};

const consoleInfo = (message) => {
console.log('\x1b[36m%s\x1b[0m', message);
};

module.exports.consoleSuccess = consoleSuccess;
module.exports.consoleError = consoleError;
module.exports.consoleInfo = consoleInfo;
Loading

0 comments on commit bc7e486

Please sign in to comment.