@nativescript/windows 0.1.0-alpha.7 → 0.1.0-alpha.9

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.
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.IO;
3
+ using System.Linq;
3
4
  using System.Runtime.InteropServices;
4
5
  using System.Text.Json;
5
6
 
@@ -139,30 +140,63 @@ namespace __PROJECT_NAME__
139
140
  private static string ResolveEntryScriptPath()
140
141
  {
141
142
  var baseDir = AppContext.BaseDirectory;
142
- var defaultLower = Path.Combine(baseDir, "app", "main.js");
143
- var defaultUpper = Path.Combine(baseDir, "App", "main.js");
144
- var packageJsonPath = Path.Combine(baseDir, "package.json");
143
+ // EXE lives in <project>/bin/; webpack bundle lives in <project>/app/.
144
+ var parentDir = Path.GetDirectoryName(
145
+ baseDir.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar))
146
+ ?? baseDir;
145
147
 
146
- if (!File.Exists(packageJsonPath))
147
- return File.Exists(defaultLower) ? defaultLower : defaultUpper;
148
+ // Candidate app directories: sibling of bin/ first, then directly under baseDir.
149
+ var appDirCandidates = new[]
150
+ {
151
+ Path.Combine(parentDir, "app"),
152
+ Path.Combine(parentDir, "App"),
153
+ Path.Combine(baseDir, "app"),
154
+ Path.Combine(baseDir, "App"),
155
+ };
156
+
157
+ string packageJsonPath = null;
158
+ string resolvedBaseDir = null;
159
+ foreach (var dir in appDirCandidates)
160
+ {
161
+ var candidate = Path.Combine(dir, "package.json");
162
+ if (File.Exists(candidate))
163
+ {
164
+ packageJsonPath = candidate;
165
+ resolvedBaseDir = dir;
166
+ break;
167
+ }
168
+ }
169
+
170
+ // Also accept package.json at the project root (parent of bin/).
171
+ if (packageJsonPath == null && File.Exists(Path.Combine(parentDir, "package.json")))
172
+ {
173
+ packageJsonPath = Path.Combine(parentDir, "package.json");
174
+ resolvedBaseDir = parentDir;
175
+ }
176
+
177
+ string Fallback() =>
178
+ appDirCandidates.Select(d => Path.Combine(d, "bundle.js")).FirstOrDefault(File.Exists);
179
+
180
+ if (packageJsonPath == null)
181
+ return Fallback();
148
182
 
149
183
  try
150
184
  {
151
185
  var config = ParsePackageConfig(packageJsonPath);
152
186
  if (!string.IsNullOrWhiteSpace(config.WindowsMain))
153
187
  {
154
- var p = ResolveScriptPath(baseDir, config.WindowsMain);
188
+ var p = ResolveScriptPath(resolvedBaseDir, config.WindowsMain);
155
189
  if (p != null) return p;
156
190
  }
157
191
  if (!string.IsNullOrWhiteSpace(config.Main))
158
192
  {
159
- var p = ResolveScriptPath(baseDir, config.Main);
193
+ var p = ResolveScriptPath(resolvedBaseDir, config.Main);
160
194
  if (p != null) return p;
161
195
  }
162
196
  }
163
197
  catch { }
164
198
 
165
- return File.Exists(defaultLower) ? defaultLower : defaultUpper;
199
+ return Fallback();
166
200
  }
167
201
 
168
202
  private static RuntimePackageConfig ParsePackageConfig(string packageJsonPath)
@@ -181,12 +215,16 @@ namespace __PROJECT_NAME__
181
215
  {
182
216
  if (string.IsNullOrWhiteSpace(scriptPath)) return null;
183
217
  var normalized = scriptPath.Replace('/', Path.DirectorySeparatorChar);
184
- var direct = Path.IsPathRooted(normalized) ? normalized : Path.Combine(baseDir, normalized);
185
- if (File.Exists(direct)) return direct;
186
- var appLower = Path.Combine(baseDir, "app", normalized);
187
- if (File.Exists(appLower)) return appLower;
188
- var appUpper = Path.Combine(baseDir, "App", normalized);
189
- return File.Exists(appUpper) ? appUpper : null;
218
+ foreach (var candidate in new[] { normalized, normalized + ".js" })
219
+ {
220
+ var direct = Path.IsPathRooted(candidate) ? candidate : Path.Combine(baseDir, candidate);
221
+ if (File.Exists(direct)) return direct;
222
+ var appLower = Path.Combine(baseDir, "app", candidate);
223
+ if (File.Exists(appLower)) return appLower;
224
+ var appUpper = Path.Combine(baseDir, "App", candidate);
225
+ if (File.Exists(appUpper)) return appUpper;
226
+ }
227
+ return null;
190
228
  }
191
229
 
192
230
  public void Dispose()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/windows",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "NativeScript for using Windows v8",
5
5
  "repository": {
6
6
  "type": "git",