Permalink
Browse files

feat(all): add webpack

closes #184
closes #260

chore(webpack): clean up tasks, update command json

chore(webpack): cleanup

chore(new): ask for loader/bundler in custo

chore(webpack): add asp.net core support

chore(webpack): replace existing csproj if present

fix(project-item): ask for file replacement in sequence

in "au new" the CLI asks the user to replace existing file. When there are multiple files that already exist, the CLI only asks the user whether to replace the file for one of those files. This is due to the fact that the .create() method of child project-item's are called in parallel, not in sequence.

chore(webpack): improve instructions for aspnet core

chore(all): fixed minor scaffolding issues

chore(webpack): more user information

chore(webpack): add tasks for karma & jest
  • Loading branch information...
JeroenVinke committed Jul 14, 2017
1 parent 1507919 commit 2c08625d44910a6f2e044fffc3e9ff0f4f93e45c
Showing with 1,967 additions and 477 deletions.
  1. +142 −0 build/tasks/generate-projects.js
  2. +47 −0 build/tasks/skeletons.json
  3. +54 −0 lib/build/webpack-reporter.js
  4. +8 −2 lib/commands/help/command.js
  5. +1 −1 lib/commands/new/{ → buildsystems/cli}/css-processors/less.js
  6. +1 −1 lib/commands/new/{ → buildsystems/cli}/css-processors/none.js
  7. +1 −1 lib/commands/new/{ → buildsystems/cli}/css-processors/postcss.js
  8. +1 −1 lib/commands/new/{ → buildsystems/cli}/css-processors/sass.js
  9. +1 −1 lib/commands/new/{ → buildsystems/cli}/css-processors/stylus.js
  10. 0 lib/commands/new/{ → buildsystems/cli}/editors/atom.js
  11. 0 lib/commands/new/{ → buildsystems/cli}/editors/none.js
  12. 0 lib/commands/new/{ → buildsystems/cli}/editors/sublime.js
  13. +1 −1 lib/commands/new/{ → buildsystems/cli}/editors/visualstudio.js
  14. +1 −1 lib/commands/new/{ → buildsystems/cli}/editors/vscode.js
  15. 0 lib/commands/new/{ → buildsystems/cli}/editors/webstorm.js
  16. +136 −0 lib/commands/new/buildsystems/cli/index.js
  17. +30 −0 lib/commands/new/buildsystems/cli/loaders/require.js
  18. +34 −0 lib/commands/new/buildsystems/cli/loaders/system.js
  19. +1 −1 lib/commands/new/{ → buildsystems/cli}/markup-processors/maximum.js
  20. +1 −1 lib/commands/new/{ → buildsystems/cli}/markup-processors/minimum.js
  21. +1 −1 lib/commands/new/{ → buildsystems/cli}/markup-processors/none.js
  22. +1 −1 lib/commands/new/{ → buildsystems/cli}/markup-processors/pug.js
  23. +12 −0 lib/commands/new/buildsystems/cli/platforms/aspnetcore.js
  24. +9 −0 lib/commands/new/buildsystems/cli/platforms/web.js
  25. +1 −1 lib/commands/new/{ → buildsystems/cli}/transpilers/babel.js
  26. +1 −1 lib/commands/new/{ → buildsystems/cli}/transpilers/typescript.js
  27. +2 −2 lib/commands/new/{ → buildsystems/cli}/unit-test-runners/karma.js
  28. 0 lib/commands/new/{ → buildsystems/cli}/unit-test-runners/none.js
  29. +8 −0 lib/commands/new/buildsystems/webpack/css-processors/less.js
  30. +4 −0 lib/commands/new/buildsystems/webpack/css-processors/none.js
  31. +8 −0 lib/commands/new/buildsystems/webpack/css-processors/postcss.js
  32. +8 −0 lib/commands/new/buildsystems/webpack/css-processors/sass.js
  33. +8 −0 lib/commands/new/buildsystems/webpack/css-processors/stylus.js
  34. +5 −0 lib/commands/new/buildsystems/webpack/editors/atom.js
  35. +3 −0 lib/commands/new/buildsystems/webpack/editors/none.js
  36. +5 −0 lib/commands/new/buildsystems/webpack/editors/sublime.js
  37. +12 −0 lib/commands/new/buildsystems/webpack/editors/vscode.js
  38. +5 −0 lib/commands/new/buildsystems/webpack/editors/webstorm.js
  39. +97 −0 lib/commands/new/buildsystems/webpack/index.js
  40. +4 −0 lib/commands/new/buildsystems/webpack/integration-test-runner/none.js
  41. +28 −0 lib/commands/new/buildsystems/webpack/integration-test-runner/protractor.js
  42. +18 −0 lib/commands/new/buildsystems/webpack/platforms/aspnetcore.js
  43. +14 −0 lib/commands/new/buildsystems/webpack/platforms/index.js
  44. +3 −0 lib/commands/new/{ → buildsystems/webpack}/platforms/web.js
  45. +33 −0 lib/commands/new/buildsystems/webpack/transpilers/babel.js
  46. +20 −0 lib/commands/new/buildsystems/webpack/transpilers/typescript.js
  47. +30 −0 lib/commands/new/buildsystems/webpack/unit-test-runners/jasmine.js
  48. +110 −0 lib/commands/new/buildsystems/webpack/unit-test-runners/jest.js
  49. +41 −0 lib/commands/new/buildsystems/webpack/unit-test-runners/karma.js
  50. +4 −0 lib/commands/new/buildsystems/webpack/unit-test-runners/none.js
  51. +0 −16 lib/commands/new/loaders/require.js
  52. +0 −20 lib/commands/new/loaders/system.js
  53. +275 −88 lib/commands/new/new-application.json
  54. +0 −6 lib/commands/new/platforms/aspnetcore.js
  55. +69 −118 lib/commands/new/project-template.js
  56. +52 −12 lib/dependencies.json
  57. +4 −0 lib/file-system.js
  58. +1 −0 lib/index.js
  59. +34 −4 lib/project-item.js
  60. +21 −0 lib/resources/content/javascriptservices/Controllers/HomeController.cs
  61. +44 −0 lib/resources/content/javascriptservices/Controllers/SampleDataController.cs
  62. +24 −0 lib/resources/content/javascriptservices/Program.cs
  63. +68 −0 lib/resources/content/javascriptservices/Startup.cs
  64. +24 −0 lib/resources/content/javascriptservices/Startup.cs.readme.txt
  65. +10 −0 lib/resources/content/javascriptservices/Views/Home/Index.cshtml
  66. +6 −0 lib/resources/content/javascriptservices/Views/Shared/Error.cshtml
  67. +15 −0 lib/resources/content/javascriptservices/Views/Shared/_Layout.cshtml
  68. +3 −0 lib/resources/content/javascriptservices/Views/_ViewImports.cshtml
  69. +3 −0 lib/resources/content/javascriptservices/Views/_ViewStart.cshtml
  70. +10 −0 lib/resources/content/javascriptservices/appsettings.json
  71. +3 −0 lib/resources/content/javascriptservices/global.json
  72. +33 −0 lib/resources/content/javascriptservices/project.csproj
  73. BIN lib/resources/content/javascriptservices/wwwroot/favicon.ico
  74. +13 −1 lib/resources/content/package-scripts.template.js
  75. +1 −0 lib/resources/content/tsconfig.json
  76. +26 −24 lib/resources/content/webpack.config.template.js
  77. +1 −1 lib/resources/tasks/build-webpack.js
  78. +1 −1 lib/resources/tasks/build-webpack.ts
  79. +22 −0 lib/resources/tasks/jest.js
  80. +11 −0 lib/resources/tasks/jest.json
  81. +22 −0 lib/resources/tasks/jest.ts
  82. +16 −0 lib/resources/tasks/karma.js
  83. +11 −0 lib/resources/tasks/karma.json
  84. +16 −0 lib/resources/tasks/karma.ts
  85. +6 −65 lib/resources/tasks/run-webpack.js
  86. +21 −0 lib/resources/tasks/run-webpack.json
  87. +6 −65 lib/resources/tasks/run-webpack.ts
  88. +36 −23 lib/workflow/activities/project-create.js
  89. +19 −6 lib/workflow/activities/project-install.js
  90. +85 −10 spec/lib/project-item.spec.js
