Skip to content

Commit

Permalink
chore: Preparing changes to project.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmadames committed May 30, 2024
1 parent c3c56cc commit 1e7e7ee
Show file tree
Hide file tree
Showing 48 changed files with 1,080 additions and 1,023 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bun 1.1.8
bun 1.1.10
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
},
"javascript": {
"formatter": {
"quoteStyle": "single"
"quoteStyle": "single",
"semicolons": "asNeeded"
},
"parser": {
"unsafeParameterDecoratorsEnabled": true
Expand Down
30 changes: 15 additions & 15 deletions src/commands/clean/deps.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import { Command } from 'commander';
import { projectConfig } from '../../config/project';
import { deletePath } from '../../utils/file-system';
import logger from '../../utils/log';
import sharedOptions from '../../utils/shared-options';
import { Command } from 'commander'
import { projectConfig } from '../../config/project'
import { deletePath } from '../../utils/file-system'
import logger from '../../utils/log'
import sharedOptions from '../../utils/shared-options'

export const cleanDepsCommand = () => {
const command = new Command();
const command = new Command()
command
.name('deps')
.aliases(['dependencies'])
.summary('Cleanup repositories dependencies (node_modules).')
.description('Cleans all repos dependencies locally installed.')
.addOption(sharedOptions.force)
.action(async (options) => {
const config = projectConfig();
const config = projectConfig()
logger.info(
'Cleaning all local dependencies for configured applications...',
);
)

if (options.force) {
logger.warn('User interactivity disabled due to --force flag.');
logger.warn('User interactivity disabled due to --force flag.')
}

for (const repo of Object.values(config.paths.repos)) {
await deletePath({
path: `${repo}/node_modules`,
force: options.force,
});
})
}

logger.info('Dependencies cleanup task completed.');
});
logger.info('Dependencies cleanup task completed.')
})

return command;
};
return command
}

export default cleanDepsCommand();
export default cleanDepsCommand()
30 changes: 15 additions & 15 deletions src/commands/clean/dot-env.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Command } from 'commander';
import { projectConfig } from '../../config/project';
import { deletePath } from '../../utils/file-system';
import logger from '../../utils/log';
import sharedOptions from '../../utils/shared-options';
import { Command } from 'commander'
import { projectConfig } from '../../config/project'
import { deletePath } from '../../utils/file-system'
import logger from '../../utils/log'
import sharedOptions from '../../utils/shared-options'

export const cleanDotEnvCommand = () => {
const command = new Command();
const command = new Command()
command
.name('dot-env')
.aliases(['env', 'dotenv'])
Expand All @@ -15,24 +15,24 @@ export const cleanDotEnvCommand = () => {
)
.addOption(sharedOptions.force)
.action(async (options) => {
const config = projectConfig();
logger.info('Removing dot env files for managed repositories...');
const config = projectConfig()
logger.info('Removing dot env files for managed repositories...')

if (options.force) {
logger.warn('User interactivity disabled due to --force flag.');
logger.warn('User interactivity disabled due to --force flag.')
}

for (const repo of Object.values(config.paths.repos)) {
await deletePath({
path: `${repo}/.env`,
force: options.force,
});
})
}

logger.info('dot env files (.env) removed for managed repositories.');
});
logger.info('dot env files (.env) removed for managed repositories.')
})

return command;
};
return command
}

export default cleanDotEnvCommand();
export default cleanDotEnvCommand()
24 changes: 12 additions & 12 deletions src/commands/clean/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Command } from 'commander';
import { projectConfig } from '../../config/project';
import { noIndent } from '../../utils/string';
import { cleanDepsCommand } from './deps';
import { cleanDotEnvCommand } from './dot-env';
import { cleanReposCommand } from './repos';
import { Command } from 'commander'
import { projectConfig } from '../../config/project'
import { noIndent } from '../../utils/string'
import { cleanDepsCommand } from './deps'
import { cleanDotEnvCommand } from './dot-env'
import { cleanReposCommand } from './repos'

export const cleanCommand = () => {
const command = new Command();
const config = projectConfig();
const command = new Command()
const config = projectConfig()

command
.name('clean')
Expand All @@ -20,9 +20,9 @@ export const cleanCommand = () => {
)
.addCommand(cleanDepsCommand())
.addCommand(cleanDotEnvCommand())
.addCommand(cleanReposCommand());
.addCommand(cleanReposCommand())

return command;
};
return command
}

export default cleanCommand();
export default cleanCommand()
44 changes: 21 additions & 23 deletions src/commands/clean/repos.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import chalk from 'chalk';
import { Command } from 'commander';
import cliConfig from '../../config/cli';
import { projectConfig } from '../../config/project';
import { deletePath } from '../../utils/file-system';
import logger from '../../utils/log';
import sharedOptions from '../../utils/shared-options';
import { noIndent } from '../../utils/string';
import chalk from 'chalk'
import { Command } from 'commander'
import { cliConfig } from '../../config/cli'
import { projectConfig } from '../../config/project'
import { deletePath } from '../../utils/file-system'
import logger from '../../utils/log'
import sharedOptions from '../../utils/shared-options'
import { noIndent } from '../../utils/string'

