Skip to content

Commit

Permalink
Bumped deps and deno (#168)
Browse files Browse the repository at this point in the history
* Bumped deps and deno

* Updated changelog

* Bumped nessie version and fixed issues
  • Loading branch information
halvardssm authored Sep 24, 2023
1 parent b3fa017 commit 7e30b12
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 53 deletions.
1 change: 0 additions & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:

- name: Run unit tests
run: deno task test:unit


- name: Generate lcov
run: deno coverage --unstable --lcov ./coverage > coverage.lcov
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Nessie Change Log

## Version 2.0.11 - 2023-09-24

- Deno v1.37.0
- Deno std v0.202.0
- Cliffy v0.25.7
- MySQL v2.12.1
- SQLite v3.8

## Version 2.0.10 - 2022-10-28

- Deno v1.27.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DB_MYSQL_PORT=5001
DB_USER=root
DB_PWD=pwd
DB_NAME=nessie
NESSIE_VERSION=2.0.10
NESSIE_VERSION=2.0.11
DENO_VERSION?=1.24.1
DOCKER_IMAGE=halvardm/nessie

Expand Down
2 changes: 1 addition & 1 deletion consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bold, yellow } from "./deps.ts";

export const VERSION = "2.0.10";
export const VERSION = "2.0.11";

export const SPONSOR_NOTICE = bold(
yellow(
Expand Down
18 changes: 9 additions & 9 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ export {
relative,
resolve,
toFileUrl,
} from "https://deno.land/std@0.161.0/path/mod.ts";
} from "https://deno.land/std@0.202.0/path/mod.ts";
export {
assert,
assertEquals,
} from "https://deno.land/std@0.161.0/testing/asserts.ts";
export { exists } from "https://deno.land/std@0.161.0/fs/mod.ts";
export { format } from "https://deno.land/std@0.161.0/datetime/mod.ts";
} from "https://deno.land/std@0.202.0/testing/asserts.ts";
export { exists } from "https://deno.land/std@0.202.0/fs/mod.ts";
export { format } from "https://deno.land/std@0.202.0/datetime/mod.ts";
export {
bold,
green,
yellow,
} from "https://deno.land/std@0.161.0/fmt/colors.ts";
} from "https://deno.land/std@0.202.0/fmt/colors.ts";

/** Cliffy */
export {
Expand All @@ -26,16 +26,16 @@ export {
HelpCommand as CliffyHelpCommand,
Select as CliffySelect,
Toggle as CliffyToggle,
} from "https://deno.land/x/[email protected].2/mod.ts";
export type { IAction as CliffyIAction } from "https://deno.land/x/[email protected].2/mod.ts";
} from "https://deno.land/x/[email protected].7/mod.ts";
export type { IAction as CliffyIAction } from "https://deno.land/x/[email protected].7/mod.ts";

/** MySQL */
export { Client as MySQLClient } from "https://deno.land/x/mysql@v2.10.3/mod.ts";
export { Client as MySQLClient } from "https://deno.land/x/mysql@v2.12.1/mod.ts";

/** PostgreSQL */
export {
Client as PostgreSQLClient,
} from "https://deno.land/x/[email protected]/mod.ts";

