The Lazy Developer Guide: How to Automate Code Updates?

Rate this content
Bookmark

How to update hundreds of projects all at once? With organizations rapidly growing, demand for the scalability of the teams grows which directly impacts projects structure and ownership. The usual dilemma is mono- vs. multi-repos, but ... What if I tell you that it does not matter much? Both approaches can punch you in the face at some point, so perhaps it is better to think bottom-up.


Today I will walk you through some of the biggest challenges that exist in both approaches and those are managing dependencies across a few hundred projects, global code updates and many other things. I will also show you examples of how we solved this inside Infobip through building our own internal libraries.

This talk has been presented at DevOps.js Conf 2022, check out the latest edition of this JavaScript Conference.

FAQ

Ante is a senior software engineer at Neo4j with nearly 6 years of experience. He focuses on bad infrastructure and is also a frequent speaker at meetups.

Ante has several interests including React, Webpack, Application Build, Application Optimization, Performance, Web Architecture, Automation, and User Experience.

Ante's presentation focuses on code automations, particularly how repetitive tasks are managed and automated in software development using Neo4j.

Ante mentioned several tools for automation, including ESLint, ShellJS for executing Unix commands, and oclf for CLI tasks.

Ante highlights automation as a crucial element to save time, reduce repetitive tasks, and improve efficiency in handling multiple projects, emphasizing working smart over just working hard.

Ante discusses updating dependencies in projects, such as upgrading from React 16 to React 17, and automating linting in codebases to enhance code quality.

Ante believes that choosing to automate tasks reflects a desire to work efficiently rather than lazily, aiming to allocate more time to challenging and impactful tasks.

Outside of his professional work, Ante is passionate about photography, which he shares on his Instagram blog.

Ante Tomić
Ante Tomić
22 min
25 Mar, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Code automations can save time and effort in development tasks. There are tools and examples available for automating tasks like updating dependencies and code formatting. Automation allows teams to focus on valuable work and improves overall performance. Deciding when to automate depends on the impact and type of code. The last automated task discussed was applying translation updates to multiple projects.

1. Introduction to Code Automations

Short description:

Hi all and I'm sending you a big hello from Croatia. Today, I will talk about code automations and how we did them in Neo4j. Working smart and choosing battles wisely are key in development. Thinking is a powerful tool, but we should avoid overthinking. Let's jump into the coding examples and explore the dependencies in the package.json file.

Hi all and I'm sending you a big, big, big hello from Croatia. My name is Ante and I am going to talk to you today about very interesting topics which are code automations and how we did them in Neo4j. I hope that you will enjoy my session so let me begin.

Hi, I'm Ante and I'm 28 years old. I am senior software engineer working in Neo4j for nearly 6 years and I am focused on bad infrastructure. I am also a frequent speaker on meetups and and I have a lot of interests like React, Webpack, Application Build, Application Optimization, Performance, Web Architecture, Automation and Experience. And you know everyone who knows me would tell you that I am a huge photography buff and I love photography and I'm a happy photographer. So if you are interested, feel free to check out my photography blog on Instagram but let me start from a question, how do you handle repeating tasks at work? This is something I would like you to answer in the poll so let's see, maybe we are doing copy, paste and then repeat, repeat and repeat for the same thing or for example, we count 20 projects and then we change the same thing in all of them. Well, we do have a lot of repetitive tasks and this can take us a lot of time, especially with you know 50 or more projects, and we can see like in this blue line that we can do this manually you know, and we can also see this red which is actually what I want to explore in this session as it is also related to the concept of automation, which is extremely important, and I would like to start from a quote and that is I will always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it and let's see actually how this applies.

First things first it is not related to that we should be lazy about learning. No, programming is a skill that takes hours and hours to perfect and we definitely should work hard to become better developers and to expand our knowledge. And then really then what the hell am I talking about? Well, we need to be able to choose our battles wisely because working hard is just as important as working smart. And in development or the missions are the key to achieving all of this and we are going to check this on a few examples. But you also need to mention thinking. Obviously it is the hardest part of development right? Especially when you have to name them. But thinking is actually a really powerful tool for the missions because it helps us produce ideas and solutions and also helps us actively seek challenges and improvements. But wait! We have to be careful not to overthink it because our time is valuable and we shouldn't spend too much time on complications as it will make it harder to support and update code in the future. Maybe we can have good intentions but our code can simply be too complex to understand. And this is something we will check in the coding examples. You can see QR code and repository link here so you can follow with me or you can check the repository later.

