Skip to content

Commit ccd52d1

Browse files
committed
sync configure script
1 parent e420205 commit ccd52d1

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

configure-package.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,17 @@ class Features {
350350
},
351351
};
352352

353+
autoformat = {
354+
name: 'autoformat',
355+
prompt: 'Automatically lint & format code on push?',
356+
enabled: true,
357+
default: true,
358+
dependsOn: [],
359+
disable: () => {
360+
safeUnlink(getWorkflowFilename('format-code'));
361+
},
362+
};
363+
353364
dependabot = {
354365
name: 'dependabot',
355366
prompt: 'Use Dependabot?',
@@ -466,19 +477,9 @@ class Features {
466477
},
467478
};
468479

469-
useCommanderPackage = {
470-
name: 'useCommanderPackage',
471-
prompt: 'Use the commander package for creating CLI apps?',
472-
enabled: true,
473-
default: true,
474-
dependsOn: ['isPackageCommandLineApp'],
475-
disable: () => {
476-
//
477-
},
478-
};
479-
480480
features = [
481481
this.codecov,
482+
this.autoformat,
482483
this.dependabot,
483484
this.automerge,
484485
this.codeql,
@@ -487,7 +488,6 @@ class Features {
487488
this.useJestPackage,
488489
this.useEslintPackage,
489490
this.isPackageCommandLineApp,
490-
// this.useCommanderPackage,
491491
];
492492

493493
async run() {
@@ -629,14 +629,11 @@ class OptionalPackages {
629629
}
630630
}
631631

632-
const packageList = await askQuestion(this.otherPackages, this.otherPackages.default);
632+
const packageList = await askQuestion(this.otherPackages.prompt, this.otherPackages.default);
633633

634634
if (packageList.length > 0) {
635635
this.otherPackages.add(packageList.split(',').map(pkg => pkg.trim()));
636636
}
637-
638-
cp.execSync('node ./node_modules/.bin/prettier --write ./src', { cwd: __dirname, stdio: 'inherit' });
639-
cp.execSync('node ./node_modules/.bin/eslint --fix ./src', { cwd: __dirname, stdio: 'inherit' });
640637
}
641638
}
642639

@@ -657,6 +654,11 @@ const askBooleanQuestion = async str => {
657654
return result === 'y';
658655
};
659656

657+
const lintAndFormatSourceFiles = () => {
658+
cp.execSync('node ./node_modules/.bin/prettier --write ./src', { cwd: __dirname, stdio: 'inherit' });
659+
cp.execSync('node ./node_modules/.bin/eslint --fix ./src', { cwd: __dirname, stdio: 'inherit' });
660+
};
661+
660662
const run = async function () {
661663
await populatePackageInfo();
662664
await configureOptionalFeatures();
@@ -677,11 +679,17 @@ const run = async function () {
677679
try {
678680
removeTemplateReadmeText();
679681
removeAssetsDirectory();
682+
} catch (e) {
683+
console.log('Error removing template assets: ', e);
684+
}
685+
686+
try {
680687
processFiles(__dirname, packageInfo);
681688
installDependencies();
682689
await new OptionalPackages().run();
690+
lintAndFormatSourceFiles();
683691
} catch (err) {
684-
//
692+
console.log('Error: ', err);
685693
}
686694

687695
rl.close();

0 commit comments

Comments
 (0)