Django 2.0,
Node.js 8.11.4
I have a djanog project of the format:
reactify/
└── src/
├── reactify-ui/
| ├── build/
| | └── static/
| | └── js/
| | └── main.3425.js
| └── package.json
└── staticfiles/
└── js/
└── reactify-django-us.js
I want to replace the content of \reactify\src\staticfiles\js with what is in \reactify\src\reactify-ui\build\static\js\*
My packages.json looks like this
"scripts": {
...
"copy-build-js": "copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'",,
...
}
When I run npm copy-build-js I get the following output:
> reactify-ui#0.1.0 copy-build-js C:\Users\Owner\dev\reactifydjango\src\reactify-ui
> copyfiles -f 'build/static/js/*.js' '../staticfiles/js/'
It looks like it works, but when I inspect the file in the target location ../staticfiles/js/, it hasn't changed.
I validate it by
changing the file before I run the command,
do an `ls -lrth` to get the timetamp,
wait a minute so the timestamp changes,
run the command `npm copy-build-js`,
and then doing an `ls -lrth` on the target location and seeing that the timestamp isn't post hasn't changed.
I also look at the file and it is the same.
Why would the copyfiles not work?
You have the structure correct, but the copyfiles package has some quirks that you missed. Use this as your script:
"copy-build-js": "del /F \"../staticfiles/js\" && copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js"
The double quotes here are required, so you need black slashes before each to escape them.
The copyfiles package does not have an option to replace all files in a directory even if the filenames don't exist, so first you have to run del /F \"../staticfiles/js\" to delete all files in the src/staticfiles/js directory. This command assumes you're on Windows.
Then you run copyfiles -E -f \"./build/static/js/*.js\" ../staticfiles/js. What you missed was that when using wildcards/globs with this package (*), you have to double quote the location. If a location doesn't have a wildcard in it, you don't need quotes at all. I added in the -E flag that will throw an error if files aren't copied, which could potentially save you trouble later on.
Related
I made a React app that I want to build for different servers / customers.
I created a folder configurations with different .env files. E.g.: .env.foo, .env.bar, .env.tree, .env.mirror, .env.backup.
To point three values out as an example I have:
REACT_OWNER_NAME=Malcom X
REACT_OWNER_MAIL=mx#mail.com
REACT_FTP_FOLDER_PATH=foo.domain.com
In my App.js I have
const App = () => {
return (
<>
{process.env.REACT_OWNER_NAME}<br />
{process.env.REACT_OWNER_MAIL}
</>
);
}
Now I want to place each configurations/.env* file in the root, build the app and deploy it to the different servers.
To automate this, I build the following builder.sh script:
mv .env env
for CURR in foo bar tree mirror backup
do
cp configurations/.env.$CURR .env
export $(cat .env | grep -v '#' | awk '/=/ {print $1}')
if [ -z ${REACT_FTP_FOLDER_NAME+x} ]; then foldername=$CURR; else foldername=$REACT_FTP_FOLDER_NAME; fi
yarn build
mkdir apps/${foldername}
mv build/* apps/${foldername}/.
rm -rf build
mv .env apps/${foldername}/.env
done
mv env .env
Now my issue: When I run the script with for CURR in foo, then for CURR in bar and so on (each file one by one) I have no issue, I get all the apps build into apps/.
But when I run it with for CURR in foo bar tree mirror backup the output is the same, but when I log process.env all variables containing a space get cut off by the space.
When I just yarn build the apps, no issue. When I add "" around the strings I get REACT_OWNER_NAME: "\Malcom".
In every case when I compare configurations/.env.foo with apps/foo.domain.com/.env there is no difference between the files.
And the funnies thing... the first app (in this example foo) is correct.
So I have this codegen.yml
overwrite: true
schema:
- ${REACT_APP_GRAPHQL_URL}:
headers:
'x-hasura-admin-secret': ${REACT_APP_GRAPHQL_ADMIN_SECRET}
documents: "./src/**/*.{ts,tsx}"
generates:
src/generated/graphql.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
config:
withHooks: true
My .env looks like this:
REACT_APP_GRAPHQL_URL=https://somesite.com/graphql
REACT_APP_GRAPHQL_ADMIN_SECRET=abcde1234
but it failed everytime I run codegen npm run codegen and npm run codegen -r dotenv/config. I've tried changing up the quote marks, spaces etc but it still doesn't work. When I replace the environment variable with the URI and admin-secret, it runs fine. What did I do wrong?
Not the best solution but it's worked for me
Add your variebles before calling script like:
REACT_APP_GRAPHQL_URL=$(grep REACT_APP_GRAPHQL_URL .env | cut -d '=' -f2)
so script should looks like
"scripts": {
"graphql-codegen": "REACT_APP_GRAPHQL_URL=$(grep REACT_APP_GRAPHQL_URL .env | cut -d '=' -f2) REACT_APP_GRAPHQL_ADMIN_SECRET=$(grep REACT_APP_GRAPHQL_ADMIN_SECRET .env | cut -d '=' -f2) graphql-code-generator --config ./codegen.yml",
},
Then just run
npm run graphql-codegen
I was just wondering what’s the best way to configure codecov for a monorepo setting. For example, let’s say I have packages A and B under my monorepo. The way I’m currently using codecov is by using a github action codecov/codecov-action#v1, by using multiple uses statement in my GitHub workflow YAML file like the following:-
- uses: codecov/codecov-action#v1
with:
files: ./packages/A/coverage/lcov.info
flags: flag_a
name: A
- uses: codecov/codecov-action#v1
with:
files: ./packages/B/coverage/lcov.info
flags: flag_b
name: B
I know it's possible to use a comma-separated value to upload multiple files, but I have to set a separate flag for each package, and doing it that way doesn't seem to work.
Thank you.
If anyone wants to know my solution, heres what I came up with.
I ended up replacing the github action with my own bash script.
final code
#!/usr/bin/env bash
codecov_file="${GITHUB_WORKSPACE}/scripts/codecov.sh"
curl -s https://codecov.io/bash > $codecov_file
chmod +x $codecov_file
cd "${GITHUB_WORKSPACE}/packages";
for dir in */
do
package="${dir/\//}"
if [ -d "$package/coverage" ]
then
file="$PWD/$package/coverage/lcov.info"
flag="${package/-/_}"
$codecov_file -f $file -F $flag -v -t $CODECOV_TOKEN
fi
done
this is what the above bash script does
Downloading the bash uploader script from codecov
Moving to the packages directory where are the packages are located, and going through all the 1st level directories
Change the package name by removing extra slash
If the directory contains coverage directory only then enter into it, since only those packages have been tested.
Create a file and flag variable (removing hypen with underscore as codecov doesn't support hypen in flag name)
Executed the downloaded codecov script by passing the file and flag variable as argument
Background
I am following some instructions from a teammate. These instructions include a command to checkout, then copy .a files from a make command from one vob to another. The commands were given to me as such:
ct co -nc -unr /vobs/sbov/ABC/libs/qwert/*.a
find . -name '*.a' | grep -v ABCDE | xargs -I {} cp {} /vobs/sbov/ABC/libs/quert
This should have no problem working normally...except recently numerous .a files in that directory have changed from files to symlinks. Symlinks are not clearcase elements. Therefore, the commands attempted to checkout, then copy to, various non-clearcase entities as opposed to the actual files. Hence my question...
Question
How do I modify the commands above to manipulate the actual files the symlinks point to, as opposed to the symlinks themselves?
Try first a cp with a de reference option
find . -name '*.a' | grep -v ABCDE | xargs -I {} cp -L {} /vobs/sbov/ABC/libs/quert
^^^^^^^^
That should help getting actual files instead of symlinks.
I have an OCaml project, for which I use ocamlbuild.
In this project, I have two subprojects, subproject1 and subproject2.
subproject2 needs to use a module called Module from subproject1.
To sum up, I have the following structure:
project/
|
|-- subproject1
| |
| |-- module.ml
|
|-- subproject2
|
|-- main.ml
If module.ml were located in subproject2, next to main.ml, I'd simply use the open directive in subproject2/main.ml:
(*subproject2/main.ml *)
open Module
But since module.ml is located in subproject1, how can I tell ocamlbuild to open subproject1/module.ml?
While I haven't found any straightforward way to include or directly link a source file, I've come up with a way to effectively include a module from a sibling directory.
Once again, here is the structure of the project:
project/
|
|-- subproject1
| |
| |-- module.ml
|
|-- subproject2
|
|-- main.ml
From the project directory, the following ocamlbuild command will compile the whole project, with subproject2/main.ml as target, and subproject2/_build/ as output build directory:
ocamlbuild -I subproject1 subproject2/_build/ subproject2/main.byte
The expected main.byte file will however be output as subproject2/_build/subproject2/main.byte, so manual link editing will be necessary to end up with the usual main.byte symlink in subproject2.
Since I like being able to use make, I wrote the following Makefile in subproject2/, so as to compile subproject2/ by simply running make from the inside, as make is supposed to work.
all:
# Move to project/
cd ..;\
# Run the ocamlbuild command
ocamlbuild -I subproject1 subproject2/_build/ subproject2/main.byte\
# Go back into subproject2
cd subproject2;\
# Try to remove the existing symlink, mute stderr, and continue on error
rm main.byte 2> /dev/null || true;\
# Create the desired symlink
ln -s _build/subproject2/main.byte main.byte