@haatlabs-core/cli 0.0.0-stage → 0.11.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Haatlabs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,96 @@
1
- # Temporary Holding Version
1
+ # @haatlabs-core/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `haatlabs`: writes a project's managed files from `@haatlabs-core/templates`, and makes new
4
+ projects.
5
+
6
+ ## Install
7
+
8
+ pnpm add @haatlabs-core/cli --save-dev
9
+
10
+ or, to make a new app: `npx @haatlabs-core/cli create <name> --domain <domain>`.
11
+
12
+ ## In a project
13
+
14
+ Each project has `@haatlabs-core/cli` as a devDependency, at its platform version, and a
15
+ `platform.json` that says what the templates need to know (name, domain, port series, apps,
16
+ CSP lists, memory limits, shared services, and the paths it keeps as its own in
17
+ `unmanaged`).
18
+
19
+ make sync # pnpm exec haatlabs sync
20
+ make sync-check # pnpm exec haatlabs sync --check
21
+
22
+ - `sync` writes every managed file and records what it wrote in `.platform/managed.json`.
23
+ It refuses to overwrite a file edited since, naming it, and writes nothing then:
24
+ change the template in the platform, or list the path in `unmanaged`. `--force`
25
+ overwrites. It removes a file the templates no longer produce.
26
+ - `sync --check` fails when a managed file differs from what the templates would write.
27
+ - `pnpm-workspace.yaml` is managed only between `# platform:begin` and `# platform:end`;
28
+ the project's own lines go after the block.
29
+ - After moving to a new platform version by hand: `pnpm install`, then `make sync`. The
30
+ upgrade pull requests the platform's release opens have done both.
31
+
32
+ ### `memory` in platform.json
33
+
34
+ The stack's container limits and the Node processes' memory and concurrency, all optional
35
+ except as defaulted. A small host might say:
36
+
37
+ "memory": { "api": "320m", "redis": "48m", "redisMaxMemory": "32mb", "nodeHeapMb": 128, "workerConcurrency": 2 }
38
+
39
+ - `api` (default `512m`) and `redis` (default `256m`): the containers' memory limits.
40
+ `workerMemory` (default `1g`) is the worker's.
41
+ - `redisMaxMemory` (default `128mb`): Redis's own maxmemory, which must be below the redis
42
+ limit (the copy Redis makes of itself while it rewrites its file needs the room). The
43
+ schema only refuses a value at or above the limit; leaving real headroom for that copy
44
+ is the project's job.
45
+ - `nodeHeapMb`: a Node heap cap (`--max-old-space-size`) for the api and the worker, so
46
+ Node throws before Docker kills the container. It must be below the api limit and
47
+ `workerMemory`. Unset, Node keeps its own default.
48
+ - `workerConcurrency`: the worker's `WORKER_CONCURRENCY`, which wins over the env file's.
49
+
50
+ Without `memory`, nothing changes. A refused value fails `sync` with the field named.
51
+
52
+ ### `memory.cache`
53
+
54
+ "memory": { …, "cache": {} }
55
+
56
+ A Redis of the environment's own for caches (`maxMemory` 8mb in a `limit` of 16m by
57
+ default): `allkeys-lru`, nothing on disk, never the queues' Redis. The api and worker get
58
+ `CACHE_REDIS_URL=redis://cache:6379`. `maxMemory` must be below `limit`.
59
+
60
+ ### The name
61
+
62
+ Lowercase letters and digits, single hyphens between them, starting with a letter, 2 to 31
63
+ characters (`haatlabs-api`). Postgres identifiers, Prometheus metrics and variable names take
64
+ it with underscores (`nameSnake`: `haatlabs_api`, `HAATLABS_API_…`); everything else keeps the
65
+ hyphen.
66
+
67
+ ## A new project
68
+
69
+ npx @haatlabs-core/cli create <name> --domain <domain> [--kind shopify|web] \
70
+ [--infra standalone|haatlabs] [--port-series <1-9>] [--into <directory>] [--no-install] [--no-git]
71
+
72
+ - `--kind shopify` (the default): the api, worker, dashboard, the embedded Shopify app, the
73
+ administrators' dashboard, billing and plans. `--kind web`: the same without Shopify
74
+ (email sign-in, organizations, Stripe and Razorpay plans).
75
+ - `--infra standalone` (the default): the app brings its own Postgres, Redis and Caddy
76
+ (HTTPS) and deploys to any Debian or Ubuntu server; it owns every file, `LICENSE` and
77
+ `NOTICE` (Apache-2.0) included, and needs no token. `--infra haatlabs`: one of our own apps,
78
+ on Haatlabs' hosts, with the managed files `haatlabs sync` keeps in step; it prints what to
79
+ add to the edge, the database and GitHub.
80
+
81
+ `--port-series` (required with `--infra haatlabs`; 1 for a standalone app) picks the ports:
82
+ `<series>X00` for the api and `<series>X01` for the worker (X: 1 prod, 2 staging, 3 dev,
83
+ 4 local); 4, 5 and 6 are taken by our own apps.
84
+
85
+ ### A browser extension of an app
86
+
87
+ npx @haatlabs-core/cli create <name> --kind extension --app-domain <domain> [--app-name <name>]
88
+
89
+ A side panel for Chrome and Edge on `@haatlabs-core/extension-ui` and
90
+ `@haatlabs-core/extension-kit`, signed in through the app's own connect page
91
+ (`https://app.<domain>/connect/extension`, which hands the key over as `<app-name>.connected`;
92
+ the app's name is the project's without `-extension` by default) and calling its API
93
+ (`https://api.<domain>`). `make key` gives its id for the app's `CONNECTABLE_EXTENSION_IDS`;
94
+ `make extension-zip` writes the Chrome Web Store (and Edge Add-ons) upload. Firefox's web pages
95
+ cannot hand a key to an extension, so this sign-in is for Chrome and Edge; an app with its own
96
+ OAuth server can sign an extension in on Firefox with the kit's `startOAuthPkce`.
@@ -0,0 +1,6 @@
1
+ export declare const BEGIN = "# platform:begin";
2
+ export declare const END = "# platform:end";
3
+ /** The managed block of a file, markers included, or null when the file has none. */
4
+ export declare function blockOf(text: string): string | null;
5
+ /** The file with its block replaced; a new file, or one without markers, becomes the block alone. */
6
+ export declare function withBlock(existing: string | null, block: string): string;
package/dist/block.js ADDED
@@ -0,0 +1,20 @@
1
+ export const BEGIN = '# platform:begin';
2
+ export const END = '# platform:end';
3
+ /** The managed block of a file, markers included, or null when the file has none. */
4
+ export function blockOf(text) {
5
+ const start = text.indexOf(`${BEGIN}\n`);
6
+ if (start === -1)
7
+ return null;
8
+ const end = text.indexOf(END, start);
9
+ if (end === -1)
10
+ return null;
11
+ return text.slice(start, end + END.length);
12
+ }
13
+ /** The file with its block replaced; a new file, or one without markers, becomes the block alone. */
14
+ export function withBlock(existing, block) {
15
+ const current = existing === null ? null : blockOf(existing);
16
+ if (existing === null || current === null)
17
+ return `${block}\n`;
18
+ return existing.replace(current, () => block);
19
+ }
20
+ //# sourceMappingURL=block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.js","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC;AACxC,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAgB,CAAC;AAEpC,qFAAqF;AACrF,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,SAAS,CAAC,QAAuB,EAAE,KAAa;IAC9D,MAAM,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IAC/D,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import { create, createExtension } from './create.js';
4
+ import { INFRAS, KINDS } from './platform-json.js';
5
+ import { sync } from './sync.js';
6
+ const USAGE = `usage:
7
+ haatlabs sync [--check] [--force] [--dir <project>]
8
+ haatlabs create <name> --domain <domain> [--kind shopify|web] [--infra standalone|haatlabs] [--port-series <1-9>]
9
+ [--into <directory>] [--no-install] [--no-git]
10
+ haatlabs create <name> --kind extension --app-domain <domain> [--app-name <name>]
11
+ [--into <directory>] [--no-install] [--no-git]`;
12
+ async function main(argv) {
13
+ const [command, ...rest] = argv;
14
+ if (command === 'sync') {
15
+ const { values } = parseArgs({
16
+ args: rest,
17
+ options: { check: { type: 'boolean' }, force: { type: 'boolean' }, dir: { type: 'string' } },
18
+ });
19
+ const result = await sync({
20
+ dir: values.dir ?? process.cwd(),
21
+ check: values.check,
22
+ force: values.force,
23
+ });
24
+ if (values.check) {
25
+ for (const problem of result.problems)
26
+ console.error(problem);
27
+ if (result.problems.length > 0) {
28
+ console.error('the managed files differ from the templates: run make sync');
29
+ return 1;
30
+ }
31
+ console.log('managed files match the templates');
32
+ return 0;
33
+ }
34
+ for (const path of result.written)
35
+ console.log(`wrote ${path}`);
36
+ for (const path of result.removed)
37
+ console.log(`removed ${path}`);
38
+ if (result.written.length + result.removed.length === 0)
39
+ console.log('managed files already up to date');
40
+ return 0;
41
+ }
42
+ if (command === 'create') {
43
+ const { values, positionals } = parseArgs({
44
+ args: rest,
45
+ allowPositionals: true,
46
+ allowNegative: true,
47
+ options: {
48
+ domain: { type: 'string' },
49
+ 'port-series': { type: 'string' },
50
+ into: { type: 'string' },
51
+ kind: { type: 'string' },
52
+ infra: { type: 'string' },
53
+ 'app-domain': { type: 'string' },
54
+ 'app-name': { type: 'string' },
55
+ install: { type: 'boolean', default: true },
56
+ git: { type: 'boolean', default: true },
57
+ },
58
+ });
59
+ const [name] = positionals;
60
+ if (values.kind === 'extension') {
61
+ if (!name || !values['app-domain']) {
62
+ console.error(USAGE);
63
+ return 2;
64
+ }
65
+ await createExtension({
66
+ name,
67
+ appDomain: values['app-domain'],
68
+ ...(values['app-name'] ? { appName: values['app-name'] } : {}),
69
+ into: values.into ?? process.cwd(),
70
+ install: values.install,
71
+ git: values.git,
72
+ });
73
+ return 0;
74
+ }
75
+ const kind = values.kind ?? 'shopify';
76
+ const infra = values.infra ?? 'standalone';
77
+ if (!name ||
78
+ !values.domain ||
79
+ !KINDS.includes(kind) ||
80
+ !INFRAS.includes(infra)) {
81
+ console.error(USAGE);
82
+ return 2;
83
+ }
84
+ await create({
85
+ name,
86
+ domain: values.domain,
87
+ ...(values['port-series'] ? { portSeries: Number(values['port-series']) } : {}),
88
+ kind: kind,
89
+ infra: infra,
90
+ into: values.into ?? process.cwd(),
91
+ install: values.install,
92
+ git: values.git,
93
+ });
94
+ return 0;
95
+ }
96
+ console.error(USAGE);
97
+ return 2;
98
+ }
99
+ main(process.argv.slice(2)).then((code) => process.exit(code), (error) => {
100
+ console.error(error instanceof Error ? error.message : error);
101
+ process.exit(1);
102
+ });
103
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,KAAK,GAAG;;;;;iEAKmD,CAAC;AAElE,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;YAC3B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE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AAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { PlatformConfig } from './platform-json.js';
2
+ declare const ENVIRONMENTS: {
3
+ readonly prod: 1;
4
+ readonly staging: 2;
5
+ readonly dev: 3;
6
+ readonly local: 4;
7
+ };
8
+ export type Environment = keyof typeof ENVIRONMENTS;
9
+ export type PortName = 'api' | 'worker' | 'web' | 'shopify' | 'admin';
10
+ export interface TemplateContext {
11
+ vars: Record<string, string>;
12
+ conditions: Record<string, boolean>;
13
+ }
14
+ /** <series>X00 api, X01 worker, X10 web, X20 shopify, X30 admin; X is 1 prod, 2 staging, 3 dev, 4 local. */
15
+ export declare function portsOf(config: PlatformConfig): Record<Environment, Record<PortName, number>>;
16
+ /** The values and conditions a template is rendered with, for one project. */
17
+ export declare function contextOf(config: PlatformConfig, extra?: Record<string, string>): TemplateContext;
18
+ export {};
@@ -0,0 +1,100 @@
1
+ const ENVIRONMENTS = { prod: 1, staging: 2, dev: 3, local: 4 };
2
+ /** <series>X00 api, X01 worker, X10 web, X20 shopify, X30 admin; X is 1 prod, 2 staging, 3 dev, 4 local. */
3
+ export function portsOf(config) {
4
+ const result = {};
5
+ for (const [environment, digit] of Object.entries(ENVIRONMENTS)) {
6
+ const base = config.portSeries * 1000 + digit * 100;
7
+ result[environment] = {
8
+ api: base,
9
+ worker: base + 1,
10
+ web: base + 10,
11
+ shopify: base + 20,
12
+ admin: base + 30,
13
+ ...config.ports[environment],
14
+ };
15
+ }
16
+ return result;
17
+ }
18
+ /** The values and conditions a template is rendered with, for one project. */
19
+ export function contextOf(config, extra = {}) {
20
+ // Postgres identifiers, Prometheus metric names and environment variables take no hyphen;
21
+ // everything else (Docker, npm, Redis, cookies, DNS) keeps the project's real name.
22
+ const nameSnake = config.name.replaceAll('-', '_');
23
+ const vars = {
24
+ name: config.name,
25
+ nameSnake,
26
+ Name: config.title ?? config.name.charAt(0).toUpperCase() + config.name.slice(1),
27
+ NAME: nameSnake.toUpperCase(),
28
+ domain: config.domain,
29
+ workerMemory: config.workerMemory,
30
+ 'memory.api': config.memory.api,
31
+ 'memory.redis': config.memory.redis,
32
+ 'memory.redisMaxMemory': config.memory.redisMaxMemory,
33
+ 'csp.connectSrc': config.csp.connectSrc.join(' '),
34
+ 'csp.imgSrc': config.csp.imgSrc.join(' '),
35
+ 'csp.connectSrcPrefixed': config.csp.connectSrc.map((source) => ` ${source}`).join(''),
36
+ 'csp.imgSrcPrefixed': config.csp.imgSrc.map((source) => ` ${source}`).join(''),
37
+ };
38
+ // A new project's own containers on a laptop: clear of the ports the three first
39
+ // projects chose by hand, whatever its series.
40
+ const series = config.portSeries;
41
+ vars.portSeries = String(series);
42
+ vars['port.local.postgres'] = String(55029 + 100 * series);
43
+ vars['port.local.redis'] = String(64009 + 100 * series);
44
+ vars['port.local.cache'] = String(64019 + 100 * series);
45
+ vars['port.local.mail'] = String(8309 + 10 * series);
46
+ vars['port.local.smtp'] = String(10509 + 10 * series);
47
+ for (const [environment, ports] of Object.entries(portsOf(config))) {
48
+ for (const [name, value] of Object.entries(ports))
49
+ vars[`port.${environment}.${name}`] = String(value);
50
+ }
51
+ vars.combinedEnvs = config.combinedWorker.join(' ');
52
+ vars['memory.combinedApi'] = config.memory.combinedApi;
53
+ vars['memory.combinedHeapMb'] = String(config.memory.combinedHeapMb);
54
+ if (config.memory.nodeHeapMb !== undefined)
55
+ vars['memory.nodeHeapMb'] = String(config.memory.nodeHeapMb);
56
+ if (config.memory.workerConcurrency !== undefined) {
57
+ vars['memory.workerConcurrency'] = String(config.memory.workerConcurrency);
58
+ }
59
+ if (config.memory.cache) {
60
+ vars['memory.cache.maxMemory'] = config.memory.cache.maxMemory;
61
+ vars['memory.cache.limit'] = config.memory.cache.limit;
62
+ }
63
+ // What ci.yml says its runs never reach.
64
+ vars.ciTalksTo = config.apps.includes('shopify')
65
+ ? 'Shopify, a payment gateway'
66
+ : 'a payment gateway';
67
+ // The project's own pnpm-workspace entries: whole lines, each starting with a newline, so
68
+ // a project with none renders the block as it was.
69
+ const yamlKey = (key) => (/^[a-z0-9][a-z0-9._-]*$/i.test(key) ? key : `'${key}'`);
70
+ vars['workspace.allowBuilds'] = Object.entries(config.workspace?.allowBuilds ?? {})
71
+ .map(([name, allowed]) => `\n ${yamlKey(name)}: ${allowed}`)
72
+ .join('');
73
+ vars['workspace.minimumReleaseAgeExclude'] = (config.workspace?.minimumReleaseAgeExclude ?? [])
74
+ .map((name) => `\n - ${yamlKey(name)}`)
75
+ .join('');
76
+ const image = config.sharedServices?.image;
77
+ if (image) {
78
+ vars.sharedImage = image;
79
+ vars.sharedImageVar = `${image.toUpperCase().replaceAll('-', '_')}_IMAGE`;
80
+ }
81
+ return {
82
+ vars: { ...vars, ...extra },
83
+ conditions: {
84
+ web: config.apps.includes('web'),
85
+ shopify: config.apps.includes('shopify'),
86
+ admin: config.apps.includes('admin'),
87
+ dashboards: ['web', 'shopify', 'admin'].some((app) => config.apps.includes(app)),
88
+ sharedServices: config.sharedServices !== undefined,
89
+ sharedImage: image !== undefined,
90
+ combinedWorker: config.combinedWorker.length > 0,
91
+ registryGithub: config.registry === 'github',
92
+ nodeHeap: config.memory.nodeHeapMb !== undefined,
93
+ workerConcurrency: config.memory.workerConcurrency !== undefined,
94
+ cache: config.memory.cache !== undefined,
95
+ standalone: config.infra === 'standalone',
96
+ kindShopify: config.kind === 'shopify',
97
+ },
98
+ };
99
+ }
100
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAC;AASxE,4GAA4G;AAC5G,MA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CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAU,CAAC,CAAC;YACvF,cAAc,EAAE,MAAM,CAAC,cAAc,KAAK,SAAS;YACnD,WAAW,EAAE,KAAK,KAAK,SAAS;YAChC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;YAChD,cAAc,EAAE,MAAM,CAAC,QAAQ,KAAK,QAAQ;YAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS;YAChD,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS;YAChE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS;YACxC,UAAU,EAAE,MAAM,CAAC,KAAK,KAAK,YAAY;YACzC,WAAW,EAAE,MAAM,CAAC,IAAI,KAAK,SAAS;SACvC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Infra, Kind } from './platform-json.js';
2
+ export interface CreateOptions {
3
+ name: string;
4
+ domain: string;
5
+ /**
6
+ * The project's port series (1 to 9), which keeps our own apps apart on shared hosts. A
7
+ * standalone app has a server of its own: 1 unless given. Required with `infra: haatlabs`.
8
+ */
9
+ portSeries?: number;
10
+ /** The directory the project's own directory is made in. */
11
+ into: string;
12
+ /** A Shopify app (the default) or a plain web app. */
13
+ kind?: Kind;
14
+ /** Its own Postgres, Redis and proxy (the default), or Haatlabs' hosts with `haatlabs sync`. */
15
+ infra?: Infra;
16
+ /**
17
+ * Where the app installs the platform from. Default: the registry this CLI itself came
18
+ * from (ownRegistry), so `npx @haatlabs-core/cli create` makes an app that needs no token.
19
+ */
20
+ registry?: 'github' | 'npm';
21
+ /** Installs the dependencies, which writes pnpm-lock.yaml. */
22
+ install?: boolean;
23
+ /** Makes the directory a git repository with one commit. */
24
+ git?: boolean;
25
+ log?: (line: string) => void;
26
+ }
27
+ /**
28
+ * The registry a package of the platform came from: the npm copy says so in its own
29
+ * package.json (`platformRegistry: "npm"`, written when it is published); ours says nothing.
30
+ * Never read from the package's name: the npm copy's code is the same code, renamed.
31
+ */
32
+ export declare function ownRegistry(pkg: {
33
+ platformRegistry?: string;
34
+ }): 'github' | 'npm';
35
+ /**
36
+ * Whether a template file is written executable. npm and pnpm pack every file but a bin as
37
+ * 0644, so an installed template has lost its mode: a shell script is executable by its name.
38
+ */
39
+ export declare function executableTemplate(path: string, mode: number): boolean;
40
+ /**
41
+ * A new project with everything the platform's apps have: the starter, rendered for its
42
+ * name, series and domain, then every managed file (`haatlabs sync`). Returns its directory.
43
+ */
44
+ export declare function create(options: CreateOptions): Promise<string>;
45
+ export interface CreateExtensionOptions {
46
+ /** The extension project's name, such as `acme-extension`. */
47
+ name: string;
48
+ /** The app's domain: its dashboard is https://app.<domain>, its API https://api.<domain>. */
49
+ appDomain: string;
50
+ /**
51
+ * The app's own name, which its connect page sends the key with (`<app>.connected`); by
52
+ * default the project's name without `-extension`.
53
+ */
54
+ appName?: string;
55
+ /** Where its @haatlabs-core packages come from: by default, where this CLI came from. */
56
+ registry?: 'github' | 'npm';
57
+ into: string;
58
+ install?: boolean;
59
+ git?: boolean;
60
+ log?: (line: string) => void;
61
+ }
62
+ /**
63
+ * A browser extension of an app made on the platform: a side panel that signs in through the
64
+ * app's connect page and calls its API (`@haatlabs-core/extension-ui`, `@haatlabs-core/extension-kit`).
65
+ * It owns its files; there is no platform.json and no sync. Returns its directory.
66
+ */
67
+ export declare function createExtension(options: CreateExtensionOptions): Promise<string>;