How to read files in a subdirectory with node.js? - node.js

I have a subdirectory called dev inside of my root folder that I want to pull data from html files (Just the <title> element).
root
|- dev
| |-foo.html
| |-bar.html
|
|--main.js
|--package.json
|--...
My main application runs in the root and watches for changes. I need the application navigate to the dev folder and run my script, asynchronously. I used:
process.chdir('../root/dev');
to change the directory but my application quits.
How do I change directories without my application dying?

Related

AWS CodeDeploy deployment error with wrong file name in deployment-archive folder

I have a .NET 6 project running with our CICD on aws CcodeDeploy, and here is the error from CodeDeploy deployment:
The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/{guid}/d-xxxxxxx/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/{guid}/d-xxxxxxx/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at http://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html View more.
However, when I login into the LINUX instance and can find the files under /opt/codedeploy-agent/deployment-root/0596c43c-d025-448a-8999-9675455ad44c/d-VE62UHKSH/deployment-archive, but their file name all look like: XXX\wwwroot\locales\zh.json, XXX\appspec.yml. I have no idea why CodeDeloy unzip the file like this which I never ever meet before.
Actually, the source code structure is:
RootFolder
|
| __ wwwroot
| |
| |__ locales
| |
| |__ zh.json
|
|____ Application.dll
|____ appspec.yml
So, anyone who ever met such an issue?

Why am I getting a build error from GitHub Actions when attempting to deploy a no framework static web app on Azure?

I have a simple, static website that I'm attempting to deploy as an Azure Static Web App (no framework) using GitHub Actions. My directory structure is:
├── .github/workflows/
├── css/
├── img/
├── js/
├ index.html
When I make a push to the GitHub repo, the Azure Static Web Apps CI/CD action starts the build & deploy job. In my YAML configuration file in the .github/workflows directory, I have set the following for my Repository/Build Configuration:
app_location: "/" # The app source code is in the root directory for the repo
api_location: "" # There is no API that needs to be configured
output_location: "/" # my index.html file is in the root directory for the repo
However, I get the following error in my Build and Deploy Job:
Failed to find a default file in the app artifacts folder (/). Valid
default files: index.html,Index.html. If your application contains
purely static content, please verify that the variable 'app_location'
in your workflow file (located in .github/workflows) points to the root of your application.
Why am I getting this error when I've specified where the index.html file is?
Because the deploy container was based on Ubuntu, I guessed that the output location may be getting confused with the root directory for the entire system.
So, I set the output location in the workflow YAML file to:
output_location: "./"
With that change, the build completes and the static web app deploys successfully.
I have the same problem,
I tried to run this command locally:
`npm run build`
then I checked the root folder of the app to find what is the name of the build folder and it fixed my problem.

How do I get Kudu to leave out a few folders from my repo?

I have a git repo with a website that has the following structure:
repo_root:
- what_a_nice_day_it_is_today.txt
reference
- countries.txt
docs
- foo.txt
src
- index.html
content
- index.css
scripts
- index.js
I have created an Azure App Service using the Web App template for my web application. In the Deployment Center, I have chosen to deploy from my GitHub repo and have chosen Kudu as the build server.
How do I get Kudu to not copy anything other than the contents of the src folder (and its subfolders) when deploying my web app?
That is, I want it to leave out the docs folder and the reference folder and any file that's in the repo_root but not in the src folder, which, in this example is the what_a_nice_day_it_is_today.txt file.
Define SCM_TARGET_PATH and PROJECT env accordingly. See https://github.com/projectkudu/kudu/wiki/Deploying-inplace-and-without-repository.

Cannot find module '/parse/cloud/main.js' in Docker Parse Server

I am working with Docker Parse Server and I am trying to get some cloud code working.
It does work with the basic example (section "Server Side Developments" in the link given above) where my git repository just contains a main.js like so:
(root)
|
|- main.js
However, when I try to upload a Parse Example Project, I am not getting to the point that this is working. The project is structured as follows:
(root)
|
|- cloud
| |- main.js
|
|- public
| |- assets
| |- ...
|
|- index.js
|- package.json
|- ...
The error I keep getting is "Error: Cannot find module '/parse/cloud/main.js'" because the main.js is not in the root folder of my uploaded project anymore, but in a subfolder "cloud". Also, it is completely ignoring the other files. My guess is that the mounting point of the git repository is at "/parse/cloud" although it should be "/parse". Any ideas how to fix that? I already added an issue for it (sorry, no more than two links aloud for me here). Thank you!
Btw.: I use docker compose to start the parse server and all its docker friends..
USER1=some_user USER1_PASSWORD=some_password PARSE_DASHBOARD_VIRTUAL_HOST=subdomain1.some_domain.com PARSE_DASHBOARD_LETSENCRYPT_HOST=subdomain1.some_domain.com PARSE_DASHBOARD_LETSENCRYPT_EMAIL=mail#some_domain.com PARSE_SERVER_VIRTUAL_HOST=subdomain2.some_domain.com PARSE_SERVER_LETSENCRYPT_HOST=subdomain2.some_domain.com PARSE_SERVER_LETSENCRYPT_EMAIL=mail#some_domain.com SERVER_URL=https://subdomain2.some_domain.com/parse PARSE_DASHBOARD_ALLOW_INSECURE_HTTP=0 APP_ID=some_id MASTER_KEY=some_master_key docker-compose -f docker-compose-le.yml up
Here is what I've done to get this working using the official parse-server docker image.
docker run --name dev-parse-server --link dev-mongo:mongo -v /app:/app
-p 80:1337 parseplatform/parse-server:2.2.25-beta.1 --appId betaId --masterKey foo --databaseURI mongodb://mongo/test --cloud /app/cloud/main.js
The part that is important is to pass the full path to main.js. I also happen to use a local folder that holds my cloud code.

Committed folders pushed to heroku don't make it

I'm having a weird issue when pushing my app to heroku.
It's an angularjs front app with a basic nodejs server to be able to run it on heroku.
I'm pushing a deployment branch with all the app already "compile" by grunt in a /dist folder
My problem is in the /dist/public directory, I have 4 folders : js, css, img and fonts ; but after a push and checking on the dyno with heroku run bash, only the img one is in /dist/public, the 3 others aren't there.
I try to do a new push, renaming the public folder to another name (ie shared) and this time, all 4 folders are there, so it seems heroku's doing something with folders named public but I can't figure why and how to avoid this suppression/ignoring thing.
Has any of you encountered the same issue, and how to resolve it without having to rename my public folder ?
EDIT :
Adding my .gitignore file for those of you wondering about that:
/.vagrant/machines
/node_modules
/app/bower_components
/.sass-cache
/test
/app/src/lib/config.js
/dist
Do a git add -f dist/public/js dist/public/css dist/public/fonts from within your repo.
You have a .gitignore rule for /dist, which will ignore any files within /dist and its subdirectories, unless they are already being tracked. My guess is, that the files you have newly generated were not being tracked earlier, and hence they were silently ignored.
The -f flag in the git add above will add those forcefully (overriding the ignore rule), and so you will be able to make commits.
If there are only a few files, and you want to avoid adding the whole folders, I would suggest adding each of the individual files forcefully (i.e., with the -f flag).

Resources