Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add offline mode #260

Merged
merged 8 commits into from Oct 15, 2021

Conversation

spjuanjoc
Copy link
Contributor

@spjuanjoc spjuanjoc commented Oct 7, 2021

Adds the options to disable the ensureInstalled and ensureDownload, and the option to set a custom directory where the runtime headers will be downloaded.

Currently it always checks for installed and downloaded, even when running cmake-js clean

This PR keeps the default behavior as it is, but gives the option to change the settings in the package.json just as it works for "runtime", "runtimeVersion", and "arch":

  "cmake-js": {
    "ensureDownloaded": false,
    "runtimeDir": "cmake-js-custom-dir"
  }

With "ensureDownloaded": false only the cmake-js install command will check for download status and perform a download if it is needed.
ensureInstalled is true since it is not defined.

The runtimeDir is the one to join the environment.home to form the internalPath, instead of "runtime + arch + version"

This might solve the issue #254

@alejandroclaro
Copy link

alejandroclaro commented Oct 8, 2021

Better if this doesn't have to be change in the package.json, and it's compatible with node-gyp arguments and environment variables:

--nodedir=node-dir-path
npm config set [--global] nodedir node-dir-path

@spjuanjoc
Copy link
Contributor Author

With the npmConfig added, now it is possible to set the nodedir, which will be loaded into the runtimeDir variable, so there's no need to define it in the package.json

npm set nodedir="runtime-directory"

Will set the internalPath to environment.home + nodedir

lib/dist.js Outdated Show resolved Hide resolved
lib/dist.js Outdated Show resolved Hide resolved
lib/dist.js Outdated Show resolved Hide resolved
lib/buildSystem.js Outdated Show resolved Hide resolved
lib/buildSystem.js Outdated Show resolved Hide resolved
- Use the runtimeDirectory as the full path if defined, otherwise, keep it as it was
@spjuanjoc
Copy link
Contributor Author

Ok, so now this PR only adds the possibility to configure the npm_config variable "nodedir" and use it as the internalPath. If the runtime is not already there it will try to download it.
If the variable is not defined it will behave as it was prior to these changes.

@claudv
Copy link

claudv commented Aug 28, 2023

Would it be possible to have a working example for how to enable the custom node directory?

npm set nodedir="runtime-directory"

does not seem to work.

@spjuanjoc
Copy link
Contributor Author

Would it be possible to have a working example for how to enable the custom node directory?

npm set nodedir="runtime-directory"

does not seem to work.

The way I tested it is the following:

  1. Find or download the node headers

  2. Put the headers in the path to configure. e.g.: /tmp/node

  3. Set the nodedir variable to that path

    npm config set nodedir="/tmp/node"

  4. Check the npm configuration file .npmrc for the nodedir variable value

  5. Validate that the directory ~/.cmake-js doesn't exist

  6. Run the install-offline command in your project that uses cmake-js

  7. Validate that ~/.cmake-js has not been created, meaning that cmake-js did not download the default runtime

@audetto
Copy link

audetto commented Oct 29, 2023

npm config set nodedir="/tmp/node"

npm ERR! nodedir is not a valid npm option

regardless of the path I use.

It is not very clear how this is supposed to work.

But one odd thing is that in .nvm I already have all the headers, could cmake-js go fetch them there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants