How to debug a Meteor plugin file? - meteor

I've followed Meteor Doc to register a plug-in package.
Created a plug-in file in the package/plugin/ folder
Added a debugger; in that file.
ran $ meteor debug;
Problem: debugger; directive is ignored. How to debug the plug-in file?
Thx!
plugin/compile-atscript.js:
Plugin.registerSourceHandler(
'ats'
, function (compileStep) {
var source = compileStep.read().toString('utf8');
console.log('source: ' + source);
debugger;
console.log('compiled source: ' + source);
});

The Meteor tool runs build plugins in-process, so you just need to run it under the debugger. On Linux and Mac OS X, the launcher script supports a TOOL_NODE_FLAGS variable that can be used to pass arguments to the Node.js runtime to enable debugging. See the instructions for debugging the Meteor tool, although these are geared toward use with a git checkout of Meteor. A hacky shortcut:
METEOR_INSTALLATION=~/.meteor/packages/meteor-tool/$(meteor --long-version | sed -ne 's/^meteor-tool#//p')/mt-$(meteor --arch)
TOOL_NODE_FLAGS=$METEOR_INSTALLATION/dev_bundle/lib/node_modules/node-inspector/bin/node-debug.js $METEOR_INSTALLATION/meteor
(Note, using just meteor on the last line may not work because when the default version of the Meteor tool executes the proper version for the app, the debugger would be started a second time.)
On Windows, support for TOOL_NODE_FLAGS was added to the launcher script in Meteor 1.4.4. If the app is using an older version of Meteor, one could manually edit the launcher script. The commands to start debugging would look like:
set METEOR_INSTALLATION=%LOCALAPPDATA%\.meteor\packages\meteor-tool\TOOL_VERSION\mt-os.windows.x86_32
set TOOL_NODE_FLAGS=%METEOR_INSTALLATION%\dev_bundle\lib\node_modules\node-inspector\bin\node-debug.js
%METEOR_INSTALLATION%\meteor.bat
(Someone else is welcome to add copy-and-pasteable code to figure out the correct TOOL_VERSION!)

On macOS
Set Environment variable
export TOOL_NODE_FLAGS="--inspect-brk"
List env vars
printenv
Run meteor
meteor
Debugger will be listening and will get attached to Chrome dev tools on opening the Chrome Browser.

Related

'flutterfire configure' command not working, I need to set firebase in my flutter project

