Configure IIS to use specified directory in Grunt - iis

I am trying to configure IIS to use a specified directory in Grunt. Installing IIS creates the 'Default Web Site' and sets the path for this.
I am trying to make Grunt configure IIS to use a set directory depending on the machine it is on.
The way I have tried to do this is by using this site: https://www.npmjs.com/package/grunt-iis#options-path
I have used various options and tasks, even down to just using your_target and physicalPath. But I have had no luck.
grunt.initConfig({
iis: {
developer: {
physicalPath : __dirname,
site : 'Default Web Site',
path : 'NewSite',
pool : 'NewSite',
managedRuntimeVersion : 'v4.0'
}
},
});
Please can someone help me with this.
Thanks,
Sam

I have done this using exec command: command:
exec: {
command: 'c:\\Windows\\System32\\inetsrv\\appcmd.exe set vdir \"Default Web Site/\" -physicalPath:\"path"',
stdout: false,
stderr: false
},
},
});

Related

why node-sp-auth on demand doesn't show browser window?

I'm trying to setup a brand new angular 9 application local development environment for a SPA SharePoint Online application.
As part of the process I need to setup the local proxy server sp-rest-proxy. I configured it to use on demand credentials. This is the config/private.json content:
{
"siteUrl": "https://tenant.sharepoint.com/sites/mysite",
"strategy": "OnDemandCredentials",
"ondemand": true
}
My package.json file includes:
{
"scripts": {
"serve": "node src/server.js"
}
}
server.js content is:
const RestProxy = require('sp-rest-proxy');
const settings = {
configPath: './config/private.json', // Location for SharePoint instance mapping and credentials
port: 8080, // Local server port
staticRoot: './node_modules/sp-rest-proxy/static' // Root folder for static content
};
const restProxy = new RestProxy(settings);
restProxy.serve();
I run:
npm run serve
Open browser and point it to http://localhost:8080 when I try to execute a simple request like /_api/web?$select=Title I get the following error:
{
"readyState": 4,
"responseText": "Command failed: C:\\WINDOWS\\system32\\cmd.exe /d /s /c \"electron C:\\projects\\MyProject\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\ondemand\\electron\\main.js https://tenant.sharepoint.com/sites/diner false\"",
"status": 400,
"statusText": "Bad Request"
}
No browser window is shown.
I have electron installed globally.
When I execute the following on the command line:
electron C:\projects\MyProject\node_modules\node-sp-auth\lib\src\auth\resolvers\ondemand\electron\main.js https://tenant.sharepoint.com false
Nothing happens, the process ends with no messages, no browser window is opened.
What can I do to find and fix the problem?
On-Demand auth requires Electron being installed npm i -g electron#6.
Electron is optional in node-sp-auth, as it's huge it was an architectural decision making it optional and for manual install only for that rare cases when On-Demand is needed.
The issue is solved after upgrading sp-rest-proxy to version 2.11.1.
See this issue on GitHub

Protractor & Jasmine Configuration on Jenkins

I am trying to configure Protractor on Jenkins for CTI.... I have already setup Protractor along with Jasmine and trying to get it integrated with Jenkins.
I have gone through several links & blogs on internet but none seem to be helpful in providing detailed information on how to get the Protractor configured with Jenkins.
Any help or pointing towards the right blog or video will be really appreciated. Thanks
#Vishal
Please find the below snippet you can add as grunt task.
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
exec: {
protractorRunAppsTest: {
cmd: 'C:\\Program Files\\nodejs\\node.exe C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\protractor\\built\\cli.js C:\\Jenkins\\workspace\\test\\conf.js'
}
},
server: {
port:3000,
base: ['app']
},
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('server', 'Start node server', function() {
grunt.log.writeln('Started server on port 3000');
require('./app.js');
});
grunt.registerTask('runAppsTest', ['exec:protractorRunAppsTest']);
};
Save the above code as Gruntfile.js
Make sure this is in the workspace folder for jenkins.
In Jenkins job add the 'Build' Section (i am assuming Jenkins is windows server)
add "Execute Windows Batch Command" and add the below content to the text field there.
cd %WORKSPACE%
grunt server runAppsData || exit 0
I hope this would work for you. Please try and let me know.
Consider rating my answer.
#Vishal try to use grunt for doing the same. So that you can easily integrate the Jenkins job with grunt task details.
Just configure and register task with grunt.
Then use the grunt task to run in jenkins.
If you want i can provide more details.

Hosting an angular-fullstack Yeoman Site on IIS

