Skip to content

Commit

Permalink
feat(packageJson): run 'poetry add'
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Feb 17, 2022
1 parent 7e4eaa8 commit 9b8d31d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/generators/packageJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ export async function generatePackageJson(
);
jsonObj.scripts.prettify += await generatePrettierSuffix(config.dirPath);

let dependencies = [] as string[];
let dependencies: string[] = [];
let devDependencies = ['lint-staged', 'prettier', 'sort-package-json', '@willbooster/prettier-config'];
const poetryDependencies: string[] = [];

if (config.root) {
// To install the latest pinst
Expand Down Expand Up @@ -186,7 +187,9 @@ export async function generatePackageJson(
}

if (config.containingPoetryLock) {
jsonObj.scripts.postinstall = 'poetry install';
if (jsonObj.scripts.postinstall === 'poetry install') {
delete jsonObj.scripts.postinstall;
}
const dirNames = fs.readdirSync(config.dirPath).filter((dirName) => {
const dirPath = path.resolve(config.dirPath, dirName);
if (!fs.lstatSync(dirPath).isDirectory()) return false;
Expand All @@ -199,6 +202,7 @@ export async function generatePackageJson(
jsonObj.scripts.lint = `poetry run flake8 ${dirNames.join(' ')}`;
jsonObj.scripts['lint-fix'] = 'yarn lint';
jsonObj.scripts.format += ` && yarn format-code`;
poetryDependencies.push('black', 'isort', 'flake8');
}
}
}
Expand Down Expand Up @@ -226,6 +230,9 @@ export async function generatePackageJson(
if (devDependencies.length) {
spawnSync('yarn', ['add', '-D', ...new Set(devDependencies)], config.dirPath);
}
if (poetryDependencies.length) {
spawnSync('poetry', ['add', ...new Set(poetryDependencies)], config.dirPath);
}
}
}

Expand Down

0 comments on commit 9b8d31d

Please sign in to comment.