I followed "https://firebase.flutter.dev/docs/overview" instruction to set firebase in my flutter project.
step i took:
"flutter pub add firebase_core" then dependencies were added, and generated_plugin_registrant.dart was created.
generated_plugin_registrant.dart file
2) "dart pub global activate flutterfire_cli" it showed an warnign message ie "Warning: Pub installs executables into C:\Users\Asus\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
Activated flutterfire_cli 0.1.1+2."
then i added "C:\Users\Asus\AppData\Local\Pub\Cache\bin" in system; "path" environment variable.
"flutterfire configure" now it gives error "bash: flutterfire: command not found".
Step by step commands for getting flutterfire work in Mac:
dart pub global activate flutterfire_cli
export PATH="$PATH":"$HOME/.pub-cache/bin"
curl -sL https://firebase.tools | bash
firebase login
flutterfire configure
More details here
Windows Step-by-Step guide:
Open the Windows Search Bar, type in “env”, and choose “Edit the system environment variables”
Click the “Environment Variables…”
In System Variables box, search for "PATH" and double click on it
Click "New" and then paste the following line, replacing *USERNAME* with your Windows username
C:\Users\*USERNAME*\AppData\Local\Pub\Cache\bin
Click Ok and restart your IDE, then try flutterfire commands
I had the same problem. Following command worked for me (in Windows).
flutterfire.bat configure
I had same problem and I solved this by:
Added C:\Users\<username>\AppData\Local\Pub\Cache\bin to Environment Path.
Restarted IDE
Executed command: dart pub global activate flutterfire_cli
Here's a solution that worked for me:
From your terminal,open your bash profile in your home directory. Example home directory, Users/your-name/. I'm using macOS, so I typed typed the command sudo vim ~/.bash_profile from my home directory folder, followed by E to edit.
Scroll to the bottom of the file or below # Flutter ENV, on your keyboard, hit i to insert, then paste the following line, export PATH="$PATH":"$HOME/.pub-cache/bin". Press ESC, type ":wq!" then press Enter to save the changes and exit vim.
From the command line, reload your bash profile with source ~/.bash_profile. flutterfire configure should now work.
Hrishabh
This worked for me.
Close your IDE.
Restart IDE.
Re-run "flutter pub add firebase_core" in your terminal.
Finally run "dart pub global acttivate flutterfire_cli" in your terminal.
I had the same problem here is the way to solve it:
Warning: Pub installs executables into C:\Users\userName\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
Go the Windows searchbar and write var
Select modify system environment
Click on environment variables
On system variables click on Path
Click on Edit
On the modify the environment variable windows click on New
Copy paste C:\Users\userName\AppData\Local\Pub\Cache\bin
Close all the windows clicking on Ok
Restart Android Studio
Inside Android Studio terminal write this to check if succeed
dart pub global activate flutterfire_cli
You should have the following message:
The package flutterfire_cli is already activated at newest available version.
On windows, from flutter root folder, running 'flutterfire configure' I got the same error message.
The 'problem' was resolved when I removed the following lines from pubspec.yaml.
plugin:
platforms:
ios:
pluginClass: AppDelegate
(I added those lines in an attempt to create a "podfile" that is required in order to create a binary ios file. )
For me it required a little bit more work but this is what worked for me, I'm using Windows:
As mentioned already before I ran these steps:
1). Search for "Edit System Environment Variables"
2). Click on Environment Variables
3). Under System Variables, double click on "path."
4). Click on "New" and add C:\Users\USERNAME\AppData\Local\Pub\Cache\bin
5). Click OK and restart IDE
After restarting IDE I ran the following commands in the terminal and this time it worked
1). Firstly, flutter upgrade firebase_core
2). Then, I ran dart pub global activate flutterfire_cli again and this time when I ran flutterfire commands it worked.
For me it wasn't working in bash. When i switched over to the standard windows comand prompt it worked.

Atom Javascript Console

I've tried to use Script and atom-js-console on atom but when I run code using script I get this message 'env: node: No such file or directory'. How can I get a console that works with running javascript code on atom.
I recommend you hook it up to a web but if you want it inside of the atom-editor itself then there are packages for running it inside of the atom editor it self. Note: These packages copy chromes"inspect" view so don't expect it to be very optimised.

Logging console output using Qt Installer Framework scripting

