PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.1
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / blocks-v2 / phone-field / tools / sync-intl-tel-input.js
jetformbuilder / modules / blocks-v2 / phone-field / tools Last commit date
sync-intl-tel-input.js 4 months ago
sync-intl-tel-input.js
105 lines
1 // tools/sync-intl-tel-input.js
2 const fs = require('fs');
3 const path = require('path');
4
5 function ensureDir(dir) {
6 fs.mkdirSync(dir, { recursive: true });
7 }
8
9 function exists(p) {
10 return fs.existsSync(p);
11 }
12
13 function rmSafe(targetPath) {
14 if (!exists(targetPath)) return;
15 fs.rmSync(targetPath, { recursive: true, force: true });
16 }
17
18 function copyFile(src, dest) {
19 ensureDir(path.dirname(dest));
20 fs.copyFileSync(src, dest);
21 }
22
23 function copyDir(srcDir, destDir) {
24 if (!exists(srcDir)) return;
25
26 ensureDir(destDir);
27
28 for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
29 const src = path.join(srcDir, entry.name);
30 const dest = path.join(destDir, entry.name);
31
32 if (entry.isDirectory()) copyDir(src, dest);
33 else copyFile(src, dest);
34 }
35 }
36
37 function assertExists(p, label) {
38 if (!exists(p)) {
39 console.error(`[sync] ERROR: Missing ${label}: ${p}`);
40 process.exit(1);
41 }
42 }
43
44 function readJSON(p) {
45 return JSON.parse(fs.readFileSync(p, 'utf8'));
46 }
47
48 // --- Resolve package root ---
49 let pkgJsonPath;
50 try {
51 pkgJsonPath = require.resolve('intl-tel-input/package.json');
52 } catch (e) {
53 console.error('[sync] ERROR: intl-tel-input is not installed. Run: npm i intl-tel-input');
54 process.exit(1);
55 }
56
57 const pkgRoot = path.dirname(pkgJsonPath);
58 const pkgJSON = readJSON(pkgJsonPath);
59 const version = pkgJSON?.version || 'unknown';
60
61 // --- Sources in node_modules ---
62 const srcCss = path.join(pkgRoot, 'build', 'css', 'intlTelInput.min.css');
63 const srcJs = path.join(pkgRoot, 'build', 'js', 'intlTelInputWithUtils.min.js');
64 const srcImg = path.join(pkgRoot, 'build', 'img');
65 const srcI18n = path.join(pkgRoot, 'build', 'js', 'i18n');
66
67 // Ensure critical assets exist
68 assertExists(srcCss, 'CSS intlTelInput.min.css');
69 assertExists(srcJs, 'JS intlTelInputWithUtils.min.js');
70
71 // --- Destinations in plugin ---
72 const pluginRoot = path.resolve(__dirname, '..');
73 const outBase = path.join(pluginRoot, 'assets', 'lib');
74
75 const outCss = path.join(outBase, 'intl-tel-input', 'intlTelInput.min.css');
76 const outJs = path.join(outBase, 'intl-tel-input', 'intlTelInputWithUtils.min.js');
77 const outImg = path.join(outBase, 'img');
78 const outI18n = path.join(outBase, 'intl-tel-input', 'i18n');
79
80 // --- Cleanup (so no leftovers after updates) ---
81 rmSafe(outCss);
82 rmSafe(outJs);
83 rmSafe(outImg);
84 rmSafe(outI18n);
85
86 // Recreate base folders (optional, but clearer)
87 ensureDir(path.dirname(outCss));
88 ensureDir(path.dirname(outJs));
89
90 // --- Copy assets ---
91 copyFile(srcCss, outCss);
92 copyFile(srcJs, outJs);
93 copyDir(srcImg, outImg);
94 copyDir(srcI18n, outI18n);
95
96 // --- Report ---
97 const copied = [];
98 copied.push(path.relative(pluginRoot, outCss));
99 copied.push(path.relative(pluginRoot, outJs));
100 if (exists(outImg)) copied.push(path.relative(pluginRoot, outImg) + '/');
101 if (exists(outI18n)) copied.push(path.relative(pluginRoot, outI18n) + '/');
102
103 console.log(`[sync] intl-tel-input v${version} synced:`);
104 for (const item of copied) console.log(` - ${item}`);
105