Archiver v1.3.0 - Unable to zip directory content without the directory name being the root folder - phonegap-build

I am using https://archiverjs.com/docs/ to zip a directory for my PhoneGap application but I have not yet managed to achieve what I want to.
I have a folder structured like this:
- www
- css
- images
- scripts
- config.xml
- index.html
Now what I would like to have is a zip file containing the the CONTENT of the www folder but NOT the www itself.
BAD
- www.zip
- www
- css
- images
- scripts
- config.xml
- index.html
GOOD
- www.zip
- css
- images
- scripts
- config.xml
- index.html
The code I have in place is the follow:
var archiver = require('archiver');
var output = fs.createWriteStream('./www/www.zip');
var archive = archiver('zip', {
store: true // Sets the compression method to STORE.
});
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
archive.directory('www/');
archive.finalize();
I have tried to add something like:
archive.directory('www/*');
but it throws an error.
Any other way I can accomplish that?
Thanks

I found the solution, I just needed to do the follow:
archive.directory('www', '/');
Problem solved :)
Thanks

Related

react-i18next cannot resolve key

I have a problem with react-i18next not resolving my keys, so everything I get as an output are the keys themself.
I had to embed my project as gui project to a VisualStudio solution. Running my original project works just fine, the solution project in contrast cannot resolve the key part of my translate function call.
t('user:KEY_CONSTANT') //output: KEY_CONSTANT
My i18n.config looks like this:
i18n
.use(XHR)
.init({
lng: i18nHelper.languageDetector(),
load: 'currentOnly',
fallbackLng: 'en-US',
backend: {
loadPath: 'i18n/{{lng}}/{{ns}}.json'
},
ns: ['admin', 'user'],
defaultNS: 'admin',
debug: false,
interpolation: {
escapeValue: false,
formatSeparator: ',',
format: function (vale, format, lng) {
if (format === 'uppercase') return value.toUpperCase();
return value;
}
}
});
When embedding the project in the solution, I had to change webpacks output folder, which I think is the actual reason of malfunctioning, but I can't find where exact the problem occurs. I tried changing the loadPath, but if thats the source of failure, I just didn't try it the right way :S
My project tree looks like:
Solution
|-gui
| |-src
| |-i18n
| |-de-DE(containing the german admin.json and user.json files)
| |-en-US(containing the english admin.json and user.json files)
| |-utils
| |-i18n.js
|-out
| |-prgFiles
| |-html
| |-i18n(contains same items as i18n under src)
In my old project, the webpack output was '/dist/' on the same level as src, in the solution, '../out/prgFiles/html'.
admin.json right now contains no keys at all, user.json contains the keys just like you'd expect:
{
"KEY_CONSTANT": "Actual string value"
}
As said, I tried around a bit with path changes, checked for translate, i18next and i18next-Provider beeing found and everythings fine. It just cant resolve KEY_CONSTANT to the actual value.
Do you have an idea what the problem might be?
set debug option to true in i18next init -> i bet you will get an error stating something like backendConnector failed to load namespace user...
make sure the clientside is able to load the translations (the webpack-dev server does a good job in doing so - but in production you will need to serve those file yourself)

Mix/version images in Laravel 5.4?

