Skip to content

Commit

Permalink
Move test & script utils out of /lib (github#17517)
Browse files Browse the repository at this point in the history
* Remove an unused file

* Move authenticate-to-aws to scripts/utils

* Move crowdin-config to tests/utils

* Remove add-frontmatter-to-file

* Move find-unused-assets

* Move git-utils to script/utils

* Move lib/github to script/utils

* Revert "Remove an unused file"

This reverts commit cd93ad846a0354e957359f23124eb0724c9147cf.

* Move find-extraneous-translation-files to script/utils

* We already have tests/helpers

* Rename script/utils => helpers for consistency

* Forgot a path

* Fix path to crowdin-config

Co-authored-by: Chiedo John <[email protected]>
  • Loading branch information
JasonEtco and chiedo authored Jan 29, 2021
1 parent 0e04893 commit 8d4f3e6
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 24 deletions.
8 changes: 0 additions & 8 deletions lib/add-frontmatter-to-file.js

This file was deleted.

2 changes: 1 addition & 1 deletion script/check-s3-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const allVersions = require('../lib/all-versions')
const nonEnterpriseDefaultVersion = require('../lib/non-enterprise-default-version')
const { getS3BucketPathFromVersion, getVersionFromS3BucketPath } = require('../lib/s3-bucket-path-utils')
const patterns = require('../lib/patterns')
const authenticateToAWS = require('../lib/authenticate-to-aws.js')
const authenticateToAWS = require('./helpers/authenticate-to-aws.js')
const readlineSync = require('readline-sync')
const { execSync } = require('child_process')
const enterpriseServerVersions = Object.keys(allVersions).filter(v => v.startsWith('enterprise-server@'))
Expand Down
2 changes: 1 addition & 1 deletion script/delete-unused-staging-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ assert(process.env.HEROKU_API_TOKEN)
const { chain } = require('lodash')
const chalk = require('chalk')
const Heroku = require('heroku-client')
const github = require('../lib/github')()
const github = require('./helpers/github')()
const heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN })
const owner = 'github'
const repo = 'docs-internal'
Expand Down
2 changes: 1 addition & 1 deletion script/graphql/update-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const yaml = require('js-yaml')
const { execSync } = require('child_process')
const graphqlDataDir = path.join(process.cwd(), 'data/graphql')
const graphqlStaticDir = path.join(process.cwd(), 'lib/graphql/static')
const { getContents, listMatchingRefs } = require('../../lib/git-utils')
const { getContents, listMatchingRefs } = require('../helpers/git-utils')
const dataFilenames = require('./utils/data-filenames')
const allVersions = require('../../lib/all-versions')
const processPreviews = require('./utils/process-previews')
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const { difference } = require('lodash')
const walk = require('walk-sync').entries
const languages = require('../lib/languages')
const languages = require('../../lib/languages')

module.exports = function findExtraneousTranslatedFiles () {
const files = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const path = require('path')
const walk = require('walk-sync')
const { execSync } = require('child_process')
const assert = require('assert')
const loadSiteData = require('./site-data')
const { loadPages } = require('./pages')
const patterns = require('./patterns')
const getDataReferences = require('./get-liquid-data-references')
const loadSiteData = require('../../lib/site-data')
const { loadPages } = require('../../lib/pages')
const patterns = require('../../lib/patterns')
const getDataReferences = require('../../lib/get-liquid-data-references')
const imagesPath = '/assets/images'

// these paths should remain in the repo even if they are not referenced directly
Expand Down
2 changes: 1 addition & 1 deletion lib/git-utils.js → script/helpers/git-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const github = require('../lib/github')()
const github = require('./github')()

// https://docs.github.com/rest/reference/git#get-a-reference
async function getCommitSha (owner, repo, ref) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion script/remove-extraneous-translation-files.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

const fs = require('fs')
const findExtraneousFiles = require('../lib/find-extraneous-translation-files')
const findExtraneousFiles = require('./helpers/find-extraneous-translation-files')

// [start-readme]
//
Expand Down
2 changes: 1 addition & 1 deletion script/remove-unused-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const fs = require('fs')
const path = require('path')
const findUnusedAssets = require('../lib/find-unused-assets')
const findUnusedAssets = require('./helpers/find-unused-assets')

// [start-readme]
//
Expand Down
2 changes: 1 addition & 1 deletion script/update-enterprise-dates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const { getContents } = require('../lib/git-utils')
const { getContents } = require('./helpers/git-utils')
const fs = require('fs')
const path = require('path')
const enterpriseDatesFile = path.join(__dirname, '../lib/enterprise-dates.json')
Expand Down
2 changes: 1 addition & 1 deletion script/update-s3cmd-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const authenticateToAWS = require('../lib/authenticate-to-aws.js')
const authenticateToAWS = require('./helpers/authenticate-to-aws.js')

// [start-readme]
//
Expand Down
2 changes: 1 addition & 1 deletion script/upload-images-to-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs')
const path = require('path')
const program = require('commander')
const allVersions = require('../lib/all-versions')
const authenticateToAWS = require('../lib/authenticate-to-aws')
const authenticateToAWS = require('./helpers/authenticate-to-aws')
const nonEnterpriseDefaultVersion = require('../lib/non-enterprise-default-version')
const { getS3BucketPathFromVersion } = require('../lib/s3-bucket-path-utils')
const walk = require('walk-sync')
Expand Down
2 changes: 1 addition & 1 deletion tests/content/crowdin-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const config = require('../../lib/crowdin-config').read()
const config = require('../helpers/crowdin-config').read()
const { loadPages } = require('../../lib/pages')
const ignoredPagePaths = config.files[0].ignore
const ignoredDataPaths = config.files[2].ignore
Expand Down
2 changes: 1 addition & 1 deletion lib/crowdin-config.js → tests/helpers/crowdin-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')
const yaml = require('js-yaml')

const read = function () {
const filename = path.join(__dirname, '../crowdin.yml')
const filename = path.join(__dirname, '../../crowdin.yml')
return yaml.load(fs.readFileSync(filename, 'utf8'), { filename })
}

Expand Down

0 comments on commit 8d4f3e6

Please sign in to comment.