-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
1507919
commit 2c08625
Showing
90 changed files
with
1,967 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
}] | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/css-processors/less.js → ...w/buildsystems/cli/css-processors/less.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/css-processors/none.js → ...w/buildsystems/cli/css-processors/none.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/css-processors/postcss.js → ...uildsystems/cli/css-processors/postcss.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/css-processors/sass.js → ...w/buildsystems/cli/css-processors/sass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/css-processors/stylus.js → ...buildsystems/cli/css-processors/stylus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
lib/commands/new/editors/visualstudio.js → .../buildsystems/cli/editors/visualstudio.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/commands/new/editors/vscode.js → ...ds/new/buildsystems/cli/editors/vscode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.