newspack-scripts 5.6.1 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +0 -4
- package/.github/workflows/main.yml +100 -10
- package/.prettierrc.js +5 -0
- package/bin/newspack-scripts.js +4 -4
- package/config/babel.config.js +2 -4
- package/config/eslintrc.js +3 -12
- package/config/getWebpackConfig.js +1 -1
- package/config/stylelint.config.js +3 -4
- package/package.json +54 -45
- package/scripts/release.js +8 -7
- package/scripts/typescript-check.js +7 -0
- package/src/executors/default.yml +1 -1
- package/src/jobs/i18n.yml +91 -0
- package/src/jobs/lint-php.yml +1 -1
- package/src/jobs/test-php.yml +1 -1
package/.eslintrc.js
CHANGED
|
@@ -1,15 +1,105 @@
|
|
|
1
|
-
on:
|
|
2
|
-
|
|
1
|
+
on:
|
|
2
|
+
pull_request_review:
|
|
3
|
+
types: [submitted]
|
|
4
|
+
name: Label pull requests on review
|
|
3
5
|
jobs:
|
|
4
6
|
labelWhenApproved:
|
|
5
7
|
name: Label when approved
|
|
6
8
|
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pull-requests: write
|
|
7
12
|
steps:
|
|
8
|
-
- name:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
- name: Check if review is approved
|
|
14
|
+
id: check_approval
|
|
15
|
+
run: |
|
|
16
|
+
if [ "${{ github.event.review.state }}" = "approved" ]; then
|
|
17
|
+
echo "approved=true" >> $GITHUB_OUTPUT
|
|
18
|
+
else
|
|
19
|
+
echo "approved=false" >> $GITHUB_OUTPUT
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
- name: Add approved label
|
|
23
|
+
if: steps.check_approval.outputs.approved == 'true'
|
|
24
|
+
uses: actions/github-script@v7
|
|
25
|
+
with:
|
|
26
|
+
script: |
|
|
27
|
+
const { owner, repo, number } = context.issue;
|
|
28
|
+
|
|
29
|
+
// Add the approved label
|
|
30
|
+
await github.rest.issues.addLabels({
|
|
31
|
+
owner,
|
|
32
|
+
repo,
|
|
33
|
+
issue_number: number,
|
|
34
|
+
labels: ['[Status] Approved']
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Remove the needs review label if it exists
|
|
38
|
+
try {
|
|
39
|
+
await github.rest.issues.removeLabel({
|
|
40
|
+
owner,
|
|
41
|
+
repo,
|
|
42
|
+
issue_number: number,
|
|
43
|
+
name: '[Status] Needs Review'
|
|
44
|
+
});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// Label might not exist, which is fine
|
|
47
|
+
console.log('Label "[Status] Needs Review" not found or already removed');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Remove the needs changes or feedback label if it exists
|
|
51
|
+
try {
|
|
52
|
+
await github.rest.issues.removeLabel({
|
|
53
|
+
owner,
|
|
54
|
+
repo,
|
|
55
|
+
issue_number: number,
|
|
56
|
+
name: '[Status] Needs Changes or Feedback'
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
// Label might not exist, which is fine
|
|
60
|
+
console.log('Label "[Status] Needs Changes or Feedback" not found or already removed');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
labelWhenChangesRequested:
|
|
64
|
+
name: Label when changes requested
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
permissions:
|
|
67
|
+
contents: read
|
|
68
|
+
pull-requests: write
|
|
69
|
+
steps:
|
|
70
|
+
- name: Check if review requests changes
|
|
71
|
+
id: check_changes_requested
|
|
72
|
+
run: |
|
|
73
|
+
if [ "${{ github.event.review.state }}" = "changes_requested" ]; then
|
|
74
|
+
echo "changes_requested=true" >> $GITHUB_OUTPUT
|
|
75
|
+
else
|
|
76
|
+
echo "changes_requested=false" >> $GITHUB_OUTPUT
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
- name: Add changes requested label
|
|
80
|
+
if: steps.check_changes_requested.outputs.changes_requested == 'true'
|
|
81
|
+
uses: actions/github-script@v7
|
|
82
|
+
with:
|
|
83
|
+
script: |
|
|
84
|
+
const { owner, repo, number } = context.issue;
|
|
85
|
+
|
|
86
|
+
// Add the changes requested label
|
|
87
|
+
await github.rest.issues.addLabels({
|
|
88
|
+
owner,
|
|
89
|
+
repo,
|
|
90
|
+
issue_number: number,
|
|
91
|
+
labels: ['[Status] Needs Changes or Feedback']
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Remove the approved label if it exists
|
|
95
|
+
try {
|
|
96
|
+
await github.rest.issues.removeLabel({
|
|
97
|
+
owner,
|
|
98
|
+
repo,
|
|
99
|
+
issue_number: number,
|
|
100
|
+
name: '[Status] Approved'
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
// Label might not exist, which is fine
|
|
104
|
+
console.log('Label "[Status] Approved" not found or already removed');
|
|
105
|
+
}
|
package/.prettierrc.js
ADDED
package/bin/newspack-scripts.js
CHANGED
|
@@ -25,14 +25,14 @@ if (
|
|
|
25
25
|
if ( result.signal === 'SIGKILL' ) {
|
|
26
26
|
utils.log(
|
|
27
27
|
'The build failed because the process exited too early. ' +
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
'This probably means the system ran out of memory or someone called ' +
|
|
29
|
+
'`kill -9` on the process.'
|
|
30
30
|
);
|
|
31
31
|
} else if ( result.signal === 'SIGTERM' ) {
|
|
32
32
|
utils.log(
|
|
33
33
|
'The build failed because the process exited too early. ' +
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
'Someone might have called `kill` or `killall`, or the system could ' +
|
|
35
|
+
'be shutting down.'
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
process.exit( 1 );
|
package/config/babel.config.js
CHANGED
package/config/eslintrc.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
const wpRecommended = require.resolve(
|
|
2
|
-
'@wordpress/eslint-plugin/configs/recommended'
|
|
3
|
-
);
|
|
4
|
-
const reactRecommended = require.resolve(
|
|
5
|
-
'@wordpress/eslint-plugin/configs/react'
|
|
6
|
-
);
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* Assume `@wordpress/*` packages are available. This is because `@wordpress/scripts` is using
|
|
10
3
|
* Dependency Extraction Webpack Plugin to use core WP packages instead of those from
|
|
@@ -23,17 +16,14 @@ module.exports = {
|
|
|
23
16
|
extends: [
|
|
24
17
|
'plugin:import/errors',
|
|
25
18
|
'plugin:import/warnings',
|
|
26
|
-
'plugin:@
|
|
27
|
-
'plugin:@
|
|
28
|
-
reactRecommended,
|
|
29
|
-
wpRecommended,
|
|
19
|
+
'plugin:@wordpress/eslint-plugin/recommended',
|
|
20
|
+
'plugin:@wordpress/eslint-plugin/react',
|
|
30
21
|
],
|
|
31
22
|
env: {
|
|
32
23
|
browser: true,
|
|
33
24
|
jest: true,
|
|
34
25
|
},
|
|
35
26
|
parser: '@typescript-eslint/parser',
|
|
36
|
-
plugins: [ '@typescript-eslint' ],
|
|
37
27
|
settings: {
|
|
38
28
|
'import/resolver': {
|
|
39
29
|
node: {
|
|
@@ -85,5 +75,6 @@ module.exports = {
|
|
|
85
75
|
'@typescript-eslint/no-shadow': 'error',
|
|
86
76
|
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
87
77
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
78
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
88
79
|
},
|
|
89
80
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
|
|
4
|
-
],
|
|
2
|
+
extends: [ '@wordpress/stylelint-config' ],
|
|
3
|
+
ignoreFiles: [ 'dist/**', 'node_modules/**', 'release/**', 'scripts/**' ],
|
|
5
4
|
rules: {
|
|
6
5
|
'rule-empty-line-before': null,
|
|
7
6
|
'at-rule-empty-line-before': null,
|
|
@@ -16,6 +15,7 @@ module.exports = {
|
|
|
16
15
|
'alpha-value-notation': null,
|
|
17
16
|
'color-function-notation': null,
|
|
18
17
|
'selector-not-notation': null,
|
|
18
|
+
'no-invalid-double-slash-comments': null,
|
|
19
19
|
'function-no-unknown': [
|
|
20
20
|
true,
|
|
21
21
|
{
|
|
@@ -29,6 +29,5 @@ module.exports = {
|
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
31
|
'media-feature-range-notation': null,
|
|
32
|
-
'max-line-length': null,
|
|
33
32
|
},
|
|
34
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -8,63 +8,72 @@
|
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@commitlint/cli": "^
|
|
12
|
-
"@commitlint/config-conventional": "^
|
|
13
|
-
"@rushstack/eslint-patch": "^1.
|
|
11
|
+
"@commitlint/cli": "^20.1.0",
|
|
12
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
13
|
+
"@rushstack/eslint-patch": "^1.14.1",
|
|
14
14
|
"@semantic-release/changelog": "^6.0.3",
|
|
15
15
|
"@semantic-release/git": "^10.0.1",
|
|
16
|
-
"@testing-library/jest-dom": "^
|
|
17
|
-
"@testing-library/react": "^
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@wordpress/
|
|
22
|
-
"@wordpress/
|
|
23
|
-
"@wordpress/
|
|
24
|
-
"@wordpress/
|
|
25
|
-
"@wordpress/
|
|
26
|
-
"@wordpress/
|
|
27
|
-
"@wordpress/
|
|
28
|
-
"@wordpress/
|
|
29
|
-
"@wordpress/
|
|
30
|
-
"@wordpress/
|
|
31
|
-
"@wordpress/
|
|
32
|
-
"@wordpress/
|
|
33
|
-
"@wordpress/
|
|
34
|
-
"@wordpress/html
|
|
35
|
-
"@wordpress/
|
|
36
|
-
"@wordpress/
|
|
37
|
-
"@wordpress/
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
40
|
-
"@wordpress/
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
16
|
+
"@testing-library/jest-dom": "^6.9.0",
|
|
17
|
+
"@testing-library/react": "^16.3.0",
|
|
18
|
+
"@types/qs": "^6.14.0",
|
|
19
|
+
"@types/react": "^19.2.2",
|
|
20
|
+
"@typescript-eslint/parser": "^8.46.0",
|
|
21
|
+
"@wordpress/a11y": "^4.33.0",
|
|
22
|
+
"@wordpress/api-fetch": "^7.33.0",
|
|
23
|
+
"@wordpress/base-styles": "^6.9.0",
|
|
24
|
+
"@wordpress/block-editor": "^15.6.0",
|
|
25
|
+
"@wordpress/blocks": "^15.6.0",
|
|
26
|
+
"@wordpress/browserslist-config": "^6.33.0",
|
|
27
|
+
"@wordpress/components": "^30.6.0",
|
|
28
|
+
"@wordpress/compose": "^7.33.0",
|
|
29
|
+
"@wordpress/data": "^10.33.0",
|
|
30
|
+
"@wordpress/date": "^5.33.0",
|
|
31
|
+
"@wordpress/dom-ready": "^4.33.0",
|
|
32
|
+
"@wordpress/edit-post": "^8.33.0",
|
|
33
|
+
"@wordpress/element": "^6.33.0",
|
|
34
|
+
"@wordpress/escape-html": "^3.33.0",
|
|
35
|
+
"@wordpress/eslint-plugin": "^22.19.0",
|
|
36
|
+
"@wordpress/hooks": "^4.33.0",
|
|
37
|
+
"@wordpress/html-entities": "^4.33.0",
|
|
38
|
+
"@wordpress/i18n": "^6.6.0",
|
|
39
|
+
"@wordpress/icons": "^11.0.0",
|
|
40
|
+
"@wordpress/keycodes": "^4.33.0",
|
|
41
|
+
"@wordpress/plugins": "^7.33.0",
|
|
42
|
+
"@wordpress/prettier-config": "^4.33.0",
|
|
43
|
+
"@wordpress/scripts": "^30.26.0",
|
|
44
|
+
"@wordpress/stylelint-config": "^23.25.0",
|
|
45
|
+
"@wordpress/url": "^4.33.0",
|
|
46
|
+
"autoprefixer": "^10.4.21",
|
|
47
|
+
"commitizen": "^4.3.1",
|
|
48
|
+
"cross-spawn": "^7.0.6",
|
|
46
49
|
"cz-conventional-changelog": "^3.3.0",
|
|
47
50
|
"eslint": "^8.57.0",
|
|
48
|
-
"eslint-config-prettier": "^
|
|
49
|
-
"eslint-plugin-import": "^2.
|
|
50
|
-
"eslint-plugin-jest": "^
|
|
51
|
-
"eslint-plugin-react": "^7.
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"eslint-plugin-import": "^2.32.0",
|
|
53
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
54
|
+
"eslint-plugin-react": "^7.37.5",
|
|
55
|
+
"lint-staged": "^16.2.6",
|
|
52
56
|
"lodash": "^4.17.21",
|
|
53
|
-
"postcss": "^8.
|
|
54
|
-
"postcss-focus-within": "^
|
|
57
|
+
"postcss": "^8.5.6",
|
|
58
|
+
"postcss-focus-within": "^9.0.1",
|
|
55
59
|
"postcss-scss": "^4.0.9",
|
|
56
60
|
"prettier": "npm:wp-prettier@^3.0.3",
|
|
57
|
-
"
|
|
61
|
+
"qs": "^6.14.0",
|
|
62
|
+
"semantic-release": "^25.0.1",
|
|
58
63
|
"semantic-release-version-bump": "^1.4.1",
|
|
59
|
-
"stylelint": "^
|
|
60
|
-
"typescript": "^5.
|
|
64
|
+
"stylelint": "^16.25.0",
|
|
65
|
+
"typescript": "^5.9.3",
|
|
61
66
|
"yargs": "^17.7.2"
|
|
62
67
|
},
|
|
63
68
|
"overrides": {
|
|
64
|
-
"
|
|
65
|
-
"path-to-regexp": "1.7.0"
|
|
69
|
+
"prettier": "$prettier"
|
|
66
70
|
},
|
|
67
71
|
"scripts": {
|
|
72
|
+
"lint": "npm run lint:js",
|
|
73
|
+
"lint:js": "./bin/newspack-scripts.js wp-scripts lint-js '**/{bin,config,scripts}/**/*.{js,jsx,ts,tsx}'",
|
|
74
|
+
"lint:js:staged": "./bin/newspack-scripts.js wp-scripts lint-js --ext .js,.jsx,.ts,.tsx",
|
|
75
|
+
"fix:js": "./bin/newspack-scripts.js wp-scripts lint-js --fix '**/{bin,config,scripts}/**/*.{js,jsx,ts,tsx}'",
|
|
76
|
+
"format:js": "./bin/newspack-scripts.js wp-scripts format '**/{bin,config,scripts}/**/*.{js,jsx,ts,tsx}'",
|
|
68
77
|
"semantic-release": "semantic-release"
|
|
69
78
|
},
|
|
70
79
|
"release": {
|
package/scripts/release.js
CHANGED
|
@@ -12,12 +12,6 @@ const filesList = files.split( ',' );
|
|
|
12
12
|
|
|
13
13
|
utils.log( `Releasing ${ process.env.CIRCLE_PROJECT_REPONAME }…` );
|
|
14
14
|
|
|
15
|
-
const shouldPublishOnNPM = Boolean( process.env.NPM_TOKEN );
|
|
16
|
-
|
|
17
|
-
if ( shouldPublishOnNPM ) {
|
|
18
|
-
utils.log( `Will publish on npm` );
|
|
19
|
-
}
|
|
20
|
-
|
|
21
15
|
const getConfig = ({ gitBranchName }) => {
|
|
22
16
|
const branchType = gitBranchName.split("/")[0];
|
|
23
17
|
const githubConfig = {
|
|
@@ -35,6 +29,12 @@ const getConfig = ({ gitBranchName }) => {
|
|
|
35
29
|
githubConfig.failComment = false;
|
|
36
30
|
}
|
|
37
31
|
|
|
32
|
+
// Only publish alpha and release branches to NPM.
|
|
33
|
+
const shouldPublishOnNPM = Boolean( process.env.NPM_TOKEN ) && ["alpha", "release"].includes(branchType);
|
|
34
|
+
if ( shouldPublishOnNPM ) {
|
|
35
|
+
utils.log( `Will publish to npm.` );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
38
|
const config = {
|
|
39
39
|
dryRun: otherArgs.dryRun,
|
|
40
40
|
ci: otherArgs.ci,
|
|
@@ -129,7 +129,7 @@ const run = async () => {
|
|
|
129
129
|
try {
|
|
130
130
|
const gitBranch = await utils.getGitBranch();
|
|
131
131
|
|
|
132
|
-
const result = await semanticRelease(
|
|
132
|
+
const result = await semanticRelease.default(
|
|
133
133
|
getConfig( { gitBranchName: gitBranch } )
|
|
134
134
|
);
|
|
135
135
|
|
|
@@ -154,6 +154,7 @@ const run = async () => {
|
|
|
154
154
|
}
|
|
155
155
|
} catch ( err ) {
|
|
156
156
|
console.error( 'The automated release failed with %O', err );
|
|
157
|
+
process.exit( 1 );
|
|
157
158
|
}
|
|
158
159
|
};
|
|
159
160
|
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DEPRECATION NOTICE: As of v5.8.0, this script is deprecated as @wordpress/eslint-plugin
|
|
3
|
+
* will perform TypeScript checks on .ts and .tsx files.
|
|
4
|
+
*
|
|
5
|
+
* This script and its dependencies will be removed in a future version of Newspack Scripts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
'use strict';
|
|
2
9
|
|
|
3
10
|
const spawn = require( 'cross-spawn' );
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
description: >
|
|
2
|
+
Create translation files.
|
|
3
|
+
|
|
4
|
+
executor: default
|
|
5
|
+
|
|
6
|
+
steps:
|
|
7
|
+
- checkout_with_workspace
|
|
8
|
+
- run:
|
|
9
|
+
name: Check if commit author is bot
|
|
10
|
+
command: |
|
|
11
|
+
COMMIT_AUTHOR=$(git log -1 --pretty=format:'%ae')
|
|
12
|
+
if [ "$COMMIT_AUTHOR" = "$GITHUB_COMMITER_EMAIL" ]; then
|
|
13
|
+
echo "Commit was made by bot ($(git rev-parse --short HEAD)), skipping translation update"
|
|
14
|
+
circleci step halt
|
|
15
|
+
fi
|
|
16
|
+
- run:
|
|
17
|
+
name: Install WP CLI
|
|
18
|
+
command: |
|
|
19
|
+
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
|
20
|
+
chmod +x wp-cli.phar
|
|
21
|
+
sudo mv wp-cli.phar /usr/local/bin/wp
|
|
22
|
+
- run:
|
|
23
|
+
name: Build plugin files, so dist dir is available
|
|
24
|
+
command: |
|
|
25
|
+
npm run build || true
|
|
26
|
+
- run:
|
|
27
|
+
name: Create POT translation files
|
|
28
|
+
command: |
|
|
29
|
+
# Theme is excluded, more in https://github.com/Automattic/newspack-theme/pull/2458
|
|
30
|
+
if [ "$CIRCLE_PROJECT_REPONAME" = "newspack-theme" ]; then
|
|
31
|
+
cd ./newspack-theme
|
|
32
|
+
wp i18n make-pot . languages/${CIRCLE_PROJECT_REPONAME}.pot --exclude='src' --domain=${CIRCLE_PROJECT_REPONAME}
|
|
33
|
+
cd -
|
|
34
|
+
else
|
|
35
|
+
wp i18n make-pot . languages/${CIRCLE_PROJECT_REPONAME}.pot --domain=${CIRCLE_PROJECT_REPONAME}
|
|
36
|
+
fi
|
|
37
|
+
- run:
|
|
38
|
+
name: Create JSON translation files
|
|
39
|
+
command: |
|
|
40
|
+
if [ "$CIRCLE_PROJECT_REPONAME" = "newspack-theme" ]; then
|
|
41
|
+
cd ./newspack-theme
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
sudo apt-get update && sudo apt-get install -y gettext
|
|
45
|
+
|
|
46
|
+
cd languages
|
|
47
|
+
|
|
48
|
+
# Create PO files from POT if they don't exist
|
|
49
|
+
if [ ! -f "${CIRCLE_PROJECT_REPONAME}-en_US.po" ]; then
|
|
50
|
+
echo "Creating ${CIRCLE_PROJECT_REPONAME}-en_US.po from POT file"
|
|
51
|
+
wp i18n update-po ${CIRCLE_PROJECT_REPONAME}.pot .
|
|
52
|
+
else
|
|
53
|
+
echo "${CIRCLE_PROJECT_REPONAME}-en_US.po file already exists, skipping creation"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
for po in *.po; do
|
|
57
|
+
if [ -f "$po" ]; then
|
|
58
|
+
echo "Processing file $po …"
|
|
59
|
+
# Update translations according to the new POT file
|
|
60
|
+
msgmerge $po $CIRCLE_PROJECT_REPONAME.pot -o $po.out
|
|
61
|
+
mv $po.out $po
|
|
62
|
+
msgfmt $po -o $(basename $po .po).mo
|
|
63
|
+
# no-purge since we need the JS translations for the next run
|
|
64
|
+
wp i18n make-json --no-purge $po .
|
|
65
|
+
fi
|
|
66
|
+
done
|
|
67
|
+
- run:
|
|
68
|
+
name: Commit translation files
|
|
69
|
+
command: |
|
|
70
|
+
if [ "$CIRCLE_PROJECT_REPONAME" = "newspack-theme" ]; then
|
|
71
|
+
cd ./newspack-theme
|
|
72
|
+
fi
|
|
73
|
+
if [ -d "languages" ]; then
|
|
74
|
+
LINES_CHANGED=$(git diff --numstat languages/ | awk '{sum += $1 + $2} END {print sum}')
|
|
75
|
+
# If no existing files were changed, check for new files
|
|
76
|
+
if [ -z "$LINES_CHANGED" ] || [ "$LINES_CHANGED" -eq 0 ]; then
|
|
77
|
+
LINES_CHANGED=$(git ls-files --others --exclude-standard languages/ | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')
|
|
78
|
+
fi
|
|
79
|
+
else
|
|
80
|
+
LINES_CHANGED=0
|
|
81
|
+
fi
|
|
82
|
+
LINES_CHANGED=${LINES_CHANGED:-0}
|
|
83
|
+
echo "Lines changed in languages/: $LINES_CHANGED"
|
|
84
|
+
if [ "$LINES_CHANGED" -gt 3 ]; then
|
|
85
|
+
git config user.email "$GITHUB_COMMITER_EMAIL"
|
|
86
|
+
git config user.name "$GIT_COMMITTER_NAME"
|
|
87
|
+
git remote set-url origin https://$GITHUB_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git
|
|
88
|
+
git add languages/
|
|
89
|
+
git commit -m "chore: update translation files [skip ci]"
|
|
90
|
+
git push origin $CIRCLE_BRANCH
|
|
91
|
+
fi
|
package/src/jobs/lint-php.yml
CHANGED