Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions platform.bible-extension/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Types publishing
release-types

# #region shared with https://github.com/paranext/paranext-multi-extension-template/blob/main/.eslintignore

# Please keep this file in sync with .prettierignore and .stylelintignore
Expand Down
2 changes: 1 addition & 1 deletion platform.bible-extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = {
},
},
{
files: ['./lib/*', './webpack/*'],
files: ['./lib/*', './scripts/*', './webpack/*'],
rules: {
// These files are scripts not running in Platform.Bible, so they can't use the logger
'no-console': 'off',
Expand Down
37 changes: 37 additions & 0 deletions platform.bible-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,43 @@ To build the extension once:

`npm run build`

## Publishing the types package to npm

The `fw-lite-extension-types` npm package exposes the TypeScript types from `src/types/fw-lite-extension.d.ts` so that other Platform.Bible extensions can consume the `EntryService` network object and other public types from this extension.

### Prerequisites

Set the `NPM_TOKEN` environment variable to a valid npm access token that has publish rights to the `fw-lite-extension-types` package:

```bash
export NPM_TOKEN=<your-npm-token>
```

The token is read from `release-types/.npmrc` and is never stored in source control.

### Bump the types package version

Run the following from the `platform.bible-extension` directory, replacing `<version>` with the desired semver version (e.g. `patch`, `minor`, `major`, or a full version string like `1.0.0`):

```bash
npm run types:bump -- <version>
```

This updates the `version` field in `release-types/package.json`. Commit the updated `release-types/package.json` and open a PR.

### Publish the types package

Once the version bump is merged, publish from the `platform.bible-extension` directory:

```bash
npm run types:publish
```

This command:

1. Copies `src/types/fw-lite-extension.d.ts` and `src/types/enums.ts` into `release-types/` (`types:sync`)
2. Publishes the `release-types/` directory to the npm registry as `fw-lite-extension-types`

<!--
## To package for distribution

Expand Down
5 changes: 4 additions & 1 deletion platform.bible-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
"core:stop": "npm --prefix ../../paranext-core stop",
"core:install": "npm --prefix ../../paranext-core install",
"core:pull": "git -C ../../paranext-core pull --ff-only",
"core:update": "npm run core:pull && npm run core:install"
"core:update": "npm run core:pull && npm run core:install",
"types:sync": "node scripts/sync-types.js",
"types:bump": "cd ./release-types && npm version --no-git-tag-version",
"types:publish": "npm run types:sync && npm publish ./release-types"
},
"browserslist": [],
"peerDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions platform.bible-extension/release-types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Synced from src/types/ by `npm run types:sync` — do not edit directly
fw-lite-extension.d.ts
enums.ts
1 change: 1 addition & 0 deletions platform.bible-extension/release-types/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
15 changes: 15 additions & 0 deletions platform.bible-extension/release-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "fw-lite-extension-types",
"version": "0.0.1",
"description": "TypeScript types for the fw-lite-extension Platform.Bible extension",
"author": "SIL Global",
"license": "MIT",
"types": "fw-lite-extension.d.ts",
"files": [
"fw-lite-extension.d.ts",
"enums.ts"
],
"publishConfig": {
"access": "public"
}
}
15 changes: 15 additions & 0 deletions platform.bible-extension/scripts/sync-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
Comment thread
coderabbitai[bot] marked this conversation as resolved.
// Copies the types files from src/types/ into release-types/ ready for publishing.
const fs = require('fs');
const path = require('path');

const srcDir = path.join(__dirname, '..', 'src', 'types');
const destDir = path.join(__dirname, '..', 'release-types');
const files = ['fw-lite-extension.d.ts', 'enums.ts'];

files.forEach((file) => {
const src = path.join(srcDir, file);
const dest = path.join(destDir, file);
fs.copyFileSync(src, dest);
console.log(`Copied ${file} → release-types/${file}`);
});
2 changes: 1 addition & 1 deletion platform.bible-extension/tsconfig.lint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig",
"include": [".eslintrc.js", "*.ts", "*.js", "lib", "src", "webpack"]
"include": [".eslintrc.js", "*.ts", "*.js", "lib", "scripts", "src", "webpack"]
}
Loading