@basaltkit/deploy 0.3.0 → 0.3.1
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/README.md +7 -7
- package/dist/config.d.ts +5 -5
- package/dist/env-check.d.ts +1 -1
- package/dist/env-check.js +1 -1
- package/dist/init.js +2 -2
- package/dist/services.d.ts +1 -1
- package/dist/services.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,8 +31,8 @@ and runs `check` on what it wrote.
|
|
|
31
31
|
import { apache, ask, defineDeploy, dockerInfra, pm2, secret } from '@basaltkit/deploy'
|
|
32
32
|
|
|
33
33
|
export default defineDeploy({
|
|
34
|
-
app: '
|
|
35
|
-
domain: '
|
|
34
|
+
app: 'acme', // names everything it owns: acme-api, acme-pg, …
|
|
35
|
+
domain: 'acme.example.com',
|
|
36
36
|
tenants: 'subdomain', // also checks the *.domain certificate and DNS
|
|
37
37
|
branch: 'master',
|
|
38
38
|
env: {
|
|
@@ -41,14 +41,14 @@ export default defineDeploy({
|
|
|
41
41
|
generate: { APP_SECRET: secret(32) },
|
|
42
42
|
ask: {
|
|
43
43
|
MAILER_URL: ask.secret('SMTP URL', { optional: true }),
|
|
44
|
-
|
|
44
|
+
PAYCO_SECRET_TOKEN: ask.secret('PayCo token'),
|
|
45
45
|
},
|
|
46
|
-
derive: ({ domain }) => ({
|
|
47
|
-
forbid: ['
|
|
46
|
+
derive: ({ domain }) => ({ PAYCO_CALLBACK_URL: `https://${domain}/api/webhooks/payco` }),
|
|
47
|
+
forbid: ['PAYCO_FAKE'],
|
|
48
48
|
},
|
|
49
|
-
infra: dockerInfra('
|
|
49
|
+
infra: dockerInfra('acme', {
|
|
50
50
|
postgres: { urlParams: { schema: 'public' } },
|
|
51
|
-
minio: { buckets: ['
|
|
51
|
+
minio: { buckets: ['acme-documents', 'acme-backups'] },
|
|
52
52
|
}),
|
|
53
53
|
build: { prisma: ['prisma.config.ts', 'prisma/tenants/prisma.config.ts'], web: 'web' },
|
|
54
54
|
migrate: { central: true, tenants: true },
|
package/dist/config.d.ts
CHANGED
|
@@ -25,12 +25,12 @@ export interface DeployConfig<E extends object = EnvShape> {
|
|
|
25
25
|
/**
|
|
26
26
|
* Owner label: names every process, container, volume, vhost and backup.
|
|
27
27
|
* `[a-z][a-z0-9-]{1,30}`.
|
|
28
|
-
* @example '
|
|
28
|
+
* @example 'acme'
|
|
29
29
|
*/
|
|
30
30
|
app: string;
|
|
31
31
|
/**
|
|
32
32
|
* The apex the app answers on.
|
|
33
|
-
* @example '
|
|
33
|
+
* @example 'acme.example.com'
|
|
34
34
|
*/
|
|
35
35
|
domain: string;
|
|
36
36
|
/**
|
|
@@ -108,7 +108,7 @@ export interface EnvConfig<E extends object = EnvShape> {
|
|
|
108
108
|
* Relative to the app directory, or absolute. Written 0600, backed up
|
|
109
109
|
* before every change, in its own directory.
|
|
110
110
|
* @default '.env'
|
|
111
|
-
* @example '/etc/
|
|
111
|
+
* @example '/etc/globex/api.env'
|
|
112
112
|
*/
|
|
113
113
|
file?: string;
|
|
114
114
|
/** Exact copies of the file (0600), rewritten with it; one that differs is a C10 error. */
|
|
@@ -202,7 +202,7 @@ export interface ExternalPostgres<E extends object = EnvShape> {
|
|
|
202
202
|
* there when absent), and granted DML through the owner's default privileges.
|
|
203
203
|
*/
|
|
204
204
|
export interface AppRole<E extends object = EnvShape> {
|
|
205
|
-
/** @example '
|
|
205
|
+
/** @example 'globex_app' */
|
|
206
206
|
name: string;
|
|
207
207
|
/** The `.env` key with the app's URL. */
|
|
208
208
|
urlKey: EnvKey<E>;
|
|
@@ -287,7 +287,7 @@ export interface MigrateConfig<E extends object = EnvShape> {
|
|
|
287
287
|
command?: string[];
|
|
288
288
|
/**
|
|
289
289
|
* Values that override the `.env` for the migration and the pre-migration
|
|
290
|
-
* dump — e.g. URLs that name a container (`@
|
|
290
|
+
* dump — e.g. URLs that name a container (`@globex-postgres:`) rewritten to
|
|
291
291
|
* reach it from the host (`@127.0.0.1:`).
|
|
292
292
|
*/
|
|
293
293
|
env?: (values: ReadonlyMap<EnvKey<E>, string>) => {
|
package/dist/env-check.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function checkSchema(ctx: DeployContext, values: Map<string, stri
|
|
|
8
8
|
/**
|
|
9
9
|
* C6 — a value written to turn something OFF that the schema reads as ON.
|
|
10
10
|
* `z.coerce.boolean()` is `Boolean(string)`: every non-empty string is true,
|
|
11
|
-
* "0" and "false" included. `
|
|
11
|
+
* "0" and "false" included. `PAYCO_FAKE="0"` switched the fake payment
|
|
12
12
|
* gateway on in production. Generic on purpose: it needs no list of boolean
|
|
13
13
|
* keys, only the parsed result (prefixed names — `MY_APP_FLAG` for `FLAG` —
|
|
14
14
|
* are matched too).
|
package/dist/env-check.js
CHANGED
|
@@ -59,7 +59,7 @@ const FALSY = new Set(['0', 'false', 'no', 'off']);
|
|
|
59
59
|
/**
|
|
60
60
|
* C6 — a value written to turn something OFF that the schema reads as ON.
|
|
61
61
|
* `z.coerce.boolean()` is `Boolean(string)`: every non-empty string is true,
|
|
62
|
-
* "0" and "false" included. `
|
|
62
|
+
* "0" and "false" included. `PAYCO_FAKE="0"` switched the fake payment
|
|
63
63
|
* gateway on in production. Generic on purpose: it needs no list of boolean
|
|
64
64
|
* keys, only the parsed result (prefixed names — `MY_APP_FLAG` for `FLAG` —
|
|
65
65
|
* are matched too).
|
package/dist/init.js
CHANGED
|
@@ -9,7 +9,7 @@ const SENSITIVE = /SECRET|TOKEN|PASSWORD|PASS\b|_KEY\b|^KEY_|CREDENTIAL|_URL$|_D
|
|
|
9
9
|
* the server. One a provider issues (S3, an API, SMTP) is asked instead — a
|
|
10
10
|
* random value would only fail at the first call.
|
|
11
11
|
*/
|
|
12
|
-
const ISSUED = /S3|AWS|ACCESS_KEY|API_?KEY|TOKEN|SMTP|MAIL|OAUTH|CLIENT|STRIPE|
|
|
12
|
+
const ISSUED = /S3|AWS|ACCESS_KEY|API_?KEY|TOKEN|SMTP|MAIL|OAUTH|CLIENT|STRIPE|PAYCO|TWILIO|SENDGRID|PASSWORD/;
|
|
13
13
|
// ── detection ──────────────────────────────────────────────────────────────
|
|
14
14
|
export async function detectProject(host, dir, options = {}) {
|
|
15
15
|
const pkg = parseJson(await host.readFile(`${dir}/package.json`));
|
|
@@ -427,7 +427,7 @@ function block(name, entries) {
|
|
|
427
427
|
return [` ${name}: { ${entries.join(', ')} },`];
|
|
428
428
|
return [` ${name}: {`, ...entries.map((e) => ` ${e},`), ' },'];
|
|
429
429
|
}
|
|
430
|
-
/** `
|
|
430
|
+
/** `GLOBEX_SMTP_URL` → `SMTP URL`: the prompt the operator sees once. */
|
|
431
431
|
function label(key, app) {
|
|
432
432
|
const prefix = `${app.toUpperCase().replace(/-/g, '_')}_`;
|
|
433
433
|
return (key.startsWith(prefix) ? key.slice(prefix.length) : key).replace(/_/g, ' ');
|
package/dist/services.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare function appRoleEnv(ctx: DeployContext, values: Map<string, strin
|
|
|
45
45
|
/**
|
|
46
46
|
* The role exists, logs in with the `.env`'s password, and gets DML on what the
|
|
47
47
|
* owner creates in `public` (default privileges — never on existing tables: an
|
|
48
|
-
* app may keep some append-only, as
|
|
48
|
+
* app may keep some append-only, as Globex's audit log is).
|
|
49
49
|
*/
|
|
50
50
|
export declare function ensureAppRole(ctx: DeployContext, pg: PostgresHandle, role: AppRole, values: Map<string, string>): Promise<string>;
|
|
51
51
|
/**
|
package/dist/services.js
CHANGED
|
@@ -74,7 +74,7 @@ async function psql(ctx, pg, sql, as) {
|
|
|
74
74
|
/**
|
|
75
75
|
* The role exists, logs in with the `.env`'s password, and gets DML on what the
|
|
76
76
|
* owner creates in `public` (default privileges — never on existing tables: an
|
|
77
|
-
* app may keep some append-only, as
|
|
77
|
+
* app may keep some append-only, as Globex's audit log is).
|
|
78
78
|
*/
|
|
79
79
|
export async function ensureAppRole(ctx, pg, role, values) {
|
|
80
80
|
const raw = values.get(role.urlKey);
|