Skip to content

Instantly share code, notes, and snippets.

View revanth0212's full-sized avatar

Revanth Kumar Annavarapu revanth0212

View GitHub Profile
[
{
"name": "Vitalia Top",
"discount": 12
},
{
"name": "Jillian Top",
"discount": 15
},
{
@revanth0212
revanth0212 / mesh-build-webpack.config.js
Created October 27, 2022 15:38
Webpack config to build mesh config artifacts into single JS file
const path = require("path");
const webpack = require("webpack");
const entry = "./src/actions/mesh/handler.js";
module.exports = {
entry,
target: "node",
output: {
library: {
@revanth0212
revanth0212 / pwaCacheClean.js
Created August 10, 2021 22:30
While using PWA Studio's scaffolding command if you run into any errors or if you notice the command using old packages, run this file to clear your cache and try again.
const fs = require("fs");
const os = require("os");
const { promisify } = require("util");
const exec = promisify(require("child_process").exec);
const temptdir = os.tmpdir();
if (fs.existsSync(`${temptdir}/@magento`)) {
fs.rmdirSync(`${temptdir}/@magento`, { recursive: true });
@revanth0212
revanth0212 / getPackagesWithInstallScripts.js
Created March 31, 2021 01:21
Get a list of all the packages that have pre and post install scripts to access the extent of damage we can cause by using --ignore-scripts flag while running npm.
// lets check which packages have pre and post install scripts
const fs = require('fs');
const path = require('path');
const verifyNodeModulesExists = folderPath => {
return fs.existsSync(folderPath);
};
const getPackageJsonPath = (folderPath, packageName) => {

Zetlen has made changes that are not publised yet that make extensibility a piece of cake.

It starts with adding a new target in the declare file.

//We are adding an extension point in the venia UI declare file which an extension developer can use to add JSX to the buttons section of the product details page.

buttonActions: new targets.types.AsyncSeriesWaterfall(['actions'])
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@revanth0212
revanth0212 / compose_implementation.js
Last active September 12, 2019 17:06
Custom implementation of Ramda's Compose Function without any dependencies. This function has been implemented with tail recursion, so no more stack overflow issues.
/**
* Compose function
*/
function _compose(functions, param) {
const lastFunction = functions.pop();
const result = lastFunction.call(null, param);
return functions.length === 0 ? result : _compose(functions, result);
}
@revanth0212
revanth0212 / LifeCycleMethodsUsingHooks.js
Last active August 31, 2019 16:59
A sample Hooks component demonstrating Life Cycle Methods Composition.
function useLikes() {
const [likes, setLikes] = useState(0)
const [likedByMySelf, setLikedByMySelf] = useState(false)
useEffect(() => {
fetchLikes().then(({ likes, likedByMySelf }) => {
setLikes(likes)
setLikedByMySelf(likedByMySelf)
})
}, [])
const onLike = () => {
[
{
"name":"country",
"path":[
"fields",
"country"
],
"props":{
"value":"USA"
}
@revanth0212
revanth0212 / HowToUseFieldCalculator.js
Created August 5, 2018 17:06
A sample to show how to use the field changes calculator.
const calculator = require('field-change-effects-calculator');
const changesCalculator = calculator(rules);
const calculateChanges = (event) => {
const state = getState()
const { name, value } = event.target
const changes = changesCalculator(state)(name, ['path', 'of', 'field', 'in', 'the', 'state', 'object'], value)
return changes
}