I have a project built using the angular-fullstack generator for Yeoman. I would like to deploy this to a Windows Server running IIS. I have successfully generated the "dist" folder using Grunt and moved the "public" and "server" folders with files to my IIS box.
How do I configure my Windows Server to host my application? Do I need to have two IIS sites (one for "public" and one for "server")? Do I need to install grunt, bower, etc. on the Windows Server?
You don't have to manually install grunt nor bower. Install locally the node components declared in package.json using the following comman:
npm install
The angular-fullstack generator creates a Node.js application, so all you have to do is run the server side application. Run /server/app.js with Node.js
You can check how to run Node applications inside IIS here:
http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx
You have to deploy the application on iisnode
the do the right configuration for you web.config file I currently are able to run the application using the nodejs server but not in the iisnode applications because my web.config file still working correct I posted a question with more information here
This is just to give you a hint to the way to a solution. It´s not a detailed step by step answer.
If alredy using Grunt, you can use this grunt plugin.
It´s a wrapper of the msdeploy.exe command so you need to learn about that here.
Before all of this you need to install Web Deploy on your server. There are serveral strats and posts about this. I choosed using the Remote Agent way.
I manually create the website (don´t know how to do this remotely yet. Working on that. That´s why I found this question) before I deploy. Then I just sync directories in my computer (your /dist folder) and the path in the remote server.
This a piece of my Gruntfile.js with 2 examples defined in the grunt.initConfig()
'Backup' saves in a package (zip file) the current remote directory.
The second task called 'Oper' syncs your current build located on <%= yeoman.dist %>
msdeploy: {
backup: {
options: {
verb: "sync",
source: {
dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
},
dest: {
package: '<%= deploy.Config.basePathOper %>\\backups\\web_' + grunt.template.today("yyyy-mm-dd-HH-MM-ss") + '.zip,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
}
}
},
Oper: {
options: {
verb: 'sync',
source: {
dirPath: process.cwd() + '\\<%= yeoman.dist %>'
},
dest: {
dirPath: '<%= deploy.Config.basePathOper %><%=deploy.Oper.Web %>,computerName=<%=deploy.Config.computerName %>,username=<%=deploy.Config.username %>,password=<%= deploy.Config.password %>'
}
}
}
The task I created looks something like this
grunt.registerTask('deploy', function (target) {
if (target === 'Oper') {
grunt.task.run([
'msdeploy:backup',
'msdeploy:Oper'
]);
}
});
Don´t forget to load the plugin:
grunt.loadNpmTasks('grunt-msdeploy');

Deploy DocPad to Gandi.net Simple Hosting

I'm trying to deploy my first DocPad website to the Gandi.net hosting provider, with this service :
https://www.gandi.net/hebergement/simple?language=nodejs&grid=A
My code is here :
https://github.com/nylnook/nylnook-website
It's running fine locally on my computer.
Technically it seem to be a 'vhost', and I'm supposed to write a "server.js" file to deploy DocPad in production to the gandi server, after I used :
git push gandi master
('gandi' being my git remote repo at their server)
and also used a custom command (XXX instead of my login) :
ssh XXXXX#git.XXX.gpaas.net 'deploy default.git'
They have a guide for their Node.js instance :
http://wiki.gandi.net/en/simple/instance/nodejs?s[]=node
and a guide for git usage on their servers :
http://wiki.gandi.net/en/simple/git
that suggest to use this code :
https://github.com/visionmedia/express/blob/master/examples/vhost/index.js
but I a newbie to node.js, learning with DocPad, so I can't figure how to do that !
Last link, the DocPad guide for deployment I followed so far :
http://docpad.org/docs/deploy
Thanks for you help !
Edit : another lead maybe :http://docpad.org/docs/api#using-with-express
Answering myself for documentation :
you need to modify 3 files
in server.js (thanks plflannery : https://github.com/bevry/docpad/issues/819) :
var spawn = require('child_process').spawn
var args = ['server'];
spawn('node_modules/.bin/docpad', args, {stdio:'inherit'}).on('close', function(err) {
if (err)
console.log("docpad failed");
else
console.log("docpad running");
});
in docpad.coffee, put :
port: 8080
in docpadConfig fonction, to change default port (9778) to
8080, as required by Gandi, explanations here :
https://github.com/bobobo1618/docpad-docum...
and in package.json put
"main": "server.js"
instead of
"main": "node_modules/docpad/bin/docpad-server"
So to launch docpad and install dependencies when deployment via Git.
Example of a working code :
https://github.com/nylnook/nylnook-website
Good luck in your projects !

watch doesn't refresh the page on file change (express site)

It would be nice to have the browser automatically reload the page when I change a project file. I have this node-express site with the server being defined in 'server.js'
However, I've tried different grunt configurations, but none of them caused the browser to reload on a file change although the 'watch' task prints a message that the file changed!
Here is the relevant grunt configuration:
watch: {
all: {
files: 'views/index.ejs', // for now only watch this file!
options: {
livereload: true
}
}
},
express: {
options: {
background: true,
error: function(err, result, code) {},
fallback: function() {},
port: 3000
delay: 0,
output: ".+",
debug: false
},
dev: {
options: {
script: './server.js',
node_env: 'development',
livereload: true
}
}
}
....
grunt.registerTask('server', [
'express:dev',
'open',
'watch'
])
};
And to run the task I do
$> grunt server
Can someone explain what is wrong with this configuration ?
thnx
You need to install the livereload browser plugin from http://livereload.com/
I am trying to use grunt livereload to reload css changes on my node.js pages. I am getting closer to solve my problem which is similar to yours. So from what i know so far and please correct me if i'm wrong you dont need to install "livereload browser plugin" right? I used grunt alone without node.js and i could just use livereload without installing "livereload browser plugin" i just had to add a line in my .html (the problem i run into with node is how to reload .ejs and i found this page/question on the way solving it) : so i dont know if installing the livereload thing is another way to do the script part or if this is the case like i mentioned in my problem if i want to live reload .ejs i have to install the plugin.

Resources