Coder Social home page Coder Social logo

goingnative's Introduction

Workshopper

Join the chat at https://gitter.im/nodeschool/workshoppers

Workshopper is no longer maintained

In mid-term workshopper will be replaced with workshopper-adventure. Please try to build new workshoppers against workshopper-adventure. Thanks. (your maintainer)

Readme until now:

A terminal workshop runner framework

NPM NPM

Learn You The Node.js For Much Win!

Workshopper is used by learnyounode, and other Node.js command-line workshop applications.

*Documentation is being written for the v1 rewrite right now! Ping @rvagg if you need anything. learnyounode is now using this new version, for now you can use it to see how this works.

For now, @linclark has written a good introduction on creating your own workshop, available here.

High-level overview

Workshopper is essentially a test-runner with a fancy terminal UI. The Workshopper package itself is largely concerned with the menu system and some of the basic command-line parsing. Much of the work for executing the exercise validation is handled by workshopper-exercise.

Contributors

workshopper is proudly brought to you by the following hackers:

Maintainers

License

Workshopper is Copyright (c) 2013-2015 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Workshopper builds on the excellent work by @substack and @maxogden who created stream-adventure which serves as the original foundation for Workshopper and learnyounode. Portions of Workshopper may also be Copyright (c) 2013 @substack and @maxogden given that it builds on their original code.

goingnative's People

Contributors

ccarruitero avatar dat2 avatar domenic avatar dtudury avatar eush77 avatar hmalphettes avatar jclulow avatar jkbits1 avatar julianduque avatar justinabrahms avatar koenkivits avatar mainarthur avatar martinheidegger avatar mcollina avatar mdda avatar nineninesevenfour avatar rvagg avatar ryan-cd avatar semitrivial avatar snowinferno avatar someoneweird avatar txase avatar vincishark avatar xeodou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goingnative's Issues

io.js / node 0.12 not supported?

It says on the first step that goingnative doesn't support "unstable" versions, which it seems to be equating to anything under 0.10.14 and over 0.10.35.

IIRC io.js v1.x and node.js 0.12.x are both stable. Are there any breaking changes to working native modules in these types of environments?

Typo in for_the_sake_of_argument/problem.md

On line 24 of for_the_sake_of_argument/problem.md:

Each element in the array is an object is a V8 type with a special function...

Should read something like

Each element in the array is an object which is a V8 type with a special function

(I'm not super familiar with C++ so my correction may not be accurate, but... I'll leave that up to someone who knows the content better.)

Am I ready error on osx

On osx I failed the verify with:

$ goingnative verify
✓ Found usable `gcc` in $PATH: v5.1.0
✓ Found usable `python` in $PATH: v2.7.5
✓ Found usable `node-gyp` in $PATH: v0.13.1
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/alan/Desktop/~test-addon.7844/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/alan/.node-gyp/0.10.28/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/alan/.node-gyp/0.10.28',
gyp info spawn args   '-Dmodule_root_dir=/Users/alan/Desktop/~test-addon.7844',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]

module.js:340
    throw err;
          ^
Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at [eval]:1:1
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:536:25)
    at startup (node.js:80:7)
    at node.js:906:3
gyp: Call to 'node -e "require('nan')"' returned exit status 8. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/alan/Desktop/~test-addon.7844
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok 
✗ Could not compile test addon

# FAIL

Your solution to AM I READY? didn't pass. Try again!

Python version is too new v2.6.6

$ goingnative verify
✓ Found usable node version: v0.12.7
✓ Found usable gcc in $PATH: v4.4.7
python version is too new: v2.6.6, please install a version >= v2.6.x and <= v2.7.x
✓ Found usable node-gyp in $PATH: v3.6.0

are you kidding??

Call Me Maybe - having multiple issues

