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

Enhancement: Node.js Local Document Generator #531

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

MutableLoss
Copy link

Update One adding custom Node.js documentation building, to start the upgrade process per Issue #503 .

The new API module is setup to create new documents once learnyounode is started, generating to node_apidoc and the version reflecting the version of Node.js used to execute. To keep with the consistency of offering an offline solution, all requests are made locally so there is no need for connectivity after the deps have been installed.

Note: Once the documents are created any future requests will be ignored as long as the folder exists, making sure not to add overhead on every single run. If a user accidentally removes the doc folder, it will recreate that folder on the next run.

To remove the need to overwrite files, reduce size, and redundancy the old 0.10 apidoc folder has been removed.

@MutableLoss
Copy link
Author

The CI build check is choking on the docbuild file which cannot get past the test. I am not sure what to do to get around the errors on the require calls, but everything works as intended.

lib/docbuild.js Outdated
@@ -0,0 +1,7 @@
createDocs = require('node-offline-api').createDocs
buildOptions = require('node-offline-api').buildOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use something like var buildOptions = require('') or const may be.

That would help the test to pass.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AnshulMalik !

Wow, what in the world was I doing when I submitted that? I think I spent a little too much time with Ruby that day. :)

It has been done! Using var for now, until the lowest version of Node is a specific, then I can cross-check the available ES6 sugar that can be safely used.

@MutableLoss
Copy link
Author

Looks like one more issue where it is checking the local file build, and adding the default folder path. Fix on the way up.

@AnshulMalik
Copy link
Contributor

Looks like the travis is still unhappy :P

@MutableLoss
Copy link
Author

MutableLoss commented Jun 2, 2017

Ok, it looks like it is now failing on the official Node.js document generator API that is part of the offline document API, otherwise it seems to be working as intended. I could go through those files, and change them all to standard if needed, and it should remove any of the CI errors.

Actually, going to check out this EEXISTS issue first.

@MutableLoss
Copy link
Author

Ok, I see now. It is catching the fs.stat error which isn't an actual error. Let me quiet that down, and see if it will ignore the standard on the official after that. Fix coming up.

@MutableLoss
Copy link
Author

MutableLoss commented Jun 2, 2017

Well, the fatal errors are gone now. The only issue with the tests is where the tests see some of the verbosity of the API when testing the exercises.

The reason for this is due to running that offline document API upon startup. It is run quietly per the buildOptions.quiet setting so no one actually sees this when running LYN, and it only runs when the document directory does not exist (first run unless doc dir is removed). For some reason the exercise tests still see these in the test though.

EDIT: Yep, I need to check this out. It seems when running it with next/verify/help/etc the messages still show. I'll create a new fix in the morning. Apologies for all of the surprises there at the end.

@MutableLoss
Copy link
Author

Ok, refactored, and re-released module to allow 100% passing locally.

@MutableLoss
Copy link
Author

It looks like there is a possible issue when validating files. I'm going to take the weekend to look for a way to limit the possible executions, instead of running on every instance.

@MutableLoss
Copy link
Author

Since I rebased with the latest master, it seems that the 5.x build is now erroring, but the 6.x and 7.x tests are passing. Unfortunately the 5.0 build is giving an npm error that if cannot find the function Buffer.alloc, which requires Node.js 5.10.0+ and the CI is using 5.0.0:

screen shot 2017-12-01 at 19 14 02

screen shot 2017-12-01 at 19 16 08

Looking through my latest source, I am not finding this being called. It looks like this is an external issue, but not sure where when no node modules are being installed due to the error.

Please let me know if you need anything from me, as I would love to see this move forward so I can continue to help with new updates to help make this a more recent-friendly workshop. 😃

Copy link
Contributor

@martinheidegger martinheidegger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged this PR against a test-branch and the build seems to be working now: https://travis-ci.org/workshopper/learnyounode/builds/343205079

But I added some response on how to improve this PR. It would be awesome if this could find its way into master.

package.json Outdated
@@ -80,7 +81,7 @@
"workshopper-adventure-test": "^1.1.2"
},
"scripts": {
"lint": "./node_modules/.bin/standard",
"lint": "./node_modules/.bin/standard --fix",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be part of THIS pr! (Note: during development you can run npm run lint -- --fix

lib/docbuild.js Outdated
buildOptions.buildName = 'node_apidoc'

fs.stat('../node-apidoc', function (err) {
if (err) { createDocs() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can theoretically be various errors here. I think the .code === "ENOENT" is the error we are looking for.

buildOptions.buildDir = process.cwd()
buildOptions.buildName = 'node_apidoc'

fs.stat('../node-apidoc', function (err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to avoid modules without an export, can this module also wrap the operation in a module?

bin/learnyounode Outdated
require('../learnyounode').execute(process.argv.slice(2))

if(process.argv.slice(2) == 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is not standard syntax)

Workshopper has a commands option that allows to register custom commands just for this purpose. Of course there should be a postinstall script that launches this command.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge thanks Martin. I'll get these knocked out this week.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all resolved. It doesn't like like I can mark these resolved, so just leaving a reminder since I know you're very busy.

@MutableLoss
Copy link
Author

MutableLoss commented Mar 11, 2018

I went ahead and cleaned up the module, and added the postinstall script. Let me know if there is anything else that you feel would work better, or be more ideal in other situations.

EDIT: rebased the branch due to some lockfile conflicts. Not sure if you want an updated lockfile, so left it as-is until later.

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

Successfully merging this pull request may close these issues.

None yet

3 participants