Skip to content

Commit

Permalink
change to use trial version by default
Browse files Browse the repository at this point in the history
  • Loading branch information
MuriloChianfa committed Dec 7, 2023
1 parent 7d4dd37 commit b67e200
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ __tests__/runner/*

# Custom
encrypted
eval_linux
ioncube_encoder_evaluation
ioncube_encoder_evaluation.tar.gz
2 changes: 1 addition & 1 deletion __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ describe('action', () => {
expect(debugMock).toHaveBeenNthCalledWith(9, '')

expect(setOutputMock).toHaveBeenCalledWith('status', 'Project encoded with success')
})
}, 20000)
})
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ inputs:
outputs:
status:
description: 'The message of encode proccess'
type: string

runs:
using: node20
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 116 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"node-tar": "^1.0.0",
"tar": "^6.2.0"
},
"devDependencies": {
"@babel/core": "^7.23.5",
Expand Down
27 changes: 17 additions & 10 deletions src/evaluation.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
const core = require('@actions/core')
const EVALUATION_PATH = './ioncube_encoder_evaluation/ioncube_encoder.sh'
const tar = require('tar')
const fs = require('fs')
const cp = require('child_process')
const process = require('process')

/**
* Download ioncube evaluation.
* @returns {string} Returns the path of encoder.
* @returns {Promise<string>} Returns the path of encoder.
*/
async function evaluation() {
core.debug('Using trial ioncube to encode files!')
core.debug('Downloading trial version of ioncube encoder...')
module.exports = async function evaluation() {
const cwd = process.cwd()

// TODO: download ioncube evaluation
// wget https://www.ioncube.com/eval_linux -O ioncube_encoder_evaluation.tar.gz
// tar -xzvf ioncube_encoder_evaluation.tar.gz
if (!fs.existsSync('ioncube_encoder_evaluation')) {
await download('https://www.ioncube.com/eval_linux', `${cwd}/ioncube_encoder_evaluation.tar.gz`)
await tar.extract({ file: `${cwd}/ioncube_encoder_evaluation.tar.gz` })

if (fs.existsSync(`${cwd}/ioncube_encoder_evaluation.tar.gz`)) {
fs.unlinkSync(`${cwd}/ioncube_encoder_evaluation.tar.gz`)
}
}

return EVALUATION_PATH
}

module.exports = {
EVALUATION_PATH,
evaluation
const download = async (uri, filename) => {
cp.execSync(`wget ${uri} -O ${filename}`)
}
8 changes: 4 additions & 4 deletions src/inputs/trial.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const evaluation = require('../evaluation')

/**
* Validate trial input values.
* @returns {string} Returns a validated trial input.
* @returns {Promise<string>} Returns a validated trial input.
*/
module.exports = function validateTrial() {
const trial = core.getInput('trial', { required: true }) ?? false
module.exports = async function validateTrial() {
const trial = core.getInput('trial', { required: true }) ?? true

if (trial) {
return evaluation.evaluation()
return await evaluation()
}

// TODO: add a default path parameter
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const validate = require('./validate')
*/
async function run() {
try {
const inputs = validate()
const inputs = await validate()

if (!inputs.trial) {
// TODO: activate ioncube
Expand Down
6 changes: 3 additions & 3 deletions src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const validateOutput = require('./inputs/output')

/**
* Set default arguments depending on inputed template.
* @returns {object} Inputs based on templates.
* @returns {Promise<object>} Inputs based on templates.
*/
module.exports = function validate() {
module.exports = async function validate() {
const template = validateTemplate()

const ioncube = validateTrial()
const ioncube = await validateTrial()
const trial = ioncube === EVALUATION_PATH ? true : false

const defaults = choose(template)
Expand Down

0 comments on commit b67e200

Please sign in to comment.