I want to use mix on a set of images. First I copy them:
mix.copy('resources/images', 'public/images');
Then version:
mix.version();
The above does nothing to the images.
I've also tried specifying the path:
mix.version('public/images/*');
But I get a no such file or directory error.
How can I version the images?
I know it's an old question, but for 2019 - laravel mix 4 you can use:
mix.copy('resources/images/*', 'public/images');
mix.version();
This will version all your copied files. DON'T use one of these:
mix.copy('resources/images/*', 'public/images/*');
mix.copy('resources/images/', 'public/images/*');
mix.copyDirectory('resources/images/*', 'public/images');
-> it will not version the files then.
The see the result, take a look in the public/mix-manifest.json:
"/favicon.ico": "/favicon.ico?id=ecb5fdce0172885513c8",
To use it in code, use the laravel mix helper method: mix();
<link rel="icon" type="image/x-icon" href="{{ mix('favicon.ico') }}" />
which will generate something like this:
<link rel="icon" type="image/x-icon" href="/favicon.ico?id=ecb5fdce0172885513c8" />
version() (without arguments) is not applied to files passed to copy() and copyDirectory().
If you'll look at the source of mix.version you'll see that it expands glob synchronously. But all laravel-mix operations such as copy and version are executed asynchronously. This means that public/images/* is empty because there are no files yet in public directory.
As a workaround you can list files in source directory (from which you copy files, for example resources), replace resources path segment with public and pass this list to version().
In my case I have various assets in resources directory so directory tree looks like:
- resources
| - css
| - fonts
| - images
| - js
| - less
I need to copy to public and version all these directories except less which I need to preprocess and also version.
This is like my webpack.mix.js looks like:
const mix = require('laravel-mix'),
glob = require('glob');
mix.disableNotifications();
const
directoriesToCopy = ['css', 'fonts', 'images', 'js'],
publicDir = 'public/',
publicCssDir = publicDir + 'css/',
resourcesDir = 'resources/',
resourcesLessDir = resourcesDir + 'less/',
lessFiles = glob.sync('**/*.less', {cwd: resourcesLessDir});
directoriesToCopy.forEach(d => mix.copyDirectory(resourcesDir + d, publicDir + d));
lessFiles.forEach(f => mix.less(resourcesLessDir + f, publicCssDir + f.slice(0, -'less'.length) + 'css'));
mix.version([].concat(...directoriesToCopy.map(d => glob.sync('**/*', {cwd: resourcesDir + d}).map(f => d + '/' + f))).map(f => publicDir + f));
Basically I use glob to recursively get a list of all files in each copied directory, replace resources with public in their paths and then pass list of all such files to mix.version.

Extract scss into multiple files using extract-text-webpack-plugin?

My folder structure is like this
|
|-scss/
|-main1.scss
|-main2.scss
Is it possible to use extract-text-webpack-plugin to extract these two entry points two separate files?
Currently, I'm getting it as a single file.
If you specify the two entry points in your webpack config like so:
entry: {
main1: __dirname + '/src/main1.js',
main2: __dirname + '/src/main2.js',
},
ouput: {
path: __dirname,
filename: '[name].js'
}
I assume your main1.scss is imported in the main1.js file, and main2.scss is imported in main2.js.
You can then use the [name] placeholder on the extract-text-webpack-plugin, which should create a separate output file for each entry point:
plugins: [
new ExtractTextPlugin('[name].css')
]
This should output two separate css files for you: main1.css and main2.css
Hope this helps!

NativeScript when adding custom resource/json files

I am creating a project to target Android and in it, I want it to come with a .json file from which some data will be loaded.
I put my .json file into the Android folder. When running "tns run android --device 1" (which is my physical device) I get:
-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found new input file
[aapt] Generating resource IDs...
[aapt] invalid resource directory name: /Users/konrad/Desktop/NativeScript/hello-world/platforms/android/res res
[aapt] invalid resource directory name: /Users/konrad/Desktop/NativeScript/hello-world/platforms/android/res small.json
BUILD FAILED
/usr/local/Cellar/android-sdk/24.3.3/tools/ant/build.xml:649: The following error occurred while executing this line:
/usr/local/Cellar/android-sdk/24.3.3/tools/ant/build.xml:694: null returned: 1
Total time: 0 seconds
Command ant failed with exit code 1
The file is called small.json
EDIT: Even if I remove the file, the problem still remains.
The property of Android is that it restricts access to some parts of the file system. There are two ways of accessing files on NativeScript for Android:
1) JavaScript way
var fs = require('file-system');
var documents = fs.knownFolders.documents();
var myFile = documents.getFile(filename);
as specified in the docs: https://github.com/NativeScript/docs/blob/master/ApiReference/file-system/HOW-TO.md
2) Android specific way including a third party library called "json-simple" which needs to be attached using the command tns library add android .
var context = app.android.context;
var assets = context.getAssets();
var br = new java.io.BufferedReader(new java.io.InputStreamReader(assets.open(filename)));
var parser = new org.json.simple.parser.JSONParser();
try {
parser.parse(br);
} catch (ex) {
var javaEx = ex.nativeException;
var msg = javaEx.getMessage();
console.log("whops! : "+msg);
}