First, I just want to say that I'm liking this package, so thanks for this! 🍺
However I'm having the following issues with this challenge:

  • The instructions say:

    Use the handle->IntegerValue() method, which returns a int64_t type value.

    However when you complete the challenge, the official solution doesn't use this function. This confused me a little bit. This confusion led me to the next issue.

  • The official solution doesn't compile for me. I copied the official solution file into myaddon/ directory and tried running $ node-gyp rebuild within the myaddon/ directory. I get the following errors:

    $ node-gyp rebuild
    gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | linux | x64
    gyp info spawn /usr/bin/python2
    gyp info spawn args [ '/home/kg/.nvm/versions/node/v5.0.0/lib/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/kg/Documents/gits/goingnative-lessons/myaddon/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/kg/.nvm/versions/node/v5.0.0/lib/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/kg/.node-gyp/5.0.0/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/home/kg/.node-gyp/5.0.0',
    gyp info spawn args   '-Dnode_gyp_dir=/home/kg/.nvm/versions/node/v5.0.0/lib/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/home/kg/Documents/gits/goingnative-lessons/myaddon',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.' ]
    gyp info spawn make
    gyp make: Entering directory '/home/kg/Documents/gits/goingnative-lessons/myaddon/build'
    info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    CXX(target) Release/obj.target/myaddon/myaddon.o
    ../myaddon.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE Delay(Nan::NAN_METHOD_ARGS_TYPE)’:
    ../myaddon.cc:10:70: error: no matching function for call to ‘To(v8::Local<v8::Value>)’
    Nan::MaybeLocal<Function> maybeCallback = Nan::To<Function>(info[1]);
                                                                      ^
    In file included from ../node_modules/nan/nan.h:199:0,
                 from ../myaddon.cc:1:
    ../node_modules/nan/nan_converters.h:53:38: note: candidate: template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>)
    typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
                                        ^
    ../node_modules/nan/nan_converters.h:53:38: note:   template argument deduction/substitution failed:
    ../node_modules/nan/nan_converters.h: In substitution of ‘template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>) [with T = v8::Function]’:
    ../myaddon.cc:10:70:   required from here
    ../node_modules/nan/nan_converters.h:53:38: error: invalid use of incomplete type ‘struct Nan::imp::ToFactory<v8::Function>’
    ../node_modules/nan/nan_converters.h:18:29: note: declaration of ‘struct Nan::imp::ToFactory<v8::Function>’
    template<typename T> struct ToFactory;
                               ^
    myaddon.target.mk:90: recipe for target 'Release/obj.target/myaddon/myaddon.o' failed
    make: *** [Release/obj.target/myaddon/myaddon.o] Error 1
    make: Leaving directory '/home/kg/Documents/gits/goingnative-lessons/myaddon/build'
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/home/kg/.nvm/versions/node/v5.0.0/lib/node_modules/node-gyp/lib/build.js:276:23)
    gyp ERR! stack     at emitTwo (events.js:87:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    gyp ERR! System Linux 4.2.0-19-generic
    gyp ERR! command "/home/kg/.nvm/versions/node/v5.0.0/bin/node" "/home/kg/.nvm/versions/node/v5.0.0/bin/node-gyp" "rebuild"
    gyp ERR! cwd /home/kg/Documents/gits/goingnative-lessons/myaddon
    gyp ERR! node -v v5.0.0
    gyp ERR! node-gyp -v v3.2.0
    gyp ERR! not ok 
    $

    Here's the output when I run goingnative verify myaddon/ with the official solution in place:

    $ goingnative verify myaddon 
    ✓ package.json contains `"gypfile": true`
    ✓ binding.gyp includes a "myaddon" target
    ✓ binding.gyp includes "myaddon.cc" as a source file
    ✓ binding.gyp includes a correct NAN include statement
    make: Entering directory '/home/kg/Documents/gits/goingnative-lessons/~test-addon.9565/build'
    CXX(target) Release/obj.target/myaddon/myaddon.o
    ../myaddon.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE Delay(Nan::NAN_METHOD_ARGS_TYPE)’:
    ../myaddon.cc:10:70: error: no matching function for call to ‘To(v8::Local<v8::Value>)’
    Nan::MaybeLocal<Function> maybeCallback = Nan::To<Function>(info[1]);
                                                                      ^
    In file included from ../node_modules/nan/nan.h:199:0,
                 from ../myaddon.cc:1:
    ../node_modules/nan/nan_converters.h:53:38: note: candidate: template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>)
    typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
                                        ^
    ../node_modules/nan/nan_converters.h:53:38: note:   template argument deduction/substitution failed:
    ../node_modules/nan/nan_converters.h: In substitution of ‘template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>) [with T = v8::Function]’:
    ../myaddon.cc:10:70:   required from here
    ../node_modules/nan/nan_converters.h:53:38: error: invalid use of incomplete type ‘struct Nan::imp::ToFactory<v8::Function>’
    ../node_modules/nan/nan_converters.h:18:29: note: declaration of ‘struct Nan::imp::ToFactory<v8::Function>’
    template<typename T> struct ToFactory;
                               ^
    myaddon.target.mk:90: recipe for target 'Release/obj.target/myaddon/myaddon.o' failed
    make: *** [Release/obj.target/myaddon/myaddon.o] Error 1
    make: Leaving directory '/home/kg/Documents/gits/goingnative-lessons/~test-addon.9565/build'
    ✗ node-gyp build: `make` failed with exit code: 2
    
    # FAIL
    
    Your solution to CALL ME MAYBE didn't pass. Try again!

