Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ Gabriele Venturi (https://github.com/gventuri)
Gianni Valdambrini (https://github.com/gvaldambrini)

Roberto Di Lillo (https://github.com/koop4)

Filippo Calabrese (https://github.com/filippocalabrese)
15 changes: 15 additions & 0 deletions extra/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js

node_js:
- '10'

cache:
npm: true
directories:
- '.eslintcache'
- 'node_modules'

script:
- npm install
- npm install --save-dev jest
- npm run test
35 changes: 35 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AVAILABLE COMMAND:
init initialize the cli
config change the default settings of the cli. you need to initialize the cli before
add creates a new component using the provided name. default path: '${DEFAULT_PATH}'
travis create a standard .travis.yml configuration file for your project

OPTIONS
-path override default path.
Expand All @@ -53,6 +54,7 @@ AUTHORS
CONTRIBUTORS
Gianni Vandalbrini (https://github.com/gvaldambrini)
Roberto Di Lillo (https://github.com/koop4)
Filippo Calabrese (https://github.com/filippocalabrese)
`;
const WRONG_PATH_MSG = `The path provided is wrong`;
const PROJ_INIT = `The project has been initialized`;
Expand Down Expand Up @@ -89,6 +91,15 @@ class Commands {
}
}

static initTravis() {
const data = fs.readFileSync(__dirname+"/extra/.travis.yml", "utf-8");
fs.writeFile(__dirname+"/.travis.yml", data, err => {
if (err) {
console.log(`Cannot create travis init file`);
}
});
}

config() {
const questions = [
{
Expand All @@ -103,6 +114,13 @@ class Commands {
name: "storybook",
message: "Do you want to enable the support for Storybook?",
default: true
},
{
type: "confirm",
name: "travis",
message:
"Are you using Travis CI for your software development pipeline?",
default: true
}
];

Expand All @@ -112,7 +130,11 @@ class Commands {
".react-templates/config.json",
JSON.stringify(answers)
);

handleTravis(answers.travis);

} catch (err) {
console.log(err);
warnAndExit(`You need to initialize the cli before you configure it.`);
}
});
Expand Down Expand Up @@ -167,6 +189,15 @@ const warnAndExit = error => {
process.exit(-1);
};

const handleTravis = (flag) => {
if(flag){
Commands.initTravis();
}
else{
fs.unlink(".travis.yml", ()=>{console.log('removed travis configuration file');});
}
}

const main = () => {
const commands = new Commands();

Expand All @@ -181,6 +212,10 @@ const main = () => {
commands.add(name, opt.path);
});

program.command("travis").action(() => {
Commands.initTravis();
});

program.command("init").action(() => {
commands.init();
});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.