How to export dependency licenses information to csv? - flutter

Having an application with about 30 dependencies, we report about the licenses in the app via the default showLicensePage.
How can we export this list to a CSV format (including transitive dependencies)? I am looking for something like this:
package name,transitive (direct/transitive),license,link
some_package,direct,MIT,https://github.com/someone/some_package
...

The LicenseFinder has support for flutter since version 7.0.0 and supports many output formats including csv. The good thing over e.g. flutter_oss_licenses is that it also provides the license name (not only the license text) and also has many other features (e.g. allowing a set of licenses, CI-support, other languages/package-managers support etc.), it is actively maintained by pivotal and is itself MIT licensed.
For example, one can use the docker version to run it (see README - for more information how to run the tool).
Then you can get a csv report for your flutter project with a command like this:
cd some_flutter_project
docker run -v $PWD:/scan -it licensefinder/license_finder:7.0.1 /bin/bash -lc "cd /scan && PUB_CACHE=~/.pub license_finder report --format=csv -p"
This command will mount the current working directory to the docker container and analyze it. The -p option runs flutter pub get in the docker container to setup the dependency cache that is then analyzed.
Note that the command will print the result to standard out, but you can, for example, pipe it to a file (command from above) > out.csv.

Related

How to install a NetBeans plugin via CLI?

