cPanel auto-deploy repository and run npm script - apache

I've locally written code for a website that has since been pushed to a private github repository owned by my organization. I would like to set up my Apache web server's subdomain to automatically pull that code every time a push is made to a certain branch of the Github repo.
I've read many documentations and tried many things, nothing seems to be working for me.
Could someone please provide detailed steps or a method that has worked for them in this situation?
EDIT
With cPanel's Git Version Control Tool and SSH keys, I've been able to get my repository cloned properly. Now, I still need a way to make cPanel run "npm run start" every time the repository is deployed. Any thoughts?

Related

How make changes on vue project in hosting

I have vue project which published on Digital Ocean. The main problem is when i make some changes on FileZilla it is not affect on website. How can i solve this issue?
This is not an issue per-se. This is just the way how modern web development works. Vue.js (but also Nuxt) is using a bundler right now (Webpack, Vite are the most common), hence to go to production it needs to be bundled each time you push something to it.
If you upload something via FTP or SSH and edit some source code, a bundle step will be required in order to get any changes on the actual webapp.
Backend languages may not need that, for example you could SSH into a server and change some .php file, if you F5 the page it will be updated in real time. But this is not how frontend JS code works, it needs to be optimised.
Another thing, sending code via SSH/FTP is not really a good workflow because it is not easily trackable, no version-controlled, will not trigger any build flags in case of an error etc...
The best approach is to have a git repo + some build step included in some CI.
A common platform for it is Netlify, you connect a Github repo, you tell which command to use to build the project and each time you push some code, it may do some checks/tests/optimizations/etc... via Github Actions before being released automatically to production (updated on your webapp).
This workflow have a lot of benefits as one may tell but is also de-facto, the official/regular approach for modern Web development on the frontend.

How to overwrite beta versions in private gitlab NPM registry

I am currently working with GitLab-CI and one problem that I have is that I need to use unique version names in my NPM registry. Now, while I really like this feature with NPM in the open world, in development when pipelines are run on development branches for features not released, this is somehow annoying since the registry gets filled up with trash pretty easily.
There are 2 ways I can think of to accomplish using the same version like 0.1.0-alpha again.
npm unpublish
is not available in the GitLab registry at the moment
use curl and GitLab api to delete repository first
This will probably the way I go if no one has a better solution, but I don't really like this approach as I don't want my pipeline and repositories being full with shell scripts that need maintaining.
Are there any more elegant solutions to this problem?

Can't see or publish packages with Verdaccio

I’m fairly new to Verdaccio. Been familiar with the tool for quite some time, but this is my first time trying to use it. I’ve installed it locally for the purpose of trying to figure out the right syntax for handling versioning, tagging and publishing a shared component library for work, but I’m having trouble getting this package published to my locally running instance of Verdaccio, and I’m struggling to understand why the publish command is failing. Was hoping someone here might be able to help.
First off, I should say that I have it installed and running locally, I can browse to http://localhost:7890 and see the Verdaccio web UI, and it says that I have “No package published yet.” That makes sense, because I haven’t been able to successfully publish anything yet. I’ve created a user with the npm adduser —registry http://localhost:7890 command, and then after that I ran the following command to attempt to publish to it: npm publish —access public —registry http://localhost:7890. When I run this command, I get the following error: “EPUBLISHCONFLICT … Cannot publish over existing version.”
Now, I can in fact see, when I look in .local/share/verdaccio/storage that there is a folder for the scope that I published with, and in that folder, there is a folder for the package that I apparently published, and it only has a package.json file in it. I’ve attempted to wipe this all clean, reinstall Verdaccio, etc, etc, nothing seems to fix the issue. I can’t seem to make this package go away, OR to get it to display in the UI either. After publishing (unsuccessfully), and despite the face that it says this version of the package exists, I still see nothing in the UI. It still just says “No package published yet”, which I still don’t really understand.
Any ideas would be appreciated. This has me pretty stumped. Thanks.
Add your package.json name as npm registry (it needs the same one you published the last time).
I was getting this issue:
The following works for me:
npm publish --registry=http://yourhost:yourport

How to install npm packages from Telerik private repository in VSTS build?

I have a nice application where I'm using Telerik's Kendo UI for Angular 2. It is getting better and better. I would like to setup my builds in VSTS where installing packages, compiling TypeScript files are part of the build. Getting packages from Telerik repository requires authentication. I haven't found so far any usable description how to do it.
Telerik says that I should either directly authenticate or use .npmrc file and refers to an MS site.
The funny thing is that npm login (which is needed to connect Telerik's npm repo) does not accept username and password as parameter (doesn't matter how the community screams for it). I don't know why Telerik refers to this.
The .npmrc option is also funny, because it says that I should use vsts-npm-auth package to get credentials. I assume it means that I'll get the credentials of the build machine and it will be written in .npmr file. It is not a good solution for me. I got the build machines from a pool and the credentials rather a strongly limited credentials (enough fora build machine and nothing more) which does not equal my username and password at Telerik.
So, that's where my story ends and I need some help from you guys. How to do it? Did I misunderstand something? Is there anybody out there who did it?
First, vsts-npm-auth is used for VSTS.
Secondly, after logging in (npm login) the .npmrc will be populated with an authentication token that can be copied to build agents or store file per-project. So try to use this .npmrc file and check the result.
It figured out that vsts-npm-auth doesn't work together other private repositories than VSTS feeds. I let the team know and they, hopefully, will implement it.

Steps to get angular 2 universal starter to deploy to an external server host (Google Cloud, Azure, etc)?

I cloned universal-starter (webpack version) and have it up and running on my local machine using npm start and npm run watch per the instructions
Now stuck after npm run build and attempting to deploy to Azure (and Google Cloud) via the github integration - can't figure out how to set up either to work.
Anyone have a recipe on how to get the webpack bundled files to fire up on an external host with express.js? Do I need to run commands via a CI integration? The files in /dist don't seem to stand on their own.
At Netlify you can connect your git repo and tell them what build commands you want them to use. If you specify the "dist" directory, then they will deploy anything that gets in there (after they have compiled your application).
Edit: the lowest tier is free.
Edit2: I am not associated with Netlify. I just used them in my latest deploy, and found the process extremely easy.
Note: This has changed dramatically since Angular 2. While I'm now moved on to SSR, docker, and all kinds of other things, the simplest answer was to
1) Production build
ng build --prod
2) Transfer files to a static web host (i.e., I used awscli to connect to a s3 bucket when it was just a static site...I know use SSR so I need to use a node server like express)
3) Serve files (there are some complexities for redirect requirements for index.html for error and for 404...and of course setting the status for both redirects to 200)
4) Put something on the frontend for performance/ ssl/ etc. nginx or a CDN would make sense.