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

repo sync #606

Merged
merged 5 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ Runs tests. Equivalent of `npm test`.

## Additional scripts

### [`anonymize-branch.js`](anonymize-branch.js)

Flatten all the commits in the current branch into a single anonymized @Octomerger commit

Usage: script/anonymize-branch.js <new-commit-message> [base-branch] Example: script/anonymize-branch.js "nothing to see here" If the optional [base-branch] argument is omitted, it will default to `main`

---


### [`archive-enterprise-version.js`](archive-enterprise-version.js)

Run this script during the Enterprise deprecation process to download static copies of all pages for the oldest supported Enterprise version. See the Enterprise deprecation issue template for instructions.
Expand Down Expand Up @@ -270,6 +279,19 @@ Usage $ script/new-versioning/main
---


### [`new-versioning/update-not-fpt-conditionals.js`](new-versioning/update-not-fpt-conditionals.js)

Run this script to update these Liquid conditionals:

{% if currentVersion != 'free-pro-team@latest' %}

to:

{% if enterpriseServerVersions contains currentVersion %}

---


### [`new-versioning/update-products-yml.js`](new-versioning/update-products-yml.js)


Expand Down Expand Up @@ -307,15 +329,7 @@ This script is run as a git precommit hook (installed by husky after npm install

### [`preview-openapi-changes`](preview-openapi-changes)

This script stitches and unstitches the `github/github` OpenAPI description via `rest-api-operations` to produce a local preview in docs-internal.

`github`, `rest-api-operations`, and `docs-internal` must share a parent directory locally.

You must bootstrap `github` for this script to work. To check if you need to bootstrap, check if the `bin` directory in `github` exists locally. If it does not exist, run `./script/bootstrap` from the `github` directory.

To stitch the repos together and do an npm build, pass the `stitch` argument.

To unstitch the repos and revert them to their pre-stitched state, pass the `unstitch` argument.

---

Expand Down Expand Up @@ -379,13 +393,19 @@ Run this script to remove reusables and image files that exist in the repo but a

This is a convenience script for replacing the contents of translated files with the English content from their corresponding source file.

It's intended to be a workaround to temporarily bypass Crowdin parser bugs while we wait for Crowdin to fix them.
It's intended to be a workaround to temporarily bypass Crowdin parser bugs while we wait for translators to fix them.

Usage: script/reset-translated-file.js <filename>

Examples:

reset a single translated file using a relative path: $ script/reset-translated-file.js translations/es-XL/content/actions/index.md

Usage: script/reset-translated-File.js <relative-filename> [<two-letter-language-code>]
reset a single translated file using a full path: $ script/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md

script/reset-translated-File.js content/desktop/foo.md -> resets all translations of foo.md
reset all language variants of a single English file (using a relative path): $ script/reset-translated-file.js content/actions/index.md $ script/reset-translated-file.js data/ui.yml

script/reset-translated-File.js content/desktop/foo.md de -> resets german translation of foo.md
reset all language variants of a single English file (using a full path): $ script/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md $ script/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml

---

Expand Down
37 changes: 29 additions & 8 deletions script/reset-translated-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@
// files with the English content from their corresponding source file.
//
// It's intended to be a workaround to temporarily bypass Crowdin parser bugs
// while we wait for Crowdin to fix them.
// while we wait for translators to fix them.
//
// Usage:
// script/reset-translated-File.js <relative-filename> [<two-letter-language-code>]
// script/reset-translated-file.js <filename>
//
// script/reset-translated-File.js content/desktop/foo.md
// -> resets all translations of foo.md
// Examples:
//
// script/reset-translated-File.js content/desktop/foo.md de
// -> resets german translation of foo.md
// reset a single translated file using a relative path:
// $ script/reset-translated-file.js translations/es-XL/content/actions/index.md
//
// reset a single translated file using a full path:
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md
//
// reset all language variants of a single English file (using a relative path):
// $ script/reset-translated-file.js content/actions/index.md
// $ script/reset-translated-file.js data/ui.yml
//
// reset all language variants of a single English file (using a full path):
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md
// $ script/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml
//
// [end-readme]

Expand All @@ -25,8 +34,20 @@ const fs = require('fs')
const path = require('path')
const languages = require('../lib/languages')

const [relativePath, languageCode] = process.argv.slice(2)
assert(relativePath, 'first arg must be a target filename')
const [pathArg] = process.argv.slice(2)
assert(pathArg, 'first arg must be a target filename')
let languageCode

// Is the arg a fully-qualified path?
let relativePath = fs.existsSync(pathArg)
? path.relative(process.cwd(), pathArg)
: pathArg

// extract relative path and language code if pathArg is in the format `translations/<lang>/path/to/file`
if (relativePath.startsWith('translations/')) {
languageCode = Object.values(languages).find(language => relativePath.startsWith(language.dir) && language.code !== 'en').code
relativePath = relativePath.split(path.sep).slice(2).join(path.sep)
}

const englishFile = path.join(process.cwd(), relativePath)
assert(fs.existsSync(englishFile), `file does not exist: ${englishFile}`)
Expand Down