export const cleanReposCommand = () => {
const command = new Command();
const command = new Command()
command
.name('repos')
.aliases(['repositories', 'repo'])
Expand All @@ -21,32 +21,30 @@ export const cleanReposCommand = () => {
)
.addOption(sharedOptions.force)
.action(async (options) => {
const config = projectConfig();
logger.info("Removing the current project's git repositories...");
logger.info(`Current project: ${chalk.bold(cliConfig.currentProject)}`);
const config = projectConfig()
logger.info("Removing the current project's git repositories...")
logger.info(`Current project: ${chalk.bold(cliConfig.currentProject)}`)

if (options.force) {
logger.warn('User interactivity disabled due to --force flag.');
logger.warn('User interactivity disabled due to --force flag.')
}

logger.warn('The repositories that will be removed are:');
logger.warn('The repositories that will be removed are:')
for (const repo of config.repositories) {
logger.warn(` - ${repo}`);
logger.warn(` - ${repo}`)
}

for (const repo of Object.values(config.paths.repos)) {
await deletePath({
path: repo,
force: options.force,
});
})
}

logger.info(
'All managed git repositories directories have been removed.',
);
});
logger.info('All managed git repositories directories have been removed.')
})

return command;
};
return command
}

export default cleanReposCommand();
export default cleanReposCommand()
28 changes: 14 additions & 14 deletions src/commands/compose/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from 'commander';
import { projectConfig } from '../../config/project';
import { composeExec } from '../../utils/compose';
import logger from '../../utils/log';
import { composeShowArgsCommand } from './show-args';
import { Command } from 'commander'
import { projectConfig } from '../../config/project'
import { composeExec } from '../../utils/compose'
import logger from '../../utils/log'
import { composeShowArgsCommand } from './show-args'

export const composeCommand = () => {
const command = new Command();
const config = projectConfig();
const command = new Command()
const config = projectConfig()

command
.name('compose')
Expand All @@ -20,16 +20,16 @@ export const composeCommand = () => {
.allowUnknownOption()
.action((composeArgs) => {
if (composeArgs.length === 0) {
logger.error('A Compose command needs to be specified.');
process.exit(1);
logger.error('A Compose command needs to be specified.')
process.exit(1)
}

composeExec({
command: composeArgs,
});
});
})
})

return command;
};
return command
}

export default composeCommand();
export default composeCommand()
24 changes: 12 additions & 12 deletions src/commands/compose/show-args.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Command } from 'commander';
import { composeExecParams, composeFiles } from '../../utils/compose';
import logger from '../../utils/log';
import { Command } from 'commander'
import { composeExecParams, composeFiles } from '../../utils/compose'
import logger from '../../utils/log'

export const composeShowArgsCommand = () => {
const command = new Command();
const command = new Command()

command
.name('show-args')
Expand All @@ -13,13 +13,13 @@ export const composeShowArgsCommand = () => {
'docker compose command for DEMS.',
)
.action(() => {
logger.info('Compose command params:');
console.log(JSON.stringify(composeExecParams(), null, 2));
logger.info('Compose files params:');
console.log(JSON.stringify(composeFiles({}), null, 2));
});
logger.info('Compose command params:')
console.log(JSON.stringify(composeExecParams(), null, 2))
logger.info('Compose files params:')
console.log(JSON.stringify(composeFiles({}), null, 2))
})

return command;
};
return command
}

export default composeShowArgsCommand();
export default composeShowArgsCommand()
8 changes: 4 additions & 4 deletions src/commands/config/generate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from 'commander';
import CLIConfig from '../../config/cli.config';
import { Command } from 'commander'
import { cliConfig } from '../../config/cli.config'

export function generateConfigCommand() {
return new Command()
.name('generate')
.alias('create')
.summary('Generates default DEMS config file')
.action(() => {
CLIConfig.generate();
});
cliConfig.save(cliConfig.default())
})
}
12 changes: 6 additions & 6 deletions src/commands/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from 'commander';
import { generateConfigCommand } from './generate';
import { viewConfigCommand } from './view';
import { Command } from 'commander'
import { generateConfigCommand } from './generate'
import { viewConfigCommand } from './view'

export const configCommand = () => {
return new Command()
Expand All @@ -10,7 +10,7 @@ export const configCommand = () => {
'Manages and displays the DEMS configuration currently in-use.',
)
.addCommand(viewConfigCommand())
.addCommand(generateConfigCommand());
};
.addCommand(generateConfigCommand())
}

export default configCommand();
export default configCommand()
10 changes: 5 additions & 5 deletions src/commands/config/view.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Command } from 'commander';
import CLIConfig from '../../config/cli.config';
import { Command } from 'commander'
import { cliConfig } from '../../config/cli.config'

export function viewConfigCommand() {
return new Command()
.name('view')
.alias('get')
.aliases(['get', 'show'])
.summary('Shows the DEMS config file ')
.action(() => {
console.log(JSON.parse(CLIConfig.get().toString()));
});
console.log(cliConfig.get())
})
}
20 changes: 10 additions & 10 deletions src/commands/dependencies/copy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Command } from 'commander';
import { projectConfig } from '../../config/project';
import { composeExec } from '../../utils/compose';
import { Command } from 'commander'
import { projectConfig } from '../../config/project'
import { composeExec } from '../../utils/compose'

export const depsCopyCommand = () => {
const command = new Command();
const command = new Command()

command
.name('copy')
Expand All @@ -13,7 +13,7 @@ export const depsCopyCommand = () => {
'IDE features such as IntelliSense.',
)
.action(() => {
const config = projectConfig();
const config = projectConfig()
for (const repo of config.repositories) {
composeExec({
command: [
Expand All @@ -24,11 +24,11 @@ export const depsCopyCommand = () => {
)}:/usr/app/node_modules`,
`${config.paths.repos[repo.replace('-', '_')]}/node_modules`,
],
});
})
}
});
})

return command;
};
return command
}

export default depsCopyCommand();
export default depsCopyCommand()
Loading

0 comments on commit 1e7e7ee

Please sign in to comment.