Generate NodeScript modules
npm install @nodescript/module-generatorStatus: experimental
TLDR
1. Generate specs from openapi:
```
npm run generate:openapi -- --in=openapi/
2. Generate libraries
``
npm run generate:library -- --in=specs/
3. Publish libraries (See Nodescript publishing for more info.)
``
NODE_ENV=
Both in production and development, you will need to set up a service account in NodeScript in the workspace created for the published modules:
1. In Nodescript, navigate to the desired workspace, then Settings > service accounts and create a service account with WORKSPACE_MODULES_PUBLISH and WORKSPACE_MODULES_VIEW scopes.
2. On the new service account, generate a key, ensure you copy the key as you'll need it shortly.
1. Create/update a file in ./secrets/development/ directory named config.json, then inside create/update the object following this format:
``
{
"
"workspaceId": "
"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.
2. Run the publish command outlined in How to, setting the NODE_ENV to development.
1. Ensure you have sops installed (See Sops for more info.)
2. There should already be a file in ./secrets/production named config.json, which is encrypted. Edit the file using Sops. While editing you should see file contents in this format:
``
{
"google-docs": {
"workspaceId": "
"key": "
},
"bigquery": {
"workspaceId": "
"key": "
},
"youtube": {
"workspaceId": "
"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.
3. Run the publish command outlined in How to, setting the NODE_ENV to production.
4. Commit your changes.
Secrets are managed using SOPS. Installing SOPS is required to edit the secrets locally.
1. Install SOPS:
``
brew install sops
2. Log into GCloud:
``
gcloud auth login
gcloud auth application-default login
3. Edit the secrets file with sops:
```
sops ./secrets/production/config.json