@speedkit/cli 4.44.0-beta.4 → 4.45.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/CHANGELOG.md +40 -11
- package/README.md +77 -47
- package/dist/base/sk-command.d.ts +7 -0
- package/dist/base/sk-command.js +19 -0
- package/dist/commands/deploy.d.ts +1 -0
- package/dist/commands/deploy.js +5 -1
- package/dist/commands/diff.d.ts +47 -0
- package/dist/commands/diff.js +67 -0
- package/dist/commands/generate-pop-config.js +3 -7
- package/dist/commands/origin-request.d.ts +2 -1
- package/dist/commands/origin-request.js +1 -0
- package/dist/helpers/race.js +4 -2
- package/dist/helpers/spec/race.spec.js +31 -0
- package/dist/models/files.d.ts +0 -1
- package/dist/models/files.js +0 -1
- package/dist/services/browser-fetch/browser-origin-fetch.js +1 -1
- package/dist/services/browser-fetch/browser-origin-fetcher.d.ts +1 -7
- package/dist/services/browser-fetch/browser-origin-fetcher.js +3 -26
- package/dist/services/bundler/bundle-service-factory.d.ts +0 -3
- package/dist/services/bundler/bundle-service-factory.js +1 -5
- package/dist/services/bundler/bundle-service.d.ts +1 -10
- package/dist/services/bundler/bundle-service.js +1 -16
- package/dist/services/bundler/index.d.ts +0 -1
- package/dist/services/bundler/index.js +0 -1
- package/dist/services/cli/cli-environment.d.ts +11 -0
- package/dist/services/cli/cli-environment.js +37 -0
- package/dist/services/cli/cli-service-model.d.ts +3 -1
- package/dist/services/cli/cli-service.d.ts +1 -1
- package/dist/services/cli/cli-service.js +4 -1
- package/dist/services/cli/spec/cli-environment.spec.js +30 -1
- package/dist/services/deploy/checks/activation/customer-approval-check.js +1 -1
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/refresh-deployment-job-check.js +8 -7
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +11 -7
- package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +2 -2
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +3 -2
- package/dist/services/deploy/checks/pre-deploy/device-detection-changed-check.js +3 -2
- package/dist/services/deploy/checks/pre-deploy/split-change-check.js +3 -2
- package/dist/services/deploy/deploy-service-build-context.d.ts +2 -0
- package/dist/services/deploy/deploy-service-build-context.js +13 -2
- package/dist/services/deploy/deploy-service-factory.js +2 -9
- package/dist/services/deploy/deploy-service-model.d.ts +11 -1
- package/dist/services/deploy/deploy-service.d.ts +2 -0
- package/dist/services/deploy/deploy-service.js +26 -1
- package/dist/services/deploy/handler/customer-config-handler.d.ts +2 -2
- package/dist/services/deploy/handler/install-resource-handler.d.ts +2 -2
- package/dist/services/deploy/handler/install-resource-handler.js +6 -3
- package/dist/services/deploy/handler/module-handler.d.ts +2 -2
- package/dist/services/deploy/handler/module-handler.js +2 -2
- package/dist/services/deploy/handler/server-config-handler.d.ts +2 -2
- package/dist/services/deploy/handler/server-config-handler.js +2 -2
- package/dist/services/deploy/mr/live-state-check.d.ts +2 -2
- package/dist/services/deploy/mr/merge-request-deploy-service-factory.js +2 -7
- package/dist/services/deploy/policy/deploy-policy-model.d.ts +1 -5
- package/dist/services/deploy/policy/deploy-policy-model.js +0 -4
- package/dist/services/deploy/policy/index.d.ts +1 -0
- package/dist/services/deploy/policy/index.js +1 -0
- package/dist/services/deploy/policy/testing-deploy-policy.d.ts +16 -0
- package/dist/services/deploy/policy/testing-deploy-policy.js +42 -0
- package/dist/services/deploy/spec/checks/post-deploy/refresh-deployment-job-check.spec.js +5 -12
- package/dist/services/deploy/spec/deploy-service.spec.js +64 -0
- package/dist/services/deploy/spec/handler/install-resource-handler.spec.js +58 -0
- package/dist/services/deploy/spec/mr/live-state-check.spec.js +2 -2
- package/dist/services/deploy/spec/policy/auto-deploy-policy.spec.js +0 -2
- package/dist/services/deploy/spec/policy/testing-deploy-policy.spec.d.ts +1 -0
- package/dist/services/deploy/spec/policy/testing-deploy-policy.spec.js +46 -0
- package/dist/services/diff/create-diff-engine.d.ts +14 -0
- package/dist/services/diff/create-diff-engine.js +42 -0
- package/dist/services/diff/customer-origin.d.ts +9 -0
- package/dist/services/diff/customer-origin.js +19 -0
- package/dist/services/diff/diff-engine.d.ts +30 -0
- package/dist/services/diff/diff-engine.js +49 -0
- package/dist/services/diff/diff-log.d.ts +9 -0
- package/dist/services/diff/diff-log.js +18 -0
- package/dist/services/diff/diff-model.d.ts +68 -0
- package/dist/services/diff/diff-model.js +1 -0
- package/dist/services/diff/diff-service-build-context.d.ts +99 -9
- package/dist/services/diff/diff-service-build-context.js +299 -1
- package/dist/services/diff/diff-service-factory.d.ts +24 -2
- package/dist/services/diff/diff-service-factory.js +165 -3
- package/dist/services/diff/diff-service.d.ts +93 -33
- package/dist/services/diff/diff-service.js +274 -140
- package/dist/services/diff/index.d.ts +12 -1
- package/dist/services/diff/index.js +12 -1
- package/dist/services/diff/noise-baseline.d.ts +28 -0
- package/dist/services/diff/noise-baseline.js +105 -0
- package/dist/services/diff/page-source.d.ts +42 -0
- package/dist/services/diff/page-source.js +93 -0
- package/dist/services/diff/side-failure.d.ts +28 -0
- package/dist/services/diff/side-failure.js +100 -0
- package/dist/services/diff/sinks/json-diff-sink.d.ts +32 -0
- package/dist/services/diff/sinks/json-diff-sink.js +44 -0
- package/dist/services/diff/sinks/no-diff-sink.d.ts +5 -0
- package/dist/services/diff/sinks/no-diff-sink.js +6 -0
- package/dist/services/diff/sinks/patch-diff-sink.d.ts +19 -0
- package/dist/services/diff/sinks/patch-diff-sink.js +29 -0
- package/dist/services/diff/sinks/tool-diff-sink.d.ts +26 -0
- package/dist/services/diff/sinks/tool-diff-sink.js +88 -0
- package/dist/services/diff/sinks/unified-patch.d.ts +7 -0
- package/dist/services/diff/sinks/unified-patch.js +12 -0
- package/dist/services/diff/spec/customer-origin.spec.d.ts +1 -0
- package/dist/services/diff/spec/customer-origin.spec.js +27 -0
- package/dist/services/diff/spec/diff-engine.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-engine.spec.js +47 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-service-build-context.spec.js +185 -0
- package/dist/services/diff/spec/diff-service.spec.d.ts +1 -0
- package/dist/services/diff/spec/diff-service.spec.js +393 -0
- package/dist/services/diff/spec/noise-baseline.spec.d.ts +1 -0
- package/dist/services/diff/spec/noise-baseline.spec.js +95 -0
- package/dist/services/diff/spec/page-source.spec.d.ts +1 -0
- package/dist/services/diff/spec/page-source.spec.js +140 -0
- package/dist/services/diff/spec/sinks/json-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/json-diff-sink.spec.js +72 -0
- package/dist/services/diff/spec/sinks/patch-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/patch-diff-sink.spec.js +47 -0
- package/dist/services/diff/spec/sinks/tool-diff-sink.spec.d.ts +1 -0
- package/dist/services/diff/spec/sinks/tool-diff-sink.spec.js +61 -0
- package/dist/services/document-handler-runtime/document-handler-abort.d.ts +2 -0
- package/dist/services/document-handler-runtime/document-handler-abort.js +2 -0
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +0 -17
- package/dist/services/document-handler-runtime/document-handler-server.js +19 -81
- package/dist/services/document-handler-runtime/runtime-files.d.ts +9 -0
- package/dist/services/document-handler-runtime/runtime-files.js +17 -0
- package/dist/services/integration-api/integration-api-model.d.ts +1 -2
- package/dist/services/integration-api/spec/speed-kit-config-file.spec.js +8 -68
- package/dist/services/integration-api/struct/customer-config.d.ts +1 -32
- package/dist/services/integration-api/struct/customer-config.js +3 -33
- package/dist/services/integration-api/struct/speed-kit-config-file.d.ts +4 -9
- package/dist/services/integration-api/struct/speed-kit-config-file.js +10 -27
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +8 -25
- package/dist/services/onboarding/dashboard/diff-against-current-page.d.ts +29 -7
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +24 -37
- package/dist/services/onboarding/dashboard/index.js +13 -6
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +21 -8
- package/dist/services/onboarding/dashboard/request-diff-service.js +21 -49
- package/dist/services/onboarding/onboarding-model.d.ts +0 -1
- package/dist/services/onboarding/onboarding-model.js +0 -1
- package/dist/services/onboarding/onboarding-service-factory.d.ts +0 -1
- package/dist/services/onboarding/onboarding-service-factory.js +24 -30
- package/dist/services/onboarding/spec/dashboard/request-diff-service.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/dashboard/request-diff-service.spec.js +57 -0
- package/dist/services/onboarding/templates/install-speed-kit-js-template.js +0 -5
- package/dist/services/onboarding/virtual-orestes-app/index.d.ts +3 -3
- package/dist/services/onboarding/virtual-orestes-app/index.js +5 -5
- package/dist/services/origin-request/index.d.ts +3 -0
- package/dist/services/origin-request/index.js +3 -0
- package/dist/services/origin-request/origin-fetcher.d.ts +52 -0
- package/dist/services/origin-request/origin-fetcher.js +93 -0
- package/dist/services/origin-request/origin-request-service-build-context.d.ts +6 -3
- package/dist/services/origin-request/origin-request-service-build-context.js +30 -4
- package/dist/services/origin-request/origin-request-service-factory.d.ts +5 -0
- package/dist/services/origin-request/origin-request-service-factory.js +40 -6
- package/dist/services/origin-request/origin-request-service.d.ts +6 -10
- package/dist/services/origin-request/origin-request-service.js +28 -70
- package/dist/services/origin-request/runtime-config-source.d.ts +36 -0
- package/dist/services/origin-request/runtime-config-source.js +59 -0
- package/dist/services/origin-request/spec/origin-error-cause.spec.d.ts +1 -0
- package/dist/services/{onboarding/spec/virtual-orestes-app → origin-request/spec}/origin-error-cause.spec.js +1 -1
- package/dist/services/origin-request/spec/origin-fetcher.spec.d.ts +1 -0
- package/dist/services/{onboarding/spec/virtual-orestes-app/crawler.spec.js → origin-request/spec/origin-fetcher.spec.js} +46 -15
- package/dist/services/origin-request/spec/origin-request-service-build-context.spec.d.ts +1 -0
- package/dist/services/origin-request/spec/origin-request-service-build-context.spec.js +32 -0
- package/dist/services/prewarm/assets/asset-api-client.d.ts +6 -0
- package/dist/services/prewarm/assets/asset-api-client.js +6 -1
- package/dist/services/prewarm/pre-warm-service.d.ts +10 -0
- package/dist/services/prewarm/pre-warm-service.js +17 -0
- package/dist/services/prewarm/spec/pre-warm-service.spec.d.ts +1 -0
- package/dist/services/prewarm/spec/pre-warm-service.spec.js +72 -0
- package/dist/services/query-builder/query-builder-factory.js +3 -3
- package/dist/services/setup/os/tool-registry.d.ts +1 -1
- package/oclif.manifest.json +162 -23
- package/package.json +1 -2
- package/dist/commands/diff-url-parameters.d.ts +0 -19
- package/dist/commands/diff-url-parameters.js +0 -121
- package/dist/services/bundler/error/packjockel-error.d.ts +0 -3
- package/dist/services/bundler/error/packjockel-error.js +0 -3
- package/dist/services/bundler/packjockel-service.d.ts +0 -72
- package/dist/services/bundler/packjockel-service.js +0 -156
- package/dist/services/bundler/spec/packjockel-service.spec.js +0 -143
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.d.ts +0 -15
- package/dist/services/deploy/checks/post-deploy/deprecated-deployment-detection-check.js +0 -70
- package/dist/services/deploy/error/check-module-file-error.d.ts +0 -4
- package/dist/services/deploy/error/check-module-file-error.js +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.d.ts +0 -4
- package/dist/services/deploy/error/post-deploy-deployment-detection-error.js +0 -4
- package/dist/services/onboarding/server-config/index.d.ts +0 -10
- package/dist/services/onboarding/server-config/index.js +0 -27
- package/dist/services/onboarding/virtual-orestes-app/crawler.d.ts +0 -31
- package/dist/services/onboarding/virtual-orestes-app/crawler.js +0 -98
- /package/dist/{services/bundler/spec/packjockel-service.spec.d.ts → helpers/spec/race.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/spec/virtual-orestes-app/crawler.spec.d.ts → deploy/spec/deploy-service.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/spec/virtual-orestes-app/origin-error-cause.spec.d.ts → deploy/spec/handler/install-resource-handler.spec.d.ts} +0 -0
- /package/dist/services/{onboarding/virtual-orestes-app → origin-request}/origin-error-cause.d.ts +0 -0
- /package/dist/services/{onboarding/virtual-orestes-app → origin-request}/origin-error-cause.js +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdtemp } from "node:fs/promises";
|
|
1
|
+
import { rmSync } from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import puppeteer from "puppeteer";
|
|
5
4
|
import { chromeProxyFlag, currentOriginProxy, } from "../../helpers/origin-proxy.js";
|
|
@@ -493,31 +492,9 @@ export class BrowserOriginFetcher {
|
|
|
493
492
|
this.logger?.comment(`[browserFetch]: headless Chrome ${this.browserVersion} ready${proxy ? ` via ${chromeProxyFlag(proxy)}` : ""}`);
|
|
494
493
|
return browser;
|
|
495
494
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Creates this browser's own profile directory, pruning anything a crashed run left behind.
|
|
498
|
-
*
|
|
499
|
-
* Pruning is by age rather than by wiping the parent: two `sk onboarding` sessions can run at
|
|
500
|
-
* once, and one must not delete the profile the other is holding open.
|
|
501
|
-
*/
|
|
495
|
+
/** Creates this browser's own profile directory, pruning anything a crashed run left behind. */
|
|
502
496
|
async createProfile() {
|
|
503
|
-
|
|
504
|
-
mkdirSync(parent, { recursive: true });
|
|
505
|
-
this.pruneProfiles(parent);
|
|
506
|
-
return mkdtemp(path.join(parent, "profile-"));
|
|
507
|
-
}
|
|
508
|
-
pruneProfiles(parent) {
|
|
509
|
-
const stale = safe(() => readdirSync(parent));
|
|
510
|
-
if (stale.success !== true)
|
|
511
|
-
return;
|
|
512
|
-
for (const entry of stale.data) {
|
|
513
|
-
const candidate = path.join(parent, entry);
|
|
514
|
-
const stats = safe(() => statSync(candidate));
|
|
515
|
-
if (stats.success !== true)
|
|
516
|
-
continue;
|
|
517
|
-
if (Date.now() - stats.data.mtimeMs < PROFILE_MAX_AGE_MS)
|
|
518
|
-
continue;
|
|
519
|
-
rmSync(candidate, { force: true, recursive: true });
|
|
520
|
-
}
|
|
497
|
+
return this.environment.createTempDirectory(PROFILE_FOLDER, PROFILE_MAX_AGE_MS);
|
|
521
498
|
}
|
|
522
499
|
warnOnce(key, message) {
|
|
523
500
|
if (this.warned.has(key))
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BundleService } from "./bundle-service.js";
|
|
2
2
|
export declare class BundleServiceFactory {
|
|
3
3
|
private customerFolder?;
|
|
4
|
-
/**
|
|
5
|
-
* @param customerFolder the directory bundled code resolves its own imports from
|
|
6
|
-
*/
|
|
7
4
|
constructor(customerFolder?: string);
|
|
8
5
|
buildService(): BundleService;
|
|
9
6
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { BundleService } from "./bundle-service.js";
|
|
2
|
-
import { PackjockelService } from "./packjockel-service.js";
|
|
3
2
|
export class BundleServiceFactory {
|
|
4
3
|
customerFolder;
|
|
5
|
-
/**
|
|
6
|
-
* @param customerFolder the directory bundled code resolves its own imports from
|
|
7
|
-
*/
|
|
8
4
|
constructor(customerFolder) {
|
|
9
5
|
this.customerFolder = customerFolder;
|
|
10
6
|
}
|
|
11
7
|
buildService() {
|
|
12
|
-
return new BundleService(this.customerFolder
|
|
8
|
+
return new BundleService(this.customerFolder);
|
|
13
9
|
}
|
|
14
10
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PluginBuild, LogLevel } from "esbuild";
|
|
2
|
-
import type { PackjockelService } from "./packjockel-service.js";
|
|
3
2
|
export type BundleEntryPoints = Record<string, string>;
|
|
4
3
|
export type BundleBasePaths = Record<string, string>;
|
|
5
4
|
/**
|
|
@@ -9,18 +8,10 @@ export type BundleBasePaths = Record<string, string>;
|
|
|
9
8
|
export type BundleResolveFallback = (specifier: string) => Promise<string | null>;
|
|
10
9
|
export declare class BundleService {
|
|
11
10
|
private moduleDiscoveryDir;
|
|
12
|
-
private readonly packjockelService?;
|
|
13
11
|
/**
|
|
14
12
|
* @param moduleDiscoveryDir the directory bundled code resolves its own imports from
|
|
15
|
-
* @param packjockelService bundles instead of esbuild for customers with the `enableSpeedKitConfigPlugins` feature
|
|
16
13
|
*/
|
|
17
|
-
constructor(moduleDiscoveryDir: string
|
|
18
|
-
/**
|
|
19
|
-
* The packjockel bundler for customers with the `enableSpeedKitConfigPlugins` feature.
|
|
20
|
-
*
|
|
21
|
-
* @throws ApplicationError when the service was built without one
|
|
22
|
-
*/
|
|
23
|
-
get packjockel(): PackjockelService;
|
|
14
|
+
constructor(moduleDiscoveryDir: string);
|
|
24
15
|
bundle({ entryPoints, basePaths, define, target, minify, logLevel, alias, platform, resolveFallback, packages, }: {
|
|
25
16
|
entryPoints: BundleEntryPoints;
|
|
26
17
|
basePaths?: BundleBasePaths;
|
|
@@ -4,31 +4,16 @@ import { URL } from "node:url";
|
|
|
4
4
|
import { BundleResolveError } from "./error/bundle-resolve-error.js";
|
|
5
5
|
import { BundleFetchError } from "./error/bundle-fetch-error.js";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
|
-
import ApplicationError from "../error-handling/error/application-error.js";
|
|
8
7
|
const FALLBACK_NAMESPACE = "bundle-resolve-fallback";
|
|
9
8
|
const RELATIVE_SPECIFIER = /^\.{1,2}\//;
|
|
10
9
|
const importCache = {};
|
|
11
10
|
export class BundleService {
|
|
12
11
|
moduleDiscoveryDir;
|
|
13
|
-
packjockelService;
|
|
14
12
|
/**
|
|
15
13
|
* @param moduleDiscoveryDir the directory bundled code resolves its own imports from
|
|
16
|
-
* @param packjockelService bundles instead of esbuild for customers with the `enableSpeedKitConfigPlugins` feature
|
|
17
14
|
*/
|
|
18
|
-
constructor(moduleDiscoveryDir
|
|
15
|
+
constructor(moduleDiscoveryDir) {
|
|
19
16
|
this.moduleDiscoveryDir = moduleDiscoveryDir;
|
|
20
|
-
this.packjockelService = packjockelService;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The packjockel bundler for customers with the `enableSpeedKitConfigPlugins` feature.
|
|
24
|
-
*
|
|
25
|
-
* @throws ApplicationError when the service was built without one
|
|
26
|
-
*/
|
|
27
|
-
get packjockel() {
|
|
28
|
-
if (!this.packjockelService) {
|
|
29
|
-
throw new ApplicationError("This bundler has no packjockel");
|
|
30
|
-
}
|
|
31
|
-
return this.packjockelService;
|
|
32
17
|
}
|
|
33
18
|
async bundle({ entryPoints, basePaths, define, target = "es5", minify = true, logLevel = "silent", alias = {}, platform, resolveFallback, packages = "bundle", }) {
|
|
34
19
|
const plugins = [];
|
|
@@ -48,6 +48,17 @@ export declare class CliEnvironment {
|
|
|
48
48
|
attachCli(cli: CliServiceInterface): this;
|
|
49
49
|
/** The directory the CLI keeps its caches and scratch files in. */
|
|
50
50
|
get cacheDir(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a fresh scratch directory, `<cacheDir>/<folder>/<random>`.
|
|
53
|
+
*
|
|
54
|
+
* A scratch directory is not removed when the command ends: a diff tool or
|
|
55
|
+
* a browser may still hold it open. Instead, each new one removes the
|
|
56
|
+
* directories of the same folder older than `maxAgeMs`. That is by age
|
|
57
|
+
* rather than by wiping the folder, because two runs of the CLI can share
|
|
58
|
+
* it, and one must not delete what the other is using.
|
|
59
|
+
*/
|
|
60
|
+
createTempDirectory(folder: string, maxAgeMs?: number): string;
|
|
61
|
+
private pruneTempDirectories;
|
|
51
62
|
/**
|
|
52
63
|
* Whether this runs in CI. Most CI providers set `CI=true`, and several set
|
|
53
64
|
* their own dedicated variable, so both are checked.
|
|
@@ -18,6 +18,8 @@ const environmentMapping = {
|
|
|
18
18
|
testApp: "TEST_APP",
|
|
19
19
|
};
|
|
20
20
|
const CONFIG_FILE_NAME = "config.json";
|
|
21
|
+
/** How long a scratch directory is kept before a later run removes it. */
|
|
22
|
+
const TEMP_DIRECTORY_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
21
23
|
/** Variables CI providers set besides `CI`. */
|
|
22
24
|
const CI_MARKERS = [
|
|
23
25
|
"CONTINUOUS_INTEGRATION",
|
|
@@ -98,6 +100,41 @@ export class CliEnvironment {
|
|
|
98
100
|
get cacheDir() {
|
|
99
101
|
return this.oclif.cacheDir;
|
|
100
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates a fresh scratch directory, `<cacheDir>/<folder>/<random>`.
|
|
105
|
+
*
|
|
106
|
+
* A scratch directory is not removed when the command ends: a diff tool or
|
|
107
|
+
* a browser may still hold it open. Instead, each new one removes the
|
|
108
|
+
* directories of the same folder older than `maxAgeMs`. That is by age
|
|
109
|
+
* rather than by wiping the folder, because two runs of the CLI can share
|
|
110
|
+
* it, and one must not delete what the other is using.
|
|
111
|
+
*/
|
|
112
|
+
createTempDirectory(folder, maxAgeMs = TEMP_DIRECTORY_MAX_AGE_MS) {
|
|
113
|
+
const parent = path.resolve(this.cacheDir, folder);
|
|
114
|
+
fs.mkdirSync(parent, { recursive: true });
|
|
115
|
+
this.pruneTempDirectories(parent, maxAgeMs);
|
|
116
|
+
return fs.mkdtempSync(path.join(parent, "run-"));
|
|
117
|
+
}
|
|
118
|
+
pruneTempDirectories(parent, maxAgeMs) {
|
|
119
|
+
let entries;
|
|
120
|
+
try {
|
|
121
|
+
entries = fs.readdirSync(parent);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
const candidate = path.join(parent, entry);
|
|
128
|
+
try {
|
|
129
|
+
if (Date.now() - fs.statSync(candidate).mtimeMs < maxAgeMs)
|
|
130
|
+
continue;
|
|
131
|
+
fs.rmSync(candidate, { force: true, recursive: true });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Gone already, or held by another process: the next run tries again.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
101
138
|
/**
|
|
102
139
|
* Whether this runs in CI. Most CI providers set `CI=true`, and several set
|
|
103
140
|
* their own dedicated variable, so both are checked.
|
|
@@ -40,7 +40,9 @@ export interface CliServiceInterface {
|
|
|
40
40
|
value: T;
|
|
41
41
|
checked?: boolean;
|
|
42
42
|
description?: string;
|
|
43
|
-
}[]
|
|
43
|
+
}[],
|
|
44
|
+
/** Answers `true` for a choice to accept, or the message to ask again with. */
|
|
45
|
+
validate?: (chosen: T[]) => true | string): Promise<T[]>;
|
|
44
46
|
/** Put text on the system clipboard; resolves to whether it arrived. */
|
|
45
47
|
copyToClipboard(text: string): Promise<boolean>;
|
|
46
48
|
/** Machine-readable payload, verbatim, to the data channel. */
|
|
@@ -49,7 +49,7 @@ export declare class CliService implements CliServiceInterface {
|
|
|
49
49
|
value: T;
|
|
50
50
|
checked?: boolean;
|
|
51
51
|
description?: string;
|
|
52
|
-
}[]): Promise<T[]>;
|
|
52
|
+
}[], validate?: (chosen: T[]) => true | string): Promise<T[]>;
|
|
53
53
|
/**
|
|
54
54
|
* Put text on the system clipboard.
|
|
55
55
|
*
|
|
@@ -137,13 +137,16 @@ export class CliService {
|
|
|
137
137
|
message: this.getFormattedMessage(message),
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
async multiSelect(message, choices) {
|
|
140
|
+
async multiSelect(message, choices, validate) {
|
|
141
141
|
if (this.quiet) {
|
|
142
142
|
return choices.filter((c) => c.checked).map((c) => c.value);
|
|
143
143
|
}
|
|
144
144
|
return checkbox({
|
|
145
145
|
choices,
|
|
146
146
|
message: this.getFormattedMessage(message),
|
|
147
|
+
validate: validate
|
|
148
|
+
? (chosen) => validate(chosen.map((choice) => choice.value))
|
|
149
|
+
: undefined,
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { describe, beforeEach, afterEach, it } from "mocha";
|
|
3
|
-
import { mkdtempSync, rmSync, readFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, readFileSync, utimesSync, } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { CliEnvironment } from "../cli-environment.js";
|
|
@@ -123,3 +123,32 @@ describe("CliEnvironment settings save/load", () => {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
|
+
describe("CliEnvironment.createTempDirectory", () => {
|
|
127
|
+
let dir;
|
|
128
|
+
beforeEach(() => {
|
|
129
|
+
dir = mkdtempSync(path.join(tmpdir(), "sk-cli-environment-"));
|
|
130
|
+
});
|
|
131
|
+
afterEach(() => {
|
|
132
|
+
rmSync(dir, { recursive: true, force: true });
|
|
133
|
+
});
|
|
134
|
+
it("creates a fresh directory in its folder under the cache directory", () => {
|
|
135
|
+
const environment = CliEnvironment.load(fakeOclifConfig(dir));
|
|
136
|
+
const first = environment.createTempDirectory("diff");
|
|
137
|
+
const second = environment.createTempDirectory("diff");
|
|
138
|
+
expect(path.dirname(first)).to.equal(path.join(dir, "diff"));
|
|
139
|
+
expect(first).to.not.equal(second);
|
|
140
|
+
expect(existsSync(first)).to.equal(true);
|
|
141
|
+
});
|
|
142
|
+
it("removes the directories of its folder that are older than the limit", () => {
|
|
143
|
+
const environment = CliEnvironment.load(fakeOclifConfig(dir));
|
|
144
|
+
const stale = path.join(dir, "diff", "run-stale");
|
|
145
|
+
const fresh = path.join(dir, "diff", "run-fresh");
|
|
146
|
+
mkdirSync(stale, { recursive: true });
|
|
147
|
+
mkdirSync(fresh, { recursive: true });
|
|
148
|
+
const twoDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000);
|
|
149
|
+
utimesSync(stale, twoDaysAgo, twoDaysAgo);
|
|
150
|
+
environment.createTempDirectory("diff");
|
|
151
|
+
expect(existsSync(stale)).to.equal(false);
|
|
152
|
+
expect(existsSync(fresh)).to.equal(true);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -50,7 +50,7 @@ export class CustomerApprovalCheck {
|
|
|
50
50
|
const configFile = await VirtualSpeedKitConfigFile.createRemote(speedKitConfig, this.bundler);
|
|
51
51
|
const splits = [];
|
|
52
52
|
for (const origin of this.customer.origins) {
|
|
53
|
-
const result = await safe(configFile.evaluate(this.customer, origin));
|
|
53
|
+
const result = await safe(configFile.evaluate(this.customer.app, origin));
|
|
54
54
|
if (result.success === false) {
|
|
55
55
|
// An unreadable config is not proof that the split is 0, so keep the
|
|
56
56
|
// approval question rather than skipping it.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EntityManager } from "baqend";
|
|
2
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
2
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
3
3
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
4
4
|
export declare class RefreshDeploymentJobCheck implements PostDeployCheckInterface {
|
|
5
5
|
private entityManager;
|
|
6
6
|
private cli;
|
|
7
7
|
constructor(entityManager: EntityManager, cli: CliServiceInterface);
|
|
8
|
-
check(): Promise<
|
|
8
|
+
check(): Promise<PostDeployCheckResult>;
|
|
9
9
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ApplicationError from "../../../error-handling/error/application-error.js";
|
|
2
1
|
export class RefreshDeploymentJobCheck {
|
|
3
2
|
entityManager;
|
|
4
3
|
cli;
|
|
@@ -21,12 +20,14 @@ export class RefreshDeploymentJobCheck {
|
|
|
21
20
|
this.cli.writeWarning(" Deployment jobs are missing. These are normally created on first deployment run.");
|
|
22
21
|
}
|
|
23
22
|
if (missingRequiredJobs.length > 0) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
" ",
|
|
29
|
-
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
error: `Missing required jobs: ${missingRequiredJobs.join(", ")}`,
|
|
26
|
+
suggestions: [
|
|
27
|
+
"To create missing jobs, follow the steps here: https://www.notion.so/baqend/How-to-create-missing-Jobs-306de49f8a9980f397c2ebe693da4aac?v=fcdbfc994dca4aa6be42228b37609d48&source=copy_link",
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
30
|
}
|
|
31
|
+
return { success: true };
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
2
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
2
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
3
3
|
import { ConfigApiService } from "../../../config-api/index.js";
|
|
4
4
|
export default class RevalidatedModuleCheck implements PostDeployCheckInterface {
|
|
5
5
|
private readonly configApi;
|
|
6
6
|
private cli;
|
|
7
7
|
private readonly app;
|
|
8
8
|
constructor(configApi: ConfigApiService, cli: CliServiceInterface, app: string);
|
|
9
|
-
check(): Promise<
|
|
9
|
+
check(): Promise<PostDeployCheckResult>;
|
|
10
10
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { safe } from "../../../../helpers/safe.js";
|
|
2
2
|
import { DeployModuleFileError } from "../../error/deploy-module-file-error.js";
|
|
3
|
-
import { CheckModuleFileError } from "../../error/check-module-file-error.js";
|
|
4
3
|
const REVALIDATED_MODULE_NAME = "speedKit.Revalidated";
|
|
5
4
|
export default class RevalidatedModuleCheck {
|
|
6
5
|
configApi;
|
|
@@ -14,14 +13,19 @@ export default class RevalidatedModuleCheck {
|
|
|
14
13
|
async check() {
|
|
15
14
|
this.cli.startAction("POST:CHECK:REVALIDATED_MODULE", "[postDeployCheck] check for revalidated module");
|
|
16
15
|
const result = await safe(this.configApi.getModule(REVALIDATED_MODULE_NAME));
|
|
17
|
-
if (result.success === true && result.data) {
|
|
18
|
-
this.cli.successAction("POST:CHECK:REVALIDATED_MODULE");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
22
16
|
if (result.success === false) {
|
|
17
|
+
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
23
18
|
throw new DeployModuleFileError(result.error);
|
|
24
19
|
}
|
|
25
|
-
|
|
20
|
+
if (result.data) {
|
|
21
|
+
this.cli.successAction("POST:CHECK:REVALIDATED_MODULE");
|
|
22
|
+
return { success: true };
|
|
23
|
+
}
|
|
24
|
+
this.cli.failAction("POST:CHECK:REVALIDATED_MODULE");
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
error: `${REVALIDATED_MODULE_NAME} does not exist in the app ${this.app}`,
|
|
28
|
+
suggestions: [`sk generate-pop-config ${this.app}`],
|
|
29
|
+
};
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../../../cli/index.js";
|
|
2
2
|
import { FileListInterface, InstallResourceFile } from "../../../integration-api/index.js";
|
|
3
|
-
import { PostDeployCheckInterface } from "../../deploy-service-model.js";
|
|
3
|
+
import { PostDeployCheckInterface, PostDeployCheckResult } from "../../deploy-service-model.js";
|
|
4
4
|
import { DeployPolicyInterface } from "../../policy/index.js";
|
|
5
5
|
export default class SaveFilesCheck implements PostDeployCheckInterface {
|
|
6
6
|
private policy;
|
|
7
7
|
private fileList;
|
|
8
8
|
private readonly cli;
|
|
9
9
|
constructor(fileList: FileListInterface, cli: CliServiceInterface, policy: DeployPolicyInterface);
|
|
10
|
-
check(): Promise<
|
|
10
|
+
check(): Promise<PostDeployCheckResult>;
|
|
11
11
|
safeFiles(fileList: InstallResourceFile[]): Promise<void>;
|
|
12
12
|
}
|
|
@@ -15,10 +15,10 @@ export default class SaveFilesCheck {
|
|
|
15
15
|
return file.isUpdated();
|
|
16
16
|
});
|
|
17
17
|
if (fileList.length === 0) {
|
|
18
|
-
return;
|
|
18
|
+
return { success: true };
|
|
19
19
|
}
|
|
20
20
|
if (!(await this.policy.confirm(DeployQuestion.SaveLocalFiles, `Changes to localFiles will be saved now. Proceed?`))) {
|
|
21
|
-
return;
|
|
21
|
+
return { success: true };
|
|
22
22
|
}
|
|
23
23
|
this.cli.startAction("POST:DEPLOY:SAVE_FILES", "safe changed files");
|
|
24
24
|
const result = await safe(this.safeFiles(fileList));
|
|
@@ -27,6 +27,7 @@ export default class SaveFilesCheck {
|
|
|
27
27
|
throw new SafeFileError(result.error);
|
|
28
28
|
}
|
|
29
29
|
this.cli.successAction("POST:DEPLOY:SAVE_FILES");
|
|
30
|
+
return { success: true };
|
|
30
31
|
}
|
|
31
32
|
async safeFiles(fileList) {
|
|
32
33
|
for (const file of fileList) {
|
|
@@ -61,10 +61,11 @@ export class DeviceDetectionChangedCheck {
|
|
|
61
61
|
}
|
|
62
62
|
async checkForChangedDeviceDetection(speedKitConfigFile, activeSpeedKitConfig) {
|
|
63
63
|
const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
|
|
64
|
+
const app = this.customerConfig.app;
|
|
64
65
|
const origin = this.customerConfig.origins[0];
|
|
65
66
|
const changes = [];
|
|
66
|
-
const localSpeedKit = await speedKitConfigFile.evaluate(
|
|
67
|
-
const remoteSpeedKit = await remoteConfigFile.evaluate(
|
|
67
|
+
const localSpeedKit = await speedKitConfigFile.evaluate(app, origin);
|
|
68
|
+
const remoteSpeedKit = await remoteConfigFile.evaluate(app, origin);
|
|
68
69
|
if ((localSpeedKit.detectDevice && !remoteSpeedKit.detectDevice) ||
|
|
69
70
|
(!localSpeedKit.detectDevice && remoteSpeedKit.detectDevice)) {
|
|
70
71
|
changes.push("detectDevice");
|
|
@@ -63,10 +63,11 @@ export class SplitChangeCheck {
|
|
|
63
63
|
}
|
|
64
64
|
async checkSplitsForEachOrigin(speedKitConfigFile, activeSpeedKitConfig) {
|
|
65
65
|
const remoteConfigFile = await VirtualSpeedKitConfigFile.createRemote(activeSpeedKitConfig, this.bundler);
|
|
66
|
+
const app = this.customerConfig.app;
|
|
66
67
|
const changes = [];
|
|
67
68
|
for (const origin of this.customerConfig.origins) {
|
|
68
|
-
const localSpeedKit = await speedKitConfigFile.evaluate(
|
|
69
|
-
const remoteSpeedKit = await remoteConfigFile.evaluate(
|
|
69
|
+
const localSpeedKit = await speedKitConfigFile.evaluate(app, origin);
|
|
70
|
+
const remoteSpeedKit = await remoteConfigFile.evaluate(app, origin);
|
|
70
71
|
// check for split change
|
|
71
72
|
if (localSpeedKit.split !== remoteSpeedKit.split) {
|
|
72
73
|
changes.push({
|
|
@@ -11,6 +11,7 @@ declare const flags: {
|
|
|
11
11
|
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
12
12
|
artifacts: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
13
13
|
mr: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
14
|
+
testing: Interfaces.BooleanFlag<boolean>;
|
|
14
15
|
description: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
15
16
|
approval: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
16
17
|
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
@@ -57,6 +58,7 @@ export declare class DeployServiceBuildContext extends DeployServiceBuildContext
|
|
|
57
58
|
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
58
59
|
artifacts: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
59
60
|
mr: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
61
|
+
testing: Interfaces.BooleanFlag<boolean>;
|
|
60
62
|
description: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
61
63
|
approval: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
62
64
|
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
@@ -26,9 +26,13 @@ const flags = {
|
|
|
26
26
|
mr: Flags.integer({
|
|
27
27
|
description: "deploy the reviewed change of this merged merge request, without questions",
|
|
28
28
|
}),
|
|
29
|
+
testing: Flags.boolean({
|
|
30
|
+
exclusive: ["mr", "dryRun"],
|
|
31
|
+
description: "deploy the local config as a testing installation only, without questions. It never activates for real users, and it leaves the modules and the server config alone",
|
|
32
|
+
}),
|
|
29
33
|
description: Flags.string({
|
|
30
|
-
|
|
31
|
-
description: "the description every installation of the run gets
|
|
34
|
+
relationships: [{ type: "some", flags: ["mr", "testing"] }],
|
|
35
|
+
description: "the description every installation of the run gets. With --mr it is asked while it is left out",
|
|
32
36
|
}),
|
|
33
37
|
approval: Flags.string({
|
|
34
38
|
options: ["approved", "testing", "skip"],
|
|
@@ -51,6 +55,13 @@ export class DeployServiceBuildContext extends Context() {
|
|
|
51
55
|
: [],
|
|
52
56
|
dryRun: parsedFlags.dryRun,
|
|
53
57
|
useTestConfig: parsedFlags.useTestConfig,
|
|
58
|
+
// A testing deploy runs without a person and touches the installation only.
|
|
59
|
+
...(parsedFlags.testing && {
|
|
60
|
+
installFilesOnly: true,
|
|
61
|
+
skipPostDeployChecks: true,
|
|
62
|
+
opensDiffTool: false,
|
|
63
|
+
promptForLogin: false,
|
|
64
|
+
}),
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
/** A production config gets the checks a change to live traffic needs. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDiffEngine } from "../diff/index.js";
|
|
2
2
|
import InstallResourceBuilder from "./builder/install-resource-builder.js";
|
|
3
3
|
import RevalidatedModuleCheck from "./checks/post-deploy/revalidated-module-check.js";
|
|
4
4
|
import SaveFilesCheck from "./checks/post-deploy/save-files-check.js";
|
|
@@ -11,7 +11,6 @@ import ServerConfigHandler from "./handler/server-config-handler.js";
|
|
|
11
11
|
import { IntegrationApiFactory, IntegrationApiServiceBuildContext, FILE_TYPE, DEFAULT_BLOCKED_FOLDERS, } from "../integration-api/index.js";
|
|
12
12
|
import { SplitChangeCheck } from "./checks/pre-deploy/split-change-check.js";
|
|
13
13
|
import { ConfigApiContext, ConfigApiServiceFactory, } from "../config-api/index.js";
|
|
14
|
-
import { DeprecatedDeploymentDetectionCheck } from "./checks/post-deploy/deprecated-deployment-detection-check.js";
|
|
15
14
|
import { DeviceDetectionChangedCheck } from "./checks/pre-deploy/device-detection-changed-check.js";
|
|
16
15
|
import { RefreshDeploymentJobCheck } from "./checks/post-deploy/refresh-deployment-job-check.js";
|
|
17
16
|
import { CustomerApprovalCheck } from "./checks/activation/customer-approval-check.js";
|
|
@@ -52,12 +51,7 @@ export default class DeployServiceFactory {
|
|
|
52
51
|
this.files = files;
|
|
53
52
|
this.configName = configName;
|
|
54
53
|
this.configApi = configApi;
|
|
55
|
-
const diffService =
|
|
56
|
-
environment: this.context.environment,
|
|
57
|
-
executablePath: this.context.environment.settings.diffExec,
|
|
58
|
-
executableTemplate: this.context.environment.settings.diffExecTemplate,
|
|
59
|
-
opensDiffTool: this.context.opensDiffTool ?? true,
|
|
60
|
-
})).getService();
|
|
54
|
+
const diffService = createDiffEngine(this.context.environment, (this.context.opensDiffTool ?? true) ? "tool" : "none");
|
|
61
55
|
const policy = this.policyOverride ?? new InteractiveDeployPolicy(cliService);
|
|
62
56
|
const installResourceBuilder = new InstallResourceBuilder(configApi);
|
|
63
57
|
const bundler = new BundleServiceFactory("./").buildService();
|
|
@@ -99,7 +93,6 @@ export default class DeployServiceFactory {
|
|
|
99
93
|
return [
|
|
100
94
|
new SaveFilesCheck(files, cliService, policy),
|
|
101
95
|
new RevalidatedModuleCheck(configApi, cliService, app),
|
|
102
|
-
new DeprecatedDeploymentDetectionCheck(files, cliService, configApi, app, policy),
|
|
103
96
|
new RefreshDeploymentJobCheck(await configApi.client.getEntityManager(), cliService),
|
|
104
97
|
];
|
|
105
98
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a post-deploy check found. The deploy is already uploaded when the checks
|
|
3
|
+
* run, so a finding is reported rather than thrown; a check throws only when it
|
|
4
|
+
* could not do its job.
|
|
5
|
+
*/
|
|
6
|
+
export interface PostDeployCheckResult {
|
|
7
|
+
readonly success: boolean;
|
|
8
|
+
readonly error?: string;
|
|
9
|
+
readonly suggestions?: string[];
|
|
10
|
+
}
|
|
1
11
|
export interface PostDeployCheckInterface {
|
|
2
|
-
check(): Promise<
|
|
12
|
+
check(): Promise<PostDeployCheckResult>;
|
|
3
13
|
}
|
|
4
14
|
export interface PreDeployCheckInterface {
|
|
5
15
|
check(): Promise<void>;
|
|
@@ -15,5 +15,7 @@ export default class DeployService {
|
|
|
15
15
|
private uploadType;
|
|
16
16
|
private runPreDeployChecks;
|
|
17
17
|
private runPostDeployChecks;
|
|
18
|
+
/** Lays a result out the way oclif prints an error: message, then suggestions. */
|
|
19
|
+
private reportFailedPostDeployChecks;
|
|
18
20
|
private filterFilesToProcess;
|
|
19
21
|
}
|
|
@@ -55,9 +55,34 @@ export default class DeployService {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async runPostDeployChecks() {
|
|
58
|
+
const failed = [];
|
|
58
59
|
for (const postDeployCheck of this.postDeployChecks) {
|
|
59
|
-
await postDeployCheck.check();
|
|
60
|
+
const result = await postDeployCheck.check();
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
failed.push(result);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.reportFailedPostDeployChecks(failed);
|
|
66
|
+
}
|
|
67
|
+
/** Lays a result out the way oclif prints an error: message, then suggestions. */
|
|
68
|
+
reportFailedPostDeployChecks(failed) {
|
|
69
|
+
if (failed.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.cli.spacer();
|
|
73
|
+
this.cli.writeWarning(`${failed.length} post-deploy check(s) failed:`);
|
|
74
|
+
for (const { error, suggestions = [] } of failed) {
|
|
75
|
+
const lines = [`› ${error}`];
|
|
76
|
+
if (suggestions.length === 1) {
|
|
77
|
+
lines.push(` Try this: ${suggestions[0]}`);
|
|
78
|
+
}
|
|
79
|
+
else if (suggestions.length > 1) {
|
|
80
|
+
lines.push(" Try this:", ...suggestions.map((s) => ` * ${s}`));
|
|
81
|
+
}
|
|
82
|
+
this.cli.spacer();
|
|
83
|
+
this.cli.writeWarning(lines.join("\n"));
|
|
60
84
|
}
|
|
85
|
+
this.cli.spacer();
|
|
61
86
|
}
|
|
62
87
|
filterFilesToProcess() {
|
|
63
88
|
this.fileList.filter((file) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DeployHandlerInterface from "../interface/deploy-handler-interface.js";
|
|
2
2
|
import { CustomerConfig, CustomerConfigFile, FILE_TYPE } from "../../integration-api/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DiffEngine } from "../../diff/index.js";
|
|
4
4
|
import { CliServiceInterface } from "../../cli/index.js";
|
|
5
5
|
import InstallResourceBuilder from "../builder/install-resource-builder.js";
|
|
6
6
|
import { ConfigApiService } from "../../config-api/index.js";
|
|
@@ -13,7 +13,7 @@ export default class CustomerConfigHandler implements DeployHandlerInterface {
|
|
|
13
13
|
private cli;
|
|
14
14
|
private builder;
|
|
15
15
|
private policy;
|
|
16
|
-
constructor(customer: CustomerConfig, configApi: ConfigApiService, configName: string, diffService:
|
|
16
|
+
constructor(customer: CustomerConfig, configApi: ConfigApiService, configName: string, diffService: DiffEngine, cli: CliServiceInterface, builder: InstallResourceBuilder, policy: DeployPolicyInterface);
|
|
17
17
|
canHandle(type: FILE_TYPE): boolean;
|
|
18
18
|
handle(files: CustomerConfigFile[]): Promise<void>;
|
|
19
19
|
upload(files: CustomerConfigFile[]): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DeployHandlerInterface from "../interface/deploy-handler-interface.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DiffEngine } from "../../diff/index.js";
|
|
3
3
|
import { CliServiceInterface } from "../../cli/index.js";
|
|
4
4
|
import InstallResourceBuilder from "../builder/install-resource-builder.js";
|
|
5
5
|
import DeletedFileCheck from "./install-resource-modifier/deleted-file-check.js";
|
|
@@ -17,7 +17,7 @@ export default class InstallResourceHandler implements DeployHandlerInterface {
|
|
|
17
17
|
private deletedFilesChecker;
|
|
18
18
|
private customerApprovalCheck;
|
|
19
19
|
private policy;
|
|
20
|
-
constructor(customer: CustomerConfig, configApi: ConfigApiService, configName: string, diffService:
|
|
20
|
+
constructor(customer: CustomerConfig, configApi: ConfigApiService, configName: string, diffService: DiffEngine, cli: CliServiceInterface, builder: InstallResourceBuilder, deletedFilesChecker: DeletedFileCheck, customerApprovalCheck: CustomerApprovalCheck, policy: DeployPolicyInterface);
|
|
21
21
|
canHandle(type: FILE_TYPE): boolean;
|
|
22
22
|
handle(files: InstallResourceInterface[]): Promise<void>;
|
|
23
23
|
upload(files: InstallResourceInterface[]): Promise<void>;
|