Bash script to transform links and download images

I want to download all wallpapers from this gallery: http://minus.com/mPxswm5Mn
Googling I found that I could use:
wget -r -A jpg http://minus.com/mPxswm5Mn
However, the page contains the thumbnails only, and the link of the wallpapers could be found from them like the following:
Example 1:
Thumbnail url: i3.minus.com/jsyJQqqkzB66W_e.jpg
Wallpaper url: i3.minus.com/isyJQqqkzB66W.jpg
Example 2:
Thumbnail url: i1.minus.com/jNgnESZBOrhfk_e.jpg
Wallpaper url: i1.minus.com/iNgnESZBOrhfk.jpg
Any help is appreciated
This is far from a perfect solution, but you could always use your browser to list all the files you need to download and then use wget to download them :
Run this javascript snippet in your browser :
var imgs = document.getElementsByClassName("grid_item_thumb");
var html = "";
for(var i=0; i<imgs.length; ++i) {
html += imgs[i].src.replace(/\/j(.*)_e.jpg/, "/i$1.jpg") + ' ';
}
document.getElementsByTagName("body")[0].innerHTML = html;
For your specific page, it will give you this :
http://i1.minus.com/ibb1tmEYMJGWFT.jpg http://i1.minus.com/iNgnESZBOrhfk.jpg http://i3.minus.com/iitJZBqmXOYUq.jpg http://i3.minus.com/iyuCwEjztXsMF.jpg http://i2.minus.com/i0ZQNJf8vb6O2.jpg http://i2.minus.com/i6VRXhptiq1KU.jpg http://i5.minus.com/ib0H6MXLY4JeGL.jpg http://i1.minus.com/ibdwVqCRDKD8R7.jpg http://i3.minus.com/ievFZt5lDS0xy.jpg http://i4.minus.com/iHqfqOEkZDPo0.jpg http://i1.minus.com/iUe1SLFXjtyVe.jpg http://i1.minus.com/i8diPC08rFPIg.jpg http://i4.minus.com/isl4vklSl72pd.jpg http://i3.minus.com/isyJQqqkzB66W.jpg http://i7.minus.com/iriBAKsCaL92j.jpg http://i5.minus.com/im0ZKpI5FAHq0.jpg http://i2.minus.com/ilSVC7K8c0aXK.jpg http://i4.minus.com/ibmQ6r3h8SWYzI.jpg http://i3.minus.com/iVzu4QVH9azWW.jpg http://i2.minus.com/ijYWU36ege0Rr.jpg http://i1.minus.com/iQel0uLQK2Z4z.jpg http://i7.minus.com/ibk24biYBBYAeT.jpg http://i4.minus.com/ieGTVoAZaPbI2.jpg http://i2.minus.com/iuYThOzLn6XsF.jpg http://i2.minus.com/i0SAaVhrZZaL5.jpg http://i3.minus.com/ibztNp9L7zaU3F.jpg http://i5.minus.com/iJCl7B0bRahTr.jpg http://i5.minus.com/iR6Wa5uoxJFeA.jpg http://i2.minus.com/i5QHKNePLD9C0.jpg http://i3.minus.com/ibzAkM1IjGFHvR.jpg http://i2.minus.com/iqYYDjp83txiQ.jpg http://i6.minus.com/i6jFQkoAJYa1R.jpg http://i6.minus.com/ibrPBnHFyGEHQC.jpg http://i3.minus.com/iGzGyXBihCWcQ.jpg http://i4.minus.com/ibqwMh3mFNCirI.jpg http://i3.minus.com/ibvCZejMz05iH4.jpg http://i5.minus.com/iE85MKn3sMyqk.jpg http://i7.minus.com/ipixgQGKKkPw2.jpg http://i5.minus.com/iX5wooBBLIl39.jpg http://i4.minus.com/iNqvRAmIQAphd.jpg http://i6.minus.com/icj3SqCWVXDiV.jpg http://i4.minus.com/iblZFuq9kvs1Nf.jpg http://i1.minus.com/iigEYtFY87N0U.jpg http://i3.minus.com/ibtZHiIuJQTU6w.jpg http://i3.minus.com/iGujEMf2OfWIY.jpg http://i5.minus.com/ib0JPBn8i4VCNx.jpg http://i3.minus.com/ibvTyZm0l6MXiZ.jpg http://i1.minus.com/i5dJh4TYPx9bj.jpg http://i6.minus.com/ibrHdaADSSejvl.jpg http://i1.minus.com/ibcUJxQZCU49BF.jpg http://i1.minus.com/ixcoa5XdfgtCn.jpg http://i5.minus.com/ip52CdwKAz2bR.jpg http://i2.minus.com/i5KMTx22lA7bP.jpg http://i5.minus.com/iuDulPAkX9CGk.jpg http://i5.minus.com/iB3sqxh7pIuH9.jpg http://i5.minus.com/i20DFIO4GVB1h.jpg http://i6.minus.com/ibhcAIwJ8AYgJR.jpg http://i5.minus.com/ioCdy2IZSqmWx.jpg http://i3.minus.com/iby48bA5K2GP0L.jpg http://i1.minus.com/iPfaYCDuz9xwz.jpg http://i2.minus.com/inO9GQr6450Bv.jpg http://i2.minus.com/iiYxzaAKpa6A4.jpg http://i1.minus.com/ibaaCqAGnT5CAu.jpg http://i7.minus.com/ibkc4xjbf0yKEG.jpg http://i5.minus.com/iuDW7LnAKqWrf.jpg http://i5.minus.com/ib1TTRbjEOrVsd.jpg http://i1.minus.com/ivfdsnDvOm0As.jpg http://i2.minus.com/iFR7E3cVR7vFM.jpg http://i2.minus.com/iGRxohksNdi1H.jpg http://i2.minus.com/iGVYyjaP9DWgs.jpg http://i1.minus.com/ibd34cjNZysV9D.jpg http://i6.minus.com/ibhFhdBswSdRbl.jpg http://i4.minus.com/iGqdr0L18P3Kr.jpg http://i5.minus.com/iCEZ5T4sUDjHi.jpg http://i7.minus.com/ivBTUAk6cK26L.jpg http://i2.minus.com/ifO73LUD5tgQp.jpg http://i5.minus.com/i98v2HTQgcjcb.jpg http://i2.minus.com/iFLa4Zo1u8KOu.jpg http://i3.minus.com/iDzGoaFEbOK3X.jpg http://i4.minus.com/ibqzS9GS4z7gCD.jpg http://i4.minus.com/iblogFe9Op8tFk.jpg http://i4.minus.com/i5nnZ6wXLHtgn.jpg http://i4.minus.com/iCpWjYy07z7S1.jpg http://i4.minus.com/iKnkXFPRZB7W.jpg http://i3.minus.com/iby6Dg1zpdY1in.jpg http://i7.minus.com/iABhWmq0upnuz.jpg http://i4.minus.com/ibn52BzbDsG4L5.jpg http://i2.minus.com/icOC6xjysZVpu.jpg http://i4.minus.com/ism8wP4XNCW7M.jpg http://i3.minus.com/iby5hJlpTlO1I3.jpg http://i6.minus.com/ihILTGiearIR6.jpg http://i2.minus.com/idYS2bhiPdDc3.jpg http://i6.minus.com/iOj9Omn6HEnYv.jpg http://i4.minus.com/iMmgVQAXqrg4Q.jpg http://i4.minus.com/ibpZhkaaPzDtWU.jpg http://i1.minus.com/ibaOlHIsx0iJMS.jpg http://i6.minus.com/iyrZSX5TswnDk.jpg http://i3.minus.com/ibujJB04GxWwvO.jpg http://i4.minus.com/ibor2bgtCBjMp3.jpg http://i5.minus.com/ij1JjMySkCATm.jpg http://i3.minus.com/ivxToOWGkXko4.jpg http://i4.minus.com/ibllcqgDcJ8ess.jpg http://i6.minus.com/ixji9sK26KiAT.jpg http://i4.minus.com/iboh6KjVVXlIV7.jpg http://i7.minus.com/ibsod54BAoswvp.jpg http://i2.minus.com/ihRIt03KJasW0.jpg http://i4.minus.com/iMnPTCNhtyhtv.jpg
You can then copy-paste this to a console and download the images with wget :
wget http://i1.minus.com/ibb1tmEYMJGWFT.jpg http://i1.minus.com/iNgnESZBOrhfk.jpg http://i3.minus.com/iitJZBqmXOYUq.jpg http://i3.minus.com/iyuCwEjztXsMF.jpg http://i2.minus.com/i0ZQNJf8vb6O2.jpg http://i2.minus.com/i6VRXhptiq1KU.jpg http://i5.minus.com/ib0H6MXLY4JeGL.jpg http://i1.minus.com/ibdwVqCRDKD8R7.jpg http://i3.minus.com/ievFZt5lDS0xy.jpg http://i4.minus.com/iHqfqOEkZDPo0.jpg http://i1.minus.com/iUe1SLFXjtyVe.jpg http://i1.minus.com/i8diPC08rFPIg.jpg http://i4.minus.com/isl4vklSl72pd.jpg http://i3.minus.com/isyJQqqkzB66W.jpg http://i7.minus.com/iriBAKsCaL92j.jpg http://i5.minus.com/im0ZKpI5FAHq0.jpg http://i2.minus.com/ilSVC7K8c0aXK.jpg http://i4.minus.com/ibmQ6r3h8SWYzI.jpg http://i3.minus.com/iVzu4QVH9azWW.jpg http://i2.minus.com/ijYWU36ege0Rr.jpg http://i1.minus.com/iQel0uLQK2Z4z.jpg http://i7.minus.com/ibk24biYBBYAeT.jpg http://i4.minus.com/ieGTVoAZaPbI2.jpg http://i2.minus.com/iuYThOzLn6XsF.jpg http://i2.minus.com/i0SAaVhrZZaL5.jpg http://i3.minus.com/ibztNp9L7zaU3F.jpg http://i5.minus.com/iJCl7B0bRahTr.jpg http://i5.minus.com/iR6Wa5uoxJFeA.jpg http://i2.minus.com/i5QHKNePLD9C0.jpg http://i3.minus.com/ibzAkM1IjGFHvR.jpg http://i2.minus.com/iqYYDjp83txiQ.jpg http://i6.minus.com/i6jFQkoAJYa1R.jpg http://i6.minus.com/ibrPBnHFyGEHQC.jpg http://i3.minus.com/iGzGyXBihCWcQ.jpg http://i4.minus.com/ibqwMh3mFNCirI.jpg http://i3.minus.com/ibvCZejMz05iH4.jpg http://i5.minus.com/iE85MKn3sMyqk.jpg http://i7.minus.com/ipixgQGKKkPw2.jpg http://i5.minus.com/iX5wooBBLIl39.jpg http://i4.minus.com/iNqvRAmIQAphd.jpg http://i6.minus.com/icj3SqCWVXDiV.jpg http://i4.minus.com/iblZFuq9kvs1Nf.jpg http://i1.minus.com/iigEYtFY87N0U.jpg http://i3.minus.com/ibtZHiIuJQTU6w.jpg http://i3.minus.com/iGujEMf2OfWIY.jpg http://i5.minus.com/ib0JPBn8i4VCNx.jpg http://i3.minus.com/ibvTyZm0l6MXiZ.jpg http://i1.minus.com/i5dJh4TYPx9bj.jpg http://i6.minus.com/ibrHdaADSSejvl.jpg http://i1.minus.com/ibcUJxQZCU49BF.jpg http://i1.minus.com/ixcoa5XdfgtCn.jpg http://i5.minus.com/ip52CdwKAz2bR.jpg http://i2.minus.com/i5KMTx22lA7bP.jpg http://i5.minus.com/iuDulPAkX9CGk.jpg http://i5.minus.com/iB3sqxh7pIuH9.jpg http://i5.minus.com/i20DFIO4GVB1h.jpg http://i6.minus.com/ibhcAIwJ8AYgJR.jpg http://i5.minus.com/ioCdy2IZSqmWx.jpg http://i3.minus.com/iby48bA5K2GP0L.jpg http://i1.minus.com/iPfaYCDuz9xwz.jpg http://i2.minus.com/inO9GQr6450Bv.jpg http://i2.minus.com/iiYxzaAKpa6A4.jpg http://i1.minus.com/ibaaCqAGnT5CAu.jpg http://i7.minus.com/ibkc4xjbf0yKEG.jpg http://i5.minus.com/iuDW7LnAKqWrf.jpg http://i5.minus.com/ib1TTRbjEOrVsd.jpg http://i1.minus.com/ivfdsnDvOm0As.jpg http://i2.minus.com/iFR7E3cVR7vFM.jpg http://i2.minus.com/iGRxohksNdi1H.jpg http://i2.minus.com/iGVYyjaP9DWgs.jpg http://i1.minus.com/ibd34cjNZysV9D.jpg http://i6.minus.com/ibhFhdBswSdRbl.jpg http://i4.minus.com/iGqdr0L18P3Kr.jpg http://i5.minus.com/iCEZ5T4sUDjHi.jpg http://i7.minus.com/ivBTUAk6cK26L.jpg http://i2.minus.com/ifO73LUD5tgQp.jpg http://i5.minus.com/i98v2HTQgcjcb.jpg http://i2.minus.com/iFLa4Zo1u8KOu.jpg http://i3.minus.com/iDzGoaFEbOK3X.jpg http://i4.minus.com/ibqzS9GS4z7gCD.jpg http://i4.minus.com/iblogFe9Op8tFk.jpg http://i4.minus.com/i5nnZ6wXLHtgn.jpg http://i4.minus.com/iCpWjYy07z7S1.jpg http://i4.minus.com/iKnkXFPRZB7W.jpg http://i3.minus.com/iby6Dg1zpdY1in.jpg http://i7.minus.com/iABhWmq0upnuz.jpg http://i4.minus.com/ibn52BzbDsG4L5.jpg http://i2.minus.com/icOC6xjysZVpu.jpg http://i4.minus.com/ism8wP4XNCW7M.jpg http://i3.minus.com/iby5hJlpTlO1I3.jpg http://i6.minus.com/ihILTGiearIR6.jpg http://i2.minus.com/idYS2bhiPdDc3.jpg http://i6.minus.com/iOj9Omn6HEnYv.jpg http://i4.minus.com/iMmgVQAXqrg4Q.jpg http://i4.minus.com/ibpZhkaaPzDtWU.jpg http://i1.minus.com/ibaOlHIsx0iJMS.jpg http://i6.minus.com/iyrZSX5TswnDk.jpg http://i3.minus.com/ibujJB04GxWwvO.jpg http://i4.minus.com/ibor2bgtCBjMp3.jpg http://i5.minus.com/ij1JjMySkCATm.jpg http://i3.minus.com/ivxToOWGkXko4.jpg http://i4.minus.com/ibllcqgDcJ8ess.jpg http://i6.minus.com/ixji9sK26KiAT.jpg http://i4.minus.com/iboh6KjVVXlIV7.jpg http://i7.minus.com/ibsod54BAoswvp.jpg http://i2.minus.com/ihRIt03KJasW0.jpg http://i4.minus.com/iMnPTCNhtyhtv.jpg
Or, as pointed out by Enissay, the urls could be saved to a file and downloaded like this :
wget -i urls.txt
If you are feeling lucky, you could always try to download all files from your browser using only javascript.

Resources