workspace-pack icon indicating copy to clipboard operation
workspace-pack copied to clipboard

Ability to provide an output path / filename for the created zip

Open petersow opened this issue 8 years ago • 9 comments

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

petersow avatar Apr 17 '18 09:04 petersow

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.

tamagokun avatar Apr 17 '18 12:04 tamagokun

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.

tamagokun avatar Aug 23 '18 13:08 tamagokun

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.

alex-lmi avatar Sep 27 '19 10:09 alex-lmi

hey @alex-lmi I just pushed a fix for this, have another go!

tamagokun avatar Sep 27 '19 10:09 tamagokun

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!

alex-lmi avatar Sep 27 '19 13:09 alex-lmi

ahh, of course, didn't think about that case either. I can add that in and cut a new release!

tamagokun avatar Sep 27 '19 14:09 tamagokun

@alex-lmi fix landed in 0.0.5

tamagokun avatar Sep 27 '19 14:09 tamagokun

Works now, thanks :)

alex-lmi avatar Sep 30 '19 15:09 alex-lmi

--output cli flag added to version 0.0.6. Closing this issue 🙌

tamagokun avatar Oct 10 '19 14:10 tamagokun