@@ -0,0 +1,142 @@
require('aurelia-polyfills');
const gulp = require('gulp');
const Container = require('aurelia-dependency-injection').Container;
const definition = require('../../lib/commands/new/new-application.json');
const WorkflowEngine = require('../../lib/workflow/workflow-engine').WorkflowEngine;
const ProjectCreate = require('../../lib/workflow/activities/project-create');
const UI = require('../../lib/ui').UI;
const ConsoleUI = require('../../lib/ui').ConsoleUI;
const fs = require('fs');
const LogManager = require('aurelia-logging');
const Logger = require('../../lib/logger').Logger;
gulp.task('generate-projects', function(done) {
LogManager.addAppender(new Logger(new ConsoleUI()));
LogManager.setLevel('debug');
const ui = new ConsoleUI();
ui.question('Where would you like to create the projects?')
.then(dir => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
process.chdir(dir);
return createProjectsInSeries(require('./skeletons.json'))
.then(() => {
console.log('Created all projects');
done();
})
.catch(e => {
console.log(e);
done();
});
});
});
function createProjectsInSeries(instructions) {
let i = -1;
function createP() {
i++;
if (i < instructions.length) {
return createProject(instructions[i]).then(createP);
}
return Promise.resolve();
}
return createP();
}
function createProject(answers) {
let container = new Container();
let engine = new WorkflowEngine(
definition,
container
);
container.registerInstance(UI, new ConsoleUI());
container.unregister('project-install');
container.registerInstance('project-install', new AutoProjectInstall());
container.unregister('project-create');
container.registerSingleton('project-create', AutoProjectCreate);
container.unregister('input-text');
container.registerInstance('input-text', new AutoInputText(answers));
container.unregister('input-select');
container.registerInstance('input-select', new AutoInputSelect(answers));
container.unregister('input-multiselect');
container.registerInstance('input-multiselect', new AutoInputMultiSelect(answers));
return engine.start()
.then(() => console.log('Finished creating project'))
.catch(e => {
console.log('error while creating project');
console.log(e);
throw e;
});
}
class AutoInputSelect {
constructor(answers) {
this._answers = answers;
}
execute(context) {
let answer = this._answers[this.id];
if (!answer) {
answer = this.options[0].value;
}
context.state[this.stateProperty] = answer;
context.next(this.nextActivity);
}
}
class AutoInputMultiSelect {
constructor(answers) {
this._answers = answers;
}
execute(context) {
let answer = this._answers[this.id];
if (!answer) {
answer = [this.options[0].value];
}
context.state[this.stateProperty] = answer;
context.next(this.nextActivity);
}
}
class AutoInputText {
constructor(answers) {
this._answers = answers;
}
execute(context) {
let answer = this._answers[this.id];
if (!answer) {
throw new Error('AutoInputText has no answer for activityId ' + this.id);
}
context.state[this.stateProperty] = answer;
context.next(this.nextActivity);
}
}
class AutoProjectCreate extends ProjectCreate {
projectConfirmation() {
return Promise.resolve({ value: 'yes' });
}
}
class AutoProjectInstall {
execute(context) {
context.next(this.nextActivity);
}
}
View
@@ -0,0 +1,47 @@
[{
"200": "skeleton-requirejs-esnext",
"300": "default-esnext"
}, {
"200": "skeleton-requirejs-typescript",
"300": "default-typescript"
},{
"200": "skeleton-systemjs-esnext",
"300": "custom",
"600": "systemjs"
}, {
"200": "skeleton-systemjs-typescript",
"300": "custom",
"600": "systemjs",
"630": {
"id": "typescript",
"displayName": "TypeScript",
"fileExtension": ".ts"
}
}, {
"200": "skeleton-webpack-esnext",
"300": "custom",
"600": "webpack",
"680": [{
"id": "karma",
"displayName": "Karma"
}, {
"id": "jest",
"displayName": "Jest"
}]
}, {
"200": "skeleton-webpack-typescript",
"300": "custom",
"600": "webpack",
"630": {
"id": "typescript",
"displayName": "TypeScript",
"fileExtension": ".ts"
},
"680": [{
"id": "karma",
"displayName": "Karma"
}, {
"id": "jest",
"displayName": "Jest"
}]
}]
@@ -0,0 +1,54 @@
'use strict';
module.exports = function reportReadiness(options) {
const uri = createDomain(options);
const yargs = require('yargs');
const argv = yargs.argv;
argv.color = require('supports-color');
const open = require('opn');
const useColor = argv.color;
let startSentence = `Project is running at ${colorInfo(useColor, uri)}`;
if (options.socket) {
startSentence = `Listening to socket at ${colorInfo(useColor, options.socket)}`;
}
console.log((argv.progress ? '\n' : '') + startSentence);
console.log(`webpack output is served from ${colorInfo(useColor, options.publicPath)}`);
const contentBase = Array.isArray(options.contentBase) ? options.contentBase.join(', ') : options.contentBase;
if (contentBase) {
console.log(`Content not from webpack is served from ${colorInfo(useColor, contentBase)}`);
}
if (options.historyApiFallback) {
console.log(`404s will fallback to ${colorInfo(useColor, options.historyApiFallback.index || '/index.html')}`);
}
if (options.open) {
open(uri).catch(function() {
console.log('Unable to open browser. If you are running in a headless environment, please do not use the open flag.');
});
}
};
function createDomain(opts) {
const protocol = opts.https ? 'https' : 'http';
const url = require('url');
// the formatted domain (url without path) of the webpack server
return opts.public ? `${protocol}://${opts.public}` : url.format({
protocol: protocol,
hostname: opts.host,
port: opts.socket ? 0 : opts.port.toString()
});
}
function colorInfo(useColor, msg) {
if (useColor) {
// Make text blue and bold, so it *pops*
return `\u001b[1m\u001b[33m${msg}\u001b[39m\u001b[22m`;
}
return msg;
}
@@ -35,11 +35,17 @@ module.exports = class {
getLocalCommandText() {
let commands = [
require('../generate/command.json'),
require('../import/command.json'),
require('../install/command.json'),
require('./command.json')
];
let bundler = this.project.model.bundler;
if (!bundler || bundler.id === 'cli') {
commands = commands.concat([
require('../import/command.json'),
require('../install/command.json')
]);
}
return this.project.getTaskMetadata().then(metadata => {
return string.buildFromMetadata(metadata.concat(commands), this.ui.getWidth());
});
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
project.addToTasks(
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
project.addToTasks(
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
project.addToTasks(
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
project.addToTasks(
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
project.addToTasks(
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
if (project.model.transpiler.id !== 'typescript') {
@@ -1,5 +1,5 @@
'use strict';
const ProjectItem = require('../../../project-item').ProjectItem;
const ProjectItem = require('../../../../../project-item').ProjectItem;
module.exports = function(project) {
if (project.model.transpiler.id !== 'typescript') {
Oops, something went wrong.

0 comments on commit 2c08625

Please sign in to comment.