From e2f7d990faf39e90caa02180756ec9a60fd0e130 Mon Sep 17 00:00:00 2001 From: William Killerud Date: Fri, 9 Aug 2024 12:47:32 +0200 Subject: [PATCH] refactor: use latest mainline eik/common --- lib/analyze-commits.js | 2 +- lib/generate-notes.js | 6 +++--- lib/main.js | 8 +------- lib/prepare.js | 2 +- lib/publish.js | 2 +- lib/state.js | 6 ++++++ lib/success.js | 6 +++--- lib/verify-conditions.js | 7 ++++--- lib/verify-release.js | 2 +- package.json | 3 +-- 10 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 lib/state.js diff --git a/lib/analyze-commits.js b/lib/analyze-commits.js index b651d62..5f378ac 100644 --- a/lib/analyze-commits.js +++ b/lib/analyze-commits.js @@ -19,7 +19,7 @@ const E_VERSIONING_ERROR = * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function analyzeCommits(options, context, state) { const { version: currentVersion, server, type, name } = state.eikJSON; diff --git a/lib/generate-notes.js b/lib/generate-notes.js index 342a13e..77a9ec4 100644 --- a/lib/generate-notes.js +++ b/lib/generate-notes.js @@ -1,5 +1,5 @@ import { join } from "path"; -import { typeSlug } from "@eik/common-utils"; +import { helpers } from "@eik/common"; /** * Semantic Release "generate notes" hook @@ -8,7 +8,7 @@ import { typeSlug } from "@eik/common-utils"; * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function generateNotes(options, context, state) { if (!state.publishNeeded) return; @@ -17,7 +17,7 @@ export default async function generateNotes(options, context, state) { const version = state.versionToPublish; const date = new Date(); const dateString = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`; - const slug = typeSlug(type); + const slug = helpers.typeSlug(type); const versionURL = new URL(join(slug, name, version), server).href; const nameURL = new URL(join(slug, name), server).href; diff --git a/lib/main.js b/lib/main.js index 28686c7..c099557 100644 --- a/lib/main.js +++ b/lib/main.js @@ -5,13 +5,7 @@ import generateNotes from "./generate-notes.js"; import prepare from "./prepare.js"; import publish from "./publish.js"; import success from "./success.js"; - -class State { - eikToken = ""; - eikJSON = {}; - versionToPublish = null; - publishNeeded = null; -} +import { State } from "./state.js"; const state = new State(); diff --git a/lib/prepare.js b/lib/prepare.js index cc77bb2..f275505 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -9,7 +9,7 @@ const VERSION_WRITTEN = "Version: ✅ v%s written back to eik.json file."; * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function prepare(options, context, state) { if (!state.publishNeeded) return; diff --git a/lib/publish.js b/lib/publish.js index 7e4a4a6..d8f3064 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -11,7 +11,7 @@ const E_PUBLISH_FAILED = * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function publish(options, context, state) { if (!state.publishNeeded) return; diff --git a/lib/state.js b/lib/state.js new file mode 100644 index 0000000..7776439 --- /dev/null +++ b/lib/state.js @@ -0,0 +1,6 @@ +export class State { + eikToken = ""; + eikJSON = {}; + versionToPublish = null; + publishNeeded = null; +} diff --git a/lib/success.js b/lib/success.js index 4ac5654..925ec0f 100644 --- a/lib/success.js +++ b/lib/success.js @@ -1,5 +1,5 @@ import { join } from "node:path"; -import { typeSlug } from "@eik/common-utils"; +import { helpers } from "@eik/common"; const PUBLISH_SUCCESS = "Publish: ✅ Successfully published package %s (v%s) to %s."; @@ -13,13 +13,13 @@ const PUBLISH_FAILURE = * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function success(options, context, state) { if (!state.publishNeeded) return; const { logger } = context; const { server, name, type } = state.eikJSON; - const slug = typeSlug(type); + const slug = helpers.typeSlug(type); const url = new URL(join(slug, name, state.versionToPublish), server); url.searchParams.set("ts", `${Date.now()}`); const result = await fetch(url); diff --git a/lib/verify-conditions.js b/lib/verify-conditions.js index 92a64b7..31dc1f4 100644 --- a/lib/verify-conditions.js +++ b/lib/verify-conditions.js @@ -1,5 +1,6 @@ import eik from "@eik/cli"; -import { configStore } from "@eik/common-config-loader"; +import { helpers } from "@eik/common"; + import AggregateError from "aggregate-error"; const E_TOKEN_MISSING = "Verify: ❌ EIK_TOKEN environment variable not found"; @@ -15,7 +16,7 @@ const LEVELS = ["major", "minor", "patch"]; * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function verifyConditions(options, context, state) { const errors = []; @@ -30,7 +31,7 @@ export default async function verifyConditions(options, context, state) { // verify existance of and validity of eik.json file AND read contents try { - state.eikJSON = configStore.findInDirectory(context.cwd); + state.eikJSON = helpers.configStore.findInDirectory(context.cwd); } catch (err) { errors.push(err); } diff --git a/lib/verify-release.js b/lib/verify-release.js index af119fa..ed11358 100644 --- a/lib/verify-release.js +++ b/lib/verify-release.js @@ -11,7 +11,7 @@ const FOUND_FILES = "Verify: ✅ Found %d file(s) to publish"; * * @param {object} options * @param {object} context - * @param {object} state + * @param {import('./state.js').State} state */ export default async function verifyRelease(options, context, state) { if (!state.publishNeeded) return; diff --git a/package.json b/package.json index fb8d03e..7c87cd4 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "license": "MIT", "dependencies": { "@eik/cli": "2.0.39", - "@eik/common-config-loader": "4.0.0-next.12", - "@eik/common-utils": "4.0.0-next.12", + "@eik/common": "4.0.7", "aggregate-error": "5.0.0" }, "devDependencies": {