Question:
Is there a way to install a downloaded NBM (Netbeans Module) into an already installed Netbeans IDE via CLI?
Current setup
Netbeans 12.3 with Windows 10
Netbeans 12.3 with Linux Mint 20.1
Relevant scenario
If the question comes to your mind 'why aren't you just using the GUI?' or anything like that. Think of the following scenario. When working on an air gapped network with 50 computers you're the one having to install Netbeans plugins on all of that PCs. You're able to put files on those PCs and execute a command via console and you don't want to run around all the buildings and clicking through the process.
Thank you very much in advance.
I think I found a solution. I'll post it here to reflect my research because I've never found a answer on stackoverflow.
When Netbeans is already installed you can use the --help parameter like:
C:\Program Files\NetBeans\netbeans\bin\netbeans64.exe --help
This lists lot of available parameters (which I haven't found a list of on the web) like (shortened):
General options:
--help show this help
--jdkhome <path> path to JDK
--console new open new console for output
Module reload options:
--reload /path/to/module.jar install or reinstall a module JAR file
Additional module options:
--modules
--refresh Refresh all catalogs
--list Prints the list of all modules, their versions and enablement status
--install <arg1>...<argN> Installs provided JAR files as modules
--disable <arg1>...<argN> Disable modules for specified codebase names
--enable <arg1>...<argN> Enable modules for specified codebase names
--update <arg1>...<argN> Updates all or specified modules
--update-all Updates all modules
Core options:
--fontsize <size> set the base font size of the user interface, in points
--userdir <path> use specified directory to store user settings
--nosplash do not show the splash screen
In my case the solution was to use the --install parameter pointing to the jar file to install.Be aware that the NBM files are just containers containing the jar file and some more meta data files like config xml files. You're able to open it via 7zip for example. And you'll have to take care of all the dependencies yourself.

Hyperledger FabCar Network issue via Visual Studio Code

While reproducing steps from an interesting tutorial found online - Hyperledger Fabric 1.4 Tutorial - FabCar Sample Application, I have installed all Hyperledger Fabric binaries via the Curl command:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s
From the Command Prompt window one can see that, the scripts are run correctly leading to the pull of hyperledger-docker images.
However, while launching the network from Visual Studio Code through the execution of
./startFabric.sh javascript from the fabcar sub-directory, one ends up with Fabric Images issues, which seems paradoxical.
A similar issue has been encountered, while attempting to bring up the network via the command
./network.sh up
from the test-network sub-directory too.
Thus, any relevant feedback would indeed be appreciated, given an absence of rationale to justify this matter.
[EDIT]
As a matter of fact, a synchronization issue might have caused the previously reported issue, since fabric-samples v.1.4.9 is not found from Curl command documented online. Thus the script automatically installs the latest Fabric binaries 2.x.
To rule out this issue, I have re-executed the Curl command by specifying the version 1.4.4 instead.
Therefore I can confirm, that the test-network sub-directory is not part of the Fabric binaries pertaining to the version 1.4x.
Furthermore, before the installation of this binaries, I had removed all containers, and related images, yielding to:
Back to the fabcar sub-directory, running:
./startFabric.sh javascript has still led to the following network issue :
What strikes me the most is:
firstly, that configtxlator can be found on my C:\Users\...\Documents\test4\fabric-samples\bin as opposed to the path highlighted on the command window.
secondly, I do not see the matter of version's incompatibility by scrutinizing byfn.sh:
Eventually, the manual amendment of IMAGETAG has not improved the situation.
Best
You seem to have the different version.
In hyperledger/fabric-samples, the test-network does not exist in version 1.4. In other words, you are running the code for the master version of fabric-samples (currently the version 2.x version). Since you're running the 1.4 tutorial, run the commands based on the 1.4 documentation and code.
fabric/docs/release-1.4
fabric/samples/release-1.4
[NOTE] It is also very likely that the different version binary has been installed. In the fabric document, the version can be specified and downloaded, so to download the binary of the corresponding version, you need to execute the command including the input parameter (version) below.
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s - 1.4.9 1.4.9 0.4.21
[EDIT - 1]
Prior to the explanation, in 1.4.x, first-network/byfn.sh exists, not test-network/network.sh. Change the branch of your fabric-samples to release-1.4.
Do not run 2.x code while doing the 1.4 tutorial.
./byfn.sh basically executes the image tag as latest. That is, if you have pulled the 2.x version of the image, even if you proceed to 1.4.x, it will run as 2.x.
cd fabric-samples
git checkout release-1.4
There are two ways.
tag the latest with 1.4.x image
Untag all hyperledger latest image tags, and tag 1.4.x images as latest.
(In fact, the easiest way is to delete both the 2.x and 1.4.x images and execute the command again.)
Or edit in byfn.sh
There is a part to set IMAGE_TAG in byfn.sh.
byfn.sh
# default image tag
# IMAGETAG="latest"
IMAGETAG="1.4.9"
Make sure the value of that part matches your 1.4.x version
[EDIT - 2]
For binary I don't know where and how you built it. However, you can easily build it on the fabric github.
make binaries
cd $GOPATH/src/github.com/hyperledger
git clone http://github.com/hyperledger/fabric
cd fabric
git checkout release-1.4
make native
Makefile
native - ensures all native binaries are available
configtxgen - builds a native configtxgen binary
configtxlator - builds a native configtxlator binary
cryptogen - builds a native cryptogen binary
idemixgen - builds a native idemixgen binary
peer - builds a native fabric peer binary
orderer - builds a native fabric orderer binary
Path setting
mv $GOPATH/src/github.com/hyperledger/fabric/.build/bin/* <your_bin_path>
# in my case
# mv $GOPATH/src/github.com/hyperledger/fabric/.build/bin/* usr/local/bin
or
export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/.build/bin

Can I install and run multiple versions of gcloud (google cloud sdk) on the same machine?

Features and options in gcloud are sometimes deprecated/removed. If CI depends on it and refactoring is not an option while at the same time we need to use new features which come out in later releases can we have multiple versions of gcloud installed on same machines and used concurrently?
There are multiple ways to install Cloud SDK on your machine. For this probably simplest would be to download versioned package from https://cloud.google.com/sdk/downloads#versioned.
For example you can do
gsutil cp gs://cloud-sdk-release/google-cloud-sdk-VERSION-linux-x86_64.tar.gz .
where VERSION is you want to get (for example "161.0.0"). You could also use wget or curl or simply use browser to download the package for your platform.
Then unzip/untar into your desired location for example
mkdir -p ~/cloudsdk/161.0.0
tar xzf google-cloud-sdk-161.0.0-linux-x86_64.tar.gz -C ~/cloudsdk/161.0.0
repeat for some different version:
mkdir -p ~/cloudsdk/130.0.0
tar xzf google-cloud-sdk-130.0.0-linux-x86_64.tar.gz -C ~/cloudsdk/130.0.0
Now you can run gcloud via
~/cloudsdk/161.0.0/google-cloud-sdk/bin/gcloud components list
or
~/cloudsdk/130.0.0/google-cloud-sdk/bin/gcloud components list
Note both version will share same config directory. This is generally undesirable, because there could have been changes between versions in how they treat configuration. To force different Cloud SDK versions use different gcloud configurations set CLOUDSDK_CONFIG environment variable to point to different gcloud config directory. For example:
$ CLOUDSDK_CONFIG=~/.config/gcloud-legacy ~/cloudsdk/130.0.0/google-cloud-sdk/bin/gcloud

Adding binaries to path with BOSH

This seems like it should be done in the packaging phase of a job, but the documentation does it in the job's control script.
However when I ssh into the machine the binaries I added to the path are not in the path anymore.
Your assumption is correct, I'm not sure what docs you reference, but binaries should be define in packages
The spec file tells director where in blobs to find the binary:
---
name: bamboo-agent
dependencies:
files:
- bamboo/atlassian-bamboo-5.9.7.tar.gz
And the packaging file tells it where to place those files on the job's vm.
# abort script on any command that exits with a non zero value
set -e
# agent jar is within the full installation tar, pull it out.
tar -xzf $BOSH_COMPILE_TARGET/bamboo/atlassian-bamboo-5.9.7.tar.gz
cp -a atlassian-bamboo-5.9.7/atlassian-bamboo/admin/agent/atlassian-bamboo-agent-installer-5.9.7.jar $BOSH_INSTALL_TARGET/
Control scripts might use those binaries, but should not manipulate them.
See https://bosh.io/docs/create-release.html#pkg-skeletons for an overview of how packages fit into BOSH releases.

wget :: rename downloaded files and only download if newer

I am trying to use wget to download a file under a different local name and only download if the file on the server is newer.
What I thought I could do was use the -O option of wget so as to be able to choose the name of the downloaded file, as in:
wget http://example.com/weird-name -O local-name
and combine that with the -N option that doesn't download anything except if the timestamp is newer on the server. For reasons explained in the comments below, wget refuses to combine both flags:
WARNING: timestamping does nothing in combination with -O. See the manual
for details.
Any ideas on succinct work-arounds ?
Download it, then create a link
wget -N example.com/weird-name
ln weird-name local-name
After that you can run wget -N and it will work as expected:
Only download if newer
If a new file is downloaded it will be accessible from either name, without
costing you extra drive space
If using other tool is possible in your case, I recommend the free, open source lwp-mirror:
lwp-mirror [-options] <url> <file>
It works just as you wish, with no workarounds.
This command is provided by the libwww-perl package on Ubuntu and Debian among other places.
Note that lwp-mirror doesn't support all of wget's other features. For example, it doesn't allow you to set a User Agent for the request like wget does.