Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from CommonJS to ESM #6651

Merged
merged 51 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f99b272
Switch shields.io package to module type
PyvesB May 23, 2021
483cc96
Run Putout convert-commonjs-to-esm with require and exports rules
PyvesB May 23, 2021
819a676
Remove incorrect default modifier for named exports
PyvesB May 23, 2021
1a939f6
Fix incorrect array imports
PyvesB May 23, 2021
489a814
Fix logo loading
PyvesB May 23, 2021
a254090
Replace __dirname and __filename
PyvesB May 23, 2021
c7dba90
Fix config loading
PyvesB May 23, 2021
1593bcd
Switch to asynchronous service loading
PyvesB Jun 1, 2021
9032572
Fix load issues with service classes
PyvesB Jun 6, 2021
183d0e0
Fix service test loading and running
PyvesB Jun 16, 2021
2a8b1e9
Fix core tests
PyvesB Jun 19, 2021
2d2f720
Fix entrypoint test
PyvesB Jun 19, 2021
ad6a1fc
Fix integration tests
PyvesB Jun 19, 2021
7c4781d
Remove strict linting rule
PyvesB Jun 20, 2021
6295041
Fix Dangerfile
PyvesB Jun 20, 2021
6ab7cb5
Update documentation
PyvesB Jun 20, 2021
b0de9eb
Remove remaining 'use strict'
PyvesB Jun 20, 2021
626ffa5
Fix new gradle-plugin-portal service
PyvesB Jun 20, 2021
fabf736
Fix Gatsby files
PyvesB Jun 20, 2021
17bd0a6
Fix linting issues
PyvesB Jun 20, 2021
3fb195c
Run Prettier
PyvesB Jun 20, 2021
c461cb1
Ignore LGTM alert
PyvesB Jun 20, 2021
4b23b29
Move call to readAllStdinSync earlier during initialisation
PyvesB Jun 20, 2021
47f6b4f
Merge branch 'master' into commonjs-to-esm
PyvesB Jun 21, 2021
58c76da
Merge branch 'master' into commonjs-to-esm
PyvesB Jun 27, 2021
15fa8cb
Attempt moving Gatsby files to .cjs extension
PyvesB Jun 27, 2021
56328ce
Revert "Attempt moving Gatsby files to .cjs extension"
PyvesB Jun 28, 2021
779b717
Attempt to fix Gatsby build
PyvesB Jul 3, 2021
a6fe22e
Exclude Prettier from Gatsby folders
PyvesB Jul 3, 2021
7d1393c
Exclude ESLint from Gatsby folders
PyvesB Jul 3, 2021
0b8ac0d
Remove now redundant nodemonConfig exclusion
PyvesB Jul 3, 2021
4fc3067
Switch Danger file back to CommonJS
PyvesB Jul 3, 2021
43ab8e5
Fix frontend tests
PyvesB Jul 3, 2021
027cc8d
Merge branch 'master' into commonjs-to-esm
PyvesB Jul 3, 2021
528044f
Fix newly added services
PyvesB Jul 3, 2021
3e837bf
Attempt fixing e2e tests
PyvesB Jul 3, 2021
078db82
Fix URL import
PyvesB Jul 5, 2021
d72301d
Attempt to point Heroku to the right directory
PyvesB Jul 5, 2021
f381fcb
Revert "Attempt to point Heroku to the right directory"
PyvesB Jul 5, 2021
f45e48c
Move generated Gatsby files one level up for Heroku buildpack
PyvesB Jul 6, 2021
fc9dc78
Error for e2e test highly unhelpful, use advanced debugging technique
PyvesB Jul 6, 2021
55217f4
Revert "Error for e2e test highly unhelpful, use advanced debugging t…
PyvesB Jul 6, 2021
98c56d0
Update to more recent Cypress image
PyvesB Jul 6, 2021
a045c87
Merge remote-tracking branch 'upstream/master' into commonjs-to-esm
PyvesB Jul 6, 2021
f82abaf
Move frontend files from within build script
PyvesB Jul 7, 2021
9c82e01
Remove no longer needed try/catch block
PyvesB Jul 7, 2021
9697ac1
Narrow down Gatsby .gitignore
PyvesB Jul 8, 2021
b465b83
Document unusual import style
PyvesB Jul 8, 2021
b4660d4
Merge branch 'master' into commonjs-to-esm
PyvesB Jul 8, 2021
813cbc3
Migrate new Wikiapiary badge
PyvesB Jul 8, 2021
bae618b
Remove require-hacker dependency
PyvesB Jul 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ jobs:

