Skip to content

Commit

Permalink
fix: jest config warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
lgandecki committed Feb 25, 2021
1 parent 72208c2 commit 9b1d095
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"graphql": "^15.5.0",
"graphql-tag": "^2.10.3",
"handlebars": "^4.0.12",
"listr2": "3.2.3",
"listr2": "3.3.3",
"ora": "^5.3.0",
"pascal-case": "^3.1.2",
"shelljs": "^0.8.4",
Expand Down
21 changes: 9 additions & 12 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ async function configureTsconfig(projectMainPath: string) {
await fs.promises.writeFile(tsconfigJsonPath, JSON.stringify(tsconfig, null, 2));
}

async function configureJest(projectMainPath: string) {
async function configureJest(projectMainPath: string, task: ListrTaskWrapper<ListrContext, ListrRendererFactory>) {
const jestConfigPath = path.join(projectMainPath, 'jest.config.js');

if (fs.existsSync(jestConfigPath)) {
console.warn(
`Sorry! We do not have the functionality yet to adjust your jest.config.js to work with chimp, please take a look at https://github.com/xolvio/chimp#updating-jestconfigjs-after-chimp-init to see how to do so manually`,
);
task.output =
"Sorry! We can't adjust existing jest.config.js automatically yet, please take a look at https://github.com/xolvio/chimp#updating-jestconfigjs-after-chimp-init to see how to do so manually";
} else {
await fs.promises.copyFile(path.join(__dirname, '../../scaffold/jest.config.js'), jestConfigPath);
await fs.promises.copyFile(
Expand Down Expand Up @@ -195,16 +194,14 @@ export default class Init extends Command {
assertModulePathInTopLevelSrc(projectMainPath, modulesPath);
const tasks = new Listr(
[
newTask('Creating example code', async (task: ListrTaskWrapper<ListrContext, ListrRendererFactory>) =>
createExampleCode(task, path.join(projectMainPath, modulesPath)),
),
newTask('Add project dependencies', async () => addProjectDependencies(projectMainPath, modulesPath)),
newTask('Configure tsconfig.json', async () => configureTsconfig(projectMainPath)),
newTask('Configure jest', async () => configureJest(projectMainPath)),
newTask('Add empty GraphQL context file', async () => addContext(projectMainPath)),
newTask('Creating example code', (task) => createExampleCode(task, path.join(projectMainPath, modulesPath))),
newTask('Add project dependencies', () => addProjectDependencies(projectMainPath, modulesPath)),
newTask('Configure tsconfig.json', () => configureTsconfig(projectMainPath)),
newTask('Configure jest', (task) => configureJest(projectMainPath, task)),
newTask('Add empty GraphQL context file', () => addContext(projectMainPath)),
// newTask('Install packages', async () => addContext(projectMainPath)),
],
{ renderer: ListrRenderer },
{ renderer: ListrRenderer, rendererOptions: { formatOutput: 'wrap' } },
);

// eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
Expand Down
3 changes: 3 additions & 0 deletions src/generate/helpers/ListrHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const newTask = (
debug('%O', error);
throw new Error(`${title}\n${error}\n`);
}),
options: {
persistentOutput: true,
},
});

// @ts-ignore
Expand Down
9 changes: 5 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3788,10 +3788,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

listr2@3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.2.3.tgz#ef9e0d790862f038dde8a9837be552b1adfd1c07"
integrity sha512-vUb80S2dSUi8YxXahO8/I/s29GqnOL8ozgHVLjfWQXa03BNEeS1TpBLjh2ruaqq5ufx46BRGvfymdBSuoXET5w==
listr2@3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.3.3.tgz#af44f6a4cb76d17d293aa5cb88ea84b67bc6144e"
integrity sha512-CeQrTeot/OQTrd2loXEBMfwlOjlPeHu/9alA8UyEoiEyncpj/mv2zRLgx32JzO62wbJIBSKgGM2L23XeOwrRlg==
dependencies:
chalk "^4.1.0"
cli-truncate "^2.1.0"
Expand All @@ -3801,6 +3801,7 @@ [email protected]:
p-map "^4.0.0"
rxjs "^6.6.3"
through "^2.3.8"
wrap-ansi "^7.0.0"

load-json-file@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 9b1d095

Please sign in to comment.