CMS Development

PMC-RO
Member

get the list of files/folders in developer file system

SOLVE

Hi,

For our website we want to load external React apps. The production builds are deployed to CMS developer file system through a CI/CD pipeline and this works like a charm. The problem is that we did not find any way to get the list of js/css files of the build in order to load them with require_js (_css) and the names of the files changes when new builds are deployed.

Is there any way to get the list of files from a developer file system folder and then load the react app in a loop of require_js(get_asset_url(...))? But without using CMS Api or serverless functions. 

 

Thanks for any idea ..

 

0 Upvotes
1 Accepted solution
PMC-RO
Solution
Member

get the list of files/folders in developer file system

SOLVE

So ... the only solution that we found was to push the compiled React app(s) from GitHub to HubSpot dev file system through a GitHub action, together with a JSON file describing the app(s) (meaning the scripts/css files/chuncks). Of course, the JSON is in a form of a Hubl variable. Then, a custom module loads the app(s) into the page(s). 

We are open to share the solution if somebody is interested to use it.

View solution in original post

0 Upvotes
3 Replies 3
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

get the list of files/folders in developer file system

SOLVE

Hi @PMC-RO ,

 

You can use the HubSpot CLI to get a list of all the files with the `hs list [path]` command.

 

If that does not help, I would like to advise you to take a look at the React Boilerplate. Maybe it helps to solve your issue.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
PMC-RO
Member

get the list of files/folders in developer file system

SOLVE

Hi,

Thanks for the reply.

 

Hubspot CLI is not a solution since it cannot be used inside a module. 

 

We thought to make use of the React boilerplate but we did not find a way to do it. To be more specific, we only deploy the production build files (chunks) and we need to load them.

 

We thought that there is a function like as scandir() in PHP which returns the list of children of a folder (files or sub-folders). 

 

Of course, technically, we can use CMS Api (source -code endpoint) to get the list we need but this require some kind of authentication that shall be made on server side. This means serverless functions whic are great but we believe that are much too expensive to be used with only what we need now.

 

Will keep looking for alternatives 🙂

0 Upvotes
PMC-RO
Solution
Member

get the list of files/folders in developer file system

SOLVE

So ... the only solution that we found was to push the compiled React app(s) from GitHub to HubSpot dev file system through a GitHub action, together with a JSON file describing the app(s) (meaning the scripts/css files/chuncks). Of course, the JSON is in a form of a Hubl variable. Then, a custom module loads the app(s) into the page(s). 

We are open to share the solution if somebody is interested to use it.

0 Upvotes