Skip to content

Commit 8cc863c

Browse files
authored
Create script for guided sync from P.B template (#2333)
1 parent c80d5d2 commit 8cc863c

25 files changed

Lines changed: 5685 additions & 4620 deletions

.github/workflows/platform.bible-extension.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@ jobs:
2626
os: [ubuntu-latest]
2727
steps:
2828
- name: Checkout git repo
29-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
29+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3030
with:
3131
path: lexbox
32+
persist-credentials: false
3233

3334
- name: Checkout paranext-core repo to use its sub-packages
34-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
35+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3536
with:
3637
path: paranext-core
3738
repository: paranext/paranext-core
39+
persist-credentials: false
3840

3941
- name: Setup Node.js
40-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
42+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
4143
with:
4244
cache: "npm"
4345
cache-dependency-path: |

platform.bible-extension/.eslintrc.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
module.exports = {
44
extends: [
5-
// https://github.com/electron-react-boilerplate/eslint-config-erb/blob/main/index.js
6-
// airbnb rules are embedded in erb https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
7-
'erb',
5+
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
6+
'airbnb',
7+
'airbnb/hooks',
8+
'plugin:promise/recommended',
9+
'plugin:compat/recommended',
810
// https://github.com/import-js/eslint-plugin-import?tab=readme-ov-file#typescript
911
'plugin:import/recommended',
1012
'plugin:import/typescript',
1113
// Make sure this is last so it gets the chance to override other configs.
1214
// See https://github.com/prettier/eslint-config-prettier and https://github.com/prettier/eslint-plugin-prettier
1315
'plugin:prettier/recommended',
1416
],
17+
env: {
18+
browser: true,
19+
node: true,
20+
},
1521

1622
rules: {
1723
// Some rules in this following shared region are not applied since they are overridden in subsequent regions
18-
// #region shared with https://github.com/paranext/paranext-core/blob/main/.eslintrc.js except certain overrides
24+
// #region shared with https://github.com/paranext/paranext-core/blob/main/.eslintrc.js
1925

2026
// #region ERB rules
2127

@@ -28,6 +34,7 @@ module.exports = {
2834
'import/no-import-module-exports': 'off',
2935
'import/no-unresolved': 'error',
3036
'import/prefer-default-export': 'off',
37+
'no-param-reassign': ['error', { props: false }],
3138
'react/jsx-filename-extension': 'off',
3239
'react/react-in-jsx-scope': 'off',
3340

@@ -45,12 +52,32 @@ module.exports = {
4552
],
4653
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
4754
'lines-between-class-members': 'off',
48-
'@typescript-eslint/lines-between-class-members': [
55+
'@stylistic/ts/lines-between-class-members': [
4956
'error',
5057
'always',
5158
{ exceptAfterSingleLine: true, exceptAfterOverload: true },
5259
],
5360
'@typescript-eslint/member-ordering': 'error',
61+
'@typescript-eslint/naming-convention': [
62+
'error',
63+
{
64+
selector: 'variableLike',
65+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
66+
leadingUnderscore: 'allow',
67+
},
68+
{
69+
selector: 'enumMember',
70+
format: ['PascalCase'],
71+
},
72+
{
73+
selector: 'function',
74+
format: ['camelCase', 'PascalCase'],
75+
},
76+
{
77+
selector: 'typeLike',
78+
format: ['PascalCase'],
79+
},
80+
],
5481
'no-empty-function': 'off',
5582
'@typescript-eslint/no-empty-function': [
5683
'error',
@@ -123,6 +150,17 @@ module.exports = {
123150
globalThis: 'readonly',
124151
},
125152
overrides: [
153+
{
154+
files: ['*.ts', '*.tsx'],
155+
rules: {
156+
// #region shared with https://github.com/paranext/paranext-core/blob/main/.eslintrc.js
157+
158+
// These are already handled by TypeScript
159+
'no-dupe-class-members': 'off',
160+
161+
// #endregion
162+
},
163+
},
126164
{
127165
// Allow this file to have overrides to rules from paranext-core
128166
files: ['.eslintrc.*js'],
@@ -151,14 +189,14 @@ module.exports = {
151189
},
152190
},
153191
],
192+
parser: '@typescript-eslint/parser',
154193
parserOptions: {
155194
ecmaVersion: 2022,
156195
sourceType: 'module',
157196
project: './tsconfig.lint.json',
158197
tsconfigRootDir: __dirname,
159-
createDefaultProgram: true,
160198
},
161-
plugins: ['@typescript-eslint', 'no-type-assertion', 'no-null'],
199+
plugins: ['@typescript-eslint', '@stylistic/ts', 'no-type-assertion', 'no-null'],
162200
settings: {
163201
'import/resolver': {
164202
typescript: {

platform.bible-extension/.stylelintrc.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
extends: [
55
'stylelint-config-recommended',
66
'stylelint-config-sass-guidelines',
7-
'stylelint-config-tailwindcss/scss',
7+
'@dreamsicle.io/stylelint-config-tailwindcss',
88
],
99
overrides: [
1010
{
@@ -13,22 +13,38 @@ module.exports = {
1313
},
1414
],
1515
rules: {
16+
// Let Prettier handle the space between style property and value (they were fighting when a
17+
// value was long enough to be on its own line but not long enough to span multiple lines)
18+
'@stylistic/declaration-colon-space-after': null,
19+
// Disable Stylelint's function parentheses control for Prettier compatibility
20+
'@stylistic/function-parentheses-space-inside': 'never-single-line',
1621
// Disable Stylelint's indentation control
1722
'@stylistic/indentation': null,
1823
// Let Prettier handle selector list formatting
1924
'@stylistic/selector-list-comma-newline-after': null,
25+
'at-rule-no-unknown': null,
2026
'color-named': null,
2127
'max-nesting-depth': 2,
2228
'no-descending-specificity': null,
23-
'selector-max-compound-selectors': 4,
24-
'selector-max-id': 1,
25-
'at-rule-no-unknown': null,
2629
'scss/at-rule-no-unknown': [
2730
true,
2831
{
29-
ignoreAtRules: ['tailwind', 'apply', 'layer', 'screen', 'variants'],
32+
ignoreAtRules: [
33+
'tailwind',
34+
'apply',
35+
'layer',
36+
'screen',
37+
'variants',
38+
'config',
39+
'theme',
40+
'plugin',
41+
'source',
42+
'custom-variant',
43+
],
3044
},
3145
],
46+
'selector-max-compound-selectors': 4,
47+
'selector-max-id': 1,
3248
},
3349
};
3450

platform.bible-extension/.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"editor.rulers": [100],
77
"editor.wordWrapColumn": 100,
88

9-
"eslint.validate": ["javascript", "javascriptreact", "html", "typescriptreact"],
9+
"eslint.validate": ["html", "javascript", "javascriptreact", "typescript", "typescriptreact"],
1010

1111
"files.associations": {
12+
"*.css": "tailwindcss",
13+
"*.usj": "json",
1214
".eslintignore": "ignore",
1315
".prettierignore": "ignore",
1416
".stylelintignore": "ignore"

platform.bible-extension/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- Attention template README maintainers: The content in the portion of this README following the Template Info section roughly parallels that of the paranext-multi-extension-template. When editing one, please consider whether similar changes should also be made in the other.-->
2+
13
# lexicon
24

35
The Platform.Bible extension for managing the lexicon for your project's target/vernacular language.
@@ -186,6 +188,57 @@ useEffect(() => {
186188
- To use `lexiconService.addEntry`, also import types `IEntry` and `PartialEntry` from `'lexicon'`.
187189
- To use `lexiconService.getEntries`, also import types `IEntryQuery` and `PartialEntry` from `'lexicon'`.
188190

191+
## Sync template updates into this extension
192+
193+
This extension is based on [`paranext-extension-template`](https://github.com/paranext/paranext-extension-template). Tooling updates (linting, formatting, build config, etc.) can be pulled in interactively using the sync script.
194+
195+
### Prerequisites
196+
197+
Clone `paranext-extension-template` as a sibling of the `languageforge-lexbox` monorepo root:
198+
199+
```bash
200+
git clone https://github.com/paranext/paranext-extension-template ../paranext-extension-template
201+
```
202+
203+
### Running the sync
204+
205+
```bash
206+
npm run template:sync
207+
```
208+
209+
The script:
210+
211+
1. Runs `git pull --ff-only` in the template repo to get the latest changes.
212+
2. Lists every tracked template file (respecting `.gitignore`) and shows a `git diff` for each file that differs from this extension.
213+
3. Prompts you to choose an action for each differing file.
214+
215+
### Prompt options
216+
217+
For each differing file the prompt shows (color-coded to match the diff):
218+
219+
| Key | Color | Action |
220+
| --- | ------ | ------------------------------------------------------------------ |
221+
| `e` | green | Keep the **extension** version — no change |
222+
| `t` | red | Apply the **template** version directly |
223+
| `d` | yellow | **Defer** — skip for now and revisit after the main pass |
224+
| `b` | orange | Do **both** — copy the template version, then defer to review/edit |
225+
226+
Files that have extension-specific modifications (`package.json`, `manifest.json`, `README.md`, config files, etc.) have `[t]` blocked, ensuring that if you apply the template version, you have to review them.
227+
228+
Files in `contributions/` and `assets/` are surfaced for reference but block both `[t]` and `[b]` — adapt those manually.
229+
230+
### Deferred files
231+
232+
After the main pass, deferred files are listed and the script pauses so you can edit them. Press Enter to do another pass over only the deferred files. Repeat until all deferred files are resolved.
233+
234+
### Final steps
235+
236+
- Commit changes to your working branch.
237+
- Review a diff of that branch from `develop` to verify you haven't removed extension-specific updates.
238+
- Delete `package-lock.json` and `node_modules/`, then run `npm i --no-scripts` to regenerate `package-lock.json`.
239+
- Run `npm run build` and `npm run lint` and fix any failures. If failures arise from (e.g.) changed lint rules in the template, don't just revert the rule change; either update the code or add a targeted exemption.
240+
- Commit all, push, and create a pr.
241+
189242
<!--
190243
## To package for distribution
191244

0 commit comments

Comments
 (0)