├── .gitignore ├── .gitmodules ├── Jenkinsfile ├── README.md ├── app ├── assets │ └── stylesheets │ │ └── index.less ├── controllers │ ├── BaseController.scala │ ├── GitController.scala │ ├── GitInitController.scala │ ├── GithubController.scala │ ├── HomeController.scala │ ├── ParseController.scala │ ├── ProjectController.scala │ ├── SandboxController.scala │ ├── SbtController.scala │ ├── SbtHistoryController.scala │ ├── SbtPublishController.scala │ └── StaticSiteController.scala ├── models │ ├── parse │ │ ├── Importer.scala │ │ ├── ProjectDefinition.scala │ │ ├── Utils.scala │ │ ├── parser │ │ │ ├── TSDefLexical.scala │ │ │ ├── TSDefParser.scala │ │ │ ├── TSTokens.scala │ │ │ └── tree │ │ │ │ └── Tree.scala │ │ └── sc │ │ │ ├── printer │ │ │ ├── Printer.scala │ │ │ ├── PrinterFiles.scala │ │ │ ├── PrinterFilesMulti.scala │ │ │ ├── PrinterFilesSingle.scala │ │ │ └── PrinterHelper.scala │ │ │ ├── transform │ │ │ ├── ExcludedMembers.scala │ │ │ ├── IgnoredPackages.scala │ │ │ ├── ReplacementManager.scala │ │ │ ├── Replacements.scala │ │ │ └── Transformations.scala │ │ │ └── tree │ │ │ ├── ClassSymbol.scala │ │ │ ├── CommentSymbol.scala │ │ │ ├── ContainerSymbol.scala │ │ │ ├── FieldSymbol.scala │ │ │ ├── JSNameable.scala │ │ │ ├── MethodSymbol.scala │ │ │ ├── ModuleSymbol.scala │ │ │ ├── Name.scala │ │ │ ├── PackageSymbol.scala │ │ │ ├── ParamSymbol.scala │ │ │ ├── QualifiedName.scala │ │ │ ├── Symbol.scala │ │ │ ├── TypeAliasSymbol.scala │ │ │ ├── TypeParamSymbol.scala │ │ │ └── TypeRef.scala │ └── sandbox │ │ └── SandboxTask.scala ├── services │ ├── file │ │ └── FileService.scala │ ├── git │ │ └── GitService.scala │ ├── github │ │ └── GithubService.scala │ ├── parse │ │ ├── ClassReferenceService.scala │ │ ├── PrinterService.scala │ │ ├── TypeScriptFiles.scala │ │ └── TypeScriptImport.scala │ ├── project │ │ ├── ProjectDetailsService.scala │ │ ├── ProjectOutput.scala │ │ └── ProjectService.scala │ └── sbt │ │ ├── SbtHistoryService.scala │ │ ├── SbtResultParser.scala │ │ └── SbtService.scala ├── utils │ ├── Application.scala │ ├── Config.scala │ ├── DateUtils.scala │ ├── JsonSerializers.scala │ ├── Logging.scala │ ├── NumberUtils.scala │ └── web │ │ ├── ErrorHandler.scala │ │ ├── FormUtils.scala │ │ ├── LoggingFilter.scala │ │ ├── RequestHandler.scala │ │ └── WebFilters.scala └── views │ ├── component │ └── filterForm.scala.html │ ├── detail.scala.html │ ├── error │ ├── badRequest.scala.html │ ├── notFound.scala.html │ └── serverError.scala.html │ ├── git │ ├── detail.scala.html │ ├── form.scala.html │ ├── result.scala.html │ ├── results.scala.html │ └── test.scala.html │ ├── github │ ├── detail.scala.html │ ├── list.scala.html │ └── test.scala.html │ ├── history │ ├── compare.scala.html │ ├── detail.scala.html │ └── list.scala.html │ ├── home.scala.html │ ├── layout │ ├── basic.scala.html │ ├── materialize.scala.html │ └── simple.scala.html │ ├── list.scala.html │ ├── metrics.scala.html │ ├── parse │ ├── process.scala.html │ └── processAll.scala.html │ ├── problems.scala.html │ ├── project │ ├── update.scala.html │ └── updateAll.scala.html │ ├── sandbox │ ├── list.scala.html │ ├── metrics.scala.html │ └── run.scala.html │ └── sbt │ ├── form.scala.html │ ├── list.scala.html │ ├── published.scala.html │ ├── result.scala.html │ └── results.scala.html ├── build.sbt ├── conf ├── application.conf ├── logback.xml ├── replacement │ ├── accounting.txt │ ├── ace.txt │ ├── alertify.txt │ ├── algoliasearch.txt │ ├── apexjs.txt │ ├── arbiter.txt │ ├── async.txt │ ├── atmosphere.txt │ ├── awssdk.txt │ ├── bcrypt.txt │ ├── bigint.txt │ ├── biginteger.txt │ ├── bootstrap.txt │ ├── calq.txt │ ├── combokeys.txt │ ├── css.txt │ ├── datgui.txt │ ├── debug.txt │ ├── each.txt │ ├── expectations.txt │ ├── faker.txt │ ├── flipsnap.txt │ ├── gamepad.txt │ ├── github.txt │ ├── hashids.txt │ ├── jquery.txt │ ├── jqueryui.txt │ ├── less.txt │ ├── materializecss.txt │ ├── matterjs.txt │ ├── mixpanel.txt │ ├── msgpack.txt │ ├── nedb.txt │ ├── node.txt │ ├── pad.txt │ ├── phaser.txt │ ├── phaserpixi.txt │ ├── pixijs.txt │ ├── qwest.txt │ ├── react.txt │ ├── redis.txt │ ├── resumablejs.txt │ ├── title.txt │ ├── traverson.txt │ ├── trim.txt │ ├── ts │ │ ├── react.ts.txt │ │ └── sharepoint.ts.txt │ └── xterm.txt └── routes ├── project ├── Dependencies.scala ├── Packaging.scala ├── Server.scala ├── Shared.scala ├── build.properties └── plugins.sbt ├── public ├── browserconfig.xml ├── images │ └── ui │ │ └── favicon │ │ └── favicon.png └── manifest.json ├── scalastyle-config.xml └── util └── ts-dump ├── cycles.ts ├── index.ts ├── package-lock.json ├── package.json ├── props.ts ├── tests └── jQuery.d.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | project/project/target 3 | project/target 4 | target 5 | tmp 6 | .history 7 | dist 8 | /.idea 9 | /*.iml 10 | /out 11 | /backup 12 | /data 13 | /util/ts-dump/node_modules 14 | /.idea_modules 15 | /.classpath 16 | /.project 17 | /RUNNING_PID 18 | /.settings 19 | 20 | buildinfo.properties 21 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "util/scala-js-template"] 2 | path = util/scala-js-template 3 | url = git@github.com:DefinitelyScala/scala-js-template.git 4 | [submodule "typescript/DefinitelyTyped"] 5 | path = typescript/DefinitelyTyped 6 | url = https://github.com/DefinitelyTyped/DefinitelyTyped.git 7 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | 4 | stages { 5 | stage('Build') { 6 | steps { 7 | sh "sbt -no-colors -batch dist" 8 | archiveArtifacts artifacts: '**/target/universal/*.zip', fingerprint: true 9 | } 10 | } 11 | 12 | stage('Publish') { 13 | steps { 14 | echo 'TODO: publish' 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # scala-js-typescript 2 | 3 | # ARCHIVED: These projects are superceded by the great work at https://github.com/ScalablyTyped/Distribution 4 | 5 | A TypeScript-to-Scala.js converter. 6 | Designed for parsing http://definitelytyped.org, powers http://definitelyscala.com. 7 | 8 | ## Running 9 | 10 | Right now the whole thing is a giant Scala Play Framework app that expects certain directories. 11 | You can run the freshly-cloned repository with `SBT`, but there won't be any projects. 12 | 13 | To run for your own TypeScript definitions ("foo") rename your `index.d.ts` to "foo.ts", and place it in `./data/typescript`. 14 | Then start the app with `sbt run`, and open [http://localhost:9000](). Select `Project List`, then your project. 15 | You'll see options to parse, build, and publish your project. Publishing won't work. 16 | 17 | In order to create the SBT project, you'll need to clone `git@github.com:DefinitelyScala/scala-js-template.git` into `./util`. 18 | 19 | More documentation coming soon. Feel free to email me if you run into trouble. 20 | 21 | ## License 22 | 23 | The code is licensed under [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0). 24 | -------------------------------------------------------------------------------- /app/assets/stylesheets/index.less: -------------------------------------------------------------------------------- 1 | // General Styles 2 | body { 3 | display: flex; 4 | min-height: 100vh; 5 | flex-direction: column; 6 | background-color: #fcfcfc; 7 | } 8 | 9 | main { 10 | flex: 1 0 auto; 11 | .static-container { 12 | margin-top: 16px; 13 | } 14 | } 15 | 16 | // Helper Classes 17 | .initially-hidden { 18 | display: none; 19 | } 20 | 21 | .black { 22 | background-color: #555 !important; 23 | } 24 | 25 | .pre-wrap { 26 | white-space: pre-wrap; 27 | font-family: 'roboto-mono'; 28 | } 29 | 30 | .clear { 31 | clear: both; 32 | } 33 | 34 | // Materialize Tweaks 35 | .flash-error, .flash-success { 36 | text-align: center; 37 | padding: 10px; 38 | margin-bottom: 10px; 39 | } 40 | 41 | .flash-error { 42 | background-color: #ffffff; 43 | color: #8b0000; 44 | } 45 | 46 | footer.page-footer { 47 | margin: 0; 48 | padding: 0; 49 | .footer-copyright { 50 | height: 48px; 51 | line-height: 48px; 52 | padding: 0 10px; 53 | } 54 | } 55 | 56 | .right-link { 57 | float: right !important; 58 | margin-right: 0 !important; 59 | } 60 | 61 | .flash { 62 | padding: 20px; 63 | margin-bottom: 10px; 64 | } 65 | 66 | .btn, .btn-flat { 67 | text-transform: none !important; 68 | } 69 | 70 | // Navbar 71 | nav { 72 | a { 73 | -webkit-font-smoothing: antialiased; 74 | } 75 | } 76 | 77 | .nb-container { 78 | height: 48px; 79 | } 80 | 81 | #topnav { 82 | height: 48px; 83 | line-height: 48px; 84 | 85 | #user-dropdown-toggle { 86 | height: 48px; 87 | line-height: 48px; 88 | } 89 | 90 | .button-collapse i { 91 | height: 48px; 92 | line-height: 48px; 93 | } 94 | 95 | .brand-logo { 96 | margin: 0 14px; 97 | font-size: 1.6rem; 98 | 99 | &.center { 100 | margin: 0; 101 | } 102 | 103 | i { 104 | height: 48px; 105 | line-height: 48px; 106 | margin-right: 6px; 107 | } 108 | } 109 | 110 | @media only screen and (max-width: 992px) { 111 | .brand-logo { 112 | margin: 0; 113 | } 114 | } 115 | 116 | @media only screen and (max-width: 600px) { 117 | .fa-search { 118 | margin-top: 20px; 119 | } 120 | } 121 | 122 | .menu-toggle { 123 | font-size: 190%; 124 | margin-left: 12px; 125 | float: left; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /app/controllers/BaseController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api.mvc._ 4 | import utils.{ Application, Logging } 5 | 6 | import scala.concurrent.Future 7 | 8 | abstract class BaseController() extends InjectedController with Logging { 9 | def app: Application 10 | 11 | def act(action: String)(block: Request[AnyContent] => Future[Result]) = Action.async { implicit request => 12 | block(request) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/controllers/GitController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.twirl.api.Html 4 | import services.git.GitService 5 | import services.github.GithubService 6 | import services.project.ProjectService 7 | import utils.Application 8 | import scala.concurrent.ExecutionContext.Implicits.global 9 | 10 | import scala.concurrent.Future 11 | import scala.util.control.NonFatal 12 | 13 | @javax.inject.Singleton 14 | class GitController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 15 | def detail(key: String) = act(s"git.$key") { implicit request => 16 | val projectDir = ProjectService.projectDir(key) 17 | val dir = projectDir / ".git" 18 | if (dir.exists) { 19 | Future.successful(Ok(views.html.git.detail(key))) 20 | } else { 21 | Future.successful(Ok(Html(s"Git repo for [$key] not found."))) 22 | } 23 | } 24 | 25 | def status(key: String) = act(s"git.status.$key") { implicit request => 26 | val result = GitService.status(ProjectService.projectDir(key)) 27 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 28 | } 29 | 30 | def statusAll() = act("git.status.all") { implicit request => 31 | val results = githubService.listRepos(includeTemplates = false).map { repos => 32 | repos.map { repo => 33 | val key = repo.name.stripPrefix("scala").stripPrefix("-").stripPrefix("js") 34 | val result = try { 35 | GitService.status(ProjectService.projectDir(key)) 36 | } catch { 37 | case NonFatal(x) => (-1, x.toString) 38 | } 39 | val out = result._2.split('\n').filterNot(_.contains("../../../")).mkString("\n") 40 | (repo.name, result._1, out) 41 | } 42 | } 43 | results.map(r => Ok(views.html.git.results(r))) 44 | } 45 | 46 | def reset(key: String) = act(s"git.reset.$key") { implicit request => 47 | val result = GitService.reset(ProjectService.projectDir(key)) 48 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 49 | } 50 | 51 | def resetAll() = act("git.reset.all") { implicit request => 52 | val results = githubService.listRepos(includeTemplates = false).map { repos => 53 | repos.map { repo => 54 | val key = repo.name.stripPrefix("scala").stripPrefix("-").stripPrefix("js") 55 | val result = try { 56 | GitService.reset(ProjectService.projectDir(key)) 57 | } catch { 58 | case NonFatal(x) => (-1, x.toString) 59 | } 60 | val out = result._2.split('\n').filterNot(_.contains("../../../")).mkString("\n") 61 | (repo.name, result._1, out) 62 | } 63 | } 64 | results.map(r => Ok(views.html.git.results(r))) 65 | } 66 | 67 | def commitForm() = act(s"project.commit.form") { implicit request => 68 | Future.successful(Ok(views.html.git.form())) 69 | } 70 | 71 | def commit(key: String) = act(s"git.commit.$key") { implicit request => 72 | val msg = request.body.asFormUrlEncoded.get("msg").mkString 73 | val result = GitService.commit(ProjectService.projectDir(key), Nil, msg) 74 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 75 | } 76 | 77 | def commitAll() = act("git.commit.all") { implicit request => 78 | val body = request.body.asFormUrlEncoded.get 79 | val msg = body("msg").mkString 80 | val files = body.getOrElse("files", Nil) 81 | val results = githubService.listRepos(includeTemplates = false).map { repos => 82 | repos.map { repo => 83 | val key = repo.name.stripPrefix("scala-js-") 84 | val result = GitService.commit(ProjectService.projectDir(key), files, msg) 85 | (repo.name, result._1, result._2) 86 | } 87 | } 88 | results.map(r => Ok(views.html.git.results(r))) 89 | } 90 | 91 | def push(key: String) = act(s"git.update.$key") { implicit request => 92 | val result = GitService.push(ProjectService.projectDir(key)) 93 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 94 | } 95 | 96 | def pushAll() = act("git.push.all") { implicit request => 97 | val results = githubService.listRepos(includeTemplates = false).map { repos => 98 | repos.map { repo => 99 | val key = repo.name.stripPrefix("scala").stripPrefix("-").stripPrefix("js") 100 | val result = GitService.push(ProjectService.projectDir(key)) 101 | (repo.name, result._1, result._2) 102 | } 103 | } 104 | results.map(r => Ok(views.html.git.results(r))) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/controllers/GitInitController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import models.parse.ProjectDefinition 4 | import scala.concurrent.ExecutionContext.Implicits.global 5 | import services.git.GitService 6 | import services.github.GithubService 7 | import services.project.{ ProjectDetailsService, ProjectService } 8 | import utils.Application 9 | 10 | import scala.concurrent.Future 11 | 12 | @javax.inject.Singleton 13 | class GitInitController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 14 | def createAll(q: Option[String]) = act("git.create.all") { implicit request => 15 | val projects = ProjectDetailsService.getAll(q, Some("norepo")) 16 | val results = projects.map { project => 17 | val projectDir = ProjectService.projectDir(project.key) 18 | val dir = projectDir / ".git" 19 | if (dir.exists) { 20 | project.key + ": Skipping invalid project with repo." 21 | } else { 22 | val result = GitService.init(projectDir) 23 | project.key + ": " + result._2 24 | } 25 | } 26 | Future.successful(Ok("Ok:\n\n" + results.mkString("\n"))) 27 | } 28 | 29 | def create(key: String) = act(s"git.create.$key") { implicit request => 30 | val projectDir = ProjectService.projectDir(key) 31 | val dir = projectDir / ".git" 32 | if (dir.exists) { 33 | throw new IllegalStateException(s"Git repo already exists for [$key].") 34 | } else { 35 | val result = GitService.init(projectDir) 36 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 37 | } 38 | } 39 | 40 | def addRemote(key: String) = act(s"git.add.remote.$key") { implicit request => 41 | val projectDir = ProjectService.projectDir(key) 42 | val result = GitService.addRemote(projectDir) 43 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 44 | } 45 | 46 | def firstCommit(key: String) = act(s"git.first.commit.$key") { implicit request => 47 | val projectDir = ProjectService.projectDir(key) 48 | val result = GitService.firstCommit(projectDir) 49 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 50 | } 51 | 52 | def secondCommit(key: String) = act(s"git.second.commit.$key") { implicit request => 53 | val projectDir = ProjectService.projectDir(key) 54 | val result = GitService.secondCommit(projectDir) 55 | Future.successful(Ok(views.html.git.result(key, result._1, result._2))) 56 | } 57 | 58 | def thirdCommit(key: String) = act(s"git.third.commit.$key") { implicit request => 59 | val projectDir = ProjectService.projectDir(key) 60 | val result = GitService.thirdCommit(projectDir) 61 | Future.successful(Ok(views.html.git.result(key, result._1, result._2, Some("Publish" -> controllers.routes.SbtPublishController.publish(key))))) 62 | } 63 | 64 | def fullInit(key: String) = act(s"git.full.init.$key") { implicit request => 65 | val projectDir = ProjectService.projectDir(key) 66 | val dir = projectDir / ".git" 67 | if (dir.exists) { 68 | throw new IllegalStateException(s"Git repo already exists for [$key].") 69 | } else { 70 | GitService.init(projectDir) 71 | } 72 | 73 | val proj = ProjectDefinition.fromJson(ProjectService.outDirFor(key)) 74 | 75 | githubService.create("scala-js-" + proj.keyNormalized, proj.description).map { result => 76 | GitService.addRemote(projectDir) 77 | GitService.firstCommit(projectDir) 78 | val result4 = GitService.secondCommit(projectDir) 79 | 80 | Ok(views.html.git.result(key, result4._1, result4._2, Some("Third" -> controllers.routes.GitInitController.thirdCommit(key)))) 81 | } 82 | } 83 | 84 | def initCommitsAll(q: Option[String]) = act("git.create.all") { implicit request => 85 | val projects = ProjectDetailsService.getAll(q, Some("built")) 86 | val results = projects.map { project => 87 | val projectDir = ProjectService.projectDir(project.key) 88 | val commitCount = GitService.commitCount(projectDir) 89 | if (commitCount == 0) { 90 | val proj = ProjectDefinition.fromJson(ProjectService.outDirFor(project.key)) 91 | githubService.create("scala-js-" + proj.keyNormalized, proj.description).map { result => 92 | GitService.addRemote(projectDir) 93 | GitService.firstCommit(projectDir) 94 | GitService.secondCommit(projectDir) 95 | } 96 | project.key + ": GO!" 97 | } else { 98 | project.key + ": Skip." 99 | } 100 | } 101 | Future.successful(Ok(s"Ok (${results.size}):\n\n" + results.mkString("\n"))) 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/controllers/GithubController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import models.parse.ProjectDefinition 4 | import scala.concurrent.ExecutionContext.Implicits.global 5 | import play.twirl.api.Html 6 | import services.git.GitService 7 | import services.github.GithubService 8 | import services.project.{ ProjectDetailsService, ProjectService } 9 | import utils.Application 10 | 11 | import scala.concurrent.Future 12 | 13 | @javax.inject.Singleton 14 | class GithubController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 15 | def list = act(s"github.list") { implicit request => 16 | githubService.listRepos().map { repos => 17 | Ok(views.html.github.list(repos)) 18 | } 19 | } 20 | 21 | def mergeAll = act(s"github.merge") { implicit request => 22 | githubService.listRepos().map { repos => 23 | val result = repos.map { repo => 24 | val dir = ProjectService.projectDir(repo.name.stripPrefix("scala-js-")) 25 | if (!dir.exists) { 26 | dir.createDirectory() 27 | } 28 | val gitDir = dir / ".git" 29 | val ret = gitDir.exists 30 | if (ret) { 31 | log.info(s"Skipping existing github repository for [${repo.name}].") 32 | } else { 33 | log.info(s"Merging github repository for [${repo.name}].") 34 | val parent = dir.parent 35 | dir.delete(swallowIOExceptions = true) 36 | GitService.cloneRepo(parent, repo.name) 37 | } 38 | ret 39 | } 40 | Ok(Html(s"Ok: ${result.filterNot(x => x).size} github repos merged, ${result.count(x => x)} already present.")) 41 | } 42 | } 43 | 44 | def detail(key: String) = act(s"github.$key") { implicit request => 45 | githubService.detail(key).map { 46 | case Some(repo) => Ok(views.html.github.detail(repo)) 47 | case None => Ok(Html(s"Github repo for [$key] not found.")) 48 | } 49 | } 50 | 51 | def create(key: String) = act(s"github.create.$key") { implicit request => 52 | val proj = ProjectDefinition.fromJson(ProjectService.outDirFor(key)) 53 | githubService.create("scala-js-" + proj.keyNormalized, proj.description).map { result => 54 | Redirect(controllers.routes.GithubController.detail(proj.keyNormalized)) 55 | } 56 | } 57 | 58 | def createAll(q: Option[String]) = act(s"github.create.all") { implicit request => 59 | githubService.listRepos().flatMap { repos => 60 | val projects = ProjectDetailsService.getAll(q, Some("built"), repos) 61 | val results = projects.flatMap { project => 62 | val projectDir = ProjectService.projectDir(project.key) 63 | //val commitCount = GitService.commitCount(projectDir) 64 | if (project.repo && !project.github) { 65 | val proj = ProjectDefinition.fromJson(ProjectService.outDirFor(project.key)) 66 | Some(proj) 67 | } else { 68 | None 69 | } 70 | } 71 | val f = results.foldLeft(Future.successful(Seq.empty[ProjectDefinition])) { (ret, p) => 72 | ret.flatMap { r => 73 | githubService.create("scala-js-" + p.keyNormalized, p.description).map { result => 74 | val projectDir = ProjectService.projectDir(p.key) 75 | GitService.addRemote(projectDir) 76 | GitService.push(projectDir) 77 | log.info(p.key + "!!!!!!!!!") 78 | r :+ p 79 | } 80 | } 81 | } 82 | f.map(results => Ok(s"Ok (${results.size}):\n\n" + results.mkString("\n"))) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/controllers/HomeController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import models.parse.ProjectDefinition 4 | import scala.concurrent.ExecutionContext.Implicits.global 5 | import play.api.mvc.Action 6 | import services.github.GithubService 7 | import services.parse.TypeScriptFiles 8 | import services.project.{ ProjectDetailsService, ProjectService } 9 | import utils.Application 10 | 11 | import scala.concurrent.Future 12 | 13 | @javax.inject.Singleton 14 | class HomeController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 15 | def home(q: Option[String], filter: Option[String]) = act("home") { implicit request => 16 | val srcDirs = TypeScriptFiles.list(q) 17 | val keys = srcDirs.sorted.map(x => x -> ProjectDefinition.normalize(x)) 18 | 19 | Future.successful(Ok(views.html.home(q, filter, keys, app.config.debug))) 20 | } 21 | 22 | def list(q: Option[String], filter: Option[String]) = act("home") { implicit request => 23 | githubService.listRepos(includeTemplates = false).map { repos => 24 | val details = ProjectDetailsService.getAll(q, filter, repos) 25 | Ok(views.html.list(q, filter, details, app.config.debug)) 26 | } 27 | } 28 | 29 | def problems() = act("problems") { implicit request => 30 | githubService.listRepos(includeTemplates = false).map { repos => 31 | val details = ProjectDetailsService.getAll(None, None, repos) 32 | Ok(views.html.problems(details, app.config.debug)) 33 | } 34 | } 35 | 36 | def detail(key: String) = act(s"home.$key") { implicit request => 37 | githubService.detail(key).map { github => 38 | val outDir = ProjectService.outDirFor(key) 39 | val projectDir = ProjectService.projectDir(key) 40 | val hasRepo = (projectDir / ".git").exists 41 | val details = if (outDir.exists) { 42 | ProjectDefinition.fromJson(outDir) 43 | } else { 44 | ProjectDefinition(key, "?", "?", "?", "?") 45 | } 46 | 47 | Ok(views.html.detail(key, details, outDir, projectDir, hasRepo, github, app.config.debug)) 48 | } 49 | } 50 | 51 | def untrail(path: String) = Action.async { 52 | Future.successful(MovedPermanently(s"/$path")) 53 | } 54 | 55 | def externalLink(url: String) = act("external.link") { implicit request => 56 | Future.successful(Redirect(if (url.startsWith("http")) { url } else { "http://" + url })) 57 | } 58 | 59 | def ping(timestamp: Long) = act("ping") { implicit request => 60 | Future.successful(Ok(timestamp.toString)) 61 | } 62 | 63 | def robots() = act("robots") { implicit request => 64 | Future.successful(Ok("User-agent: *\nDisallow: /")) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/controllers/ParseController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import models.parse.parser.tree.DeclTree 4 | import play.twirl.api.Html 5 | import services.parse.{ PrinterService, TypeScriptFiles, TypeScriptImport } 6 | import utils.Application 7 | 8 | import scala.concurrent.Future 9 | 10 | object ParseController { 11 | case class Result(key: String, content: String, tree: Option[List[DeclTree]], text: Seq[String]) 12 | } 13 | 14 | @javax.inject.Singleton 15 | class ParseController @javax.inject.Inject() (override val app: Application) extends BaseController { 16 | def copy() = act(s"parse.copy") { implicit request => 17 | val result = TypeScriptFiles.copy() 18 | Future.successful(Ok(Html(s"[${utils.NumberUtils.withCommas(result._1 - result._2)}] of [${utils.NumberUtils.withCommas(result._1)}] files copied."))) 19 | } 20 | 21 | def parseAll(q: Option[String]) = act("parse.all") { implicit request => 22 | val scripts = TypeScriptFiles.list(q) 23 | val results = scripts.par.map { script => 24 | log.info(s"Parsing [$script]...") 25 | parseLibrary(script) 26 | }.seq 27 | Future.successful(Ok(views.html.parse.processAll(results, app.config.debug))) 28 | } 29 | 30 | def parse(key: String) = act(s"parse.$key") { implicit request => 31 | val result = parseLibrary(key) 32 | Future.successful(Ok(views.html.parse.process(key, result.content, result.tree, None, result.text, app.config.debug))) 33 | } 34 | 35 | def refresh(key: String) = act(s"refresh.$key") { implicit request => 36 | val result = parseLibrary(key) 37 | if (result.tree.isDefined) { 38 | Future.successful(Redirect(controllers.routes.ProjectController.update(key))) 39 | } else { 40 | throw new IllegalStateException("Cannot parse.") 41 | } 42 | } 43 | 44 | def parseLibrary(key: String) = { 45 | val content = TypeScriptFiles.getContent(key) 46 | val tree = TypeScriptImport.parse(content) 47 | val res = tree match { 48 | case Right(t) => Some(t) -> PrinterService(key, t).export() 49 | case Left(err) => None -> Seq("Error: " + err) 50 | } 51 | ParseController.Result(key, content, res._1, res._2) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/controllers/ProjectController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import services.file.FileService 4 | import services.project.ProjectService 5 | import utils.Application 6 | 7 | import scala.concurrent.Future 8 | 9 | @javax.inject.Singleton 10 | class ProjectController @javax.inject.Inject() (override val app: Application, parseController: ParseController) extends BaseController { 11 | def update(key: String) = act(s"update.$key") { implicit request => 12 | val created = ProjectService(key).update() 13 | Future.successful(Ok(views.html.project.update(key, created, app.config.debug))) 14 | } 15 | 16 | def updateAll(q: Option[String]) = act("project.all") { implicit request => 17 | val outDirs = FileService.getDir("out").list.filter(_.isDirectory).filter(_.name.contains(q.getOrElse(""))).toSeq 18 | val results = outDirs.par.map(outDir => outDir.name -> ProjectService(outDir.name).update()).seq 19 | Future.successful(Ok(views.html.project.updateAll(results, app.config.debug))) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/controllers/SandboxController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import akka.util.Timeout 4 | import models.sandbox.SandboxTask 5 | import scala.concurrent.ExecutionContext.Implicits.global 6 | import utils.Application 7 | 8 | import scala.concurrent.Future 9 | import scala.concurrent.duration._ 10 | 11 | @javax.inject.Singleton 12 | class SandboxController @javax.inject.Inject() (override val app: Application) extends BaseController { 13 | implicit val timeout = Timeout(10.seconds) 14 | 15 | def list = act("sandbox.list") { implicit request => 16 | Future.successful(Ok(views.html.sandbox.list())) 17 | } 18 | 19 | def sandbox(key: String) = act("sandbox." + key) { implicit request => 20 | val sandbox = SandboxTask.withName(key) 21 | sandbox.run(app).map { result => 22 | Ok(views.html.sandbox.run(sandbox, result)) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/controllers/SbtController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import better.files.File 4 | import services.github.GithubService 5 | import services.project.ProjectService 6 | import services.sbt.{ SbtHistoryService, SbtResultParser, SbtService } 7 | import utils.Application 8 | 9 | import scala.concurrent.Future 10 | 11 | @javax.inject.Singleton 12 | class SbtController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 13 | def list(q: Option[String]) = act(s"sbt.list") { implicit request => 14 | val statuses = SbtHistoryService.statuses() 15 | Future.successful(Ok(views.html.sbt.list(q, statuses))) 16 | } 17 | 18 | def last(key: String) = act(s"sbt.last") { implicit request => 19 | val status = SbtHistoryService.status(key) 20 | val result = SbtResultParser.parse(status) 21 | Future.successful(Ok(views.html.sbt.result(key, result, status.contentAsString))) 22 | } 23 | 24 | def clean(key: String) = act(s"sbt.build.$key") { implicit request => 25 | val projectDir = ProjectService.projectDir(key) 26 | val buildResult = SbtService.clean(projectDir) 27 | val result = SbtResultParser.Result(key, Nil, Nil, Nil) 28 | Future.successful(Ok(views.html.sbt.result(key, result, buildResult._2))) 29 | } 30 | 31 | def build(key: String) = act(s"sbt.build.$key") { implicit request => 32 | val projectDir = ProjectService.projectDir(key) 33 | if (projectDir.exists) { 34 | val buildResult = SbtService.build(projectDir) 35 | val status = SbtHistoryService.status(key) 36 | val result = SbtResultParser.parse(status) 37 | Future.successful(Ok(views.html.sbt.result(key, result, buildResult._2))) 38 | } else { 39 | throw new IllegalStateException(s"No project found for [$key].") 40 | } 41 | } 42 | 43 | def buildForm(q: Option[String]) = act(s"sbt.build.all") { implicit request => 44 | Future.successful(Ok(views.html.sbt.form(q))) 45 | } 46 | 47 | private[this] def test(f: File, start: Option[String]) = { 48 | val name = f.name.stripPrefix("scala-js-") 49 | if (start.exists(_ > name)) { 50 | (f.name, 0, "Skipped") 51 | } else { 52 | if (name == "clone" || name == "notify") { 53 | (f.name, 0, "Ignored") 54 | } else { 55 | val x = SbtService.build(f) 56 | (f.name, x._1, x._2) 57 | } 58 | } 59 | } 60 | 61 | def formatAll(q: Option[String]) = act(s"sbt.build.all") { implicit request => 62 | val projects = ProjectService.list(q) 63 | val result = projects.map { x => 64 | val ret = SbtService.format(x) 65 | (x.name, ret._1, ret._2) 66 | }.seq 67 | Future.successful { 68 | log.info(s"Formatted [${result.size}] projects.") 69 | Ok(views.html.sbt.results(result)) 70 | } 71 | } 72 | 73 | def buildAll(q: Option[String], start: Option[String]) = act(s"sbt.build.all") { implicit request => 74 | val projects = ProjectService.list(q).sortBy(_.path) 75 | val result = projects.map(x => test(x, start)).seq 76 | Future.successful { 77 | log.info(s"Processed [${result.size}] projects, with [${result.count(_._2 == 0)}] passing and [${result.count(_._2 != 0)}] failing.") 78 | Ok(views.html.sbt.results(result)) 79 | } 80 | } 81 | 82 | def cleanAll(q: Option[String]) = act(s"sbt.clean.all") { implicit request => 83 | val projects = ProjectService.list(q) 84 | val result = projects.map { x => 85 | val ret = SbtService.clean(x) 86 | (x.name, ret._1, ret._2) 87 | } 88 | Future.successful { 89 | log.info(s"Processed [${result.size}] projects, with [${result.count(_._2 == 0)}] passing and [${result.count(_._2 != 0)}] failing.") 90 | Ok(views.html.sbt.results(result)) 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/controllers/SbtHistoryController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import services.github.GithubService 4 | import services.sbt.SbtHistoryService 5 | import utils.Application 6 | 7 | import scala.concurrent.Future 8 | 9 | @javax.inject.Singleton 10 | class SbtHistoryController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 11 | def list() = act(s"sbt.history") { implicit request => 12 | val result = SbtHistoryService.list() 13 | Future.successful(Ok(views.html.history.list(result))) 14 | } 15 | 16 | def compare() = act(s"sbt.history.compare") { implicit request => 17 | val files = request.queryString.getOrElse("q", Nil).toList 18 | files match { 19 | case lName :: rName :: Nil => 20 | val lSeq = SbtHistoryService.read(lName) 21 | val rSeq = SbtHistoryService.read(rName) 22 | val keys = (lSeq.map(_._1) ++ rSeq.map(_._1)).distinct.sorted 23 | Future.successful(Ok(views.html.history.compare(keys, lName, lSeq.toMap, rName, rSeq.toMap))) 24 | case _ => throw new IllegalStateException(s"Invalid [q] param: [${files.mkString(", ")}].") 25 | } 26 | 27 | } 28 | 29 | def write() = act(s"sbt.history.write") { implicit request => 30 | SbtHistoryService.write() 31 | Future.successful(Redirect(routes.SbtHistoryController.list())) 32 | } 33 | 34 | def detail(key: String) = act(s"sbt.history.detail") { implicit request => 35 | val result = SbtHistoryService.read(key) 36 | Future.successful(Ok(views.html.history.detail(key, result))) 37 | } 38 | 39 | def delete(key: String) = act(s"sbt.history.delete") { implicit request => 40 | SbtHistoryService.delete(key) 41 | Future.successful(Redirect(routes.SbtHistoryController.list())) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/controllers/SbtPublishController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api.libs.ws.WSClient 4 | import services.github.GithubService 5 | import services.project.{ ProjectDetailsService, ProjectService } 6 | import services.sbt.{ SbtResultParser, SbtService } 7 | import utils.Application 8 | import scala.concurrent.ExecutionContext.Implicits.global 9 | 10 | import scala.concurrent.Future 11 | 12 | @javax.inject.Singleton 13 | class SbtPublishController @javax.inject.Inject() (override val app: Application, githubService: GithubService, wsClient: WSClient) extends BaseController { 14 | private[this] val key = "href=\":scala-js-" 15 | 16 | private[this] def getPublishedJars = { 17 | val mFuture = wsClient.url("https://dl.bintray.com/definitelyscala/maven/com/definitelyscala/").get 18 | wsClient.url("https://jcenter.bintray.com/com/definitelyscala/").get.flatMap { jRsp => 19 | val j = jRsp.body.split('\n').flatMap { line => 20 | line.indexOf(key) match { 21 | case -1 => None 22 | case x => Some(line.substring(x + key.length, line.indexOf("_sjs"))) 23 | } 24 | } 25 | mFuture.map { mRsp => 26 | val m = mRsp.body.split('\n').flatMap { line => 27 | line.indexOf(key) match { 28 | case -1 => None 29 | case x => Some(line.substring(x + key.length, line.indexOf("_sjs"))) 30 | } 31 | } 32 | m -> j 33 | } 34 | } 35 | } 36 | 37 | def list() = act(s"publish.list") { implicit request => 38 | getPublishedJars.flatMap { publishedKeys => 39 | githubService.listRepos().map { repos => 40 | val repoKeys = repos.map(_.key) 41 | 42 | val keys = (publishedKeys._1 ++ publishedKeys._2 ++ repoKeys).distinct.sorted 43 | 44 | Ok(views.html.sbt.published(keys, repoKeys.toSet, publishedKeys._1.toSet, publishedKeys._2.toSet)) 45 | } 46 | } 47 | } 48 | 49 | def publish(key: String) = act(s"sbt.publish.$key") { implicit request => 50 | val projectDir = ProjectService.projectDir(key) 51 | if (projectDir.exists) { 52 | val publishResult = SbtService.publish(projectDir) 53 | 54 | val result = SbtResultParser.Result(key, Nil, Nil, Nil) 55 | 56 | Future.successful(Ok(views.html.sbt.result(key, result, publishResult._2))) 57 | } else { 58 | throw new IllegalStateException(s"No project found for [$key].") 59 | } 60 | } 61 | 62 | def publishAll(q: Option[String]) = act(s"sbt.publish.all") { implicit request => 63 | getPublishedJars.flatMap { publishedKeys => 64 | githubService.listRepos().map { repos => 65 | val deetSet = ProjectDetailsService.getAll(q = None, filter = Some("built"), repos = repos).filter(_.github).map(_.key).toSet 66 | val results = repos.map { repo => 67 | val f = ProjectService.projectDir(repo.key) 68 | if (deetSet(repo.key)) { 69 | val x = SbtService.publish(f) 70 | (f.name, x._1, x._2) 71 | } else { 72 | (f.name, 0, "Skipped") 73 | } 74 | } 75 | Ok(views.html.sbt.results(results)) 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/controllers/StaticSiteController.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import better.files._ 4 | import models.parse.ProjectDefinition 5 | import scala.concurrent.ExecutionContext.Implicits.global 6 | import play.twirl.api.Html 7 | import services.file.FileService 8 | import services.github.GithubService 9 | import utils.Application 10 | 11 | @javax.inject.Singleton 12 | class StaticSiteController @javax.inject.Inject() (override val app: Application, githubService: GithubService) extends BaseController { 13 | private[this] def htmlFor(projName: String, definition: ProjectDefinition) = { 14 | s"""
@result18 |
@result._314 |
@result12 |
@result12 |
Project | 11 |@lName | 12 |@rName | 13 |
---|---|---|
@key | 22 |@lVal.map(_.toString).getOrElse("-") | 23 |@rVal.map(_.toString).getOrElse("-") | 24 |
Project | 41 |@lName | 42 |@rName | 43 |
---|---|---|
@key | 49 |@l.get(key).map(_.toString).getOrElse("-") | 50 |@r.get(key).map(_.toString).getOrElse("-") | 51 |
@entries.count(_._2) passing, @entries.count(!_._2) failing.
11 |Key | 27 |Out | 28 |Project | 29 |Build | 30 |Publish | 31 |Repo | 32 |Github | 33 |
---|---|---|---|---|---|---|
39 | @detail.key 40 | | 41 |42 | 43 | @if(detail.parsed) { } else { } 44 | 45 | | 46 |47 | 48 | @if(detail.project) { } else { } 49 | 50 | | 51 |52 | @if(detail.built) { } else { } 53 | | 54 |55 | ... 56 | | 57 |58 | @if(detail.repo) { } else { } 59 | | 60 |@if(detail.github) { 61 | 62 | } else { 63 | 64 | } | 65 |
@json6 |
@output.mkString("\n")
@definitions
@definitionsJson
@content
@result.text
@json3 | -------------------------------------------------------------------------------- /app/views/sandbox/run.scala.html: -------------------------------------------------------------------------------- 1 | @(s: models.sandbox.SandboxTask, result: models.sandbox.SandboxTask.Result)( 2 | implicit request: Request[AnyContent], session: Session, flash: Flash 3 | )@layout.simple(title = s"${s.name} Result") { 4 |
@result.result
Key | 18 |Repo | 19 |Maven | 20 |JCenter | 21 |
---|---|---|---|
@key | 27 |@if(repos(key)) { } else { } | 28 |@if(m(key)) { } else { } | 29 |@if(j(key)) { } else { } | 30 |
@err.content20 | } 21 |
@output24 |
@result._3
(object: {}): object is ReactElement
; 18 | function isValidElement
(object: object): ReactElement
;
19 | =
20 | setState ;
28 | props: Readonly ;
29 | =
30 | (props: P & { children?: ReactNode }, context?: any): ReactElement, callback?: () => any): void;
21 | setState, callback?: () => any): void;
22 | =
23 | setState, callback?: () => any): void;
24 | setState, callback?: () => any): void;
25 |
26 | =
27 | props: Readonly<{ children?: ReactNode }> & Readonly