Skip to content

Commit

Permalink
Merge branch 'feature/completion' into develop
Browse files Browse the repository at this point in the history
Closes #8
  • Loading branch information
Kevin Grandemange committed Apr 6, 2017
2 parents 60680cd + a851c8c commit a30be9e
Show file tree
Hide file tree
Showing 21 changed files with 460 additions and 73 deletions.
19 changes: 5 additions & 14 deletions bin/clea-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@ const program = require('commander'),
packageFile = require('../package.json'),
project = require('../lib/project').getInstance(),
Build = require('../lib/commands/build'),
logger = require('../vendors/logger');

program
.version(packageFile.version)
.option('-v, --verbose', 'verbose mode')
.option('--target [env]', 'build the application with the targeted environment (defaults to: development)')
.option('--output-path [path]', 'build the application into this path (defaults to: dist/)')
.option('--base-href [url]', 'base url for the application being built (defaults to: /)', '/')
.option('--compress', 'enable gzip compression')
.option('--sourcemap', 'output sourcemaps')
.option('--doc', 'generate the documentation')
.option('--progress', 'display a compilation progress')
.option('--merge-config [config]', 'merge the given webpack configuration with the existing one')
.option('--override-config [config]', 'override the existing webpack configuration by the given one');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-build'),
Command = require('../lib/utilities/command');

program.version(packageFile.version);
Command.addOptions(program, options);
program.parse(process.argv);

project.init().then(() => {
Expand Down
17 changes: 17 additions & 0 deletions bin/clea-completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node
/* eslint-disable no-console */

const program = require('commander'),
packageFile = require('../package.json'),
Completion = require('../lib/commands/completion'),
{ options } = require('../lib/commands-options/clea-completion'),
Command = require('../lib/utilities/command');

program.version(packageFile.version);

Command.addOptions(program, options);

program.parse(process.argv);

const completion = new Completion(program.zsh && 'zsh');
completion.start();
12 changes: 8 additions & 4 deletions bin/clea-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ const program = require('commander'),
Project = require('../lib/project'),
project = Project.getInstance(),
Blueprints = require('../lib/blueprints/blueprints'),
Generate = require('../lib/commands/generate');
Generate = require('../lib/commands/generate'),
{ options } = require('../lib/commands-options/clea-generate'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.arguments('[blueprint] [name]')
.option('--with-component', `generate a component with the generated module. Only for ${chalk.blue('module')} blueprint.`)
.option('--lazy-load', `lazy load the module in the closest parent routing file. Only for ${chalk.blue('module')} blueprint.`)
.arguments('[blueprint] [name]');

Command.addOptions(program, options);

program
.action((blueprint, name, options) => {
project.init().then(() => {
if (project.clea && project.clea.type === Project.TYPE.LIBRARY) {
Expand Down
17 changes: 8 additions & 9 deletions bin/clea-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ const program = require('commander'),
packageFile = require('../package.json'),
Project = require('../lib/project'),
InitProject = require('../lib/commands/init-project'),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-init'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.arguments('[project-name]')
.option('-v, --verbose', 'verbose mode')
.option('--lib', 'generate a library instead of an application')
.option('--ui-framework [framework]', 'create application with built-in ui framework. "material" or "bootstrap" (defaults to: none)')
.option('--make-it-progressive', 'add the default configuration for a Progressive Web App (defaults to: false)')
.option('--skip-install', 'skip installing packages (defaults to: false)')
.option('--skip-git', 'skip initializing a git repository (defaults to: false)')
.option('--commit-message-conventions', 'add commit-msg hook to force use of the Google message conventions (defaults to: false)')
.arguments('[project-name]');

Command.addOptions(program, options);

program
.action((name) => {
if (!InitProject.UI_FRAMEWORKS.includes(program.uiFramework)) {
logger.error(`"${program.uiFramework}" ui framework is not allowed. ${chalk.blue.bold('clea help new')} to see allowed types.`);
Expand Down
10 changes: 6 additions & 4 deletions bin/clea-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const program = require('commander'),

project = require('../lib/project').getInstance(),
Lint = require('../lib/commands/lint'),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-lint'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.option('--fix', 'will attempt to fix lint errors')
.option('--force', 'will always return error code 0 even with lint errors. It also launches all linters, whether there is errors or not.');
.version(packageFile.version);

Command.addOptions(program, options);

program.parse(process.argv);

Expand Down
17 changes: 8 additions & 9 deletions bin/clea-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ const program = require('commander'),
packageFile = require('../package.json'),
Project = require('../lib/project'),
InitProject = require('../lib/commands/init-project'),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-new'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.arguments('[project-name]')
.option('-v, --verbose', 'verbose mode')
.option('--lib', 'generate a library instead of an application')
.option('--ui-framework [framework]', 'create application with built-in ui framework. "material" or "bootstrap" (defaults to: none)')
.option('--make-it-progressive', 'add the default configuration for a Progressive Web App (defaults to: false)')
.option('--skip-install', 'skip installing packages (defaults to: false)')
.option('--skip-git', 'skip initializing a git repository (defaults to: false)')
.option('--commit-message-conventions', 'add commit-msg hook to force use of the Google message conventions (defaults to: false)')
.arguments('[project-name]');

Command.addOptions(program, options);

program
.action((name) => {
if (!InitProject.UI_FRAMEWORKS.includes(program.uiFramework)) {
logger.error(`"${program.uiFramework}" ui framework is not allowed. ${chalk.blue.bold('clea help new')} to see allowed types.`);
Expand Down
20 changes: 6 additions & 14 deletions bin/clea-serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@ const program = require('commander'),
Project = require('../lib/project'),
project = Project.getInstance(),
Serve = require('../lib/commands/serve'),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-serve'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.option('-v, --verbose', 'verbose mode')
.option('--target [env]', 'build the application with the targeted environment (defaults to: development)', 'development')
.option('--host [host]', 'host to listen to (defaults to: localhost)', 'localhost')
.option('--port [port]', 'the port to serve the application (defaults to: 8080)', '8080')
.option('--base-href [url]', 'base url for the application being built (defaults to: /)', '/')
.option('--https', 'flag to turn on HTTPS')
.option('--progress', 'display a compilation progress (defaults to: false)')
.option('--api [db]', 'enable the mock API on the specified database JSON file (defaults to: db.json)')
.option('--api-custom-routes [config]', 'add custom Express routes (defaults to: api.conf.js)', 'api.conf.js')
.option('--proxy-config [config]', 'proxy configuration file')
.option('--merge-config [config]', 'merge the given webpack configuration with the existing one')
.option('--override-config [config]', 'override the existing webpack configuration by the given one');
.version(packageFile.version);

Command.addOptions(program, options);

program.parse(process.argv);

Expand Down
12 changes: 6 additions & 6 deletions bin/clea-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const program = require('commander'),
packageFile = require('../package.json'),
project = require('../lib/project').getInstance(),
Test = require('../lib/commands/test'),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
{ options } = require('../lib/commands-options/clea-test'),
Command = require('../lib/utilities/command');

program
.version(packageFile.version)
.option('--watch', 'run tests when files change')
.option('--single-run', 'run tests only once')
.option('--log-level [level]', 'level of logging (defaults to: info)', 'info')
.option('--port [port]', 'port where the web server will be listening (defaults to: 9876)', 9876);
.version(packageFile.version);

Command.addOptions(program, options);

program.parse(process.argv);

Expand Down
20 changes: 7 additions & 13 deletions bin/clea.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
#!/usr/bin/env node

const program = require('commander'),
chalk = require('chalk'),
SemVer = require('semver').SemVer,

packageFile = require('../package.json'),
nodeVersion = new SemVer(process.version),
logger = require('../vendors/logger');
logger = require('../vendors/logger'),
packageFile = require('../package.json'),
{ commands } = require('../lib/commands-options/clea'),
Command = require('../lib/utilities/command');

if (nodeVersion.compare(new SemVer('6.9.0')) < 0) {
logger.error(`ERROR: Your running version of Node v${nodeVersion.version}, is not a supported version to use the CLI. The official Node supported version is 6.9 and greater.`);

process.exit(1);
}

program.version(packageFile.version)
.command('new', `creates a new directory and runs ${chalk.blue.bold('clea init')} in it`)
.command('init', `creates a new project in the current folder`)
.command('generate', 'generates new code from blueprints')
.command('serve', 'builds and serves your app, rebuilding on file changes')
.command('build', 'builds your app and places it into the output path')
.command('test', 'runs your app\'s test suite')
.command('lint', 'lints code in existing project')
.parse(process.argv);
program.version(packageFile.version);
Command.addCommands(program, commands);
program.parse(process.argv);
34 changes: 34 additions & 0 deletions lib/commands-options/clea-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const options = [{
option: '-v, --verbose',
doc: 'verbose mode'
}, {
option: '--target [env]',
doc: 'build the application with the targeted environment (defaults to: development)'
}, {
option: '--output-path [path]',
doc: 'build the application into this path (defaults to: dist/)'
}, {
option: '--base-href [url]',
doc: 'base url for the application being built (defaults to: /)'
}, {
option: '--compress',
doc: 'enable gzip compression'
}, {
option: '--sourcemap',
doc: 'output sourcemaps'
}, {
option: '--doc',
doc: 'generate the documentation'
}, {
option: '--progress',
doc: 'display a compilation progress'
}, {
option: '--merge-config [config]',
doc: 'merge the given webpack configuration with the existing one'
}, {
option: '--override-config [config]',
doc: 'override the existing webpack configuration by the given one'
}];

module.exports.name = 'build';
module.exports.options = options;
10 changes: 10 additions & 0 deletions lib/commands-options/clea-completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const options = [{
option: '-z, --zsh',
doc: 'generate zsh config'
}, {
option: '-b, --bash',
doc: 'generate bash config'
}];

module.exports.name = 'completion';
module.exports.options = options;
12 changes: 12 additions & 0 deletions lib/commands-options/clea-generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const chalk = require('chalk');

const options = [{
option: '--with-component',
doc: `generate a component with the generated module. Only for ${chalk.blue('module')} blueprint.`
}, {
option: '--lazy-load',
doc: `lazy load the module in the closest parent routing file. Only for ${chalk.blue('module')} blueprint.`
}];

module.exports.name = 'generate';
module.exports.options = options;
25 changes: 25 additions & 0 deletions lib/commands-options/clea-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const options = [{
option: '-v, --verbose',
doc: 'verbose mode'
}, {
option: '--lib',
doc: 'generate a library instead of an application'
}, {
option: '--ui-framework [framework]',
doc: 'create application with built-in ui framework. "material" or "bootstrap" (defaults to: none)'
}, {
option: '--make-it-progressive',
doc: 'add the default configuration for a Progressive Web App (defaults to: false)'
}, {
option: '--skip-install',
doc: 'skip installing packages (defaults to: false)'
}, {
option: '--skip-git',
doc: 'skip initializing a git repository (defaults to: false)'
}, {
option: '--commit-message-conventions',
doc: 'add commit-msg hook to force use of the Google message conventions (defaults to: false)'
}];

module.exports.name = 'init';
module.exports.options = options;
10 changes: 10 additions & 0 deletions lib/commands-options/clea-lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const options = [{
option: '--fix',
doc: 'will attempt to fix lint errors'
}, {
option: '--force',
doc: 'will always return error code 0 even with lint errors. It also launches all linters, whether there is errors or not.'
}];

module.exports.name = 'lint';
module.exports.options = options;
25 changes: 25 additions & 0 deletions lib/commands-options/clea-new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const options = [{
option: '-v, --verbose',
doc: 'verbose mode'
}, {
option: '--lib',
doc: 'generate a library instead of an application'
}, {
option: '--ui-framework [framework]',
doc: 'create application with built-in ui framework. "material" or "bootstrap" (defaults to: none)'
}, {
option: '--make-it-progressive',
doc: 'add the default configuration for a Progressive Web App (defaults to: false)'
}, {
option: '--skip-install',
doc: 'skip installing packages (defaults to: false)'
}, {
option: '--skip-git',
doc: 'skip initializing a git repository (defaults to: false)'
}, {
option: '--commit-message-conventions',
doc: 'add commit-msg hook to force use of the Google message conventions (defaults to: false)'
}];

module.exports.name = 'new';
module.exports.options = options;
45 changes: 45 additions & 0 deletions lib/commands-options/clea-serve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const options = [{
option: '-v, --verbose',
doc: 'verbose mode'
}, {
option: '--target [env]',
doc: 'build the application with the targeted environment (defaults to: development)',
default: 'development'
}, {
option: '--host [host]',
doc: 'host to listen to (defaults to: localhost)',
default: 'localhost'
}, {
option: '--port [port]',
doc: 'the port to serve the application (defaults to: 8080)',
default: '8080'
}, {
option: '--base-href [url]',
doc: 'base url for the application being built (defaults to: /)',
default: '/'
}, {
option: '--https',
doc: 'flag to turn on HTTPS'
}, {
option: '--progress',
doc: 'display a compilation progress (defaults to: false)'
}, {
option: '--api [db]',
doc: 'enable the mock API on the specified database JSON file (defaults to: db.json)'
}, {
option: '--api-custom-routes [config]',
doc: 'add custom Express routes (defaults to: api.conf.js)',
default: 'api.conf.js'
}, {
option: '--proxy-config [config]',
doc: 'proxy configuration file'
}, {
option: '--merge-config [config]',
doc: 'merge the given webpack configuration with the existing one'
}, {
option: '--override-config [config]',
doc: 'override the existing webpack configuration by the given one'
}];

module.exports.name = 'serve';
module.exports.options = options;

0 comments on commit a30be9e

Please sign in to comment.