@sociallane/elements 1.0.2 → 1.0.3
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/package.json +3 -3
- package/scripts/postinstall.js +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sociallane/elements",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Elementor widgets and elements with Tailwind CSS for SocialLane. WordPress plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/Mitch00llK/sociallane-elements.git"
|
|
13
|
+
"url": "git+https://github.com/Mitch00llK/sociallane-elements.git"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"wordpress",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build": "npm run build -w @sociallane/core",
|
|
28
28
|
"build:core": "npm run build -w @sociallane/core",
|
|
29
29
|
"build:all": "npm run build --workspaces --if-present",
|
|
30
|
-
"postinstall": "node scripts/
|
|
30
|
+
"postinstall": "node scripts/postinstall.js",
|
|
31
31
|
"setup": "bash scripts/setup.sh",
|
|
32
32
|
"sync-widgets": "node scripts/sync-widgets.js",
|
|
33
33
|
"reinstall": "rm -rf node_modules && npm install",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script for SocialLane Elements.
|
|
4
|
+
* Runs sync-widgets and build, but skips when installed via npx (to avoid
|
|
5
|
+
* failures in the npx cache where node/npm may not be in PATH).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { spawnSync } from 'child_process';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
|
|
13
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const pluginRoot = path.resolve(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// Skip in npx cache (npm_execpath contains _npx, or we're in a temp/cache folder)
|
|
17
|
+
const npmExecPath = process.env.npm_execpath || '';
|
|
18
|
+
const cwd = process.cwd();
|
|
19
|
+
const isNpxCache =
|
|
20
|
+
npmExecPath.includes('_npx') ||
|
|
21
|
+
cwd.includes('_npx') ||
|
|
22
|
+
cwd.includes('.npm/_cacache') ||
|
|
23
|
+
cwd.includes('node_modules/.cache');
|
|
24
|
+
|
|
25
|
+
if (isNpxCache) {
|
|
26
|
+
// Silent exit - install.js will handle the build in the target directory
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Also skip if this is being installed as a dependency (not the root package)
|
|
31
|
+
const isRootPackage = path.resolve(cwd) === path.resolve(pluginRoot);
|
|
32
|
+
if (!isRootPackage) {
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Run sync-widgets
|
|
37
|
+
console.log('Running sync-widgets...');
|
|
38
|
+
const syncResult = spawnSync('node', [path.join(__dirname, 'sync-widgets.js')], {
|
|
39
|
+
cwd: pluginRoot,
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
});
|
|
42
|
+
if (syncResult.status !== 0) {
|
|
43
|
+
process.exit(syncResult.status || 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Run build
|
|
47
|
+
console.log('Running build...');
|
|
48
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
49
|
+
const buildResult = spawnSync(npmCmd, ['run', 'build'], {
|
|
50
|
+
cwd: pluginRoot,
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
shell: true,
|
|
53
|
+
});
|
|
54
|
+
if (buildResult.status !== 0) {
|
|
55
|
+
process.exit(buildResult.status || 1);
|
|
56
|
+
}
|