@omega.js/desktop 0.52.0 → 0.54.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/README.md +53 -48
- package/dist/assets/css/core/_initialize.scss +1 -1
- package/dist/assets/js/core/app-shell.js +14 -15
- package/dist/assets/themes/_template/_theme.js +6 -6
- package/dist/assets/themes/base/_includes/global/sections/account.html +4 -4
- package/dist/assets/themes/base/_includes/global/sections/app-sidebar.html +5 -5
- package/dist/assets/themes/base/_layouts/frontend/pages/account/index.html +3 -3
- package/dist/assets/themes/base/_layouts/frontend/pages/alternatives/index.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/blog/tags/tag.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/payment/confirmation.html +1 -1
- package/dist/assets/themes/base/_sections/marketing/newsletter-cta/section.js +2 -3
- package/dist/assets/themes/base/_sections/verts/unit/section.html +1 -1
- package/dist/assets/themes/base/_sections/verts/unit/section.js +3 -4
- package/dist/assets/themes/base/_theme.js +4 -3
- package/dist/assets/themes/bootstrap/_theme.js +2 -2
- package/dist/assets/themes/bootstrap/overrides/_links.scss +1 -1
- package/dist/assets/themes/classy/_theme.js +8 -6
- package/dist/assets/themes/classy/css/marketing/_sections.scss +1 -2
- package/dist/assets/themes/classy/js/hero-demo-form.js +3 -2
- package/dist/assets/themes/neobrutalism/_theme.js +5 -5
- package/dist/assets/themes/neobrutalism/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/assets/themes/newsflash/_theme.js +6 -6
- package/dist/assets/themes/newsflash/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/build.js +87 -111
- package/dist/cli-run.js +4 -1
- package/dist/cli.js +3 -3
- package/dist/commands/build.js +2 -2
- package/dist/commands/cdp/capture.js +2 -2
- package/dist/commands/cdp/client.js +1 -1
- package/dist/commands/cdp/quit.js +2 -2
- package/dist/commands/cdp/relaunch.js +2 -2
- package/dist/commands/cdp/theme.js +1 -1
- package/dist/commands/cdp.js +1 -1
- package/dist/commands/clean.js +4 -5
- package/dist/commands/deploy.js +4 -4
- package/dist/commands/dev.js +25 -0
- package/dist/commands/finalize-release.js +4 -4
- package/dist/commands/launch.js +2 -2
- package/dist/commands/lib/deploy-precheck.js +3 -3
- package/dist/commands/lib/ensure-target.js +18 -23
- package/dist/commands/lib/migrate.js +17 -0
- package/dist/commands/logs.js +1 -1
- package/dist/commands/package.js +2 -2
- package/dist/commands/publish.js +2 -2
- package/dist/commands/release.js +4 -4
- package/dist/commands/runner.js +11 -11
- package/dist/commands/sign-windows.js +5 -5
- package/dist/commands/test.js +8 -8
- package/dist/commands/update.js +7 -6
- package/dist/commands/validate-certs.js +4 -4
- package/dist/commands/version.js +3 -3
- package/dist/defaults/.github/workflows/build.yml +18 -18
- package/dist/defaults/_.gitignore +0 -2
- package/dist/defaults/_mas/README.md +3 -3
- package/dist/defaults/config/certs/README.md +1 -1
- package/dist/defaults/config/omega.json5 +43 -43
- package/dist/defaults/docs/README.md +3 -3
- package/dist/defaults/gulpfile.js +1 -1
- package/dist/defaults/hooks/build/post.js +2 -2
- package/dist/defaults/hooks/build/pre.js +2 -2
- package/dist/defaults/hooks/deploy/pre.js +1 -1
- package/dist/defaults/hooks/notarize/post.js +2 -2
- package/dist/defaults/hooks/release/post.js +2 -2
- package/dist/defaults/hooks/release/pre.js +2 -2
- package/dist/defaults/src/assets/js/components/about/index.js +3 -5
- package/dist/defaults/src/assets/js/components/main/index.js +3 -5
- package/dist/defaults/src/assets/js/components/settings/index.js +3 -5
- package/dist/defaults/src/assets/scss/pages/about.scss +1 -1
- package/dist/defaults/src/assets/scss/pages/main.scss +1 -1
- package/dist/defaults/src/assets/scss/pages/settings.scss +1 -1
- package/dist/defaults/src/integrations/context-menu/index.js +13 -13
- package/dist/defaults/src/integrations/menu/index.js +8 -8
- package/dist/defaults/src/integrations/tray/index.js +12 -12
- package/dist/defaults/src/main.js +5 -7
- package/dist/defaults/src/preload.js +4 -6
- package/dist/defaults/test/README.md +5 -5
- package/dist/defaults/test/_init.js +1 -1
- package/dist/gulp/main.js +9 -10
- package/dist/gulp/tasks/audit.js +11 -14
- package/dist/gulp/tasks/build-config.js +8 -8
- package/dist/gulp/tasks/bundle.js +16 -16
- package/dist/gulp/tasks/defaults.js +3 -3
- package/dist/gulp/tasks/distribute.js +2 -2
- package/dist/gulp/tasks/html.js +9 -9
- package/dist/gulp/tasks/package-quick.js +3 -3
- package/dist/gulp/tasks/package.js +3 -3
- package/dist/gulp/tasks/release.js +3 -3
- package/dist/gulp/tasks/sass.js +6 -6
- package/dist/gulp/tasks/serve.js +4 -4
- package/dist/hooks/notarize-artifacts.js +1 -1
- package/dist/hooks/notarize.js +1 -1
- package/dist/index.js +5 -8
- package/dist/lib/_environment-mixin.js +50 -0
- package/dist/lib/_lifecycle-mixin.js +45 -0
- package/dist/lib/analytics.js +33 -35
- package/dist/lib/app-state.js +14 -14
- package/dist/lib/auth-flow.js +18 -18
- package/dist/lib/auth-persistence.js +12 -12
- package/dist/lib/auth.js +421 -0
- package/dist/lib/auto-updater.js +49 -49
- package/dist/lib/context-menu.js +13 -13
- package/dist/lib/context.js +19 -19
- package/dist/lib/deep-link.js +34 -34
- package/dist/lib/fontawesome.js +5 -5
- package/dist/lib/ipc.js +4 -4
- package/dist/lib/menu.js +25 -25
- package/dist/lib/protocol.js +5 -5
- package/dist/lib/remote-config.js +22 -22
- package/dist/lib/remote-scripts.js +21 -21
- package/dist/lib/restart-manager/index.js +29 -29
- package/dist/lib/restart-manager/install.js +1 -1
- package/dist/lib/restart-manager/protocol.js +1 -1
- package/dist/lib/sign-helpers/exec-with-limit.js +1 -1
- package/dist/lib/sign-helpers/sign-events.js +1 -1
- package/dist/lib/startup.js +18 -13
- package/dist/lib/storage.js +10 -10
- package/dist/lib/templating.js +16 -16
- package/dist/lib/theme.js +10 -10
- package/dist/lib/tray.js +27 -27
- package/dist/lib/usage.js +11 -11
- package/dist/lib/window-manager.js +26 -26
- package/dist/main.js +399 -483
- package/dist/preload.js +236 -176
- package/dist/renderer.js +417 -391
- package/dist/test/fixtures/consumer-app/config/omega.json5 +1 -1
- package/dist/test/fixtures/consumer-app/src/assets/js/components/main/index.js +8 -11
- package/dist/test/fixtures/consumer-app/src/main.js +5 -7
- package/dist/test/fixtures/consumer-app/src/preload.js +2 -2
- package/dist/test/harness/boot-entry.js +22 -20
- package/dist/test/harness/main-entry.js +31 -30
- package/dist/test/harness/renderer-entry.js +5 -5
- package/dist/test/harness/renderer-preload.js +137 -141
- package/dist/test/index.js +10 -10
- package/dist/test/runner.js +2 -2
- package/dist/test/runners/boot.js +7 -6
- package/dist/test/runners/electron.js +3 -2
- package/dist/test/runners/render-event.js +2 -2
- package/dist/test/suites/boot/consumer-app-boots.test.js +57 -26
- package/dist/test/suites/boot/restart-manager.test.js +2 -2
- package/dist/test/suites/boot/storage-bundled.test.js +5 -5
- package/dist/test/suites/boot/theme.test.js +13 -13
- package/dist/test/suites/build/audit.test.js +21 -8
- package/dist/test/suites/build/auth-persistence-resolve.test.js +6 -6
- package/dist/test/suites/build/boot-fixture.test.js +2 -2
- package/dist/test/suites/build/boot-runner-timeout.test.js +6 -5
- package/dist/test/suites/build/brand-scss.test.js +1 -1
- package/dist/test/suites/build/build-json-bake.test.js +1 -1
- package/dist/test/suites/build/build-workflow-jobs.test.js +2 -2
- package/dist/test/suites/build/cli.test.js +30 -2
- package/dist/test/suites/build/config-schema.test.js +5 -5
- package/dist/test/suites/build/defaults-em-dash.test.js +22 -0
- package/dist/test/suites/build/defaults-scaffold.test.js +21 -7
- package/dist/test/suites/build/deploy-direct.test.js +7 -5
- package/dist/test/suites/build/deploy-dispatch.test.js +2 -1
- package/dist/test/suites/build/deploy-hook.test.js +7 -5
- package/dist/test/suites/build/dev-verb.test.js +67 -0
- package/dist/test/suites/build/ensure-target.test.js +13 -5
- package/dist/test/suites/build/env-delivery.test.js +2 -2
- package/dist/test/suites/build/esm-only-dependency.test.js +2 -2
- package/dist/test/suites/build/exports.test.js +9 -8
- package/dist/test/suites/build/get-config.test.js +4 -4
- package/dist/test/suites/build/manifest-deps.test.js +1 -1
- package/dist/test/suites/build/merge-line-files.test.js +7 -7
- package/dist/test/suites/build/migrate.test.js +29 -0
- package/dist/test/suites/build/omega-shell.test.js +34 -2
- package/dist/test/suites/build/omega.test.js +350 -0
- package/dist/test/suites/build/project-scripts-deps.test.js +6 -10
- package/dist/test/suites/build/renderer-auth-bridge.test.js +211 -78
- package/dist/test/suites/build/runner-env-write.test.js +73 -0
- package/dist/test/suites/build/runner.test.js +11 -10
- package/dist/test/suites/build/sentry.test.js +2 -2
- package/dist/test/suites/build/setup-scripts.test.js +27 -0
- package/dist/test/suites/build/sign-windows-e2e.test.js +2 -2
- package/dist/test/suites/build/templating.test.js +3 -3
- package/dist/test/suites/build/test-stealth.test.js +7 -9
- package/dist/test/suites/build/url-helpers.test.js +55 -56
- package/dist/test/suites/build/validate-config.test.js +15 -4
- package/dist/test/suites/build/verb-logs.test.js +20 -0
- package/dist/test/suites/build/wave5-pins.test.js +2 -2
- package/dist/test/suites/main/analytics.test.js +59 -59
- package/dist/test/suites/main/app-state.test.js +66 -66
- package/dist/test/suites/main/auth-flow.test.js +41 -41
- package/dist/test/suites/main/auth-persistence.test.js +54 -43
- package/dist/test/suites/main/{client-bridge.integration.test.js → auth.integration.test.js} +10 -9
- package/dist/test/suites/main/auth.test.js +336 -0
- package/dist/test/suites/main/auto-updater.test.js +134 -134
- package/dist/test/suites/main/boot-sequence.test.js +37 -49
- package/dist/test/suites/main/context-menu.test.js +51 -50
- package/dist/test/suites/main/context.test.js +25 -25
- package/dist/test/suites/main/deep-link.test.js +74 -74
- package/dist/test/suites/main/fontawesome.test.js +27 -27
- package/dist/test/suites/main/ipc.test.js +35 -35
- package/dist/test/suites/main/menu.test.js +101 -100
- package/dist/test/suites/main/protocol.test.js +19 -19
- package/dist/test/suites/main/remote-config.test.js +63 -63
- package/dist/test/suites/main/remote-scripts.test.js +103 -103
- package/dist/test/suites/main/request.test.js +71 -0
- package/dist/test/suites/main/restart-manager.test.js +33 -33
- package/dist/test/suites/main/startup-paths-and-ua.test.js +4 -4
- package/dist/test/suites/main/startup.test.js +26 -26
- package/dist/test/suites/main/stealth-window.test.js +1 -1
- package/dist/test/suites/main/storage.test.js +25 -25
- package/dist/test/suites/main/theme.test.js +34 -34
- package/dist/test/suites/main/tray.test.js +79 -79
- package/dist/test/suites/main/url-helpers.test.js +133 -133
- package/dist/test/suites/main/usage.test.js +25 -25
- package/dist/test/suites/main/window-bounds.test.js +27 -27
- package/dist/test/suites/main/window-manager.test.js +44 -44
- package/dist/test/suites/renderer/analytics-bridge.test.js +5 -5
- package/dist/test/suites/renderer/cross-context-helpers.test.js +37 -31
- package/dist/test/suites/renderer/round-trip.test.js +3 -3
- package/dist/test/suites/renderer/tooltips.test.js +15 -15
- package/dist/test/suites/renderer/{window-em-surface.test.js → window-desktop-surface.test.js} +28 -8
- package/dist/test/utils/extended-mode-warning.js +1 -1
- package/dist/utils/boot-harness.js +56 -0
- package/dist/utils/build-pipeline.js +4 -4
- package/dist/utils/mode-helpers.js +2 -15
- package/dist/utils/runner-env.js +13 -28
- package/dist/utils/ship-keys.js +3 -3
- package/dist/utils/signing-status.js +51 -0
- package/dist/utils/test-events.js +7 -0
- package/dist/utils/test-stealth.js +6 -6
- package/dist/utils/url-helpers.js +52 -42
- package/dist/utils/user-agent.js +44 -0
- package/dist/vendor/account/engine.js +3 -3
- package/dist/vendor/account/index.js +14 -45
- package/dist/vendor/account/resolve-account.js +44 -0
- package/dist/vendor/account/schema.js +1 -1
- package/dist/vendor/account/user.js +99 -0
- package/dist/vendor/config/client-config.js +1 -1
- package/dist/vendor/config/company.js +46 -14
- package/dist/vendor/config/defaults.js +30 -7
- package/dist/vendor/config/edit.js +25 -3
- package/dist/vendor/config/env-delivery.js +1 -1
- package/dist/vendor/config/env-schema.js +3 -6
- package/dist/vendor/config/env.js +34 -22
- package/dist/vendor/config/environment.js +11 -30
- package/dist/vendor/config/index.js +21 -28
- package/dist/vendor/config/load.js +16 -9
- package/dist/vendor/config/platforms.js +1 -1
- package/dist/vendor/config/repo.js +10 -27
- package/dist/vendor/config/schema-client.js +64 -0
- package/dist/vendor/config/schema-cloud.js +38 -0
- package/dist/vendor/config/schema-manager.js +118 -0
- package/dist/vendor/config/schema-overrides.js +68 -0
- package/dist/vendor/config/schema.js +104 -160
- package/dist/vendor/config/site-global.js +2 -3
- package/dist/vendor/config/validate.js +97 -78
- package/dist/vendor/config/winback.js +1 -1
- package/dist/vendor/devkit/actions-secrets.js +1 -1
- package/dist/vendor/devkit/agents-md.js +233 -0
- package/dist/vendor/devkit/attach-log-file.js +16 -2
- package/dist/vendor/devkit/build-json.js +1 -1
- package/dist/vendor/devkit/ci-workflows.js +30 -30
- package/dist/vendor/devkit/cli-router.js +16 -11
- package/dist/vendor/devkit/defaults-engine.js +15 -51
- package/dist/vendor/devkit/deploy-snapshot.js +44 -9
- package/dist/vendor/devkit/env-lines.js +183 -0
- package/dist/vendor/devkit/local.js +64 -10
- package/dist/vendor/devkit/lockfile.js +32 -13
- package/dist/vendor/devkit/logger.js +7 -2
- package/dist/vendor/devkit/merge-line-files.js +219 -177
- package/dist/vendor/devkit/omega-bin.js +208 -111
- package/dist/vendor/devkit/preludes/docs-sync.js +52 -0
- package/dist/vendor/devkit/preludes/index.js +1 -0
- package/dist/vendor/devkit/target-picker.js +45 -0
- package/dist/vendor/devkit/test/dashed-files.js +37 -0
- package/dist/vendor/devkit/test/run-verb-under-tee.js +71 -0
- package/dist/vendor/devkit/test/runner-core.js +6 -6
- package/dist/vendor/devkit/update.js +15 -15
- package/dist/vendor/devkit/verb-scripts.js +40 -0
- package/dist/vendor/devkit/verbs.js +170 -0
- package/dist/vendor/monitoring/env.js +2 -2
- package/dist/vendor/monitoring/index.js +1 -1
- package/dist/vendor/monitoring/main.js +1 -1
- package/dist/vendor/monitoring/preload.js +1 -1
- package/dist/vendor/monitoring/renderer.js +1 -1
- package/package.json +19 -26
- package/dist/commands/install.js +0 -37
- package/dist/defaults/AGENTS.md +0 -110
- package/dist/defaults/CLAUDE.md +0 -1
- package/dist/lib/client-bridge.js +0 -374
- package/dist/lib/logger.js +0 -4
- package/dist/test/suites/build/manager.test.js +0 -213
- package/dist/test/suites/main/client-bridge.test.js +0 -262
- package/dist/vendor/config/env-retired.js +0 -137
- package/dist/vendor/config/retired-keys.js +0 -635
- package/docs/analytics.md +0 -140
- package/docs/app-state.md +0 -92
- package/docs/audit.md +0 -69
- package/docs/auto-updater.md +0 -243
- package/docs/boot-sequence.md +0 -39
- package/docs/build-system.md +0 -169
- package/docs/cdp-debugging.md +0 -169
- package/docs/client-bridge.md +0 -269
- package/docs/common-mistakes.md +0 -21
- package/docs/config-schema.md +0 -120
- package/docs/context-menu.md +0 -112
- package/docs/context.md +0 -81
- package/docs/css.md +0 -90
- package/docs/deep-link.md +0 -186
- package/docs/environment-detection.md +0 -112
- package/docs/fontawesome.md +0 -107
- package/docs/hooks.md +0 -89
- package/docs/icons.md +0 -79
- package/docs/index.md +0 -317
- package/docs/installer-options.md +0 -165
- package/docs/ipc.md +0 -61
- package/docs/lib-modules.md +0 -53
- package/docs/logging.md +0 -229
- package/docs/menu.md +0 -160
- package/docs/releasing.md +0 -239
- package/docs/remote-config.md +0 -118
- package/docs/remote-scripts.md +0 -144
- package/docs/restart-manager.md +0 -144
- package/docs/runner.md +0 -290
- package/docs/sentry.md +0 -97
- package/docs/shared/agent-docs.md +0 -89
- package/docs/shared/analytics.md +0 -612
- package/docs/shared/brands.md +0 -57
- package/docs/shared/breaking-changes.md +0 -851
- package/docs/shared/config.md +0 -1952
- package/docs/shared/deploys.md +0 -341
- package/docs/shared/icons.md +0 -219
- package/docs/shared/local-dev.md +0 -167
- package/docs/shared/logging.md +0 -205
- package/docs/shared/monitoring.md +0 -167
- package/docs/shared/publishing.md +0 -187
- package/docs/shared/rulings.md +0 -34
- package/docs/shared/testing.md +0 -147
- package/docs/shared/theming.md +0 -629
- package/docs/shared/translation.md +0 -333
- package/docs/shared/updates.md +0 -61
- package/docs/signing.md +0 -293
- package/docs/startup.md +0 -142
- package/docs/storage.md +0 -59
- package/docs/templating.md +0 -101
- package/docs/test-boot-layer.md +0 -157
- package/docs/test-framework.md +0 -362
- package/docs/themes.md +0 -149
- package/docs/tooltips.md +0 -99
- package/docs/tray.md +0 -164
- package/docs/usage.md +0 -58
- package/docs/verts.md +0 -62
- package/docs/windows.md +0 -149
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// Build-time tests for the Manager class (build.js).
|
|
2
|
-
|
|
3
|
-
const Manager = require('../../../build.js');
|
|
4
|
-
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
5
|
-
|
|
6
|
-
// The one input and the two lane flags that decide it, saved and restored
|
|
7
|
-
// around every case that touches them (#817).
|
|
8
|
-
const LANE_KEYS = ['OMEGA_ENVIRONMENT', 'OMEGA_BUILD_MODE', 'OMEGA_TEST_MODE', 'NODE_ENV'];
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Run `fn` with exactly `vars` set on the lane keys (null clears them all).
|
|
12
|
-
* @param {object|null} vars - the lane env for this case.
|
|
13
|
-
* @param {function} fn - the body.
|
|
14
|
-
* @returns {*} whatever `fn` returns.
|
|
15
|
-
*/
|
|
16
|
-
function withEnvironment(vars, fn) {
|
|
17
|
-
const saved = {};
|
|
18
|
-
for (const key of LANE_KEYS) saved[key] = process.env[key];
|
|
19
|
-
try {
|
|
20
|
-
for (const key of LANE_KEYS) delete process.env[key];
|
|
21
|
-
Object.assign(process.env, vars || {});
|
|
22
|
-
return fn();
|
|
23
|
-
} finally {
|
|
24
|
-
for (const key of LANE_KEYS) {
|
|
25
|
-
if (saved[key] === undefined) delete process.env[key];
|
|
26
|
-
else process.env[key] = saved[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* What src/build.js resolves at LOAD for a given lane. build.js sets the input
|
|
33
|
-
* once, at require time, so this loads a fresh copy of it per lane.
|
|
34
|
-
* @param {object} vars - the lane env.
|
|
35
|
-
* @returns {string} the resolved environment.
|
|
36
|
-
*/
|
|
37
|
-
function laneEnvironment(vars) {
|
|
38
|
-
const buildPath = require.resolve('../../../build.js');
|
|
39
|
-
return withEnvironment(vars, () => {
|
|
40
|
-
const saved = require.cache[buildPath];
|
|
41
|
-
delete require.cache[buildPath];
|
|
42
|
-
try {
|
|
43
|
-
return require(buildPath).getEnvironment();
|
|
44
|
-
} finally {
|
|
45
|
-
if (saved) require.cache[buildPath] = saved;
|
|
46
|
-
else delete require.cache[buildPath];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = defineCases({
|
|
52
|
-
type: 'group', // independent tests; run all even on failure
|
|
53
|
-
layer: 'build',
|
|
54
|
-
description: 'Manager (build.js)',
|
|
55
|
-
tests: [
|
|
56
|
-
{
|
|
57
|
-
name: 'class is exported and instantiable',
|
|
58
|
-
run: (ctx) => {
|
|
59
|
-
ctx.expect(typeof Manager).toBe('function');
|
|
60
|
-
ctx.expect(new Manager()).toBeInstanceOf(Manager);
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'getMode returns the mode shape',
|
|
65
|
-
run: (ctx) => {
|
|
66
|
-
const mode = Manager.getMode();
|
|
67
|
-
ctx.expect(mode).toHaveProperty('build');
|
|
68
|
-
ctx.expect(mode).toHaveProperty('publish');
|
|
69
|
-
ctx.expect(mode).toHaveProperty('server');
|
|
70
|
-
ctx.expect(mode).toHaveProperty('environment');
|
|
71
|
-
ctx.expect(['development', 'testing', 'production']).toContain(mode.environment);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
// The environment reads ONE input, `OMEGA_ENVIRONMENT`
|
|
76
|
-
// ([#817](https://github.com/Omega-JS-Stack/omega/issues/817)), and the
|
|
77
|
-
// lane that boots or builds this app sets it (src/build.js does, at load).
|
|
78
|
-
// Nothing sniffs NODE_ENV, app.isPackaged or OMEGA_TEST_MODE any more.
|
|
79
|
-
name: 'getEnvironment answers the one input, for each of the three names',
|
|
80
|
-
run: (ctx) => {
|
|
81
|
-
withEnvironment(null, () => {
|
|
82
|
-
for (const name of ['development', 'testing', 'production']) {
|
|
83
|
-
process.env.OMEGA_ENVIRONMENT = name;
|
|
84
|
-
ctx.expect(Manager.getEnvironment()).toBe(name);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
// The bug this replaced: with no signal desktop's own copy answered
|
|
91
|
-
// 'production', so a plain `npm start` bundled itself as a production
|
|
92
|
-
// artifact, while @omega.js/extension's copy of the same function
|
|
93
|
-
// answered 'development' from the same inputs (#817).
|
|
94
|
-
name: 'the build lane resolves production, a dev boot resolves development',
|
|
95
|
-
run: (ctx) => {
|
|
96
|
-
const buildLane = laneEnvironment({ OMEGA_BUILD_MODE: 'true' });
|
|
97
|
-
ctx.expect(buildLane).toBe('production');
|
|
98
|
-
|
|
99
|
-
const devBoot = laneEnvironment({});
|
|
100
|
-
ctx.expect(devBoot).toBe('development');
|
|
101
|
-
|
|
102
|
-
// A lane that already named one keeps it, EXCEPT a build lane: a
|
|
103
|
-
// production build spawned from a test run still bakes production.
|
|
104
|
-
ctx.expect(laneEnvironment({ OMEGA_ENVIRONMENT: 'testing' })).toBe('testing');
|
|
105
|
-
ctx.expect(laneEnvironment({ OMEGA_ENVIRONMENT: 'testing', OMEGA_BUILD_MODE: 'true' })).toBe('production');
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'no input at all is a loud error naming OMEGA_ENVIRONMENT, never a default',
|
|
110
|
-
run: (ctx) => {
|
|
111
|
-
withEnvironment(null, () => {
|
|
112
|
-
delete process.env.OMEGA_ENVIRONMENT;
|
|
113
|
-
ctx.expect(() => Manager.getEnvironment()).toThrow(/OMEGA_ENVIRONMENT/);
|
|
114
|
-
process.env.OMEGA_ENVIRONMENT = 'staging';
|
|
115
|
-
ctx.expect(() => Manager.getEnvironment()).toThrow(/OMEGA_ENVIRONMENT/);
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
// The core invariant: is*() DERIVE from getEnvironment(), so they can
|
|
121
|
-
// NEVER disagree with it, and exactly one is always true.
|
|
122
|
-
name: 'invariant: is*() exactly matches getEnvironment() + mutually exclusive (every scenario)',
|
|
123
|
-
run: (ctx) => {
|
|
124
|
-
withEnvironment(null, () => {
|
|
125
|
-
for (const name of ['development', 'testing', 'production']) {
|
|
126
|
-
process.env.OMEGA_ENVIRONMENT = name;
|
|
127
|
-
const e = Manager.getEnvironment();
|
|
128
|
-
ctx.expect(e).toBe(name);
|
|
129
|
-
ctx.expect(Manager.isDevelopment()).toBe(e === 'development');
|
|
130
|
-
ctx.expect(Manager.isTesting()).toBe(e === 'testing');
|
|
131
|
-
ctx.expect(Manager.isProduction()).toBe(e === 'production');
|
|
132
|
-
const trueCount = [Manager.isDevelopment(), Manager.isTesting(), Manager.isProduction()].filter(Boolean).length;
|
|
133
|
-
ctx.expect(trueCount).toBe(1);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: 'getPackage("main") resolves to @omega.js/desktop package.json',
|
|
140
|
-
run: (ctx) => {
|
|
141
|
-
const pkg = Manager.getPackage('main');
|
|
142
|
-
ctx.expect(pkg.name).toBe('@omega.js/desktop');
|
|
143
|
-
ctx.expect(pkg).toHaveProperty('version');
|
|
144
|
-
ctx.expect(pkg).toHaveProperty('exports');
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'getRootPath("main") returns a non-empty string',
|
|
149
|
-
run: (ctx) => {
|
|
150
|
-
const root = Manager.getRootPath('main');
|
|
151
|
-
ctx.expect(typeof root).toBe('string');
|
|
152
|
-
ctx.expect(root.length).toBeGreaterThan(0);
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'getLiveReloadPort defaults to 35729',
|
|
157
|
-
run: (ctx) => {
|
|
158
|
-
const prev = process.env.OMEGA_LIVERELOAD_PORT;
|
|
159
|
-
delete process.env.OMEGA_LIVERELOAD_PORT;
|
|
160
|
-
try {
|
|
161
|
-
ctx.expect(Manager.getLiveReloadPort()).toBe(35729);
|
|
162
|
-
} finally {
|
|
163
|
-
if (prev !== undefined) process.env.OMEGA_LIVERELOAD_PORT = prev;
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'getWindowsSignStrategy defaults to self-hosted when no config',
|
|
169
|
-
run: (ctx) => {
|
|
170
|
-
// No EM_WIN_SIGN_STRATEGY env-var support anymore — config is the only source.
|
|
171
|
-
// Run from a cwd with no omega.json5 to confirm the default.
|
|
172
|
-
const fs = require('fs'); const os = require('os'); const path = require('path');
|
|
173
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-strategy-'));
|
|
174
|
-
const orig = process.cwd();
|
|
175
|
-
try {
|
|
176
|
-
process.chdir(tmp);
|
|
177
|
-
ctx.expect(Manager.getWindowsSignStrategy()).toBe('self-hosted');
|
|
178
|
-
} finally {
|
|
179
|
-
process.chdir(orig);
|
|
180
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: 'getWindowsSignStrategy reads config platforms.windows.signing.strategy',
|
|
186
|
-
run: (ctx) => {
|
|
187
|
-
const fs = require('fs'); const os = require('os'); const path = require('path');
|
|
188
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-strategy-'));
|
|
189
|
-
fs.mkdirSync(path.join(tmp, 'config'), { recursive: true });
|
|
190
|
-
fs.writeFileSync(path.join(tmp, 'config', 'omega.json5'),
|
|
191
|
-
`{ targets: { desktop: { type: 'desktop', platforms: { windows: { signing: { strategy: 'cloud' } } } } } }`);
|
|
192
|
-
const orig = process.cwd();
|
|
193
|
-
try {
|
|
194
|
-
process.chdir(tmp);
|
|
195
|
-
ctx.expect(Manager.getWindowsSignStrategy()).toBe('cloud');
|
|
196
|
-
} finally {
|
|
197
|
-
process.chdir(orig);
|
|
198
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
name: 'logger returns a named logger',
|
|
204
|
-
run: (ctx) => {
|
|
205
|
-
const m = new Manager();
|
|
206
|
-
const logger = m.logger('test-name');
|
|
207
|
-
ctx.expect(logger.name).toBe('test-name');
|
|
208
|
-
ctx.expect(typeof logger.log).toBe('function');
|
|
209
|
-
ctx.expect(typeof logger.error).toBe('function');
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
});
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
// Main-process tests for lib/client-bridge.js — unit-level coverage that doesn't hit Firebase.
|
|
2
|
-
//
|
|
3
|
-
// Real Firebase integration tests live in client-bridge.integration.test.js
|
|
4
|
-
// (gated on extended mode); the sign-in proof itself is #904's, through a
|
|
5
|
-
// persona the backend emulator seeds.
|
|
6
|
-
|
|
7
|
-
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
8
|
-
|
|
9
|
-
module.exports = defineCases({
|
|
10
|
-
type: 'suite',
|
|
11
|
-
layer: 'main',
|
|
12
|
-
description: 'client-bridge (main, unit)',
|
|
13
|
-
cleanup: async (ctx) => {
|
|
14
|
-
await ctx.manager.omega._resetForTests();
|
|
15
|
-
},
|
|
16
|
-
tests: [
|
|
17
|
-
{
|
|
18
|
-
name: 'initialize ran during boot',
|
|
19
|
-
run: (ctx) => {
|
|
20
|
-
ctx.expect(ctx.manager.omega._initialized).toBe(true);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'IPC handlers are registered',
|
|
25
|
-
run: (ctx) => {
|
|
26
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:sync-request')).toBe(true);
|
|
27
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:sign-out')).toBe(true);
|
|
28
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:get-user')).toBe(true);
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'getCurrentUser returns null when nothing is signed in',
|
|
33
|
-
run: (ctx) => {
|
|
34
|
-
// The harness boots without auth; either firebase isn't loaded (no cloud.config
|
|
35
|
-
// in default config) or it is and there's no user. Either way, currentUser is null.
|
|
36
|
-
ctx.expect(ctx.manager.omega.getCurrentUser()).toBeNull();
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'getIdToken returns null when nothing is signed in',
|
|
41
|
-
run: async (ctx) => {
|
|
42
|
-
// Same no-auth harness as getCurrentUser above — signed-in token
|
|
43
|
-
// round-trips are the integration suite's domain.
|
|
44
|
-
ctx.expect(await ctx.manager.omega.getIdToken()).toBeNull();
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'handleAuthToken returns no-op result when firebase not loaded',
|
|
49
|
-
run: async (ctx) => {
|
|
50
|
-
// Default config has empty cloud.config → firebase fails to init → _firebaseAuth=null.
|
|
51
|
-
if (ctx.manager.omega._firebaseAuth) {
|
|
52
|
-
ctx.skip('firebase did load (cloud.config was set) — covered by integration tests');
|
|
53
|
-
}
|
|
54
|
-
const r = await ctx.manager.omega.handleAuthToken('whatever');
|
|
55
|
-
ctx.expect(r.success).toBe(false);
|
|
56
|
-
ctx.expect(r.reason).toBe('firebase-not-loaded');
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'handleAuthToken with empty token returns no-token failure',
|
|
61
|
-
run: async (ctx) => {
|
|
62
|
-
// Stub _firebaseAuth so we hit the "no token" branch instead of "firebase-not-loaded."
|
|
63
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
64
|
-
ctx.manager.omega._firebaseAuth = { currentUser: null }; // truthy so we pass the firebase check
|
|
65
|
-
try {
|
|
66
|
-
const r = await ctx.manager.omega.handleAuthToken('');
|
|
67
|
-
ctx.expect(r.success).toBe(false);
|
|
68
|
-
ctx.expect(r.reason).toBe('no-token');
|
|
69
|
-
} finally {
|
|
70
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'sync-request: same UID → no sync needed',
|
|
76
|
-
run: async (ctx) => {
|
|
77
|
-
// Stub the auth so we control bgUid.
|
|
78
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
79
|
-
ctx.manager.omega._firebaseAuth = { currentUser: { uid: 'abc' } };
|
|
80
|
-
try {
|
|
81
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: 'abc' });
|
|
82
|
-
ctx.expect(result.needsSync).toBe(false);
|
|
83
|
-
} finally {
|
|
84
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'sync-request: main signed out, renderer signed in → tells renderer to sign out',
|
|
90
|
-
run: async (ctx) => {
|
|
91
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
92
|
-
ctx.manager.omega._firebaseAuth = { currentUser: null };
|
|
93
|
-
try {
|
|
94
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: 'someone' });
|
|
95
|
-
ctx.expect(result.needsSync).toBe(true);
|
|
96
|
-
ctx.expect(result.signOut).toBe(true);
|
|
97
|
-
} finally {
|
|
98
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'sync-request: firebase not loaded → no sync',
|
|
104
|
-
run: async (ctx) => {
|
|
105
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
106
|
-
ctx.manager.omega._firebaseAuth = null;
|
|
107
|
-
try {
|
|
108
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: null });
|
|
109
|
-
ctx.expect(result.needsSync).toBe(false);
|
|
110
|
-
ctx.expect(result.reason).toBe('firebase-not-loaded');
|
|
111
|
-
} finally {
|
|
112
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'sign-out IPC succeeds when nothing is signed in',
|
|
118
|
-
run: async (ctx) => {
|
|
119
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sign-out');
|
|
120
|
-
ctx.expect(result.success).toBe(true);
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'get-user IPC returns null when no current user',
|
|
125
|
-
run: async (ctx) => {
|
|
126
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:get-user');
|
|
127
|
-
ctx.expect(result).toBeNull();
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'onAuthChange returns an unsubscribe fn',
|
|
132
|
-
run: (ctx) => {
|
|
133
|
-
const fn = () => {};
|
|
134
|
-
const off = ctx.manager.omega.onAuthChange(fn);
|
|
135
|
-
ctx.expect(ctx.manager.omega._stateSubs.has(fn)).toBe(true);
|
|
136
|
-
off();
|
|
137
|
-
ctx.expect(ctx.manager.omega._stateSubs.has(fn)).toBe(false);
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: '_snapshotUser returns the public user shape (no token)',
|
|
142
|
-
run: (ctx) => {
|
|
143
|
-
const snap = ctx.manager.omega._snapshotUser({
|
|
144
|
-
uid: 'u1',
|
|
145
|
-
email: 'a@b.com',
|
|
146
|
-
displayName: 'Bob',
|
|
147
|
-
photoURL: 'http://x/p.png',
|
|
148
|
-
emailVerified: true,
|
|
149
|
-
// sensitive stuff that should NOT be exposed
|
|
150
|
-
stsTokenManager: { accessToken: 'SECRET' },
|
|
151
|
-
providerData: ['xxx'],
|
|
152
|
-
});
|
|
153
|
-
ctx.expect(snap).toEqual({
|
|
154
|
-
uid: 'u1',
|
|
155
|
-
email: 'a@b.com',
|
|
156
|
-
displayName: 'Bob',
|
|
157
|
-
photoURL: 'http://x/p.png',
|
|
158
|
-
emailVerified: true,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
// The emulator gate (#46). _getFirebaseAuth resolves firebase through the
|
|
164
|
-
// bridge's OWN seams (_firebase / _firebaseModule, filled by
|
|
165
|
-
// _tryLoadFirebase) — swapping those recording namespaces in drives the real
|
|
166
|
-
// method, no stubbing of the module under test. The manager is an input too:
|
|
167
|
-
// isTesting() is the whole gate.
|
|
168
|
-
name: 'auth emulator: a testing run connects, dev/production never do',
|
|
169
|
-
run: (ctx) => {
|
|
170
|
-
const bridge = ctx.manager.omega;
|
|
171
|
-
const saved = {
|
|
172
|
-
firebase: bridge._firebase,
|
|
173
|
-
module: bridge._firebaseModule,
|
|
174
|
-
auth: bridge._firebaseAuth,
|
|
175
|
-
manager: bridge._manager,
|
|
176
|
-
port: process.env.OMEGA_AUTH_PORT,
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// One recording firebase namespace pair, reused per run
|
|
180
|
-
const connects = [];
|
|
181
|
-
const authInstance = { __auth: true };
|
|
182
|
-
bridge._firebase = {
|
|
183
|
-
getApp: () => { throw new Error('no app'); },
|
|
184
|
-
initializeApp: () => ({ __app: true }),
|
|
185
|
-
};
|
|
186
|
-
bridge._firebaseModule = {
|
|
187
|
-
getAuth: () => authInstance,
|
|
188
|
-
connectAuthEmulator: (auth, url, opts) => connects.push({ auth, url, opts }),
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const run = (isTesting, dev) => {
|
|
192
|
-
bridge._firebaseAuth = null;
|
|
193
|
-
bridge._manager = {
|
|
194
|
-
config: { cloud: { config: { apiKey: 'AIza-test', projectId: 'demo-desktop' } }, ...(dev ? { dev } : {}) },
|
|
195
|
-
isTesting: () => isTesting,
|
|
196
|
-
};
|
|
197
|
-
return bridge._getFirebaseAuth(null);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
delete process.env.OMEGA_AUTH_PORT;
|
|
202
|
-
|
|
203
|
-
// production / dev shape — no emulator, ever
|
|
204
|
-
ctx.expect(run(false)).toBe(authInstance);
|
|
205
|
-
ctx.expect(connects.length).toBe(0);
|
|
206
|
-
|
|
207
|
-
// testing shape: the port comes from the map the bundle baked, which
|
|
208
|
-
// carries @omega.js/config's classic 9099 as its floor
|
|
209
|
-
// ([#834](https://github.com/Omega-JS-Stack/omega/issues/834)).
|
|
210
|
-
ctx.expect(run(true, { ports: { auth: 9099 } })).toBe(authInstance);
|
|
211
|
-
ctx.expect(connects.length).toBe(1);
|
|
212
|
-
ctx.expect(connects[0].auth).toBe(authInstance);
|
|
213
|
-
ctx.expect(connects[0].url).toBe('http://localhost:9099');
|
|
214
|
-
|
|
215
|
-
// a bumped port arrives on OMEGA_AUTH_PORT (N7)
|
|
216
|
-
process.env.OMEGA_AUTH_PORT = '9199';
|
|
217
|
-
run(true, { ports: { auth: 9099 } });
|
|
218
|
-
ctx.expect(connects.length).toBe(2);
|
|
219
|
-
ctx.expect(connects[1].url).toBe('http://localhost:9199');
|
|
220
|
-
|
|
221
|
-
// Neither channel is a broken artifact, and it says so by name
|
|
222
|
-
// rather than dialling a port nothing identity-checks (#834).
|
|
223
|
-
delete process.env.OMEGA_AUTH_PORT;
|
|
224
|
-
let threw;
|
|
225
|
-
try { run(true); } catch (e) { threw = e; }
|
|
226
|
-
ctx.expect(threw).toBeDefined();
|
|
227
|
-
ctx.expect(threw.message).toMatch(/dev port for `auth`/);
|
|
228
|
-
ctx.expect(threw.message).toMatch(/bundle task/);
|
|
229
|
-
ctx.expect(connects.length).toBe(2);
|
|
230
|
-
} finally {
|
|
231
|
-
bridge._firebase = saved.firebase;
|
|
232
|
-
bridge._firebaseModule = saved.module;
|
|
233
|
-
bridge._firebaseAuth = saved.auth;
|
|
234
|
-
bridge._manager = saved.manager;
|
|
235
|
-
if (saved.port === undefined) delete process.env.OMEGA_AUTH_PORT;
|
|
236
|
-
else process.env.OMEGA_AUTH_PORT = saved.port;
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: 'deep-link auth/token route is wired to handleAuthToken',
|
|
242
|
-
run: async (ctx) => {
|
|
243
|
-
// We've already tested the deep-link side in deep-link.test.js. Here we verify
|
|
244
|
-
// the integration is actually live: dispatching the route triggers our spy.
|
|
245
|
-
let received = null;
|
|
246
|
-
const orig = ctx.manager.omega.handleAuthToken;
|
|
247
|
-
ctx.manager.omega.handleAuthToken = async (token) => {
|
|
248
|
-
received = token;
|
|
249
|
-
return { success: true };
|
|
250
|
-
};
|
|
251
|
-
try {
|
|
252
|
-
ctx.manager.deepLink.dispatch('myapp://auth/token?authToken=BRIDGE-TEST-TOKEN');
|
|
253
|
-
// Built-in handler is sync up to the await — give it a tick.
|
|
254
|
-
await new Promise((r) => setImmediate(r));
|
|
255
|
-
ctx.expect(received).toBe('BRIDGE-TEST-TOKEN');
|
|
256
|
-
} finally {
|
|
257
|
-
ctx.manager.omega.handleAuthToken = orig;
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retired ENV keys ([#893](https://github.com/Omega-JS-Stack/omega/issues/893))
|
|
3
|
-
* - the `.env` half of retired-keys.js.
|
|
4
|
-
*
|
|
5
|
-
* Six values were declared in both homes at once: the env schema carried them
|
|
6
|
-
* as non-secret keys while the config schema already declared (or now
|
|
7
|
-
* declares) the same fact. Two homes for one value drift, and the rule that
|
|
8
|
-
* settles which one wins is in docs/shared/config.md ("Config or env?"):
|
|
9
|
-
* config holds what is PUBLIC by design (an id a store URL carries, a key a
|
|
10
|
-
* browser bundle ships, a value printed in a binary), `.env` holds secrets,
|
|
11
|
-
* the login coordinates that only travel with a secret, and machine paths.
|
|
12
|
-
*
|
|
13
|
-
* There is no dual-read anywhere in OMEGA, so a `.env` line left behind is a
|
|
14
|
-
* value nothing reads: the id a brand carefully pasted would be ignored and
|
|
15
|
-
* the publish would address the wrong listing, or none. Every layer read
|
|
16
|
-
* therefore FAILS on one, naming the config path the value moved to
|
|
17
|
-
* (env.js's parseEnvFile, the one place a `.env` layer is parsed).
|
|
18
|
-
*
|
|
19
|
-
* The config-side register gets nothing from this move: these were never
|
|
20
|
-
* config keys, so nothing there was renamed.
|
|
21
|
-
*
|
|
22
|
-
* The register also carries the env-side RENAMES
|
|
23
|
-
* ([#845](https://github.com/Omega-JS-Stack/omega/issues/845)): a key that is
|
|
24
|
-
* still a secret and still lives in `.env`, under a new name. Same silence,
|
|
25
|
-
* same refusal; the fix it names is renaming the line, not deleting it.
|
|
26
|
-
*
|
|
27
|
-
* And it carries the keys that are retired OUTRIGHT
|
|
28
|
-
* ([#819](https://github.com/Omega-JS-Stack/omega/issues/819)): no config path,
|
|
29
|
-
* no new env name, because what replaced the key is a MECHANISM rather than a
|
|
30
|
-
* value. Such a row declares `replacement: null` and its refusal reads as a
|
|
31
|
-
* deletion with nowhere to move the value to.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
// env var name -> { replacement, why, home } (docs/shared/config.md carries the
|
|
35
|
-
// rows). `home` is where the replacement LIVES: 'config' by default (the #893
|
|
36
|
-
// move), or 'env' for a key that stayed a secret and only changed NAME, which
|
|
37
|
-
// is a rename of the line rather than a deletion. `replacement: null` is a key
|
|
38
|
-
// with no successor of any kind (#819): the line is simply deleted, and the
|
|
39
|
-
// row's `why` names the mechanism that made it unnecessary.
|
|
40
|
-
const RETIRED_ENV_KEYS = {
|
|
41
|
-
CHROME_EXTENSION_ID: {
|
|
42
|
-
replacement: 'targets.<name>.listings.chrome.id',
|
|
43
|
-
why: 'a store item id is public by design (it is in the listing URL), so it lives beside that listing in config',
|
|
44
|
-
},
|
|
45
|
-
FIREFOX_EXTENSION_ID: {
|
|
46
|
-
replacement: 'targets.<name>.listings.firefox.id',
|
|
47
|
-
why: "the AMO add-on id IS the manifest's gecko id, and config is its ONE home: the local scaffold pins the derived id there and the package task writes it into the manifest",
|
|
48
|
-
},
|
|
49
|
-
EDGE_PRODUCT_ID: {
|
|
50
|
-
replacement: 'targets.<name>.listings.edge.id',
|
|
51
|
-
why: 'a store product id is public by design (it is in the listing URL), so it lives beside that listing in config',
|
|
52
|
-
},
|
|
53
|
-
RECAPTCHA_SITE_KEY: {
|
|
54
|
-
replacement: 'captcha.providers.recaptcha.siteKey',
|
|
55
|
-
why: 'the site key is rendered into every page that carries a form, so it is public by definition; RECAPTCHA_SECRET_KEY stays in .env',
|
|
56
|
-
},
|
|
57
|
-
PAYPAL_CLIENT_ID: {
|
|
58
|
-
replacement: 'payment.providers.paypal.clientId',
|
|
59
|
-
why: 'the public half of the PayPal pair, already declared in config; the backend read it through a boot bridge that copied config into env',
|
|
60
|
-
},
|
|
61
|
-
CHARGEBEE_SITE: {
|
|
62
|
-
replacement: 'payment.providers.chargebee.site',
|
|
63
|
-
why: 'the site name is in every Chargebee URL, already declared in config; the backend read it through a boot bridge that copied config into env',
|
|
64
|
-
},
|
|
65
|
-
// The connections pair ([#845](https://github.com/Omega-JS-Stack/omega/issues/845)):
|
|
66
|
-
// these are SECRETS and stayed in `.env`, so the row is a rename, not a move.
|
|
67
|
-
// Exact names only, one per provider: the register is a name lookup, so the
|
|
68
|
-
// `OAUTH2_*` family is spelled out a row at a time as a brand needs it, and
|
|
69
|
-
// Google is the pair every brand carries today.
|
|
70
|
-
OAUTH2_GOOGLE_CLIENT_ID: {
|
|
71
|
-
home: 'env',
|
|
72
|
-
replacement: 'CONNECTIONS_GOOGLE_CLIENT_ID',
|
|
73
|
-
why: '#788 renamed the oauth2 feature to connections, the env family included; the backend reads only CONNECTIONS_<PROVIDER>_CLIENT_ID now',
|
|
74
|
-
},
|
|
75
|
-
OAUTH2_GOOGLE_CLIENT_SECRET: {
|
|
76
|
-
home: 'env',
|
|
77
|
-
replacement: 'CONNECTIONS_GOOGLE_CLIENT_SECRET',
|
|
78
|
-
why: '#788 renamed the oauth2 feature to connections, the env family included; the backend reads only CONNECTIONS_<PROVIDER>_CLIENT_SECRET now',
|
|
79
|
-
},
|
|
80
|
-
// The test-lane pair ([#819](https://github.com/Omega-JS-Stack/omega/issues/819),
|
|
81
|
-
// Ian 2026-09-13): retired outright, so neither row names a replacement. A
|
|
82
|
-
// suite no longer holds a credential of its own, which is why there is
|
|
83
|
-
// nothing to move the value to.
|
|
84
|
-
OMEGA_TEST_FIREBASE_ADMIN_KEY: {
|
|
85
|
-
replacement: null,
|
|
86
|
-
why: 'retired: desktop, extension and web test their own sign-in through a seeded persona from the backend emulator (#904), so no suite mints a custom token from a service account any more',
|
|
87
|
-
},
|
|
88
|
-
OMEGA_TEST_USER_UID: {
|
|
89
|
-
replacement: null,
|
|
90
|
-
why: 'retired: desktop, extension and web test their own sign-in through a seeded persona from the backend emulator (#904), and the roster names the persona, so no uid is configured anywhere',
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The retired keys a parsed `.env` layer carries, in the layer's own order.
|
|
96
|
-
*
|
|
97
|
-
* Presence is the whole test: an empty value (`KEY=`) documents a key nothing
|
|
98
|
-
* reads, so it is owed the same deletion as a valued one.
|
|
99
|
-
*
|
|
100
|
-
* @param {Object<string, string>} values - Parsed `.env` values.
|
|
101
|
-
* @returns {Array<{ key: string, replacement: string|null, why: string }>}
|
|
102
|
-
*/
|
|
103
|
-
function findRetiredEnvKeys(values) {
|
|
104
|
-
return Object.keys(values || {})
|
|
105
|
-
.filter((key) => RETIRED_ENV_KEYS[key])
|
|
106
|
-
.map((key) => ({ key, ...RETIRED_ENV_KEYS[key] }));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Refuse a `.env` layer that still carries a retired key, spelling the move
|
|
111
|
-
* out. A row with no replacement says so plainly: the line is deleted and
|
|
112
|
-
* nothing takes the value anywhere (#819).
|
|
113
|
-
*
|
|
114
|
-
* @param {Object<string, string>} values - Parsed `.env` values.
|
|
115
|
-
* @param {string} envPath - The file the values came from (named in the error).
|
|
116
|
-
* @throws {Error} Naming every retired key in the layer, its new home, and why.
|
|
117
|
-
*/
|
|
118
|
-
function assertNoRetiredEnvKeys(values, envPath) {
|
|
119
|
-
const found = findRetiredEnvKeys(values);
|
|
120
|
-
if (found.length === 0) return;
|
|
121
|
-
|
|
122
|
-
const moves = found.map(({ key, replacement, why, home }) => {
|
|
123
|
-
if (!replacement) return ` ${key} is retired outright: delete the .env line, nothing replaces the value (${why})`;
|
|
124
|
-
|
|
125
|
-
return home === 'env'
|
|
126
|
-
? ` ${key} renamed to ${replacement}; rename the .env line (${why})`
|
|
127
|
-
: ` ${key} moved to ${replacement} in config/omega.json5; delete the .env line (${why})`;
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
throw new Error(
|
|
131
|
-
`${envPath} carries ${found.length} retired env key(s). Nothing reads them, so the value is silently lost:\n`
|
|
132
|
-
+ `${moves.join('\n')}\n`
|
|
133
|
-
+ 'The rule, and the whole register: docs/shared/config.md ("Config or env?").',
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
module.exports = { RETIRED_ENV_KEYS, findRetiredEnvKeys, assertNoRetiredEnvKeys };
|