Okay then let's jump onto it. What I want to show you is this package.json file. This is my project for the dummy project or example one for the medical equations and I want to point your attention to these dependencies. What I have on the dependencies is CLI tool that is called oclf. Now it is your preference for what you would choose. I simply chose oclf because it is easy to integrate and it sets up a lot of stuff out of the box. So it helps me and it offers a lot of possibilities and integrations. But you know you have more options like commander or yars and of course you have oclf as well if you want to use it. But what you can also see is some other dependencies. You have some minor ones maybe less known ones like edit json file or replace-in file which you know you will maybe search for and use based on your necessity.

2. Tools, Examples, and Update Dependencies

Short description:

You have popular tools like stemware for semantic versioning, shelljs for executing unix commands in any environment, and examples of eslint-update commands and update dependencies. The eslint upgrade command has four parts: filter, cloning the project, checking migrations, and executing the main migration. The main migration command is written in index.js and additional dependencies are installed. The update dependencies step will be discussed next.

And you have more popular tools like stemware which is used for semantic versioning. It can help you you know check what version you have and if it is matching with the version that you need and yada yada yada.

Then we have shelljs which is unix-like library which offers you the option to execute unix commands in any environment like windows or mac os or linux or any of the other ones. And you know some of you definitely are familiar with uh you just go ships for doing updates and of course it can be used as well. But I would like to talk about two examples I'm going to show you.

The first one is eslint-update commands where we are simply going to check if we have eslint link fix which you can see also in packages on the right and if you check scripts here you will see that we don't have it. So we will add link fix to auto updating. The second command is update dependencies where we will simply check if we have react 16 and if we do we will simply bump the version to react 17.

Okay let's check so I have eslint upgrade commands with four parts the first one is filter where usually in gi I we use big packet api to download the package json file so that we can do some sort of quick checks. As you can see here in the filter so we use package.json file for each downloaded package.json for the project to check if we have eslint of course we have eslint so if I execute the command that you have here in the sample which can also help you you will see that I will get through azure result which means that my migration will execute. So that's the first step done. The second step is cloning the project. Every project for which we run filter every turn true will be cloned and then before executing the migration inside indexts I first check these migrations and this is a expanded filter where thanks to package package, you know, thanks to the whole project cloned, I can check absolutely anything I want to. I don't know for simplicity reasons I'm checking package.json here to simply see if I have linpicks command and since I don't have linpicks command, here you can see that it will return true. So, if I execute my migration command, it will return true and I will then be able to execute the main migration or at least it will be executed in the TI job. So, I go to index.js and I can see my main migration command. But it's written here like you can see here is additional dependencies that you usually install. This is where you will mostly use them. So, inside your migration job. And here I'm using the JSON file. As you can see here in the migrate command where I first get my path to the project, then I have added a JSON file and inside my lintfix step where I simply also check if I already have lintfix command. And if I don't have lintfix command, then I add it to a JSON file and it will also be automatically saved. And again, let's check the code sample here. So I will copy paste it and I will execute the run eslintupgrade command. And you will see here that now lintfix has appeared and I have changes inside my github project. So, voila, I know that it is working. The second step that I want to show you is update dependencies. But before I jump on to update dependencies, I want to mention briefly get migration options, which I won't get it but you can use it to get whichever options and information you need for automatic job execution or even for pull requests and that. So here you can pass, you can retrieve, you can calculate any information you need for your TI environment. But what I would like to do is I would like to jump on to update dependencies.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
NPM workspaces help manage multiple nested packages within a single top-level package, improving since the release of NPM CLI 7.0. You can easily add dependencies to workspaces and handle duplications. Running scripts and orchestration in a monorepo is made easier with NPM workspaces. The npm pkg command is useful for setting and retrieving keys and values from package.json files. NPM workspaces offer benefits compared to Lerna and future plans include better workspace linking and adding missing features.
Automating All the Code & Testing Things with GitHub Actions
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
We will learn how to automate code and testing with GitHub Actions, including linting, formatting, testing, and deployments. Automating deployments with scripts and Git hooks can help avoid mistakes. Popular CI-CD frameworks like Jenkins offer powerful orchestration but can be challenging to work with. GitHub Actions are flexible and approachable, allowing for environment setup, testing, deployment, and custom actions. A custom AppleTools Eyes GitHub action simplifies visual testing. Other examples include automating content reminders for sharing old content and tutorials.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
DevOps is a journey that varies for each company, and remote work makes transformation challenging. Pull requests can be frustrating and slow, but success stories like Mateo Colia's company show the benefits of deploying every day. Challenges with tools and vulnerabilities require careful consideration and prioritization. Investing in documentation and people is important for efficient workflows and team growth. Trust is more important than excessive control when deploying to production.
Why is CI so Damn Slow?
DevOps.js Conf 2022DevOps.js Conf 2022
27 min
Why is CI so Damn Slow?
Slow CI has a negative impact on productivity and finances. Debugging CI workflows and tool slowness is even worse. Dependencies impact CI and waiting for NPM or YARN is frustrating. The ideal CI job involves native programs for static jobs and lightweight environments for dynamic jobs. Improving formatter performance and linting is a priority. Performance optimization and fast tools are essential for CI and developers using slower hardware.
The Zen of Yarn
DevOps.js Conf 2022DevOps.js Conf 2022
31 min
The Zen of Yarn
Let's talk about React and TypeScript, Yarn's philosophy and long-term relevance, stability and error handling in Yarn, Yarn's behavior and open source sustainability, investing in maintenance and future contributors, contributing to the JavaScript ecosystem, open-source contribution experience, maintaining naming consistency in large projects, version consistency and strictness in Yarn, and Yarn 4 experiments for performance improvement.
Atomic Deployment for JS Hipsters
DevOps.js Conf 2024DevOps.js Conf 2024
25 min
Atomic Deployment for JS Hipsters
This Talk discusses atomic deployment for JavaScript and TypeScript, focusing on automated deployment processes, Git hooks, and using hard links to copy changes. The speaker demonstrates setting up a bare repository, configuring deployment variables, and using the post-receive hook to push changes to production. They also cover environment setup, branch configuration, and the build process. The Talk concludes with tips on real use cases, webhooks, and wrapping the deployment process.

