From 281a86442b62328c5661e9124ea72815faf8fa69 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 9 Apr 2021 04:57:27 +0100 Subject: [PATCH 001/136] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 5f4a718..fccac9a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ ISC License (ISC) -Copyright 2021 Code Collabo +Copyright 2021 Obiagba Mary | Code Collabo Permission to use, copy, modify, and/or distribute this software for any purpose From eb3d5f115c868f455f569d65581bda1207d65ee3 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 9 Apr 2021 04:59:54 +0100 Subject: [PATCH 002/136] Add word Community to org name in license --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index fccac9a..bff42ba 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ ISC License (ISC) -Copyright 2021 Obiagba Mary | Code Collabo +Copyright 2021 Obiagba Mary | Code Collabo Community Permission to use, copy, modify, and/or distribute this software for any purpose From 896696070fc7267b6c307785a78d72be7153f494 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 17:21:20 +0100 Subject: [PATCH 003/136] Update all docs links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0bf7e01..7653673 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,15 @@ The [cli](https://github.com/code-collabo/node-mongo-cli) is built to help provide better experience when using the starter-kit in MongoDB, MERN or MEAN projects. ## Documentation -For easy maintenance (due to modifications to be made and addition of more features) and also to provide you better support, sections previously included in the readme have been [moved to our docs](https://github.com/code-collabo/docs). Simply click on any of the links to learn to install, use and contribute to the node-mongo project. +For easy maintenance (due to modifications to be made and addition of more features) and also to provide you better support, sections previously included in the readme have been [moved to our docs](https://code-collabo.gitbook.io/docs-code-collabo/) - see [this section of the docs](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/code-collabo-docs) in case you also wish to contribute to the docs. Simply click on any of the links to learn to install, use and contribute to the node-mongo project. #### Using node-mongo No user guide yet, work is still in progress. #### Contributing to node-mongo -* See [docs: contributor guide](https://github.com/code-collabo/docs/tree/main/contributor-guide) which contains ***contributing.md***, ***CODE_OF_CONDUCT***, ***git workflow*** and ***project development setup*** to help you get started. +* See [contributor guide](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/contributor-guide) which contains ***contributing.md***, ***CODE_OF_CONDUCT***, ***git workflow*** and ***project development setup*** to help you get started. ## Resources -You can [use these resources](https://github.com/code-collabo/docs/blob/main/contributor-guide/node-mongo-project/resources.md) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. +You can [use these resources](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/node-mongo-project/resources) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. ## Contributors ✨ From 85812f6400435508e9dd9c12e81df3251f62060f Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:22:59 -0800 Subject: [PATCH 004/136] Transfer contributors to docs --- README.md | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7653673..ea0dc22 100644 --- a/README.md +++ b/README.md @@ -20,27 +20,9 @@ No user guide yet, work is still in progress. ## Resources You can [use these resources](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/node-mongo-project/resources) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. -## Contributors ✨ +## Meet our contributors ✨ -Thanks to these wonderful people helping to improve the ***node-mongo-cli*** project [= (emoji key) =>](https://allcontributors.org/docs/en/emoji-key) - - - - - - - - - - -

Obiagba Mary Ifeoma

💻 📖 🚇 🚧 👀 📆 🤔

Israel Obiagba

🧑‍🏫

Joseph Obiagba

🧑‍🏫
- - - - - - -See complete list of Code Collabo contributors in the [docs: all-contributors.md](https://github.com/code-collabo/docs/blob/main/all-contributors.md). +[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs-code-collabo/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ ## Technologies From f55caa1f1f29d807d7661756eea4c8477c96744f Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:24:19 -0800 Subject: [PATCH 005/136] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea0dc22..ef8cc34 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ No user guide yet, work is still in progress. ## Resources You can [use these resources](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/node-mongo-project/resources) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. -## Meet our contributors ✨ +## Contributors ✨ [Thanks to these wonderful people](https://code-collabo.gitbook.io/docs-code-collabo/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ From 21ae3ae8d4bda6dd250c198a14e5f21242a0012d Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:26:05 -0800 Subject: [PATCH 006/136] Delete CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 8b8b608..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1 +0,0 @@ -Moved to [docs: CODE_OF_CONDUCT](https://github.com/code-collabo/docs/blob/main/CODE_OF_CONDUCT.md) From 590c9fa0ea17113c4bf2ac2f8d03823679315d8d Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:26:36 -0800 Subject: [PATCH 007/136] Delete contributor.md --- contributor.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 contributor.md diff --git a/contributor.md b/contributor.md deleted file mode 100644 index 34be49f..0000000 --- a/contributor.md +++ /dev/null @@ -1 +0,0 @@ -Move ***node-mongo-cli*** contributors here once the readme looks too crowded. From e0da56c23e1da7eddf8dc1b9a8377c14dc10506d Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:26:57 -0800 Subject: [PATCH 008/136] Delete contributing.md --- contributing.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 contributing.md diff --git a/contributing.md b/contributing.md deleted file mode 100644 index a4f93b8..0000000 --- a/contributing.md +++ /dev/null @@ -1 +0,0 @@ -Moved to [docs: contributing.md](https://github.com/code-collabo/docs/blob/main/contributing.md) From 322ad1beebea35b06c08e62e3ac88fe3f002bae0 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 11 Apr 2021 11:56:17 -0800 Subject: [PATCH 009/136] Update links --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ef8cc34..f6929d6 100644 --- a/README.md +++ b/README.md @@ -10,19 +10,19 @@ The [cli](https://github.com/code-collabo/node-mongo-cli) is built to help provide better experience when using the starter-kit in MongoDB, MERN or MEAN projects. ## Documentation -For easy maintenance (due to modifications to be made and addition of more features) and also to provide you better support, sections previously included in the readme have been [moved to our docs](https://code-collabo.gitbook.io/docs-code-collabo/) - see [this section of the docs](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/code-collabo-docs) in case you also wish to contribute to the docs. Simply click on any of the links to learn to install, use and contribute to the node-mongo project. +For easy maintenance (due to modifications to be made and addition of more features) and also to provide you better support, sections previously included in the readme have been [moved to our docs](https://code-collabo.gitbook.io/docs/) - see [this section of the docs](https://code-collabo.gitbook.io/docs/contributor-guide/docs) in case you also wish to contribute to the docs. Simply click on any of the links to learn to install, use and contribute to the node-mongo project. #### Using node-mongo No user guide yet, work is still in progress. #### Contributing to node-mongo -* See [contributor guide](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/contributor-guide) which contains ***contributing.md***, ***CODE_OF_CONDUCT***, ***git workflow*** and ***project development setup*** to help you get started. +* See [contributor guide](https://code-collabo.gitbook.io/docs/contributor-guide/contributor-guide) which contains ***contributing.md***, ***CODE_OF_CONDUCT***, ***git workflow*** and ***project development setup*** to help you get started. ## Resources -You can [use these resources](https://code-collabo.gitbook.io/docs-code-collabo/contributor-guide/node-mongo-project/resources) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. +You can [use these resources](https://code-collabo.gitbook.io/docs/contributor-guide/node-mongo-project/resources) as guide while contributing to the project. Appreciation goes to authors [@dkundel](https://github.com/dkundel), [@academind](https://github.com/academind), [@CodAffection](https://github.com/CodAffection), whose awesome youTube videos and/or articles make up this list of resources, and which have been useful to building the node-mongo project so far. Also to [@coryhouse](https://github.com/coryhouse), author of building a javascript development environment course. ## Contributors ✨ -[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs-code-collabo/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ +[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ ## Technologies From 31d910ebd2cd2ab0e9f1a593fbc306bc40683e16 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 9 May 2021 10:12:15 +0100 Subject: [PATCH 010/136] Create task creation template --- .github/ISSUE_TEMPLATE/create-a-task.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/create-a-task.md diff --git a/.github/ISSUE_TEMPLATE/create-a-task.md b/.github/ISSUE_TEMPLATE/create-a-task.md new file mode 100644 index 0000000..6ec212a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/create-a-task.md @@ -0,0 +1,19 @@ +--- +name: Create a task +about: Pattern to follow while creating a task to be solved +title: '' +labels: '' +assignees: '' + +--- + +Pattern to follow when creating a new task. Note: This is not for bug report. A separate template exists for reporting bugs. + +#### Task description +Give brief intro and describe what the task entails. + +#### Test cases and expected output +Include test cases e.g. commands to run and expected output. Add screenshots if/where possible. + +#### Examples +You can include examples of files, repos, issues or pull requests where something similar to the task you're describing has been done, if any. From 8c8c951428489b338dce2d911ac58baf8a4b797c Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 9 May 2021 10:27:59 +0100 Subject: [PATCH 011/136] Create bug template --- .github/ISSUE_TEMPLATE/report-a-bug.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/report-a-bug.md diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md new file mode 100644 index 0000000..f77378f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/report-a-bug.md @@ -0,0 +1,26 @@ +--- +name: Report a bug +about: Found a bug? Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Run this command '....' +3. See error etc. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. From a50c523c276cc395e3a6e09e80c6a765e1c7ed55 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 9 May 2021 10:43:16 +0100 Subject: [PATCH 012/136] Update task template assignee & label --- .github/ISSUE_TEMPLATE/create-a-task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/create-a-task.md b/.github/ISSUE_TEMPLATE/create-a-task.md index 6ec212a..84a655c 100644 --- a/.github/ISSUE_TEMPLATE/create-a-task.md +++ b/.github/ISSUE_TEMPLATE/create-a-task.md @@ -2,8 +2,8 @@ name: Create a task about: Pattern to follow while creating a task to be solved title: '' -labels: '' -assignees: '' +labels: repo setup +assignees: Ifycode --- From 4d1784408352c0b457dfd1b7f8a4c38ee9027d81 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sun, 9 May 2021 10:59:26 +0100 Subject: [PATCH 013/136] Create pull_request_template.md --- .github/pull_request_template.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..27ae2ed --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,14 @@ +**This pull request makes the following changes:** +* Fixes issue code-collabo/node-mongo-cli#issueNumberHere + +**Details:** +* Setup for '...' +* Adds '...' etc. + +**Testing checklist:** +- [ ] Run '...' +- [ ] Check that '...' +- [ ] Check that '...' etc. +- [ ] I certify that I ran my checklist. + +Ping @code-collabo/node-mongo-cli From 31525955a1d7c34fc9bfbf26e8478e9c384f3e43 Mon Sep 17 00:00:00 2001 From: ifycode Date: Thu, 13 May 2021 03:45:16 -0800 Subject: [PATCH 014/136] Fix folder overwrite when there's no args & separate the prompts --- src/cli.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/src/cli.js b/src/cli.js index b87ded4..73eed8e 100644 --- a/src/cli.js +++ b/src/cli.js @@ -2,6 +2,7 @@ import arg from 'arg'; import inquirer from 'inquirer'; import { createProject } from './main'; import chalk from 'chalk'; +import fs from 'fs'; let parseArgumentsIntoOptions = (rawArgs) => { @@ -41,17 +42,76 @@ let parseArgumentsIntoOptions = (rawArgs) => { let promptForMissingOptions = async (options) => { const [defaultFolderName, defaultTemplate] = ['node-mongo-starter-kit', 'es6']; - const questions = []; + const folderQuestions = []; - if (!options.folderName) { - questions.push({ + let questionPush = (msgString, folder) => { + folderQuestions.push({ type: 'input', name: 'folderName', - message: 'Please enter folder name:', - default: defaultFolderName + message: msgString, + default: folder + }); + } + + if (!options.folderName) { + try { + fs.accessSync(`./${defaultFolderName}`, fs.constants.F_OK); //, () => { + console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); + questionPush( 'Enter different folder name:', null); + } catch (err) { + if (err) { + questionPush('Please enter folder name:', defaultFolderName); + } + } + } + + let folderNameAnswers = await inquirer.prompt(folderQuestions); + + try { + fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); + + const rootDir = process.cwd(); + //console.log(rootDir); + const rootDirContent = fs.readdirSync(rootDir, (err, files) => { + if (err) { + throw err; + } + + return files; }); + + //console.log(rootDirContent); + + let equalToAtLeastOneFolder; + + do { + equalToAtLeastOneFolder = rootDirContent.some(content => { + return content === folderNameAnswers.folderName; + }); + + console.log(equalToAtLeastOneFolder); + + if (equalToAtLeastOneFolder === true) { + console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); + folderQuestions.push({ + type: 'input', + name: 'folderName', + message: 'Enter different folder name:', + }); + folderNameAnswers = await inquirer.prompt(folderQuestions); + } + } while (equalToAtLeastOneFolder === true); + + } catch (err) { + if (err) { + //console.log('if (err) statement & the comment prevents: unhandledPromiseRejectionWarning in console'); + } } + console.log(folderNameAnswers); + + const templateQuestions = []; + const templateCollection = [defaultTemplate, 'cjs', 'ts-es6']; const equalToAtLeastOneTemplate = templateCollection.some(tc => { @@ -79,7 +139,7 @@ let promptForMissingOptions = async (options) => { } if (!options.template || notAmongTemplateCollection) { - questions.push({ + templateQuestions.push({ type: 'list', name: 'template', message: 'Please choose which project template to use', @@ -92,21 +152,22 @@ let promptForMissingOptions = async (options) => { console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); } - const answers = await inquirer.prompt(questions); + const templateAnswers = await inquirer.prompt(templateQuestions); + console.log(templateAnswers); if (notAmongTemplateCollection) { return { ...options, - folderName: options.folderName || answers.folderName, - template: answers.template, + folderName: options.folderName || folderNameAnswers.folderName, + template: templateAnswers.template, git: options.git || answers.git } } return { ...options, - folderName: options.folderName || answers.folderName, - template: options.template || answers.template, + folderName: options.folderName || folderNameAnswers.folderName, + template: options.template || templateAnswers.template, git: options.git || answers.git } } From 5b88501905f162191558b08e98eb2c0c2e786e23 Mon Sep 17 00:00:00 2001 From: ifycode Date: Thu, 13 May 2021 05:14:00 -0800 Subject: [PATCH 015/136] Fix folder overwrite when options.folder arg is present --- src/cli.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cli.js b/src/cli.js index 73eed8e..085ac50 100644 --- a/src/cli.js +++ b/src/cli.js @@ -65,6 +65,18 @@ let promptForMissingOptions = async (options) => { } } + if (options.folderName) { + try { + fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); //, () => { + console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); + questionPush( 'Enter different folder name:', null); + } catch (err) { + if (err) { + //console.log('if (err) statement & the comment prevents: unhandledPromiseRejectionWarning in console'); + } + } + } + let folderNameAnswers = await inquirer.prompt(folderQuestions); try { @@ -108,6 +120,10 @@ let promptForMissingOptions = async (options) => { } } + if (options.folderName) { + options.folderName = folderNameAnswers.folderName; + } + console.log(folderNameAnswers); const templateQuestions = []; From 02216e8780fb738086554581807fa28e039f14e5 Mon Sep 17 00:00:00 2001 From: ifycode Date: Thu, 13 May 2021 06:17:18 -0800 Subject: [PATCH 016/136] Fix skip git warning - remove unused/unneeded code --- src/cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 085ac50..a73d70f 100644 --- a/src/cli.js +++ b/src/cli.js @@ -176,7 +176,7 @@ let promptForMissingOptions = async (options) => { ...options, folderName: options.folderName || folderNameAnswers.folderName, template: templateAnswers.template, - git: options.git || answers.git + git: options.git } } @@ -184,7 +184,7 @@ let promptForMissingOptions = async (options) => { ...options, folderName: options.folderName || folderNameAnswers.folderName, template: options.template || templateAnswers.template, - git: options.git || answers.git + git: options.git } } From 090ae3e914ae0de1fa8a024097e5da42d42dfdf2 Mon Sep 17 00:00:00 2001 From: ifycode Date: Thu, 13 May 2021 20:35:50 -0800 Subject: [PATCH 017/136] Fix folder overwrite not previously existing folder when options.folder arg is present --- src/cli.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cli.js b/src/cli.js index a73d70f..a6213db 100644 --- a/src/cli.js +++ b/src/cli.js @@ -53,6 +53,8 @@ let promptForMissingOptions = async (options) => { }); } + let folderNameAnswers; + if (!options.folderName) { try { fs.accessSync(`./${defaultFolderName}`, fs.constants.F_OK); //, () => { @@ -63,6 +65,7 @@ let promptForMissingOptions = async (options) => { questionPush('Please enter folder name:', defaultFolderName); } } + folderNameAnswers = await inquirer.prompt(folderQuestions); } if (options.folderName) { @@ -70,15 +73,15 @@ let promptForMissingOptions = async (options) => { fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); //, () => { console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); questionPush( 'Enter different folder name:', null); + folderNameAnswers = await inquirer.prompt(folderQuestions); } catch (err) { if (err) { - //console.log('if (err) statement & the comment prevents: unhandledPromiseRejectionWarning in console'); - } + folderNameAnswers = {}; + folderNameAnswers.folderName = options.folderName; + } } } - let folderNameAnswers = await inquirer.prompt(folderQuestions); - try { fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); @@ -120,6 +123,7 @@ let promptForMissingOptions = async (options) => { } } + //Note: This affects only the try block (when options.folderName arg is present) if (options.folderName) { options.folderName = folderNameAnswers.folderName; } From 26b19fe39bed9559bc3161bb0200b65f91b1cd24 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 14 May 2021 02:59:35 +0100 Subject: [PATCH 018/136] Add task label, remove assignee --- .github/ISSUE_TEMPLATE/create-a-task.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/create-a-task.md b/.github/ISSUE_TEMPLATE/create-a-task.md index 84a655c..e4d90ec 100644 --- a/.github/ISSUE_TEMPLATE/create-a-task.md +++ b/.github/ISSUE_TEMPLATE/create-a-task.md @@ -2,8 +2,7 @@ name: Create a task about: Pattern to follow while creating a task to be solved title: '' -labels: repo setup -assignees: Ifycode +labels: task --- From a16a12e27c9e17521cbb9d73866a7513f9736cfe Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 14 May 2021 03:01:42 +0100 Subject: [PATCH 019/136] Add bug label --- .github/ISSUE_TEMPLATE/report-a-bug.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/report-a-bug.md b/.github/ISSUE_TEMPLATE/report-a-bug.md index f77378f..de41e30 100644 --- a/.github/ISSUE_TEMPLATE/report-a-bug.md +++ b/.github/ISSUE_TEMPLATE/report-a-bug.md @@ -2,7 +2,7 @@ name: Report a bug about: Found a bug? Create a report to help us improve title: '' -labels: '' +labels: 'bug' assignees: '' --- From 17c9e223ded6c400cf70311942198bbf53e8aed0 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 14 May 2021 03:02:44 +0100 Subject: [PATCH 020/136] Add empty assignee column as before --- .github/ISSUE_TEMPLATE/create-a-task.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/create-a-task.md b/.github/ISSUE_TEMPLATE/create-a-task.md index e4d90ec..42a20d9 100644 --- a/.github/ISSUE_TEMPLATE/create-a-task.md +++ b/.github/ISSUE_TEMPLATE/create-a-task.md @@ -3,6 +3,7 @@ name: Create a task about: Pattern to follow while creating a task to be solved title: '' labels: task +assignees: '' --- From 1977972845dab89fb0a049e7e1adc6e20f9a670f Mon Sep 17 00:00:00 2001 From: ifycode Date: Fri, 14 May 2021 02:23:12 -0800 Subject: [PATCH 021/136] Change es6 to esm --- README.md | 4 ++-- src/cli.js | 4 ++-- templates/es6/src/es6.js | 1 - templates/{es6 => esm}/package.json | 2 +- templates/esm/src/esm.js | 1 + templates/{ts-es6 => ts-esm}/package.json | 0 templates/{ts-es6/src/ts-es6.js => ts-esm/src/ts-esm.js} | 0 7 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 templates/es6/src/es6.js rename templates/{es6 => esm}/package.json (91%) create mode 100644 templates/esm/src/esm.js rename templates/{ts-es6 => ts-esm}/package.json (100%) rename templates/{ts-es6/src/ts-es6.js => ts-esm/src/ts-esm.js} (100%) diff --git a/README.md b/README.md index f6929d6..402885e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) ![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg) ![GitHub issues](https://img.shields.io/github/issues/code-collabo/node-mongo-cli?color=red) ![GitHub pull requests](https://img.shields.io/github/issues-pr/code-collabo/node-mongo-cli?color=goldenrod) -`node-mongo-cli` is a command-line interface tool useful to initialize, scaffold and make mongoDB development easier in nodejs environment. With the CLI, you can install any of the starter kit templates - [es6](https://github.com/code-collabo/node-mongo-starter-kit) and [cjs](https://github.com/code-collabo/node-mongo-starter-cjs). It not only helps install the starter-kit, but also allows you to add new model and controller files with content using simple commands. +`node-mongo-cli` is a command-line interface tool useful to initialize, scaffold and make mongoDB development easier in nodejs environment. With the CLI, you can install any of the starter kit templates - [esm](https://github.com/code-collabo/node-mongo-starter-kit) and [cjs](https://github.com/code-collabo/node-mongo-starter-cjs). It not only helps install the starter-kit, but also allows you to add new model and controller files with content using simple commands. The [cli](https://github.com/code-collabo/node-mongo-cli) is built to help provide better experience when using the starter-kit in MongoDB, MERN or MEAN projects. @@ -22,7 +22,7 @@ You can [use these resources](https://code-collabo.gitbook.io/docs/contributor-g ## Contributors ✨ -[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ +[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ ## Technologies diff --git a/src/cli.js b/src/cli.js index a6213db..3429847 100644 --- a/src/cli.js +++ b/src/cli.js @@ -40,7 +40,7 @@ let parseArgumentsIntoOptions = (rawArgs) => { } let promptForMissingOptions = async (options) => { - const [defaultFolderName, defaultTemplate] = ['node-mongo-starter-kit', 'es6']; + const [defaultFolderName, defaultTemplate] = ['node-mongo-starter-kit', 'esm']; const folderQuestions = []; @@ -132,7 +132,7 @@ let promptForMissingOptions = async (options) => { const templateQuestions = []; - const templateCollection = [defaultTemplate, 'cjs', 'ts-es6']; + const templateCollection = [defaultTemplate, 'cjs', 'ts-esm']; const equalToAtLeastOneTemplate = templateCollection.some(tc => { return tc === options.template diff --git a/templates/es6/src/es6.js b/templates/es6/src/es6.js deleted file mode 100644 index 09abc6e..0000000 --- a/templates/es6/src/es6.js +++ /dev/null @@ -1 +0,0 @@ -//I'm a ES6 file. diff --git a/templates/es6/package.json b/templates/esm/package.json similarity index 91% rename from templates/es6/package.json rename to templates/esm/package.json index 3c86dce..e42fc35 100644 --- a/templates/es6/package.json +++ b/templates/esm/package.json @@ -1,5 +1,5 @@ { - "name": "es6-template", + "name": "esm-template", "version": "1.0.0", "description": "", "main": "src/index.js", diff --git a/templates/esm/src/esm.js b/templates/esm/src/esm.js new file mode 100644 index 0000000..501eed0 --- /dev/null +++ b/templates/esm/src/esm.js @@ -0,0 +1 @@ +//I'm a esm file. diff --git a/templates/ts-es6/package.json b/templates/ts-esm/package.json similarity index 100% rename from templates/ts-es6/package.json rename to templates/ts-esm/package.json diff --git a/templates/ts-es6/src/ts-es6.js b/templates/ts-esm/src/ts-esm.js similarity index 100% rename from templates/ts-es6/src/ts-es6.js rename to templates/ts-esm/src/ts-esm.js From d804222738a20b105e68ca458c0de09b1d950fe5 Mon Sep 17 00:00:00 2001 From: ifycode Date: Fri, 14 May 2021 02:40:16 -0800 Subject: [PATCH 022/136] Clean up comments & unneeded console.logs --- src/cli.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/cli.js b/src/cli.js index 3429847..7348c0d 100644 --- a/src/cli.js +++ b/src/cli.js @@ -86,7 +86,6 @@ let promptForMissingOptions = async (options) => { fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); const rootDir = process.cwd(); - //console.log(rootDir); const rootDirContent = fs.readdirSync(rootDir, (err, files) => { if (err) { throw err; @@ -95,8 +94,6 @@ let promptForMissingOptions = async (options) => { return files; }); - //console.log(rootDirContent); - let equalToAtLeastOneFolder; do { @@ -104,8 +101,6 @@ let promptForMissingOptions = async (options) => { return content === folderNameAnswers.folderName; }); - console.log(equalToAtLeastOneFolder); - if (equalToAtLeastOneFolder === true) { console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); folderQuestions.push({ @@ -119,7 +114,7 @@ let promptForMissingOptions = async (options) => { } catch (err) { if (err) { - //console.log('if (err) statement & the comment prevents: unhandledPromiseRejectionWarning in console'); + //Dummy comment to prevent: unhandledPromiseRejectionWarning in console } } @@ -128,8 +123,6 @@ let promptForMissingOptions = async (options) => { options.folderName = folderNameAnswers.folderName; } - console.log(folderNameAnswers); - const templateQuestions = []; const templateCollection = [defaultTemplate, 'cjs', 'ts-esm']; @@ -173,7 +166,6 @@ let promptForMissingOptions = async (options) => { } const templateAnswers = await inquirer.prompt(templateQuestions); - console.log(templateAnswers); if (notAmongTemplateCollection) { return { From 87796715220934f3e773442ddfee315bbae47d13 Mon Sep 17 00:00:00 2001 From: ifycode Date: Fri, 14 May 2021 18:46:38 -0800 Subject: [PATCH 023/136] Clean up comments --- src/cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 7348c0d..92853bd 100644 --- a/src/cli.js +++ b/src/cli.js @@ -57,7 +57,7 @@ let promptForMissingOptions = async (options) => { if (!options.folderName) { try { - fs.accessSync(`./${defaultFolderName}`, fs.constants.F_OK); //, () => { + fs.accessSync(`./${defaultFolderName}`, fs.constants.F_OK); console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); questionPush( 'Enter different folder name:', null); } catch (err) { @@ -70,7 +70,7 @@ let promptForMissingOptions = async (options) => { if (options.folderName) { try { - fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); //, () => { + fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); questionPush( 'Enter different folder name:', null); folderNameAnswers = await inquirer.prompt(folderQuestions); From e8dba6a75abedcf5a382a9100a06cc3450f2fec5 Mon Sep 17 00:00:00 2001 From: ifycode Date: Sat, 15 May 2021 02:48:06 -0800 Subject: [PATCH 024/136] Temporary fix for install bug/issue --- bin/customize-preinstall | 4 ---- package.json | 1 - 2 files changed, 5 deletions(-) delete mode 100644 bin/customize-preinstall diff --git a/bin/customize-preinstall b/bin/customize-preinstall deleted file mode 100644 index dbc05a9..0000000 --- a/bin/customize-preinstall +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env node - -require = require('esm')(module /*, options */); -require('../src/customize/customize').customize(); diff --git a/package.json b/package.json index 0a7f9c3..2c22ec9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "access": "public" }, "scripts": { - "preinstall": "node bin/customize-preinstall", "prestart": "node -r esm src/customize/startMessage.js", "start": "npm-run-all --parallel lint:watch", "lint": "esw src --color", From addb072c37315ecc08715d5fc7683baca77db1f5 Mon Sep 17 00:00:00 2001 From: ifycode Date: Sat, 15 May 2021 06:40:26 -0800 Subject: [PATCH 025/136] Detect, change & increment defaultFolderName if already in use --- src/cli.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/cli.js b/src/cli.js index 92853bd..9c2723f 100644 --- a/src/cli.js +++ b/src/cli.js @@ -40,7 +40,7 @@ let parseArgumentsIntoOptions = (rawArgs) => { } let promptForMissingOptions = async (options) => { - const [defaultFolderName, defaultTemplate] = ['node-mongo-starter-kit', 'esm']; + let [defaultFolderName, defaultTemplate] = ['node-mongo-kit', 'esm']; const folderQuestions = []; @@ -53,18 +53,26 @@ let promptForMissingOptions = async (options) => { }); } + const rootDir = process.cwd(); + const rootDirContent = fs.readdirSync(rootDir, (err, files) => { + if (err) { + throw err; + } + + return files; + }); + + let matchDefaultValue = rootDirContent.filter(content => { + return content.match(defaultFolderName); + }); + let folderNameAnswers; if (!options.folderName) { - try { - fs.accessSync(`./${defaultFolderName}`, fs.constants.F_OK); - console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); - questionPush( 'Enter different folder name:', null); - } catch (err) { - if (err) { - questionPush('Please enter folder name:', defaultFolderName); - } + if (matchDefaultValue.length >= 1) { + defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; } + questionPush('Please enter folder name:', defaultFolderName); folderNameAnswers = await inquirer.prompt(folderQuestions); } @@ -85,15 +93,6 @@ let promptForMissingOptions = async (options) => { try { fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); - const rootDir = process.cwd(); - const rootDirContent = fs.readdirSync(rootDir, (err, files) => { - if (err) { - throw err; - } - - return files; - }); - let equalToAtLeastOneFolder; do { From 82854887b8f636b7045712f47564585223842754 Mon Sep 17 00:00:00 2001 From: ifycode Date: Sun, 16 May 2021 00:08:19 -0800 Subject: [PATCH 026/136] Prepare repo for adding node-mongo-cli contributors --- .all-contributorsrc | 11 +++++------ README.md | 5 +---- contributor.md | 1 + 3 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 contributor.md diff --git a/.all-contributorsrc b/.all-contributorsrc index 4aaa7eb..9e34256 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,8 +1,9 @@ { "files": [ - "README.md" + "README.md", + "contributor.md" ], - "imageSize": 100, + "imageSize": 90, "commit": false, "contributors": [ { @@ -12,11 +13,9 @@ "profile": "https://github.com/Ifycode", "contributions": [ "code", - "doc", - "infra", "maintenance", "review", - "projectManagement", + "bug", "ideas" ] }, @@ -39,7 +38,7 @@ ] } ], - "contributorsPerLine": 7, + "contributorsPerLine": 3, "projectName": "node-mongo-cli", "projectOwner": "code-collabo", "repoType": "github", diff --git a/README.md b/README.md index 402885e..ec9f808 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ # node-mongo-cli - -[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) - ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) ![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg) ![GitHub issues](https://img.shields.io/github/issues/code-collabo/node-mongo-cli?color=red) ![GitHub pull requests](https://img.shields.io/github/issues-pr/code-collabo/node-mongo-cli?color=goldenrod) @@ -22,7 +19,7 @@ You can [use these resources](https://code-collabo.gitbook.io/docs/contributor-g ## Contributors ✨ -[Thanks to these wonderful people](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) helping to improve some or all aspects of the [Code Collabo project](https://github.com/code-collabo)_**.**_ +[Thanks to these wonderful people](https://github.com/code-collabo/node-mongo-cli/contributor.md) helping to improve the [node-mongo-cli project](https://github.com/code-collabo/node-mongo-cli), and [all contributors](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) to the [Code Collabo community project](https://github.com/code-collabo)_**.**_ ## Technologies diff --git a/contributor.md b/contributor.md new file mode 100644 index 0000000..2e38422 --- /dev/null +++ b/contributor.md @@ -0,0 +1 @@ +Add node-mongo-cli contributors here From df7fb877ceea0c49d88d3aa680a5d69023a953f1 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:29:39 -0800 Subject: [PATCH 027/136] Update .all-contributorsrc --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9e34256..c5fdd96 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -29,7 +29,7 @@ ] }, { - "login": "jiobiagba", + "login": "jiobiagba", "name": "Joseph Obiagba", "avatar_url": "https://avatars.githubusercontent.com/u/42423547?v=4", "profile": "https://github.com/jiobiagba", From bd25cbcf54c3ad4bca0d1df54979038f5012f143 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:30:08 -0800 Subject: [PATCH 028/136] Update .all-contributorsrc --- .all-contributorsrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index c5fdd96..8115b2f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,6 @@ { "files": [ - "README.md", - "contributor.md" + "contributor.md" ], "imageSize": 90, "commit": false, From b625d89084eabec372d57ad71ca1b46c8ddbf59a Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:31:34 -0800 Subject: [PATCH 029/136] Update .all-contributorsrc --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8115b2f..c544f5b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,6 +1,6 @@ { "files": [ - "contributor.md" + "contributor.md" ], "imageSize": 90, "commit": false, From 0f7a91626f80cf0d4ce45794160d52ccbfbf99f5 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:46:07 -0800 Subject: [PATCH 030/136] Remove bug --- .all-contributorsrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index c544f5b..7e0829b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -13,8 +13,7 @@ "contributions": [ "code", "maintenance", - "review", - "bug", + "review" "ideas" ] }, From e583c36dde5209ac0b0102190d7665194e14d9e2 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:48:11 -0800 Subject: [PATCH 031/136] Remove Obiagba Mary --- contributor.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/contributor.md b/contributor.md index 2e38422..de15ab5 100644 --- a/contributor.md +++ b/contributor.md @@ -1 +1,19 @@ -Add node-mongo-cli contributors here + +[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) + + +## Contributors ✨ +Thanks to these wonderful people helping to improve the ***node-mongo-cli*** project [= (emoji key) =>](https://allcontributors.org/docs/en/emoji-key) + + + + + + + + +

Israel Obiagba

🧑‍🏫

Joseph Obiagba

🧑‍🏫
+ + + + From a65d107c995433b7e5e8c119150bf6fc4fc9b032 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 16:50:38 -0800 Subject: [PATCH 032/136] Remove Obiagba Mary --- .all-contributorsrc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 7e0829b..b757d98 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2,21 +2,9 @@ "files": [ "contributor.md" ], - "imageSize": 90, + "imageSize": 100, "commit": false, "contributors": [ - { - "login": "Ifycode", - "name": "Obiagba Mary Ifeoma", - "avatar_url": "https://avatars.githubusercontent.com/u/45185388?v=4", - "profile": "https://github.com/Ifycode", - "contributions": [ - "code", - "maintenance", - "review" - "ideas" - ] - }, { "login": "IsraelObiagba", "name": "Israel Obiagba", From 5dd6ac17ce331527437efa1a6a5906ed91bea03c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 00:54:56 +0000 Subject: [PATCH 033/136] docs: update contributor.md [skip ci] --- contributor.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contributor.md b/contributor.md index de15ab5..d573ba3 100644 --- a/contributor.md +++ b/contributor.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) ## Contributors ✨ @@ -11,9 +11,12 @@ Thanks to these wonderful people helping to improve the ***node-mongo-cli*** pro
Israel Obiagba

🧑‍🏫
Joseph Obiagba

🧑‍🏫 +
Obiagba Mary Ifeoma

💻 🚧 🤔 + + From 3246fdf517af519871d3daa4e2f7cfed056d7c3c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 00:54:57 +0000 Subject: [PATCH 034/136] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b757d98..0234f53 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -22,6 +22,17 @@ "contributions": [ "mentoring" ] + }, + { + "login": "Ifycode", + "name": "Obiagba Mary Ifeoma", + "avatar_url": "https://avatars.githubusercontent.com/u/45185388?v=4", + "profile": "https://github.com/Ifycode", + "contributions": [ + "code", + "maintenance", + "ideas" + ] } ], "contributorsPerLine": 3, From 3962893b9d0e39c2fab9ea6e4ba95e252ec23593 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 17:03:10 -0800 Subject: [PATCH 035/136] Add and set contributorsSortAlphabetically to true --- .all-contributorsrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b757d98..9e10265 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -4,6 +4,7 @@ ], "imageSize": 100, "commit": false, + "contributorsSortAlphabetically": true, "contributors": [ { "login": "IsraelObiagba", From be73727bcac562624e0735c2204c2db4d2c1f85e Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 17:04:48 -0800 Subject: [PATCH 036/136] Set contributors per line to 4 for now --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9e10265..855ed84 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -25,7 +25,7 @@ ] } ], - "contributorsPerLine": 3, + "contributorsPerLine": 4, "projectName": "node-mongo-cli", "projectOwner": "code-collabo", "repoType": "github", From ee90cb8558ec9e4f0932b47fd789bb7447868804 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 01:13:21 +0000 Subject: [PATCH 037/136] docs: update contributor.md [skip ci] --- contributor.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contributor.md b/contributor.md index d573ba3..1ffa15c 100644 --- a/contributor.md +++ b/contributor.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-) ## Contributors ✨ @@ -9,6 +9,7 @@ Thanks to these wonderful people helping to improve the ***node-mongo-cli*** pro + From fbd8cfbbbc8110531f3867d40a3313c9667936b6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 01:13:22 +0000 Subject: [PATCH 038/136] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b73f764..976fd91 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -34,6 +34,15 @@ "maintenance", "ideas" ] + }, + { + "login": "chuddyjoachim", + "name": "Chikezie Joachim", + "avatar_url": "https://avatars.githubusercontent.com/u/56943504?v=4", + "profile": "https://github.com/chuddyjoachim", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 4, From 1b03bf70a1150abdab524b43d2210a38346a5dea Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 17:20:17 -0800 Subject: [PATCH 039/136] Update number of contributors --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ec9f808..c79b66a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # node-mongo-cli + +[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-) + + ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat) ![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg) ![GitHub issues](https://img.shields.io/github/issues/code-collabo/node-mongo-cli?color=red) ![GitHub pull requests](https://img.shields.io/github/issues-pr/code-collabo/node-mongo-cli?color=goldenrod) `node-mongo-cli` is a command-line interface tool useful to initialize, scaffold and make mongoDB development easier in nodejs environment. With the CLI, you can install any of the starter kit templates - [esm](https://github.com/code-collabo/node-mongo-starter-kit) and [cjs](https://github.com/code-collabo/node-mongo-starter-cjs). It not only helps install the starter-kit, but also allows you to add new model and controller files with content using simple commands. From fb96bee58557bfe0f0d75428fcc85c141b9eb27e Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Sat, 15 May 2021 17:27:33 -0800 Subject: [PATCH 040/136] Link to cli contributors - develop branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c79b66a..ced3fb3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ You can [use these resources](https://code-collabo.gitbook.io/docs/contributor-g ## Contributors ✨ -[Thanks to these wonderful people](https://github.com/code-collabo/node-mongo-cli/contributor.md) helping to improve the [node-mongo-cli project](https://github.com/code-collabo/node-mongo-cli), and [all contributors](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) to the [Code Collabo community project](https://github.com/code-collabo)_**.**_ +[Thanks to these wonderful people](https://github.com/code-collabo/node-mongo-cli/blob/develop/contributor.md) helping to improve the [node-mongo-cli project](https://github.com/code-collabo/node-mongo-cli), and [all contributors](https://code-collabo.gitbook.io/docs/meet-our-awesome-contributors/all-contributors) to the [Code Collabo community project](https://github.com/code-collabo)_**.**_ ## Technologies From 9ea8d68772c7e5e37402ee44b65bf6dd1c821e9f Mon Sep 17 00:00:00 2001 From: ifycode Date: Sun, 16 May 2021 03:41:21 -0800 Subject: [PATCH 041/136] Fix wrong prompt when folderName arg is not present --- src/cli.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index 9c2723f..dd2ab3a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -107,7 +107,11 @@ let promptForMissingOptions = async (options) => { name: 'folderName', message: 'Enter different folder name:', }); - folderNameAnswers = await inquirer.prompt(folderQuestions); + if (options.folderName) { + folderNameAnswers = await inquirer.prompt(folderQuestions); + } else { + folderNameAnswers = await inquirer.prompt([folderQuestions[1]]); + } } } while (equalToAtLeastOneFolder === true); From 77015b7b862eda9bde0781dbafe74e48a75afb16 Mon Sep 17 00:00:00 2001 From: ifycode Date: Sun, 16 May 2021 06:31:13 -0800 Subject: [PATCH 042/136] Make comments used as guide more explanatory --- src/cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index dd2ab3a..ede051e 100644 --- a/src/cli.js +++ b/src/cli.js @@ -117,11 +117,11 @@ let promptForMissingOptions = async (options) => { } catch (err) { if (err) { - //Dummy comment to prevent: unhandledPromiseRejectionWarning in console + //Dummy if statement to prevent: unhandledPromiseRejectionWarning in console } } - //Note: This affects only the try block (when options.folderName arg is present) + //Note: This affects only the try block of the previous if (options.folderName) statement if (options.folderName) { options.folderName = folderNameAnswers.folderName; } From 520c80327df4efb9a3f8c83b24331b2a9485dbc9 Mon Sep 17 00:00:00 2001 From: ifycode Date: Sun, 16 May 2021 08:21:01 -0800 Subject: [PATCH 043/136] Fix empty folder prompt bug --- src/cli.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli.js b/src/cli.js index ede051e..e4d29d7 100644 --- a/src/cli.js +++ b/src/cli.js @@ -62,6 +62,8 @@ let promptForMissingOptions = async (options) => { return files; }); + rootDirContent.push(''); + let matchDefaultValue = rootDirContent.filter(content => { return content.match(defaultFolderName); }); @@ -101,7 +103,11 @@ let promptForMissingOptions = async (options) => { }); if (equalToAtLeastOneFolder === true) { - console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); + if (folderNameAnswers.folderName !== '') { + console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); + } else { + console.log( chalk.cyanBright(`Folder name cannot be empty`) ); + } folderQuestions.push({ type: 'input', name: 'folderName', From c5607ade15f351c28ba27384a81aeba69af678b9 Mon Sep 17 00:00:00 2001 From: joachim chikezie <56943504+chuddyjoachim@users.noreply.github.com> Date: Mon, 17 May 2021 15:27:39 -0700 Subject: [PATCH 044/136] Made 'quote_type' rule applicable to both .js and .ts files --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 1c8f4c8..a77cada 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true -[*.ts] +[.{js,ts}] quote_type = single [*.md] From 3173c813edef9a4e5a639c422101922867bddf4f Mon Sep 17 00:00:00 2001 From: Ifycode Date: Wed, 8 Sep 2021 10:08:42 +0100 Subject: [PATCH 045/136] npm link (original) --- bin/create-node-mongo-project | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/create-node-mongo-project diff --git a/bin/create-node-mongo-project b/bin/create-node-mongo-project old mode 100644 new mode 100755 From 88b2867ce0b82b1b508c704ee363c5e8250953f0 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 13 Sep 2021 01:43:57 +0100 Subject: [PATCH 046/136] Add OS check for templateDirectory's new url --- src/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 4926320..803bda7 100644 --- a/src/main.js +++ b/src/main.js @@ -45,12 +45,12 @@ export let createProject = async (options) => { const currentFileUrl = import.meta.url; - const templateDir = path.resolve( - new URL(currentFileUrl).pathname.substring(new URL(currentFileUrl).pathname.indexOf('/') + 1), - '../../templates', - options.template.toLowerCase() - ); + let newUrl; + if (process.platform === 'darwin') newUrl = new URL(currentFileUrl).pathname; + else newUrl = new URL(currentFileUrl).pathname.substring(new URL(currentFileUrl).pathname.indexOf('/') + 1); + const templateDir = path.resolve(newUrl, '../../templates', options.template.toLowerCase()); + options.templateDirectory = templateDir; try { From cd87f88d7e010a7ed7e3dc518898174d45445666 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 13 Sep 2021 06:10:58 +0100 Subject: [PATCH 047/136] Separate folder Prompt function and move to another file --- src/cli.js | 102 +++--------------------------------------- src/prompts/folder.js | 98 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 95 deletions(-) create mode 100644 src/prompts/folder.js diff --git a/src/cli.js b/src/cli.js index e4d29d7..0ba5383 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,8 +1,8 @@ import arg from 'arg'; import inquirer from 'inquirer'; -import { createProject } from './main'; import chalk from 'chalk'; -import fs from 'fs'; +import { folderNamePrompt } from './prompts/folder'; +import { createProject } from './main'; let parseArgumentsIntoOptions = (rawArgs) => { @@ -39,98 +39,8 @@ let parseArgumentsIntoOptions = (rawArgs) => { } } -let promptForMissingOptions = async (options) => { - let [defaultFolderName, defaultTemplate] = ['node-mongo-kit', 'esm']; - - const folderQuestions = []; - - let questionPush = (msgString, folder) => { - folderQuestions.push({ - type: 'input', - name: 'folderName', - message: msgString, - default: folder - }); - } - - const rootDir = process.cwd(); - const rootDirContent = fs.readdirSync(rootDir, (err, files) => { - if (err) { - throw err; - } - - return files; - }); - - rootDirContent.push(''); - - let matchDefaultValue = rootDirContent.filter(content => { - return content.match(defaultFolderName); - }); - - let folderNameAnswers; - - if (!options.folderName) { - if (matchDefaultValue.length >= 1) { - defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; - } - questionPush('Please enter folder name:', defaultFolderName); - folderNameAnswers = await inquirer.prompt(folderQuestions); - } - - if (options.folderName) { - try { - fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); - console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); - questionPush( 'Enter different folder name:', null); - folderNameAnswers = await inquirer.prompt(folderQuestions); - } catch (err) { - if (err) { - folderNameAnswers = {}; - folderNameAnswers.folderName = options.folderName; - } - } - } - - try { - fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); - - let equalToAtLeastOneFolder; - - do { - equalToAtLeastOneFolder = rootDirContent.some(content => { - return content === folderNameAnswers.folderName; - }); - - if (equalToAtLeastOneFolder === true) { - if (folderNameAnswers.folderName !== '') { - console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); - } else { - console.log( chalk.cyanBright(`Folder name cannot be empty`) ); - } - folderQuestions.push({ - type: 'input', - name: 'folderName', - message: 'Enter different folder name:', - }); - if (options.folderName) { - folderNameAnswers = await inquirer.prompt(folderQuestions); - } else { - folderNameAnswers = await inquirer.prompt([folderQuestions[1]]); - } - } - } while (equalToAtLeastOneFolder === true); - - } catch (err) { - if (err) { - //Dummy if statement to prevent: unhandledPromiseRejectionWarning in console - } - } - - //Note: This affects only the try block of the previous if (options.folderName) statement - if (options.folderName) { - options.folderName = folderNameAnswers.folderName; - } +let promptForMissingOptions = async (options, folderNameAnswers) => { + let defaultTemplate = 'esm'; const templateQuestions = []; @@ -204,7 +114,9 @@ export let cli = async (args) => { options.git = false; } - options = await promptForMissingOptions(options); + let [updatedOptions, folderNameAnswers] = await folderNamePrompt(options); + + options = await promptForMissingOptions(updatedOptions, folderNameAnswers); //console.log(options); diff --git a/src/prompts/folder.js b/src/prompts/folder.js new file mode 100644 index 0000000..b9242aa --- /dev/null +++ b/src/prompts/folder.js @@ -0,0 +1,98 @@ +import inquirer from 'inquirer'; +import chalk from 'chalk'; +import fs from 'fs'; + +export const folderNamePrompt = async (options) => { + let defaultFolderName = 'node-mongo-kit'; + const folderQuestions = []; + + let questionPush = (msgString, folder) => { + folderQuestions.push({ + type: 'input', + name: 'folderName', + message: msgString, + default: folder + }); + } + + const rootDir = process.cwd(); + const rootDirContent = fs.readdirSync(rootDir, (err, files) => { + if (err) { + throw err; + } + + return files; + }); + + rootDirContent.push(''); + + let matchDefaultValue = rootDirContent.filter(content => { + return content.match(defaultFolderName); + }); + + let folderNameAnswers; + + if (!options.folderName) { + if (matchDefaultValue.length >= 1) { + defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; + } + questionPush('Please enter folder name:', defaultFolderName); + folderNameAnswers = await inquirer.prompt(folderQuestions); + } + + if (options.folderName) { + try { + fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); + console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); + questionPush( 'Enter different folder name:', null); + folderNameAnswers = await inquirer.prompt(folderQuestions); + } catch (err) { + if (err) { + folderNameAnswers = {}; + folderNameAnswers.folderName = options.folderName; + } + } + } + + try { + fs.accessSync(`./${folderNameAnswers.folderName}`, fs.constants.F_OK); + + let equalToAtLeastOneFolder; + + do { + equalToAtLeastOneFolder = rootDirContent.some(content => { + return content === folderNameAnswers.folderName; + }); + + if (equalToAtLeastOneFolder === true) { + if (folderNameAnswers.folderName !== '') { + console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); + } else { + console.log( chalk.cyanBright(`Folder name cannot be empty`) ); + } + folderQuestions.push({ + type: 'input', + name: 'folderName', + message: 'Enter different folder name:', + }); + if (options.folderName) { + folderNameAnswers = await inquirer.prompt(folderQuestions); + } else { + folderNameAnswers = await inquirer.prompt([folderQuestions[1]]); + } + } + } while (equalToAtLeastOneFolder === true); + + } catch (err) { + if (err) { + //Dummy if statement to prevent: unhandledPromiseRejectionWarning in console + } + } + + //Note: This affects only the try block of the previous if (options.folderName) statement + if (options.folderName) { + options.folderName = folderNameAnswers.folderName; + } + + return [options, folderNameAnswers]; +} \ No newline at end of file From e09528fb58a705bd82cc2c0a471955c33f013ae2 Mon Sep 17 00:00:00 2001 From: Chikezie Joachim <56943504+chuddyjoachim@users.noreply.github.com> Date: Mon, 13 Sep 2021 03:37:39 -0700 Subject: [PATCH 048/136] ran audit fix --- package-lock.json | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6573f54..98f7fdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1727,16 +1727,16 @@ } }, "browserslist": { - "version": "4.16.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.3.tgz", - "integrity": "sha512-vIyhWmIkULaq04Gt93txdh+j02yX/JzlyhLYbV3YQCn/zvES3JnY7TifHHvvr1w5hTDluNKMkV05cs4vy8Q7sw==", + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.0.tgz", + "integrity": "sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001181", - "colorette": "^1.2.1", - "electron-to-chromium": "^1.3.649", + "caniuse-lite": "^1.0.30001254", + "colorette": "^1.3.0", + "electron-to-chromium": "^1.3.830", "escalade": "^3.1.1", - "node-releases": "^1.1.70" + "node-releases": "^1.1.75" } }, "buffer-from": { @@ -1811,9 +1811,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001202", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001202.tgz", - "integrity": "sha512-ZcijQNqrcF8JNLjzvEiXqX4JUYxoZa7Pvcsd9UD8Kz4TvhTonOSNRsK+qtvpVL4l6+T1Rh4LFtLfnNWg6BGWCQ==", + "version": "1.0.30001257", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001257.tgz", + "integrity": "sha512-JN49KplOgHSXpIsVSF+LUyhD8PUp6xPpAXeRrrcBh4KBeP7W864jHn6RvzJgDlrReyeVjMFJL3PLpPvKIxlIHA==", "dev": true }, "chalk": { @@ -2060,9 +2060,9 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "colorette": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz", - "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.4.0.tgz", + "integrity": "sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==", "dev": true }, "commander": { @@ -2315,9 +2315,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.691", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.691.tgz", - "integrity": "sha512-ZqiO69KImmOGCyoH0icQPU3SndJiW93juEvf63gQngyhODO6SpQIPMTOHldtCs5DS5GMKvAkquk230E2zt2vpw==", + "version": "1.3.836", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.836.tgz", + "integrity": "sha512-Ney3pHOJBWkG/AqYjrW0hr2AUCsao+2uvq9HUlRP8OlpSdk/zOHOUJP7eu0icDvePC9DlgffuelP4TnOJmMRUg==", "dev": true }, "elegant-spinner": { @@ -3304,9 +3304,9 @@ } }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==" + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" }, "http-cache-semantics": { "version": "4.1.0", @@ -4346,9 +4346,9 @@ "dev": true }, "node-releases": { - "version": "1.1.71", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.71.tgz", - "integrity": "sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==", + "version": "1.1.75", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz", + "integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==", "dev": true }, "nodemon": { @@ -4428,9 +4428,9 @@ "dev": true }, "normalize-url": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", - "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", "dev": true }, "npm-run-all": { @@ -4800,9 +4800,9 @@ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "path-type": { "version": "3.0.0", From 7b01276f4865ed920b4e4eea710f460aba14b716 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 01:22:54 +0100 Subject: [PATCH 049/136] Prepare options.skipPrompts for template function separation --- src/cli.js | 10 ++++++---- src/prompts/folder.js | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/cli.js b/src/cli.js index 0ba5383..6614b9b 100644 --- a/src/cli.js +++ b/src/cli.js @@ -39,7 +39,7 @@ let parseArgumentsIntoOptions = (rawArgs) => { } } -let promptForMissingOptions = async (options, folderNameAnswers) => { +let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderName) => { let defaultTemplate = 'esm'; const templateQuestions = []; @@ -54,17 +54,19 @@ let promptForMissingOptions = async (options, folderNameAnswers) => { if (notAmongTemplateCollection && options.skipPrompts && options.template !== undefined) { console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); + options.template = defaultTemplate; } if (notAmongTemplateCollection && options.skipPrompts && options.template === undefined) { console.log( chalk.cyanBright(`No template specified, the default template: "${defaultTemplate}" will be used instead.`) ); + options.template = defaultTemplate; } if (options.skipPrompts) { return { ...options, folderName: options.folderName || defaultFolderName, - template: defaultTemplate, + template: options.template, runInstall: false, git: false } @@ -114,9 +116,9 @@ export let cli = async (args) => { options.git = false; } - let [updatedOptions, folderNameAnswers] = await folderNamePrompt(options); + let [updatedOptions, folderNameAnswers, defaultFolderName] = await folderNamePrompt(options); - options = await promptForMissingOptions(updatedOptions, folderNameAnswers); + options = await promptForMissingOptions(updatedOptions, folderNameAnswers, defaultFolderName); //console.log(options); diff --git a/src/prompts/folder.js b/src/prompts/folder.js index b9242aa..bfefb96 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -14,7 +14,7 @@ export const folderNamePrompt = async (options) => { default: folder }); } - + const rootDir = process.cwd(); const rootDirContent = fs.readdirSync(rootDir, (err, files) => { if (err) { @@ -31,11 +31,17 @@ export const folderNamePrompt = async (options) => { }); let folderNameAnswers; + + let incrementFolderName = () => { + if (matchDefaultValue.length >= 1) { + defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; + } + } + + if (!options.folderName && options.skipPrompts) incrementFolderName(); - if (!options.folderName) { - if (matchDefaultValue.length >= 1) { - defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; - } + if (!options.folderName && !options.skipPrompts) { + incrementFolderName(); questionPush('Please enter folder name:', defaultFolderName); folderNameAnswers = await inquirer.prompt(folderQuestions); } @@ -94,5 +100,5 @@ export const folderNamePrompt = async (options) => { options.folderName = folderNameAnswers.folderName; } - return [options, folderNameAnswers]; + return [options, folderNameAnswers, defaultFolderName]; } \ No newline at end of file From 28549cd5b3d97da64a21ee6801f93dca01b89878 Mon Sep 17 00:00:00 2001 From: Chikezie Joachim <56943504+chuddyjoachim@users.noreply.github.com> Date: Tue, 14 Sep 2021 11:41:46 +0100 Subject: [PATCH 050/136] rename name in package.json same as project's name --- src/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 803bda7..9cede77 100644 --- a/src/main.js +++ b/src/main.js @@ -54,7 +54,13 @@ export let createProject = async (options) => { options.templateDirectory = templateDir; try { - await access(templateDir, fs.constants.R_OK); + await access(templateDir, fs.constants.R_OK).then(_ => { + /* rename name option in package.json same as project/folder name */ + execa('npx', ['npe','name',options.folderName], { + cwd: options.targetDirectory + }).stdout.pipe(process.stdout); + }) + }catch (err) { console.error(`\n%s "${options.template}" is (probably) an invalid template name i.e. not among template name stored in the templateCollection variable/array.`, chalk.red.bold('ERROR')); process.exit(1); From 6c7d2dc9213dff6df5a7f7b9817f418ddf2ca919 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 14:18:48 +0100 Subject: [PATCH 051/136] separate skipPrompts from template --- src/cli.js | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/cli.js b/src/cli.js index 6614b9b..b024759 100644 --- a/src/cli.js +++ b/src/cli.js @@ -39,39 +39,41 @@ let parseArgumentsIntoOptions = (rawArgs) => { } } +let skipPrompts = (options, defaultFolderName, notAmongTemplateCollection, defaultTemplate) => { + if (notAmongTemplateCollection && options.template !== undefined) { + console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); + options.template = defaultTemplate; + } + + if (notAmongTemplateCollection && options.template === undefined) { + console.log( chalk.cyanBright(`No template specified, the default template: "${defaultTemplate}" will be used instead.`) ); + options.template = defaultTemplate; + } + + options = { + ...options, + folderName: options.folderName || defaultFolderName, + template: options.template, + runInstall: false, + git: false + } + + return options; +} + let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderName) => { - let defaultTemplate = 'esm'; + const defaultTemplate = 'esm'; const templateQuestions = []; const templateCollection = [defaultTemplate, 'cjs', 'ts-esm']; const equalToAtLeastOneTemplate = templateCollection.some(tc => { - return tc === options.template + return tc === options.template; }); const notAmongTemplateCollection = equalToAtLeastOneTemplate === false; - if (notAmongTemplateCollection && options.skipPrompts && options.template !== undefined) { - console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); - options.template = defaultTemplate; - } - - if (notAmongTemplateCollection && options.skipPrompts && options.template === undefined) { - console.log( chalk.cyanBright(`No template specified, the default template: "${defaultTemplate}" will be used instead.`) ); - options.template = defaultTemplate; - } - - if (options.skipPrompts) { - return { - ...options, - folderName: options.folderName || defaultFolderName, - template: options.template, - runInstall: false, - git: false - } - } - if (!options.template || notAmongTemplateCollection) { templateQuestions.push({ type: 'list', @@ -82,6 +84,10 @@ let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderNa }); } + if (options.skipPrompts) { + options = skipPrompts(options, defaultFolderName, notAmongTemplateCollection, defaultTemplate); + } + if (notAmongTemplateCollection && options.template !== undefined) { console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); } @@ -120,7 +126,7 @@ export let cli = async (args) => { options = await promptForMissingOptions(updatedOptions, folderNameAnswers, defaultFolderName); - //console.log(options); + console.log(options); try { await createProject(options); From d84be606f4c218af2a32c9617971c50aae1eefd8 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 15:51:45 +0100 Subject: [PATCH 052/136] Remove template prompt and folder prompt when --yes flag is specified --- src/cli.js | 16 +++++++++++----- src/main.js | 2 +- src/prompts/folder.js | 8 ++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/cli.js b/src/cli.js index b024759..fa5cafd 100644 --- a/src/cli.js +++ b/src/cli.js @@ -46,7 +46,7 @@ let skipPrompts = (options, defaultFolderName, notAmongTemplateCollection, defau } if (notAmongTemplateCollection && options.template === undefined) { - console.log( chalk.cyanBright(`No template specified, the default template: "${defaultTemplate}" will be used instead.`) ); + console.log( chalk.cyanBright(`--yes or -y flag detected. Generate "${defaultTemplate}" template since no template is specified.`) ); options.template = defaultTemplate; } @@ -84,18 +84,22 @@ let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderNa }); } + let templateAnswers; + if (options.skipPrompts) { options = skipPrompts(options, defaultFolderName, notAmongTemplateCollection, defaultTemplate); + templateQuestions.template = defaultTemplate; + templateAnswers = templateQuestions; } - if (notAmongTemplateCollection && options.template !== undefined) { + if (notAmongTemplateCollection && options.template !== undefined && !options.skipPrompts) { console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); } - const templateAnswers = await inquirer.prompt(templateQuestions); + if (!options.skipPrompts) templateAnswers = await inquirer.prompt(templateQuestions); if (notAmongTemplateCollection) { - return { + options = { ...options, folderName: options.folderName || folderNameAnswers.folderName, template: templateAnswers.template, @@ -103,12 +107,14 @@ let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderNa } } - return { + options = { ...options, folderName: options.folderName || folderNameAnswers.folderName, template: options.template || templateAnswers.template, git: options.git } + + return options; } export let cli = async (args) => { diff --git a/src/main.js b/src/main.js index 803bda7..cc9c219 100644 --- a/src/main.js +++ b/src/main.js @@ -81,6 +81,6 @@ export let createProject = async (options) => { await tasks.run(); - console.log(`%s Project bootstrapped into the folder you specified => ${options.folderName} <=`, chalk.green.bold('DONE')); + console.log(`%s Project bootstrapped into the generated folder => ${options.folderName} <=`, chalk.green.bold('DONE')); return true; } diff --git a/src/prompts/folder.js b/src/prompts/folder.js index bfefb96..9f6f2ed 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -46,7 +46,7 @@ export const folderNamePrompt = async (options) => { folderNameAnswers = await inquirer.prompt(folderQuestions); } - if (options.folderName) { + if (options.folderName && !options.skipPrompts) { try { fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); @@ -96,9 +96,13 @@ export const folderNamePrompt = async (options) => { } //Note: This affects only the try block of the previous if (options.folderName) statement - if (options.folderName) { + if (options.folderName && !options.skipPrompts) { options.folderName = folderNameAnswers.folderName; } + + if (options.folderName && options.skipPrompts) { + options.folderName = incrementFolderName(); + } return [options, folderNameAnswers, defaultFolderName]; } \ No newline at end of file From e59fadd5eecd144a55536069b4c94dafa59c3269 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 18:29:04 +0100 Subject: [PATCH 053/136] Work in progress --- src/prompts/folder.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/prompts/folder.js b/src/prompts/folder.js index 9f6f2ed..54d75d8 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -101,7 +101,31 @@ export const folderNamePrompt = async (options) => { } if (options.folderName && options.skipPrompts) { + + let matchFolderNameArg = rootDirContent.filter(content => { + return content.match(options.folderName); + }); + + console.log(matchFolderNameArg) + + if (matchFolderNameArg) { + console.log(matchFolderNameArg) + options.folderName = incrementFolderName(); + } + + /*if (matchFolderNameArg) { + console.log(matchDefaultValue) + options.folderName = incrementFolderName(); + }*/ + + //console.log(matchFolderNameArg); + /*if (matchDefaultValue) { + console.log(matchDefaultValue) + }*/ + /*if (matchDefaultValue) { options.folderName = incrementFolderName(); + }*/ + //options.folderName = incrementFolderName(); } return [options, folderNameAnswers, defaultFolderName]; From f0512f85756bf44eab4ab4884fe8c9e9fe746065 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 20:15:17 +0100 Subject: [PATCH 054/136] Remove prompt and increment default folder name when --yes flag is specified and folder already exists --- src/prompts/folder.js | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/prompts/folder.js b/src/prompts/folder.js index 54d75d8..8ef1fa2 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -95,37 +95,19 @@ export const folderNamePrompt = async (options) => { } } - //Note: This affects only the try block of the previous if (options.folderName) statement + //Note: This affects only the try block of the previous if (options.folderName && !options.skipPrompts) statement if (options.folderName && !options.skipPrompts) { options.folderName = folderNameAnswers.folderName; } - + if (options.folderName && options.skipPrompts) { - - let matchFolderNameArg = rootDirContent.filter(content => { - return content.match(options.folderName); + let matchFolderNameArg = rootDirContent.some(content => { + return content === options.folderName; }); - console.log(matchFolderNameArg) - if (matchFolderNameArg) { - console.log(matchFolderNameArg) options.folderName = incrementFolderName(); } - - /*if (matchFolderNameArg) { - console.log(matchDefaultValue) - options.folderName = incrementFolderName(); - }*/ - - //console.log(matchFolderNameArg); - /*if (matchDefaultValue) { - console.log(matchDefaultValue) - }*/ - /*if (matchDefaultValue) { - options.folderName = incrementFolderName(); - }*/ - //options.folderName = incrementFolderName(); } return [options, folderNameAnswers, defaultFolderName]; From a1cf8cb2186b7da821a21b0c7e8cdcea90221309 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 20:50:45 +0100 Subject: [PATCH 055/136] Change function names to better represent it's purpose --- src/cli.js | 10 +++++----- src/prompts/folder.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli.js b/src/cli.js index fa5cafd..7178c79 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,7 +1,7 @@ import arg from 'arg'; import inquirer from 'inquirer'; import chalk from 'chalk'; -import { folderNamePrompt } from './prompts/folder'; +import { folderNameMissingOptionPrompt } from './prompts/folder'; import { createProject } from './main'; let parseArgumentsIntoOptions = (rawArgs) => { @@ -61,7 +61,7 @@ let skipPrompts = (options, defaultFolderName, notAmongTemplateCollection, defau return options; } -let promptForMissingOptions = async (options, folderNameAnswers, defaultFolderName) => { +let templateMissingOptionPrompt = async (options, folderNameAnswers, defaultFolderName) => { const defaultTemplate = 'esm'; const templateQuestions = []; @@ -128,11 +128,11 @@ export let cli = async (args) => { options.git = false; } - let [updatedOptions, folderNameAnswers, defaultFolderName] = await folderNamePrompt(options); + let [updatedOptions, folderNameAnswers, defaultFolderName] = await folderNameMissingOptionPrompt(options); - options = await promptForMissingOptions(updatedOptions, folderNameAnswers, defaultFolderName); + options = await templateMissingOptionPrompt(updatedOptions, folderNameAnswers, defaultFolderName); - console.log(options); + //console.log(options); try { await createProject(options); diff --git a/src/prompts/folder.js b/src/prompts/folder.js index 8ef1fa2..219c002 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -2,7 +2,7 @@ import inquirer from 'inquirer'; import chalk from 'chalk'; import fs from 'fs'; -export const folderNamePrompt = async (options) => { +export const folderNameMissingOptionPrompt = async (options) => { let defaultFolderName = 'node-mongo-kit'; const folderQuestions = []; From adaedb4d8929fd3a7aae8c07e871b64e56e6f7ce Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 14 Sep 2021 21:49:34 +0100 Subject: [PATCH 056/136] Move template missing option prompt to it's own file --- src/cli.js | 81 +---------------------------------------- src/prompts/template.js | 78 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 80 deletions(-) create mode 100644 src/prompts/template.js diff --git a/src/cli.js b/src/cli.js index 7178c79..45fd8ce 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,7 +1,6 @@ import arg from 'arg'; -import inquirer from 'inquirer'; -import chalk from 'chalk'; import { folderNameMissingOptionPrompt } from './prompts/folder'; +import { templateMissingOptionPrompt } from './prompts/template'; import { createProject } from './main'; let parseArgumentsIntoOptions = (rawArgs) => { @@ -39,84 +38,6 @@ let parseArgumentsIntoOptions = (rawArgs) => { } } -let skipPrompts = (options, defaultFolderName, notAmongTemplateCollection, defaultTemplate) => { - if (notAmongTemplateCollection && options.template !== undefined) { - console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); - options.template = defaultTemplate; - } - - if (notAmongTemplateCollection && options.template === undefined) { - console.log( chalk.cyanBright(`--yes or -y flag detected. Generate "${defaultTemplate}" template since no template is specified.`) ); - options.template = defaultTemplate; - } - - options = { - ...options, - folderName: options.folderName || defaultFolderName, - template: options.template, - runInstall: false, - git: false - } - - return options; -} - -let templateMissingOptionPrompt = async (options, folderNameAnswers, defaultFolderName) => { - const defaultTemplate = 'esm'; - - const templateQuestions = []; - - const templateCollection = [defaultTemplate, 'cjs', 'ts-esm']; - - const equalToAtLeastOneTemplate = templateCollection.some(tc => { - return tc === options.template; - }); - - const notAmongTemplateCollection = equalToAtLeastOneTemplate === false; - - if (!options.template || notAmongTemplateCollection) { - templateQuestions.push({ - type: 'list', - name: 'template', - message: 'Please choose which project template to use', - choices: templateCollection, - default: defaultTemplate - }); - } - - let templateAnswers; - - if (options.skipPrompts) { - options = skipPrompts(options, defaultFolderName, notAmongTemplateCollection, defaultTemplate); - templateQuestions.template = defaultTemplate; - templateAnswers = templateQuestions; - } - - if (notAmongTemplateCollection && options.template !== undefined && !options.skipPrompts) { - console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); - } - - if (!options.skipPrompts) templateAnswers = await inquirer.prompt(templateQuestions); - - if (notAmongTemplateCollection) { - options = { - ...options, - folderName: options.folderName || folderNameAnswers.folderName, - template: templateAnswers.template, - git: options.git - } - } - - options = { - ...options, - folderName: options.folderName || folderNameAnswers.folderName, - template: options.template || templateAnswers.template, - git: options.git - } - - return options; -} - export let cli = async (args) => { let options = parseArgumentsIntoOptions(args); diff --git a/src/prompts/template.js b/src/prompts/template.js new file mode 100644 index 0000000..67c65a9 --- /dev/null +++ b/src/prompts/template.js @@ -0,0 +1,78 @@ +import inquirer from 'inquirer'; +import chalk from 'chalk'; + +let skipPromptsModified = (options, defaultFolderName, notAmongTemplateCollection, defaultTemplate) => { + if (notAmongTemplateCollection && options.template !== undefined) { + console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); + options.template = defaultTemplate; + } + + if (notAmongTemplateCollection && options.template === undefined) { + console.log( chalk.cyanBright(`--yes or -y flag detected. Generate "${defaultTemplate}" template since no template is specified.`) ); + options.template = defaultTemplate; + } + + options = { + ...options, + folderName: options.folderName || defaultFolderName, + template: options.template, + runInstall: false, + git: false + } + + return options; +} + +export const templateMissingOptionPrompt = async (options, folderNameAnswers, defaultFolderName) => { + const defaultTemplate = 'esm'; + const templateQuestions = []; + const templateCollection = [defaultTemplate, 'cjs', 'ts-esm']; + + const equalToAtLeastOneTemplate = templateCollection.some(tc => { + return tc === options.template; + }); + + const notAmongTemplateCollection = equalToAtLeastOneTemplate === false; + + if (!options.template || notAmongTemplateCollection) { + templateQuestions.push({ + type: 'list', + name: 'template', + message: 'Please choose which project template to use', + choices: templateCollection, + default: defaultTemplate + }); + } + + let templateAnswers; + + if (options.skipPrompts) { + options = skipPromptsModified(options, defaultFolderName, notAmongTemplateCollection, defaultTemplate); + templateQuestions.template = defaultTemplate; + templateAnswers = templateQuestions; + } + + if (notAmongTemplateCollection && options.template !== undefined && !options.skipPrompts) { + console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); + } + + if (!options.skipPrompts) templateAnswers = await inquirer.prompt(templateQuestions); + + if (notAmongTemplateCollection) { + options = { + ...options, + folderName: options.folderName || folderNameAnswers.folderName, + template: templateAnswers.template, + git: options.git + } + } + + options = { + ...options, + folderName: options.folderName || folderNameAnswers.folderName, + template: options.template || templateAnswers.template, + git: options.git + } + + return options; +} \ No newline at end of file From 28f7ba8baab0284fc5f6488cc2af1b6ac327cde2 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Wed, 15 Sep 2021 01:58:19 +0100 Subject: [PATCH 057/136] Remove unnecessary console logs in preparation for --help flag, and clean up code --- src/prompts/folder.js | 6 +++--- src/prompts/template.js | 13 +------------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/prompts/folder.js b/src/prompts/folder.js index 219c002..eda4840 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -49,7 +49,7 @@ export const folderNameMissingOptionPrompt = async (options) => { if (options.folderName && !options.skipPrompts) { try { fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); - console.log( chalk.cyanBright(`Folder name: ${options.folderName} already exists, enter a different folder name instead`) ); + console.log( chalk.cyanBright(`Folder name ${options.folderName} already exists`) ); questionPush( 'Enter different folder name:', null); folderNameAnswers = await inquirer.prompt(folderQuestions); } catch (err) { @@ -72,7 +72,7 @@ export const folderNameMissingOptionPrompt = async (options) => { if (equalToAtLeastOneFolder === true) { if (folderNameAnswers.folderName !== '') { - console.log( chalk.cyanBright(`Folder name: "${folderNameAnswers.folderName}" already exists, enter a different folder name instead`) ); + console.log( chalk.cyanBright(`Folder name "${folderNameAnswers.folderName}" already exists`) ); } else { console.log( chalk.cyanBright(`Folder name cannot be empty`) ); } @@ -98,7 +98,7 @@ export const folderNameMissingOptionPrompt = async (options) => { //Note: This affects only the try block of the previous if (options.folderName && !options.skipPrompts) statement if (options.folderName && !options.skipPrompts) { options.folderName = folderNameAnswers.folderName; - } + } //------------------------------------------------ if (options.folderName && options.skipPrompts) { let matchFolderNameArg = rootDirContent.some(content => { diff --git a/src/prompts/template.js b/src/prompts/template.js index 67c65a9..e08f13a 100644 --- a/src/prompts/template.js +++ b/src/prompts/template.js @@ -1,14 +1,7 @@ import inquirer from 'inquirer'; -import chalk from 'chalk'; let skipPromptsModified = (options, defaultFolderName, notAmongTemplateCollection, defaultTemplate) => { - if (notAmongTemplateCollection && options.template !== undefined) { - console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection, the default template: "${defaultTemplate}" will be used instead.`) ); - options.template = defaultTemplate; - } - - if (notAmongTemplateCollection && options.template === undefined) { - console.log( chalk.cyanBright(`--yes or -y flag detected. Generate "${defaultTemplate}" template since no template is specified.`) ); + if (notAmongTemplateCollection && (options.template !== undefined || options.template === undefined)) { options.template = defaultTemplate; } @@ -50,10 +43,6 @@ export const templateMissingOptionPrompt = async (options, folderNameAnswers, de options = skipPromptsModified(options, defaultFolderName, notAmongTemplateCollection, defaultTemplate); templateQuestions.template = defaultTemplate; templateAnswers = templateQuestions; - } - - if (notAmongTemplateCollection && options.template !== undefined && !options.skipPrompts) { - console.log( chalk.cyanBright(`Cli does not have template: "${options.template}" in its template collection`) ); } if (!options.skipPrompts) templateAnswers = await inquirer.prompt(templateQuestions); From b492a704c30db21fa4aa8e16bf9933fba6112641 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 17 Sep 2021 01:49:27 +0100 Subject: [PATCH 058/136] Update LICENSE --- LICENSE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LICENSE b/LICENSE index bff42ba..dfe8b63 100644 --- a/LICENSE +++ b/LICENSE @@ -18,3 +18,6 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +This project was of help in the project's initial setup: +* [@dkundel/create-project](https://github.com/dkundel/create-project) From f87e6abb93fdcf4f6ac119dec1c9c938f86e9949 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 17 Sep 2021 01:56:42 +0100 Subject: [PATCH 059/136] Fix since markup not working --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index dfe8b63..43c8b50 100644 --- a/LICENSE +++ b/LICENSE @@ -20,4 +20,4 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. This project was of help in the project's initial setup: -* [@dkundel/create-project](https://github.com/dkundel/create-project) +@dkundel/create-project - https://github.com/dkundel/create-project From 2f067e82838cee938b1c8a0fb7a508d1b03213d1 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 17 Sep 2021 01:59:32 +0100 Subject: [PATCH 060/136] mention project name --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 43c8b50..1a6cf0b 100644 --- a/LICENSE +++ b/LICENSE @@ -19,5 +19,5 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -This project was of help in the project's initial setup: -@dkundel/create-project - https://github.com/dkundel/create-project +This project was of help in the node-mongo CLI project's +initial setup: @dkundel/create-project - https://github.com/dkundel/create-project From 424c4f438a95f0b790386e0df272176ce78d07b3 Mon Sep 17 00:00:00 2001 From: Obiagba Mary Ifeoma Date: Fri, 17 Sep 2021 02:28:27 +0100 Subject: [PATCH 061/136] Add YouTube resource --- LICENSE | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 1a6cf0b..d34739b 100644 --- a/LICENSE +++ b/LICENSE @@ -20,4 +20,6 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. This project was of help in the node-mongo CLI project's -initial setup: @dkundel/create-project - https://github.com/dkundel/create-project +initial setup: +YouTube resource - https://youtu.be/s2h28p4s-Xs +@dkundel/create-project - https://github.com/dkundel/create-project From 7d185b4276d7ead4633e2b02075f08dede8114f3 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Sat, 18 Sep 2021 03:46:53 +0100 Subject: [PATCH 062/136] Fix folder name increment: Prevent prompt anytime folder name matches default folder name --- src/prompts/folder.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/prompts/folder.js b/src/prompts/folder.js index eda4840..14dbe7f 100644 --- a/src/prompts/folder.js +++ b/src/prompts/folder.js @@ -32,10 +32,18 @@ export const folderNameMissingOptionPrompt = async (options) => { let folderNameAnswers; + let extractedNumbers = matchDefaultValue.map((value) => { + let valueMatch = value.match(/(\d+)/); + if (valueMatch !== null) return value.match(/(\d+)/).map(Number)[0]; + }).filter(value => { return value !== undefined; }); + + let maxNumber = Math.max(...extractedNumbers); + let incrementFolderName = () => { - if (matchDefaultValue.length >= 1) { - defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; - } + if (matchDefaultValue.length >= 1) { + if (maxNumber === -Infinity) defaultFolderName = `${defaultFolderName}-${matchDefaultValue.length}`; + else defaultFolderName = `${defaultFolderName}-${maxNumber + 1}`; + } } if (!options.folderName && options.skipPrompts) incrementFolderName(); From 5f1de5a2c2c64e8c98de48643e7be80daac988a2 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Sun, 19 Sep 2021 00:35:48 +0100 Subject: [PATCH 063/136] Execfile work in progress: Make npm install more interactive --- .gitignore | 3 +++ src/main.js | 34 +++++++++++++++++++++------------- templates/esm/package.json | 12 +++++++++++- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index c7e9dcf..60bb18c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. +# testing and rough work +test.js + # dependencies /node_modules diff --git a/src/main.js b/src/main.js index cc9c219..d2d4b2f 100644 --- a/src/main.js +++ b/src/main.js @@ -5,10 +5,11 @@ import path from 'path'; import { promisify } from 'util'; import execa from 'execa'; import Listr from 'listr'; -import { projectInstall } from 'pkg-install'; +import { execFile } from 'child_process'; const access = promisify(fs.access); const copy = promisify(ncp); +const execute = promisify(execFile); let copyTemplateFiles = async (options) => { return copy(options.templateDirectory, options.targetDirectory, { @@ -30,6 +31,19 @@ export async function initGit(options) { return; } +let npmInstall = async (options) => { + if (options.runInstall) { + await execute('npm', ['install'], (error, stdout, stderr) => { + if (error) { + throw error; + } + console.log(`\n${stderr}\n${stdout}`); + }); + } + + return; +} + export let createProject = async (options) => { options = { ...options, @@ -60,27 +74,21 @@ export let createProject = async (options) => { process.exit(1); } - const tasks = new Listr([ + const listrTasks = new Listr([ { - title: 'copy project files', + title: `Project bootstrapped into the generated folder ${chalk.green(`=> ${options.folderName}`)}`, task: () => copyTemplateFiles(options) }, { - title: 'Initialize git', + title: 'Git init', task: () => initGit(options), skip: () => !options.git ? 'Automatically initialize git by doing nothing. Alternatively, pass --git or -g' : undefined - }, - { - title: 'Install dependencies', - task: () => projectInstall({ - cwd: options.targetDirectory - }), - skip: () => !options.runInstall ? 'Automatically install dependencies by doing nothing. Alternatively, pass --install or -i' : undefined } ]); - await tasks.run(); + await listrTasks.run(); + + npmInstall(options); - console.log(`%s Project bootstrapped into the generated folder => ${options.folderName} <=`, chalk.green.bold('DONE')); return true; } diff --git a/templates/esm/package.json b/templates/esm/package.json index e42fc35..cb71aa6 100644 --- a/templates/esm/package.json +++ b/templates/esm/package.json @@ -10,6 +10,16 @@ "author": "Brent Schooley", "license": "ISC", "dependencies": { - "esm": "^3.2.25" + "esm": "^3.2.25", + "arg": "^5.0.0", + "chalk": "^4.1.0", + "clear": "^0.1.0", + "execa": "^5.0.0", + "figlet": "^1.5.0", + "inquirer": "^8.0.0", + "listr": "^0.14.3", + "ncp": "^2.0.0", + "npm-run-all": "^4.1.5", + "pkg-install": "^1.0.0" } } From 2aca6ba8b755a4e77e4e1ae7f0eb63f64d2eb27d Mon Sep 17 00:00:00 2001 From: Ifycode Date: Sun, 19 Sep 2021 15:43:56 +0100 Subject: [PATCH 064/136] Add npm install progress in terminal using spawn child process --- src/main.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main.js b/src/main.js index d2d4b2f..68cdf11 100644 --- a/src/main.js +++ b/src/main.js @@ -5,11 +5,10 @@ import path from 'path'; import { promisify } from 'util'; import execa from 'execa'; import Listr from 'listr'; -import { execFile } from 'child_process'; +import { spawn } from 'child_process'; const access = promisify(fs.access); const copy = promisify(ncp); -const execute = promisify(execFile); let copyTemplateFiles = async (options) => { return copy(options.templateDirectory, options.targetDirectory, { @@ -31,13 +30,19 @@ export async function initGit(options) { return; } -let npmInstall = async (options) => { - if (options.runInstall) { - await execute('npm', ['install'], (error, stdout, stderr) => { - if (error) { - throw error; - } - console.log(`\n${stderr}\n${stdout}`); +let npmInstall = async (cliOptions) => { + if (cliOptions.runInstall) { //install only if runInstall returns true + const install = spawn('npm', ['install'], {cwd: cliOptions.targetDirectory, stdio: 'inherit'}); + + //console.log(install.stdout); + //console.log(install); + + install.stdout.on('data', (data) => { + console.log(`${data}`); + }); + + install.stderr.on('data', (data) => { + console.log(`${data}`); }); } @@ -88,7 +93,7 @@ export let createProject = async (options) => { await listrTasks.run(); - npmInstall(options); + await npmInstall(options); return true; } From 10a0aef85947e766295616e4ae40737e19ea1930 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Sun, 19 Sep 2021 17:46:16 +0100 Subject: [PATCH 065/136] Remove on listeners to fix null error for spawn's usage and add to listr task --- src/main.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index 68cdf11..2cba106 100644 --- a/src/main.js +++ b/src/main.js @@ -32,18 +32,7 @@ export async function initGit(options) { let npmInstall = async (cliOptions) => { if (cliOptions.runInstall) { //install only if runInstall returns true - const install = spawn('npm', ['install'], {cwd: cliOptions.targetDirectory, stdio: 'inherit'}); - - //console.log(install.stdout); - //console.log(install); - - install.stdout.on('data', (data) => { - console.log(`${data}`); - }); - - install.stderr.on('data', (data) => { - console.log(`${data}`); - }); + spawn('npm', ['install'], {cwd: cliOptions.targetDirectory, stdio: 'inherit'}); } return; @@ -88,12 +77,17 @@ export let createProject = async (options) => { title: 'Git init', task: () => initGit(options), skip: () => !options.git ? 'Automatically initialize git by doing nothing. Alternatively, pass --git or -g' : undefined + }, + { + title: 'npm install', + task: () => npmInstall(options), + skip: () => !options.runInstall ? 'Automatically install dependencies by doing nothing. Alternatively, pass --install or -i' : undefined } ]); await listrTasks.run(); - await npmInstall(options); + //await npmInstall(options); return true; } From 6914a5ea41b8598f88358e41c7a37d69925e84b0 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Sun, 19 Sep 2021 19:26:20 +0100 Subject: [PATCH 066/136] Remove pkg-install --- package-lock.json | 114 ++-------------------------------------------- package.json | 3 +- 2 files changed, 6 insertions(+), 111 deletions(-) diff --git a/package-lock.json b/package-lock.json index 98f7fdd..4a48165 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1311,25 +1311,12 @@ "defer-to-connect": "^1.0.1" } }, - "@types/execa": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@types/execa/-/execa-0.9.0.tgz", - "integrity": "sha512-mgfd93RhzjYBUHHV532turHC2j4l/qxsF/PbfDmprHDEUHmNZGlDn1CEsulGK3AfsPdhkWzZQT/S/k0UGhLGsA==", - "requires": { - "@types/node": "*" - } - }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, - "@types/node": { - "version": "11.15.49", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.15.49.tgz", - "integrity": "sha512-ft3FD0S4sSu+nA//lFRPLPKqHa3qCIIOjHI3/e9H0o37pCtVNU9W7f9YRYjAiysDmHlLL+gBpNKV5BNahy1fqw==" - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2334,6 +2321,7 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, "requires": { "once": "^1.4.0" } @@ -4653,6 +4641,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -4690,11 +4679,6 @@ "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", "dev": true }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -4846,91 +4830,6 @@ "find-up": "^3.0.0" } }, - "pkg-install": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-install/-/pkg-install-1.0.0.tgz", - "integrity": "sha512-UGI8bfhrDb1KN01RZ7Bq08GRQc8rmVjxQ2up0g4mUHPCYDTK1FzQ0PMmLOBCHg3yaIijZ2U3Fn9ofLa4N392Ug==", - "requires": { - "@types/execa": "^0.9.0", - "@types/node": "^11.9.4", - "execa": "^1.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "requires": { - "pump": "^3.0.0" - } - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "requires": { - "path-key": "^2.0.0" - } - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - } - } - }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -4973,6 +4872,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -5754,11 +5654,6 @@ "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" - }, "strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", @@ -6290,7 +6185,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "write-file-atomic": { "version": "3.0.3", diff --git a/package.json b/package.json index 2c22ec9..af9b69d 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,7 @@ "inquirer": "^8.0.0", "listr": "^0.14.3", "ncp": "^2.0.0", - "npm-run-all": "^4.1.5", - "pkg-install": "^1.0.0" + "npm-run-all": "^4.1.5" }, "devDependencies": { "@babel/cli": "^7.13.10", From 7b8fb9c7a0a099e3189a49cc10158c27a66ecaf3 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 02:02:28 +0100 Subject: [PATCH 067/136] Change function names and to arrow function if needed --- src/cli.js | 4 ++-- src/main.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cli.js b/src/cli.js index 45fd8ce..e91896a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,7 +1,7 @@ import arg from 'arg'; import { folderNameMissingOptionPrompt } from './prompts/folder'; import { templateMissingOptionPrompt } from './prompts/template'; -import { createProject } from './main'; +import { downloadTemplateKit } from './main'; let parseArgumentsIntoOptions = (rawArgs) => { @@ -56,7 +56,7 @@ export let cli = async (args) => { //console.log(options); try { - await createProject(options); + await downloadTemplateKit(options); } catch (err) { console.log('Error | ', err); } diff --git a/src/main.js b/src/main.js index 97ca990..097b44f 100644 --- a/src/main.js +++ b/src/main.js @@ -10,13 +10,13 @@ import { spawn } from 'child_process'; const access = promisify(fs.access); const copy = promisify(ncp); -let copyTemplateFiles = async (options) => { +let copyTemplateFolderContent = async (options) => { return copy(options.templateDirectory, options.targetDirectory, { clobber: false }); } -export async function initGit(options) { +let gitInit = (options) => { if (options.git) { //git init only if git returns true const result = await execa('git', ['init'], { cwd: options.targetDirectory @@ -38,7 +38,7 @@ let npmInstall = async (cliOptions) => { return; } -export let createProject = async (options) => { +export let downloadTemplateKit = async (options) => { options = { ...options, targetDirectory: options.targetDirectory || process.cwd() //root/parent folder at this point @@ -77,11 +77,11 @@ export let createProject = async (options) => { const listrTasks = new Listr([ { title: `Project bootstrapped into the generated folder ${chalk.green(`=> ${options.folderName}`)}`, - task: () => copyTemplateFiles(options) + task: () => copyTemplateFolderContent(options) }, { title: 'Git init', - task: () => initGit(options), + task: () => gitInit(options), skip: () => !options.git ? 'Automatically initialize git by doing nothing. Alternatively, pass --git or -g' : undefined }, { From 59e603ccba183f02bfdb5f84516c68864b2da4e9 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 02:06:19 +0100 Subject: [PATCH 068/136] Change cliOptions to options in npmInstall function --- src/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 097b44f..095cdee 100644 --- a/src/main.js +++ b/src/main.js @@ -30,9 +30,9 @@ let gitInit = (options) => { return; } -let npmInstall = async (cliOptions) => { - if (cliOptions.runInstall) { //install only if runInstall returns true - spawn('npm', ['install'], {cwd: cliOptions.targetDirectory, stdio: 'inherit'}); +let npmInstall = async (options) => { + if (options.runInstall) { //install only if runInstall returns true + spawn('npm', ['install'], {cwd: options.targetDirectory, stdio: 'inherit'}); } return; From b72b98151b6684fcec46f9c2142e34c928d1fb89 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 02:12:11 +0100 Subject: [PATCH 069/136] Change folder.js to foldername.js --- src/cli.js | 2 +- src/prompts/{folder.js => foldername.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/prompts/{folder.js => foldername.js} (100%) diff --git a/src/cli.js b/src/cli.js index e91896a..2440800 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,5 +1,5 @@ import arg from 'arg'; -import { folderNameMissingOptionPrompt } from './prompts/folder'; +import { folderNameMissingOptionPrompt } from './prompts/foldername'; import { templateMissingOptionPrompt } from './prompts/template'; import { downloadTemplateKit } from './main'; diff --git a/src/prompts/folder.js b/src/prompts/foldername.js similarity index 100% rename from src/prompts/folder.js rename to src/prompts/foldername.js From 75dc748be94b22b8dd676bb5f742d065da2e98bc Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 02:30:59 +0100 Subject: [PATCH 070/136] Fix async omission error --- src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 095cdee..e28ab2d 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,7 @@ let copyTemplateFolderContent = async (options) => { }); } -let gitInit = (options) => { +let gitInit = async (options) => { if (options.git) { //git init only if git returns true const result = await execa('git', ['init'], { cwd: options.targetDirectory From 9a0835f984bc398e0b1c7971d46e17937dc4c8ee Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 03:25:54 +0100 Subject: [PATCH 071/136] Improve console and error msgs in main.js --- src/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index e28ab2d..a374968 100644 --- a/src/main.js +++ b/src/main.js @@ -70,24 +70,24 @@ export let downloadTemplateKit = async (options) => { }) }catch (err) { - console.error(`\n%s "${options.template}" is (probably) an invalid template name i.e. not among template name stored in the templateCollection variable/array.`, chalk.red.bold('ERROR')); + console.error(`\n%s Template name or directory path is (probably) incorrect`, chalk.red.bold('ERROR')); process.exit(1); } const listrTasks = new Listr([ { - title: `Project bootstrapped into the generated folder ${chalk.green(`=> ${options.folderName}`)}`, + title: `${chalk.green(`${options.template} template`)} copied into the generated folder ${chalk.green(`=> ${options.folderName}`)}`, task: () => copyTemplateFolderContent(options) }, { - title: 'Git init', + title: 'git init', task: () => gitInit(options), - skip: () => !options.git ? 'Automatically initialize git by doing nothing. Alternatively, pass --git or -g' : undefined + skip: () => !options.git ? 'Skipped because you specified either --skip-git or --yes flags' : undefined }, { title: 'npm install', task: () => npmInstall(options), - skip: () => !options.runInstall ? 'Automatically install dependencies by doing nothing. Alternatively, pass --install or -i' : undefined + skip: () => !options.runInstall ? 'Skipped because you specified either --skip-install or --yes flags' : undefined } ]); From 7d40e9128b7bb3de465e98306645123a4d00e719 Mon Sep 17 00:00:00 2001 From: Ifycode Date: Mon, 20 Sep 2021 04:44:29 +0100 Subject: [PATCH 072/136] Improve console msgs for template & folder name. Fix other minor issues --- src/prompts/foldername.js | 8 ++++---- src/prompts/template.js | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/prompts/foldername.js b/src/prompts/foldername.js index 14dbe7f..eb646c6 100644 --- a/src/prompts/foldername.js +++ b/src/prompts/foldername.js @@ -57,12 +57,12 @@ export const folderNameMissingOptionPrompt = async (options) => { if (options.folderName && !options.skipPrompts) { try { fs.accessSync(`./${options.folderName}`, fs.constants.F_OK); - console.log( chalk.cyanBright(`Folder name ${options.folderName} already exists`) ); + console.log( chalk.cyanBright(`Folder name ${chalk.green(`${options.folderName}`)} already exists`) ); questionPush( 'Enter different folder name:', null); folderNameAnswers = await inquirer.prompt(folderQuestions); } catch (err) { if (err) { - folderNameAnswers = {}; + folderNameAnswers = {folderName: ''}; folderNameAnswers.folderName = options.folderName; } } @@ -80,9 +80,9 @@ export const folderNameMissingOptionPrompt = async (options) => { if (equalToAtLeastOneFolder === true) { if (folderNameAnswers.folderName !== '') { - console.log( chalk.cyanBright(`Folder name "${folderNameAnswers.folderName}" already exists`) ); + console.log( `Folder name ${chalk.green(`${folderNameAnswers.folderName}`)} already exists` ); } else { - console.log( chalk.cyanBright(`Folder name cannot be empty`) ); + console.log( `${chalk.yellowBright(`Folder name cannot be empty`)}` ); } folderQuestions.push({ type: 'input', diff --git a/src/prompts/template.js b/src/prompts/template.js index e08f13a..208c6f5 100644 --- a/src/prompts/template.js +++ b/src/prompts/template.js @@ -1,4 +1,5 @@ import inquirer from 'inquirer'; +import chalk from 'chalk'; let skipPromptsModified = (options, defaultFolderName, notAmongTemplateCollection, defaultTemplate) => { if (notAmongTemplateCollection && (options.template !== undefined || options.template === undefined)) { @@ -27,11 +28,13 @@ export const templateMissingOptionPrompt = async (options, folderNameAnswers, de const notAmongTemplateCollection = equalToAtLeastOneTemplate === false; + if (notAmongTemplateCollection && options.template !== undefined) console.log(`${chalk.redBright(`${options.template}`)} is not in the node-mongo template collection`); + if (!options.template || notAmongTemplateCollection) { templateQuestions.push({ type: 'list', name: 'template', - message: 'Please choose which project template to use', + message: 'Please choose which node-mongo template kit to use', choices: templateCollection, default: defaultTemplate }); From 4716ead904b200819c39e79c3ab615d37c4363ef Mon Sep 17 00:00:00 2001 From: Ifycode Date: Tue, 21 Sep 2021 22:45:48 +0100 Subject: [PATCH 073/136] Configure help flag to work --- src/cli.js | 29 +++++++++++++++++++++++------ src/help.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 src/help.js diff --git a/src/cli.js b/src/cli.js index 2440800..6f3b112 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,15 +1,21 @@ import arg from 'arg'; +import { help } from './help'; import { folderNameMissingOptionPrompt } from './prompts/foldername'; import { templateMissingOptionPrompt } from './prompts/template'; import { downloadTemplateKit } from './main'; let parseArgumentsIntoOptions = (rawArgs) => { - //make -x the alias for --skip-git + //configure --skip-git flag let myHandler = (value, argName, previousValue) => { return previousValue || '--skip-git'; } + //configure --help flag + let helpHandler = (value, argName, previousValue) => { + return previousValue || '--help'; + } + const args = arg({ '--git': Boolean, '--skip-git': Boolean, @@ -21,7 +27,9 @@ let parseArgumentsIntoOptions = (rawArgs) => { '-x': '--skip-git', '-y': '--yes', '-i': '--install', - '-s': '--skip-install' + '-s': '--skip-install', + '--help': arg.flag(helpHandler), + '-h': '--help' }, { argv: rawArgs.slice(2) @@ -34,13 +42,12 @@ let parseArgumentsIntoOptions = (rawArgs) => { folderName: args._[0], template: args._[1], runInstall: args['--install'] || true, - skipInstall: args['--skip-install'] || false + skipInstall: args['--skip-install'] || false, + help: args['--help'] || false } } -export let cli = async (args) => { - let options = parseArgumentsIntoOptions(args); - +let otherOptions = async (options) => { if (options.skipInstall) { options.runInstall = false; } @@ -61,3 +68,13 @@ export let cli = async (args) => { console.log('Error | ', err); } } + +export let cli = async (args) => { + let options = parseArgumentsIntoOptions(args); + + if (options.help) { + help(); + } else { + await otherOptions(options); + } +} diff --git a/src/help.js b/src/help.js new file mode 100644 index 0000000..2427bba --- /dev/null +++ b/src/help.js @@ -0,0 +1,34 @@ + +export const help = () => { +console.log( +`Usage: +node-mongo

Chikezie Joachim

🐛

Israel Obiagba

🧑‍🏫

Joseph Obiagba

🧑‍🏫

Obiagba Mary Ifeoma

💻 🚧 🤔