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

"apex-nitro publish" deletes distribution folder and throws error #240

Closed
jasonlyle88 opened this issue Jan 29, 2018 · 18 comments
Closed

"apex-nitro publish" deletes distribution folder and throws error #240

jasonlyle88 opened this issue Jan 29, 2018 · 18 comments
Milestone

Comments

@jasonlyle88
Copy link

jasonlyle88 commented Jan 29, 2018

Issue Description

When I run apex-nitro publish oracle-volunteers, I see the "nitro-dist" folder be deleted in explorer and receive an error that the distribution folder does not exist. Below is the command line interaction. I do a listing of the directory to show the distribution folder exists, then call the publish function, then I do a listing to show that the distribution folder has suddenly been deleted.

C:\WINDOWS\system32>dir C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\
 Volume in drive C has no label.
 Volume Serial Number is 0ADF-5727

 Directory of C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk

01/29/2018  12:55 PM    <DIR>          .
01/29/2018  12:55 PM    <DIR>          ..
01/22/2018  09:04 PM    <DIR>          app
01/22/2018  09:04 PM    <DIR>          blob
01/17/2018  12:17 PM               557 blob_to_clob.sql
01/22/2018  09:04 PM    <DIR>          css
01/22/2018  09:04 PM    <DIR>          csv
01/22/2018  09:04 PM    <DIR>          data
01/22/2018  09:04 PM    <DIR>          ddl
01/22/2018  09:04 PM    <DIR>          dml
01/22/2018  09:04 PM    <DIR>          geo
01/22/2018  09:04 PM    <DIR>          media
01/29/2018  12:55 PM    <DIR>          nitro-dist
01/29/2018  11:51 AM    <DIR>          nitro-src
01/22/2018  09:04 PM    <DIR>          ords
01/22/2018  09:04 PM    <DIR>          pkg
01/22/2018  09:04 PM    <DIR>          plugin
01/22/2018  09:04 PM    <DIR>          resources
01/22/2018  09:04 PM    <DIR>          vw
               1 File(s)            557 bytes
              18 Dir(s)  357,168,128,000 bytes free

C:\WINDOWS\system32>apex-nitro publish oracle-volunteers

    _     ____   _____ __  __    _   _  _  _
   / \   |  _ \ | ____|\ \/ /   | \ | |(_)| |_  _ __  ___
  / _ \  | |_) ||  _|   \  /    |  \| || || __|| '__|/ _ \
 / ___ \ |  __/ | |___  /  \    | |\  || || |_ | |  | (_) |
/_/   \_\|_|    |_____|/_/\_\   |_| \_||_| \__||_|   \___/

is now processing your files...
...Done!
C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\apex-publish-static-files\index.js:31
                        throw new Error(`Directory ${opts.directory} is not a valid path.`);
                        ^

Error: Directory C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\nitro-dist\ is not a valid path.
    at Object.publish (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\apex-publish-static-files\index.js:31:10)
    at launch (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\lib\commands\publish.js:47:14)
    at runSequence (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\lib\gulp\launch.js:59:5)
    at finish (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\run-sequence\index.js:86:4)
    at runNextSet (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\run-sequence\index.js:126:4)
    at Gulp.onTaskEnd (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\run-sequence\index.js:102:4)
    at Gulp.emit (events.js:160:13)
    at Gulp.Orchestrator._emitTaskDone (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\orchestrator\index.js:264:8)
    at C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\orchestrator\index.js:275:23
    at finish (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\orchestrator\lib\runTask.js:21:8)

C:\WINDOWS\system32>dir C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\
 Volume in drive C has no label.
 Volume Serial Number is 0ADF-5727

 Directory of C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk

