Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
yarn.lock
.nyc_output
coverage
.project
1 change: 1 addition & 0 deletions .nyc_output/0f513c9c-8c18-41a6-9eee-509a794dc7aa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/14a1ed33-3dd5-4277-9bcf-a2ded4fbb56c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/1a0c0d5e-81b3-427e-a5a0-b853cb27777d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/1de8dc45-e3df-4e42-8849-0139a5a71a71.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/26bec8df-a085-4a08-9555-76d226d13235.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/37f13554-0026-4c41-92e9-7bb804693189.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/4d7871a4-b71d-4d88-92cd-5bb1591dab79.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/55a044bc-2e1a-48d9-a416-1666bf4c4303.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/6dc9ae70-d9ab-46d0-ab47-8cc97f13e5ea.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/74a13c5d-4da1-48f1-842d-a02cde4b07f7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/925a023e-4153-4158-a5c7-9ceef282cbc2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/ac7716ad-18bc-492c-ba20-4f4cfb00edc2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/c0b5d324-1f73-42c5-b464-32edfe792f63.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/c373ef84-dc73-455d-bcb8-dbefdcbb72d8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/d6523f5a-693f-4b12-ae2c-b0225c407130.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .nyc_output/fdd932f1-5fdb-4991-ae7b-df5a7604c4f8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59588,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"phoenix-app\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529277,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/0f513c9c-8c18-41a6-9eee-509a794dc7aa.json","externalId":"","uuid":"0f513c9c-8c18-41a6-9eee-509a794dc7aa","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59590,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"phoenix-app\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529428,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/14a1ed33-3dd5-4277-9bcf-a2ded4fbb56c.json","externalId":"","uuid":"14a1ed33-3dd5-4277-9bcf-a2ded4fbb56c","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59587,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"xanadu-all\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529278,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/1a0c0d5e-81b3-427e-a5a0-b853cb27777d.json","externalId":"","uuid":"1a0c0d5e-81b3-427e-a5a0-b853cb27777d","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59589,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"xanadu-all\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529428,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/1de8dc45-e3df-4e42-8849-0139a5a71a71.json","externalId":"","uuid":"1de8dc45-e3df-4e42-8849-0139a5a71a71","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"d6523f5a-693f-4b12-ae2c-b0225c407130","pid":59405,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/npm","root","-g"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479524753,"ppid":59346,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/26bec8df-a085-4a08-9555-76d226d13235.json","externalId":"","uuid":"26bec8df-a085-4a08-9555-76d226d13235","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59302,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/lib/cli.js","--generators"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479522632,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/37f13554-0026-4c41-92e9-7bb804693189.json","externalId":"","uuid":"37f13554-0026-4c41-92e9-7bb804693189","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"37f13554-0026-4c41-92e9-7bb804693189","pid":59343,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/npm","root","-g"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479523645,"ppid":59302,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/4d7871a4-b71d-4d88-92cd-5bb1591dab79.json","externalId":"","uuid":"4d7871a4-b71d-4d88-92cd-5bb1591dab79","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59446,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/lib/cli.js","","--help"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479525298,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/55a044bc-2e1a-48d9-a416-1666bf4c4303.json","externalId":"","uuid":"55a044bc-2e1a-48d9-a416-1666bf4c4303","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59592,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"phoenix-app\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529577,"ppid":1,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/6dc9ae70-d9ab-46d0-ab47-8cc97f13e5ea.json","externalId":"","uuid":"6dc9ae70-d9ab-46d0-ab47-8cc97f13e5ea","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59543,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/npm","root","-g"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479526595,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/74a13c5d-4da1-48f1-842d-a02cde4b07f7.json","externalId":"","uuid":"74a13c5d-4da1-48f1-842d-a02cde4b07f7","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59443,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/npm","root","-g"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479525157,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/925a023e-4153-4158-a5c7-9ceef282cbc2.json","externalId":"","uuid":"925a023e-4153-4158-a5c7-9ceef282cbc2","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59299,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/lib/cli.js","--version"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479522169,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/ac7716ad-18bc-492c-ba20-4f4cfb00edc2.json","externalId":"","uuid":"ac7716ad-18bc-492c-ba20-4f4cfb00edc2","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"55a044bc-2e1a-48d9-a416-1666bf4c4303","pid":59484,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/npm","root","-g"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479526252,"ppid":59446,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/c0b5d324-1f73-42c5-b464-32edfe792f63.json","externalId":"","uuid":"c0b5d324-1f73-42c5-b464-32edfe792f63","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":null,"pid":59274,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/.bin/mocha","--timeout=30000"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479521117,"ppid":59272,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/c373ef84-dc73-455d-bcb8-dbefdcbb72d8.json","externalId":"","uuid":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59346,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/lib/cli.js","--generators","--local-only"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479523807,"ppid":59274,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/d6523f5a-693f-4b12-ae2c-b0225c407130.json","externalId":"","uuid":"d6523f5a-693f-4b12-ae2c-b0225c407130","files":[]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","pid":59591,"argv":["/Users/tjlahr/.nvm/versions/node/v22.9.0/bin/node","/Users/tjlahr/Repos/yo/node_modules/update-notifier/check.js","{\"pkg\":{\"name\":\"xanadu-all\",\"version\":\"0.1.0\"},\"distTag\":\"latest\"}"],"execArgv":[],"cwd":"/Users/tjlahr/Repos/yo","time":1742479529577,"ppid":1,"coverageFilename":"/Users/tjlahr/Repos/yo/.nyc_output/fdd932f1-5fdb-4991-ae7b-df5a7604c4f8.json","externalId":"","uuid":"fdd932f1-5fdb-4991-ae7b-df5a7604c4f8","files":[]}
1 change: 1 addition & 0 deletions .nyc_output/processinfo/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"processes":{"0f513c9c-8c18-41a6-9eee-509a794dc7aa":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":[]},"1a0c0d5e-81b3-427e-a5a0-b853cb27777d":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":[]},"26bec8df-a085-4a08-9555-76d226d13235":{"parent":"d6523f5a-693f-4b12-ae2c-b0225c407130","children":[]},"37f13554-0026-4c41-92e9-7bb804693189":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":["4d7871a4-b71d-4d88-92cd-5bb1591dab79"]},"4d7871a4-b71d-4d88-92cd-5bb1591dab79":{"parent":"37f13554-0026-4c41-92e9-7bb804693189","children":[]},"55a044bc-2e1a-48d9-a416-1666bf4c4303":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":["c0b5d324-1f73-42c5-b464-32edfe792f63"]},"74a13c5d-4da1-48f1-842d-a02cde4b07f7":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":[]},"925a023e-4153-4158-a5c7-9ceef282cbc2":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":[]},"ac7716ad-18bc-492c-ba20-4f4cfb00edc2":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":[]},"c0b5d324-1f73-42c5-b464-32edfe792f63":{"parent":"55a044bc-2e1a-48d9-a416-1666bf4c4303","children":[]},"c373ef84-dc73-455d-bcb8-dbefdcbb72d8":{"parent":null,"children":["0f513c9c-8c18-41a6-9eee-509a794dc7aa","1a0c0d5e-81b3-427e-a5a0-b853cb27777d","37f13554-0026-4c41-92e9-7bb804693189","55a044bc-2e1a-48d9-a416-1666bf4c4303","74a13c5d-4da1-48f1-842d-a02cde4b07f7","925a023e-4153-4158-a5c7-9ceef282cbc2","ac7716ad-18bc-492c-ba20-4f4cfb00edc2","d6523f5a-693f-4b12-ae2c-b0225c407130"]},"d6523f5a-693f-4b12-ae2c-b0225c407130":{"parent":"c373ef84-dc73-455d-bcb8-dbefdcbb72d8","children":["26bec8df-a085-4a08-9555-76d226d13235"]}},"files":{},"externalIds":{}}
65 changes: 32 additions & 33 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const yosay = require('yosay');
const stringLength = require('string-length');
const rootCheck = require('root-check');
const meow = require('meow');
const list = require('cli-list');
const Tabtab = require('tabtab');
const pkg = require('../package.json');
const Router = require('./router');

