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

refactor(november): Keep our repos aligned #100

Closed
aimeerivers opened this issue Nov 1, 2024 · 0 comments
Closed

refactor(november): Keep our repos aligned #100

aimeerivers opened this issue Nov 1, 2024 · 0 comments
Assignees
Labels
refactor Refactoring production code

Comments

@aimeerivers
Copy link
Member

aimeerivers commented Nov 1, 2024

git checkout main && git pull && git checkout -b november-alignment && ncu -i

0 - Update all dependencies

git add package*.json && git commit -m "deps: Update dependencies"

1 - Add service name and version to /ping endpoint

Requires ping version 1.2.0

The ping route can now be fed the extra information:

import packageJson from "../../package.json" with { type: "json" };
createPingRoute(`${packageJson.name} ${packageJson.version}`),
git add src/**/main.ts && git commit -m "feat: Add app name and version to the ping endpoint" 

2 - Add log statement to all setup.ts scripts to confirm that the script actually finished as expected

(Added by @Styrke)

The setup scripts can currently complete without giving an indication of the outcome.

Let's just add a simple log statement after calling all init() methods to indicated that the script was executed to at least that point. OAuth2-service has a nice structure that I think we should use:

import { Logger } from "@hedia/logger";
import packageJson from "../package.json" with { type: "json" };
import { loadConfig } from "./config.js";

const config = loadConfig();

const logger = new Logger({
	format: config.logFormat,
	level: config.logLevel,
	metadata: {
		service: {
			name: packageJson.name,
			version: packageJson.version,
		},
	},
});

const pgPool = new pg.Pool({ connectionString: config.localPgUrl.toString() });
const pgPoolClient = await pgPool.connect();

try {


	logger.info("Repositories successfully initialized");
} catch (error) {
	logger.error("Failed to initialize repositories", error);
} finally {
	pgPoolClient.release();
}

await pgPool.end();
git add src/**/setup.ts && git commit -m "feat: Add logging and try/catch to the setup script" 

3 - Update to eslint-config v5

git rm .eslintrc.json .eslintignore
cp ../../modules/module-template/eslint.config.js .
npm run eslint:fix && \
git add eslint.config.js && \
git commit -m "chore: Update to eslint-config v5"

Fix any problems that may arise

If there is a Dockerfile ensure that it doesn't have any reference to eslint config files, old or new.

git add eslint.config.js
git commit -m "chore: Update to eslint-config v5"

4 - Add "no-only-tests" eslint rule

https://www.npmjs.com/package/eslint-plugin-no-only-tests

Added to eslint-config v5.1.0 so it'll get into every repo when i update to the latest.


Run all the robots, create the PR and cleanup

npm run eslint:fix && npm run prettier:write && npm run package:lint && npm run build && npm run test && \
  git push origin november-alignment && \
  gh pr create --base main --head november-alignment --title "feat: Update to latest standards, including ping details and eslint-config" --fill && \
  gh pr merge --auto --squash --delete-branch && \
  git checkout main && git branch -D november-alignment && git pull && exit
@hedia-bot hedia-bot added the refactor Refactoring production code label Nov 1, 2024
@aimeerivers aimeerivers self-assigned this Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring production code
Projects
None yet
Development

No branches or pull requests

3 participants