Skip to content

Commit

Permalink
feat: add version in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Oct 29, 2023
1 parent 237f428 commit de6b191
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WORKDIR /app
COPY src/ /app/src
COPY package.json package-lock.json tsconfig.json .eslintrc.json /app/

RUN npm run prebuild
RUN npm ci --ignore-scripts && npm run build

RUN echo "" > .env
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"lint": "eslint src/ --ext .ts",
"lint:fix": "eslint src/ --ext .ts --fix",
"test": "jest --config ./meta/testing/jest.config.cjs",
"prebuild": "sh scripts/build-info.sh",
"build": "tsc",
"predeploy": "npm ci && npm run build",
"pm2": "bash deployment/pm2.sh",
Expand Down
4 changes: 4 additions & 0 deletions scripts/build-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

VERSION=$(npm pkg get version | xargs)
echo "{ \"name\": \"Touitomamout\", \"version\": \"$VERSION\" }" > ./src/buildInfo.json
1 change: 1 addition & 0 deletions src/buildInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "name": "Touitomamout", "version": "1.3.0" }
2 changes: 2 additions & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MASTODON_INSTANCE,
SYNC_BLUESKY,
SYNC_MASTODON,
TOUITOMAMOUT_VERSION,
TWITTER_HANDLE,
} from "../constants.js";
import { handleTwitterAuth } from "../helpers/auth/auth.js";
Expand Down Expand Up @@ -46,6 +47,7 @@ export const configuration = async (): Promise<{
}
});

console.log(`Touitomamout@v${TOUITOMAMOUT_VERSION}`);
// Init configuration
await createCacheFile();
await runMigrations();
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import dotenv from "dotenv";
import fs from "fs";
import { join } from "path";

import buildInfo from "./buildInfo.json" assert { type: "json" };

const envPath = process.argv[2] ?? join(process.cwd(), ".env");
const envAvailable = await fs.promises
.access(envPath, fs.constants.F_OK)
Expand Down Expand Up @@ -60,3 +62,4 @@ export const DEBUG = (process.env.TOUITOMAMOUT_DEBUG || "false") === "true";
export const DAEMON = (process.env.DAEMON || "false") === "true";
export const VOID = "∅";
export const API_RATE_LIMIT = parseInt(process.env.API_RATE_LIMIT ?? "10");
export const TOUITOMAMOUT_VERSION = buildInfo.version || "0.0.0";
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SYNC_BLUESKY,
SYNC_FREQUENCY_MIN,
SYNC_MASTODON,
TOUITOMAMOUT_VERSION,
TWITTER_HANDLE,
} from "./constants.js";
import {
Expand Down Expand Up @@ -47,7 +48,7 @@ const touitomamout = async () => {
synchronizedPostsCountAllTime.set(response.metrics.totalSynced);

console.log("\n🦤 → 🦣+☁️");
console.log("Touitomamout sync");
console.log(`Touitomamout sync | v${TOUITOMAMOUT_VERSION}`);
console.log(`| Twitter handle: @${TWITTER_HANDLE}`);
console.log(
`| ${response.metrics.justSynced
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
"resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

Expand Down

0 comments on commit de6b191

Please sign in to comment.