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
support pkg little better with default setup #177
Comments
I don't suggest using pkg at all so I won't be modifying the generated code. I couldn't make sense of your second paragraph though |
I think oclif is an awesome tool. I understand there are a lot of CLI apps intended for developers, but I think there are also a lot of apps being provided to teams not running NodeJS locally, without docker and other standard dev tooling. In this case I think pkg is a great solution. For us we have graphics team members and content developers using CLI tools. For me the biggest advantage over Commander that I see is connecting the dots with ENV variables also, as well as establishing more of a structure to help quick build out simpler commands. The documentation about setting up Multi commands using the generate, did not include a link to how to setup the "topics" in the help for the directories (instead of showing the description of the first task in the directory). Very minor detail, but it took a search to find how to set them... |
oclif already provides a means for including node with the built in |
@jdxcode that is incorrect. That is for building a bundled command that could be installed via homebrew, this is simply for building the command to be published to NPM. there is no way to do this currently, as far as I can tell. |
None of what we've discussed has anything to do with npm distribution |
@jdxcode yeah, but it's about building the thing. there isn't any builtin support for that, you need to do it your self (in order to publish to NPM, or whatever) |
@jdxcode and oclif-dev pack is not that. it serves a different purpose |
See my comment on your other post, the prepack step is not working on your local machine. |
@jdxcode my problem was not if node was included or not, but if the commands JS files are included in the pkg (ie src/commands/**/*.js). In my case it looked like it was working because the package.json had some information for titles in it (so running pkgname --help showed help), but none of the commands JS was bundled. The two configs I suggest would make npm run pkg always build a proper single file app (single command and multi command). we are not trying to distribute a tarball. intended users are not using Node/NPM locally; we are simply trying to give them some simple CLI tools. |
I understand that you want to use pkg. I'm saying the tarball method solves the same problem that pkg would solve via a different means. (Bundling Node with the CLI and so you don't have to install via npm) I also understand that we could make some simple changes to more easily accommodate pkg, but including such config essentially condones its use which I'm not sure I want to do. I would prefer people use the tarball method instead |
ill look into oclif-dev pack, feel free to close |
I'll leave it open since I'm willing to be convinced otherwise and others may chime in. Would love to hear what your thoughts are about pack as well |
Hi! I'm going the pkg route because I don't understand what to do with the tarballs. I'm not sure what users should do with it: download, unzip, and then what? Create a symlink in The homebrew method wouldn't work as well because I would need to support multiple package managers (debian, etc.) that sounds like way too much effort for distributing a little app. |
Just to confirm that I managed to use pkg to distribute my closed-source binary (https://port7777.com/). |
I am with @mnapoli. At first I tried to distribute my cli app to some colleagues using the tarbells. This required generating the tarbell, converting to a zip file (because Windows users don't have an easy way to unpack tarbells), sending the zip file, unzipping, and instructing users to execute commands from the bin folder. I was able to simplify the process using
And now I can execute |
My use case is similar to @mnapoli where I want to distribute a closed-source binary. In a multi-command project, I am able to run |
@Chuwiey oclif uses globby to look for commands (https://github.com/oclif/config/blob/0779d64dedc5a3a0dee28376971c0e42715c4d36/src/plugin.ts#L232) For versions of So I recommend locking down your version of pkg to PS: one other problem you might run into is |
It would be really impractical to expect users to know how to work with tarballs or distribution packages. The whole point of creating a CLI app (at least in my cases), is to lower the barrier of entry for non-technical or semi-technical people. I was able to get pkg to work with a mutli-command oclif app by making the following changes to Use pkg v4.4.9:
Add a
Include the
|
@christroutner Hi! I'm bumping into the same need, e.g. I need to package my Node/Express app with pkg, and including oclif as simple CLI for some basic commands. I cloned your repo https://github.com/christroutner/bin-cli-boilerplate and tried out, but unfortunately could not follow the same. I'm using Typescript btw. |
@ngkimnhatnam I hit a wall as well. The technique I described worked at first, but I ran into issues as I started to add more complex npm packages. |
Here is how we did it, hopefully that helps but since it was done a while ago, and it was very confusing to pull off, I may not be sharing 100% of the steps needed to achieve it. package.json: {
...
"bin": {
"7777": "bin/run"
},
"dependencies": {
...
},
"files": [
"/bin",
"/lib",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"main": "lib/index.js",
"oclif": {
"commands": "./lib/commands",
"bin": "7777",
"plugins": [
"@oclif/plugin-help"
]
},
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md",
"tsc": "tsc"
}
} The export {run} from '@oclif/command' Build script: # Install pkg
npm install -g pkg@4.4.9
# Delete the previous binaries
rm -rf dist/ lib/
# This compiles Typescript to JavaScript in the `lib` directory
npm pack
# This archive is also generated but we don't use it, let's remove it
rm -f 7777-*.tgz
# Now before creating the binary, we lighten the final binary by removing dev dependencies
npm ci --only=prod
# Generate the binaries using the `pkg` tool
./node_modules/.bin/pkg . --targets=node14-macos --out-path dist We use pkg 4.4.9 because of vercel/pkg#1130 |
I needed to first do |
I am trying to package my small cli app with
I've "pkg": {
"scripts": "./dist/**/*.js",
"outputPath": "exec"
}, and running the following command Can anyone give me a hint what's going on? |
@mdonnalley It would be nice to include some context/description on why the issue is being closed (if it was completed, then when/where it was completed; if it's 'not planned' then more of an explanation of why it's not going to happen). This current process of 'close a huge pile of issues' with no context is generally considered pretty 'hostile'/'disrespectful' (for lack of a better term) to open source/collaboration/etc. |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
pkg . doesnt include multi commands
What is the expected behavior?
pkg . includes multi commands
adding the following seems pretty low bar to get basic support to package.json
"pkg": {
"scripts": "src/commands/**/*.js"
}
and
"scripts: {
"pkg": "pkg ."
}
The docs where missing a links mutli intro introduction page to package.json:pkg.topics as the place to document the subdirectories as they are created.
The text was updated successfully, but these errors were encountered: