How to find static path in create react app? - css

I (using windows) have implemented the code given here. For which when I do npm run winBuild where winBuild is "winBuild": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build" I get the below image in my console
and
The post build I have is "postbuild": "purgecss --css build/static/css/*.css --content build/index.html build/static/js/*.js --output build/static/css && find /path/to/build/static -type f \\( -name \\*.js -o -name \\*.css \\) -exec gzip {} \\; -exec mv {}.gz {} \\;"
Taken from above link. But then I realise that it is asking for /path/to/build/static which will vary. How do I find path to static files in create-react-app and if this file name will vary how am I getting File sizes after gzip: as shown in image in my console?
In the Docker container in Linux machine, it's throwing an error as No such file or directory.

Related

Recursively execute latexmk -c on folders

I'd like to execute the command latexmk -c on all of the directories inside a directory, e.g.,
.
./test-dir
The effect is to remove all of the auxiliary files created curing latex compilation.
I've tried using the find command to tell me about the directories and then execute a command, like so:
find -type d -exec latexmk -c \;
But unfortunately, that command only has the effect of removing the auxiliary files in the directory in which I call it, not in the subdirectory (test-dir in this example).
I had a very similar problem: I wanted to convert .tex files recursively. The final solution for me was:
find . -name '*.tex' -execdir latexmk -pdf {} \;
The secret here is to use -execdir instead of -exec which executes the command in the directory the file was found. So the solution to your problem is most likely:
find -type d -execdir latexmk -c \;

apply a code patch to subdirectories of each project

I have over 10+ drupal websites and I need to apply a patch to each one. currently my patch resides in /home/201803.patch and my drupal websites is in the same folder. Currently I have to cd into each directory and then run the following command:
patch -p1 < ../201803.patch
but I want to just be able to do each one from the /home folder. I tried in the home folder:
patch -p1 subdirectory/ < 201803.patch
but that doesnt work. How can I patch from one directory above?
This is a question about Bash/Shell. Try the following. This will cd in every subdirectory of your current location and will then run the given command.
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && patch -p1 < ../201803.patch" \;
Or one by one:
cd subdirectory && patch -p1 < ../201803.patch && cd ..

Version placeholder in install script

We are using the Qt Installer Framework to create our product installers. Most things are running quite smoothly, but there are still some unresolved issues.
Every time we are creating a new product version, which happens quite frequently, we have to update the content of the <Version> Tag inside the package.xml. But we also need to change the name of the link created by the installer in the installscript.qs, such that the client can distinguish among two parallel installed versions of the program.
E.g. here a link like MyApplication-2.1 should appear inside the startmenu after installation.
Component.prototype.createOperations = function()
{
try {
// call the base create operations function
component.createOperations();
component.addOperation("CreateShortcut", "#TargetDir#/bin/MyApplication-2.1-vc14.exe", "#StartMenuDir#/MyApplication-2.1.lnk");
} catch (e) {
print(e);
}
}
Unfortunately, one cannot write #ProductVersion# or #Version#, instead of 2.1, referring to the content of the <Version> Tag of the package.xml. Instead #ProductVersion# and also #Version# are seemingly referring to the content of the <Version> tag inside the config.xml, which is not the desired behavior.
My problem is now, that I need to synchronize every time the versions numbers, which seems to be quite error-prone. Are there some workarounds?
On Linux, I used sed, based on this:
In the qmake file I have set up to generate the installer:
# Generate version numbers in XML files
DATE_CMD="date --rfc-3339=date"
SED_DATE_CMD="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|#DATE#|`$$DATE_CMD`|g\" \"{}\" \;"
SED_VERSION_CMD="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|#VERSION#|$${VERSION}|g\" \"{}\" \;"
SED_DATE_UNDO="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|<ReleaseDate>`$$DATE_CMD`<|<ReleaseDate>#DATE#<|g\" \"{}\" \;"
SED_VERSION_UNDO="find $$shell_path($$PWD) \\\( -name "package.xml" -or -name "config.xml" \\\) -exec sed -i \"s|<Version>$${VERSION}<|<Version>#VERSION#<|g\" \"{}\" \;"
offlineInstaller.commands = \
$$SED_VERSION_CMD && \
$$SED_DATE_CMD && \
$$QTIFWDIR/bin/binarycreator --offline-only \
-c $$PWD/config/config.xml -p $$PWD/packages $$offlineInstaller.target && \
$$SED_VERSION_UNDO && \
$$SED_DATE_UNDO
This replaces the #VERSION# and #DATE# in the XML files, builds, then puts them back. A better solution might be to copy the files out of the source tree.

Symfony2 Api-Platform bin/schema issue

I've just started Api-Platform framework and while executing:
php bin/schema generate-types src/ app/config/schema.yml
I get this:
C:\wamp\www\sf2-api>php bin/schema generate-types src/ app/config/schema.yml
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../vendor/api-platform/schema-generator/bin" &
& pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m $dir);
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/schema" "$#"
I am using Symfony 2.7.8 on window7.
I have the same issue on ubunbu 14.04.
Finally, I replace the bin directory with the one in blog-api.
Updated:
The bin-api-platform is the one generated by api-platform.
The bin-blog-api is the one I copy from blog-api. This works fine.
Use :
php vendor/api-platform/schema-generator/bin/schema generate-types src/app/config/schema.yml
instead of :
php bin/schema generate-types src/ app/config/schema.yml
The correct syntax is:
php vendor/api-platform/schema-generator/bin/schema generate-types src/ app/config/schema.yml

Formatting Find output before it's used in next command

I am batch uploading files to an FTP server with find and curl using this command:
find /path/to/target/folder -not -path '*/\.*' -type f -exec curl -u username:password --ftp-create-dirs -T {} ftp://ftp.myserver.com/public/{} \;
The problem is find is outputting paths like
/full/path/from/root/to/file.txt
so on the FTP server I get the file uploaded to
ftp.myserver.com/public/full/path/from/root/to/file.txt
instead of
ftp.myserver.com/public/relative/path/to/file.txt
The goal was to have all files and folders that are in the target folder get uploaded to the public folder, but this problem is destroying the file structure. Is there a way to edit the find output to trim the path before it gets fed into curl?
Not sure exactly what you want to end up with in your path, but this should give you an idea. The trick is to exec sh to allow you to modify the path and run a command.
find . -type f -exec sh -c 'joe=$(basename {}); echo $joe' \;

Resources