Skip to content

Commit

Permalink
Add lint workflow for @comet/create-app
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyomair committed Dec 4, 2024
1 parent 5bf5820 commit 1fe4e2b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ on:
- next

jobs:
lint:
name: Lint
lint-starter:
name: Starter
runs-on: ubuntu-latest
steps:
- run: echo "${{ github.actor }}"
Expand Down Expand Up @@ -68,3 +68,31 @@ jobs:

- name: Build
run: npm run build
lint-create-app:
name: "@comet/create-app"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
cache-dependency-path: "create-app/package-lock.json"

- name: Install dependencies
run: npm --prefix create-app ci

- name: Lint
run: npm --prefix create-app run lint

- name: Build
run: npm --prefix create-app run build

- name: Create a new application
run: cd create-app/ && node bin/index.js test --no-install --no-commit

- name: Remove the site
run: cd create-app/test && node ../bin/index.js remove-site
1 change: 1 addition & 0 deletions create-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The following arguments can be passed to customize the project setup:

- `project-name` (required): Specifies the name of the project. It will be used as the directory name for the project.
- `-ni` or `--no-install`: Disables the automatic installation of dependencies.
- `-nc` or `--no-commit`: Disables the initial commit.
- `-r` or `--repository <repository>`: Repository to clone from. Defaults to `https://github.com/vivid-planet/comet-starter.git`.
- `-b` or `--branch <branch>`: Branch to checkout. Defaults to `main`.
- `-v` or `--verbose`: Enables extra console logs for verbose output.
Expand Down
2 changes: 2 additions & 0 deletions create-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void (async () => {
.argument("<projectName>", "Sets the name of the project.")
.option("-v, --verbose", "Enables extra console logs for verbose output.")
.option("-ni, --no-install", "Disables the automatic installation of dependencies.")
.option("-nc, --no-commit", "Disables the initial commit.")
.option("-r, --repository <repository>", "Repository to clone from.")
.option("-b, --branch <branch>", "Branch to checkout.")
.action((projectName: string, options) => {
Expand All @@ -32,6 +33,7 @@ void (async () => {
install: options.install,
repository: options.repository,
branch: options.branch,
commit: options.commit,
});
} else {
program.error("Please provide a valid project name.");
Expand Down
9 changes: 7 additions & 2 deletions create-app/src/scripts/create-app/createApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface CreateAppCommandOptions {
install: boolean;
repository?: string;
branch?: string;
commit: boolean;
}

export async function createApp(commandOptions: CreateAppCommandOptions) {
Expand All @@ -25,7 +26,9 @@ export async function createApp(commandOptions: CreateAppCommandOptions) {
cleanupReadme(commandOptions.verbose);
cleanupWorkingDirectory(commandOptions.verbose);
replacePlaceholder(commandOptions.projectName, commandOptions.verbose);
createInitialGitCommit(commandOptions.verbose);
if (commandOptions.commit) {
createInitialGitCommit(commandOptions.verbose);
}
if (commandOptions.install) {
const spinner = createSpinner("Installing project...").spin();
try {
Expand All @@ -39,7 +42,9 @@ export async function createApp(commandOptions: CreateAppCommandOptions) {
if (commandOptions.verbose) console.log(kleur.grey(`${error}`));
}
}
amendCommitChanges();
if (commandOptions.commit) {
amendCommitChanges();
}
console.log(`\nSuccess! Created '${commandOptions.projectName}' at '${process.cwd()}'.`);
console.log(`Inside that directory, you can run several commands:\n`);
console.log(kleur.cyan(`nvm use`));
Expand Down
6 changes: 4 additions & 2 deletions create-app/src/util/runEslintFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export function runEslintFix(verbose: boolean) {
for (const microservice of microservices) {
if (!fs.existsSync(microservice)) {
continue;
} else if (!hasDependenciesInstalled(microservice) && verbose) {
console.log(kleur.grey(`Skipping ESLint fix in ${microservice} because dependencies are not installed.`));
} else if (!hasDependenciesInstalled(microservice)) {
if (verbose) {
console.log(kleur.grey(`Skipping ESLint fix in ${microservice} because dependencies are not installed.`));
}
continue;
}

Expand Down

0 comments on commit 1fe4e2b

Please sign in to comment.