e2e:
docker:
- image: cypress/base:14
- image: cypress/base:14.16.0
steps:
- checkout

Expand Down
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/build
/coverage
/__snapshots__
/public
public
badge-maker/node_modules/
!.github/
1 change: 0 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ rules:
# Shields additions.
no-var: 'error'
prefer-const: 'error'
strict: 'error'
arrow-body-style: ['error', 'as-needed']
no-extension-in-require/main: 'error'
object-shorthand: ['error', 'properties']
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ service-definitions.yml
!/config/local*.template.yml

# Gatsby
/.cache
/public
.cache
PyvesB marked this conversation as resolved.
Show resolved Hide resolved
public

# Cypress
/cypress/videos/
Expand Down
1 change: 0 additions & 1 deletion .mocharc-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ require:
- '@babel/polyfill'
- '@babel/register'
- mocha-yaml-loader
- frontend/mocha-ignore-pngs
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package.json
package-lock.json
/__snapshots__
/.next
/.cache
.cache
PyvesB marked this conversation as resolved.
Show resolved Hide resolved
/api-docs
/build
/public
public
/coverage
private/*.json
/.nyc_output
Expand Down
14 changes: 6 additions & 8 deletions core/badge-urls/make-badge-url.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

const { URL } = require('url')
const queryString = require('query-string')
const { compile } = require('path-to-regexp')
import url from 'url'
PyvesB marked this conversation as resolved.
Show resolved Hide resolved
PyvesB marked this conversation as resolved.
Show resolved Hide resolved
import queryString from 'query-string'
import { compile } from 'path-to-regexp'

function badgeUrlFromPath({
baseUrl = '',
Expand Down Expand Up @@ -147,13 +145,13 @@ function dynamicBadgeUrl({
function rasterRedirectUrl({ rasterUrl }, badgeUrl) {
// Ensure we're always using the `rasterUrl` by using just the path from
// the request URL.
const { pathname, search } = new URL(badgeUrl, 'https://bogus.test')
const result = new URL(pathname, rasterUrl)
const { pathname, search } = new url.URL(badgeUrl, 'https://bogus.test')
const result = new url.URL(pathname, rasterUrl)
paulmelnikow marked this conversation as resolved.
Show resolved Hide resolved
result.search = search
return result
}

module.exports = {
export {
badgeUrlFromPath,
badgeUrlFromPattern,
encodeField,
Expand Down
8 changes: 3 additions & 5 deletions core/badge-urls/make-badge-url.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict'

const { test, given } = require('sazerac')
const {
import { test, given } from 'sazerac'
import {
badgeUrlFromPath,
badgeUrlFromPattern,
encodeField,
staticBadgeUrl,
queryStringStaticBadgeUrl,
dynamicBadgeUrl,
} = require('./make-badge-url')
} from './make-badge-url.js'

describe('Badge URL generation functions', function () {
test(badgeUrlFromPath, () => {
Expand Down
6 changes: 1 addition & 5 deletions core/badge-urls/path-helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

// Escapes `t` using the format specified in
// <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129>
function escapeFormat(t) {
Expand All @@ -13,6 +11,4 @@ function escapeFormat(t) {
)
}

module.exports = {
escapeFormat,
}
export { escapeFormat }
6 changes: 2 additions & 4 deletions core/badge-urls/path-helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const { test, given } = require('sazerac')
const { escapeFormat } = require('./path-helpers')
import { test, given } from 'sazerac'
import { escapeFormat } from './path-helpers.js'

describe('Badge URL helper functions', function () {
test(escapeFormat, () => {
Expand Down
8 changes: 3 additions & 5 deletions core/base-service/auth-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

const { URL } = require('url')
const { InvalidParameter } = require('./errors')
import { URL } from 'url'
import { InvalidParameter } from './errors.js'

class AuthHelper {
constructor(
Expand Down Expand Up @@ -207,4 +205,4 @@ class AuthHelper {
}
}

module.exports = { AuthHelper }
export { AuthHelper }
10 changes: 4 additions & 6 deletions core/base-service/auth-helper.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

const { expect } = require('chai')
const { test, given, forCases } = require('sazerac')
const { AuthHelper } = require('./auth-helper')
const { InvalidParameter } = require('./errors')
import { expect } from 'chai'
import { test, given, forCases } from 'sazerac'
import { AuthHelper } from './auth-helper.js'
import { InvalidParameter } from './errors.js'

describe('AuthHelper', function () {
describe('constructor checks', function () {
Expand Down
12 changes: 5 additions & 7 deletions core/base-service/base-graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
* @module
*/

