Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(cli): fix progress bar display #848

Merged
merged 6 commits into from
Apr 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bug(cli): fix progress bar display
fixes #846
Idrinth committed Apr 21, 2024
commit 04b48bacd9e9934a07d97df82034a8cd52d9a7ff
64 changes: 44 additions & 20 deletions cli/src/cli/make.ts
Original file line number Diff line number Diff line change
@@ -33,16 +33,36 @@
}
const bar = new SingleBar({
stopOnComplete: true,
clearOnComplete: true,
format: 'progress [{bar}] {value}/{total} {task}',
},);
const mkdir = (path: string,) => {
bar.update({
task: `Creating ${ path }`,
},);
mkdirSync(root + path,);
};
const write = (path: string, data: string) => {

Check warning on line 44 in cli/src/cli/make.ts

GitHub Actions / lint

Missing trailing comma
bar.update({
task: `Creating ${ path }`,
},);
writeFileSync(root + '/package.json', data, 'utf8',);
};
const exec = (command: string) => {

Check warning on line 50 in cli/src/cli/make.ts

GitHub Actions / lint

Missing trailing comma
bar.update({
task: `executing '${ command }'`,
},);
execSync(command, {
cwd: root,
},);
};
const tasks = [
() => mkdirSync(root,),
() => mkdirSync(root + '/src',),
() => mkdirSync(root + '/test',),
() => mkdirSync(root + '/src/routes',),
() => mkdirSync(root + '/src/routes/main',),
() => mkdirSync(root + '/src/routes/before',),
() => writeFileSync(root + '/package.json', JSON.stringify({
() => mkdir('',),
() => mkdir('/src',),
() => mkdir('/test',),
() => mkdir('/src/routes',),
() => mkdir('/src/routes/main',),
() => mkdir('/src/routes/before',),
() => write('/package.json', JSON.stringify({
name,
private: true,
type: 'module',
@@ -57,6 +77,8 @@
c8: '^8.0.1',
eslint: '^8.55.0',
'eslint-plugin-json': '^3.1.0',
'@typescript-eslint/eslint-plugin': '^7.0.0',
'@typescript-eslint/parser': '^7.0.0',
},
scripts: {
start: 'tsc -p tsconfig.json && run-benchmark',
@@ -271,8 +293,11 @@
'parserOptions:\n' +
' ecmaVersion: 2018\n'
,),
() => writeFileSync(
root + '/.editorconfig',
() => write('/test/.eslintrc.yml', 'env:\n' +
' mocha: true\n'
,),
() => write(
'/.editorconfig',
'root = true\n' +
'\n' +
'[*]\n' +
@@ -282,8 +307,8 @@
'indent_style = space\n' +
'indent_size = 2\n',
),
() => writeFileSync(
root + '/.mocharc.cjs',
() => write(
'/.mocharc.cjs',
'module.exports = {\n' +
' recursive: true,\n' +
' extension: [\n' +
@@ -296,8 +321,8 @@
' parallel: false\n' +
'}',
),
() => writeFileSync(
root + '/.nycrc.json',
() => write(
'/.nycrc.json',
'{\n' +
' "require": ["ts-node/register"],\n' +
' "extension" : [".ts", ".tsx"],\n' +
@@ -309,16 +334,15 @@
' "include": ["src/**/*.ts"]\n' +
'}\n',
),
() => execSync('npm install', {
cwd: root,
},),
() => execSync('git init --initial-branch=master', {
cwd: root,
},),
() => exec('npm install',),
() => exec('git init --initial-branch=master',),
];
bar.start(tasks.length, EMPTY,);
for (const task of tasks) {
task();
bar.update({
task: '',
},);
bar.increment();
}
};