Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aurelia build on VSO Hosted Build Controller

I am trying to get a build going for Aurelia on VSO Hosted Build Controller. I created a small powershell script to run the following commands

npm install
.node_modules/.bin/jspm cc
.node_modules/.bin/jspm install -y
.node_modules/.bin/gulp build

I do have AfterBuild targets to copy the jspm_packages and dist folders to my _publishedWebsites folder.

npm install runs fine, but when it comes to jspm cc (if I remove the jspm cc and let it run jspm install -y), it fails trying to this

jspm cc

          Migrating global jspm folder from C:\Users\buildguest\.jspm to C:\Users\buildguest\AppData\Local\.jspm...
          Copying configuration...

     err  Error migrating to new jspm folder
 2>EXEC : error : ENOENT, no such file or directory 'C:\Users\buildguest\.jspm\config' [d:\a\src\WebGUI\OwinAureliaScaffold\OwinAureliaScaffold.csproj]
              at Object.fs.openSync (evalmachine.<anonymous>:427:18)
              at Object.fs.readFileSync (evalmachine.<anonymous>:284:15)
              at Object.<anonymous> (d:\a\src\WebGUI\OwinAureliaScaffold\public\node_modules\jspm\lib\global-config.js:36:24)
              at Module._compile (module.js:456:26)
              at Object.Module._extensions..js (module.js:474:10)
              at Module.load (module.js:356:32)
              at Function.Module._load (module.js:312:12)
              at Module.require (module.js:364:17)
              at require (module.js:380:17)
              at Object.<anonymous> (d:\a\src\WebGUI\OwinAureliaScaffold\public\node_modules\jspm\lib\registry.js:19:20)
     ok   Loader file cache cleared.
     ok   Package cache cleared.

I do understand the jspm is not installed globally, since it is a hosted controller, I cannot really install it globally. My question is, how do I work through this without having a global jspm install? Is there a workaround where it does not have to migrate the config file?

like image 377
Sujesh Arukil Avatar asked May 07 '15 12:05

Sujesh Arukil


2 Answers

Even though you cannot install and run the jspm CLI on the hosted build agent, you can run jspm through node itself.

First, make sure jspm is installed - which your powershell script does. Alternatively, you can use VSO Build's "npm install task", provided jspm is in your package.json file. enter image description here

I used Gulp to execute jspm through node. I'm not sure if that's the best way to do this step, but it works... I used VSO's "Gulp task"

enter image description here

Here are the relevant bits from gulpfile.js:

var gulp = require('gulp'),
    exec = require('child_process').exec;

//#region Build Tasks
gulp.task('build:jspm', function (cb) {
    exec("node ./node_modules/jspm/jspm.js install", function(err, stdout, stderr) {
        console.log(stdout);
        console.error(stderr);
        cb(err);
    });
});

gulp.task('_build', ['build:jspm']);
like image 95
M Falanga Avatar answered Nov 11 '22 17:11

M Falanga


I do understand the jspm is not installed globally, since it is a hosted controller, I cannot really install it globally.

It appears that this is not true (at least currently.) You can install jspm globally on a hosted controller.

I was able to solve this with a build process that looks like this:

Build Steps

  1. npm install
  2. npm install -g jspm
  3. node C:\NPM\Modules\node_modules\jspm\jspm.js install

1) Installs all of the local dependencies from my package.json. 2) Installs a global version of JSPM 3) Evokes it from the global installation location

I realized from M Falanga's answer that node was obviously in the controller's path so I could call it from Powershell/command line. The global JSPM install location I found from looking at the build's debug logs. Note to implementors, you'll want to make sure your working directory for steps 1 and 3 are set to where your package.json is located.

Alternative Solution

I have not tested this next option in a build yet but you should be able to skip the extra build steps and just use the scripts feature of NPM to do the JSPM install. In this case you won't need the NPM install step nor the Run node step above.

In your package.json you'll need the following script entry:

  "keywords": [...],
  "scripts": {
    "postinstall": "./node_modules/.bin/jspm install -y"
  },
  "jspm": {...
like image 45
Robb Vandaveer Avatar answered Nov 11 '22 15:11

Robb Vandaveer