Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wakx

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wakx - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

2

main.js

@@ -6,5 +6,5 @@ #!/usr/bin/env node

* author: Nolann Morencé
* version: 1.1.5
* version: 1.1.6
*/
const fs=require("fs"),path=require("path"),liveServer=require("live-server"),prompts=require("prompts"),TEMPLATE_APP={Name:"My First App",ShortName:"MyFirstApp",Description:"Simple app for progressive web app with WebAppKit framework",Lang:"en",ThemeColor:"white",LaunchScreen:"home_screen",NewScreen:"new_screen",NewComponent:"NewComponent"},TEMPLATE_PATH=path.join(path.dirname(__filename),"templates"),HELP_MESSAGE="\nWelcome on WebAppKit !\nThanks for using this framework\n\nUsage: node wak.js <command>\n---\ninit: Initiate a new project\nhelp: Show this help\n\nUsage: node wak.js <app-name> <command>\n---\nscreen: Create new screen\ncomponent: Create new component\nbuild: Build app with manifest update\nstart: Run your app (-p|--port XXXX, -l|--launch)\n\nLink to github project: https://github.com/exagyde/webappkit\n",INIT_PROMPT=[{type:"text",name:"app_name",message:`What is your app name ? (${TEMPLATE_APP.Name}) `,initial:TEMPLATE_APP.Name},{type:"text",name:"app_short_name",message:`What is your short app name ? (${TEMPLATE_APP.ShortName}) `,initial:TEMPLATE_APP.ShortName},{type:"text",name:"app_description",message:"What is your app description ? ",initial:TEMPLATE_APP.Description},{type:"select",name:"app_lang",message:"Set you app language : ",choices:[{title:"English",value:"en"},{title:"French",value:"fr"},{title:"Spanish",value:"es"},{title:"German",value:"de"}]},{type:"select",name:"app_theme_color",message:"Set you app theme color : ",choices:[{title:"Light",value:"white"},{title:"Dark",value:"black"}]},{type:"text",name:"app_launch_screen",message:`Set your launch screen : (${TEMPLATE_APP.LaunchScreen}) `,initial:TEMPLATE_APP.LaunchScreen}],WEBAPPKIT={Init:async()=>{let e=await prompts(INIT_PROMPT);if(fs.existsSync("./"+e.app_short_name))return void console.log(`Project ${e.app_short_name} already exists`);fs.mkdirSync("./"+e.app_short_name),fs.mkdirSync("./"+e.app_short_name+"/app"),fs.mkdirSync("./"+e.app_short_name+"/components"),fs.mkdirSync("./"+e.app_short_name+"/resources"),fs.mkdirSync("./"+e.app_short_name+"/screens"),fs.copyFileSync(TEMPLATE_PATH+"/favicon.ico","./"+e.app_short_name+"/favicon.ico"),fs.mkdirSync("./"+e.app_short_name+"/resources/icons"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-128.png","./"+e.app_short_name+"/resources/icons/icon-128.png"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-144.png","./"+e.app_short_name+"/resources/icons/icon-144.png"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-152.png","./"+e.app_short_name+"/resources/icons/icon-152.png"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-192.png","./"+e.app_short_name+"/resources/icons/icon-192.png"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-256.png","./"+e.app_short_name+"/resources/icons/icon-256.png"),fs.copyFileSync(TEMPLATE_PATH+"/resources/icons/icon-512.png","./"+e.app_short_name+"/resources/icons/icon-512.png"),fs.copyFileSync(TEMPLATE_PATH+"/sw.js","./"+e.app_short_name+"/sw.js"),fs.copyFileSync(TEMPLATE_PATH+"/app/App.js","./"+e.app_short_name+"/app/App.js"),fs.copyFileSync(TEMPLATE_PATH+"/app/register.js","./"+e.app_short_name+"/app/register.js"),fs.copyFileSync(TEMPLATE_PATH+"/app/style.css","./"+e.app_short_name+"/app/style.css");let n=fs.readFileSync(TEMPLATE_PATH+"/index.html","utf-8").replace(/{{ APP_LANG }}/g,e.app_lang).replace(/{{ APP_THEME_COLOR }}/g,e.app_theme_color).replace(/{{ APP_NAME }}/g,e.app_name).replace(/{{ APP_SHORT_NAME }}/g,e.app_short_name).replace(/{{ APP_DESCRIPTION }}/g,e.app_description);fs.writeFileSync("./"+e.app_short_name+"/index.html",n);let a=fs.readFileSync(TEMPLATE_PATH+"/manifest.json","utf-8").replace(/{{ APP_NAME }}/g,e.app_name).replace(/{{ APP_SHORT_NAME }}/g,e.app_short_name).replace(/{{ APP_LANG }}/g,e.app_lang).replace(/{{ APP_THEME_COLOR }}/g,e.app_theme_color).replace(/{{ APP_BACKGROUND_COLOR }}/g,e.app_theme_color).replace(/{{ APP_LAUNCH_SCREEN }}/g,e.app_launch_screen).replace(/{{ APP_DESCRIPTION }}/g,e.app_description);fs.writeFileSync("./"+e.app_short_name+"/manifest.json",a),WEBAPPKIT.CreateScreen({screen_name:e.app_launch_screen,app_name:e.app_short_name,app_lang:e.app_lang}),console.log(`Project ${e.app_name} created`)},ReadManifest:({app_name:e})=>{if(!fs.existsSync("./"+e+"/manifest.json"))return console.log("Manifest not found"),null;let n=fs.readFileSync("./"+e+"/manifest.json","utf-8");return JSON.parse(n)},CreateScreen:({app_name:e,screen_name:n,app_lang:a})=>{if(fs.existsSync("./"+e+"/screens/"+n))return void console.log(`Screen ${n} already exists`);fs.mkdirSync("./"+e+"/screens/"+n);let s=fs.readFileSync(TEMPLATE_PATH+"/screens/home_screen/screen.html","utf-8").replace(/{{ APP_LANG }}/g,a);fs.writeFileSync("./"+e+"/screens/"+n+"/screen.html",s),fs.copyFileSync(TEMPLATE_PATH+"/screens/home_screen/script.js","./"+e+"/screens/"+n+"/script.js"),fs.copyFileSync(TEMPLATE_PATH+"/screens/home_screen/style.css","./"+e+"/screens/"+n+"/style.css"),console.log(`Screen ${n} created`)},CreateComponent:({app_name:e,component_name:n})=>{if(fs.existsSync("./"+e+"/components/"+n))return void console.log(`Component ${n} already exists`);let a=fs.readFileSync(TEMPLATE_PATH+"/components/NewComponent.js","utf-8").replace(/NewComponent/g,n);fs.writeFileSync("./"+e+"/components/"+n+".js",a),console.log(`Component ${n} created`)},Build:({app_name:e})=>{let n=WEBAPPKIT.ReadManifest({app_name:e});if(n){let a=fs.readFileSync(TEMPLATE_PATH+"/index.html","utf-8").replace(/{{ APP_LANG }}/g,n.lang??TEMPLATE_APP.Lang).replace(/{{ APP_THEME_COLOR }}/g,n.theme_color??TEMPLATE_APP.ThemeColor).replace(/{{ APP_NAME }}/g,n.name??TEMPLATE_APP.Name).replace(/{{ APP_SHORT_NAME }}/g,n.short_name??TEMPLATE_APP.ShortName).replace(/{{ APP_DESCRIPTION }}/g,n.description??TEMPLATE_APP.Description);fs.writeFileSync("./"+e+"/index.html",a),console.log("Build successful")}},Start:({port:e,app:n,open:a})=>{liveServer.start({port:e??3e3,host:"localhost",root:n,open:a??!1,logLevel:2})},Help:()=>{console.log(HELP_MESSAGE)}},args=process.argv.slice(2);function getParamValue(e){let n=args.findIndex((n=>n==`-${e}`||n==`--${e}`));return-1!==n&&n+1<args.length?args[n+1]:null}function hasParam(e){return args.some((n=>n==`-${e}`||n==`--${e}`))}switch(process.argv[2]){case"init":WEBAPPKIT.Init();break;case"help":WEBAPPKIT.Help();break;default:if(fs.existsSync(process.argv[2])&&fs.statSync(process.argv[2]).isDirectory())switch(process.argv[3]){case"screen":!async function(){let e=await prompts({type:"text",name:"screen_name",message:`Set your screen name : (${TEMPLATE_APP.NewScreen}) `,initial:TEMPLATE_APP.NewScreen}),n=WEBAPPKIT.ReadManifest({app_name:process.argv[2]});n&&n.lang&&WEBAPPKIT.CreateScreen({screen_name:e.screen_name,app_name:process.argv[2],app_lang:n.lang})}();break;case"component":!async function(){let e=await prompts({type:"text",name:"component_name",message:`Set your component name : (${TEMPLATE_APP.NewComponent}) `,initial:TEMPLATE_APP.NewComponent});WEBAPPKIT.CreateComponent({component_name:e.component_name,app_name:process.argv[2]})}();break;case"build":WEBAPPKIT.Build({app_name:process.argv[2]});break;case"start":let e=getParamValue("p")||getParamValue("port"),n=hasParam("l")||hasParam("launch");WEBAPPKIT.Start({port:e?parseInt(e,10):3e3,app:process.argv[2],open:n||!1});break;default:WEBAPPKIT.Help()}else null!=process.argv[2]?console.log("App not found, check help command"):WEBAPPKIT.Help()}
{
"name": "wakx",
"version": "1.1.5",
"version": "1.1.6",
"description": "Manage WebAppKit framework",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -45,3 +45,3 @@ # Web App Kit framework

super();
// Add events listener like this.onclick
// Add events listener or other
}

@@ -54,2 +54,7 @@

}
update() {
// Optional
// Define processing after displaying the component and its updates
}
}

@@ -56,0 +61,0 @@

@@ -1,1 +0,1 @@

class CustomComponent extends HTMLElement{constructor(){super(),this.innerHTML=this.render();let e=this;new MutationObserver((t=>{t.forEach((()=>{e.innerHTML=e.render()}))})).observe(this,{attributes:!0})}get properties(){return Object.values(this.attributes).reduce(((e,t)=>(e[t.name]=t.value,e)),{})}}const App={navigate:e=>{parent.document.getElementById("app-screen").src="./../screens/"+e+"/screen.html"},getResourceURL:e=>"./../../resources/"+e,addComponent:(e,t)=>{let n=document.createElement("script");n.type="module",n.src="./../../components/"+t+".js",document.head.appendChild(n),customElements.define(e,t)}};export{CustomComponent,App};
class CustomComponent extends HTMLElement{constructor(){super(),this.innerHTML=this.render(),this.update();let e=this;new MutationObserver((t=>{t.forEach((()=>{e.innerHTML=e.render(),this.update()}))})).observe(this,{attributes:!0})}update(){}get properties(){return Object.values(this.attributes).reduce(((e,t)=>(e[t.name]=t.value,e)),{})}}const App={navigate:e=>{parent.document.getElementById("app-screen").src="./../screens/"+e+"/screen.html"},getResourceURL:e=>"./../../resources/"+e,addComponent:(e,t)=>{let n=document.createElement("script");n.type="module",n.src="./../../components/"+t+".js",document.head.appendChild(n),customElements.define(e,t)}};export{CustomComponent,App};

@@ -15,4 +15,6 @@ import { CustomComponent } from "../app/App.js";

}
update() {}
}
export { NewComponent };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc