Skip to content

Commit

Permalink
refactor: use latest mainline eik/common
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Aug 9, 2024
1 parent 153e25d commit e2f7d99
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/analyze-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/generate-notes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from "path";
import { typeSlug } from "@eik/common-utils";
import { helpers } from "@eik/common";

/**
* Semantic Release "generate notes" hook
Expand All @@ -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;
Expand All @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions lib/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class State {
eikToken = "";
eikJSON = {};
versionToPublish = null;
publishNeeded = null;
}
6 changes: 3 additions & 3 deletions lib/success.js
Original file line number Diff line number Diff line change
@@ -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.";
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions lib/verify-conditions.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 = [];
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/verify-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit e2f7d99

Please sign in to comment.