5

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?

Sujesh Arukil
  • 2,469
  • 16
  • 37
  • Did you ever find solution with VSO controller? – bychkov Jun 29 '15 at 21:58
  • simple answer. You can't on the hosted build controller. I have switched to Typescript and I use requirejs. I am using the aurelia TS files from here https://github.com/cmichaelgraham/aurelia-typescript – Sujesh Arukil Jun 30 '15 at 11:56

3 Answers3

5

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']);
M Falanga
  • 1,897
  • 17
  • 21
  • interesting. Never thought of doing that. Is this something you currently do? – Sujesh Arukil Sep 25 '15 at 13:24
  • 1
    yes. I was having the same problem as you, including not finding any good answers. The solution came to me after I looked at what the CLI is doing on my local computer by viewing the contents of my `...\AppData\Roaming\npm\jspm.cmd` file. It just runs the jspm.js file using node. I know that node is installed on the VSO build host, so I gave it a try. – M Falanga Sep 25 '15 at 13:49
  • I am going to try this out. If it works brother, you would have saved my team a lot of time! – Sujesh Arukil Sep 25 '15 at 14:47
  • 2
    How did you get around rate-limit issues from GitHub? – James Reategui Nov 11 '15 at 22:37
2

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": {...
Robb Vandaveer
  • 1,481
  • 20
  • 25
1

If administrative privileges are required on the computer to install a package, there's no way for you to do it in hosted build. You will have to create your own build machine in this case. It's something we hope to solve in the future.

That said, here's what one person did to get Aurelia set up: http://fabhojs.blogspot.com/2015/03/aurelia-app-skeleton-yeoman-generator.html (from this question). Those steps are different and may help.

Community
  • 1
  • 1
Buck Hodges
  • 3,342
  • 1
  • 19
  • 20
  • Thank you for your response. I have gotten it to work before with just grunt. its the jspm install that is the issue. The link you sent does not talk about automated builds. I am trying to setup an on premise build machine, but running in to problems there too. – Sujesh Arukil May 08 '15 at 19:41