From b5ab93cc82629db9dba21be9d3766c5132253b72 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 12 Jun 2018 13:35:45 +0530 Subject: [PATCH 1/6] Initital working browser build --- .babelrc | 4 +--- todo.js | 11 +++++++++++ webpack.config.js | 8 ++++---- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 todo.js diff --git a/.babelrc b/.babelrc index d6bfc30..c1dec08 100644 --- a/.babelrc +++ b/.babelrc @@ -6,9 +6,7 @@ "modules": false, "targets": { "browsers": [ - "> 1%", - "last 2 versions", - "not ie <= 8" + "last 2 Chrome versions" ] } } diff --git a/todo.js b/todo.js new file mode 100644 index 0000000..c61f364 --- /dev/null +++ b/todo.js @@ -0,0 +1,11 @@ +// @TODO 1. Change babelrc browser support to : +// ``` +// "browsers": [ +// "> 1%", +// "last 2 versions", +// "not ie <= 8" +// ] +// ``` + +// @TODO 2: In webpack, enable uglify +// \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index c37c10f..876d4fd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,10 +22,10 @@ module.exports = { ] }, plugins: [ - new webpack.optimize.UglifyJsPlugin({ - include: /\.min\.js$/, - minimize: true - }) , + // new webpack.optimize.UglifyJsPlugin({ + // include: /\.min\.js$/, + // minimize: true + // }) , new CopyWebpackPlugin([ { from: 'demo/index.html', to: 'dist/' } ]) From 30769198fea6e23f27ced5a4e55cc9544531918a Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 12 Jun 2018 13:43:32 +0530 Subject: [PATCH 2/6] CHange TODO comment style --- todo.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/todo.js b/todo.js index c61f364..09da512 100644 --- a/todo.js +++ b/todo.js @@ -1,11 +1,14 @@ -// @TODO 1. Change babelrc browser support to : -// ``` -// "browsers": [ -// "> 1%", -// "last 2 versions", -// "not ie <= 8" -// ] -// ``` +/* +@TODO 1. Change babelrc browser support to : +``` +"browsers": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ] +``` +*/ -// @TODO 2: In webpack, enable uglify -// \ No newline at end of file +/* +@TODO 2: In webpack, enable uglify +*/ From d2d10965e8a72a9e4c896a13712a61b8f11365bf Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 12 Jun 2018 13:49:40 +0530 Subject: [PATCH 3/6] Fix comment style --- todo.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/todo.js b/todo.js index 09da512..06510df 100644 --- a/todo.js +++ b/todo.js @@ -1,5 +1,6 @@ -/* -@TODO 1. Change babelrc browser support to : +/** + * @todo Change babelrc browser support to support all modern browsers: + ``` "browsers": [ "> 1%", @@ -7,8 +8,9 @@ "not ie <= 8" ] ``` -*/ -/* -@TODO 2: In webpack, enable uglify + */ + +/** +* @todo In webpack, enable uglify */ From 84b2775ca95ecfe12495a5fff7d28f72ea714ae6 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 12 Jun 2018 22:12:42 +0530 Subject: [PATCH 4/6] Reformat --- src/gh.ts | 63 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/gh.ts b/src/gh.ts index 8703b31..db3f968 100644 --- a/src/gh.ts +++ b/src/gh.ts @@ -73,7 +73,7 @@ interface ResponseWithMetaLink { interface ResponseWithDataArrayAndMeta extends ResponseWithDataArray, - ResponseWithMetaLink { } + ResponseWithMetaLink {} interface ResponseFromGetUserRepo extends ResponseWithMetaLink { data: RepoFromGetUserRepo[]; @@ -163,7 +163,7 @@ interface RepoNameWithParentRepo { interface RepoNameWithBranchesAndParent extends RepoNameWithBranches, - RepoNameWithParentRepo { } + RepoNameWithParentRepo {} const username = 'rousan'; @@ -204,13 +204,13 @@ async function fetchRepoNameWithBranches( const branchesResponse: ResponseWithDataArray< BranchFromGetBranches - > = await paginate((tmpFirstParam: Octokit.ReposGetBranchesParams): Promise< + > = await paginate((tmpFirstParam: Octokit.ReposGetBranchesParams): Promise< + ResponseFromGetBranches + > => { + return (octokit.repos.getBranches(tmpFirstParam) as any) as Promise< ResponseFromGetBranches - > => { - return (octokit.repos.getBranches(tmpFirstParam) as any) as Promise< - ResponseFromGetBranches - >; - }, params); + >; + }, params); return { repoName, @@ -319,31 +319,31 @@ async function fetchUserIsNotContributor( const responseFromGetContributors: ResponseWithDataArray< OwnerFromGetContributors - > = await paginate( - async ( - tmpFirstParam: Octokit.ReposGetContributorsParams - ): Promise> => { - // Modify getContributors to return empty contributor data array instead of undefined for empty repos - const response = await ((octokit.repos.getContributors( - tmpFirstParam - ) as any) as Promise); + > = await paginate( + async ( + tmpFirstParam: Octokit.ReposGetContributorsParams + ): Promise> => { + // Modify getContributors to return empty contributor data array instead of undefined for empty repos + const response = await ((octokit.repos.getContributors( + tmpFirstParam + ) as any) as Promise); - let dataNormalized = response.data; - if (dataNormalized === undefined) { - dataNormalized = []; - } + let dataNormalized = response.data; + if (dataNormalized === undefined) { + dataNormalized = []; + } - const responseNormalized: ResponseWithDataArrayAndMeta< - OwnerFromGetContributors - > = { - data: dataNormalized, - meta: response.meta, - }; + const responseNormalized: ResponseWithDataArrayAndMeta< + OwnerFromGetContributors + > = { + data: dataNormalized, + meta: response.meta, + }; - return responseNormalized; - }, - params - ); + return responseNormalized; + }, + params + ); const contributors = responseFromGetContributors.data; @@ -369,7 +369,7 @@ export async function fetchUnusedForkedRepos() { ): Promise => { return (octokit.repos.getForUser(tmpFirstParam) as any) as Promise< ResponseFromGetUserRepo - >; + >; }, params ); @@ -514,7 +514,6 @@ export async function fetchUnusedForkedRepos() { return unusedRepoNames; } - export function runMain() { fetchUnusedForkedRepos().then(unusedRepoNames => { // tslint:disable-next-line:no-console From 06e1133571af6f30ed09edb74f4dd21bddae0d01 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 12 Jun 2018 22:22:13 +0530 Subject: [PATCH 5/6] Add babel-runtime, support default browsers (Closes #1) --- .babelrc | 8 ++++++-- package.json | 1 + src/index.ts | 3 ++- yarn.lock | 12 ++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.babelrc b/.babelrc index c1dec08..a5a06b4 100644 --- a/.babelrc +++ b/.babelrc @@ -3,14 +3,18 @@ [ "env", { + "useBuiltIns": "entry", "modules": false, "targets": { "browsers": [ - "last 2 Chrome versions" + "> 0.5%", + "last 2 versions", + "Firefox ESR", + "not dead" ] } } ], "stage-2" - ] + ], } \ No newline at end of file diff --git a/package.json b/package.json index 66ae5c2..dd78813 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "dependencies": { "@octokit/rest": "^15.6.2", + "babel-polyfill": "^6.26.0", "bottleneck": "^2.3.1", "octonode": "^0.9.2" }, diff --git a/src/index.ts b/src/index.ts index b9ed9bb..20e5a8e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,11 @@ +import 'babel-polyfill'; import { Greeter } from './greeter'; // tslint:disable-next-line:ordered-imports import { fetchUnusedForkedRepos, runMain } from './gh'; export * from './greeter'; // tslint:disable-next-line:only-arrow-functions -(function (currentWindow: Window) { +(function(currentWindow: Window) { // execute when load index.js // tslint:disable-next-line:no-console diff --git a/yarn.lock b/yarn.lock index 66c9058..e52f7d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -792,6 +792,14 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" +babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" + dependencies: + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" + babel-preset-env@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" @@ -4660,6 +4668,10 @@ regenerate@^1.2.1: version "1.4.0" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" +regenerator-runtime@^0.10.5: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" From 98e392294d050818d7304af2e7b4bc1cf14a551d Mon Sep 17 00:00:00 2001 From: bendtherules Date: Wed, 13 Jun 2018 08:50:25 +0530 Subject: [PATCH 6/6] Reformat babelrc --- .babelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index a5a06b4..eec6ce6 100644 --- a/.babelrc +++ b/.babelrc @@ -16,5 +16,5 @@ } ], "stage-2" - ], + ] } \ No newline at end of file