Skip to content

Commit

Permalink
add npm release script
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianorsouza committed Jul 23, 2020
1 parent 2e8f747 commit db524da
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

*.phar
*.lock
package-lock.json

/node_modules/
/vendor/
_build/
/html

9 changes: 8 additions & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
"in": "vendor"
},
{
"exclude": ["tests", "_build"],
"exclude": [
"tests",
"_build",
"scripts",
"node_modules"
],
"in": "./"
}
],
"blacklist": [
"package.json",
"package-lock.json",
"api.php",
"box.json",
"config.yaml",
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "0.0.0",
"name": "adrianorosa/compare-system-versions",
"description": "System versions compare",
"type": "project",
Expand Down
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "compare-system-versions",
"version": "0.0.0",
"description": "Compare System Versions",
"dependencies": {},
"devDependencies": {
"release-task": "^1.0.0"
},
"scripts": {
"release": "node ./scripts/release.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/adrianorsouza/compare-system-versions.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/adrianorsouza/compare-system-versions/issues"
},
"homepage": "https://github.com/adrianorsouza/compare-system-versions#readme"
}
61 changes: 61 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/** ========================================================================
* Project : compare-system-versions
* Description : release
* Author : Adriano Rosa <https://adrianorosa.com>
* Date : 2020-07-23 17:16
* ========================================================================
* Copyright 2020 Adriano Rosa <https://adrianorosa.com>
* ======================================================================== */

const util = require('util');
const exec = util.promisify(require('child_process').exec);
const releaseTask = require('release-task');
const { writeLog } = require('release-task/src/helpers');

// create a new instance of releaseTask
const tasks = new releaseTask({
bumpFiles: ['composer.json', 'package.json'],
commitFiles: ['composer.json', 'package.json', 'CHANGELOG.md'],
config: {
indentSize: 2
}
});


const push = async () => {
writeLog('TASK push');
const {stdout, stderr} = exec('git push -u origin master --tags 2>&1');
if (stderr) throw new Error(`TASK push result an error ${stderr}`);
return `TASK push has been completed.\n\n${stdout}`;
};


// async function compilePHAR(version, options) {
const compilePHAR = async (version, options) => {
writeLog('TASK compilePHAR');
const { stdout, stderr } = await exec('box compile');

if (stderr) {
throw new Error(`An error occurred ${stderr}`);
}

if (stdout) {
return `Compile phar using box DONE!\n\n${stdout}`
}
}


// Create a custom task named push
tasks.addTask('push', push, {
checked: false,
value: 'push',
name: 'Push new releases',
});

tasks.addTask('compilePHAR', compilePHAR, {
checked: true,
value: 'compilePHAR',
name: 'Compile phar using box',
});

tasks.init();

0 comments on commit db524da

Please sign in to comment.