@nodescript/module-generator v1.0.9
Module Generator
Status: experimental
Sources of API specifications:
How to
TLDR
- Generate specs from openapi:
npm run generate:openapi -- --in=openapi/<api-name>.json --out=specs/<api-name>.yaml- Generate libraries
npm run generate:library -- --in=specs/<api-name>.yaml- Publish libraries (See Nodescript publishing for more info.)
NODE_ENV=<env> FORCE_PUBLISH=true npm run publish:library -- --in=specs/<api-name>.yamlNodescript publishing
Both in production and development, you will need to set up a service account in NodeScript in the workspace created for the published modules:
- In Nodescript, navigate to the desired workspace, then
Settings>service accountsand create a service account withWORKSPACE_MODULES_PUBLISHandWORKSPACE_MODULES_VIEWscopes. - On the new service account, generate a key, ensure you copy the key as you'll need it shortly.
Local dev:
- Create/update a file in
./secrets/development/directory namedconfig.json, then inside create/update the object following this format:
{
"<module title>": {
"workspaceId": "<workspaceId>"
"key": "<key>"
}
}Add your module title as per the spec filename from ./specs, omitting the file extension, and set the value to your generated key from NodeScript as well as the target workspace ID. Save the file.
- Run the publish command outlined in How to, setting the
NODE_ENVtodevelopment.
Production:
- Ensure you have sops installed (See Sops for more info.)
- There should already be a file in
./secrets/productionnamedconfig.json, which is encrypted. Edit the file using Sops. While editing you should see file contents in this format:
{
"google-docs": {
"workspaceId": "<workspaceId>"
"key": "<key>"
},
"bigquery": {
"workspaceId": "<workspaceId>"
"key": "<key>"
},
"youtube": {
"workspaceId": "<workspaceId>"
"key": "<key>"
},
// ...etc
}Add your module title as per the spec filename from ./specs, omitting the file extension, and set the value to your generated key from NodeScript. Save/Write and exit the editor.
Run the publish command outlined in How to, setting the
NODE_ENVtoproduction.Commit your changes.
SOPS
Secrets are managed using SOPS. Installing SOPS is required to edit the secrets locally.
Install SOPS:
brew install sopsLog into GCloud:
gcloud auth login gcloud auth application-default loginEdit the secrets file with sops:
sops ./secrets/production/config.json