01/29/2018  12:56 PM    <DIR>          .
01/29/2018  12:56 PM    <DIR>          ..
01/22/2018  09:04 PM    <DIR>          app
01/22/2018  09:04 PM    <DIR>          blob
01/17/2018  12:17 PM               557 blob_to_clob.sql
01/22/2018  09:04 PM    <DIR>          css
01/22/2018  09:04 PM    <DIR>          csv
01/22/2018  09:04 PM    <DIR>          data
01/22/2018  09:04 PM    <DIR>          ddl
01/22/2018  09:04 PM    <DIR>          dml
01/22/2018  09:04 PM    <DIR>          geo
01/22/2018  09:04 PM    <DIR>          media
01/29/2018  11:51 AM    <DIR>          nitro-src
01/22/2018  09:04 PM    <DIR>          ords
01/22/2018  09:04 PM    <DIR>          pkg
01/22/2018  09:04 PM    <DIR>          plugin
01/22/2018  09:04 PM    <DIR>          resources
01/22/2018  09:04 PM    <DIR>          vw
               1 File(s)            557 bytes
              17 Dir(s)  357,168,128,000 bytes free

APEX Nitro Version

4.0.0

Operating System

Windows 10

Node Version

9.4.0

Browser

Chrome v64

APEX Version

5.1.3

Project configuration screenshot

{
  "mode": "advanced",
  "appURL": "https://lancaster.sumnertech.com/ords/f?p=701",
  "srcFolder": "C:\\Users\\jason\\Documents\\Work\\SumnerTech\\Oracle\\201801-volunteer_website\\trunk\\nitro-src\\",
  "distFolder": "C:\\Users\\jason\\Documents\\Work\\SumnerTech\\Oracle\\201801-volunteer_website\\trunk\\nitro-dist\\",
  "js": {
    "processor": "default",
    "concat": false,
    "library": false,
    "tsConcat": false
  },
  "css": {
    "language": "css",
    "concat": false
  },
  "browsersync": {
    "notify": false,
    "ghostMode": false
  },
  "header": {
    "enabled": false
  },
  "apex": {
    "openBuilder": false,
    "apexDestination": "workspace"
  },
  "sqlcl": {
    "path": "C:\\Program Files\\sqlcl\\bin\\sql",
    "connectionType": "custom",
    "username": "volunteers",
    "connectionString": "volunteers@stlancaster"
  }
}
@jasonlyle88 jasonlyle88 changed the title "apex-nitro publish" deletes dist folder and throws error "apex-nitro publish" deletes distribution folder and throws error Jan 29, 2018
@vincentmorneau
Copy link
Collaborator

Strange. You provide a very good step by step explanation, so thank you for that.

Would you be willing to try the latest beta? A few people (including me) have been testing it over the past few weeks. It's stable so far and we haven't had any issues with the publishing feature.

If so, I'll let know you how. It's pretty simple.

@jasonlyle88
Copy link
Author

@vincentmorneau, absolutely. Let me know how to use the beta and I'll test this out again.

@vincentmorneau
Copy link
Collaborator

vincentmorneau commented Jan 30, 2018

Great! You just need to run this:

npm i -g apex-nitro@4.1.0-beta.3

It'll override your v4.0.0 with the new v4.1.0-beta.3

and then you can try this again

apex-nitro publish oracle-volunteers

Let me know if you have any problem with the installation. Right now we haven't had any bug in beta.3, so it's probably going to be released as is under v4.1.0.

@jasonlyle88
Copy link
Author

Well, let me add a bug into the beta.3 release then!

To insure no issues between v4 and v4.1-beta.3 I uninstalled 4.0

C:\WINDOWS\system32>npm uninstall -g apex-nitro
removed 1346 packages in 28.21s

Then I installed the apex nitro beta

C:\WINDOWS\system32>npm i -g apex-nitro@4.1.0-beta.3
C:\Users\jason\AppData\Roaming\npm\apex-nitro -> C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\bin\apex-nitro.js

> uws@0.14.5 install C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0


> node-sass@4.7.2 install C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/win32-x64-59_binding.node
Download complete .] - :
Binary saved to C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\node-sass\vendor\win32-x64-59\binding.node
Caching binary to C:\Users\jason\AppData\Roaming\npm-cache\node-sass\4.7.2\win32-x64-59_binding.node

> uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.7.2 postinstall C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\node-sass
> node scripts/build.js