/** SQLite */
export { DB as SQLiteClient } from "https://deno.land/x/sqlite@v3.5.0/mod.ts";
export { DB as SQLiteClient } from "https://deno.land/x/sqlite@v3.8/mod.ts";
2 changes: 1 addition & 1 deletion egg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://x.nest.land/[email protected]/src/schema.json",
"name": "Nessie",
"description": "A modular database migration module for Deno.",
"version": "2.0.10",
"version": "2.0.11",
"stable": true,
"repository": "https://github.com/halvardssm/deno-nessie",
"files": [
Expand Down
26 changes: 16 additions & 10 deletions helpers/get_image_tags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as semver from "https://deno.land/x/[email protected]/mod.ts";
import { REG_EXP_VERSION_NEXT, REG_EXP_VERSION_STABLE } from "./commons.ts";
import {
format,
gte,
parse,
SemVer,
} from "https://deno.land/[email protected]/semver/mod.ts";
import { tryParse } from "https://deno.land/[email protected]/semver/try_parse.ts";

async function getTags() {
const decoder = new TextDecoder();
Expand All @@ -21,7 +26,9 @@ async function getTags() {
Deno.exit(code);
}

return result.split("\n").filter((tag) => !tag.startsWith("v"));
return result.split("\n").map((tag) => tryParse(tag)).filter((tag) =>
!!tag
) as SemVer[];
}

async function getCurrentTag() {
Expand All @@ -44,7 +51,7 @@ async function getCurrentTag() {
Deno.exit(code);
}

return result.trim();
return parse(result.trim());
}

async function generateTagsArray() {
Expand All @@ -53,20 +60,19 @@ async function generateTagsArray() {
const tags = await getTags();
const current = await getCurrentTag();

const latestStable =
tags.filter((tag) => REG_EXP_VERSION_STABLE.test(tag))[0];
const latestNext = tags.filter((tag) => REG_EXP_VERSION_NEXT.test(tag))[0];
const latestStable = tags.find((tag) => !tag.prerelease);
const latestNext = tags.find((tag) => !!tag.prerelease);

const outputArray = [`${IMAGE}:${current}`];
const outputArray = [`${IMAGE}:${format(current)}`];

try {
if (
REG_EXP_VERSION_STABLE.test(current) && semver.gte(current, latestStable)
!current.prerelease.length && latestStable && gte(current, latestStable)
) {
outputArray.push(`${IMAGE}:latest`);
}

if (semver.gte(current, latestNext)) {
if (latestNext && gte(current, latestNext)) {
outputArray.push(`${IMAGE}:next`);
}

Expand Down
59 changes: 29 additions & 30 deletions helpers/prepare_release.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { REG_EXP_VERSION, REG_EXP_VERSION_STABLE } from "./commons.ts";
import { format, SemVer } from "https://deno.land/[email protected]/semver/mod.ts";
import { tryParse } from "https://deno.land/[email protected]/semver/try_parse.ts";

const REG_EXP_README_DENO_VERSION = /shields\.io\/badge\/deno-v\d+\.\d+\.\d+/;
const REG_EXP_MAKEFILE_DENO_VERSION = /DENO_VERSION=\d+\.\d+\.\d+/;
Expand All @@ -16,101 +17,103 @@ const FILES_CI = [
".github/workflows/publish_docker.yml",
];

type VERSIONS = {
nessie: string | undefined;
deno: string | undefined;
type Versions = {
nessie: SemVer | undefined;
deno: SemVer | undefined;
};

const setEggConfig = async (versions: VERSIONS) => {
const setEggConfig = async (versions: Versions) => {
if (versions.nessie) {
// deno-lint-ignore no-explicit-any
const eggFile = JSON.parse(await Deno.readTextFile(FILE_JSON_EGG)) as any;

eggFile.version = versions.nessie;
eggFile.stable = REG_EXP_VERSION_STABLE.test(versions.nessie);
eggFile.version = format(versions.nessie);
eggFile.stable = !versions.nessie.prerelease.length;

await Deno.writeTextFile(
FILE_JSON_EGG,
JSON.stringify(eggFile, undefined, 2),
);

console.info(`egg.json updated to ${versions.nessie}`);
console.info(`egg.json updated to ${eggFile.version}`);
}
};

const setReadMe = async (versions: VERSIONS) => {
const setReadMe = async (versions: Versions) => {
if (versions.deno) {
const readme = await Deno.readTextFile(FILE_README);

const res = readme.replace(
REG_EXP_README_DENO_VERSION,
`shields.io/badge/deno-v${versions.deno}`,
`shields.io/badge/deno-v${format(versions.deno)}`,
);

await Deno.writeTextFile(FILE_README, res);

console.info(`README.md updated to ${versions.deno}`);
console.info(`README.md updated to ${format(versions.deno)}`);
}
};

const setProgram = async (versions: VERSIONS) => {
const setProgram = async (versions: Versions) => {
if (versions.nessie) {
const cli = await Deno.readTextFile(FILE_PROGRAM);

const res = cli.replace(
REG_EXP_PROGRAM_NESSIE_VERSION,
`export const VERSION = "${versions.nessie}";`,
`export const VERSION = "${format(versions.nessie)}";`,
);

await Deno.writeTextFile(FILE_PROGRAM, res);

console.info(`consts.ts updated to ${versions.nessie}`);
console.info(`consts.ts updated to ${format(versions.nessie)}`);
}
};

const setCI = async (versions: VERSIONS) => {
const setCI = async (versions: Versions) => {
if (versions.deno || versions.nessie) {
for (const file of FILES_CI) {
let res = await Deno.readTextFile(file);

if (versions.deno) {
res = res.replace(
REG_EXP_CI_DENO_VERSION,
`DENO_VERSION: ${versions.deno}`,
`DENO_VERSION: ${format(versions.deno)}`,
);

console.info(
`${file} updated to Deno: ${format(versions.deno)}`,
);
}

await Deno.writeTextFile(file, res);

console.info(
`${file} updated to Deno: ${versions.deno}`,
);
}
}
};

const setMakefile = async (versions: VERSIONS) => {
const setMakefile = async (versions: Versions) => {
if (versions.deno || versions.nessie) {
let res = await Deno.readTextFile(FILE_MAKEFILE);

if (versions.nessie) {
res = res.replace(
REG_EXP_MAKEFILE_NESSIE_VERSION,
`NESSIE_VERSION=${versions.nessie}`,
`NESSIE_VERSION=${format(versions.nessie)}`,
);
}

if (versions.deno) {
res = res.replace(
REG_EXP_MAKEFILE_DENO_VERSION,
`DENO_VERSION=${versions.deno}`,
`DENO_VERSION=${format(versions.deno)}`,
);
}

await Deno.writeTextFile(FILE_MAKEFILE, res);

console.info(
`${FILE_MAKEFILE} updated to Nessie: ${versions.nessie} and Deno: ${versions.deno}`,
`${FILE_MAKEFILE} updated to Nessie: ${
versions.nessie && format(versions.nessie)
} and Deno: ${versions.deno && format(versions.deno)}`,
);
}
};
Expand All @@ -130,12 +133,8 @@ async function runProgram() {
}

const versions = {
nessie: REG_EXP_VERSION.test(versionsRaw.split(":")[0])
? versionsRaw.split(":")[0]
: undefined,
deno: REG_EXP_VERSION_STABLE.test(versionsRaw.split(":")[1])
? versionsRaw.split(":")[1]
: undefined,
nessie: tryParse(versionsRaw.split(":")[0]),
deno: tryParse(versionsRaw.split(":")[1]),
};

await setEggConfig(versions);
Expand Down

0 comments on commit 7e30b12

Please sign in to comment.