@haatlabs-core/templates 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/files/make/platform.mk
CHANGED
|
@@ -225,7 +225,7 @@ local-logs: $(ENV_PATH) ## follow their logs
|
|
|
225
225
|
|
|
226
226
|
# --------------------------------------------------------------- the schema --
|
|
227
227
|
|
|
228
|
-
.PHONY: migrate seed seed-plans assign-plan set-price admin-user
|
|
228
|
+
.PHONY: migrate seed seed-plans assign-plan set-price set-prices admin-user
|
|
229
229
|
|
|
230
230
|
migrate: $(ENV_PATH) ## the database schema
|
|
231
231
|
$(WITH_ENV) pnpm db:migrate
|
|
@@ -254,6 +254,12 @@ admin-user: $(ENV_PATH) ## platform administrators, ARGS="create <email>" or "di
|
|
|
254
254
|
set-price: $(ENV_PATH) ## a plan's gateway price, ARGS="<planCode> <gateway> <priceRef> <CURRENCY> <amount>"
|
|
255
255
|
$(WITH_ENV) pnpm --filter @@@name@@/api set-price $(ARGS)
|
|
256
256
|
|
|
257
|
+
# The Razorpay prices in apps/api/seed/prices.json, or `ARGS=<file>` for another file. Makes
|
|
258
|
+
# each missing Razorpay plan with this environment's keys and records its ID; run again, it
|
|
259
|
+
# changes nothing. A recorded amount that differs is refused, never replaced.
|
|
260
|
+
set-prices: $(ENV_PATH) ## the Razorpay plans in apps/api/seed/prices.json
|
|
261
|
+
$(WITH_ENV) pnpm --filter @@@name@@/api set-prices $(ARGS)
|
|
262
|
+
|
|
257
263
|
# ----------------------------------------------------------------- the apps --
|
|
258
264
|
|
|
259
265
|
.PHONY: dev build
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/templates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The starter files and shared project files that @haatlabs-core/cli writes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"haatlabs"
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"playwright-core": "1.63.0",
|
|
39
|
-
"@haatlabs-core/
|
|
40
|
-
"@haatlabs-core/
|
|
39
|
+
"@haatlabs-core/vitest-config": "0.15.0",
|
|
40
|
+
"@haatlabs-core/tsconfig": "0.15.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"assign-plan": "tsx --env-file=${ENV_FILE:?ENV_FILE is not set. Run it through make with Env=name} src/assign-plan.ts",
|
|
17
17
|
"admin-user": "tsx --env-file=${ENV_FILE:?ENV_FILE is not set. Run it through make with Env=name} src/admin-user.ts",
|
|
18
18
|
"set-price": "tsx --env-file=${ENV_FILE:?ENV_FILE is not set. Run it through make with Env=name} src/set-price.ts",
|
|
19
|
+
"set-prices": "tsx --env-file=${ENV_FILE:?ENV_FILE is not set. Run it through make with Env=name} src/set-prices.ts",
|
|
19
20
|
"seed:plans": "tsx --env-file=${ENV_FILE:?ENV_FILE is not set. Run it through make with Env=name} src/seed-plans.ts"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { RazorpayGateway } from '@haatlabs-core/billing';
|
|
4
|
+
import { runSetPrices } from '@haatlabs-core/nest-billing';
|
|
5
|
+
import { loadConfig } from '@@@name@@/config';
|
|
6
|
+
import { SystemBillingRepository, createDatabase } from '@@@name@@/database';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Operator command: `make set-prices Env=<name> [ARGS=path/to/prices.json]`
|
|
10
|
+
* (default: `apps/api/seed/prices.json`).
|
|
11
|
+
*
|
|
12
|
+
* Creates the Razorpay plans the prices file lists, with this environment's keys (Test or
|
|
13
|
+
* Live), and records each plan's ID. Safe to run again: a price already recorded at the
|
|
14
|
+
* same amount is left alone.
|
|
15
|
+
*/
|
|
16
|
+
const given = process.argv[2];
|
|
17
|
+
const path = given
|
|
18
|
+
? resolve(process.env.INIT_CWD ?? process.cwd(), given)
|
|
19
|
+
: fileURLToPath(new URL('../seed/prices.json', import.meta.url));
|
|
20
|
+
|
|
21
|
+
const config = loadConfig();
|
|
22
|
+
const razorpay = config.payments.razorpay ? new RazorpayGateway(config.payments.razorpay) : null;
|
|
23
|
+
const system = createDatabase(config.database.systemUrl, { max: 1 });
|
|
24
|
+
try {
|
|
25
|
+
process.exitCode = await runSetPrices(new SystemBillingRepository(system.db), {
|
|
26
|
+
path,
|
|
27
|
+
appName: '@@Name@@',
|
|
28
|
+
razorpay,
|
|
29
|
+
});
|
|
30
|
+
} finally {
|
|
31
|
+
await system.close();
|
|
32
|
+
}
|