I added some console.log("xxxxxx") via component / controller scripting to my installer.
ie.
function Controller()
{
console.log("OS: " + systemInfo.productType);
}
How can I view the console log during the running of the installer?
Not sure if you can see a log during installation. But after a "successful" installation the TargetDir will contain a file named InstallationLog.txt that contains all the console.log lines from the installation process.
Edit: To see it live, do like #CherryDT points out in his comment: Run your installer from the command line and provide the -v parameter (fx my_installer.exe -v).
Edit: The previous Edit is slightly wrong, check #KcFnMi answer.
To see console.log information at runtime (the time you're running the installer, not the time you are building the installer) do:
installer.exe -d
or
installer --version
-d, --verbose Verbose mode. Prints out more information.
https://doc.qt.io/qtinstallerframework/ifw-cli.html
Note: It's not -v:
-v, --version Displays version information.

Can I invoke gulp from a cake-build file?

I have an ASP.NET solution where I perform some tasks using gulp (e.g. less-compilation). Inside Visual Studio the corresponding gulp-task is bound to the BeforeBuild event, so it is automatically started whenever I build the solution.
I was experimenting with cake for building and packaging the solution. While building the solution works fine using either the DotNetBuild() or MSBuild() tasks, the gulp tasks are not executed during the build.
It seems that gulp (and probably also other task runners) are not automatically "integrated" in the build process.
Does cake somehow support invoking gulp during the build?
(Of course, it should ideally also restore gulp itself (using npm / package.json) if it is not available.)
Note: This answer was copied from the
Cake issue response
by Mattias Karlsson (with his permission).
Just did a quick look so I might be missing something, but checking the
csproj file, the BeforeBuild MSBuild target seems to be empty?
Visual Studio 2015 has a built-in task runner for Gulp/Grunt so this
might be what's kicking in.
Currently we don't have aliases for NPM or Gulp (that would be an
great addin though), but what you could do is to invoke Gulp yourself
via the StartProcess alias. I tweaked your build.cake slighly below:
var target = Argument("target", "Default");
DirectoryPath solutionDir = MakeAbsolute(Directory("./"));
FilePath solution = solutionDir.CombineWithFilePath("WebApplication1.sln");
DirectoryPath projectDir = solutionDir.Combine("WebApplication1");
FilePath lessOutput = projectDir.CombineWithFilePath("css/style.css");
Task("Default")
.Does(() =>
{
NuGetRestore(solution);
if (FileExists(lessOutput))
{
Information("Cleaning old less output {0}", lessOutput);
DeleteFile(lessOutput);
}
StartProcess("cmd", new ProcessSettings {
Arguments = "/c \"set CI=true && npm install && gulp compile-less\"",
WorkingDirectory = projectDir
});
if (!FileExists(lessOutput))
{
throw new Exception("Less failed to create " + lessOutput);
}
Information("Less created {0}", lessOutput);
MSBuild(solution);
});
RunTarget(target);
This assumes you have Node & Gulp installed globally (you install Gulp
globally via running npm install -g gulp), also this was 5 min quick
and dirty, so you would want to divide clean/restore/less into separate
cake tasks. I set environment CI=true because some node modules
could require user interaction on restore otherwise.
Discarding MSBuild / NuGet restore above will output something like:
Cleaning old less output C:/temp/cake_issue_672/WebApplication1/WebApplication1/css/style.css
[11:26:12] Using gulpfile C:\temp\cake_issue_672\WebApplication1\WebApplication1\gulpfile.js
[11:26:12] Starting 'compile-less'...
[11:26:13] Finished 'compile-less' after 29 ms
Less created C:/temp/cake_issue_672/WebApplication1/WebApplication1/css/style.css
This might not be the solution you were working for, but it "should"
work.
UPDATE: There is now an addin for Cake for running Gulp Tasks. You can find it here
As to why using the MSBuild Alias in Cake is not invoking the BeforeBuild target we are not sure. Could I ask that you raise an issue here so that we can discuss it. Ideally, a sample project that demonstrates the problem could be provided so that we can investigate.
To answer your overall question though...
No, currently, there are no Cake Aliases/Addin's that support running Gulp Tasks as part of the build pipeline. That is not to say that this couldn't be done, simply that it hasn't been on our radar yet.
Having said that, given that you can write any arbitrary C# as part of your build script, there is no reason that you couldn't spawn out a process to invoke gulp with the necessary arguments to do the work.

Using Meteor (port3000) and running index.html from IDE not output

I am Just starting to learn meteor using the official meteor tutorial.
All of this easy to understand. It works.
curl https://install.meteor.com/ | sh
meteor create simple-todos
cd simple-todos
meteor
"Open your web browser and go to http://localhost:3000 to see the app running."
Then I begin the tutorial.
I use Netbeans 8.0 and I am current with updates.
On a mac.
My question has to do with the Ports.
I have been coding MAMP, MEAN, etc. etc. so I am a little confused because they all use specific ports.
8000 8383 8888 3000
In Netbeans, I usually have to start like this:
new > project > html > <nameOfProject>
It creates this structure inside of Netbeans IDE.
It creates it within this directory. See images.
This is by default.
Project Location: /Application/MAMP/htdocs
This directory runs on port 8888 - I think.
Which Port ? I used to know how to check this and forget.
Within the Netbeans Project Named Meteor1
I needed to Create these files !
file > new > simple-todos.js
file > new > simple-todos.css
file > new > simple-todos.html
Then I copy the code from the tutorial into these files.
Note. Do you see the IDE alerts in the margins ?
When I
run > simple-todos.html
The browser outputs this:
when I change url: localhost:3000
it says,
"This webpage is not available
ERR_CONNECTION_REFUSED
Then I recalled I needed to launch meteor.
See the screenshot about how I navigated inside of the directory
and ran
meteor
It says,
"You are not in a Meteor Project"
So I am STUCK.
Rather than further explain what I understand and do not understand, I am missing something and I am certain that this will be easy to explain to me.
Thanks.
You should create a project by using meteor create my_project first then import the project into Netbeans.

Resources