Skip to content

Commit

Permalink
Cleanups: user support, workflow etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifycode committed May 14, 2023
1 parent 851685c commit 637e6dc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:

strategy:
matrix:
node-version: [15.x, 16.x, 17.x, 18.x, 19.x, 20.x]
# node version 12, 13, 14 are failing so they have been removed
node-version: [16.x, 17.x, 18.x, 19.x, 20.x]
# node version 12, 13, 14 says cannot find arg of undefined, 15 says bad engine for most upgraded packages in the cli so they have been removed from our node versions
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
16 changes: 6 additions & 10 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import arg from 'arg';
import { help } from './help';
import chalk from 'chalk';
import { version } from './version';
import { notRecognised } from './help';
import { help, notRecognised } from './help';
import { folderNameMissingOptionPrompt } from './prompts/foldername';
import { templateMissingOptionPrompt } from './prompts/template';
import { downloadTemplateKit } from './main';
Expand Down Expand Up @@ -37,7 +37,7 @@ let parseArgumentsIntoOptions = (rawArgs) => {
'-y': '--yes',
'-i': '--install',
'-s': '--skip-install',
'--help': arg.flag(helpHandler),
'--help': arg.flag(helpHandler), //eslint-disable-line no-dupe-keys
'-h': '--help',
'--version': arg.flag(versionHelper),
'-v': '--version'
Expand All @@ -56,7 +56,7 @@ let parseArgumentsIntoOptions = (rawArgs) => {
skipInstall: args['--skip-install'] || false,
help: args['--help'] || false,
version: args['--version'] || false
}
}
} catch (err) {
notRecognised();
}
Expand All @@ -80,9 +80,7 @@ let otherOptions = async (options) => {
try {
await downloadTemplateKit(options);
} catch (err) {
console.log('Error | ', err);
console.log('You can report the error they encountered at https://github.com/code-collabo/node-mongo-cli/issues/new?assignees=&labels=bug&template=cli-user-error-report.md');
console.log('There is a manual download option for the API boilerplate templates at: https://github.com/code-collabo/node-mongo-api-boilerplate-templates');
console.log(chalk.red.bold('ERROR'), err);
}
}

Expand All @@ -99,7 +97,5 @@ export let cli = async (args) => {
}
} catch (err) {
console.log('');
console.log(' You can report the error you encountered at https://github.com/code-collabo/node-mongo-cli/issues/new?assignees=&labels=bug&template=cli-user-error-report.md');
console.log(' There is a manual download option for the API boilerplate templates at: https://github.com/code-collabo/node-mongo-api-boilerplate-templates');
}
}
}
31 changes: 22 additions & 9 deletions src/help.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import chalk from 'chalk';

export const help = () => {
console.log(
`
Usage:
node-mongo <folder_name> <template>
node-mongo <folder_name> <template>
Command:
node-mongo
Expand All @@ -15,13 +16,13 @@ Arguments:
Usage example:
node-mongo test-folder cjs
The above example bootstraps the cjs template i.e.
The above example bootstraps the cjs template i.e.
the common js template into a folder named test-folder.
Prompts:
If you do not specify one or both arguments above,
you will be prompted to add your folder name and/or
choose template option from list. For foldername, you
If you do not specify one or both arguments above,
you will be prompted to add your folder name and/or
choose template option from list. For foldername, you
can choose to use the default foldername provided in
the prompt or type in your preferred folder name.
Expand All @@ -34,9 +35,9 @@ Flags:
-x, --skip-git Skip initializing git
-y, --yes See note on --yes flag below
No prompt when --yes flag is used. It skips both
install and git init, and uses esm template as default
if no template is specified or if template entered is
No prompt when --yes flag is used. It skips both
install and git init, and uses esm template as default
if no template is specified or if template entered is
not in the template collection. In the case of folder
name, default foldername is used if no folder name is
specified or when folder name already exists.
Expand All @@ -51,4 +52,16 @@ Flag(s) not recognised. Use the help command below for more info:
node-mongo --help`
);
}
}

export const userSupport = () => {
console.log (chalk.yellowBright(
`
It looks like the node-mongo-cli does not work yet for your computer's operating system. Let us know the issue with the CLI on your computer's operating system by reporting it here:
https://github.com/code-collabo/node-mongo-cli/issues/new?assignees=&labels=bug&template=cli-user-error-report.md
Alternatively, you can download and access the API boilerplate templates from the template's github repo:
https://github.com/code-collabo/node-mongo-api-boilerplate-templates
`)
);
}
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { promisify } from 'util';
import execa from 'execa';
import Listr from 'listr';
import { spawn } from 'child_process';
import { userSupport } from './help';

const access = promisify(fs.access);
const copy = promisify(ncp);
Expand Down Expand Up @@ -94,6 +95,7 @@ export let downloadTemplateKit = async (options) => {

}catch (err) {
console.error(`\n%s Template name or directory path is (probably) incorrect`, chalk.red.bold('ERROR'));
userSupport();
process.exit(1);
}

Expand Down Expand Up @@ -122,7 +124,5 @@ export let downloadTemplateKit = async (options) => {

await listrTasks.run();

//await npmInstall(options);

return true;
}

0 comments on commit 637e6dc

Please sign in to comment.