@sociallane/elements 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.js +26 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sociallane/elements",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Elementor widgets and elements with Tailwind CSS for SocialLane. WordPress plugin.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -95,7 +95,11 @@ function copyPackage(toDir, filter) {
95
95
  if (!existsSync(toDir)) {
96
96
  mkdirSync(toDir, { recursive: true });
97
97
  }
98
- const defaultFilter = (src) => !src.includes('node_modules');
98
+ const defaultFilter = (src) => {
99
+ // Exclude node_modules within the package (check relative path, not absolute)
100
+ const rel = path.relative(packageRoot, src).split(path.sep).join('/');
101
+ return !rel.includes('node_modules');
102
+ };
99
103
  cpSync(packageRoot, toDir, {
100
104
  recursive: true,
101
105
  filter: filter || defaultFilter,
@@ -103,17 +107,29 @@ function copyPackage(toDir, filter) {
103
107
  }
104
108
 
105
109
  function install(targetPath, minimal) {
106
- const target = targetPath
107
- ? path.resolve(process.cwd(), targetPath)
108
- : path.join(process.cwd(), 'wp-content', 'plugins', 'sociallane-elements');
110
+ const cwd = process.cwd();
111
+ const resolveDefaultTarget = () => {
112
+ if (existsSync(path.join(cwd, 'sociallane-elements.php'))) {
113
+ return cwd;
114
+ }
115
+ if (path.basename(cwd) === 'plugins' && path.basename(path.dirname(cwd)) === 'wp-content') {
116
+ return path.join(cwd, 'sociallane-elements');
117
+ }
118
+ if (path.basename(cwd) === 'wp-content') {
119
+ return path.join(cwd, 'plugins', 'sociallane-elements');
120
+ }
121
+ if (existsSync(path.join(cwd, 'wp-content', 'plugins'))) {
122
+ return path.join(cwd, 'wp-content', 'plugins', 'sociallane-elements');
123
+ }
124
+ return path.join(cwd, 'wp-content', 'plugins', 'sociallane-elements');
125
+ };
126
+ const target = targetPath ? path.resolve(cwd, targetPath) : resolveDefaultTarget();
109
127
 
110
128
  const targetResolved = path.resolve(target);
111
129
  const isSelf = targetResolved === path.resolve(packageRoot) || targetResolved.startsWith(packageRoot + path.sep);
112
130
 
113
131
  console.log('SocialLane Elements installer' + (minimal ? ' (minimal – add widgets with: npx @sociallane/elements add <slug> ...)' : ''));
114
132
  console.log('Target:', target);
115
- console.log('Package root:', packageRoot);
116
- console.log('Package root files:', readdirSync(packageRoot).slice(0, 10).join(', ') + '...');
117
133
 
118
134
  if (isSelf) {
119
135
  console.log('Target is the current package. Running npm install here...');
@@ -123,16 +139,11 @@ function install(targetPath, minimal) {
123
139
  console.log('Copying package...');
124
140
  if (minimal) {
125
141
  copyPackage(target, (src) => {
126
- if (src.includes('node_modules')) {
127
- console.log('EXCLUDE node_modules:', src);
128
- return false;
129
- }
130
142
  const rel = path.relative(packageRoot, src).split(path.sep).join('/');
131
- const exclude = rel === 'packages/widgets' || rel.startsWith('packages/widgets/');
132
- if (exclude) {
133
- console.log('EXCLUDE packages/widgets:', rel);
134
- return false;
135
- }
143
+ // Exclude node_modules within the package (not in parent path)
144
+ if (rel.includes('node_modules')) return false;
145
+ // Exclude packages/widgets for minimal install
146
+ if (rel === 'packages/widgets' || rel.startsWith('packages/widgets/')) return false;
136
147
  return true;
137
148
  });
138
149
  const widgetsDest = path.join(target, 'packages', 'widgets');