Binary found at C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\node-sass\vendor\win32-x64-59\binding.node
Testing binary
Binary is fine
npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\apex-nitro\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ apex-nitro@4.1.0-beta.3
added 1171 packages in 202.375s

I noticed I was missing a peer dependency, so I also installed that

C:\WINDOWS\system32>npm i -g ajv@5.0.0
+ ajv@5.0.0
added 4 packages in 1.376s

I then ran the dir listing, publish, and dir listing again

C:\WINDOWS\system32>dir C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk
 Volume in drive C has no label.
 Volume Serial Number is 0ADF-5727

 Directory of C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk

01/30/2018  08:56 AM    <DIR>          .
01/30/2018  08:56 AM    <DIR>          ..
01/22/2018  09:04 PM    <DIR>          app
01/22/2018  09:04 PM    <DIR>          blob
01/17/2018  12:17 PM               557 blob_to_clob.sql
01/22/2018  09:04 PM    <DIR>          css
01/22/2018  09:04 PM    <DIR>          csv
01/22/2018  09:04 PM    <DIR>          data
01/22/2018  09:04 PM    <DIR>          ddl
01/22/2018  09:04 PM    <DIR>          dml
01/22/2018  09:04 PM    <DIR>          geo
01/22/2018  09:04 PM    <DIR>          media
01/30/2018  08:56 AM    <DIR>          nitro-dist
01/29/2018  11:51 AM    <DIR>          nitro-src
01/22/2018  09:04 PM    <DIR>          ords
01/22/2018  09:04 PM    <DIR>          pkg
01/22/2018  09:04 PM    <DIR>          plugin
01/22/2018  09:04 PM    <DIR>          resources
01/22/2018  09:04 PM    <DIR>          vw
               1 File(s)            557 bytes
              18 Dir(s)  358,018,281,472 bytes free

C:\WINDOWS\system32>apex-nitro publish oracle-volunteers

    _     ____   _____ __  __    _   _  _  _
   / \   |  _ \ | ____|\ \/ /   | \ | |(_)| |_  _ __  ___
  / _ \  | |_) ||  _|   \  /    |  \| || || __|| '__|/ _ \
 / ___ \ |  __/ | |___  /  \    | |\  || || |_ | |  | (_) |
/_/   \_\|_|    |_____|/_/\_\   |_| \_||_| \__||_|   \___/

is now processing your files...
...Done!
C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\async-done\index.js:18
    throw err;
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at Gulp.emit (events.js:141:19)
    at Object.error (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\undertaker\lib\helpers\createExtensions.js:61:10)
    at handler (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\now-and-later\lib\mapSeries.js:43:14)
    at f (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\once\once.js:25:25)
    at f (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\once\once.js:25:25)
    at tryCatch (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\async-done\index.js:24:15)
    at done (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\async-done\index.js:40:12)
    at Domain.onError (C:\Users\jason\AppData\Roaming\npm\node_modules\apex-nitro\node_modules\async-done\index.js:51:5)
    at Object.onceWrapper (events.js:255:19)
    at Domain.emit (events.js:160:13)

C:\WINDOWS\system32>dir C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk
 Volume in drive C has no label.
 Volume Serial Number is 0ADF-5727

 Directory of C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk

01/30/2018  08:56 AM    <DIR>          .
01/30/2018  08:56 AM    <DIR>          ..
01/22/2018  09:04 PM    <DIR>          app
01/22/2018  09:04 PM    <DIR>          blob
01/17/2018  12:17 PM               557 blob_to_clob.sql
01/22/2018  09:04 PM    <DIR>          css
01/22/2018  09:04 PM    <DIR>          csv
01/22/2018  09:04 PM    <DIR>          data
01/22/2018  09:04 PM    <DIR>          ddl
01/22/2018  09:04 PM    <DIR>          dml
01/22/2018  09:04 PM    <DIR>          geo
01/22/2018  09:04 PM    <DIR>          media
01/29/2018  11:51 AM    <DIR>          nitro-src
01/22/2018  09:04 PM    <DIR>          ords
01/22/2018  09:04 PM    <DIR>          pkg
01/22/2018  09:04 PM    <DIR>          plugin
01/22/2018  09:04 PM    <DIR>          resources
01/22/2018  09:04 PM    <DIR>          vw
               1 File(s)            557 bytes
              17 Dir(s)  358,018,281,472 bytes free

