@wix/vibe-forms-plugin 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2715,7 +2715,7 @@ var require_adm_zip = __commonJS({
2715
2715
  var import_adm_zip = __toESM(require_adm_zip());
2716
2716
 
2717
2717
  // src/constants.ts
2718
- var PLUGIN_FILES_ZIP_URL = "https://static.parastorage.com/services/vibe-forms-plugin-files/0.21.0/forms-plugin-files-files.zip";
2718
+ var PLUGIN_FILES_ZIP_URL = "https://static.parastorage.com/services/vibe-forms-plugin-files/0.24.0/forms-plugin-files-files.zip";
2719
2719
  var VERTICAL_NAME = "forms";
2720
2720
  var FORMS_PLATFORM_APP_DEF_ID = "14ce1214-b278-a7e4-1373-00cebd1bef7c";
2721
2721
 
@@ -2796,7 +2796,7 @@ var installFormsPlatform = async (env) => {
2796
2796
  await installWixApp(FORMS_PLATFORM_APP_DEF_ID, env.WIX_SITE_ID, env.logger);
2797
2797
  env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Installation completed`);
2798
2798
  };
2799
- async function downloadZipFile(url, filePath) {
2799
+ async function downloadZipFile(url, filePath, logger) {
2800
2800
  return new Promise((resolve, reject) => {
2801
2801
  const file = fs__namespace.createWriteStream(filePath);
2802
2802
  const makeRequest = (requestUrl) => {
@@ -2804,7 +2804,7 @@ async function downloadZipFile(url, filePath) {
2804
2804
  if (response.statusCode === 301 || response.statusCode === 302) {
2805
2805
  const location = response.headers.location;
2806
2806
  if (location) {
2807
- console.log(
2807
+ logger.debug(
2808
2808
  `[${VERTICAL_NAME}-plugin-setup] following redirect to: ${location}`
2809
2809
  );
2810
2810
  makeRequest(location);
@@ -2836,20 +2836,72 @@ async function downloadZipFile(url, filePath) {
2836
2836
  makeRequest(url);
2837
2837
  });
2838
2838
  }
2839
- var unzipAndMergePluginFiles = async (env, zipUrl) => {
2840
- console.log(
2839
+ var unzipAndMergeParastoragePluginFiles = async (env, zipUrl) => {
2840
+ env.logger.debug(
2841
2841
  `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from dependency...`
2842
2842
  );
2843
2843
  const zipPath = path__namespace.join(process.cwd(), "picasso-forms-plugin-files.zip");
2844
2844
  const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
2845
2845
  try {
2846
- console.log(
2846
+ env.logger.debug(
2847
2847
  `[${VERTICAL_NAME}-plugin-install] downloading zip file to:`,
2848
- zipPath
2848
+ { zipPath }
2849
+ );
2850
+ await downloadZipFile(zipUrl, zipPath, env.logger);
2851
+ const zip = new import_adm_zip.default(zipPath);
2852
+ env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
2853
+ zip.getEntries().forEach((entry) => {
2854
+ if (!entry.isDirectory) {
2855
+ const entryPath = entry.entryName;
2856
+ const targetPath = path__namespace.join(targetDir, entryPath);
2857
+ const targetDirPath = path__namespace.dirname(targetPath);
2858
+ if (!fs__namespace.existsSync(targetDirPath)) {
2859
+ fs__namespace.mkdirSync(targetDirPath, { recursive: true });
2860
+ }
2861
+ fs__namespace.writeFileSync(targetPath, entry.getData());
2862
+ env.logger.debug(
2863
+ `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
2864
+ );
2865
+ }
2866
+ });
2867
+ env.logger.debug(
2868
+ `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
2869
+ );
2870
+ } catch (error) {
2871
+ env.logger.error(
2872
+ new Error(
2873
+ `[${VERTICAL_NAME}-plugin-install] Error downloading or unzipping plugin files:`
2874
+ ),
2875
+ { error }
2876
+ );
2877
+ throw error;
2878
+ }
2879
+ };
2880
+ var unzipAndMergePluginFiles = async (env, useLocal = false) => {
2881
+ if (useLocal) {
2882
+ return unzipAndMergeLocalPluginFiles(
2883
+ env,
2884
+ "/Users/laurale/vibe-plugins/plugins/forms/vibe-forms-plugin-files/dist/statics/forms-plugin-files-files.zip"
2849
2885
  );
2850
- await downloadZipFile(zipUrl, zipPath);
2886
+ } else {
2887
+ return unzipAndMergeParastoragePluginFiles(env, PLUGIN_FILES_ZIP_URL);
2888
+ }
2889
+ };
2890
+ var unzipAndMergeLocalPluginFiles = async (env, zipPath) => {
2891
+ env.logger.debug(
2892
+ `[${VERTICAL_NAME}-plugin-install] Unzipping plugin files from local file...`
2893
+ );
2894
+ const targetDir = path__namespace.join(env.CODEGEN_APP_ROOT, "src");
2895
+ try {
2896
+ env.logger.debug(
2897
+ `[${VERTICAL_NAME}-plugin-install] Using local zip file:`,
2898
+ { zipPath }
2899
+ );
2900
+ if (!fs__namespace.existsSync(zipPath)) {
2901
+ throw new Error(`Local zip file not found at: ${zipPath}`);
2902
+ }
2851
2903
  const zip = new import_adm_zip.default(zipPath);
2852
- console.log(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
2904
+ env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Unzipping files...`);
2853
2905
  zip.getEntries().forEach((entry) => {
2854
2906
  if (!entry.isDirectory) {
2855
2907
  const entryPath = entry.entryName;
@@ -2859,18 +2911,20 @@ var unzipAndMergePluginFiles = async (env, zipUrl) => {
2859
2911
  fs__namespace.mkdirSync(targetDirPath, { recursive: true });
2860
2912
  }
2861
2913
  fs__namespace.writeFileSync(targetPath, entry.getData());
2862
- console.log(
2914
+ env.logger.debug(
2863
2915
  `[${VERTICAL_NAME}-plugin-install] Extracted: ${targetPath}`
2864
2916
  );
2865
2917
  }
2866
2918
  });
2867
- console.log(
2919
+ env.logger.debug(
2868
2920
  `[${VERTICAL_NAME}-plugin-install] Plugin files unzipped and merged successfully`
2869
2921
  );
2870
2922
  } catch (error) {
2871
- console.error(
2872
- `[${VERTICAL_NAME}-plugin-install] Error downloading or unzipping plugin files:`,
2873
- error
2923
+ env.logger.error(
2924
+ new Error(
2925
+ `[${VERTICAL_NAME}-plugin-install] Error unzipping plugin files:`
2926
+ ),
2927
+ { error }
2874
2928
  );
2875
2929
  throw error;
2876
2930
  }
@@ -2882,7 +2936,7 @@ var install = async (env) => {
2882
2936
  console.log(
2883
2937
  `[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`
2884
2938
  );
2885
- await unzipAndMergePluginFiles(env, PLUGIN_FILES_ZIP_URL);
2939
+ await unzipAndMergePluginFiles(env, false);
2886
2940
  console.log(`[${VERTICAL_NAME}-plugin-install] Installation completed`);
2887
2941
  };
2888
2942
  var formsPlugin = {