@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
|
-
|
|
143
|
-
var
|
|
144
|
-
|
|
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
|
-
|
|
147
|
-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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()
|