import fs from 'node:fs';
import path from 'node:path';
import chalk from 'chalk';
import updateNotifier from 'update-notifier';
import yosay from 'yosay';
import stringLength from 'string-length';
import rootCheck from 'root-check';
import meow from 'meow';
import list from 'cli-list';
import Tabtab from 'tabtab';
import pkg from './utils/project-package.js';
import Router from './router.js';
import {bootstrap} from 'global-agent';
import * as routes from './routes/index.js';
import {getDirname} from './utils/node-shims.js';

const __dirname = getDirname(import.meta.url);
const gens = list(process.argv.slice(2));

// Override http networking to go through a proxy ifone is configured
const MAJOR_NODEJS_VERSION = Number.parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above.
require('global-agent').bootstrap();
} else {
// `global-tunnel-ng` works only with Node.js v10 and below.
require('global-tunnel-ng').initialize();
}
bootstrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can eliminate this branching because we're > Node 10.
Simply import and call bootstrap.


/* eslint new-cap: 0, no-extra-parens: 0 */
const tabtab = new Tabtab.Commands.default({
Expand All @@ -33,7 +28,7 @@ const tabtab = new Tabtab.Commands.default({
});

const cli = gens.map(gen => {
const minicli = meow({autoHelp: false, autoVersion: true, pkg, argv: gen});
const minicli = meow({autoHelp: false, autoVersion: true, pkg, argv: gen, importMeta: import.meta});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tweak to support the latest meow version.

const options = minicli.flags;
const args = minicli.input;

Expand Down Expand Up @@ -66,7 +61,9 @@ function updateCheck() {
async function pre() {
// Debugging helper
if (cmd === 'doctor') {
require('yeoman-doctor')();
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const yeomanDoctor = (await import('yeoman-doctor')).default;
yeomanDoctor();
return;
}

Expand All @@ -76,7 +73,9 @@ async function pre() {

// Easteregg
if (cmd === 'yeoman' || cmd === 'yo') {
console.log(require('yeoman-character'));
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const yeomanCharacter = (await import('yeoman-character')).default;
console.log(yeomanCharacter);
return;
}

Expand Down Expand Up @@ -171,13 +170,13 @@ async function init() {

function runYo(env) {
const router = new Router(env);
router.registerRoute('help', require('./routes/help'));
router.registerRoute('update', require('./routes/update'));
router.registerRoute('run', require('./routes/run'));
router.registerRoute('install', require('./routes/install'));
router.registerRoute('exit', require('./routes/exit'));
router.registerRoute('clearConfig', require('./routes/clear-config'));
router.registerRoute('home', require('./routes/home'));
router.registerRoute('help', routes.help);
router.registerRoute('update', routes.update);
router.registerRoute('run', routes.run);
router.registerRoute('install', routes.install);
router.registerRoute('exit', routes.exit);
router.registerRoute('clearConfig', routes.clearConfig);
router.registerRoute('home', routes.home);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I collected these into a routes object that can be imported at once.


process.once('exit', router.navigate.bind(router, 'exit'));

Expand Down
13 changes: 7 additions & 6 deletions lib/completion/completer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
'use strict';
const path = require('path');
const {execFile} = require('child_process');
const parseHelp = require('parse-help');
import path from 'path';
import {execFile} from 'node:child_process';
import parseHelp from 'parse-help';
import {getDirname} from '../utils/node-shims.js';

const __dirname = getDirname(import.meta.url);

/**
* The Completer is in charge of handling `yo-complete` behavior.
* @constructor
* @param {Environment} env A yeoman environment instance
*/
class Completer {
export default class Completer {
constructor(env) {
this.env = env;
}
Expand Down Expand Up @@ -102,5 +105,3 @@ class Completer {
return results;
}
}

module.exports = Completer;
8 changes: 5 additions & 3 deletions lib/completion/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#! /usr/bin/env node
'use strict';
const tabtab = require('tabtab')({
import tabtabFactory from 'tabtab';
import Completer from './completer.js';

const tabtab = tabtabFactory({
name: 'yo',
cache: !process.env.YO_TEST
});
const Completer = require('./completer');

(async () => {
// eslint-disable-next-line node/no-unsupported-features/es-syntax
Expand All @@ -21,4 +23,4 @@ const Completer = require('./completer');
tabtab.start();
})();

module.exports = tabtab;
export default tabtab;
20 changes: 9 additions & 11 deletions lib/router.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';
const path = require('path');
const titleize = require('titleize');
const humanizeString = require('humanize-string');
const readPkgUp = require('read-pkg-up');
const updateNotifier = require('update-notifier');
const Configstore = require('configstore');
const {namespaceToName} = require('./utils/namespace');
import path from 'path';
import titleize from 'titleize';
import humanizeString from 'humanize-string';
import readPkgUp from 'read-pkg-up';
import updateNotifier from 'update-notifier';
import Configstore from 'configstore';
import {namespaceToName} from './utils/namespace.js';
import pkg from './utils/project-package.js';

/**
* The router is in charge of handling `yo` different screens.
* @constructor
* @param {Environment} env A yeoman environment instance
* @param {Configstore} [conf] An optional config store instance
*/
class Router {
export default class Router {
constructor(env, conf) {
const pkg = require('../package.json');
this.routes = {};
this.env = env;
this.conf = conf || new Configstore(pkg.name, {
Expand Down Expand Up @@ -83,5 +83,3 @@ class Router {
}
}
}

module.exports = Router;
12 changes: 6 additions & 6 deletions lib/routes/clear-config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
const _ = require('lodash');
const chalk = require('chalk');
const inquirer = require('inquirer');
const globalConfig = require('../utils/global-config');
const {namespaceToName} = require('../utils/namespace');
import _ from 'lodash';
import chalk from 'chalk';
import inquirer from 'inquirer';
import globalConfig from '../utils/global-config.js';
import {namespaceToName} from '../utils/namespace.js';

module.exports = async app => {
export const clearConfig = async app => {
const defaultChoices = [
{
name: 'Take me back home, Yo!',
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/exit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const yosay = require('yosay');
import yosay from 'yosay';

module.exports = async () => {
export const exit = async () => {
const PADDING = 5;
const url = 'http://yeoman.io';
const maxLength = url.length + PADDING;
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/help.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
const inquirer = require('inquirer');
const open = require('open');
import inquirer from 'inquirer';
import open from 'open';

module.exports = async app => {
export const help = async app => {
return inquirer.prompt([{
name: 'whereTo',
type: 'list',
Expand Down
19 changes: 9 additions & 10 deletions lib/routes/home.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict';
const _ = require('lodash');
const chalk = require('chalk');
const fullname = require('fullname');
const inquirer = require('inquirer');
const {isString} = require('lodash');
const {namespaceToName} = require('../utils/namespace');
const globalConfigHasContent = require('../utils/global-config').hasContent;
import _ from 'lodash';
import chalk from 'chalk';
import fullname from 'fullname';
import inquirer from 'inquirer';
import {namespaceToName} from '../utils/namespace.js';
import globalConfig from '../utils/global-config.js';

module.exports = async app => {
export const home = async app => {
const defaultChoices = [{
name: 'Install a generator',
value: 'install'
Expand All @@ -19,7 +18,7 @@ module.exports = async app => {
value: 'exit'
}];

if (globalConfigHasContent()) {
if (globalConfig.hasContent()) {
defaultChoices.splice(-1, 0, {
name: 'Clear global config',
value: 'clearConfig'
Expand Down Expand Up @@ -53,7 +52,7 @@ module.exports = async app => {
}

return fullname().then(name => {
const allo = (name && isString(name)) ? `'Allo ${name.split(' ')[0]}! ` : '\'Allo! ';
const allo = (name && _.isString(name)) ? `'Allo ${name.split(' ')[0]}! ` : '\'Allo! ';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will occasionally inline lodash if it's a one-off and the specific method was imported directly.


return inquirer.prompt([{
name: 'whatNext',
Expand Down
7 changes: 7 additions & 0 deletions lib/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {clearConfig} from './clear-config.js';
export {exit} from './exit.js';
export {help} from './help.js';
export {home} from './home.js';
export {install} from './install.js';
export {run} from './run.js';
export {update} from './update.js';
Loading
Loading