when postinstall script in package.json is executed while installing the vscode extension - visual-studio-code

I have created an extension and specified to run an installer file which will download the zip and extract the binary and place it some other folder.
But it is not working?
Please tell me what is the use of the post-install script in package.json while installing the extension.
And when this will be executed.
Thanks,
Akhil

postinstall Run AFTER the package is installed
Means that postinstall applies only for npm packages. (This is the downside of abuse package.json by other ecosystems).
If you want to run some logic (download, extract etc.), you can use the activation event run the check (if a file exists for example) and if it failed, run the installation process.

Related

How install npm dependency (rsuite) from github repository

I'm using next js 11.
I want to edit an rsuite component, so I understand that I need to clone the dependency https://github.com/rsuite/rsuite.git, and in my branch make the changes and then install it.
The problem is that while I can install the dependency ("rsuite": "MYUSER/rsuite"), not all files are installed.
Test installing then directly from rsuite, ("rsuite": "rsuite/rsuite") also probe, "rsuite": "git https://github.com/rsuite/rsuite.git" and other ways, (npm install https://github.com/rsuite/rsuite.git) and (yarn add https://github.com/rsuite/rsuite.git), but there is no case, not everything is installed, only some files.
Does anyone know how they could do it?
Thanks a lot.
image:
Because npm installation will read the information in package.json.
npm install https://github.com/rsuite/rsuite.git
The package.json files configuration is read when the above statement is executed.
So only the README and CHANGELOG files are available. In order to make it more convenient to import components in a modular manner, rsuite adopts the following methods to import.
import Button rsuite/Button
To implement such component import, we make a custom directory when rsuite is released. All components will be copied to the root directory and associated with the cjs and esm directories through soft links. Detailed release scripts can be viewed in the gulpfile configuration.

Why does python setup.py bdist_wheel creates a build folder?

I just learned to upload my own python packages to PyPI thanks to this amazing tutorial. I am trying now to better understand how wheels works and I found this article helpful.
However, I still do not understand why python setup.py bdist_wheel creates an almost empty directory named build with two subfolders: bdist.win-amd64 (empty) and lib (which contains a copy of my package), in addition to the .whl file in the dist directory that developers will later upload to PyPI by doing python -m twine upload dist/*.
Why is this build directory necessary? I mean, would the dist directory not be enough? Moreover, why is the .whl called a binary distribution if the code is not actually compiled.
python setup.py bdist_wheel internally runs python setup.py install which in turn runs python setup.py build which compiles/builds the project into a temporary location inside build/ directory and then installs compiled project into another temporary location inside build/ directory. From files in that second temporary location it creates a wheel.
As for the compilation — python modules could be written in C/C++ and often they are. So python setup.py build needs to compile. If there is nothing to compile — well, the compilation step is skipped but the build step is still run.

TNS command not found after installing NativeScript

I updated NPM and Node before installing NativeScript, without errors I might add, but when I attempt to create a new project using tns create MyProjectName, I get the error tns command not found.
After much reading, I'm getting the feeling it has something to do with my PATH.
This is what is outputted in terminal during the NativeScript install regarding TNS:
sudo npm install -g nativescript --unsafe-perm
/Users/martingeldart/.npm-global/bin/tns -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
/Users/martingeldart/.npm-global/bin/nativescript -> /Users/martingeldart/.npm-global/lib/node_modules/nativescript/bin/tns
...
If I run echo $PATH, this is what outputs:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/bin/lib/node_modules/nativescript/bin
Which looks really odd to me but I'm no command line expert by any means. In fact, I'm incredibly inexperienced with the whole command line system.
Why am I not able to access the tns command? What is going on with that PATH I echoed?
MacOSX
Between version of npm the location of the global package moved location in the OS. Since the installation has moved the terminal does not know where to find the command. The PATH variable is used to tell the terminal where all the command may be located. In this case this seems a standard.
Now the best way to access command from an installed package is to use npx which is included by default with the new installation of npm.
https://docs.npmjs.com/downloading-and-installing-packages-globally
npx tns
# In your case
npx tns create MyProjectName
There 2 other ways to resolve this.
Either your global package folder is not set up correctly.
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Add the bin folder where nativescript was install to your path manually (usually in .bash_profile), open a new terminal.
I use nativescript for various project and I have a suggestion for package management. Usually I avoid installing global package because in case of multiple project there may be conflict between version if some project are updated and other not.
I usually create a folder with the version I am installing. Go to the folder, npm init and install locally the package.
mkdir nativescript-project-6-0
cd nativescript-project-6-0
npm init
npm i --save nativescript
Now I have a fix version to work with and can create other project with the same version even if I have other project with newer version of the tool or lib. Now in nativescript-project-6-0 I create my project.
npx tns create MyProjectName
This should create a folder nativescript-project-6-0/MyProjectName. All set and ready to go. Remember that is is always a good idea to use npx in this case since we want to use the local package.

Component-preload.js generation

We are about to close a SAPUI5 application, one of the last steps is to make a Component-Preload.js file to improve performance. I read different guides around the web, all of them need Node.js that I have installed. I'm not expert about that package and I can't figure how to make one of that guides work. I'm developing with NetBeans. As far as I see there is not an official tool (am I right?) to generate that file. Can someone with more experience than me suggest a working, well-explained guide to perform that task?
I don't know if this could help, that's my working tree:
There are several main ways of doing it.
You can use SAP Web IDE to generate it. This assumes that you are using WebIDE to develop your application (which is not true based on your question). The regular version of WebIDE generates this file during the "client build" just before application deployment.
The "multi cloud" version of WebIDE can use a grunt build to do it. You can find more info here if you are interested: https://www.sap.com/developer/tutorials/webide-grunt-basic.html.
Use the new UI5 command line tools (https://npmjs.com/package/#ui5/cli):
Run npm i -g #ui5/cli to install the tools globally.
Open the root of your project with your terminal.
Run ui5 build preload to build the preload.
Use the #sap/grunt-sapui5-bestpractice-build pre-configured grunt tasks. The downside is that they are more-or-less black boxes which do not allow that much customisation. You can find an example setup on SAP's GitHub repository jenkins-pipelines. In a nutshell:
You need to define an .npmrc file which adds the #sap npm registry: #sap:registry=https://npm.sap.com.
Run a npm init command such that you generate a package.json file. This file describes your application and your dependencies (runtime dependencies and dev dependencies; you will only have dev dependencies for now, as you just want to build your app). Make sure to mark the package as private. See the npm docu (at the end of the license chapter).
Then you can install grunt and the build configuration: npm i grunt -D and npm i #sap/grunt-sapui5-bestpractice-build -D.
Lastly you need to define a simple Gruntfile (you can then run the build by just running grunt):
module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('#sap/grunt-sapui5-bestpractice-build');
grunt.registerTask('default', [
'lint',
'clean',
'build'
]);
};
You can use the official grunt_openui5 plugin to generate the preload file(s). In order to be able to do this, you need to have node installed:
Create a package.json (e.g. through npm init).
Install grunt by writting in the console: npm install grunt-cli --save-dev.
Install the official openui5 grunt plugin: npm install grunt-openui5 --save-dev.
Now you have all the tools necessary, you just need to tell grunt what it has to do. You should create a Gruntfile.js in the root of your project. In this file you should configure the grunt openui5 task as described in the official github page (I linked it above). You can find a similar file here (it has more build steps like minification and copying the result files in a separate directory).
You can then run the grunt build by simply running grunt <task_name> in the console. If you registered your build task as the grunt default task (like in the sample file: grunt.registerTask('default', [...]);) then you just have to write grunt.
I think you should be able to integrate such a command line script (i.e. to run grunt) inside your IDE as an external tool.
You can use the unofficial gulp-openui5 tool to generate it. I would not recommend this if you are not already using gulp for your builds (as it is not a tool built by SAP). The procedure is the same, but using gulp for building the app instead of grunt (so you need to install node, npm init, install gulp, create the Gulpfile, etc).
Note that for most of the above methods, you need nodejs, which you can download and install from here: https://nodejs.org/en/download/.

rpm install scripts not executing

I'm working in ClearOS5.3, with rpm 4.4 installed. I'm using rpm to distribute a module I created, however the %post script in my spec file isn't executed when I install the package.
I'm using the command rpmbuild -ba mypackage.spec
to build the rpm, and the command rpm -ivh mypackage-version-release.rpm to install the package.
Installation is performed manually (not using make) in the %install script. All the files seem to be installed in the correct places, however none of the install scripts run (specifically %post and %preun, in the case of my package). Testing with other install scripts (%pre) showed those sections didn't work either.
From what I can tell based on installing the package in debug mode, the %pretrans and %posttrans scripts are run. Additionally, when building the package, it recognizes the the install scripts and lists their dependencies (/bin/sh).
Does anyone have an idea as to why these install scripts might not be running and have suggestions to fix the issue?