lawmaker-cli
v3.0.1
Published
---
Downloads
617
Readme
Lawmaker CLI
A command-line tool to feed legislator, topic, and speech data into Algolia indices.
🔧 Environment Variables
Create a .env file in the root directory with the following variables:
ALGOLIA_APP_ID=your_algolia_app_id
ALGOLIA_WRITE_KEY=your_algolia_write_key
[email protected]
HEADLESS_ACCOUNT_PASSWORD=your_password
GRAPHQL_ENDPOINT=http://localhost:3000/api/graphqlDescription
| Variable | Description |
| --------------------------- | -------------------------------------------- |
| ALGOLIA_APP_ID | Your Algolia application ID |
| ALGOLIA_WRITE_KEY | Algolia Write API key |
| HEADLESS_ACCOUNT_EMAIL | Email used for authenticating GraphQL access |
| HEADLESS_ACCOUNT_PASSWORD | Password used for authenticating GraphQL |
| GRAPHQL_ENDPOINT | The URL of lawmaker-cms GraphQL API |
Use a library like dotenv (already included) to load these into runtime automatically.
Command Environment Variables (Cloud Run Job)
You can pass options via environment variables, which is useful for Cloud Run Jobs. Defaults are applied only when the env var is not set; CLI flags may override. CLI flags are additive for data-type selection. If you enable a data type via env, adding another flag includes both. For specific values (meeting/session terms, council name) and dryrun, CLI flags override environment variables when both are provided.
Legislative Yuan:
| Variable | Description | Default |
| ----------------------- | ------------------------------------ | ------- |
| LAWMAKER_MEETING_TERM | Same as --meeting-term | 11 |
| LAWMAKER_SESSION_TERM | Same as --session-term | all |
| LAWMAKER_TOPICS | Same as --topics (boolean) | false |
| LAWMAKER_LEGISLATORS | Same as --legislators (boolean) | false |
| LAWMAKER_SPEECHES | Same as --speeches (boolean) | false |
City Council:
| Variable | Description | Default |
| --------------------------- | ---------------------------------------- | ------- |
| LAWMAKER_COUNCIL_NAME | Same as --council-name | (none) |
| LAWMAKER_COUNCILORS | Same as --councilor (boolean) | false |
| LAWMAKER_COUNCIL_TOPICS | Same as --council-topic (boolean) | false |
| LAWMAKER_COUNCIL_BILLS | Same as --council-bill (boolean) | false |
Common:
| Variable | Description | Default |
| ----------------- | ---------------------------------------- | ------- |
| LAWMAKER_DRYRUN | Same as --dryrun / --no-dryrun | true |
Boolean values accept: true/false (case-sensitive).
Installation
Clone the repository and install dependencies:
git clone https://github.com/twreporter/congress-dashboard-monorepo.git
cd congress-dashboard-monorepo/packages/cronjobs
yarn installBuild
Compile TypeScript files to JavaScript:
yarn buildUsage
Development Mode
Use the development entry point with ts-node:
yarn dev feed-algolia [options]Production Mode
After building:
yarn lawmaker feed-algolia [options]You can also invoke it directly:
./lib/index.js feed-algolia [options]Command: feed-algolia
Feed Algolia search indices with legislative yuan or city council data.
Subcommands
feed-algolia legislative-yuan
Feed legislative yuan data (topics, legislators, speeches).
Options:
If no data-type flags are provided, the command runs all data types (topics, legislators, speeches).
--meeting-term <term>Legislative meeting term (default:11).--session-term <term>Legislative meeting session term. Only for updating speeches. Accepts numeric value orallto process every session in the specified meeting term (default:all).--topicsOnly update topic records.--legislatorsOnly update legislator records.--speechesOnly update speech records.--dryrunDo not upload to Algolia (default behavior).--no-dryrunActually upload data to Algolia.
Examples:
# Default: dry run all data types in meeting term 11
yarn lawmaker feed-algolia legislative-yuan --meeting-term 11
# Use environment defaults (Cloud Run Job style)
LAWMAKER_MEETING_TERM=11 LAWMAKER_SPEECHES=true LAWMAKER_DRYRUN=false yarn lawmaker feed-algolia legislative-yuan
# Dry run only topics in meeting term 10
yarn lawmaker feed-algolia legislative-yuan --meeting-term 10 --topics
# Actually upload speeches in meeting term 11 and session term 2
yarn lawmaker feed-algolia legislative-yuan --meeting-term 11 --session-term 2 --speeches --no-dryrunfeed-algolia council
Feed city council data (councilors, topics, bills).
Options:
If no data-type flags are provided, the command runs all data types (councilors, topics, bills).
--council-name <name>Specific council to update. Valid values:taipei,new-taipei,taoyuan,taichung,tainan,kaohsiung. Omit this option to update all six major cities.--councilorOnly update councilor records.--council-topicOnly update council topic records.--council-billOnly update council bill records.--dryrunDo not upload to Algolia (default behavior).--no-dryrunActually upload data to Algolia.
Examples:
# Default: dry run all data types for all six major cities
yarn lawmaker feed-algolia council
# Dry run only councilors for Taipei
yarn lawmaker feed-algolia council --council-name taipei --councilor
# Actually upload all data for Kaohsiung
yarn lawmaker feed-algolia council --council-name kaohsiung --no-dryrun
# Use environment defaults (Cloud Run Job style)
LAWMAKER_COUNCIL_NAME=taipei LAWMAKER_COUNCILORS=true LAWMAKER_DRYRUN=false yarn lawmaker feed-algolia councilLicense
MIT License