'use strict'

const { print } = require('graphql/language/printer')
const BaseService = require('./base')
const { InvalidResponse, ShieldsRuntimeError } = require('./errors')
const { parseJson } = require('./json')
import { print } from 'graphql/language/printer.js'
import BaseService from './base.js'
import { InvalidResponse, ShieldsRuntimeError } from './errors.js'
import { parseJson } from './json.js'

function defaultTransformErrors(errors) {
return new InvalidResponse({ prettyMessage: errors[0].message })
Expand Down Expand Up @@ -93,4 +91,4 @@ class BaseGraphqlService extends BaseService {
}
}

module.exports = BaseGraphqlService
export default BaseGraphqlService
14 changes: 6 additions & 8 deletions core/base-service/base-graphql.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict'

const Joi = require('joi')
const { expect } = require('chai')
const gql = require('graphql-tag')
const sinon = require('sinon')
const BaseGraphqlService = require('./base-graphql')
const { InvalidResponse } = require('./errors')
import Joi from 'joi'
import { expect } from 'chai'
import gql from 'graphql-tag'
import sinon from 'sinon'
import BaseGraphqlService from './base-graphql.js'
import { InvalidResponse } from './errors.js'

const dummySchema = Joi.object({
requiredString: Joi.string().required(),
Expand Down
8 changes: 3 additions & 5 deletions core/base-service/base-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
* @module
*/

'use strict'

const BaseService = require('./base')
const { parseJson } = require('./json')
import BaseService from './base.js'
import { parseJson } from './json.js'

/**
* Services which query a JSON endpoint should extend BaseJsonService
Expand Down Expand Up @@ -54,4 +52,4 @@ class BaseJsonService extends BaseService {
}
}

module.exports = BaseJsonService
export default BaseJsonService
10 changes: 4 additions & 6 deletions core/base-service/base-json.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

const Joi = require('joi')
const { expect } = require('chai')
const sinon = require('sinon')
const BaseJsonService = require('./base-json')
import Joi from 'joi'
import { expect } from 'chai'
import sinon from 'sinon'
import BaseJsonService from './base-json.js'

const dummySchema = Joi.object({
requiredString: Joi.string().required(),
Expand Down
20 changes: 9 additions & 11 deletions core/base-service/base-static.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict'

const makeBadge = require('../../badge-maker/lib/make-badge')
const BaseService = require('./base')
const {
import makeBadge from '../../badge-maker/lib/make-badge.js'
import BaseService from './base.js'
import {
serverHasBeenUpSinceResourceCached,
setCacheHeadersForStaticResource,
} = require('./cache-headers')
const { makeSend } = require('./legacy-result-sender')
const { MetricHelper } = require('./metric-helper')
const coalesceBadge = require('./coalesce-badge')
const { prepareRoute, namedParamsForMatch } = require('./route')
} from './cache-headers.js'
import { makeSend } from './legacy-result-sender.js'
import { MetricHelper } from './metric-helper.js'
import coalesceBadge from './coalesce-badge.js'
import { prepareRoute, namedParamsForMatch } from './route.js'

module.exports = class BaseStaticService extends BaseService {
export default class BaseStaticService extends BaseService {
static register({ camp, metricInstance }, serviceConfig) {
const { regex, captureNames } = prepareRoute(this.route)

Expand Down
12 changes: 5 additions & 7 deletions core/base-service/base-svg-scraping.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* @module
*/

'use strict'

// See available emoji at http://emoji.muan.co/
const emojic = require('emojic')
const BaseService = require('./base')
const trace = require('./trace')
const { InvalidResponse } = require('./errors')
import emojic from 'emojic'
import BaseService from './base.js'
import trace from './trace.js'
import { InvalidResponse } from './errors.js'

const defaultValueMatcher = />([^<>]+)<\/text><\/g>/
const leadingWhitespace = /(?:\r\n\s*|\r\s*|\n\s*)/g
Expand Down Expand Up @@ -90,4 +88,4 @@ class BaseSvgScrapingService extends BaseService {
}
}

module.exports = BaseSvgScrapingService
export default BaseSvgScrapingService
12 changes: 5 additions & 7 deletions core/base-service/base-svg-scraping.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict'

const { expect } = require('chai')
const sinon = require('sinon')
const Joi = require('joi')
const makeBadge = require('../../badge-maker/lib/make-badge')
const BaseSvgScrapingService = require('./base-svg-scraping')
import { expect } from 'chai'
import sinon from 'sinon'
import Joi from 'joi'
import makeBadge from '../../badge-maker/lib/make-badge.js'
import BaseSvgScrapingService from './base-svg-scraping.js'

const schema = Joi.object({
message: Joi.string().required(),
Expand Down
14 changes: 6 additions & 8 deletions core/base-service/base-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
* @module
*/

'use strict'

// See available emoji at http://emoji.muan.co/
const emojic = require('emojic')
const fastXmlParser = require('fast-xml-parser')
const BaseService = require('./base')
const trace = require('./trace')
const { InvalidResponse } = require('./errors')
import emojic from 'emojic'
import fastXmlParser from 'fast-xml-parser'
import BaseService from './base.js'
import trace from './trace.js'
import { InvalidResponse } from './errors.js'

/**
* Services which query a XML endpoint should extend BaseXmlService
Expand Down Expand Up @@ -68,4 +66,4 @@ class BaseXmlService extends BaseService {
}
}

module.exports = BaseXmlService
export default BaseXmlService
10 changes: 4 additions & 6 deletions core/base-service/base-xml.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

const Joi = require('joi')
const { expect } = require('chai')
const sinon = require('sinon')
const BaseXmlService = require('./base-xml')
import Joi from 'joi'
import { expect } from 'chai'
import sinon from 'sinon'
import BaseXmlService from './base-xml.js'

const dummySchema = Joi.object({
requiredString: Joi.string().required(),
Expand Down
14 changes: 6 additions & 8 deletions core/base-service/base-yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* @module
*/

'use strict'

const emojic = require('emojic')
const yaml = require('js-yaml')
const BaseService = require('./base')
const { InvalidResponse } = require('./errors')
const trace = require('./trace')
import emojic from 'emojic'
import yaml from 'js-yaml'
import BaseService from './base.js'
import { InvalidResponse } from './errors.js'
import trace from './trace.js'

/**
* Services which query a YAML endpoint should extend BaseYamlService
Expand Down Expand Up @@ -72,4 +70,4 @@ class BaseYamlService extends BaseService {
}
}

module.exports = BaseYamlService
export default BaseYamlService
10 changes: 4 additions & 6 deletions core/base-service/base-yaml.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

const Joi = require('joi')
const { expect } = require('chai')
const sinon = require('sinon')
const BaseYamlService = require('./base-yaml')
import Joi from 'joi'
import { expect } from 'chai'
import sinon from 'sinon'
import BaseYamlService from './base-yaml.js'

const dummySchema = Joi.object({
requiredString: Joi.string().required(),
Expand Down
Loading