angularangular-clioctopus-deployoctopack

Octopack won't package ng build output when there are subfolders


The gulp-octo version here is 0.0.10, which is no longer the current version. This may or may not apply to the newer versions

The angular-cli command ng-build builds my angular app into a /dist folder.

I end up with a flat dist folder, containing my js, html, etc files.

/dist
  index.html
  inline.js
  [etc]

I then can use gulp-octo to publish my package to my octopus deploy host, like this:

// You need to bump version in package.json and ng build before running this
gulp.task("publish", function() {
    return gulp.src(["dist/**"])
        .pipe(octo.pack())
        .pipe(octo.push(octoConfig));
});

Which works.

I then add a file, assetFile.png, to the assets file. This changes what /dist looks like. It's no longer completely flat:

/dist
   /assets
      assetFile.png
  index.html
  inline.js
  [etc]

All of a sudden, gulp publish fails with this error:

λ gulp publish
[11:14:58] Using gulpfile C:\Source\blank-angular-cli-app\gulpfile.js
[11:14:58] Starting 'publish'...
[11:14:58] Packed 'foo.0.0.0.2.tar.gz' with 10 files
C:\Source\blank-angular-cli-app\node_modules\@octopusdeploy\octopackjs\lib\pack.js:26
    throw err;
    ^

Error: ENOENT: no such file or directory, stat 'C:\Source\blank-angular-cli-app\assets'
    at Error (native)

It's clearly unhappy with the /dist folder containing subfolders (I get the same error if I add folders to the dist after build). But I'm unsure why, and what to do about it.

What is going on? How do I fix this deployment?

A minimal example of what's going is on Github, which is blank application I created using ng init (angular-cli) and then added gulp and octopus to.


Solution

  • So the fix is to add an assets/ folder at the top level.

    - assets
        unrelatedDoesntMatter.png
    - dist
      - assets
        assetFile.png
    [etc]
    

    Here is the commit that fixes my example app. This folder doesn't matter, and doesn't get packaged. It just needs to exist. Weird, looks like a bug in gulp-octo.