@vincentmorneau
Copy link
Collaborator

About the ajv dependency, I should probably add a note in the documentation. It comes from an npm bug (npm/npm#15708) and it is harmless. It should not be a problem that you manually installed ajv.

Now back to APEX Nitro, I'm going to have to get my hands on a Windows machine. Are you still able to use the launch feature properly?

While I sort this out, you can manually zip the C:\\Users\\jason\\Documents\\Work\\SumnerTech\\Oracle\\201801-volunteer_website\\trunk\\nitro-dist folder and upload it to your workspace images.

@jasonlyle88
Copy link
Author

Yeah, I can zip and upload the directory manually without an issue.

As far as launch, it launches properly but I get a 404 for files that should be loading from localhost.

If you want, I can do a gotomeeting and let you take control if you want to do any quick debugging without having to find and configure a windows machine.

Additionally, if you get your hands on a windows machine, there is a workaround for doing a full visual studio installation. Instead, you can just first do npm i -g windows-build-tools and it solves the errors with C++ compilation/gyp.

@vincentmorneau
Copy link
Collaborator

If I'm able to make it work on my Windows 10 system, I'll let you know and schedule a gotomeeting.

About the 404, this is a separate issue? Can you right click on those files and open in a new tab? Sometimes the browser flags them as "unsecure" and you have to add the permission once.

@jasonlyle88
Copy link
Author

Okay, I'll wait for your reply regarding the publish feature. As far as the 404 goes, if I open them up in a new tab I simply get a tomcat 404 page

HTTP Status 404 - Not Found

Type Status Report
Message /css/page/p1.css
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Apache Tomcat/8.5.24

@jasonlyle88
Copy link
Author

A little more information: I went to test this on a clean windows 10 laptop I had laying around. I was confused when everything worked yesterday. This morning I got back on the laptop to see if I could figure anything out... only to figure out that it is no longer working. The laptop had not been used in a while, and I realized that it installed windows updates between the two apex-nitro tests. I haven't dug into what the updates are yet, but they are the following updates:

  • KB4056892
  • KB4056887
  • KB4058043
  • KB4041994
  • KB4054517
  • KB890830

So I am guessing that there may be an issue with an underlying node module on updated windows machines. I am going to try rolling back these updates (hopefully one at a time) and see if I can determine the culprit with process of elimination.

@jasonlyle88
Copy link
Author

Further further update: I figured out what is causing the problem. The error had nothing to do with the windows updates. But all of the sudden apex-nitro publish was working on my original windows machine. The only thing to change was the nitro-src folder. When I changed the nitro-src folder back to its original state, the error came back. So, while I do not know why, here is the folder structure of the nitro-src folder that is causing this error:

nitro-src
|
|
---- css
     |
     |
     ---- app
     ---- page
          |
          |
          ---- p1.css
---- js

nitro-src\css\app\ and nitro-src\js\ are both empty folders.

The issue I mentioned before with apex-nitro launch not loading loacalhost files seems to have to do with the css folder as well as that is working.

My current workaround is nitro-src\css\ is now named nitro-src\styles\

Hopefully this helps diagnose the issue!

@vincentmorneau
Copy link
Collaborator

vincentmorneau commented Jan 31, 2018

Ha! This helps me investigate further. Two things:

  1. having nitro-src\styles\ prevents you from having CSS processing (minifying, sourcemap, autoprefixer). APEX Nitro simply copy pastes nitro-src\styles\ into nitro-dist\styles\
  2. I have never tried to have subfolders in the nitro-src\css\. Can you try putting every CSS file directly in nitro-src\css\?

@jasonlyle88
Copy link
Author

Good to know number 1.

As far as subfolders, everything does work when just in a css directory directly. Interestingly enough, it also works as long as there are no empty sub-directories. However i don't think it does the minifying, sourcemapping, etc) when the css files are in subdirectories.

This may be a good feature to consider for the future. I assume it would be easy enough to crawl the css directory for anything that is a file (rather than a directory) and then process from there. May allow for cool other features such as "Concatenate CSS files up to CSS sub-directory" where everything in a sub-directory of css is concatenated into files with the name of the directory with a css extension (i.e. css\app\header.css and css\app\footer.css get concatenated into css\app\app.css since that is the name of the css sub-directory).

@vincentmorneau
Copy link
Collaborator

Okay so I was able to reproduce your issue and I understand the problem. It has everything to do with empty directories.

The only file you're trying to process here is nitro-src\css\page\p1.css. Right now APEX Nitro does not do recursive search, do it cannot find any css files, or javascript files, or anything. Thus, the dist folder is deleted by the cleaning job, and then never re-created.

I created a separate issue here #241 to keep track of it.

Now I'm thinking the dist folder should always be created, regardless if there is any file in it. It would prevent the publish feature from crashing.

@jasonlyle88
Copy link
Author

Great! Thanks for working with me on this!

@vincentmorneau
Copy link
Collaborator

@jasonlyle88 can you try with the new beta? It should support

  • subfolders
  • doesn't crash on publish when src is empty
npm i -g apex-nitro@4.1.0-beta.4

then again

apex-nitro publish oracle-volunteers

@vincentmorneau
Copy link
Collaborator

Also, regarding your feedback:

Concatenate CSS files up to CSS sub-directory

I understand the value of this, but if you are to make complicated CSS structures, I would strongly advise to look at the Sass options under css languages.

Using Sass, you could do this very easily. Example:

|-/src/
   |-scss
      |-app
         |-_header.scss
         |-_body.scss
         |-_footer.scss
      |-pages
         |-_p1.scss
         |-_p2.scss
         |-_p3.scss
      |-app.scss
      |-pages.scss

Then, in src/scss/app.scss, you would do

@import "app/header";
@import "app/body";
@import "app/footer";

And in src/scss/pages.scss, you would do

@import "pages/p1";
@import "pages/p2";
@import "pages/p3";

In Sass, files prefixed with an underscore _ do not produce an outcome. They are called partials, and they are only meant to be imported into other files. You can create very complex UI structures like that, and also you benefit from features like variables, css nesting, etc.

Does it make sense?

@vincentmorneau vincentmorneau added this to the v4.1.0 milestone Feb 1, 2018
@jasonlyle88
Copy link
Author

Looks like it is working well now with both empty directories and processing sub-directories. Thanks for all this!

One thing I did notice with beta.4 is that that when I run the publish command, the command line tells me that apex nitro is now launching my project, not publishing my project:

C:\Users\jason>apex-nitro publish oracle-volunteers

    _     ____   _____ __  __    _   _  _  _
   / \   |  _ \ | ____|\ \/ /   | \ | |(_)| |_  _ __  ___
  / _ \  | |_) ||  _|   \  /    |  \| || || __|| '__|/ _ \
 / ___ \ |  __/ | |___  /  \    | |\  || || |_ | |  | (_) |
/_/   \_\|_|    |_____|/_/\_\   |_| \_||_| \__||_|   \___/

is now launching oracle-volunteers ...
...Done!
Uploading to 701 - Workspace Files...

SQLcl: Release 17.4.0 Production on Fri Feb 02 09:43:25 2018

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Uploaded: C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\web\dist\img\logos\oracle-white-st.png
Uploaded: C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\web\dist\img\logos\oracle-white.png
Uploaded: C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\web\dist\img\logos\oracle.png
Uploaded: C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\web\dist\styles\app\app.css
Uploaded: C:\Users\jason\Documents\Work\SumnerTech\Oracle\201801-volunteer_website\trunk\web\dist\styles\page\p1.css

SQL>
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Files were uploaded successfully.

Granted, it is a small, non-functional, point, but an easy bit to polish!

As far as scss, that makes perfect sense! That was actually a next step for me to look at, so thank you for a quick read to demonstrate that functionality!

@vincentmorneau
Copy link
Collaborator

Nice catch. Thanks!

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

No branches or pull requests

2 participants