@endora-commerce/cli 0.100.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 +21 -0
- package/README.md +37 -0
- package/dist/bin/endora.d.ts +28 -0
- package/dist/bin/endora.d.ts.map +1 -0
- package/dist/bin/endora.js +926 -0
- package/dist/bin/endora.js.map +1 -0
- package/dist/check/estate.d.ts +189 -0
- package/dist/check/estate.d.ts.map +1 -0
- package/dist/check/estate.js +1037 -0
- package/dist/check/estate.js.map +1 -0
- package/dist/check/hosts.d.ts +25 -0
- package/dist/check/hosts.d.ts.map +1 -0
- package/dist/check/hosts.js +1347 -0
- package/dist/check/hosts.js.map +1 -0
- package/dist/check/index.d.ts +60 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +111 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/layout.d.ts +136 -0
- package/dist/check/layout.d.ts.map +1 -0
- package/dist/check/layout.js +262 -0
- package/dist/check/layout.js.map +1 -0
- package/dist/check/ledger.d.ts +98 -0
- package/dist/check/ledger.d.ts.map +1 -0
- package/dist/check/ledger.js +173 -0
- package/dist/check/ledger.js.map +1 -0
- package/dist/check/peer-owners.d.ts +116 -0
- package/dist/check/peer-owners.d.ts.map +1 -0
- package/dist/check/peer-owners.js +225 -0
- package/dist/check/peer-owners.js.map +1 -0
- package/dist/check/report.d.ts +33 -0
- package/dist/check/report.d.ts.map +1 -0
- package/dist/check/report.js +107 -0
- package/dist/check/report.js.map +1 -0
- package/dist/check/run.d.ts +147 -0
- package/dist/check/run.d.ts.map +1 -0
- package/dist/check/run.js +111 -0
- package/dist/check/run.js.map +1 -0
- package/dist/checks.d.ts +17 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +17 -0
- package/dist/checks.js.map +1 -0
- package/dist/dev/index.d.ts +83 -0
- package/dist/dev/index.d.ts.map +1 -0
- package/dist/dev/index.js +298 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/generate/divergence.d.ts +38 -0
- package/dist/generate/divergence.d.ts.map +1 -0
- package/dist/generate/divergence.js +237 -0
- package/dist/generate/divergence.js.map +1 -0
- package/dist/generate/index.d.ts +90 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +369 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/declaration.d.ts +18 -0
- package/dist/inputs/declaration.d.ts.map +1 -0
- package/dist/inputs/declaration.js +64 -0
- package/dist/inputs/declaration.js.map +1 -0
- package/dist/inputs/env-file.d.ts +73 -0
- package/dist/inputs/env-file.d.ts.map +1 -0
- package/dist/inputs/env-file.js +134 -0
- package/dist/inputs/env-file.js.map +1 -0
- package/dist/inputs/prompt.d.ts +21 -0
- package/dist/inputs/prompt.d.ts.map +1 -0
- package/dist/inputs/prompt.js +59 -0
- package/dist/inputs/prompt.js.map +1 -0
- package/dist/inputs/resolve.d.ts +163 -0
- package/dist/inputs/resolve.d.ts.map +1 -0
- package/dist/inputs/resolve.js +290 -0
- package/dist/inputs/resolve.js.map +1 -0
- package/dist/install/host.d.ts +27 -0
- package/dist/install/host.d.ts.map +1 -0
- package/dist/install/host.js +90 -0
- package/dist/install/host.js.map +1 -0
- package/dist/install/index.d.ts +173 -0
- package/dist/install/index.d.ts.map +1 -0
- package/dist/install/index.js +793 -0
- package/dist/install/index.js.map +1 -0
- package/dist/install/wizard.d.ts +144 -0
- package/dist/install/wizard.d.ts.map +1 -0
- package/dist/install/wizard.js +362 -0
- package/dist/install/wizard.js.map +1 -0
- package/dist/lib/admin-artefacts.d.ts +70 -0
- package/dist/lib/admin-artefacts.d.ts.map +1 -0
- package/dist/lib/admin-artefacts.js +354 -0
- package/dist/lib/admin-artefacts.js.map +1 -0
- package/dist/lib/admin-surfaces.d.ts +298 -0
- package/dist/lib/admin-surfaces.d.ts.map +1 -0
- package/dist/lib/admin-surfaces.js +669 -0
- package/dist/lib/admin-surfaces.js.map +1 -0
- package/dist/lib/delegated-composer.d.ts +85 -0
- package/dist/lib/delegated-composer.d.ts.map +1 -0
- package/dist/lib/delegated-composer.js +241 -0
- package/dist/lib/delegated-composer.js.map +1 -0
- package/dist/lib/divergence-artefacts.d.ts +305 -0
- package/dist/lib/divergence-artefacts.d.ts.map +1 -0
- package/dist/lib/divergence-artefacts.js +828 -0
- package/dist/lib/divergence-artefacts.js.map +1 -0
- package/dist/lib/divergence.d.ts +337 -0
- package/dist/lib/divergence.d.ts.map +1 -0
- package/dist/lib/divergence.js +1005 -0
- package/dist/lib/divergence.js.map +1 -0
- package/dist/lib/docs-artefacts.d.ts +395 -0
- package/dist/lib/docs-artefacts.d.ts.map +1 -0
- package/dist/lib/docs-artefacts.js +781 -0
- package/dist/lib/docs-artefacts.js.map +1 -0
- package/dist/lib/emitted-exports.d.ts +21 -0
- package/dist/lib/emitted-exports.d.ts.map +1 -0
- package/dist/lib/emitted-exports.js +96 -0
- package/dist/lib/emitted-exports.js.map +1 -0
- package/dist/lib/emitted-freshness.d.ts +112 -0
- package/dist/lib/emitted-freshness.d.ts.map +1 -0
- package/dist/lib/emitted-freshness.js +288 -0
- package/dist/lib/emitted-freshness.js.map +1 -0
- package/dist/lib/entity-index-artefact.d.ts +95 -0
- package/dist/lib/entity-index-artefact.d.ts.map +1 -0
- package/dist/lib/entity-index-artefact.js +210 -0
- package/dist/lib/entity-index-artefact.js.map +1 -0
- package/dist/lib/instance-build-inputs.d.ts +108 -0
- package/dist/lib/instance-build-inputs.d.ts.map +1 -0
- package/dist/lib/instance-build-inputs.js +165 -0
- package/dist/lib/instance-build-inputs.js.map +1 -0
- package/dist/lib/module-docs.d.ts +473 -0
- package/dist/lib/module-docs.d.ts.map +1 -0
- package/dist/lib/module-docs.js +711 -0
- package/dist/lib/module-docs.js.map +1 -0
- package/dist/lib/module-package-subpaths.d.ts +56 -0
- package/dist/lib/module-package-subpaths.d.ts.map +1 -0
- package/dist/lib/module-package-subpaths.js +223 -0
- package/dist/lib/module-package-subpaths.js.map +1 -0
- package/dist/lib/module-packages.d.ts +200 -0
- package/dist/lib/module-packages.d.ts.map +1 -0
- package/dist/lib/module-packages.js +580 -0
- package/dist/lib/module-packages.js.map +1 -0
- package/dist/lib/module-population.d.ts +129 -0
- package/dist/lib/module-population.d.ts.map +1 -0
- package/dist/lib/module-population.js +172 -0
- package/dist/lib/module-population.js.map +1 -0
- package/dist/lib/module-roots.d.ts +337 -0
- package/dist/lib/module-roots.d.ts.map +1 -0
- package/dist/lib/module-roots.js +586 -0
- package/dist/lib/module-roots.js.map +1 -0
- package/dist/lib/nested-checkouts.d.ts +33 -0
- package/dist/lib/nested-checkouts.d.ts.map +1 -0
- package/dist/lib/nested-checkouts.js +160 -0
- package/dist/lib/nested-checkouts.js.map +1 -0
- package/dist/lib/platform-root.d.ts +43 -0
- package/dist/lib/platform-root.d.ts.map +1 -0
- package/dist/lib/platform-root.js +134 -0
- package/dist/lib/platform-root.js.map +1 -0
- package/dist/lib/platform-surface.d.ts +235 -0
- package/dist/lib/platform-surface.d.ts.map +1 -0
- package/dist/lib/platform-surface.js +393 -0
- package/dist/lib/platform-surface.js.map +1 -0
- package/dist/lib/port-registrations.d.ts +223 -0
- package/dist/lib/port-registrations.d.ts.map +1 -0
- package/dist/lib/port-registrations.js +532 -0
- package/dist/lib/port-registrations.js.map +1 -0
- package/dist/lib/read-size.d.ts +154 -0
- package/dist/lib/read-size.d.ts.map +1 -0
- package/dist/lib/read-size.js +182 -0
- package/dist/lib/read-size.js.map +1 -0
- package/dist/lib/registration-owners.d.ts +79 -0
- package/dist/lib/registration-owners.d.ts.map +1 -0
- package/dist/lib/registration-owners.js +77 -0
- package/dist/lib/registration-owners.js.map +1 -0
- package/dist/lib/release-index.d.ts +53 -0
- package/dist/lib/release-index.d.ts.map +1 -0
- package/dist/lib/release-index.js +162 -0
- package/dist/lib/release-index.js.map +1 -0
- package/dist/lib/repeating-timers.d.ts +79 -0
- package/dist/lib/repeating-timers.d.ts.map +1 -0
- package/dist/lib/repeating-timers.js +189 -0
- package/dist/lib/repeating-timers.js.map +1 -0
- package/dist/lib/source-text.d.ts +34 -0
- package/dist/lib/source-text.d.ts.map +1 -0
- package/dist/lib/source-text.js +80 -0
- package/dist/lib/source-text.js.map +1 -0
- package/dist/lib/specifiers.d.ts +20 -0
- package/dist/lib/specifiers.d.ts.map +1 -0
- package/dist/lib/specifiers.js +130 -0
- package/dist/lib/specifiers.js.map +1 -0
- package/dist/lib/sql-tables.d.ts +166 -0
- package/dist/lib/sql-tables.d.ts.map +1 -0
- package/dist/lib/sql-tables.js +464 -0
- package/dist/lib/sql-tables.js.map +1 -0
- package/dist/lib/switchable-modules.d.ts +54 -0
- package/dist/lib/switchable-modules.d.ts.map +1 -0
- package/dist/lib/switchable-modules.js +104 -0
- package/dist/lib/switchable-modules.js.map +1 -0
- package/dist/lib/tailwind-sources.d.ts +136 -0
- package/dist/lib/tailwind-sources.d.ts.map +1 -0
- package/dist/lib/tailwind-sources.js +307 -0
- package/dist/lib/tailwind-sources.js.map +1 -0
- package/dist/lib/ui-layer.d.ts +54 -0
- package/dist/lib/ui-layer.d.ts.map +1 -0
- package/dist/lib/ui-layer.js +57 -0
- package/dist/lib/ui-layer.js.map +1 -0
- package/dist/lib/workspace-packages.d.ts +186 -0
- package/dist/lib/workspace-packages.d.ts.map +1 -0
- package/dist/lib/workspace-packages.js +351 -0
- package/dist/lib/workspace-packages.js.map +1 -0
- package/dist/new-instance/deploy.d.ts +211 -0
- package/dist/new-instance/deploy.d.ts.map +1 -0
- package/dist/new-instance/deploy.js +1381 -0
- package/dist/new-instance/deploy.js.map +1 -0
- package/dist/new-instance/docs-toolchain.d.ts +66 -0
- package/dist/new-instance/docs-toolchain.d.ts.map +1 -0
- package/dist/new-instance/docs-toolchain.js +69 -0
- package/dist/new-instance/docs-toolchain.js.map +1 -0
- package/dist/new-instance/host.d.ts +124 -0
- package/dist/new-instance/host.d.ts.map +1 -0
- package/dist/new-instance/host.js +276 -0
- package/dist/new-instance/host.js.map +1 -0
- package/dist/new-instance/index.d.ts +118 -0
- package/dist/new-instance/index.d.ts.map +1 -0
- package/dist/new-instance/index.js +567 -0
- package/dist/new-instance/index.js.map +1 -0
- package/dist/new-instance/modules.d.ts +188 -0
- package/dist/new-instance/modules.d.ts.map +1 -0
- package/dist/new-instance/modules.js +392 -0
- package/dist/new-instance/modules.js.map +1 -0
- package/dist/new-instance/template.d.ts +505 -0
- package/dist/new-instance/template.d.ts.map +1 -0
- package/dist/new-instance/template.js +1886 -0
- package/dist/new-instance/template.js.map +1 -0
- package/dist/new-module/emit.d.ts +67 -0
- package/dist/new-module/emit.d.ts.map +1 -0
- package/dist/new-module/emit.js +1393 -0
- package/dist/new-module/emit.js.map +1 -0
- package/dist/new-module/host.d.ts +67 -0
- package/dist/new-module/host.d.ts.map +1 -0
- package/dist/new-module/host.js +224 -0
- package/dist/new-module/host.js.map +1 -0
- package/dist/new-module/index.d.ts +32 -0
- package/dist/new-module/index.d.ts.map +1 -0
- package/dist/new-module/index.js +193 -0
- package/dist/new-module/index.js.map +1 -0
- package/dist/new-module/spec.d.ts +188 -0
- package/dist/new-module/spec.d.ts.map +1 -0
- package/dist/new-module/spec.js +404 -0
- package/dist/new-module/spec.js.map +1 -0
- package/dist/new-module/text.d.ts +15 -0
- package/dist/new-module/text.d.ts.map +1 -0
- package/dist/new-module/text.js +22 -0
- package/dist/new-module/text.js.map +1 -0
- package/dist/new-storefront/dockerfile.d.ts +20 -0
- package/dist/new-storefront/dockerfile.d.ts.map +1 -0
- package/dist/new-storefront/dockerfile.js +131 -0
- package/dist/new-storefront/dockerfile.js.map +1 -0
- package/dist/new-storefront/gitignore.d.ts +23 -0
- package/dist/new-storefront/gitignore.d.ts.map +1 -0
- package/dist/new-storefront/gitignore.js +39 -0
- package/dist/new-storefront/gitignore.js.map +1 -0
- package/dist/new-storefront/index.d.ts +93 -0
- package/dist/new-storefront/index.d.ts.map +1 -0
- package/dist/new-storefront/index.js +329 -0
- package/dist/new-storefront/index.js.map +1 -0
- package/dist/new-storefront/npmrc.d.ts +98 -0
- package/dist/new-storefront/npmrc.d.ts.map +1 -0
- package/dist/new-storefront/npmrc.js +217 -0
- package/dist/new-storefront/npmrc.js.map +1 -0
- package/dist/new-storefront/reference.d.ts +189 -0
- package/dist/new-storefront/reference.d.ts.map +1 -0
- package/dist/new-storefront/reference.js +430 -0
- package/dist/new-storefront/reference.js.map +1 -0
- package/dist/new-storefront/rewrite.d.ts +171 -0
- package/dist/new-storefront/rewrite.d.ts.map +1 -0
- package/dist/new-storefront/rewrite.js +701 -0
- package/dist/new-storefront/rewrite.js.map +1 -0
- package/dist/release-index.json +284 -0
- package/dist/rules/action-route-permissions.d.ts +141 -0
- package/dist/rules/action-route-permissions.d.ts.map +1 -0
- package/dist/rules/action-route-permissions.js +556 -0
- package/dist/rules/action-route-permissions.js.map +1 -0
- package/dist/rules/bundle-pairing.d.ts +74 -0
- package/dist/rules/bundle-pairing.d.ts.map +1 -0
- package/dist/rules/bundle-pairing.js +281 -0
- package/dist/rules/bundle-pairing.js.map +1 -0
- package/dist/rules/channel-resolution.d.ts +17 -0
- package/dist/rules/channel-resolution.d.ts.map +1 -0
- package/dist/rules/channel-resolution.js +382 -0
- package/dist/rules/channel-resolution.js.map +1 -0
- package/dist/rules/command-coverage.d.ts +210 -0
- package/dist/rules/command-coverage.d.ts.map +1 -0
- package/dist/rules/command-coverage.js +714 -0
- package/dist/rules/command-coverage.js.map +1 -0
- package/dist/rules/container-imports.d.ts +60 -0
- package/dist/rules/container-imports.d.ts.map +1 -0
- package/dist/rules/container-imports.js +158 -0
- package/dist/rules/container-imports.js.map +1 -0
- package/dist/rules/default-language-prose.d.ts +212 -0
- package/dist/rules/default-language-prose.d.ts.map +1 -0
- package/dist/rules/default-language-prose.js +710 -0
- package/dist/rules/default-language-prose.js.map +1 -0
- package/dist/rules/diacritic-folds.d.ts +238 -0
- package/dist/rules/diacritic-folds.d.ts.map +1 -0
- package/dist/rules/diacritic-folds.js +681 -0
- package/dist/rules/diacritic-folds.js.map +1 -0
- package/dist/rules/entity-tenant-classification.d.ts +171 -0
- package/dist/rules/entity-tenant-classification.d.ts.map +1 -0
- package/dist/rules/entity-tenant-classification.js +323 -0
- package/dist/rules/entity-tenant-classification.js.map +1 -0
- package/dist/rules/entry-presence.d.ts +142 -0
- package/dist/rules/entry-presence.d.ts.map +1 -0
- package/dist/rules/entry-presence.js +339 -0
- package/dist/rules/entry-presence.js.map +1 -0
- package/dist/rules/entry-scope.d.ts +91 -0
- package/dist/rules/entry-scope.d.ts.map +1 -0
- package/dist/rules/entry-scope.js +404 -0
- package/dist/rules/entry-scope.js.map +1 -0
- package/dist/rules/env-inputs.d.ts +222 -0
- package/dist/rules/env-inputs.d.ts.map +1 -0
- package/dist/rules/env-inputs.js +951 -0
- package/dist/rules/env-inputs.js.map +1 -0
- package/dist/rules/kernel-boundary.d.ts +37 -0
- package/dist/rules/kernel-boundary.d.ts.map +1 -0
- package/dist/rules/kernel-boundary.js +195 -0
- package/dist/rules/kernel-boundary.js.map +1 -0
- package/dist/rules/nul-bytes.d.ts +233 -0
- package/dist/rules/nul-bytes.d.ts.map +1 -0
- package/dist/rules/nul-bytes.js +332 -0
- package/dist/rules/nul-bytes.js.map +1 -0
- package/dist/rules/platform-surface.d.ts +479 -0
- package/dist/rules/platform-surface.d.ts.map +1 -0
- package/dist/rules/platform-surface.js +749 -0
- package/dist/rules/platform-surface.js.map +1 -0
- package/dist/rules/port-catches.d.ts +225 -0
- package/dist/rules/port-catches.d.ts.map +1 -0
- package/dist/rules/port-catches.js +1374 -0
- package/dist/rules/port-catches.js.map +1 -0
- package/dist/rules/port-shape.d.ts +213 -0
- package/dist/rules/port-shape.d.ts.map +1 -0
- package/dist/rules/port-shape.js +670 -0
- package/dist/rules/port-shape.js.map +1 -0
- package/dist/rules/queue-names.d.ts +108 -0
- package/dist/rules/queue-names.d.ts.map +1 -0
- package/dist/rules/queue-names.js +395 -0
- package/dist/rules/queue-names.js.map +1 -0
- package/dist/rules/singleton-identity.d.ts +205 -0
- package/dist/rules/singleton-identity.d.ts.map +1 -0
- package/dist/rules/singleton-identity.js +830 -0
- package/dist/rules/singleton-identity.js.map +1 -0
- package/dist/rules/subscribe-seam.d.ts +121 -0
- package/dist/rules/subscribe-seam.d.ts.map +1 -0
- package/dist/rules/subscribe-seam.js +594 -0
- package/dist/rules/subscribe-seam.js.map +1 -0
- package/dist/rules/transaction-context.d.ts +40 -0
- package/dist/rules/transaction-context.d.ts.map +1 -0
- package/dist/rules/transaction-context.js +294 -0
- package/dist/rules/transaction-context.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `.npmrc` a scaffolded storefront installs through — and the reason the
|
|
3
|
+
* command writes none unless it is asked.
|
|
4
|
+
*
|
|
5
|
+
* ## No `--registry` writes no file, and that is the destination
|
|
6
|
+
*
|
|
7
|
+
* `specs/104-package-publication/contracts/registry-and-scope.md` R3.4: a public
|
|
8
|
+
* consumer installs `@endora-commerce/*` with no `.npmrc` and no token. So the
|
|
9
|
+
* path this command takes **without being told anything** is the public one, and
|
|
10
|
+
* the private registry is the argument. The other way round would make every
|
|
11
|
+
* open-source consumer's first act the deletion of a file naming a host they
|
|
12
|
+
* have no credential for.
|
|
13
|
+
*
|
|
14
|
+
* ## The file holds no secret, and that is enforced rather than trusted
|
|
15
|
+
*
|
|
16
|
+
* The token is written as an environment **reference**, `${ENDORA_NPM_TOKEN}`,
|
|
17
|
+
* which pnpm expands at install time in both the registry and the auth position
|
|
18
|
+
* (measured, `research.md` §5). So the file is committable, and a registry URL
|
|
19
|
+
* carrying its own credentials — `https://user:token@host/…`, the one shape that
|
|
20
|
+
* would put a secret into a client's repository — is a refusal rather than a
|
|
21
|
+
* string this module copies through.
|
|
22
|
+
*
|
|
23
|
+
* ## The scope is derived from what the storefront installs
|
|
24
|
+
*
|
|
25
|
+
* Never a literal: the scopes are read off the reference storefront's own
|
|
26
|
+
* `workspace:` ranges, which are exactly the packages a registry has to answer
|
|
27
|
+
* for. A checkout that grows a second scope gets a second registry line in the
|
|
28
|
+
* same run, and a storefront that declares no scoped workspace dependency is a
|
|
29
|
+
* refusal — an `.npmrc` naming no scope configures nothing.
|
|
30
|
+
*
|
|
31
|
+
* ## A registry does not have to serve its tarballs under its metadata path
|
|
32
|
+
*
|
|
33
|
+
* That premise is what this file held until the acceptance criterion's registry
|
|
34
|
+
* mode was first run. It wrote **one** auth line, keyed on the configured
|
|
35
|
+
* endpoint, on the reasoning that *a credential is a property of the endpoint
|
|
36
|
+
* rather than of a scope*. The second half of that sentence is still true and the
|
|
37
|
+
* first no longer follows from it: the endpoint serves the **packument**, and the
|
|
38
|
+
* `dist.tarball` URL inside that document is the **server's** to choose. GitLab
|
|
39
|
+
* chooses the owning project's path, so an instance- or group-level endpoint
|
|
40
|
+
* answers with a tarball on `/api/v4/projects/<id>/packages/npm/…` — a path whose
|
|
41
|
+
* project id varies per package and is unknowable at the moment this file is
|
|
42
|
+
* written. The endpoint key does not cover it, that one fetch goes out
|
|
43
|
+
* unauthenticated, and GitLab answers an absent credential with **404**, the same
|
|
44
|
+
* sentence it gives for a package that was never published (`research.md` §6). So
|
|
45
|
+
* the install fails with *the package is not there*, immediately after a metadata
|
|
46
|
+
* request for that same package succeeded.
|
|
47
|
+
*
|
|
48
|
+
* `authKeys` below is the repair, and it is where the reasoning for the shape
|
|
49
|
+
* that was chosen — and for the two that were not — is written down.
|
|
50
|
+
*/
|
|
51
|
+
import { StorefrontInputError, workspaceRanges } from './reference.js';
|
|
52
|
+
/**
|
|
53
|
+
* The environment variable the auth line refers to.
|
|
54
|
+
*
|
|
55
|
+
* One name, spelled here and in `.gitlab-ci.yml`'s `publish:packages` job,
|
|
56
|
+
* because it is the name the contract writes (R3) and the one an operator is told
|
|
57
|
+
* to set. It is deliberately not an option: a per-scaffold variable name is a
|
|
58
|
+
* support conversation per client for no capability.
|
|
59
|
+
*/
|
|
60
|
+
export const TOKEN_VARIABLE = 'ENDORA_NPM_TOKEN';
|
|
61
|
+
/**
|
|
62
|
+
* The registry URL as an `.npmrc` line writes it: absolute, `http(s)`, with the
|
|
63
|
+
* trailing slash GitLab's own troubleshooting requires (R3.2).
|
|
64
|
+
*/
|
|
65
|
+
export function normalizeRegistry(registry) {
|
|
66
|
+
const raw = registry.trim();
|
|
67
|
+
if (raw.length === 0) {
|
|
68
|
+
throw new StorefrontInputError('`--registry` was given no value. It names the endpoint the scaffolded storefront ' +
|
|
69
|
+
'installs `@endora-commerce/*` from; omit the flag entirely to get the public ' +
|
|
70
|
+
'registry, which is what an open-source consumer installs from and what this command ' +
|
|
71
|
+
'does when it is not told otherwise.');
|
|
72
|
+
}
|
|
73
|
+
let url;
|
|
74
|
+
try {
|
|
75
|
+
url = new URL(raw);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
throw new StorefrontInputError(`\`--registry ${raw}\` is not an absolute URL. An \`.npmrc\` registry line is a URL and ` +
|
|
79
|
+
`nothing else — npm resolves no relative form — so a value that is not one would be ` +
|
|
80
|
+
`written into the client's file and fail at their install rather than at this command.`);
|
|
81
|
+
}
|
|
82
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
83
|
+
throw new StorefrontInputError(`\`--registry ${raw}\` names the "${url.protocol}" scheme. A registry is reached over ` +
|
|
84
|
+
`http or https; anything else is a value npm cannot fetch from.`);
|
|
85
|
+
}
|
|
86
|
+
if (url.username.length > 0 || url.password.length > 0) {
|
|
87
|
+
throw new StorefrontInputError(`\`--registry\` carries credentials in the URL. The \`.npmrc\` this command writes is a ` +
|
|
88
|
+
`file the client commits, and it holds no secret by construction: the token is written ` +
|
|
89
|
+
`as \${${TOKEN_VARIABLE}} and expanded at install time. Give the registry without its ` +
|
|
90
|
+
`userinfo and put the credential in the environment.`);
|
|
91
|
+
}
|
|
92
|
+
if (url.search.length > 0 || url.hash.length > 0) {
|
|
93
|
+
throw new StorefrontInputError(`\`--registry ${raw}\` carries a query or a fragment. Neither is part of a registry ` +
|
|
94
|
+
`endpoint, and the auth line is keyed on the host and path, so a value carrying one ` +
|
|
95
|
+
`would authenticate for an address the fetches never use.`);
|
|
96
|
+
}
|
|
97
|
+
const text = url.toString();
|
|
98
|
+
return text.endsWith('/') ? text : `${text}/`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The scopes a scaffolded storefront installs from a registry.
|
|
102
|
+
*
|
|
103
|
+
* Read off the reference storefront's `workspace:` ranges — the packages that
|
|
104
|
+
* stop resolving the moment the copy leaves the workspace — rather than off the
|
|
105
|
+
* checkout's members. The two populations are not the same question: what the
|
|
106
|
+
* platform *publishes* is `check:release-intent`'s, and what this storefront
|
|
107
|
+
* *installs* is this one's.
|
|
108
|
+
*/
|
|
109
|
+
export function installedScopes(manifest) {
|
|
110
|
+
const scopes = new Set();
|
|
111
|
+
for (const range of workspaceRanges(manifest)) {
|
|
112
|
+
if (!range.name.startsWith('@'))
|
|
113
|
+
continue;
|
|
114
|
+
const slash = range.name.indexOf('/');
|
|
115
|
+
if (slash > 0)
|
|
116
|
+
scopes.add(range.name.slice(0, slash));
|
|
117
|
+
}
|
|
118
|
+
return [...scopes].sort();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The keys the auth lines are written under: the endpoint, and the host it is on.
|
|
122
|
+
*
|
|
123
|
+
* Both are npm's own spelling for a credential — the request URL with its scheme
|
|
124
|
+
* removed — and both matter, for two different fetches.
|
|
125
|
+
*
|
|
126
|
+
* **The endpoint key** is the narrowest key covering the one address the operator
|
|
127
|
+
* actually named, and it is what GitLab's own documentation writes. It is kept
|
|
128
|
+
* rather than replaced by the broader one below: pnpm was measured walking a
|
|
129
|
+
* request path upward — a key on `//host/api/v4/` authenticates a tarball under
|
|
130
|
+
* `/api/v4/projects/…` — so for pnpm the endpoint key is redundant, and a client
|
|
131
|
+
* matching these keys **exactly** would still authenticate the packument with it.
|
|
132
|
+
* No such client was measured here, so the honest reason to keep the line is the
|
|
133
|
+
* smaller one: dropping it would make the file say less than it knows about the
|
|
134
|
+
* one address the operator gave.
|
|
135
|
+
*
|
|
136
|
+
* **The host key** is the one that covers a tarball. It is broad on purpose: the
|
|
137
|
+
* tarball URL is chosen by the server and appears for the first time inside a
|
|
138
|
+
* packument this file will never see, so the only statically derivable key
|
|
139
|
+
* guaranteed to cover it is the whole host. Measured with a local registry
|
|
140
|
+
* standing in for GitLab's shape — a packument served on the endpoint whose
|
|
141
|
+
* `dist.tarball` names `/api/v4/projects/302/packages/npm/…` on the same host —
|
|
142
|
+
* under pnpm 9.15.0, the version CI pins, and under pnpm 10:
|
|
143
|
+
*
|
|
144
|
+
* endpoint key alone ERR_PNPM_FETCH_404 … Not Found - 404
|
|
145
|
+
* "No authorization header was set for the request."
|
|
146
|
+
* endpoint + host key the tarball request carries the header; the install
|
|
147
|
+
* completes.
|
|
148
|
+
*
|
|
149
|
+
* ### Why not a narrower prefix
|
|
150
|
+
*
|
|
151
|
+
* Not because a narrower one would fail — measured, `//host/api/v4/` and
|
|
152
|
+
* `//host/api/v4/projects/` both authenticate that same tarball, because pnpm
|
|
153
|
+
* walks a request's path upward looking for a key. The mechanism is not the
|
|
154
|
+
* obstacle; the **derivation** is. Getting `/api/v4/` out of
|
|
155
|
+
* `/api/v4/packages/npm/` means knowing GitLab's URL layout, which is trading one
|
|
156
|
+
* unexamined premise about the server for a narrower one — and `--registry` names
|
|
157
|
+
* *a registry*, not *a GitLab*: the flag is documented as the endpoint the
|
|
158
|
+
* storefront installs from, and a Verdaccio or an Artifactory behind it has its
|
|
159
|
+
* own layout. `ENDORA_NPM_REGISTRY` is masked and may be the instance endpoint or
|
|
160
|
+
* a group one, so the file cannot even be written against one observed shape.
|
|
161
|
+
*
|
|
162
|
+
* ### What is given up, stated rather than glossed
|
|
163
|
+
*
|
|
164
|
+
* The credential is offered to **every** request pnpm makes to this host and
|
|
165
|
+
* port, not only to the endpoint's own subtree. That is broader than the single
|
|
166
|
+
* line this file used to write. It is accepted because the host is the one the
|
|
167
|
+
* operator named on the command line, the credential a client is handed is a
|
|
168
|
+
* deploy token scoped `read_package_registry` (R3.3) whose whole authority on
|
|
169
|
+
* that host is reading packages, and the alternative — the credential not
|
|
170
|
+
* reaching the address the registry itself directed the client to — is an install
|
|
171
|
+
* that cannot work.
|
|
172
|
+
*
|
|
173
|
+
* And what it does **not** cover, so nobody reads it as more than it is: a
|
|
174
|
+
* registry that serves tarballs from a **different host** (a CDN, a storage
|
|
175
|
+
* bucket) is not reached by this key or by any other one derivable here, because
|
|
176
|
+
* that host appears nowhere in the input. Such a registry needs a line naming it,
|
|
177
|
+
* and the symptom would be this same 404 on the tarball alone.
|
|
178
|
+
*
|
|
179
|
+
* A registry configured at the root of its host makes the two keys identical, and
|
|
180
|
+
* then there is one line rather than two: a duplicate would not be wrong, it
|
|
181
|
+
* would read as though it said something.
|
|
182
|
+
*/
|
|
183
|
+
export function authKeys(registry) {
|
|
184
|
+
const endpoint = normalizeRegistry(registry);
|
|
185
|
+
const endpointKey = endpoint.replace(/^https?:/, '');
|
|
186
|
+
const hostKey = `//${new URL(endpoint).host}/`;
|
|
187
|
+
return endpointKey === hostKey ? [endpointKey] : [endpointKey, hostKey];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The file's text: one registry line per scope, and the auth lines `authKeys`
|
|
191
|
+
* derives.
|
|
192
|
+
*
|
|
193
|
+
* There is one set of auth lines however many scopes there are, because a
|
|
194
|
+
* credential is a property of the endpoint rather than of a scope — the half of
|
|
195
|
+
* this file's original reasoning that survived the measurement above.
|
|
196
|
+
*/
|
|
197
|
+
export function npmrcContent(registry, scopes) {
|
|
198
|
+
if (scopes.length === 0) {
|
|
199
|
+
throw new StorefrontInputError(`\`--registry ${registry}\` was given, and the reference storefront declares no scoped ` +
|
|
200
|
+
`\`workspace:\` dependency for it to answer for. An \`.npmrc\` naming no scope ` +
|
|
201
|
+
`configures nothing: every fetch would go to the default registry and the file would ` +
|
|
202
|
+
`read as though it did something.`);
|
|
203
|
+
}
|
|
204
|
+
const endpoint = normalizeRegistry(registry);
|
|
205
|
+
const lines = [
|
|
206
|
+
'# Written by `endora new storefront --registry`. It holds no secret: the token below is',
|
|
207
|
+
`# an environment reference that pnpm expands at install time, so set ${TOKEN_VARIABLE} in`,
|
|
208
|
+
'# your environment (a CI variable, a keyring) and commit this file as it is.',
|
|
209
|
+
];
|
|
210
|
+
for (const scope of scopes)
|
|
211
|
+
lines.push(`${scope}:registry=${endpoint}`);
|
|
212
|
+
lines.push('# The endpoint serves the metadata; the tarball it names in that metadata can be on any', '# path of this host (GitLab serves it from the owning project), so the credential is', '# declared for the host as well. Without the second line that one fetch goes out', '# unauthenticated and the registry answers 404.');
|
|
213
|
+
for (const key of authKeys(endpoint))
|
|
214
|
+
lines.push(`${key}:_authToken=\${${TOKEN_VARIABLE}}`);
|
|
215
|
+
return `${lines.join('\n')}\n`;
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=npmrc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npmrc.js","sourceRoot":"","sources":["../../src/new-storefront/npmrc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,oBAAoB,CAC5B,mFAAmF;YACjF,+EAA+E;YAC/E,sFAAsF;YACtF,q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C,MAAM,KAAK,GAAG;QACZ,yFAAyF;QACzF,wEAAwE,cAAc,KAAK;QAC3F,8EAA8E;KAC/E,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,QAAQ,EAAE,CAAC,CAAC;IACxE,KAAK,CAAC,IAAI,CACR,yFAAyF,EACzF,sFAAsF,EACtF,kFAAkF,EAClF,iDAAiD,CAClD,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,kBAAkB,cAAc,GAAG,CAAC,CAAC;IAC5F,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { type EnvironmentConsumer, type EnvironmentInput } from '@endora-commerce/contracts';
|
|
2
|
+
/** Raised when the reference storefront cannot be read. Exit 2. */
|
|
3
|
+
export declare class StorefrontHostError extends Error {
|
|
4
|
+
}
|
|
5
|
+
/** Raised when the author asked for something this command refuses. Exit 1. */
|
|
6
|
+
export declare class StorefrontInputError extends Error {
|
|
7
|
+
}
|
|
8
|
+
/** The dependency fields a manifest can declare a `workspace:` range in. */
|
|
9
|
+
export declare const DEPENDENCY_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
10
|
+
export type DependencyField = (typeof DEPENDENCY_FIELDS)[number];
|
|
11
|
+
/** The reference storefront this run copies. */
|
|
12
|
+
export interface StorefrontReference {
|
|
13
|
+
/** The directory holding `pnpm-workspace.yaml`. */
|
|
14
|
+
readonly repoRoot: string;
|
|
15
|
+
/** The reference storefront's directory, absolute. */
|
|
16
|
+
readonly dir: string;
|
|
17
|
+
/** Its files, storefront-relative, as git reports them. */
|
|
18
|
+
readonly files: readonly string[];
|
|
19
|
+
/** Its parsed manifest. */
|
|
20
|
+
readonly manifest: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/** One `workspace:` range the copy has to rewrite. */
|
|
23
|
+
export interface WorkspaceRange {
|
|
24
|
+
readonly field: DependencyField;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** The range as written, e.g. `workspace:^`. */
|
|
27
|
+
readonly declared: string;
|
|
28
|
+
}
|
|
29
|
+
/** The shapes a declaration can name a path in. */
|
|
30
|
+
export type ReferenceKind = 'module-specifier' | 'json-extends' | 'css-source';
|
|
31
|
+
/** One declaration naming something above the storefront directory. */
|
|
32
|
+
export interface OutwardReference {
|
|
33
|
+
/** The file that writes it, storefront-relative. */
|
|
34
|
+
readonly file: string;
|
|
35
|
+
readonly kind: ReferenceKind;
|
|
36
|
+
/** The specifier exactly as written. */
|
|
37
|
+
readonly specifier: string;
|
|
38
|
+
/** Where it resolves, absolute, before any glob segment. */
|
|
39
|
+
readonly target: string;
|
|
40
|
+
}
|
|
41
|
+
/** The nearest ancestor of `start` holding a `pnpm-workspace.yaml`, or `null`. */
|
|
42
|
+
export declare function findRepoRoot(start: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* The reference storefront's files, from git.
|
|
45
|
+
*
|
|
46
|
+
* Git is the independent author here: the alternative is a walk plus an
|
|
47
|
+
* exclusion list, and an exclusion list is a second answer to "what is this
|
|
48
|
+
* application" that goes stale against `.gitignore` in silence. A checkout with
|
|
49
|
+
* no git, or a storefront directory git does not track, is exit 2 — never a
|
|
50
|
+
* partial copy.
|
|
51
|
+
*/
|
|
52
|
+
export declare function trackedFiles(repoRoot: string, storefrontDir: string): readonly string[];
|
|
53
|
+
/**
|
|
54
|
+
* Locate the reference storefront.
|
|
55
|
+
*
|
|
56
|
+
* It is found by the **one workspace member that is a Next application**, not by
|
|
57
|
+
* a directory called `storefront`: the member's manifest declares `next` and a
|
|
58
|
+
* `build` script that runs it, and `pnpm-workspace.yaml` says which directories
|
|
59
|
+
* are members. A repository that renames the directory is followed; one that
|
|
60
|
+
* grows a second Next application is exit 2 rather than a run over whichever
|
|
61
|
+
* sorted first.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveReference(cwd: string): StorefrontReference;
|
|
64
|
+
/** Workspace member directories, from the `packages:` globs as written. */
|
|
65
|
+
export declare function memberDirectories(repoRoot: string): readonly string[];
|
|
66
|
+
/** Every `workspace:` range the reference storefront declares, in field order. */
|
|
67
|
+
export declare function workspaceRanges(manifest: Record<string, unknown>): readonly WorkspaceRange[];
|
|
68
|
+
/**
|
|
69
|
+
* Every relative declaration in the reference storefront that resolves outside
|
|
70
|
+
* it, in the three shapes an application writes one.
|
|
71
|
+
*
|
|
72
|
+
* The specifier's own leading `.` is what makes it a candidate: a bare specifier
|
|
73
|
+
* names a package and is resolved by the installer, not by this copy. A glob is
|
|
74
|
+
* resolved up to its first wildcard segment, because that prefix is the part
|
|
75
|
+
* that has to exist.
|
|
76
|
+
*/
|
|
77
|
+
export declare function outwardReferences(reference: StorefrontReference): readonly OutwardReference[];
|
|
78
|
+
/** The path prefix of a glob: everything up to the first wildcard segment. */
|
|
79
|
+
export declare function globPrefix(specifier: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Every package a module's **static import and re-export statements** name,
|
|
82
|
+
* reduced to the package: `vitest/config` is `vitest`, `@scope/pkg/sub` is
|
|
83
|
+
* `@scope/pkg`. Relative specifiers and Node's own modules are not packages an
|
|
84
|
+
* installer resolves, so they are not here.
|
|
85
|
+
*
|
|
86
|
+
* Anchored at the start of a line, deliberately narrower than
|
|
87
|
+
* {@link outwardReferences}' pattern: that one looks for a path anywhere a
|
|
88
|
+
* declaration could write one, and over a configuration file it also matches
|
|
89
|
+
* the word "import" inside a rule's message string. Here a false match is a
|
|
90
|
+
* refusal of a correct scaffold, and the statements a configuration file
|
|
91
|
+
* loads its packages with are the static ones this reads.
|
|
92
|
+
*/
|
|
93
|
+
export declare function importedPackages(text: string): readonly string[];
|
|
94
|
+
/** Every package name a manifest declares, in any dependency field. */
|
|
95
|
+
export declare function declaredPackages(manifest: Record<string, unknown>): ReadonlySet<string>;
|
|
96
|
+
/** The file a storefront declares its environment in, and the copy carries verbatim. */
|
|
97
|
+
export declare const ENV_EXAMPLE_FILE = ".env.example";
|
|
98
|
+
/** The binding a storefront's declaration is exported under. */
|
|
99
|
+
export declare const STOREFRONT_DECLARATION_EXPORT = "STOREFRONT_ENVIRONMENT_INPUTS";
|
|
100
|
+
/**
|
|
101
|
+
* Every declaration the file makes, in file order — the copy's own worked
|
|
102
|
+
* example of its environment.
|
|
103
|
+
*
|
|
104
|
+
* One parser, because there are two questions asked of this file and they must
|
|
105
|
+
* not come to disagree about what it says: *which of these names a backend*
|
|
106
|
+
* (below) and *what value does this file give for a name* — the second being how
|
|
107
|
+
* the acceptance criterion configures the instance it boots without carrying a
|
|
108
|
+
* list of variables of its own. A key repeated in the file keeps its last
|
|
109
|
+
* assignment, which is what every reader of a `.env` does.
|
|
110
|
+
*
|
|
111
|
+
* A blank value is **not** a declaration. `NEXT_PUBLIC_SITE_URL=` and no line at
|
|
112
|
+
* all are the same state for whoever has to supply it, and reading the first as
|
|
113
|
+
* an answer would let a consumer pass an empty string to a command whose whole
|
|
114
|
+
* subject is that nothing is invented — `inputs/env-file.ts` makes the same call
|
|
115
|
+
* for the same reason, one directory over.
|
|
116
|
+
*/
|
|
117
|
+
export declare function envExampleDeclarations(envExampleText: string): ReadonlyMap<string, string>;
|
|
118
|
+
/** The same answer, read off a storefront directory. */
|
|
119
|
+
export declare function envExampleDeclarationsOf(storefrontDir: string): ReadonlyMap<string, string>;
|
|
120
|
+
/**
|
|
121
|
+
* The variables a storefront sets to name a member of its instance.
|
|
122
|
+
*
|
|
123
|
+
* **Derived from the storefront's own declaration, never written down here.**
|
|
124
|
+
* A sentence carrying the two backend names would be a copy of a fact the
|
|
125
|
+
* storefront already states, going stale the first time one is renamed (D-100),
|
|
126
|
+
* and the guidance this replaces is what that costs: it named
|
|
127
|
+
* `PUBLIC_API_BASE_URL`, which no file in the copy has ever read, so an operator
|
|
128
|
+
* who followed it got a storefront quietly talking to the fallback its fetchers
|
|
129
|
+
* compile in.
|
|
130
|
+
*
|
|
131
|
+
* **The predicate is `addressOf`, and it used to be the shape of the value.**
|
|
132
|
+
* This function read `.env.example` and answered *a declaration whose value is
|
|
133
|
+
* an absolute `http(s)` URL*, on the reasoning that a backend address is one and
|
|
134
|
+
* none of the file's other keys was. The second half stopped being true the
|
|
135
|
+
* moment the file gained the storefront's own public address: `.env.example`
|
|
136
|
+
* would then have swept `NEXT_PUBLIC_SITE_URL` in with the backend's, and
|
|
137
|
+
* `nextSteps` would have told a client — in a file they own outright and nobody
|
|
138
|
+
* revisits — that it "names the backend this storefront talks to". A confident
|
|
139
|
+
* wrong sentence is worse than the silence it replaces, and the criterion would
|
|
140
|
+
* have pointed the shop's canonical origin at its API host at the same time.
|
|
141
|
+
*
|
|
142
|
+
* So the question is asked of the declaration, which says what each value **is**
|
|
143
|
+
* rather than what it looks like. The scoping stays `.env.example`'s job for
|
|
144
|
+
* *values* (`envExampleDeclarations`, above); this is about meaning.
|
|
145
|
+
*
|
|
146
|
+
* Nothing is invented when the declaration names no address: the answer is empty
|
|
147
|
+
* and each caller says so in its own words.
|
|
148
|
+
*/
|
|
149
|
+
export declare function addressVariables(declared: readonly EnvironmentInput[], member: EnvironmentConsumer): readonly string[];
|
|
150
|
+
/**
|
|
151
|
+
* The same answer, read off a storefront directory.
|
|
152
|
+
*
|
|
153
|
+
* It loads that directory's own `environment-inputs.mjs` — the copy's, when the
|
|
154
|
+
* caller is holding a copy — through the one loader every other reader uses, so
|
|
155
|
+
* a declaration that will not parse is a refusal here as it is everywhere else.
|
|
156
|
+
* A storefront with no declaration at all is `DeclarationLoadError` and not an
|
|
157
|
+
* empty answer: that was `.env.example`'s rule, and it was right for a file that
|
|
158
|
+
* is a worked example. This one is the tree's statement of what it reads, and
|
|
159
|
+
* "absent" is not "reads nothing" (`loadTreeDeclaration`'s own header).
|
|
160
|
+
*/
|
|
161
|
+
export declare function backendAddressVariablesOf(storefrontDir: string): Promise<readonly string[]>;
|
|
162
|
+
/** The variables naming the storefront's own public address, off a directory. */
|
|
163
|
+
export declare function storefrontAddressVariablesOf(storefrontDir: string): Promise<readonly string[]>;
|
|
164
|
+
/**
|
|
165
|
+
* Every variable this storefront's own process reads, off a directory.
|
|
166
|
+
*
|
|
167
|
+
* The two functions above answer *which of these names a member* — a subset
|
|
168
|
+
* chosen by `addressOf`. This one is the whole population, scoped to the one
|
|
169
|
+
* member that runs here, and it exists because a caller that **spawns** a
|
|
170
|
+
* storefront's toolchain has to know which names in its own environment belong
|
|
171
|
+
* to the instance rather than to itself.
|
|
172
|
+
*
|
|
173
|
+
* That is not a curiosity. Next loads a `.env` and does **not** override a
|
|
174
|
+
* variable the process already carries, so any of these names present in a
|
|
175
|
+
* parent's environment silently displaces the value written into the copy's own
|
|
176
|
+
* `.env` — and a harness that passed its environment on wholesale would be
|
|
177
|
+
* measuring its own configuration while reporting on the command's. `NODE_ENV`
|
|
178
|
+
* is the case that made this real: this storefront's declaration says in as many
|
|
179
|
+
* words that its toolchain sets it and that *"setting it by hand is how a
|
|
180
|
+
* production build ends up serving development output"*, and a CI job that set
|
|
181
|
+
* it for the **backend** it booted put it on every process in the job, including
|
|
182
|
+
* a `next build` in a scaffolded instance outside the checkout.
|
|
183
|
+
*
|
|
184
|
+
* Scoped with `scopeToMembers` rather than by name, for `storefrontDeclaredInputs`'
|
|
185
|
+
* reason: a declaration may carry an input another member reads, and the question
|
|
186
|
+
* here is what *this* process reads.
|
|
187
|
+
*/
|
|
188
|
+
export declare function declaredVariablesOf(storefrontDir: string): Promise<readonly string[]>;
|
|
189
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/new-storefront/reference.ts"],"names":[],"mappings":"AAqCA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,4BAA4B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