Skip to content

Fix starter command and add tests#135

Open
KarolNet wants to merge 6 commits into
mainfrom
bugfix/27892-fix-starter-start-command
Open

Fix starter command and add tests#135
KarolNet wants to merge 6 commits into
mainfrom
bugfix/27892-fix-starter-start-command

Conversation

@KarolNet

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 projectSetup and the start command.
  • Adds a test:cov script 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 thread src/start/projectSetup.js Outdated
Comment on lines 51 to 55
fs.writeFile(projectDirectory + '/.env.development', fileContent, (err) => {
if (err) {
console.errorCode(100);
err.error(err);
throw err;
}
Comment thread src/start/projectSetup.js
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 thread src/start/projectSetup.js
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 thread src/start/projectSetup.js Outdated
Comment thread src/start/projectSetup.js
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);
});
Comment thread src/sdk/command.js Outdated
Comment thread src/excel/command.js Outdated
Comment thread src/excel/command.js Outdated
Comment thread src/command/helpers.js
Comment thread src/start/command.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants