public override void Run() { this.Init(); PluginLinker.CopyNativeCode(this.SourcePath, new[] { "c3p", "cordova" }, this.TargetOutputPath); string scriptOutputPath = Path.Combine(this.TargetOutputPath, "www"); this.CopyLibTypeScript(scriptOutputPath); File.Copy( Path.Combine(this.SourcePath, "ts", "node_modules", "cordova.d.ts"), Path.Combine(scriptOutputPath, "cordova.d.ts")); File.Copy( Path.Combine(this.SourcePath, "ts", "node_modules", "es6-promise.d.ts"), Path.Combine(scriptOutputPath, "es6-promise.d.ts")); this.FixTSModuleReferences(scriptOutputPath, false); Utils.CompileTypeScript(scriptOutputPath); this.GeneratePluginXml(this.TargetOutputPath, scriptOutputPath); this.CopyPackageJson(); Utils.PackNpmPackage(this.TargetOutputPath); }
public override void Run() { this.Init(); ClrApi pluginApi = this.MergeApis(this.LoadApis()); PluginLinker.CopyNativeCode(this.SourcePath, null, this.TargetOutputPath); if (this.PluginInfo.WindowsPlatform != null) { string windowsSourcePath = Path.Combine( this.SourcePath, "windows" + (this.windowsLanguage != null ? "-" + this.windowsLanguage : null)); if (Directory.Exists(windowsSourcePath)) { string windowsOutputPath = Path.Combine(this.TargetOutputPath, "windows"); if (!Directory.Exists(windowsOutputPath)) { Directory.CreateDirectory(windowsOutputPath); } PluginLinker.CopyProjectDirectory(windowsSourcePath, windowsOutputPath); } } CordovaPluginLinker.CollectSourceFilesInfo(this.TargetOutputPath, this.PluginInfo); this.CreateAndroidConfigFileInfo(); this.CreateIOSConfigFileInfo(); this.CreateWindowsConfigFileInfo(); this.AddProjectReferences(); string scriptOutputPath = Path.Combine(this.TargetOutputPath, "www"); if (Directory.Exists(scriptOutputPath)) { Directory.Delete(scriptOutputPath, true); } Directory.CreateDirectory(scriptOutputPath); this.CreateTypeScriptBindings( pluginApi, true, false, c3pPluginId + "." + c3pCordovaModuleName, scriptOutputPath); string modulesDirectoryPath = Path.Combine(scriptOutputPath, "node_modules"); Directory.CreateDirectory(modulesDirectoryPath); // This is messy, because Cordova's implementation of module resolution // doesn't respect the 'main' property from the package.json. this.CreateBridgeModuleTypeScriptDefinition(Path.Combine( modulesDirectoryPath, c3pPluginId + "." + c3pCordovaModuleName + ".d.ts")); Utils.ExtractResource( "es6-promise.d.ts", modulesDirectoryPath, c3pPluginId + "." + "es6-promise.d.ts"); foreach (string tsFile in new[] { "NativeObject.ts", "NativeBridge.ts" }) { Utils.ExtractResource(tsFile, modulesDirectoryPath, c3pPluginId + "." + tsFile); string fixTsCode = File.ReadAllText(Path.Combine( modulesDirectoryPath, c3pPluginId + "." + tsFile)); fixTsCode = fixTsCode.Replace("\"es6-promise\"", "\"" + c3pPluginId + ".es6-promise\"") .Replace("\"./NativeObject\"", "\"" + c3pPluginId + ".NativeObject\""); File.WriteAllText( Path.Combine(modulesDirectoryPath, c3pPluginId + "." + tsFile), fixTsCode); } Utils.ExtractResource("tsconfig.json", scriptOutputPath); Utils.CompileTypeScript(scriptOutputPath); Log.Message(Utils.EnsureTrailingSlash(Path.GetFullPath(this.TargetOutputPath))); this.GeneratePluginXml(scriptOutputPath); this.GeneratePackageJson(c3pCordovaPackageName); Utils.PackNpmPackage(this.TargetOutputPath); }