Fix starter command and add tests#135
Open
KarolNet wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restructures the CLI by extracting several inline yargs command handlers into dedicated command modules, fixes/adjusts the start workflow (project setup + optional content import), and adds Jest test coverage for the starter flow.
Changes:
- Refactors CLI command registration to use separate modules (
start,sdk,stats,excel,wordpress-import,contentful-import) plus shared prompt/helpers. - Updates starter project setup logic to use the Flotiq logger and adds tests for
projectSetupand thestartcommand. - Adds a
test:covscript and improves logging in the importer command.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/start/project-setup.test.js | Adds unit tests for setup/init/develop behaviors in projectSetup. |
| tests/commands/start-command.test.js | Adds CLI-level tests for start argument resolution, prompting, and --no-import. |
| src/start/projectSetup.js | Switches from console to logger and adjusts setup/init/develop + shell execution helper. |
| src/start/command.js | Introduces new start command module and argument/prompt handling. |
| src/command/command.js | Refactors main CLI entrypoint to register modular commands. |
| src/command/helpers.js | Adds shared helpers for env API key detection and prompting/validation. |
| src/sdk/command.js | Introduces new sdk install command module. |
| src/stats/command.js | Introduces new stats command module. |
| src/excel/command.js | Introduces excel import/export command modules using flotiq-excel-migrator. |
| src/wordpress-import/command.js | Introduces WordPress import command module. |
| src/contentful-import/command.js | Introduces Contentful import command module. |
| src/purifier/command.js | Renames exported command object and updates exports. |
| commands/importer.js | Improves error logging and exports a named importerCommand instead of default. |
| package.json | Adds test:cov script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
51
to
55
| fs.writeFile(projectDirectory + '/.env.development', fileContent, (err) => { | ||
| if (err) { | ||
| console.errorCode(100); | ||
| err.error(err); | ||
| throw err; | ||
| } |
Comment on lines
43
to
57
| } catch (e) { | ||
| let fileContent = 'GATSBY_FLOTIQ_API_KEY=' + apiKey + '\n'; | ||
| fs.writeFile(projectDirectory + '/.env', fileContent, (err) => { | ||
| if (err) { | ||
| console.errorCode(100); | ||
| logger.error(err); | ||
| throw err; | ||
| } | ||
| }); | ||
| fs.writeFile(projectDirectory + '/.env.development', fileContent, (err) => { | ||
| if (err) { | ||
| console.errorCode(100); | ||
| err.error(err); | ||
| throw err; | ||
| } | ||
| }); | ||
| } |
Comment on lines
29
to
31
| fs.writeFileSync(projectDirectory + '/.env.local', file); | ||
| console.log('Configuration is created successfully: ' + projectDirectory + '/.env'); | ||
| logger.info(`Configuration is created successfully: ${projectDirectory}/.env`); | ||
|
|
Comment on lines
84
to
90
| let commandProcess = exec(cmd, (error, stdout, stderr) => { | ||
| if (error) { | ||
| console.errorCode(200); | ||
| logger.error(error); | ||
| process.exit(1); | ||
| } | ||
| resolve(stdout || stderr); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.