Initial commit
Adding sample docker file creation option.
This commit is contained in:
Родитель
bd7f8abdf8
Коммит
74950de042
|
@ -0,0 +1 @@
|
|||
* text=auto
|
|
@ -0,0 +1 @@
|
|||
node_modules/
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"generator-generator": {}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
generator-docker
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
43
README.md
43
README.md
|
@ -1,2 +1,41 @@
|
|||
# generator-docker
|
||||
Yeoman generator for Docker
|
||||
# Yeoman Docker Generator
|
||||
|
||||
## Developing & testing
|
||||
After making changes to the code, run:
|
||||
```bash
|
||||
npm link
|
||||
```
|
||||
|
||||
And then run the generator:
|
||||
```bash
|
||||
yo docker
|
||||
```
|
||||
|
||||
Run the following command from the root folder of the project:
|
||||
```bash
|
||||
mocha
|
||||
```
|
||||
|
||||
## Publishing
|
||||
To publish a new version of the docker generator, increase the generator version and run:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
## Installing
|
||||
To install generator-docker from npm, run:
|
||||
|
||||
```bash
|
||||
npm install -g generator-docker
|
||||
```
|
||||
|
||||
Finally, initiate the generator:
|
||||
|
||||
```bash
|
||||
yo docker
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
'use strict';
|
||||
var yeoman = require('yeoman-generator');
|
||||
var chalk = require('chalk');
|
||||
var yosay = require('yosay');
|
||||
var path = require('path');
|
||||
|
||||
var DockerGenerator = yeoman.generators.Base.extend({
|
||||
constructor: function () {
|
||||
yeoman.generators.Base.apply(this, arguments);
|
||||
},
|
||||
|
||||
init: function () {
|
||||
this.log(yosay('Welcome to the ' + chalk.red('Docker') + ' generator!'));
|
||||
this.templatedata = {};
|
||||
},
|
||||
|
||||
initializing: function () {
|
||||
},
|
||||
|
||||
initForTest: function(artifactType) {
|
||||
this.type = artifactType;
|
||||
},
|
||||
|
||||
askFor: function () {
|
||||
var done = this.async();
|
||||
|
||||
var prompts = [{
|
||||
type: 'list',
|
||||
name: 'type',
|
||||
message: 'Which Docker artifact do you want to create?',
|
||||
choices: [
|
||||
{
|
||||
name: 'Docker file (' + chalk.bold('Dockerfile') + ')',
|
||||
value: 'dockerfile'
|
||||
},
|
||||
{
|
||||
name: 'Compose file (' + chalk.bold('Docker-compose.yml') + ')',
|
||||
value: 'composefile'
|
||||
}
|
||||
]
|
||||
}];
|
||||
|
||||
this.prompt(prompts, function (props) {
|
||||
this.type = props.type;
|
||||
done();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
writing: function () {
|
||||
this.sourceRoot(path.join(__dirname, './templates'));
|
||||
|
||||
switch (this.type) {
|
||||
case 'dockerfile':
|
||||
this.copy(this.sourceRoot() + '/_Dockerfile', 'Dockerfile');
|
||||
break;
|
||||
case 'composefile':
|
||||
break;
|
||||
default:
|
||||
// unknown.
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
install: function () {
|
||||
// this.installDependencies();
|
||||
},
|
||||
|
||||
end: function () {
|
||||
switch (this.type) {
|
||||
case 'dockerfile':
|
||||
this.log('Dockerfile was added to your project.');
|
||||
break;
|
||||
case 'composefile':
|
||||
this.log('Oops, nothing there yet :(');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = DockerGenerator;
|
|
@ -0,0 +1,3 @@
|
|||
# Hello World Dockerfile
|
||||
FROM ubuntu:latest
|
||||
RUN ["/bin/echo", "Hello World!"]
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "generator-docker",
|
||||
"version": "0.0.4",
|
||||
"description": "Docker generator",
|
||||
"files": [
|
||||
"generators/app"
|
||||
],
|
||||
"keywords": [
|
||||
"yeoman-generator",
|
||||
"vscode",
|
||||
"docker",
|
||||
"extensions",
|
||||
"visual studio",
|
||||
"docker compose"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "DockerToolsDevTeam",
|
||||
"url": "https://github.com/Microsoft"
|
||||
},
|
||||
"dependencies": {
|
||||
"yeoman-generator": "^0.19.0",
|
||||
"chalk": "^1.0.0",
|
||||
"yosay": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var assert = require('yeoman-generator').assert;
|
||||
var helpers = require('yeoman-generator').test;
|
||||
var os = require('os');
|
||||
|
||||
describe('docker:app', function () {
|
||||
before(function (done) {
|
||||
helpers.run(path.join(__dirname, '../generators/app'))
|
||||
.withPrompts({ type:"dockerfile"})
|
||||
.on('end', done);
|
||||
});
|
||||
|
||||
it('creates files', function () {
|
||||
assert.file([
|
||||
'Dockerfile'
|
||||
]);
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче