Skip to content

Commit

Permalink
Bump generator dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Feb 22, 2019
1 parent 9004aa6 commit cbb149d
Show file tree
Hide file tree
Showing 4 changed files with 874 additions and 426 deletions.
18 changes: 14 additions & 4 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class NgxCli {
if (this._options.help) {
return this._help(true);
}

switch (this._args[0]) {
case 'n':
case 'new':
Expand All @@ -92,6 +93,7 @@ class NgxCli {
if (!args[0]) {
return this._help();
}

const packageManager = this._packageManager();
fuzzyRun(args, packageManager);
}
Expand All @@ -105,6 +107,7 @@ class NgxCli {
} else {
this._exit(`No existing app found, use ${chalk.blue('ngx new')} instead`);
}

if (addon) {
args = args.filter(arg => arg !== '--addon' && arg !== '-a');
env.lookup(() =>
Expand Down Expand Up @@ -152,10 +155,12 @@ class NgxCli {

this._config.set(
disabledAddons,
addons.filter(addon => !answers.addons.includes(addon)).reduce((r, addon) => {
r[addon] = true;
return r;
}, {})
addons
.filter(addon => !answers.addons.includes(addon))
.reduce((r, addon) => {
r[addon] = true;
return r;
}, {})
);
console.log('Configuration saved.');
}
Expand All @@ -169,6 +174,7 @@ class NgxCli {
} else {
addons = await this._findAddons();
}

const disabled = this._config.get(disabledAddons);
console.log(chalk.blue(`Available add-ons${npm ? ' on NPM' : ''}:`));

Expand Down Expand Up @@ -203,6 +209,7 @@ class NgxCli {
if (components.length === 0) {
return null;
}

const dir = path.join(...components);
const packageFile = path.join(dir, 'package.json');
return fs.existsSync(packageFile) ? packageFile : find(components.slice(0, -1));
Expand All @@ -213,20 +220,23 @@ class NgxCli {
// When path starts with a slash, the first path component is empty string
components[0] = path.sep;
}

return find(components);
}

_packageManager() {
if (this._options.packageManager) {
return this._options.packageManager === 'yarn' ? 'yarn' : 'npm';
}

let pm = null;
try {
const rc = require(path.join(process.cwd(), '.yo-rc.json'));
pm = rc['generator-ngx-rocket'].props.packageManager;
} catch (error) {
// Do nothing
}

return pm || process.env.NGX_PACKAGE_MANAGER || 'npm';
}

Expand Down
1 change: 1 addition & 0 deletions generators/app/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = [
// eslint-disable-next-line unicorn/no-process-exit
process.exit(-1);
}

return value;
},
required: false,
Expand Down
Loading

0 comments on commit cbb149d

Please sign in to comment.