Skip to content

Commit

Permalink
Action finishes (cannot test yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nahuel Sotelo committed Jan 12, 2024
1 parent 68663d6 commit c8fd812
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 263 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"simple-import-sort",
"import"
],
"root": true
"root": true,
"rules": {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
}
}
17 changes: 1 addition & 16 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}
{}

Check warning on line 1 in .prettierrc.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
33 changes: 33 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { CustomError } from "ts-custom-error";

Check failure on line 1 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unable to resolve path to module 'ts-custom-error'

Check failure on line 1 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon

export class InvalidUrlError extends CustomError {
public constructor(

Check failure on line 4 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Public accessibility modifier on method definition constructor
public invalidUrl: string,
cause: unknown,
) {
super(`Invalid URL given: ${invalidUrl}`, { cause });

Check failure on line 8 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
// Set name explicitly as minification can mangle class names
Object.defineProperty(this, "name", { value: "InvalidUrlError" });

Check failure on line 10 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
}
}

export class ParseUrlsError extends CustomError {
public constructor(

Check failure on line 15 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Public accessibility modifier on method definition constructor
public wrongUrlString: string,
cause: unknown,
) {
super(`Failed to parse the given URL strings: ${wrongUrlString}`, {
cause,
});

Check failure on line 21 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
// Set name explicitly as minification can mangle class names
Object.defineProperty(this, "name", { value: "CannotParseUrlsError" });

Check failure on line 23 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
}
}

export class UnknownError extends CustomError {
public constructor(cause: unknown) {

Check failure on line 28 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Public accessibility modifier on method definition constructor
super(`Unknown error`, { cause });

Check failure on line 29 in src/errors.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
// Set name explicitly as minification can mangle class names
Object.defineProperty(this, "name", { value: "UnknownError" });
}
}
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* The entrypoint for the action.
*/
import { run } from './main'

void run()
import { run } from "./main.js";

await run();
34 changes: 34 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createLogger, format, transports } from "winston";

export const logger = createLogger({
level: "info",
format: format.combine(
format.timestamp({
format: "YYYY-MM-DD HH:mm:ss",
}),
format.errors({ stack: true }),
format.splat(),
format.json(),
),
defaultMeta: { service: "diffnews" },
transports: [
//
// - Write to all logs with level `info` and below to `quick-start-combined.log`.
// - Write all logs error (and below) to `quick-start-error.log`.
//
new transports.File({ filename: "diffnews-error.log", level: "error" }),
new transports.File({ filename: "diffnews-combined.log" }),
],
});

//
// If we're not in production then **ALSO** log to the `console`
// with the colorized simple format.
//
if (process.env.NODE_ENV !== "production") {
logger.add(
new transports.Console({
format: format.combine(format.colorize(), format.simple()),
}),
);
}
89 changes: 0 additions & 89 deletions src/main.test.ts

This file was deleted.

Loading

0 comments on commit c8fd812

Please sign in to comment.