Ability to provide an output path / filename for the created zip
My project is hosted in a private NPM Repo, i.e. in the package.json has a name like this -
"name": "@organisation/api-project"
When I run this plugin it tried to create the zip in a folder named @organisation
e.g. - '/Users/user/Documents/github/api-project/@organisation/api-project_function.zip'
Obviously @organisation doesn't exist so this throws an error.
If possible, it would be nice to solve this in a more generic way where I could state where I wanted the zip to end up
e.g.
workspace-pack function --output=target/api-project_function.zip
Ah, of course, it should be able to handle package names with a / character. I also like the idea of specifying a location for the zip.
I've added a fix so the / in the package name is replaced with a -. When I get more time i'll add in a proper options parser to the cli and provide an option to specify the target.
Hi,
I think the issue isn't fixed and I'm running into the same issue. The problem is in index.js where you sync the dependencies from the root dir using const dirName = dep.split('@').shift();
This assumes all dependencies have pattern [email protected]. But it could also be something like @foo/bar or @foo/[email protected] if I'm correct.
The current behavior is that call to shift() returns an empty string which then resolves to the root node_modules folder. That means the complete folder is copied to _build which adds dependencies from the whole workspace to the package that I want to pack.
hey @alex-lmi I just pushed a fix for this, have another go!
Thanks for the fast response, really appreciated!
Well now it works for packages like @foo/[email protected] but I also have links to local packages with format @bar/foo without a version because they are declared as dependency like "@bar/foo": "link:../foo".
I added the following locally to your index.js so that the line you adapted looks now const dirName = versionIndex === 0 ? dep : dep.substr(0, versionIndex);.
I still have to check if the installation of this package in a docker image works. So you can wait for my feedback if you like.
The fix shrinked down my tarball from ~330MB to ~8MB which is more expected :)
Thanks!
ahh, of course, didn't think about that case either. I can add that in and cut a new release!
@alex-lmi fix landed in 0.0.5
Works now, thanks :)
--output cli flag added to version 0.0.6. Closing this issue 🙌