diff --git a/index.js b/index.js index 3c9f507..2b07928 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,16 @@ -const verifyChart = require('./lib/verifyConditions'); -const prepareChart = require('./lib/prepare'); -const publishChart = require('./lib/publish'); +import verifyChart from './lib/verifyConditions.js'; +import prepareChart from './lib/prepare.js'; +import publishChart from './lib/publish.js'; let verified = false; let prepared = false; -async function verifyConditions(pluginConfig, context) { +export async function verifyConditions(pluginConfig, context) { await verifyChart(pluginConfig, context); verified = true; } -async function prepare(pluginConfig, context) { +export async function prepare(pluginConfig, context) { if (!verified) { await verifyChart(pluginConfig, context); } @@ -19,7 +19,7 @@ async function prepare(pluginConfig, context) { prepared = true; } -async function publish(pluginConfig, context) { +export async function publish(pluginConfig, context) { if (!verified) { await verifyChart(pluginConfig, context); } @@ -29,5 +29,3 @@ async function publish(pluginConfig, context) { await publishChart(pluginConfig, context); } - -module.exports = {verifyConditions, prepare, publish}; diff --git a/lib/prepare.js b/lib/prepare.js index 0e3feca..c4ef9c8 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -1,8 +1,8 @@ -const fsPromises = require('fs').promises; -const execa = require('execa'); -const yaml = require('js-yaml'); +import fsPromises from 'fs/promises'; +import execa from 'execa'; +import yaml from 'js-yaml'; -module.exports = async (pluginConfig, context) => { +export default async (pluginConfig, context) => { const {logger, nextRelease: {version}} = context; const ch = yaml.load(await fsPromises.readFile("./Chart.yaml")); diff --git a/lib/publish.js b/lib/publish.js index 1184911..1cf9c15 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -1,8 +1,8 @@ -const fsPromises = require('fs').promises; -const yaml = require('js-yaml'); -const execa = require('execa'); +import fsPromises from 'fs/promises'; +import yaml from 'js-yaml'; +import execa from 'execa'; -module.exports = async (pluginConfig, context) => { +export default async (pluginConfig, context) => { const {logger, nextRelease: {version}} = context; const ch = yaml.load(await fsPromises.readFile("./Chart.yaml")); diff --git a/lib/verifyConditions.js b/lib/verifyConditions.js index 455357d..80aa08c 100644 --- a/lib/verifyConditions.js +++ b/lib/verifyConditions.js @@ -1,8 +1,8 @@ -const { URL } = require('url'); -const execa = require('execa'); -const SemanticReleaseError = require("@semantic-release/error"); +import { URL } from 'url'; +import execa from 'execa'; +import SemanticReleaseError from "@semantic-release/error"; -module.exports = async (pluginConfig, context) => { +export default async (pluginConfig, context) => { const {env, logger} = context; const registryURL = parseRegistryURL(pluginConfig.registry, logger); diff --git a/package.json b/package.json index 207570d..038a155 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "0.0.0", "description": "semantic-release plugin for publishing Helm charts to OCI registries", "repository": "github:eshepelyuk/semantic-release-helm-oci", - "main": "index.js", + "exports": "./index.js", + "type": "module", "files": [ "index.js", "lib/**/*.js"