Project

General

Profile

Revision 18d88f23

ID18d88f2355515de33dab548ef72326f8b209dd21
Parent 658b14ef
Child d56dfd49

Added by Yan-Fa Li over 10 years ago

Fix #6523 - add git commit for admin ui to build

- add build time dependency on grunt-git-describe
- create a file git.js at build time
- add git.js to index.html
- export window.inktank.commit on loading adminApp
TODO: potentially revisit this and merge existing inktank objects in
window namespace so they don't pollute each other.

e.g. angular.extend(window.inktank, { new: 'thing' });

View differences:

ui/.gitignore
1
**/git.js
ui/admin/Gruntfile.js
314 314
          ]
315 315
        }
316 316
      }
317
    },
318
    'git-describe': {
319
        options: {
320
            'failOnError': false
321
        },
322
        'git.js': {
323
        }
317 324
    }
318 325
  });
319 326

  
......
324 331

  
325 332
    grunt.task.run([
326 333
      'symlink',
334
      'saveRevision',
327 335
      'clean:server',
328 336
      'concurrent:server',
329 337
      'connect:livereload',
......
343 351
  grunt.registerTask('build', [
344 352
    'clean:dist',
345 353
    'symlink',
354
    'saveRevision',
346 355
    'useminPrepare',
347 356
    'concurrent:dist',
348 357
    'concat',
......
360 369
    'test',
361 370
    'build'
362 371
  ]);
372

  
373
  grunt.registerTask('saveRevision', function() {
374
    grunt.event.once('git-describe', function(rev) {
375
      grunt.log.writeln('Git Revision: ' + rev);
376
      grunt.file.write('app/scripts/git.js', 'angular.module(\'adminApp\').run(function() { window.inktank = { commit: \'' + rev + '\'}; });');
377
    });
378
    grunt.task.run('git-describe');
379
  });
363 380
};
ui/admin/app/index.html
50 50
    <script src="bower_components/underscore/underscore.js"></script>
51 51
    <!-- build:js({.tmp,app}) scripts/scripts.js -->
52 52
    <script src="scripts/app.js"></script>
53
    <script src="scripts/git.js"></script>
53 54
    <script src="scripts/controllers/main.js"></script>
54 55
    <script src="scripts/controllers/user.js"></script>
55 56
    <script src="scripts/controllers/general.js"></script>
ui/admin/package.json
1 1
{
2
    "name": "admin",
3
    "version": "0.0.0",
4
    "dependencies": {},
5
    "devDependencies": {
6
        "grunt": "~0.4.1",
7
        "grunt-contrib-copy": "~0.4.1",
8
        "grunt-contrib-concat": "~0.3.0",
9
        "grunt-contrib-coffee": "~0.7.0",
10
        "grunt-contrib-uglify": "~0.2.0",
11
        "grunt-contrib-compass": "~0.3.0",
12
        "grunt-contrib-jshint": "~0.6.0",
13
        "grunt-contrib-cssmin": "~0.6.0",
14
        "grunt-contrib-connect": "~0.3.0",
15
        "grunt-contrib-clean": "~0.4.1",
16
        "grunt-contrib-htmlmin": "~0.1.3",
17
        "grunt-contrib-imagemin": "~0.1.4",
18
        "grunt-contrib-watch": "~0.4.0",
19
        "grunt-contrib-symlink": "~0.1.0",
20
        "grunt-usemin": "~0.1.11",
21
        "grunt-rev": "~0.1.0",
22
        "grunt-karma": "~0.4.3",
23
        "grunt-open": "~0.2.0",
24
        "grunt-concurrent": "~0.3.0",
25
        "matchdep": "~0.1.2",
26
        "connect-livereload": "~0.2.0",
27
        "grunt-google-cdn": "~0.2.0",
28
        "grunt-ngmin": "~0.0.2",
29
        "grunt-symbolic-link": "~0.3.1",
30
	"yo": "~1.0.0",
31
	"generator-angular": "0.4.0"
32
    },
33
    "engines": {
34
        "node": ">=0.8.0"
35
    }
2
  "name": "admin",
3
  "version": "0.0.0",
4
  "dependencies": {},
5
  "devDependencies": {
6
    "grunt": "~0.4.1",
7
    "grunt-contrib-copy": "~0.4.1",
8
    "grunt-contrib-concat": "~0.3.0",
9
    "grunt-contrib-coffee": "~0.7.0",
10
    "grunt-contrib-uglify": "~0.2.0",
11
    "grunt-contrib-compass": "~0.3.0",
12
    "grunt-contrib-jshint": "~0.6.0",
13
    "grunt-contrib-cssmin": "~0.6.0",
14
    "grunt-contrib-connect": "~0.3.0",
15
    "grunt-contrib-clean": "~0.4.1",
16
    "grunt-contrib-htmlmin": "~0.1.3",
17
    "grunt-contrib-imagemin": "~0.1.4",
18
    "grunt-contrib-watch": "~0.4.0",
19
    "grunt-contrib-symlink": "~0.1.0",
20
    "grunt-usemin": "~0.1.11",
21
    "grunt-rev": "~0.1.0",
22
    "grunt-karma": "~0.4.3",
23
    "grunt-open": "~0.2.0",
24
    "grunt-concurrent": "~0.3.0",
25
    "matchdep": "~0.1.2",
26
    "connect-livereload": "~0.2.0",
27
    "grunt-google-cdn": "~0.2.0",
28
    "grunt-ngmin": "~0.0.2",
29
    "grunt-symbolic-link": "~0.3.1",
30
    "yo": "~1.0.0",
31
    "generator-angular": "0.4.0",
32
    "grunt-git-describe": "~2.3.2"
33
  },
34
  "engines": {
35
    "node": ">=0.8.0"
36
  }
36 37
}

Also available in: Unified diff