12 |
- #!/usr/bin/env node
- (()=>{var e={761:(e,t,i)=>{i(147),i(17),i(84);const s=i(483);e.exports=class{constructor(){this.cliHelper=new s,this.cliHelper.debug("Root cli directory : "+this.cliHelper.getCliDir()),this.run()}run(){switch(this.cliHelper.getInstruction()){case"init":case"new":this.init();break;case"start":case"run":this.start();break;case"build":case"prod":this.build();break;case"buildNpm":case"buildCSS":this.buildNpm();break;case"test":this.cliHelper.info("We are sorry ! Tests are not implemented yet");break;case"doc":case"docs":case"documentation":this.doc();break;case"v":case"-v":case"--v":case"V":case"-V":case"--V":case"Version":case"-Version":case"--Version":case"version":case"-version":case"--version":this.cliHelper.info("The version of this program is in all the posts"),this.cliHelper.info("Made By : hassani ayoub (D3v4pp)"),this.cliHelper.info("Please visite http://cli.d3v4pp.fr if you feel the need to know more about @d3v4pp/cli");break;default:this.cliHelper.info("Need help Bro?"),this.cliHelper.info("Please visite http://cli.d3v4pp.fr if you feel the need to know more about @d3v4pp/cli")}}init(){this.cliHelper.info(`Initializing new ${this.cliHelper.appType} application "${this.cliHelper.getParamAsString(["init","new"])}" in : ${this.cliHelper.getWorkingDir()}`),new(i(504))(this.cliHelper).run()}start(){this.cliHelper.info(`Starting ${this.cliHelper.appType} application...`),new(i(572))(this.cliHelper).run()}build(){this.cliHelper.info("Building ..."),new(i(707))(this.cliHelper).run()}buildNpm(){this.cliHelper.info(" Building For NPM..."),new(i(152))(this.cliHelper).run()}doc(){this.cliHelper.info("Generating documentation ..."),new(i(72))(this.cliHelper).run()}}},483:(e,t,i)=>{i(84);const s=i(147),r=i(17),o={showVersion:!0,showName:!0,debugMode:!0,nameColor:63,infoColor:39,warnColor:220,errorColor:210,debugColor:22};e.exports=class{constructor(e=o){this.cp=i(81),this.readLine=i(521),this.wd=process.cwd(),this.CliDir=process.mainModule.path,this.package=JSON.parse(s.readFileSync(r.join(this.CliDir,"package.json"),"utf8")),this.config=Object.assign(o,e),this._args=process.argv.slice(2),this.appType=this.getParamAsString(["-t","--t","-type","--type"],"react")}isDebug(){return this.config.debugMode}getName(){return this.config.showVersion?`[${this.package.name}, Version : ${this.package.version}]`.color(this.config.nameColor):this.config.showName?`[${this.package.name}]`.color(this.config.nameColor):""}info(e){console.log(this.getName()+" info : ".color(this.config.infoColor)+e.color(this.config.infoColor))}warn(e){console.log(this.getName()+" warn : ".color(this.config.warnColor)+e.color(this.config.warnColor))}error(e){console.log(this.getName()+" error : ".color(this.config.errorColor)+e.color(this.config.errorColor))}debug(e){this.isDebug()&&console.log(this.getName()+" __DEGUG__ ".color(23)+e.color(this.config.debugColor))}getWorkingDir(){return this.wd}getCliDir(){return this.CliDir}getInstruction(){return this._args[0]}getArgsPosition(e){for(let t=0;t<=e.length;t++){let i=this._args.findIndex((i=>i===e[t]));if(i>-1)return i}return-1}getParamAsString(e,t){let i=this.getArgsPosition(e);return-1==i?t:this._args[i+1]}getParamAsNumber(e,t){let i=this.getArgsPosition(e);return-1==i?t:parseInt(this._args[i+1])}getParamAsBoolean(e){return this.getArgsPosition(e)>-1}question(e){return new Promise(((t,i)=>{const s=this.readLine.createInterface({input:process.stdin,output:process.stderr});s.question(this.getName()+" Question : ".color(220)+e.color(220)+"\n"+this.getName()+" Answer : ".color(220),(e=>{s.close(),t(e)}))}))}exec(e,t,i){return new Promise(((s,r)=>{const o=this.cp.spawn(e,t,{stdio:"inherit",shell:!0,cwd:i||process.cwd()});o.on("error",(e=>{r(e)})),o.on("exit",(e=>{0===e?s():r()}))}))}}},608:(e,t,i)=>{const s=i(147),r=i(17);e.exports=function(e,t,i,o){var n=o;o||(n=i,i={});var a=process.cwd(),c=r.resolve(a,e),l=r.resolve(a,t),p=i.filter,h=i.rename,u=i.transform,d=!1!==i.clobber,g=i.modified,m=i.dereference,f=null,w=0,b=0,k=0,v=i.limit||16;function x(e){if(w++,p)if(p instanceof RegExp){if(!p.test(e))return A(!0)}else if("function"==typeof p&&!p(e))return A(!0);return C(e)}function C(e){var t=m?s.stat:s.lstat;if(k>=v)return setImmediate((function(){C(e)}));k++,t(e,(function(t,i){var o,n,p={};return t?P(t):(p.name=e,p.mode=i.mode,p.mtime=i.mtime,p.atime=i.atime,i.isDirectory()?void _(n=(o=p).name.replace(c,l),(function(e){if(e)return function(e,t){s.mkdir(t,e.mode,(function(t){if(t)return P(t);j(e.name)}))}(o,n);j(o.name)})):i.isFile()?function(e){var t=e.name.replace(c,l);h&&(t=h(t)),_(t,(function(i){return i?y(e,t):(d&&D(t,(function(){y(e,t)})),g?void(m?s.stat:s.lstat)(t,(function(i,s){if(!(e.mtime.getTime()>s.mtime.getTime()))return A();y(e,t)})):A())}))}(p):i.isSymbolicLink()?function(e){var t=e.replace(c,l);s.readlink(e,(function(e,i){if(e)return P(e);!function(e,t){m&&(e=r.resolve(a,e)),_(t,(function(i){if(i)return S(e,t);s.readlink(t,(function(i,s){return i?P(i):(m&&(s=r.resolve(a,s)),s===e?A():D(t,(function(){S(e,t)})))}))}))}(i,t)}))}(e):void 0)}))}function y(e,t){var i=s.createReadStream(e.name),r=s.createWriteStream(t,{mode:e.mode});i.on("error",P),r.on("error",P),u?u(i,r,e):r.on("open",(function(){i.pipe(r)})),r.once("finish",(function(){g?(s.utimesSync(t,e.atime,e.mtime),A()):A()}))}function D(e,t){s.unlink(e,(function(e){return e?P(e):t()}))}function j(e){s.readdir(e,(function(t,i){return t?P(t):(i.forEach((function(t){x(r.join(e,t))})),A())}))}function S(e,t){s.symlink(e,t,(function(e){return e?P(e):A()}))}function _(e,t){s.lstat(e,(function(e){return e&&"ENOENT"===e.code?t(!0):t(!1)}))}function P(e){return i.stopOnError?n(e):(!f&&i.errs?f=s.createWriteStream(i.errs):f||(f=[]),void 0===f.write?f.push(e):f.write(e.stack+"\n\n"),A())}function A(e){if(e||k--,b++,w===b&&0===k&&void 0!==n)return n(f||null)}v=v<1?1:v>512?512:v,x(c)}},60:(e,t,i)=>{const s=i(147),r=i(17);e.exports=function e(t){return new Promise((function(i,o){s.access(t,(function(n){n&&o(n),s.readdir(t,{withFileTypes:!0},(function(n,a){if(n&&o(n),0==a.length)return i((c=t,new Promise(((e,t)=>{s.rmdir(c,(function(i){i&&t(i),e(c)}))}))));var c;a.map((function(o){return o.isDirectory()?i(e(r.join(t,o.name))):i((n=r.join(t,o.name),new Promise(((e,t)=>{s.unlink(n,(function(i){i&&t(i),e()}))}))));var n}))}))}))}))}},707:(e,t,i)=>{const s=i(17),r=i(147),o=i(375),n=i(354);e.exports=class{constructor(e){this.helper=e,this.package=JSON.parse(r.readFileSync(s.join(this.helper.getWorkingDir(),"package.json"),"utf8")),this.public=this.helper.getParamAsString(["-public","--public"],"/")}run(){this.buildSimpleApp()}buildSimpleApp(){this.webpackConfig=new o(this.helper,"production").get();const e=n(this.webpackConfig);e.run(((t,i)=>{if(t)throw t;i.hasErrors()&&console.error(i.toString({chunks:!1,colors:!0})),e.close((e=>{if(e)throw e;console.log(i.toString({chunks:!1,colors:!0}))}))}))}}},152:(e,t,i)=>{const s=i(375),r=(i(977),i(354)),o=i(17);e.exports=class{constructor(e){this.params=e,this.config=new s,this.webpackConfig()}webpackConfig(){this.config.resolve={modules:[o.join(this.params.getCliDir(),"node_modules"),o.join(this.params.getWorkingDir(),"node_modules")]},this.config.setProductionMode(),this.config.addEntry(this.params._args[1]),this.config.target="web",this.config.setOutputPath(o.join(this.params.getWorkingDir(),"npm")),this.config.setOutputPublicPath("./"),this.config.output.filename="index.js",this.config.output.libraryExport="default",this.config.output.libraryTarget="commonjs",this.config.addLoaderRule(this.config.getJsxLoaderRule(o.join(this.params.getCliDir(),"node_modules"))),this.config.addLoaderRule(this.config.getProdcssLoaderRule(o.join(this.params.getCliDir(),"node_modules"))),this.config.addLoaderRule(this.config.getStaticFilesLoader(o.join(this.params.getCliDir(),"node_modules"))),this.config.addLoaderRule(this.config.getFontsLoaderRule(o.join(this.params.getCliDir(),"node_modules"))),this.config.addPlugins(this.config.getProdCssExtractionPlugin())}compilerCallback(e,t){if(e)throw e;console.log(t.toString({chunks:!1,colors:!0}))}run(){r(this.config,this.compilerCallback.bind(this))}}},328:(e,t,i)=>{i(84),e.exports=class{constructor(){this.cp=i(81),this.readLine=i(521)}question(e){return new Promise(((t,i)=>{const s=this.readLine.createInterface({input:process.stdin,output:process.stderr});s.question("[@Sweetcom/cli]".color(63)+" Question : ".color(220)+e.color(220)+"\n[@Sweetcom/cli]".color(63)+" Answer : ".color(220),(e=>{s.close(),t(e)}))}))}exec(e,t,i){return new Promise(((s,r)=>{const o=this.cp.spawn(e,t,{stdio:"inherit",shell:!0,cwd:i||process.cwd()});o.on("error",(e=>{r(e)})),o.on("exit",(e=>{0===e?s():r()}))}))}}},72:(e,t,i)=>{const{exec:s}=i(81);e.exports=class{constructor(e){this.params=e}run(){s("node "+this.params.CliDir+"\\node_modules\\jsdoc\\jsdoc.js src/ -d doc",((e,t,i)=>{e?console.error(`exec error: ${e}`):(console.log(`stdout: ${t}`),console.error(`stderr: ${i}`))}))}}},504:(e,t,i)=>{const s=i(17),r=i(147),o=i(608),n=i(60),a=i(328),c=(i(84),i(607));e.exports=class extends a{constructor(e){super(),this.helper=e,this.appname=this.helper.getParamAsString(["init"]),this.workDir=this.helper.getWorkingDir(),this.cliDir=this.helper.getCliDir(),this.verbose=this.helper.getParamAsBoolean(["-v","--v","-verbose","--verbose"],!0),this.tplDir=this.getTemplateDir(),this.appDir=s.join(this.workDir,this.appname)}getTemplateDir(){let e=["react","sweet","simple"];if(e.includes(this.helper.appType))return s.join(this.cliDir,"template",this.helper.appType);throw new Error("Template name error posibilities : ["+e.join(" - ")+"]")}projectDirectoryExistsWarning(){this.helper.warn('Warning : The Directory "'+this.appname+'" allready exists !'),this.helper.warn("Please chose from below : "),this.helper.warn(" 1 : Do nothing and exit."),this.helper.warn(' 2 : Delete existing folder and initialize app in "'+this.appname+'" folder anyway !!!!'),this.helper.warn(" 3 : Chose an other name for your app.")}checkifProjectExists(){return new Promise(((e,t)=>{r.exists(this.appDir,(i=>{i?(this.projectDirectoryExistsWarning(),this.helper.question("1 to exit, 2 to erase the old app or 3 to chose a new name ? ").then((i=>{"1"==i?(this.helper.info("You chose to do nothing "),this.helper.info("Doing nothing .... "),this.helper.info("Good Day to you ;) "),process.exit(0)):"3"==i?(this.helper.info("You chose to rename your application "),this.helper.question("Please enter the new name for your application ").then((t=>{this.appname=t,this.appDir=s.join(this.workDir,this.appname),e(t)}))):"2"==i?(this.helper.info("You chose to delete the old existing folder "),n(this.appDir).then((()=>{this.helper.info(" Folder deleted correctly "),e(i)})).catch((e=>{t(e)}))):(this.helper.error("The only available choices are 1, 2 or 3 "),this.helper.info("Savest choice is doing nothing, and tel you try again if needed "),this.helper.info("Doing nothing .... "),this.helper.info("Good Day to you ;) "),process.exit(0))}))):e()}))}))}run(){this.checkifProjectExists().then((e=>{o(this.tplDir,this.appDir,(e=>{if(e)return console.error(e),process.exit(0);let t=new c(s.join(this.appDir,"package.json"));t.package.name=this.appname,t.writeFile();let i=new c(s.join(this.appDir,"src/assets/manifest.json"));i.package.short_name=this.appname,i.package.name=this.appname,i.writeFile(),this.helper.info("Running npm install ..."),this.helper.exec("npm",["install"],this.appDir).then((()=>{this.question("Would you like to start your application ( yes if empty answer )?").then((e=>{"YES"!=e.toUpperCase()&&"Y"!=e.toUpperCase()&&""!==e||this.helper.exec("devapp",["start"],this.appDir).then((()=>{})).catch((e=>(console.error(e),process.exit(0))))}))})).catch((e=>(console.error(e),process.exit(0))))}))})).catch((e=>{throw e}))}}},572:(e,t,i)=>{const s=i(17),r=i(147),o=i(375),n=i(354),a=i(426),{template:c}=i(629);e.exports=class{constructor(e){this.helper=e,this.port=this.helper.getParamAsNumber(["-p","--port"],8080),this.public=this.helper.getParamAsString(["-public","--public"],"/"),this.host="localhost",this.package=JSON.parse(r.readFileSync(s.join(this.helper.getWorkingDir(),"package.json"),"utf8"))}startSimpleApplication(){this.webpackConfig=new o(this.helper,"development").get();const e=n(this.webpackConfig),t={...this.webpackConfig.devServer,port:this.port};new a(t,e).start().then((()=>{console.log("Starting server...")}))}startReactAppLication(){this.webpackConfig=new o(this.helper,"development").get();const e=n(this.webpackConfig),t={...this.webpackConfig.devServer,port:this.port};new a(t,e).start().then((()=>{console.log("Starting server...")}))}run(){switch(this.helper.appType){case"simple":default:this.startSimpleApplication();break;case"react":this.startReactAppLication()}}}},375:(e,t,i)=>{const s=i(17),r=i(510),o=i(857),n=i(1),a=i(354);e.exports=class{constructor(e,t){switch(this.helper=e,this.webpackConfig=i(938),this.helper.appType){case"simple":this.AddSimplAppConfig(t);break;case"react":this.webpackConfig=i(938),this.commun(t),this.webpackConfig.module.rules=[{test:/\.s[ac]ss$/i,use:[o.loader,s.join(this.helper.getCliDir(),"node_modules","css-loader"),s.join(this.helper.getCliDir(),"node_modules","sass-loader")]},{test:/\.css$/i,use:[o.loader,s.join(this.helper.getCliDir(),"node_modules","css-loader")]},{test:/\.(js|jsx)$/i,exclude:[s.join(this.helper.getCliDir(),"node_modules"),s.join(this.helper.getWorkingDir(),"node_modules")],use:{loader:s.join(this.helper.getCliDir(),"node_modules","babel-loader"),options:{presets:[s.join(this.helper.getCliDir(),"node_modules","@babel/preset-env"),s.join(this.helper.getCliDir(),"node_modules","@babel/preset-react")],plugins:[s.join(this.helper.getCliDir(),"node_modules","@babel/plugin-proposal-class-properties")]}}},{test:/\.(json|txt)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}},{test:/\.(png|svg|jpg|jpeg|gif)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}},{test:/\.(woff|woff2|eot|ttf|otf)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}}];break;default:this.webpackConfig=i(938)}}commun(e){this.webpackConfig.mode=e,this.webpackConfig.resolve={modules:[s.join(this.helper.getCliDir(),"node_modules"),s.join(this.helper.getWorkingDir(),"node_modules")]},this.webpackConfig.context=this.helper.getWorkingDir(),this.webpackConfig.plugins=[new r({template:s.resolve(this.helper.getWorkingDir(),"src","index.html"),templateParameters:{favicon:"/assets/logo.png",manifest:"/assets/manifest.json"}}),new o,new n({patterns:[{from:"src/assets",to:"assets"}]}),new a.HotModuleReplacementPlugin({})],this.webpackConfig.output={path:s.resolve(this.helper.getWorkingDir(),"build"),filename:"[name].d3v4pp.bundle.js",publicPath:"/"},this.webpackConfig.devServer.static={directory:s.join(this.helper.getWorkingDir(),"src")}}AddSimplAppConfig(e){this.webpackConfig=i(979),this.commun(e),this.webpackConfig.module={rules:[{test:/\.s[ac]ss$/i,use:[o.loader,s.join(this.helper.getCliDir(),"node_modules","css-loader"),s.join(this.helper.getCliDir(),"node_modules","sass-loader")]},{test:/\.css$/i,use:[o.loader,s.join(this.helper.getCliDir(),"node_modules","css-loader")]},{test:/\.(json|txt)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}},{test:/\.(png|svg|jpg|jpeg|gif)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}},{test:/\.(woff|woff2|eot|ttf|otf)$/i,type:"asset/resource",generator:{filename:"[name][ext]"}}]},this.webpackConfig.optimization={splitChunks:{chunks:"all",minSize:1e3,maxSize:2e3,cacheGroups:{defaultVendors:{test:/[\\/]node_modules[\\/]/,name:"vendors",minChunks:2,priority:-10,reuseExistingChunk:!0},default:{minChunks:3,priority:-20,reuseExistingChunk:!0}}}}}get(){return this.webpackConfig}}},607:(e,t,i)=>{const s=i(147);e.exports=class{constructor(e,t){let i=t||!0;this.fileName=e,i&&this.load()}load(){this.package=JSON.parse(s.readFileSync(this.fileName,"utf8"))}updateVersion(){}writeFile(){s.writeFileSync(this.fileName,JSON.stringify(this.package,void 0,4))}}},938:(e,t,i)=>{const s=i(17),r=i(510),o=i(857),n=i(1);e.exports={entry:["./src/index.js"],mode:"production",target:"web",module:{rules:[{test:/\.(js|jsx)$/i,exclude:/(node_modules|bower_components)/,use:{loader:"babel-loader",options:{presets:["@babel/preset-env","@babel/preset-react"]}}},{test:/\.s[ac]ss$/i,use:[o.loader,"css-loader","sass-loader"]},{test:/\.css$/i,use:[o.loader,"css-loader"]}]},plugins:[new r({template:s.resolve("src","index.html")}),new o,new n({patterns:[{from:"src/assets",to:"assets"}]})],output:{path:s.resolve(__dirname,"build"),filename:"[name].d3v4pp.bundle.js",publicPath:"/"},devServer:{client:{progress:!0,reconnect:!0,overlay:{errors:!0,warnings:!1}},hot:!0,historyApiFallback:!0,open:!0,static:{directory:s.join(__dirname,"src")},compress:!0,port:9e3}}},979:(e,t,i)=>{const s=i(17),r=i(510),o=i(857),n=i(1);e.exports={entry:["./src/index.js"],mode:"production",target:"web",module:{rules:[{test:/\.s[ac]ss$/i,use:[o.loader,"css-loader","sass-loader"]},{test:/\.css$/i,use:[o.loader,"css-loader"]}]},plugins:[new r({template:s.resolve("src","index.html"),templateParameters:{favicon:"/assets/logo.png",manifest:"/assets/manifest.json"}}),new o,new n({patterns:[{from:"src/assets",to:"assets"}]})],output:{path:s.resolve(__dirname,"build"),filename:"[name].d3v4pp.bundle.js",publicPath:"/"},devServer:{client:{progress:!0,reconnect:!0,overlay:{errors:!0,warnings:!1}},historyApiFallback:!0,open:!0,static:{directory:s.join(__dirname,"src")},compress:!0,port:9e3}}},629:e=>{"use strict";e.exports=require("@babel/core")},84:e=>{"use strict";e.exports=require("@sweetcom/colors")},1:e=>{"use strict";e.exports=require("copy-webpack-plugin")},510:e=>{"use strict";e.exports=require("html-webpack-plugin")},857:e=>{"use strict";e.exports=require("mini-css-extract-plugin")},354:e=>{"use strict";e.exports=require("webpack")},426:e=>{"use strict";e.exports=require("webpack-dev-server")},977:e=>{"use strict";e.exports=require("webpack-node-externals")},81:e=>{"use strict";e.exports=require("child_process")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},521:e=>{"use strict";e.exports=require("readline")}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}(()=>{"use strict";new(i(761))})()})();
|