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

[i18n] NPM publish i18ntokens.json #4771

Merged
merged 5 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added `inherit` color option to `EuiIcon` to force two-tone (app) icons to inherit their parent's color ([#4760](https://github.com/elastic/eui/pull/4760))
- Updated `EuiBetaBadge, EuiBadge, EuiButtonIcon, EuiButtonContent, EuiCallOut, EuiContextMenuItem, EuiListGroupItem` icon usage to inherit their parent's color ([#4760](https://github.com/elastic/eui/pull/4760))
- Added `iconProps` prop to `EuiListGroupItem` ([#4760](https://github.com/elastic/eui/pull/4760))
- NPM publish `i18ntokens.json` ([#4771](https://github.com/elastic/eui/pull/4771))
afharo marked this conversation as resolved.
Show resolved Hide resolved

**Bug fixes**

Expand Down
70 changes: 11 additions & 59 deletions src-docs/src/i18ntokens.json → i18ntokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@
"highlighting": "string",
"loc": {
"start": {
"line": 1166,
"line": 1168,
"column": 8
},
"end": {
"line": 1166,
"line": 1168,
"column": 79
}
},
Expand All @@ -117,11 +117,11 @@
"highlighting": "string",
"loc": {
"start": {
"line": 1387,
"line": 1389,
"column": 10
},
"end": {
"line": 1391,
"line": 1393,
"column": 12
}
},
Expand Down Expand Up @@ -2901,11 +2901,11 @@
"highlighting": "string",
"loc": {
"start": {
"line": 742,
"line": 754,
"column": 14
},
"end": {
"line": 745,
"line": 757,
"column": 16
}
},
Expand Down Expand Up @@ -3440,65 +3440,17 @@
"filepath": "src/components/table/mobile/table_sort_mobile.tsx"
},
{
"token": "euiTableHeaderCell.clickForDescending",
"defString": "Click to sort in descending order",
"token": "euiTableHeaderCell.titleTextWithDesc",
"defString": "{innerText}; {description}",
"highlighting": "string",
"loc": {
"start": {
"line": 135,
"column": 10
},
"end": {
"line": 138,
"column": 12
}
},
"filepath": "src/components/table/table_header_cell.tsx"
},
{
"token": "euiTableHeaderCell.clickForUnsort",
"defString": "Click to unsort",
"highlighting": "string",
"loc": {
"start": {
"line": 144,
"column": 10
},
"end": {
"line": 147,
"column": 12
}
},
"filepath": "src/components/table/table_header_cell.tsx"
},
{
"token": "euiTableHeaderCell.clickForAscending",
"defString": "Click to sort in ascending order",
"highlighting": "string",
"loc": {
"start": {
"line": 152,
"column": 8
},
"end": {
"line": 155,
"line": 103,
"column": 10
}
},
"filepath": "src/components/table/table_header_cell.tsx"
},
{
"token": "euiTableHeaderCell.titleTextWithSort",
"defString": "{innerText}; Sorted in {ariaSortValue} order",
"highlighting": "string",
"loc": {
"start": {
"line": 163,
"column": 12
},
"end": {
"line": 166,
"column": 52
"line": 106,
"column": 48
}
},
"filepath": "src/components/table/table_header_cell.tsx"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/babel/fetch-i18n-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ tokenMappings.reduce(
);

fs.writeFileSync(
join(rootDir, 'src-docs', 'src', 'i18ntokens.json'),
join(rootDir, 'i18ntokens.json'),
JSON.stringify(tokenMappings, null, 2)
);
6 changes: 3 additions & 3 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ if (args.dry_run) {
execSync('npm run build', execOptions);
}


if (args.steps.indexOf('version') > -1) {
// prompt user for what type of version bump to make (major|minor|patch)
const versionTarget = await getVersionTypeFromChangelog();

// build may have generated a new src-docs/src/i18ntokens.json file, dirtying the git workspace
// build may have generated a new i18ntokens.json file, dirtying the git workspace
// it's important to track those changes with this release, so determine the changes and write them
// to src-docs/src/i18ntokens_changelog.json, comitting both to the workspace before running `npm version`
// to i18ntokens_changelog.json, comitting both to the workspace before running `npm version`
execSync(`npm run update-token-changelog -- ${versionTarget}`, execOptions);

// update package.json & package-lock.json version, git commit, git tag
Expand Down
30 changes: 23 additions & 7 deletions scripts/update-token-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const semver = require('semver');

const repoDir = path.resolve(__dirname, '..');
const packagePath = path.resolve(repoDir, 'package.json');
const tokensPath = path.resolve(repoDir, 'src-docs', 'src', 'i18ntokens.json');
const tokensChangelogPath = path.resolve(repoDir, 'src-docs', 'src', 'i18ntokens_changelog.json');
const tokensPath = path.resolve(repoDir, 'i18ntokens.json');
const tokensChangelogPath = path.resolve(repoDir, 'i18ntokens_changelog.json');

const validVersionTypes = new Set(['patch', 'minor', 'major']);
const [, , versionIncrementType] = process.argv;
Expand Down Expand Up @@ -101,14 +101,14 @@ async function commitTokenChanges(repo) {

const index = await repo.refreshIndex();

if (dirtyFiles.has('src-docs/src/i18ntokens.json')) {
if (dirtyFiles.has('i18ntokens.json')) {
createCommit = true;
await index.addByPath('src-docs/src/i18ntokens.json');
await index.addByPath('i18ntokens.json');
}

if (dirtyFiles.has('src-docs/src/i18ntokens_changelog.json')) {
if (dirtyFiles.has('i18ntokens_changelog.json')) {
createCommit = true;
await index.addByPath('src-docs/src/i18ntokens_changelog.json');
await index.addByPath('i18ntokens_changelog.json');
}

if (createCommit) {
Expand All @@ -128,12 +128,28 @@ async function getCommitForTagName(repo, tagname) {
return git.Commit.lookup(repo, tag.targetId());
}

async function getPreviousI18nTokens(previousVersionCommit) {
try {
return JSON.parse(
await getFileContentsFromCommit(previousVersionCommit, 'i18ntokens.json')
);
} catch (err) {
// If failed, try with the previous path where it used to exist
return JSON.parse(
await getFileContentsFromCommit(
previousVersionCommit,
'src-docs/src/i18ntokens.json'
)
);
}
}

async function main() {
const repo = await git.Repository.open(repoDir);
const previousVersionCommit = await getCommitForTagName(repo, `v${oldPackageVersion}`);

// check for i18n token differences between the current file & the most recent EUI version
const originalTokens = JSON.parse(await getFileContentsFromCommit(previousVersionCommit, 'src-docs/src/i18ntokens.json'));
const originalTokens = await getPreviousI18nTokens(previousVersionCommit);
const newTokens = require(tokensPath);

const changes = getTokenChanges(originalTokens, newTokens);
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/package/i18n_tokens.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import tokens from '../../i18ntokens';
import tokenChangelog from '../../i18ntokens_changelog';
import tokens from '../../../../i18ntokens.json';
import tokenChangelog from '../../../../i18ntokens_changelog.json';

import {
EuiAccordion,
Expand Down