From 61e6be911dd7903f340c6df6150579aefefcf138 Mon Sep 17 00:00:00 2001 From: Luca Castelllone Date: Fri, 15 Dec 2023 16:15:42 +0100 Subject: [PATCH 1/2] Transform default exports to named exports --- src/Database.ts | 2 +- src/Dump.ts | 2 +- src/Initialize.ts | 2 +- src/Package.ts | 2 +- src/Updater.ts | 2 +- src/WpPackage.ts | 4 ++-- src/actions.ts | 12 ++++++------ src/index.ts | 4 ++-- src/utils/axios.ts | 4 +--- src/utils/data.ts | 2 +- src/utils/prompts.ts | 2 +- 11 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/Database.ts b/src/Database.ts index a4ac9a9..bd69716 100644 --- a/src/Database.ts +++ b/src/Database.ts @@ -10,7 +10,7 @@ import type { WPMMconfig } from './types' * * @class Database */ -export default class Database { +export class Database { /** The configuration object. */ protected config: WPMMconfig diff --git a/src/Dump.ts b/src/Dump.ts index f1b4219..0be50da 100644 --- a/src/Dump.ts +++ b/src/Dump.ts @@ -13,7 +13,7 @@ import type { * * @category Model */ -export default class Dump { +export class Dump { /** The base folder of the WordPress installation. */ protected baseFolder: string diff --git a/src/Initialize.ts b/src/Initialize.ts index 79c7591..635c004 100644 --- a/src/Initialize.ts +++ b/src/Initialize.ts @@ -15,7 +15,7 @@ import { getWpVersionCheck } from './utils/axios' * * @class Initialize */ -export default class Initialize { +export class Initialize { /** The path to the WordPress folder. */ private wpFolder: string diff --git a/src/Package.ts b/src/Package.ts index afbebc3..105a66b 100644 --- a/src/Package.ts +++ b/src/Package.ts @@ -12,7 +12,7 @@ import { WPMMconfigPkg, WPMMpaths } from './types' * @class Package * @template Package */ -export default class Package { +export class Package { /** the package info */ public pkgInfo: WPMMconfigPkg diff --git a/src/Updater.ts b/src/Updater.ts index e5dda9d..4c04de1 100644 --- a/src/Updater.ts +++ b/src/Updater.ts @@ -6,7 +6,7 @@ import { UpdateObject, WPMMconfig } from './types' * * @class Updater */ -export default class Updater { +export class Updater { /** THe configuration object. */ config: WPMMconfig diff --git a/src/WpPackage.ts b/src/WpPackage.ts index 2688830..97d843d 100644 --- a/src/WpPackage.ts +++ b/src/WpPackage.ts @@ -1,7 +1,7 @@ import path from 'path' import fs from 'fs' import { renameFolder } from './utils/fs' -import Package from './Package' +import { Package } from './Package' import { replaceDbConstant, replaceDbConstantBool, @@ -16,7 +16,7 @@ import type { WordpressPkg, WPMMpaths } from './types' * @class WpPackage * @extends Package pkgConfig - the configuration object */ -export default class WpPackage extends Package { +export class WpPackage extends Package { public pkgInfo: WordpressPkg /** * Constructs a new instance of the class. diff --git a/src/actions.ts b/src/actions.ts index 32a76e3..dfc1ec1 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,9 +1,9 @@ import { getInfo } from './utils/data' -import Initialize from './Initialize' -import Installer from './Installer' -import Updater from './Updater' -import Dump from './Dump' -import Database from './Database' +import { Initialize } from './Initialize' +import { Installer } from './Installer' +import { Updater } from './Updater' +import { Dump } from './Dump' +import { Database } from './Database' import { WPMMconfig, WPMMpaths } from './types' import { isValidUpdateOptions } from './utils/parsers' import yargs from 'yargs' @@ -17,7 +17,7 @@ import yargs from 'yargs' * * @return {Object} The actions object. */ -export default function actions({ +export function actions({ config, paths, }: { diff --git a/src/index.ts b/src/index.ts index fb64cbe..daa829f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import { getConfig, printTimePassed } from './utils/data' import { hideBin } from 'yargs/helpers' import { getWordPressPaths } from './utils/wordpress' import yargs, { Argv } from 'yargs' -import actions from './actions' +import { actions } from './actions' import { WPMMconfig, WPMMpaths } from './types' /** @var {number} startTime - the time at which the script started. */ @@ -17,7 +17,7 @@ const argv: Argv = yargs(hideBin(process.argv)) * Get the configuration and invoke the actions based on the provided arguments. * @param argv - The command line arguments. */ -export default getConfig(argv) +getConfig(argv) .then( /** @param {WPMMconfig} config - The configuration object for the script. */ (config: WPMMconfig) => { diff --git a/src/utils/axios.ts b/src/utils/axios.ts index b467bde..c331214 100644 --- a/src/utils/axios.ts +++ b/src/utils/axios.ts @@ -39,7 +39,7 @@ const reqOptions = { }, } -const axiosFetch = { +export const axiosFetch = { get: (url: string) => axios.get(url, reqOptions).then(responseBody), post: (url: string, body: object) => axios.post(url, body, reqOptions).then(responseBody), @@ -60,5 +60,3 @@ export const getTemplate = (url: string): Promise<{ data: WPapiTemplateResponse */ export const getWpVersionCheck = (): Promise => axiosFetch.get('https://api.wordpress.org/core/version-check/1.7/') - -export default axiosFetch diff --git a/src/utils/data.ts b/src/utils/data.ts index 61f10b5..569bba6 100644 --- a/src/utils/data.ts +++ b/src/utils/data.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import Initialize from '../Initialize' +import { Initialize } from '../Initialize' import { getTemplate } from './axios' import { isWordpressFolder } from './wordpress' import { DefaultWpInstallFolder, PkgFileName } from '../constants' diff --git a/src/utils/prompts.ts b/src/utils/prompts.ts index bc804a0..2e3028d 100644 --- a/src/utils/prompts.ts +++ b/src/utils/prompts.ts @@ -2,7 +2,7 @@ import inquirer from 'inquirer' import path from 'path' import { DefaultWpInstallFolder, PkgFileName } from '../constants' import { getWordPressPaths } from './wordpress' -import Dump from '../Dump' +import { Dump } from '../Dump' import { WPMMconfig } from '../types' /** From 23ae4d2456d845908a7258dbc78d979cfb4ac8de Mon Sep 17 00:00:00 2001 From: Luca Castelllone Date: Fri, 15 Dec 2023 16:26:23 +0100 Subject: [PATCH 2/2] transform default exports to named exports #2 --- src/Installer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Installer.ts b/src/Installer.ts index 444d2b4..686dd67 100644 --- a/src/Installer.ts +++ b/src/Installer.ts @@ -1,6 +1,6 @@ import { cleanup, makeDir } from './utils/fs' -import Package from './Package' -import WpPackage from './WpPackage' +import { Package } from './Package' +import { WpPackage } from './WpPackage' import { isWPCLIAvailable, runPostInstallCommands } from './utils/commands' import { WPMMconfig, WPMMpaths } from './types' @@ -9,7 +9,7 @@ import { WPMMconfig, WPMMpaths } from './types' * * @class Installer */ -export default class Installer { +export class Installer { /** The configuration object. */ protected config: WPMMconfig