template.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * grunt-init-amber
  3. * https://amber-lang.net/
  4. *
  5. * Copyright (c) 2013 Manfred Kroehnert, contributors
  6. * Licensed under the MIT license.
  7. */
  8. 'use strict';
  9. // Basic template description.
  10. exports.description = 'Create a web application based on Amber Smalltalk.';
  11. // Template-specific notes to be displayed before question prompts.
  12. exports.notes = ' _Project title_ should be a human-readable title.';
  13. // Template-specific notes to be displayed after question prompts.
  14. exports.after = 'You should now install project dependencies with _bower install_.' +
  15. ' Afterwards, start the development server with _./bower_components/amber/bin/amber serve_.' +
  16. ' Your application is then accessible via _http://localhost:4000/_';
  17. // Any existing file or directory matching this wildcard will cause a warning.
  18. exports.warnOn = '*';
  19. // The actual init template.
  20. exports.template = function(grunt, init, done) {
  21. init.process({type: 'amber'}, [
  22. // Prompt for these values.
  23. init.prompt('name', 'AmberApplication'),
  24. init.prompt('title'),
  25. init.prompt('description', 'Amber Application.'),
  26. {
  27. name: 'namespace',
  28. message: 'The namespace used to store your Amber Packages.',
  29. },
  30. {
  31. name: 'amber_version',
  32. default: '>= 0.12.4',
  33. message: 'The version of Amber to use. Must be >= 0.12.4',
  34. },
  35. init.prompt('version'),
  36. init.prompt('repository'),
  37. init.prompt('homepage'),
  38. init.prompt('bugs'),
  39. init.prompt('licenses', 'MIT'),
  40. init.prompt('author_name'),
  41. init.prompt('author_email'),
  42. init.prompt('author_url')
  43. ], function(err, props) {
  44. // Files to copy (and process).
  45. var files = init.filesToCopy(props);
  46. // Add properly-named license files.
  47. init.addLicenseFiles(files, props.licenses);
  48. // Actually copy (and process) files.
  49. init.copyAndProcess(files, props, {noProcess: 'libs/**'});
  50. // Clean up non-npm props.
  51. delete props.namespace;
  52. var amberVersion = props.amber_version;
  53. delete props.amber_version;
  54. // Add '~' at the beginning if version is without operation (starts with number)
  55. if (amberVersion.match(/^\d/)) {
  56. amberVersion = '~' + amberVersion;
  57. }
  58. // A few additional properties.
  59. props.keywords = ['Amber', 'Smalltalk'];
  60. props.devDependencies = {
  61. "grunt": "~0.4.0",
  62. "amber-dev": "0.0.3"
  63. };
  64. props.node_version = '>= 0.8.0';
  65. props.scripts = {
  66. "test": "grunt amberc:test_runner && node test_runner.js && ( rm test_runner.js || del test_runner.js )"
  67. };
  68. // Generate package.json file, used by npm and grunt.
  69. init.writePackageJSON('package.json', props);
  70. // generate bower.json file
  71. grunt.file.write('bower.json', JSON.stringify({
  72. "name": props.name,
  73. "description": props.description,
  74. "version": props.version,
  75. "ignore": [
  76. "**/.*",
  77. "node_modules",
  78. "bower_components",
  79. "/test_runner.js",
  80. "test",
  81. "tests"
  82. ],
  83. "authors": [
  84. {
  85. "name": props.author_name,
  86. "email": props.author_email
  87. }
  88. ],
  89. "homepage": props.homepage,
  90. "main": props.main,
  91. "keywords": props.keywords,
  92. "license": props.licenses,
  93. "private": false,
  94. "dependencies": {
  95. "amber": amberVersion
  96. }
  97. }, null, 4));
  98. // All done!
  99. done();
  100. });
  101. };