@nativescript/windows 0.1.0-alpha.6 → 0.1.0-alpha.8

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