Skip to content

Commit

Permalink
get tests passing as es module
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed Nov 21, 2023
1 parent 6afdd2e commit 2eedbfb
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 47 deletions.
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const {defaultTo} = require('lodash');
const AggregateError = require('aggregate-error');
const verifyPluginConfig = require('./lib/verify-config');
const verifyPodAuth = require('./lib/verify-auth');
const verifyCliInstalled = require('./lib/verify-cli-installed');
const verifyPodLint = require('./lib/verify-pod-lint');
const preparePod = require('./lib/prepare');
const publishPod = require('./lib/publish');
import {defaultTo} from 'lodash';
import AggregateError from 'aggregate-error';
import verifyPluginConfig from './lib/verify-config.js';
import verifyPodAuth from './lib/verify-auth.js';
import verifyCliInstalled from './lib/verify-cli-installed.js';
import verifyPodLint from './lib/verify-pod-lint.js';
import preparePod from './lib/prepare.js';
import publishPod from './lib/publish.js';

// Let verified;
let prepared;
Expand Down
2 changes: 1 addition & 1 deletion lib/definitions/errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
EINVALIDPODLINT: ({podLint}) => ({
message: 'Invalid `podLint` option.',
details: `The podLint option, if defined, must be a \`Boolean\`.
Expand Down
6 changes: 3 additions & 3 deletions lib/get-error.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const SemanticReleaseError = require('@semantic-release/error');
const ERROR_DEFINITIONS = require('./definitions/errors');
import SemanticReleaseError from '@semantic-release/error';
import ERROR_DEFINITIONS from './definitions/errors.js';

module.exports = (code, ctx = {}) => {
export default function(code, ctx = {}) {
const {message, details} = ERROR_DEFINITIONS[code](ctx);
return new SemanticReleaseError(message, code, details);
};
4 changes: 2 additions & 2 deletions lib/prepare.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const replaceInFile = require('replace-in-file');
import replaceInFile from 'replace-in-file';

module.exports = async (pluginConfig, context) => {
export default async function(pluginConfig, context) {
const {
cwd,
nextRelease: {version},
Expand Down
4 changes: 2 additions & 2 deletions lib/publish.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const execa = require('execa');
import execa from 'execa';

module.exports = async (pluginConfig, context) => {
export default async function(pluginConfig, context) {
const {
cwd,
env,
Expand Down
8 changes: 4 additions & 4 deletions lib/verify-auth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const execa = require('execa');
const AggregateError = require('aggregate-error');
const getError = require('./get-error');
import execa from 'execa';
import AggregateError from 'aggregate-error';
import getError from './get-error.js';

module.exports = async (pluginConfig, context) => {
export default async function(pluginConfig, context) {
const {cwd, env, stdout, stderr, logger} = context;

logger.log(`Checking if token environment variable set`);
Expand Down
8 changes: 4 additions & 4 deletions lib/verify-cli-installed.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const execa = require('execa');
const AggregateError = require('aggregate-error');
const getError = require('./get-error');
import execa from 'execa';
import AggregateError from 'aggregate-error';
import getError from './get-error.js';

module.exports = async (pluginConfig, context) => {
export default async function(pluginConfig, context) {
const {cwd, env, stdout, stderr, logger} = context;
try {
logger.log(`Verifying 'pod' installed on machine`);
Expand Down
6 changes: 3 additions & 3 deletions lib/verify-config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const {isString, isNil, isBoolean} = require('lodash');
const getError = require('./get-error');
import {isString, isNil, isBoolean} from 'lodash-es';
import getError from './get-error.js';

const VALIDATORS = {
podLint: isBoolean,
podLintArgs: isString,
podPushArgs: isString,
};

module.exports = ({podLint, podLintArgs, podPushArgs}) => {
export default async function({podLint, podLintArgs, podPushArgs}) {
const errors = Object.entries({podLint, podLintArgs, podPushArgs}).reduce(
(errors, [option, value]) =>
!isNil(value) && !VALIDATORS[option](value)
Expand Down
8 changes: 4 additions & 4 deletions lib/verify-pod-lint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const execa = require('execa');
const AggregateError = require('aggregate-error');
const getError = require('./get-error');
import execa from 'execa';
import AggregateError from 'aggregate-error';
import getError from './get-error.js';

module.exports = async (pluginConfig, context) => {
export default async function(pluginConfig, context) {
const {cwd, env, stdout, stderr, logger} = context;

if (!pluginConfig.podLint) {
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Cocoapods publishing plugin for semantic-release ",
"version": "0.0.0-development",
"author": "Levi Bostian (https://github.com/levibostian/)",
"type": "module",
"ava": {
"files": [
"test/**/*.test.js"
Expand All @@ -13,15 +14,15 @@
"url": "https://github.com/levibostian/semantic-release-cocoapods/issues"
},
"dependencies": {
"@semantic-release/error": "^2.2.0",
"aggregate-error": "^3.0.0",
"execa": "^4.0.0",
"lodash": "^4.17.15",
"replace-in-file": "^6.1.0"
"@semantic-release/error": "^4.0.0",
"aggregate-error": "^5.0.0",
"execa": "^8.0.1",
"lodash-es": "^4.17.15",
"replace-in-file": "^7.0.2"
},
"devDependencies": {
"ava": "^3.1.0",
"sinon": "^9.0.0",
"ava": "^5.3.1",
"sinon": "^17.0.1",
"stream-buffers": "^3.0.2"
},
"files": [
Expand Down
14 changes: 8 additions & 6 deletions test/prepare.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const path = require('path');
const test = require('ava');
const {outputFile, readFile} = require('fs-extra');
const {stub} = require('sinon');
const {WritableStreamBuffer} = require('stream-buffers');
const prepare = require('../lib/prepare');
import path from 'path';
import test from 'ava'
import { readFileSync } from 'fs'
import { readFile } from 'fs/promises'
import { outputFile, outputFileSync } from 'fs-extra/esm'
import {stub} from 'sinon';
import {WritableStreamBuffer} from 'stream-buffers';
import prepare from '../lib/prepare.js';

test.beforeEach((t) => {
t.context.log = stub();
Expand Down
6 changes: 3 additions & 3 deletions test/verify-config.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('ava');
const {stub} = require('sinon');
const verify = require('../lib/verify-config');
import test from 'ava';
import {stub} from 'sinon';
import verify from '../lib/verify-config.js';

test.beforeEach((t) => {
// Stub the logger functions
Expand Down

0 comments on commit 2eedbfb

Please sign in to comment.