Skip to content

Commit

Permalink
fix: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangsibecas committed Sep 8, 2024
1 parent 6fcb7fb commit 52f831f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@nx/devkit": "19.6.5",
"@nx/jest": "19.6.5",
"@nx/js": "19.6.5",
"@types/js-yaml": "^4.0.9",
"ignore": "^5.3.2",
"js-yaml": "^4.1.0",
"nx": "19.6.5",
Expand All @@ -23,6 +22,7 @@
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.11",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/node": "18.16.9",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
Expand Down
2 changes: 2 additions & 0 deletions src/generators/init/generator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { formatFiles, readNxJson, Tree, updateNxJson } from '@nx/devkit';
import { addGitIgnoreEntry } from '../../utils';
import { addGithubActionCI } from 'src/utils/add-github-action-ci';

export async function initGenerator(tree: Tree) {
const nxJson = readNxJson(tree) || {};
Expand Down Expand Up @@ -31,6 +32,7 @@ export async function initGenerator(tree: Tree) {
updateNxJson(tree, nxJson);

addGitIgnoreEntry(tree);
addGithubActionCI(tree);

await formatFiles(tree);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/add-github-action-ci.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { Tree, readNxJson } from '@nx/devkit';
import { Tree } from '@nx/devkit';

import { addGithubActionCI } from './add-github-action-ci';

Expand Down
17 changes: 14 additions & 3 deletions src/utils/add-github-action-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ import * as yaml from 'js-yaml';

const CI_FILE_PATH = '.github/workflows/ci.yml';

type YamlFile = {
name: string;
jobs: {
main: {
steps: Array<{
uses: string;
name?: string;
with?: Record<string, string>;
}>;
};
};
};

export const addGithubActionCI = async (host: Tree) => {
if (!host.exists('.github/workflows/ci.yml')) {
return;
}

let file: Record<string, any> = await yaml.load(
host.read(CI_FILE_PATH, 'utf8'),
);
const file = (await yaml.load(host.read(CI_FILE_PATH, 'utf8'))) as YamlFile;

const actionStep = file.jobs.main.steps.findIndex(
({ uses }) => uses === 'actions/checkout@v4',
Expand Down

0 comments on commit 52f831f

Please sign in to comment.