diff --git a/__tests__/main.test.js b/__tests__/main.test.js
index 4e715ba..ec57db7 100644
--- a/__tests__/main.test.js
+++ b/__tests__/main.test.js
@@ -43,9 +43,9 @@ describe('action', () => {
expect(debugMock).toHaveBeenNthCalledWith(6, 'Using output path: encrypted')
// No errors
- expect(debugMock).toHaveBeenNthCalledWith(7, 0)
- expect(debugMock).toHaveBeenNthCalledWith(8, '')
- expect(debugMock).toHaveBeenNthCalledWith(9, '')
+ expect(debugMock).toHaveBeenNthCalledWith(18, 0)
+ expect(debugMock).toHaveBeenNthCalledWith(19, '')
+ expect(debugMock).toHaveBeenNthCalledWith(20, '')
expect(setOutputMock).toHaveBeenCalledWith(
'status',
diff --git a/action.yml b/action.yml
index 3931db4..2501207 100644
--- a/action.yml
+++ b/action.yml
@@ -3,6 +3,12 @@ description: 'Github action for integrate your project encode with ioncube into
author: 'MuriloChianfa'
inputs:
+ # Basic inputs
+ trial:
+ description: 'Encode file with trial version of ioncube'
+ required: true
+ default: false
+ type: boolean
template:
description: 'The template to choose the best parameters for type of projects'
required: true
@@ -11,23 +17,8 @@ inputs:
options:
- laravel
- php
- trial:
- description: 'Encode file with trial version of ioncube'
- required: true
- default: false
- type: boolean
-
- source:
- description: 'The source path or file to encode'
- required: true
- default: ''
- type: string
- output:
- description: 'The output path or file encoded'
- required: true
- default: 'encrypted'
- type: string
+ # Encoder inputs
encoder-version:
description: 'Ioncube encoder version'
required: true
@@ -37,7 +28,6 @@ inputs:
- current
- legacy
- obsolete
-
php-target-version:
description: 'PHP encoded files target version'
required: true
@@ -47,7 +37,6 @@ inputs:
- '8.2'
- '8.1'
- '8.0'
-
arch:
description: 'Architecture of target environment runner'
required: true
@@ -57,6 +46,92 @@ inputs:
- 86
- 64
+ # File inputs
+ source:
+ description: 'The source path or file to encode'
+ required: true
+ default: ''
+ type: string
+ output:
+ description: 'The output path or file encoded'
+ required: true
+ default: 'encrypted'
+ type: string
+
+ # Reflection API
+ allow-reflection:
+ description: 'Name or glob to funcions or classes for allow the reflection API'
+ required: true
+ default: ''
+ type: string
+ allow-reflection-all:
+ description: 'Allow the reflection API at all the PHP code'
+ required: true
+ default: false
+ type: boolean
+
+ # Files customization
+ encrypt:
+ description: 'Name or glob to files to encrypt'
+ required: true
+ default: ''
+ type: string
+ binary:
+ description: 'Encode files in binary format'
+ required: true
+ default: false
+ type: boolean
+ optimize:
+ description: 'Level of encoding performance'
+ required: true
+ default: 'max'
+ type: choice
+ options:
+ - 'more'
+ - 'max'
+
+ # Output customizations
+ no-doc-comments:
+ description: 'Not allow doc comments on encoded files'
+ required: true
+ default: true
+ type: boolean
+ without-loader-check:
+ description: 'Disable the ioncube loader installation verification'
+ required: true
+ default: true
+ type: boolean
+ preamble-file:
+ description: 'File for insert into header of all encoded files'
+ required: true
+ default: ''
+ type: string
+
+ # License options
+ passphrase:
+ description: 'Text to identify and encode the project unically'
+ required: true
+ default: ''
+ type: string
+ license-check:
+ description: 'Mode of license validation for encoded files'
+ required: true
+ default: 'auto'
+ type: choice
+ options:
+ - 'auto'
+ - 'script'
+ with-license:
+ description: 'The license file path at runtime environment'
+ required: true
+ default: ''
+ type: string
+ callback-file:
+ description: 'File to validate manually when license is invalid'
+ required: true
+ default: ''
+ type: string
+
outputs:
status:
description: 'The message of encode proccess'
diff --git a/badges/coverage.svg b/badges/coverage.svg
index f5d8348..331a352 100644
--- a/badges/coverage.svg
+++ b/badges/coverage.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/inputs/binary.js b/src/inputs/binary.js
new file mode 100644
index 0000000..e36e403
--- /dev/null
+++ b/src/inputs/binary.js
@@ -0,0 +1,15 @@
+const core = require('@actions/core')
+
+/**
+ * Validate binary input values.
+ * @returns {bool|string} Returns a validated binary input.
+ */
+module.exports = function validateBinary(standard = false) {
+ const binary = core.getInput('binary', { required: true }) ?? standard
+ core.debug(
+ binary === true
+ ? 'Encoding into binary format'
+ : 'Encoding into ASCII format'
+ )
+ return binary
+}
diff --git a/src/inputs/callback.js b/src/inputs/callback.js
new file mode 100644
index 0000000..c30a6b8
--- /dev/null
+++ b/src/inputs/callback.js
@@ -0,0 +1,16 @@
+const core = require('@actions/core')
+
+/**
+ * Validate callback input values.
+ * @returns {bool|string} Returns a validated callback input.
+ */
+module.exports = function validateCallback(standard = '') {
+ const callback =
+ core.getInput('callback-file', { required: true }) ?? standard
+ core.debug(
+ `Using callback file in runtime path: ${
+ callback === '' ? 'NONE' : callback
+ }`
+ )
+ return callback
+}
diff --git a/src/inputs/check.js b/src/inputs/check.js
new file mode 100644
index 0000000..981710a
--- /dev/null
+++ b/src/inputs/check.js
@@ -0,0 +1,18 @@
+const core = require('@actions/core')
+
+/**
+ * Validate check input values.
+ * @returns {bool|string} Returns a validated check input.
+ */
+module.exports = function validateCheck(standard = 'auto') {
+ let check = core.getInput('license-check', { required: true }) ?? standard
+
+ if (check === 'auto') {
+ check = 'auto'
+ } else {
+ check = 'script'
+ }
+
+ core.debug(`Using license check: ${check}`)
+ return check
+}
diff --git a/src/inputs/comments.js b/src/inputs/comments.js
new file mode 100644
index 0000000..b5e9e13
--- /dev/null
+++ b/src/inputs/comments.js
@@ -0,0 +1,15 @@
+const core = require('@actions/core')
+
+/**
+ * Validate comments input values.
+ * @returns {bool|string} Returns a validated comments input.
+ */
+module.exports = function validateComments(standard = true) {
+ const comments = !(
+ core.getInput('no-doc-comments', { required: true }) ?? standard
+ )
+ core.debug(
+ comments === true ? 'Allowing doc comments' : 'Now allow doc comments'
+ )
+ return comments
+}
diff --git a/src/inputs/encrypt.js b/src/inputs/encrypt.js
new file mode 100644
index 0000000..4e82ae0
--- /dev/null
+++ b/src/inputs/encrypt.js
@@ -0,0 +1,11 @@
+const core = require('@actions/core')
+
+/**
+ * Validate encrypt input values.
+ * @returns {bool|string} Returns a validated encrypt input.
+ */
+module.exports = function validateEncrypt(standard = '') {
+ const encrypt = core.getInput('encrypt', { required: true }) ?? standard
+ core.debug(`Encrypting files: ${encrypt === '' ? 'NONE' : encrypt}`)
+ return encrypt
+}
diff --git a/src/inputs/license.js b/src/inputs/license.js
new file mode 100644
index 0000000..3178b76
--- /dev/null
+++ b/src/inputs/license.js
@@ -0,0 +1,11 @@
+const core = require('@actions/core')
+
+/**
+ * Validate license input values.
+ * @returns {bool|string} Returns a validated license input.
+ */
+module.exports = function validateLicense(standard = '') {
+ const license = core.getInput('with-license', { required: true }) ?? standard
+ core.debug(`Using license file in runtime path: ${license}`)
+ return license
+}
diff --git a/src/inputs/loader.js b/src/inputs/loader.js
new file mode 100644
index 0000000..96e71c5
--- /dev/null
+++ b/src/inputs/loader.js
@@ -0,0 +1,17 @@
+const core = require('@actions/core')
+
+/**
+ * Validate loader input values.
+ * @returns {bool|string} Returns a validated loader input.
+ */
+module.exports = function validateLoader(standard = true) {
+ const loader = !(
+ core.getInput('without-loader-check', { required: true }) ?? standard
+ )
+ core.debug(
+ loader === true
+ ? 'Checking for loader in environment'
+ : 'Not checking for loader in environment'
+ )
+ return loader
+}
diff --git a/src/inputs/optimize.js b/src/inputs/optimize.js
new file mode 100644
index 0000000..e0c8952
--- /dev/null
+++ b/src/inputs/optimize.js
@@ -0,0 +1,18 @@
+const core = require('@actions/core')
+
+/**
+ * Validate optimize input values.
+ * @returns {bool|string} Returns a validated optimize input.
+ */
+module.exports = function validateOptimize(standard = 'max') {
+ let optimize = core.getInput('optimize', { required: true }) ?? standard
+
+ if (optimize === 'more') {
+ optimize = 'more'
+ } else {
+ optimize = 'max'
+ }
+
+ core.debug(`Using optimization: ${optimize}`)
+ return optimize
+}
diff --git a/src/inputs/passphrase.js b/src/inputs/passphrase.js
new file mode 100644
index 0000000..3eb459f
--- /dev/null
+++ b/src/inputs/passphrase.js
@@ -0,0 +1,11 @@
+const core = require('@actions/core')
+
+/**
+ * Validate passphrase input values.
+ * @returns {bool|string} Returns a validated passphrase input.
+ */
+module.exports = function validatePassphrase(standard = '') {
+ const passphrase = core.getInput('passphrase', { required: true }) ?? standard
+ core.debug(`Using passphrase: ${passphrase === '' ? 'NONE' : passphrase}`)
+ return passphrase
+}
diff --git a/src/inputs/preamble.js b/src/inputs/preamble.js
new file mode 100644
index 0000000..423292c
--- /dev/null
+++ b/src/inputs/preamble.js
@@ -0,0 +1,12 @@
+const core = require('@actions/core')
+
+/**
+ * Validate preamble input values.
+ * @returns {bool|string} Returns a validated preamble input.
+ */
+module.exports = function validatePreamble(standard = '') {
+ const preamble =
+ core.getInput('preamble-file', { required: true }) ?? standard
+ core.debug(`Adding preamble file: ${preamble === '' ? 'NONE' : preamble}`)
+ return preamble
+}
diff --git a/src/inputs/reflection.js b/src/inputs/reflection.js
new file mode 100644
index 0000000..cae75f9
--- /dev/null
+++ b/src/inputs/reflection.js
@@ -0,0 +1,21 @@
+const core = require('@actions/core')
+
+/**
+ * Validate reflection input values.
+ * @returns {bool|string} Returns a validated reflection input.
+ */
+module.exports = function validateReflection(standard = false) {
+ const reflectionAll =
+ core.getInput('allow-reflection-all', { required: true }) ?? standard
+
+ if (reflectionAll === true) {
+ core.debug('Allowing reflection for all')
+ return true
+ }
+
+ const reflection =
+ core.getInput('allow-reflection', { required: true }) ??
+ (standard === false ? '' : standard)
+ core.debug(`Using reflection for: ${reflection === '' ? 'NONE' : reflection}`)
+ return reflection
+}
diff --git a/src/templates/choose.js b/src/templates/choose.js
index a4ab5ed..97e50bb 100644
--- a/src/templates/choose.js
+++ b/src/templates/choose.js
@@ -8,13 +8,24 @@ const templates = {
* Choose correct template based on template input value.
* @returns {object} Returns defaults values based on templates.
*/
-module.exports = async function choose(template = 'laravel') {
+module.exports = function choose(template = 'laravel') {
const standard = {
encoderVersion: 'current',
phpTargetVersion: '8.2',
arch: 64,
input: '',
- output: 'encrypted'
+ output: 'encrypted',
+ reflection: false,
+ encrypt: '',
+ binary: false,
+ optimize: 'more',
+ comments: false,
+ loader: false,
+ preamble: '',
+ passphrase: '',
+ check: 'auto',
+ license: '',
+ callback: ''
}
const args = templates[template]?.()
diff --git a/src/templates/laravel.js b/src/templates/laravel.js
index df187b6..176428f 100644
--- a/src/templates/laravel.js
+++ b/src/templates/laravel.js
@@ -2,12 +2,23 @@
* Input values for laravel projects.
* @returns {object} Returns defaults values for laravel template.
*/
-module.exports = async function laravel() {
+module.exports = function laravel() {
return {
encoderVersion: 'current',
phpTargetVersion: '8.2',
arch: 64,
input: '',
- output: 'encrypted'
+ output: 'encrypted',
+ reflection: true,
+ encrypt: '*.blade.php',
+ binary: true,
+ optimize: 'max',
+ comments: false,
+ loader: false,
+ preamble: '',
+ passphrase: '',
+ check: 'script',
+ license: '/opt/license',
+ callback: 'public/ioncube.php'
}
}
diff --git a/src/validate.js b/src/validate.js
index db2ddc9..739cb54 100644
--- a/src/validate.js
+++ b/src/validate.js
@@ -9,33 +9,48 @@ const validatePhpTargetVersion = require('./inputs/php-target-version')
const validateArchitecture = require('./inputs/architecture')
const validateInput = require('./inputs/input')
const validateOutput = require('./inputs/output')
+const validateReflection = require('./inputs/reflection')
+const validateEncrypt = require('./inputs/encrypt')
+const validateBinary = require('./inputs/binary')
+const validateOptimize = require('./inputs/optimize')
+const validateComments = require('./inputs/comments')
+const validateLoader = require('./inputs/loader')
+const validatePreamble = require('./inputs/preamble')
+const validatePassphrase = require('./inputs/passphrase')
+const validateCheck = require('./inputs/check')
+const validateLicense = require('./inputs/license')
+const validateCallback = require('./inputs/callback')
/**
* Set default arguments depending on inputed template.
* @returns {Promise