am_i_ready/problem.md.tmpl: Could not find problem.txt or problem.md

Running goingnative print "AM I READY?" after a fresh install results in the following error:

Error loading exercise text: Could not find problem.txt or problem.md for [undefined]

Renaming exercises/am_i_ready/problem.md.tmpl to exercises/am_i_ready/problem.md works just fine.

Global installation error

when installed globally by command sudo npm install goingnative -g
It gives error

node postinstall.js

internal/fs/utils.js:269
    throw err;
    ^

Error: EACCES: permission denied, open '/usr/local/lib/node_modules/goingnative/exercises/am_i_ready/problem.md'
    at Object.openSync (fs.js:462:3)
    at Object.writeFileSync (fs.js:1384:35)
    at /usr/local/lib/node_modules/goingnative/postinstall.js:17:6
    at /usr/local/lib/node_modules/goingnative/node_modules/getos/index.js:100:16
    at /usr/local/lib/node_modules/goingnative/node_modules/async/lib/async.js:52:16
    at Object.async.forEachOf.async.eachOf (/usr/local/lib/node_modules/goingnative/node_modules/async/lib/async.js:236:30)
    at Object.async.forEach.async.each (/usr/local/lib/node_modules/goingnative/node_modules/async/lib/async.js:209:22)
    at /usr/local/lib/node_modules/goingnative/node_modules/getos/index.js:80:13
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3) {
  errno: -13,
  syscall: 'open',
  code: 'EACCES',
  path: '/usr/local/lib/node_modules/goingnative/exercises/am_i_ready/problem.md'

Going native needs a massive upgrade

I am one of the mentors of CharmCityJS Node School in Baltimore. We teach once a quarter and most who attend are newbies. Since they are new, they are using the LTS version of Node and, realistically, are not able downgrade to Node 6 in order for this workshop to work. Going Native needs to be upgraded to use more recent versions of Node. I have already opened an issue with another workshop, so this needs to be dealt with.

Possible move to the "workshopper" org

See workshopper/learnyounode#254 for context.

I'm moving learnyounode and my workshopper-* repos over to the workshopper org for better governance and collaboration and to help remove myself as the primary bottleneck to progress. I'm unsure about whether to move this module or not since it's not as core as learnyounode. I also have a bunch of collaborators in here who have never really been active on the project and probably don't need to be part of the workshopper org although I'm happy to bring you along if you're keen.

Any thoughts from collaborators?

mission possible part 3, documentation missing module registration

Documentation appears to be missing this step:

NODE_MODULE(addon, Init)

Making an issue now, but will come back with a pr when i get an extra moment.

Should this be something mentioned in the prompt for this step? or should it be included in the generated .cc file?

This tripped me up for a bit :/

MS Visual Studio 2013

I should be able to use VS 2015 if that's what I have installed. I can pull this code to a local file and work on getting that to work, Is this feasible? Where do I look for the check?

Running "Offloading The Work" fails w/ anonymous function

I'm working on the final tutorial, "Offloading The Work".

My solution fails if my delay is invoked as follows with provided code:

addon.delay(process.argv[2], function() {
  clearInterval(interval)
  console.log('Done!')
})

By making the callback non-anonymous, the solution passes:

addon.delay(process.argv[2], function callback() {
  clearInterval(interval)
  console.log('Done!')
})

Windows?

I would hope for there to be a few Windows users in the class.
We should try to make sure they're supported as well :)

Publish v2.0.8

Hi @workshopper/deploy

I updated the workshopper dependencies and fixes errors when compile solutions.

I would like to publish a new version, so people can get a working version of this workshopper.

Can you publish this new version (v2.0.8)?

cc @martinheidegger @julianduque @AnshulMalik

Compilation errors.

I'm having a problem verifying myaddon. I get the following output:

✓ package.json contains `"gypfile": true`
✓ binding.gyp includes a "myaddon" target
✓ binding.gyp includes "myaddon.cc" as a source file
✓ binding.gyp includes a correct NAN include statement
make: *** No rule to make target `Release/obj.target/myaddon/myaddon.o', needed by `Release/myaddon.node'.  Stop.
✗ node-gyp build: `make` failed with exit code: 2

All other prior verification steps have passed. Any idea why this might be breaking? I'm using:

  • node v0.10.26
  • python 2.7.5
  • GNU Make 3.81
  • gcc:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

Thanks!

running the 2nd problem from the menu generates many `myaddon` dirs

If you re-run the instructions for the first "mission possible" problem statement instead of using "goingnative print", it will generate lots & lots of new myaddon folders. It will also generate myaddon dir nested inside a myaddon dir.

Recording this bug here because it was a source of confusion among workshoppers, who mostly didn't know about print.

node version too new using v8.11.3

Maybe the workshop can stick to the LTS release which is not often changed?
LTS version has both freshness and reliability.
The official also recommend it for most of users.

So the ./exercises/am_i_ready/vars.json can have the node options like:

"node": {
      "min": "8.0.0", // keep the major release
      "max": "8.11.3" // the newest LTS version
},

Nan 2.x

Now that Nan 2.x has been released this should probably be updated.

"mission possible: part two" fails in Node.js 4 and 5, however it works on 0.10

Being unable to finish the part two of goingnative with Node.js LTS and Stable

Node.js 4

» goingnative verify myaddon
✓ package.json contains `"gypfile": true`
✓ binding.gyp includes a "myaddon" target
✓ binding.gyp includes "myaddon.cc" as a source file
✓ binding.gyp includes a correct NAN include statement
(node) child_process: options.customFds option is deprecated. Use options.stdio instead.
gyp: /Users/david/.node-gyp/4.2.4/common.gypi not found (cwd: /Users/david/code/nodeschool/going-native/~test-addon-faux.4372) while reading includes of binding.gyp while trying to load binding.gyp
✗ Compile mock C++ to test JavaScript: node-gyp configure: `gyp` failed with exit code: 1

# FAIL

Your solution to MISSION POSSIBLE: PART TWO didn't pass. Try again!

Node.js 5

$ goingnative verify myaddon
✓ package.json contains `"gypfile": true`
✓ binding.gyp includes a "myaddon" target
✓ binding.gyp includes "myaddon.cc" as a source file
✓ binding.gyp includes a correct NAN include statement
✗ Compile mock C++ to test JavaScript: node-gyp configure: 404 status code downloading SHASUMS.txt

# FAIL

Your solution to MISSION POSSIBLE: PART TWO didn't pass. Try again!

Sleep is passed correctly but always fails as taking too long

I have copied the solution you have and everything is OK but every time I sleep for 111 (correct value passed in) I always get an error along the lines of

V JavaScript code loads addon and invokes delay(x, cb) method
? Slept for the right amount of time (asked for 111ms, slept for 1455)

This is the C++ code

NAN_METHOD(Delay)
{
int delay = info[0].As()->IntegerValue();
Local callback = info[1].As();

ifdef _WIN32

Sleep(delay);

else

usleep(delay * 1000);

endif

Nan::MakeCallback(Nan::GetCurrentContext()->Global(), callback, 0, NULL);

return;

}

I am running on Windows 7 with x64 and I have tried this with node 0.10 and other versions. Is there something that is causing the function not to exit in a timely manner?

Objects and Buffers

First of all thanks bunches for goingnative, I just finished and it is a awesome learning tool! One more thing that I think would be great to cover is objects and buffers. Stuff that I'm currently working on trying to figure out how to read a buffer from a object and how to return buffers. Thanks!

Error on Windows with verifying and folder names with space characters

Issue:

When trying to run:

goingnative verify

On a Windows 8.1 (64bit) machine the program gives the following error:

 Could not properly compile test addon, error finding binding: Could not locate the binding file

Possible cause of issue:

The program can not handle being run from a (sub) directory that has a space character in the name. The displayed list of files it is trying to write/test/use are in a non existing directory. Say folder is called 'Fooz Baz' than it will run in C:\Users\Person\etc\Fooz\* instead of C:\Users\Person\etc\Fooz Baz\*

Running it from a directory without a space character in the name fixes the issue.

Call Me Maybe - Unable to verify solution

I've added the appropriate code to my module, it compiles fine with node-gyp rebuild and runs exactly as expected when I run it with node . <time in ms> however when time I try to verify I get the following message.

I'm running this using nvm installed node v0.10.40, npm 2.14.2, and node-gyp v3.0.3

message:

$goingnative verify myaddon
✓ package.json contains `"gypfile": true`
✓ binding.gyp includes a "myaddon" target
✓ binding.gyp includes "myaddon.cc" as a source file
✓ binding.gyp includes a correct NAN include statement
  CXX(target) Release/obj.target/myaddon/myaddon.o
  SOLINK_MODULE(target) Release/myaddon.node
  SOLINK_MODULE(target) Release/myaddon.node: Finished
  CXX(target) Release/obj.target/myaddon/myaddon.o
../myaddon.cc:10:45: error: no matching function for call to 'To'
  Nan::MaybeLocal<Function> maybeCallback = Nan::To<Function>(info[1]);
                                            ^~~~~~~~~~~~~~~~~
../node_modules/nan/nan_converters.h:53:38: note: candidate template ignored: substitution failure [with T = v8::Function]: implicit instantiation of undefined template
      'Nan::imp::ToFactory<v8::Function>'
typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
~~~~~~~~                             ^
1 error generated.
make: *** [Release/obj.target/myaddon/myaddon.o] Error 1
✗ Compile mock C++ to test JavaScript: node-gyp build: `make` failed with exit code: 2

# FAIL

Your solution to CALL ME MAYBE didn't pass. Try again!

myaddon.cc:

#include <nan.h>

#ifndef _WIN32
#include <unistd.h>
#endif

using namespace v8;

NAN_METHOD(Delay) {
    using Nan::To;
    using Nan::MaybeLocal;
    Nan::HandleScope scope;
    MaybeLocal<Number> maybeNum = To<Number>(info[0]);
    if (maybeNum.IsEmpty() == false) {
        int64_t sleep_time = maybeNum.ToLocalChecked()->IntegerValue();
        #ifdef _WIN32
        Sleep(sleep_time);
        #else
        usleep(sleep_time * 1000);
        #endif
        Local<Function> callback = info[1].As<Function>();
        Nan::MakeCallback(Nan::GetCurrentContext()->Global(), callback, 0, NULL);
    }
}

NAN_MODULE_INIT(Init) {
  Nan::Set(target, Nan::New("delay").ToLocalChecked(),
      Nan::GetFunction(Nan::New<FunctionTemplate>(Delay)).ToLocalChecked());
}

NODE_MODULE(myaddon, Init)

installation error

Been struggling with this one for a couple days now:

npm ERR! [email protected] postinstall: node postinstall.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the goingnative package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node postinstall.js
npm ERR! You can get their info via:
npm ERR! npm owner ls goingnative
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "goingnative"
npm ERR! cwd C:\Users\MRI
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! syscall spawn
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! not ok code 0

Windows 7, 64. All other learning apps install fine. Using VC++ Express 2013 Desktop.

URL is not rendering properly

I'm seeing Visit [http://](http://) to download a new version or use your local package manager to upgrade. in the first exercise.
Even though in the sources, I can see a valid URL, it seems to be just not rendering correctly from the template file.

python switch

The python switch doesn't seem to working. I would like todo
goingnative verify --python=python2.7

Getting the following error. Everything specified is installed.

✗ Could not properly compile test addon, did not load binding
✗ /usr/local/lib/node_modules/goingnative/exercises/am_i_ready/child.js:17
✗ if (binding.test !== 'OK') {
✗ ^
✗ TypeError: Cannot read property 'test' of undefined
✗ at Object. (/usr/local/lib/node_modules/goingnative/exercises/am_i_ready/child.js:17:12)
✗ at Module._compile (module.js:397:26)
✗ at Object.Module._extensions..js (module.js:404:10)
✗ at Module.load (module.js:343:32)
✗ at Function.Module._load (module.js:300:12)
✗ at Function.Module.runMain (module.js:429:10)
✗ at startup (node.js:139:18)
✗ at node.js:999:3
✗ Test binding file works as expected

part two get `Could not verify: Error: EISDIR`

I get this error in part two but didn't find any difference between my code and solution

> goingnative verify myaddon
Could not verify: Error: EISDIR: illegal operation on a directory, open 'C:\Users\thy\Documents\node-native\~test-addon-faux.3166'

My code:

> ls .\myaddon\


    目录: C:\Users\thy\Documents\node-native\myaddon


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2021/8/24     19:54                node_modules
-a----         2021/8/24     20:08            217 binding.gyp
-a----         2021/8/24     20:32             86 index.js
-a----         2021/8/24     20:43              0 myaddon.cc
-a----         2021/8/24     20:00            269 package.json

index.js

const bindings = require('bindings')
var addon = bindings('myaddon')

addon.print()

Error when running in git-bash

Using git-bash on Windows, running goingnative produces the following output:

$ goingnative
C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goingnative\node_modules\terinal-menu\index.js:61
    process.stdin.setRawMode(true);
                  ^

TypeError: process.stdin.setRawMode is not a function
    at new Menu (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goingnativenode_modules\terminal-menu\index.js:61:19)
    at module.exports (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goingative\node_modules\terminal-menu\index.js:8:12)
    at showMenu (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goingnativenode_modules\workshopper\menu.js:14:18)
    at Workshopper.printMenu (C:\Users\Vidminas\AppData\Roaming\npm\node_module\goingnative\node_modules\workshopper\workshopper.js:325:14)
    at new Workshopper (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goinnative\node_modules\workshopper\workshopper.js:172:8)
    at Workshopper (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\goingnatve\node_modules\workshopper\workshopper.js:20:12)
    at Object.<anonymous> (C:\Users\Vidminas\AppData\Roaming\npm\node_modules\gingnative\goingnative.js:20:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)

Some investigation seems to show that this is connected to git-bash not providing TTY streams:

call me maybe: timing off?

The instructions to "Call me Maybe" say that Sleep takes milliseconds and usleep takes microseconds. We accept an integer from the command line which is total number of seconds.

Why is it that the reference solution is Sleep(delay) and not Sleep(delay * 1000) ?

Suggested solution to "Offloading The Work" doesn't seem correct

The suggested solution uses a Nan::To<Function> which, at least here, doesn't compile:

See link: https://github.com/workshopper/goingnative/blob/master/exercises/offloading_the_work/solution/myaddon.cc#L41

The compiler tells me this:

make: Entering directory `/mypath/going-native/myaddon/build'
  CXX(target) Release/obj.target/myaddon/myaddon.o
../myaddon.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE Delay(Nan::NAN_METHOD_ARGS_TYPE)’:
../myaddon.cc:42:27: error: no matching function for call to ‘To(v8::Local<v8::Value>)’
  Nan::To<Function>(info[1]);
                           ^
../myaddon.cc:42:27: note: candidate is:
In file included from ../node_modules/nan/nan.h:199:0,
                 from ../myaddon.cc:1:
../node_modules/nan/nan_converters.h:53:38: note: template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>)
 typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
                                      ^
../node_modules/nan/nan_converters.h:53:38: note:   template argument deduction/substitution failed:
../node_modules/nan/nan_converters.h: In substitution of ‘template<class T> typename Nan::imp::ToFactory<T>::return_t Nan::To(v8::Local<v8::Value>) [with T = v8::Function]’:
../myaddon.cc:42:27:   required from here
../node_modules/nan/nan_converters.h:53:38: error: invalid use of incomplete type ‘struct Nan::imp::ToFactory<v8::Function>’
../node_modules/nan/nan_converters.h:18:29: error: declaration of ‘struct Nan::imp::ToFactory<v8::Function>’
 template<typename T> struct ToFactory;
                             ^

It would be nice to have an example on how we get a Nan::MaybeLocal<v8::Function> (or whatever) or how to check if a passed argument is a function.

Project summary

Huh?

goingnative is a workshopper for learning how to write native Node.js addons, it's slated for release & use at NodeConf (next week!). I was supposed to start this long ago but ... you know how it goes.

Who?

I've added a bunch of people to this repo, as far as I'm concerned this will be an open project (well, it's technically "closed" until next week) and I'm happy to share ownership and leadership with anyone that has significant contributions to make.

However, I know I've just thrown a bunch of you in here without asking so please if you don't have time or interest in this at the moment and don't want to be spammed then I'd be happy to take you off the collaborators list, just let me know.

@ceejbot and @tjfontaine are here because they are down as running this workshop at NodeConf with me, unfortunately I know they are both super busy with their respective employment, I'm hoping to be able to squeeze some blood out of that stone though!

@wblankenship and @expr are here because I know, through my work with them at NodeSource that they are awesome and should have a lot to offer here in terms of the learning experience.

@trevnorris and @thlorenz are here because I know they have a ton to offer on the C++ side, I don't know realistically how much I can expect to squeeze out of them in terms of time though and @thlorenz is scheduled to help with another workshop at NodeConf anyway.

@TooTallNate and @kkoopa are here because I know from experience that they have a ton of skill and knowledge in this area that would be hugely valuable if they are able to contribute.

What?

The goal here is pretty ambitious, particularly for NodeConf. We need to teach Node/JS programmers how to write native addons. Unfortunately, there is a strong allergy to C++ amongst that cohort in general so we'll have to do lots of handholding and provide lots of up-front boilerplate to point people in the right direction. The success of this will come from the right balance of boilerplate and document to actual code challenges.

learnyounode is the foundational example for building this type of thing, it's basically a terminal-based self-driven programming learning tool that provides you with challenges that ramp up in complexity and you have to complete those challenges successfully to proceed. The expectation is not that people will be able to finish this in a sitting, or even want to finish it all, it's just to give them a taste and get them started and provide enough of a learning path for those wanting to dig deeper.

I'm also thinking of ditching hopes of Windows support, for NodeConf at least. I have a docker build script that can build a dev environment that I can spin up enough instances of and hand out ssh access to separate containers to people in the workshop (@ NodeConf) who don't have suitable dev environments, or who would waste the whole time trying to get their dev environment ready. Unfortunately this assumes you're comfortable with dev over SSH and using a unixy code editor!

Another complication is the V8 variability, so I'm going to lean on nan to get this done in a way that doesn't involve having to explain all that junk. Unfortunately this is quite heavy so it'll almost make it a "nan workshopper" but I don't see a good way around that, and besides, a good portion of current native addons are using nan so it's not an isolated ecosystem. It might be possible to offer a raw 0.10 and another 0.12 version that doesn't use nan without too much hassle, but that's too complex for now.

Structure

Here's my current thoughts on an exercise structure, this is really rough and will likely change as we develop and I'm hoping that you all have ideas on how to improve this:

  1. AM I READY?: There's no coding involved in this one, typing goingnative verify for this will invoke a checker that will determine if you have: a compiler, node-gyp, python 2.x, and anything else that might be needed to get started.
  2. LET'S MAKE SOMETHING COMPILE!: Provide the user with a directory containing the basics needed to make an addon, including a package.json, binding.gyp and even an addon.cc that is partially complete but won't compile without adding some really basic code. We might even want to have package.json and binding.gyp incomplete too and they have to complete it all to pass the exercise. I'm thinking that the code can just use a simple printf to print something to stdout so there's very little complex C++ or V8 involved in making this work. Validation will be tricky but it'll have to involve at least invoking a build and running the resulting addon to make sure it works as expected.
  3. IT'S A TWO-WAY STREET: Get the user to extend the previous exercise to accept a method argument and then return something back to the calling function. This could be split up into two exercises ("IT'S A ONE-WAY STREET"?).
  4. IT'S ALL ABOUT SCOPE: It might be interesting to leave NanScope() (HandleScope) off the previous exercises completely, perhaps leaving a note in the boilerplate file saying something like // this code is intentionally incomplete and requires a Scope and point them to a later exercise that will introduce the concept of a scope. This exercise could have provide them with an addon that has no scope and when run is observed leaking memory. Their job is to stop the leak by adding a NanScope(). Maybe too simple?
  5. CALL ME MAYBE: Invoking a callback argument using MakeCallback (well, NanMakeCallback anyway)
  6. OBJECTIFICATION: Create a v8::Object and populate it with something, a String property, a Number property and maybe even a Function?
  7. OBJECTIFY ALL THE THINGS: Using ObjectWrap to wrap up a C++ object for JS use.
  8. OFFLOADING THE GRUNT WORK: A precursor to the next exercise, I'm thinking that we could get them to do some CPU intensive work in C++ and pass the result back to JS.
  9. TEAM GRUNT WORK: Take their previous exercise and split the work off into a worker thread and provide the result via a callback. Pi estimation is the example I keep on using for "CPU intensive" work and could be applicable here.

Validation in most existing workshoppers is done via running the solution code in parallel to the submission code and using stdout to compare the results. Sometimes this involves hijacking stdout to replace it with some kind of reporter. The latest workshopper incarnation (v1) doesn't force this as a requirement and I don't imagine we'll have use for it here. Validation will take the form of a script that performs a series of actions to confirm that individual components of the work are complete and correct. The user gets feedback in the form of ticks and crosses to their console for each of these so they can clearly see where they messed up if they get a failure.

Action

I'm diving right in to this, but I'm going to be doing a rough job of each of them as I go and come back and perfect later. Help would be appreciated with coding and also wording the questions, coding the solutions and making the validations fine-grained enough so that the user gets clear feedback about what they've done wrong and it's very difficult to cheat the system.

Could you please let me know if you don't want to be involved, and if you do want to be involved, in what capacity do you think you could be helpful and what would you like to try and tackle?

Testing getos on Ubuntu

Ubuntu is one of those strange distributions that shares a /etc/release file with another distribution. My algorithm for falling back through that list and finding the correct distro *should work but hasn't actually been tested.

When the dust settles, I may make some docker images of some of the systems in os.json and have a travis-ci build use them for tests...

Status of this project?

Heya folks. I don't really maintain this anymore, haven't worked directly with native modules in well over 4 years.

This project doesn't appear to have any other active maintainers and isn't relevant for modern native module development.

Should we be looking for new maintainers? Should we deprecate this? Thoughts?

Does it work with Node 4.2 ?

I'm having issues with exercise "mission impossible: part two", apparently node-gyp cannot download some files.

Jacopos-MacBook-Pro:~ utente$ goingnative verify myaddon
✓ package.json contains `"gypfile": true`
✓ binding.gyp includes a "myaddon" target
✓ binding.gyp includes "myaddon.cc" as a source file
✓ binding.gyp includes a correct NAN include statement
✗ Compile mock C++ to test JavaScript: node-gyp configure: 404 status code downloading SHASUMS.txt

# FAIL

Your solution to MISSION POSSIBLE: PART TWO didn't pass. Try again!

googling, I found that it is likely a problem with a file which changed name with the recent version of nodejs.
I tried to remove my ~/.node-gyp folder and myaddon/node_modules, reinstall node-gyp and install the latest version of nan and bindings removing them from the package.json and reinstalling them from npm, but the problem persists.

Does goingnative 2.0.4 supports Node 4.2 ? I have no idea where to look to see which version of the files node-gyp is being asked to download.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.