Skip to content

Commit

Permalink
fix: update site-preference-builder import
Browse files Browse the repository at this point in the history
  • Loading branch information
joyet-simon committed Nov 25, 2024
1 parent 5673b85 commit 53db7cb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 8 additions & 1 deletion site_preference_builder/api.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
'use strict';

let fetch;
const API_VERSION = 'v1';

async function loadFetch() {
if (!fetch) {
fetch = (await import('node-fetch')).default;
}
}

exports.getFeePlansFromAPI = async function (baseurl, key) {
const fetch = (await import('node-fetch')).default;
await loadFetch();
const url = `${baseurl}/${API_VERSION}/me/fee-plans?kind=general&only=all&deferred=true`;
try {
const response = await fetch(url, {
Expand Down
21 changes: 18 additions & 3 deletions site_preference_builder/compress.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
/* eslint-disable no-console */
'use strict';

const gulp = require('gulp');
const path = require('path');
require('dotenv').config({
path: path.resolve(__dirname, '../.env')
path: path.resolve(__dirname, '../.env'),
});

const { createDir } = require('./fs');

let deleteSync;
let zip;

/**
* Charge dynamiquement les modules ESM nécessaires
*/
async function loadDependencies() {
if (!deleteSync || !zip) {
const del = await import('del');
deleteSync = del.deleteSync;
zip = (await import('gulp-zip')).default;
}
}

/**
* Create payment processor and payment methods files
*/
Expand Down Expand Up @@ -34,8 +50,7 @@ async function copyServiceFile() {
*/
async function createZipFile() {
console.log('Creating archive');
const { deleteSync } = (await import('del'));
const zip = (await import('gulp-zip')).default;
await loadDependencies(); // Charger les modules ESM nécessaires
deleteSync(['./site_template.zip']);
gulp.src('./metadata/**')
.pipe(zip('site_template.zip'))
Expand Down

0 comments on commit 53db7cb

Please sign in to comment.