@azrico/azcli 1.1.44 → 1.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +54 -2
- package/dist/libs/builder/build_wp.js +113 -1
- package/dist/libs/builder/build_yarn.js +11 -1
- package/dist/libs/builder/index.js +21 -1
- package/dist/libs/cleaner/cleanbuild.js +12 -1
- package/dist/libs/cleaner/cleannext.js +12 -1
- package/dist/libs/cleaner/cleannode.js +21 -1
- package/dist/libs/cleaner/index.js +37 -1
- package/dist/libs/commons/filehandler.js +61 -3
- package/dist/libs/commons/helper_exec.js +49 -1
- package/dist/libs/commons/helper_interface.js +96 -4
- package/dist/libs/commons/helper_string.js +15 -1
- package/dist/libs/commons/index.js +5 -1
- package/dist/libs/integ/index.js +7 -1
- package/dist/libs/integ/integ_readme.js +6 -1
- package/dist/libs/packager/index.js +18 -1
- package/dist/libs/packager/packager.js +236 -9
- package/dist/libs/up/filterOptionsByAcceptable.js +16 -2
- package/dist/libs/up/index.js +35 -1
- package/dist/libs/up/update_composer.js +53 -1
- package/dist/libs/up/update_py.js +10 -1
- package/dist/libs/up/update_yarn.js +78 -2
- package/dist/libs/yarnhelp/index.js +8 -1
- package/dist/libs/yarnhelp/yarnb.js +14 -1
- package/dist/libs/yarnhelp/yarni.js +14 -1
- package/dist/libs/yarnhelp/yarnt.js +14 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* -------------------------------------------------------------------------- */
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* -------------------------------------------------------------------------- */
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import figlet from 'figlet';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
|
+
import yargs from 'yargs';
|
|
7
|
+
/* -------------------------------------------------------------------------- */
|
|
8
|
+
/* Consts */
|
|
9
|
+
/* -------------------------------------------------------------------------- */
|
|
10
|
+
const header = chalk.red(figlet.textSync('Az-cli', { font: 'Cyberlarge', horizontalLayout: 'full' }));
|
|
11
|
+
/* -------------------------------------------------------------------------- */
|
|
12
|
+
/* Helper functions */
|
|
13
|
+
/* -------------------------------------------------------------------------- */
|
|
14
|
+
function loadCommands(yinstance, commandList) {
|
|
15
|
+
if (!yinstance)
|
|
16
|
+
return;
|
|
17
|
+
if (Array.isArray(commandList)) {
|
|
18
|
+
if (Array.isArray(commandList[0])) {
|
|
19
|
+
//2D Command
|
|
20
|
+
commandList.forEach((sub_cmd) => {
|
|
21
|
+
loadCommands(yinstance, sub_cmd);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
yinstance.command(commandList[0], commandList[1], commandList[2], commandList[3]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/* -------------------------------------------------------------------------- */
|
|
30
|
+
/* Start */
|
|
31
|
+
/* -------------------------------------------------------------------------- */
|
|
32
|
+
const yg = yargs(hideBin(process.argv));
|
|
33
|
+
yg.usage(header);
|
|
34
|
+
/* -------------------------------------------------------------------------- */
|
|
35
|
+
import builder from './libs/builder';
|
|
36
|
+
import cleaner from './libs/cleaner';
|
|
37
|
+
import yarnhelp from './libs/yarnhelp';
|
|
38
|
+
import packager from './libs/packager';
|
|
39
|
+
import updater from './libs/up';
|
|
40
|
+
loadCommands(yg, builder);
|
|
41
|
+
loadCommands(yg, cleaner);
|
|
42
|
+
loadCommands(yg, yarnhelp);
|
|
43
|
+
loadCommands(yg, packager);
|
|
44
|
+
loadCommands(yg, updater);
|
|
45
|
+
/* -------------------------------------------------------------------------- */
|
|
46
|
+
yg.demandCommand(1).options({
|
|
47
|
+
quiet: {
|
|
48
|
+
alias: ['q', 's'],
|
|
49
|
+
describe: 'quiet mode',
|
|
50
|
+
demandOption: false,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
/* -------------------------------------------------------------------------- */
|
|
54
|
+
const ygresult = yg.parse();
|
|
@@ -1 +1,113 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0,exports.handle=handle;var _commons=require("../commons"),_chalk=_interopRequireDefault(require("chalk")),_fs=_interopRequireDefault(require("fs")),_os=_interopRequireDefault(require("os")),_path=_interopRequireDefault(require("path")),_update_composer=require("../up/update_composer"),_shellExec=_interopRequireDefault(require("shell-exec"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function b(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function f(b,d,e,f){var g=d&&d.prototype instanceof k?d:k,h=Object.create(g.prototype),a=new B(f||[]);return E(h,"_invoke",{value:w(b,e,a)}),h}function j(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function k(){}function l(){}function m(){}function q(a){["next","throw","return"].forEach(function(c){b(a,c,function(a){return this._invoke(c,a)})})}function s(b,d){function c(e,f,g,i){var a=j(b[e],b,f);if("throw"!==a.type){var k=a.arg,l=k.value;return l&&"object"==_typeof(l)&&t.call(l,"__await")?d.resolve(l.__await).then(function(a){c("next",a,g,i)},function(a){c("throw",a,g,i)}):d.resolve(l).then(function(a){k.value=a,g(k)},function(a){return c("throw",a,g,i)})}i(a.arg)}var e;E(this,"_invoke",{value:function(a,b){function f(){return new d(function(d,e){c(a,b,d,e)})}return e=e?e.then(f,f):f()}})}function w(a,b,d){var e="suspendedStart";return function(f,g){if(e==="executing")throw Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return{value:D,done:!0}}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=x(h,d);if(i){if(i===G)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=j(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===G)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function x(b,c){var d=c.method,e=b.iterator[d];if(e===D)return c.delegate=null,"throw"===d&&b.iterator["return"]&&(c.method="return",c.arg=D,x(b,c),"throw"===c.method)||"return"!==d&&(c.method="throw",c.arg=new TypeError("The iterator does not provide a '"+d+"' method")),G;var f=j(e,b.iterator,c.arg);if("throw"===f.type)return c.method="throw",c.arg=f.arg,c.delegate=null,G;var g=f.arg;return g?g.done?(c[b.resultName]=g.value,c.next=b.nextLoc,"return"!==c.method&&(c.method="next",c.arg=D),c.delegate=null,G):g:(c.method="throw",c.arg=new TypeError("iterator result is not an object"),c.delegate=null,G)}function z(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function A(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function B(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(z,this),this.reset(!0)}function C(a){if(a||""===a){var b=a[F];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(t.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=D,b.done=!0,b};return d.next=d}}throw new TypeError(_typeof(a)+" is not iterable")}_regeneratorRuntime=function(){return h};var D,h={},e=Object.prototype,t=e.hasOwnProperty,E=Object.defineProperty||function(a,b,c){a[b]=c.value},n="function"==typeof Symbol?Symbol:{},F=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",c=n.toStringTag||"@@toStringTag";try{b({},"")}catch(a){b=function(a,b,c){return a[b]=c}}h.wrap=f;var G={},i={};b(i,F,function(){return this});var o=Object.getPrototypeOf,d=o&&o(o(C([])));d&&d!==e&&t.call(d,F)&&(i=d);var r=m.prototype=k.prototype=Object.create(i);return l.prototype=m,E(r,"constructor",{value:m,configurable:!0}),E(m,"constructor",{value:l,configurable:!0}),l.displayName=b(m,c,"GeneratorFunction"),h.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===l||"GeneratorFunction"===(b.displayName||b.name))},h.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,m):(a.__proto__=m,b(a,c,"GeneratorFunction")),a.prototype=Object.create(r),a},h.awrap=function(a){return{__await:a}},q(s.prototype),b(s.prototype,a,function(){return this}),h.AsyncIterator=s,h.async=function(b,c,d,e,g){void 0===g&&(g=Promise);var j=new s(f(b,c,d,e),g);return h.isGeneratorFunction(c)?j:j.next().then(function(a){return a.done?a.value:j.next()})},q(r),b(r,c,"Generator"),b(r,F,function(){return this}),b(r,"toString",function(){return"[object Generator]"}),h.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},h.values=C,B.prototype={constructor:B,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=D,this.done=!1,this.delegate=null,this.method="next",this.arg=D,this.tryEntries.forEach(A),!a)for(var b in this)"t"===b.charAt(0)&&t.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=D)},stop:function(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function(b){function d(a,c){return h.type="throw",h.arg=b,e.next=a,c&&(e.method="next",e.arg=D),!!c}if(this.done)throw b;for(var e=this,f=this.tryEntries.length-1;0<=f;--f){var g=this.tryEntries[f],h=g.completion;if("root"===g.tryLoc)return d("end");if(g.tryLoc<=this.prev){var j=t.call(g,"catchLoc"),k=t.call(g,"finallyLoc");if(j&&k){if(this.prev<g.catchLoc)return d(g.catchLoc,!0);if(this.prev<g.finallyLoc)return d(g.finallyLoc)}else if(!j){if(!k)throw Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return d(g.finallyLoc)}else if(this.prev<g.catchLoc)return d(g.catchLoc,!0)}}},abrupt:function(b,c){for(var d,e=this.tryEntries.length-1;0<=e;--e)if(d=this.tryEntries[e],d.tryLoc<=this.prev&&t.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var f=d;break}f&&("break"===b||"continue"===b)&&f.tryLoc<=c&&c<=f.finallyLoc&&(f=null);var g=f?f.completion:{};return g.type=b,g.arg=c,f?(this.method="next",this.next=f.finallyLoc,G):this.complete(g)},complete:function(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),G},finish:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),A(b),G},catch:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var f=d.arg;A(b)}return f}throw Error("illegal catch attempt")},delegateYield:function(a,b,c){return this.delegate={iterator:C(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=D),G}},h}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function g(a){asyncGeneratorStep(i,e,f,g,h,"next",a)}function h(a){asyncGeneratorStep(i,e,f,g,h,"throw",a)}var i=b.apply(c,d);g(void 0)})}}/* This lib helps you build a wordpress plugin */var zl=require("zip-lib"),ignored_files=["wp-content","node_modules","package.json",".gitignore",".git","tsconfig.json","yarn.lock","yarn-error.log","cache","temp","build","dist","doc","docs","documents","documentation"],files_to_delete=["vendor/**/.git","vendor/**/doxygen.config","vendor/**/doxygen"];function handle(){return _handle.apply(this,arguments)}function _handle(){return _handle=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return _regeneratorRuntime().wrap(function u(b){for(;1;)switch(b.prev=b.next){case 0:for((0,_commons.show_msg)("Building WP Plugin","text"),c=_os["default"].tmpdir(),d=_os["default"].homedir(),e=_path["default"].resolve("./"),f=_path["default"].basename(e),g=_path["default"].resolve(e,"build"),h=_path["default"].resolve(c,f),i=_path["default"].resolve(d,"Desktop"),j=_path["default"].resolve(i,"Build"),k=_path["default"].resolve(j,f+".zip"),(0,_commons.show_div)(),(0,_commons.show_msg)(_chalk["default"].gray("Plugin Name :")+" "+_chalk["default"].blue(f)),(0,_commons.show_msg)(_chalk["default"].gray("Temp Dir :")+" "+_chalk["default"].gray(h)),(0,_commons.show_msg)(_chalk["default"].gray("Temp Dir :")+" "+_chalk["default"].gray(h)),(0,_commons.show_msg)(_chalk["default"].gray("Local Build :")+" "+_chalk["default"].gray(g)),(0,_commons.show_div)(),b.prev=16,(0,_commons.show_msg)(_chalk["default"].gray("Removing old build files...")),(0,_commons.rmIfExists)(g),(0,_commons.rmIfExists)(h),(0,_commons.show_msg)(_chalk["default"].gray("Creating folders...")),(0,_commons.mkdirIfNotExists)(j),(0,_commons.mkdirIfNotExists)(h),(0,_commons.mkdirIfNotExists)(g),l=_fs["default"].readdirSync(e),(0,_commons.show_msg)(_chalk["default"].white("Copy all local files to temp path")+" "+_chalk["default"].gray("[")+_chalk["default"].blue(l.length)+_chalk["default"].gray("]")),m=ignored_files.map(function(a){return _path["default"].resolve(e,a)}),n=l.map(function(a){return _path["default"].resolve(e,a)}),o=0;o<n.length;o++)p=n[o],q=_path["default"].basename(p).trim(),m.includes(p)||ignored_files.includes(q)?(0,_commons.show_msg)(_chalk["default"].red("ignore: "+p),"text",!1):(0,_commons.cpfile)(p,h)?(0,_commons.show_msg)(_chalk["default"].gray("copy: "+p),"text",!1):((0,_commons.show_msg)(_chalk["default"].red("error: "+p),"text",!1),(0,_commons.show_msg)("cant copy the file: ".concat(q),"text",!1));/* -------------------------- delete all git files -------------------------- */(0,_commons.show_msg)(_chalk["default"].white("delete git files:")),r=0;case 31:if(!(r<files_to_delete.length)){b.next=40;break}return s=_path["default"].join(h,files_to_delete[r]),b.next=35,(0,_commons.search_delete)(s);case 35:t=b.sent,(0,_commons.show_msg)(_chalk["default"].gray("del: ".concat(s," -> ").concat(t)),"text",!1);case 37:r++,b.next=31;break;case 40:if(a.noupdate){b.next=45;break}return(0,_commons.show_msg)(_chalk["default"].white("Update Composer packages...")),(0,_shellExec["default"])("cd \"".concat(h,"\"")),b.next=45,(0,_update_composer.update_composer)(_objectSpread(_objectSpread({},a),{},{prod:!0}));case 45:return(0,_commons.show_msg)(_chalk["default"].white("Zip files and copy to destination")),(0,_commons.show_msg)(_chalk["default"].white("copy:"),"none",!1),(0,_commons.show_msg)(_chalk["default"].gray(h),"none",!1),(0,_commons.show_msg)(_chalk["default"].white(" -> "),"none",!1),(0,_commons.show_msg)(_chalk["default"].gray(k),"none",!1),b.next=52,zl.archiveFolder(h,k);case 52:(0,_commons.show_msg)(_chalk["default"].white("Zip done")),"false"!=a.cleanup&&((0,_commons.show_msg)(_chalk["default"].white("Clean up")),(0,_commons.rmIfExists)(h)),(0,_commons.cpfile)(k,g),b.next=61;break;case 57:return b.prev=57,b.t0=b["catch"](16),(0,_commons.show_error)(b.t0),b.abrupt("return",!1);case 61:case"end":return b.stop()}},b,null,[[16,57]])})),_handle.apply(this,arguments)}var _default=exports["default"]=handle;
|
|
1
|
+
/* This lib helps you build a wordpress plugin */
|
|
2
|
+
import { cpfile, mkdirIfNotExists, rmIfExists, run_fn_on_dir, search_delete, show_div, show_error, show_msg, } from '../commons';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { update_composer } from '../up/update_composer';
|
|
8
|
+
const zl = require('zip-lib');
|
|
9
|
+
const ignored_files = [
|
|
10
|
+
'wp-content',
|
|
11
|
+
'node_modules',
|
|
12
|
+
'package.json',
|
|
13
|
+
'.gitignore',
|
|
14
|
+
'.git',
|
|
15
|
+
'tsconfig.json',
|
|
16
|
+
'yarn.lock',
|
|
17
|
+
'yarn-error.log',
|
|
18
|
+
'cache',
|
|
19
|
+
'temp',
|
|
20
|
+
'build',
|
|
21
|
+
'dist',
|
|
22
|
+
'doc',
|
|
23
|
+
'docs',
|
|
24
|
+
'documents',
|
|
25
|
+
'documentation',
|
|
26
|
+
];
|
|
27
|
+
const files_to_delete = [
|
|
28
|
+
'vendor/**/.git',
|
|
29
|
+
'vendor/**/doxygen.config',
|
|
30
|
+
'vendor/**/doxygen',
|
|
31
|
+
];
|
|
32
|
+
export async function handle(args) {
|
|
33
|
+
show_msg('Building WP Plugin', 'text');
|
|
34
|
+
const windows_tmpdir = os.tmpdir(); // /tmp
|
|
35
|
+
const homeDir = os.homedir(); // See: https://www.npmjs.com/package/os
|
|
36
|
+
const currentDir = path.resolve('./');
|
|
37
|
+
const currentFolderName = path.basename(currentDir);
|
|
38
|
+
/* -------------------------------------------------------------------------- */
|
|
39
|
+
const localBuildDir = path.resolve(currentDir, `build`);
|
|
40
|
+
const tempDir = path.resolve(windows_tmpdir, currentFolderName);
|
|
41
|
+
const desktopDir = path.resolve(homeDir, 'Desktop');
|
|
42
|
+
const destinationPath = path.resolve(desktopDir, 'Build');
|
|
43
|
+
const resultFile = path.resolve(destinationPath, currentFolderName + '.zip');
|
|
44
|
+
show_div();
|
|
45
|
+
show_msg(chalk.gray('Plugin Name :') + ' ' + chalk.blue(currentFolderName));
|
|
46
|
+
show_msg(chalk.gray('Temp Dir :') + ' ' + chalk.gray(tempDir));
|
|
47
|
+
show_msg(chalk.gray('Temp Dir :') + ' ' + chalk.gray(tempDir));
|
|
48
|
+
show_msg(chalk.gray('Local Build :') + ' ' + chalk.gray(localBuildDir));
|
|
49
|
+
show_div();
|
|
50
|
+
try {
|
|
51
|
+
show_msg(chalk.gray('Removing old build files...'));
|
|
52
|
+
rmIfExists(localBuildDir);
|
|
53
|
+
rmIfExists(tempDir);
|
|
54
|
+
show_msg(chalk.gray('Creating folders...'));
|
|
55
|
+
mkdirIfNotExists(destinationPath);
|
|
56
|
+
mkdirIfNotExists(tempDir);
|
|
57
|
+
mkdirIfNotExists(localBuildDir);
|
|
58
|
+
const currentFiles = fs.readdirSync(currentDir);
|
|
59
|
+
show_msg(chalk.white('Copy all local files to temp path') +
|
|
60
|
+
' ' +
|
|
61
|
+
chalk.gray('[') +
|
|
62
|
+
chalk.blue(currentFiles.length) +
|
|
63
|
+
chalk.gray(']'));
|
|
64
|
+
const ignored_files_list = ignored_files.map((r) => path.resolve(currentDir, r));
|
|
65
|
+
const currentFilesList = currentFiles.map((r) => path.resolve(currentDir, r));
|
|
66
|
+
for (let index = 0; index < currentFilesList.length; index++) {
|
|
67
|
+
const cf = currentFilesList[index];
|
|
68
|
+
const file_name = path.basename(cf).trim();
|
|
69
|
+
if (ignored_files_list.includes(cf) || ignored_files.includes(file_name)) {
|
|
70
|
+
show_msg(chalk.red('ignore: ' + cf), 'text', false);
|
|
71
|
+
}
|
|
72
|
+
else if (cpfile(cf, tempDir)) {
|
|
73
|
+
show_msg(chalk.gray('copy: ' + cf), 'text', false);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
show_msg(chalk.red('error: ' + cf), 'text', false);
|
|
77
|
+
show_msg(`cant copy the file: ${file_name}`, 'text', false);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/* -------------------------- delete all git files -------------------------- */
|
|
81
|
+
show_msg(chalk.white('delete git files:'));
|
|
82
|
+
for (let index = 0; index < files_to_delete.length; index++) {
|
|
83
|
+
const fdel = path.join(tempDir, files_to_delete[index]);
|
|
84
|
+
const res = await search_delete(fdel);
|
|
85
|
+
show_msg(chalk.gray(`del: ${fdel} -> ${res}`), 'text', false);
|
|
86
|
+
}
|
|
87
|
+
/* ----------------------------- Update Packages ---------------------------- */
|
|
88
|
+
if (!args.noupdate) {
|
|
89
|
+
await run_fn_on_dir(tempDir, async () => {
|
|
90
|
+
await update_composer({ ...args, prod: true });
|
|
91
|
+
});
|
|
92
|
+
show_msg(chalk.white('Update Composer packages...'));
|
|
93
|
+
}
|
|
94
|
+
/* ------------------------------ Create Zip ------------------------------- */
|
|
95
|
+
show_msg(chalk.white('Zip files and copy to destination'));
|
|
96
|
+
show_msg(chalk.white(`copy:`), 'none', false);
|
|
97
|
+
show_msg(chalk.gray(tempDir), 'none', false);
|
|
98
|
+
show_msg(chalk.white(' -> '), 'none', false);
|
|
99
|
+
show_msg(chalk.gray(resultFile), 'none', false);
|
|
100
|
+
await zl.archiveFolder(tempDir, resultFile);
|
|
101
|
+
show_msg(chalk.white('Zip done'));
|
|
102
|
+
if (args.cleanup != 'false') {
|
|
103
|
+
show_msg(chalk.white('Clean up'));
|
|
104
|
+
rmIfExists(tempDir);
|
|
105
|
+
}
|
|
106
|
+
cpfile(resultFile, localBuildDir);
|
|
107
|
+
}
|
|
108
|
+
catch (ex) {
|
|
109
|
+
show_error(ex);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export default handle;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/* This lib helps you build a wordpress plugin */
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { do_exec, show_msg } from '../commons';
|
|
4
|
+
export async function handle(args) {
|
|
5
|
+
show_msg(chalk.gray(`Building Yarn`), 'text', false);
|
|
6
|
+
const res = await do_exec([`yarn run build`]);
|
|
7
|
+
show_msg(res.stdout, 'text', false);
|
|
8
|
+
show_msg(chalk.gray(`Done`), 'text', false);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
export default handle;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/* Automatically integrates tools */
|
|
2
|
+
import { getProjectType, loadProjectType, show_error, show_msg, } from '../commons';
|
|
3
|
+
import build_wp from './build_wp';
|
|
4
|
+
import build_yarn from './build_yarn';
|
|
5
|
+
export async function handle(args) {
|
|
6
|
+
try {
|
|
7
|
+
loadProjectType(args);
|
|
8
|
+
switch (getProjectType(args)) {
|
|
9
|
+
case 'php':
|
|
10
|
+
return await build_wp(args);
|
|
11
|
+
case 'yarn':
|
|
12
|
+
return await build_yarn(args);
|
|
13
|
+
default:
|
|
14
|
+
return show_msg('no build steps for this project type', 'text');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (ex) {
|
|
18
|
+
return show_error(ex);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default [['build <mode>', 'Build helper', () => { }, handle]];
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* This lib helps you build a wordpress plugin */
|
|
2
|
+
import { rimraf } from 'rimraf';
|
|
3
|
+
import { show_error, show_msg } from '../commons';
|
|
4
|
+
export async function handle(args) {
|
|
5
|
+
show_msg('Cleaning up build & dist files', 'text');
|
|
6
|
+
if ((await rimraf('build')) && (await rimraf('dist'))) {
|
|
7
|
+
show_msg('Build cleanup done', 'text');
|
|
8
|
+
}
|
|
9
|
+
else
|
|
10
|
+
show_error('Build cleanup failed');
|
|
11
|
+
}
|
|
12
|
+
export default handle;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* This lib helps you build a wordpress plugin */
|
|
2
|
+
import { rimraf } from 'rimraf';
|
|
3
|
+
import { show_error, show_msg } from '../commons';
|
|
4
|
+
export async function handle(args) {
|
|
5
|
+
show_msg('Cleaning up next files', 'text');
|
|
6
|
+
if (await rimraf('.next')) {
|
|
7
|
+
show_msg('next cleanup done', 'text');
|
|
8
|
+
}
|
|
9
|
+
else
|
|
10
|
+
show_error('next cleanup failed');
|
|
11
|
+
}
|
|
12
|
+
export default handle;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/* This lib helps you build a wordpress plugin */
|
|
2
|
+
import { err_unknown, search_delete, show_msg } from '../commons';
|
|
3
|
+
export async function handle(args) {
|
|
4
|
+
try {
|
|
5
|
+
show_msg('Cleaning up node_module', 'text');
|
|
6
|
+
await search_delete('./node_modules');
|
|
7
|
+
await search_delete(' ./**/node_modules');
|
|
8
|
+
show_msg('Cleaning up cache files', 'text');
|
|
9
|
+
await search_delete('.yarn/cache');
|
|
10
|
+
await search_delete('./**/.yarn/cache');
|
|
11
|
+
await search_delete('./**/.jest/cache');
|
|
12
|
+
show_msg('Cleaning up lock files', 'text');
|
|
13
|
+
await search_delete('./**/yarn.lock');
|
|
14
|
+
await search_delete('./**/package-lock.json');
|
|
15
|
+
show_msg('Node cleanup done', 'text');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
err_unknown('cleanup failed');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default handle;
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
/* Automatically integrates tools */
|
|
2
|
+
import { err_unknown, err_unknown_action, loadProjectType, show_div } from '../commons';
|
|
3
|
+
import cleanbuild from './cleanbuild';
|
|
4
|
+
import cleannode from './cleannode';
|
|
5
|
+
import cleannext from './cleannext';
|
|
6
|
+
export async function handle(args) {
|
|
7
|
+
loadProjectType();
|
|
8
|
+
try {
|
|
9
|
+
const mode = args.mode ?? '';
|
|
10
|
+
switch (mode) {
|
|
11
|
+
case 'build':
|
|
12
|
+
await cleanbuild(args);
|
|
13
|
+
break;
|
|
14
|
+
case 'node':
|
|
15
|
+
await cleannode(args);
|
|
16
|
+
break;
|
|
17
|
+
case 'next':
|
|
18
|
+
cleannext(args);
|
|
19
|
+
break;
|
|
20
|
+
case 'all':
|
|
21
|
+
await cleanbuild(args);
|
|
22
|
+
show_div();
|
|
23
|
+
await cleannode(args);
|
|
24
|
+
show_div();
|
|
25
|
+
await cleannext(args);
|
|
26
|
+
break;
|
|
27
|
+
case '':
|
|
28
|
+
default:
|
|
29
|
+
err_unknown_action(args);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (ex) {
|
|
34
|
+
err_unknown('unknown error');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default [['clean <mode>', 'Modes: node,build,next,all', () => { }, handle]];
|
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fsextra from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { show_error, show_msg } from './helper_interface';
|
|
5
|
+
/**
|
|
6
|
+
* Resolve path with args.path if exists
|
|
7
|
+
*/
|
|
8
|
+
export function path_resolve_args(p, args) {
|
|
9
|
+
if (!p)
|
|
10
|
+
return '';
|
|
11
|
+
if (typeof args === 'object' && args != null && args.path && args.path.length > 0)
|
|
12
|
+
return path.resolve(args.path, p);
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
export function rmIfExists(rm_path, log = false) {
|
|
16
|
+
if (!fs.existsSync(rm_path))
|
|
17
|
+
return false;
|
|
18
|
+
const fullpath = path.resolve(rm_path);
|
|
19
|
+
const isDir = fs.lstatSync(fullpath).isDirectory();
|
|
20
|
+
if (!isDir)
|
|
21
|
+
fs.unlinkSync(fullpath);
|
|
22
|
+
else
|
|
23
|
+
fs.rmSync(fullpath, { recursive: true, force: true });
|
|
24
|
+
if (log)
|
|
25
|
+
show_msg('rm: ' + fullpath, 'danger');
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
export function mkdirIfNotExists(rm_path, log = false) {
|
|
29
|
+
const fullpath = path.resolve(rm_path);
|
|
30
|
+
if (!fs.existsSync(fullpath)) {
|
|
31
|
+
fs.mkdirSync(fullpath);
|
|
32
|
+
if (log)
|
|
33
|
+
show_msg('rm: ' + fullpath, 'danger');
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
export function readIfExists(dir = './package.json') {
|
|
39
|
+
if (!fs.existsSync(dir)) {
|
|
40
|
+
throw show_error('file does not exists: ' + dir);
|
|
41
|
+
}
|
|
42
|
+
return fs.readFileSync(dir);
|
|
43
|
+
}
|
|
44
|
+
export function cpfile(fromPath, toPath) {
|
|
45
|
+
if (!fs.existsSync(fromPath))
|
|
46
|
+
return false;
|
|
47
|
+
if (path.basename(fromPath).startsWith('.'))
|
|
48
|
+
return false; //cant copy hiddens
|
|
49
|
+
if (fs.existsSync(toPath)) {
|
|
50
|
+
const isDir = fs.lstatSync(toPath).isDirectory();
|
|
51
|
+
if (isDir) {
|
|
52
|
+
//targetPath is a directory
|
|
53
|
+
const mfileName = path.basename(fromPath);
|
|
54
|
+
toPath = path.resolve(toPath, mfileName);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (fromPath === toPath)
|
|
58
|
+
return false;
|
|
59
|
+
fsextra.copySync(fromPath, toPath);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
import { rimraf } from 'rimraf';
|
|
3
|
+
import { err_unknown, show_msg } from '../commons';
|
|
4
|
+
import shellExec from 'shell-exec';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
/**
|
|
7
|
+
* Run a function in a specific directory and return to the old directory
|
|
8
|
+
*/
|
|
9
|
+
export async function run_fn_on_dir(ch_dir, fn, ...args) {
|
|
10
|
+
let old_dir = process.cwd();
|
|
11
|
+
if (ch_dir) {
|
|
12
|
+
show_msg(chalk.white('switch dir: ') + chalk.gray(ch_dir));
|
|
13
|
+
process.chdir(ch_dir);
|
|
14
|
+
}
|
|
15
|
+
const res = await fn(...args);
|
|
16
|
+
if (old_dir) {
|
|
17
|
+
process.chdir(old_dir);
|
|
18
|
+
show_msg(chalk.white('switch dir: ') + chalk.gray(old_dir));
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
export async function do_exec(cmd, ch_dir = '') {
|
|
23
|
+
const str_cmd = Array.isArray(cmd) ? cmd.join(' ') : cmd;
|
|
24
|
+
if (!str_cmd || str_cmd.length <= 0)
|
|
25
|
+
return Promise.reject(new Error());
|
|
26
|
+
const shellcmd = shellExec(str_cmd);
|
|
27
|
+
shellcmd.then((r) => {
|
|
28
|
+
if (r.error) {
|
|
29
|
+
err_unknown('Error : ' + r.error.message);
|
|
30
|
+
}
|
|
31
|
+
// if (stdout && r.stdout) {
|
|
32
|
+
// stdout(r.stdout);
|
|
33
|
+
// }
|
|
34
|
+
// if (stderr && r.stderr) {
|
|
35
|
+
// stderr(r.stderr);
|
|
36
|
+
// }
|
|
37
|
+
});
|
|
38
|
+
// if (onclose) shellcmd.finally(onclose);
|
|
39
|
+
shellcmd.catch((err) => {
|
|
40
|
+
err_unknown('Error on execution');
|
|
41
|
+
});
|
|
42
|
+
return await shellcmd;
|
|
43
|
+
}
|
|
44
|
+
export async function search_delete(folder, search = '') {
|
|
45
|
+
// const cmd = `Get-ChildItem -Path "${folder}" -Recurse -Directory -Force -Filter "${search}" | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue`;
|
|
46
|
+
const delfile = search.length > 0 ? `/**/${search}` : '';
|
|
47
|
+
const final_path = String(`${folder}${delfile}`).replaceAll('\\', '/');
|
|
48
|
+
return await rimraf(final_path, { glob: true });
|
|
49
|
+
}
|