Workshops on related topic

Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.
MERN Stack Application Deployment in Kubernetes
DevOps.js Conf 2022DevOps.js Conf 2022
152 min
MERN Stack Application Deployment in Kubernetes
Workshop
Joel Lord
Joel Lord
Deploying and managing JavaScript applications in Kubernetes can get tricky. Especially when a database also has to be part of the deployment. MongoDB Atlas has made developers' lives much easier, however, how do you take a SaaS product and integrate it with your existing Kubernetes cluster? This is where the MongoDB Atlas Operator comes into play. In this workshop, the attendees will learn about how to create a MERN (MongoDB, Express, React, Node.js) application locally, and how to deploy everything into a Kubernetes cluster with the Atlas Operator.
Automated accessibility testing with jest-axe and Lighthouse CI
TestJS Summit 2021TestJS Summit 2021
85 min
Automated accessibility testing with jest-axe and Lighthouse CI
Workshop
Bonnie Schulkin
Bonnie Schulkin
Do your automated tests include a11y checks? This workshop will cover how to get started with jest-axe to detect code-based accessibility violations, and Lighthouse CI to validate the accessibility of fully rendered pages. No amount of automated tests can replace manual accessibility testing, but these checks will make sure that your manual testers aren't doing more work than they need to.
Azure Static Web Apps (SWA) with Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
13 min
Azure Static Web Apps (SWA) with Azure DevOps
WorkshopFree
Juarez Barbosa Junior
Juarez Barbosa Junior
Azure Static Web Apps were launched earlier in 2021, and out of the box, they could integrate your existing repository and deploy your Static Web App from Azure DevOps. This workshop demonstrates how to publish an Azure Static Web App with Azure DevOps.
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
DevOps.js Conf 2022DevOps.js Conf 2022
163 min
How to develop, build, and deploy Node.js microservices with Pulumi and Azure DevOps
Workshop
Alex Korzhikov
Andrew Reddikh
2 authors
The workshop gives a practical perspective of key principles needed to develop, build, and maintain a set of microservices in the Node.js stack. It covers specifics of creating isolated TypeScript services using the monorepo approach with lerna and yarn workspaces. The workshop includes an overview and a live exercise to create cloud environment with Pulumi framework and Azure services. The sessions fits the best developers who want to learn and practice build and deploy techniques using Azure stack and Pulumi for Node.js.