@simplysf/simply-cicd 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -35
- package/lib/commands/simply/cicd/build/check-permission-sets.d.ts +1 -1
- package/lib/commands/simply/cicd/build/check-permission-sets.js +1 -1
- package/lib/commands/simply/cicd/build/check-permission-sets.js.map +1 -1
- package/lib/commands/simply/cicd/build/cleanup-scratch-orgs.js +1 -2
- package/lib/commands/simply/cicd/build/cleanup-scratch-orgs.js.map +1 -1
- package/lib/commands/simply/cicd/build/create-fallback-tag.d.ts +1 -1
- package/lib/commands/simply/cicd/build/create-fallback-tag.js +1 -3
- package/lib/commands/simply/cicd/build/create-fallback-tag.js.map +1 -1
- package/lib/commands/simply/cicd/build/create-package-version.js +1 -3
- package/lib/commands/simply/cicd/build/create-package-version.js.map +1 -1
- package/lib/commands/simply/cicd/build/create-scratch.d.ts +1 -1
- package/lib/commands/simply/cicd/build/create-scratch.js +1 -3
- package/lib/commands/simply/cicd/build/create-scratch.js.map +1 -1
- package/lib/commands/simply/cicd/build/delete-scratch.js +1 -3
- package/lib/commands/simply/cicd/build/delete-scratch.js.map +1 -1
- package/lib/commands/simply/cicd/build/determine-package-changes.js +1 -2
- package/lib/commands/simply/cicd/build/determine-package-changes.js.map +1 -1
- package/lib/commands/simply/cicd/build/generate-flexipage-diff.d.ts +1 -1
- package/lib/commands/simply/cicd/build/generate-flexipage-diff.js +1 -1
- package/lib/commands/simply/cicd/build/generate-flexipage-diff.js.map +1 -1
- package/lib/commands/simply/cicd/build/generate-flow-diff.d.ts +1 -1
- package/lib/commands/simply/cicd/build/generate-flow-diff.js +1 -1
- package/lib/commands/simply/cicd/build/generate-flow-diff.js.map +1 -1
- package/lib/commands/simply/cicd/build/install-dependencies.js +1 -3
- package/lib/commands/simply/cicd/build/install-dependencies.js.map +1 -1
- package/lib/commands/simply/cicd/build/lwc-jest.d.ts +1 -1
- package/lib/commands/simply/cicd/build/lwc-jest.js +1 -1
- package/lib/commands/simply/cicd/build/lwc-jest.js.map +1 -1
- package/lib/commands/simply/cicd/build/publish-utam-page-objects.d.ts +1 -1
- package/lib/commands/simply/cicd/build/publish-utam-page-objects.js +1 -1
- package/lib/commands/simply/cicd/build/publish-utam-page-objects.js.map +1 -1
- package/lib/commands/simply/cicd/build/push-scratch.js +1 -3
- package/lib/commands/simply/cicd/build/push-scratch.js.map +1 -1
- package/lib/commands/simply/cicd/build/test-scratch.js +1 -3
- package/lib/commands/simply/cicd/build/test-scratch.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/deploy-unpackaged.js +2 -2
- package/lib/commands/simply/cicd/deploy/happy-soup/deploy-unpackaged.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/deployment-close-out.js +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/deployment-close-out.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/install-packaged.js +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/install-packaged.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/post-deploy.js +2 -2
- package/lib/commands/simply/cicd/deploy/happy-soup/post-deploy.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/post-destructive.js +2 -2
- package/lib/commands/simply/cicd/deploy/happy-soup/post-destructive.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/pre-destructive.js +2 -2
- package/lib/commands/simply/cicd/deploy/happy-soup/pre-destructive.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/tag-deployment.js +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/tag-deployment.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/validate.js +1 -1
- package/lib/commands/simply/cicd/deploy/happy-soup/validate.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/deploy-unpackaged.js +2 -2
- package/lib/commands/simply/cicd/deploy/project/deploy-unpackaged.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/install-packaged.js +1 -1
- package/lib/commands/simply/cicd/deploy/project/install-packaged.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/post-deploy.js +2 -2
- package/lib/commands/simply/cicd/deploy/project/post-deploy.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/post-destructive.js +2 -2
- package/lib/commands/simply/cicd/deploy/project/post-destructive.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/pre-destructive.js +2 -2
- package/lib/commands/simply/cicd/deploy/project/pre-destructive.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/run-apex-tests.js +1 -1
- package/lib/commands/simply/cicd/deploy/project/run-apex-tests.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/project/validate.js +1 -1
- package/lib/commands/simply/cicd/deploy/project/validate.js.map +1 -1
- package/lib/commands/simply/cicd/deploy/validate.js +1 -1
- package/lib/commands/simply/cicd/deploy/validate.js.map +1 -1
- package/lib/commands/simply/cicd/notify/build.d.ts +2 -3
- package/lib/commands/simply/cicd/notify/build.js +1 -3
- package/lib/commands/simply/cicd/notify/build.js.map +1 -1
- package/lib/commands/simply/cicd/notify/happy-soup.d.ts +2 -3
- package/lib/commands/simply/cicd/notify/happy-soup.js +4 -6
- package/lib/commands/simply/cicd/notify/happy-soup.js.map +1 -1
- package/lib/commands/simply/cicd/notify/project.d.ts +1 -2
- package/lib/commands/simply/cicd/notify/project.js +3 -5
- package/lib/commands/simply/cicd/notify/project.js.map +1 -1
- package/lib/commands/simply/cicd/notify/teams.js +1 -2
- package/lib/commands/simply/cicd/notify/teams.js.map +1 -1
- package/lib/commands/simply/cicd/sfdx-dependabot.d.ts +1 -2
- package/lib/commands/simply/cicd/sfdx-dependabot.js +1 -4
- package/lib/commands/simply/cicd/sfdx-dependabot.js.map +1 -1
- package/lib/common/deploy/stageCommand.d.ts +0 -49
- package/lib/common/deploy/stageCommand.js +0 -54
- package/lib/common/deploy/stageCommand.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -12
- package/lib/common/build/checkPermissionSets.d.ts +0 -22
- package/lib/common/build/checkPermissionSets.js +0 -102
- package/lib/common/build/checkPermissionSets.js.map +0 -1
- package/lib/common/build/cleanupScratchOrgs.d.ts +0 -6
- package/lib/common/build/cleanupScratchOrgs.js +0 -91
- package/lib/common/build/cleanupScratchOrgs.js.map +0 -1
- package/lib/common/build/createFallbackTag.d.ts +0 -24
- package/lib/common/build/createFallbackTag.js +0 -147
- package/lib/common/build/createFallbackTag.js.map +0 -1
- package/lib/common/build/createPackageVersion.d.ts +0 -42
- package/lib/common/build/createPackageVersion.js +0 -198
- package/lib/common/build/createPackageVersion.js.map +0 -1
- package/lib/common/build/createScratchOrg.d.ts +0 -14
- package/lib/common/build/createScratchOrg.js +0 -192
- package/lib/common/build/createScratchOrg.js.map +0 -1
- package/lib/common/build/deleteScratchOrg.d.ts +0 -13
- package/lib/common/build/deleteScratchOrg.js +0 -62
- package/lib/common/build/deleteScratchOrg.js.map +0 -1
- package/lib/common/build/deltaRunner.d.ts +0 -73
- package/lib/common/build/deltaRunner.js +0 -109
- package/lib/common/build/deltaRunner.js.map +0 -1
- package/lib/common/build/determinePackageChanges.d.ts +0 -11
- package/lib/common/build/determinePackageChanges.js +0 -90
- package/lib/common/build/determinePackageChanges.js.map +0 -1
- package/lib/common/build/devHubs.d.ts +0 -12
- package/lib/common/build/devHubs.js +0 -42
- package/lib/common/build/devHubs.js.map +0 -1
- package/lib/common/build/flexipageDelta.d.ts +0 -18
- package/lib/common/build/flexipageDelta.js +0 -35
- package/lib/common/build/flexipageDelta.js.map +0 -1
- package/lib/common/build/flowDelta.d.ts +0 -17
- package/lib/common/build/flowDelta.js +0 -34
- package/lib/common/build/flowDelta.js.map +0 -1
- package/lib/common/build/installDependencies.d.ts +0 -10
- package/lib/common/build/installDependencies.js +0 -39
- package/lib/common/build/installDependencies.js.map +0 -1
- package/lib/common/build/lwcJest.d.ts +0 -25
- package/lib/common/build/lwcJest.js +0 -126
- package/lib/common/build/lwcJest.js.map +0 -1
- package/lib/common/build/publishUtamPageObjects.d.ts +0 -50
- package/lib/common/build/publishUtamPageObjects.js +0 -283
- package/lib/common/build/publishUtamPageObjects.js.map +0 -1
- package/lib/common/build/pushScratch.d.ts +0 -9
- package/lib/common/build/pushScratch.js +0 -60
- package/lib/common/build/pushScratch.js.map +0 -1
- package/lib/common/build/scratchOrgAuth.d.ts +0 -18
- package/lib/common/build/scratchOrgAuth.js +0 -52
- package/lib/common/build/scratchOrgAuth.js.map +0 -1
- package/lib/common/build/scratchOrgInfo.d.ts +0 -14
- package/lib/common/build/scratchOrgInfo.js +0 -21
- package/lib/common/build/scratchOrgInfo.js.map +0 -1
- package/lib/common/build/skipGuard.d.ts +0 -8
- package/lib/common/build/skipGuard.js +0 -42
- package/lib/common/build/skipGuard.js.map +0 -1
- package/lib/common/build/testScratch.d.ts +0 -15
- package/lib/common/build/testScratch.js +0 -42
- package/lib/common/build/testScratch.js.map +0 -1
- package/lib/common/build/utamPageObjects.d.ts +0 -143
- package/lib/common/build/utamPageObjects.js +0 -245
- package/lib/common/build/utamPageObjects.js.map +0 -1
- package/lib/common/build/versionTagFormat.d.ts +0 -57
- package/lib/common/build/versionTagFormat.js +0 -194
- package/lib/common/build/versionTagFormat.js.map +0 -1
- package/lib/common/deploy/deployCommon.d.ts +0 -105
- package/lib/common/deploy/deployCommon.js +0 -358
- package/lib/common/deploy/deployCommon.js.map +0 -1
- package/lib/common/deploy/deployHappySoup.d.ts +0 -56
- package/lib/common/deploy/deployHappySoup.js +0 -160
- package/lib/common/deploy/deployHappySoup.js.map +0 -1
- package/lib/common/deploy/deployProject.d.ts +0 -27
- package/lib/common/deploy/deployProject.js +0 -114
- package/lib/common/deploy/deployProject.js.map +0 -1
- package/lib/common/deploy/runDeployStage.d.ts +0 -16
- package/lib/common/deploy/runDeployStage.js +0 -65
- package/lib/common/deploy/runDeployStage.js.map +0 -1
- package/lib/common/deploy/validate.d.ts +0 -11
- package/lib/common/deploy/validate.js +0 -54
- package/lib/common/deploy/validate.js.map +0 -1
- package/lib/common/env.d.ts +0 -9
- package/lib/common/env.js +0 -47
- package/lib/common/env.js.map +0 -1
- package/lib/common/exec/sfCli.d.ts +0 -27
- package/lib/common/exec/sfCli.js +0 -50
- package/lib/common/exec/sfCli.js.map +0 -1
- package/lib/common/flags/env.d.ts +0 -44
- package/lib/common/flags/env.js +0 -81
- package/lib/common/flags/env.js.map +0 -1
- package/lib/common/git.d.ts +0 -32
- package/lib/common/git.js +0 -106
- package/lib/common/git.js.map +0 -1
- package/lib/common/happySoup/resolveOriginProject.d.ts +0 -22
- package/lib/common/happySoup/resolveOriginProject.js +0 -61
- package/lib/common/happySoup/resolveOriginProject.js.map +0 -1
- package/lib/common/logger.d.ts +0 -10
- package/lib/common/logger.js +0 -33
- package/lib/common/logger.js.map +0 -1
- package/lib/common/notify/buildNotification.d.ts +0 -53
- package/lib/common/notify/buildNotification.js +0 -176
- package/lib/common/notify/buildNotification.js.map +0 -1
- package/lib/common/notify/getCommitStories.d.ts +0 -30
- package/lib/common/notify/getCommitStories.js +0 -70
- package/lib/common/notify/getCommitStories.js.map +0 -1
- package/lib/common/notify/getRemoteCommitStories.d.ts +0 -10
- package/lib/common/notify/getRemoteCommitStories.js +0 -45
- package/lib/common/notify/getRemoteCommitStories.js.map +0 -1
- package/lib/common/notify/happySoupNotification.d.ts +0 -26
- package/lib/common/notify/happySoupNotification.js +0 -139
- package/lib/common/notify/happySoupNotification.js.map +0 -1
- package/lib/common/notify/projectNotification.d.ts +0 -46
- package/lib/common/notify/projectNotification.js +0 -177
- package/lib/common/notify/projectNotification.js.map +0 -1
- package/lib/common/notify/renderTemplate.d.ts +0 -3
- package/lib/common/notify/renderTemplate.js +0 -24
- package/lib/common/notify/renderTemplate.js.map +0 -1
- package/lib/common/notify/sendNotification.d.ts +0 -2
- package/lib/common/notify/sendNotification.js +0 -50
- package/lib/common/notify/sendNotification.js.map +0 -1
- package/lib/common/notify/templates.d.ts +0 -13
- package/lib/common/notify/templates.js +0 -118
- package/lib/common/notify/templates.js.map +0 -1
- package/lib/common/schemas/deployConfig.d.ts +0 -25
- package/lib/common/schemas/deployConfig.js +0 -55
- package/lib/common/schemas/deployConfig.js.map +0 -1
- package/lib/common/schemas/deployProgress.d.ts +0 -33
- package/lib/common/schemas/deployProgress.js +0 -46
- package/lib/common/schemas/deployProgress.js.map +0 -1
- package/lib/common/schemas/deployRules.d.ts +0 -34
- package/lib/common/schemas/deployRules.js +0 -40
- package/lib/common/schemas/deployRules.js.map +0 -1
- package/lib/common/sfApex.d.ts +0 -22
- package/lib/common/sfApex.js +0 -169
- package/lib/common/sfApex.js.map +0 -1
- package/lib/common/sfAuth.d.ts +0 -19
- package/lib/common/sfAuth.js +0 -78
- package/lib/common/sfAuth.js.map +0 -1
- package/lib/common/sfConfig.d.ts +0 -23
- package/lib/common/sfConfig.js +0 -82
- package/lib/common/sfConfig.js.map +0 -1
- package/lib/common/sfPackages.d.ts +0 -31
- package/lib/common/sfPackages.js +0 -143
- package/lib/common/sfPackages.js.map +0 -1
- package/lib/common/sfPlugins.d.ts +0 -11
- package/lib/common/sfPlugins.js +0 -134
- package/lib/common/sfPlugins.js.map +0 -1
- package/lib/common/sfdxDependabot/dependabotRun.d.ts +0 -95
- package/lib/common/sfdxDependabot/dependabotRun.js +0 -287
- package/lib/common/sfdxDependabot/dependabotRun.js.map +0 -1
- package/lib/common/sfdxDependabot/updater.d.ts +0 -14
- package/lib/common/sfdxDependabot/updater.js +0 -94
- package/lib/common/sfdxDependabot/updater.js.map +0 -1
- package/lib/config/defaultDeploymentPlugins.d.ts +0 -2
- package/lib/config/defaultDeploymentPlugins.js +0 -18
- package/lib/config/defaultDeploymentPlugins.js.map +0 -1
- package/lib/config/trustedPlugins.d.ts +0 -2
- package/lib/config/trustedPlugins.js +0 -18
- package/lib/config/trustedPlugins.js.map +0 -1
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026, SimplySF.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { getPluginConfig } from '@simplysf/simply-core';
|
|
17
|
-
/** The tag shape every `simply cicd build` command used before the format was configurable. */
|
|
18
|
-
export const DEFAULT_VERSION_TAG_FORMAT = 'v{MAJOR}.{MINOR}.{PATCH}.{BUILD}';
|
|
19
|
-
/** Where in `sfdx-project.json` a project declares its own format. */
|
|
20
|
-
export const VERSION_TAG_FORMAT_CONFIG_PATH = 'plugins.simply.versionTagFormat';
|
|
21
|
-
/** Overrides the project's format, in every command that reads it, when set to a non-empty value. */
|
|
22
|
-
export const VERSION_TAG_FORMAT_ENV_VAR = 'SIMPLY_CICD_VERSION_TAG_FORMAT';
|
|
23
|
-
const PLACEHOLDERS = ['MAJOR', 'MINOR', 'PATCH', 'BUILD'];
|
|
24
|
-
/** `sf package version report` returns `Version` as `major.minor.patch.build`. */
|
|
25
|
-
const SALESFORCE_VERSION_PATTERN = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\.(?<build>\d+)$/;
|
|
26
|
-
/** Thrown for a format that can't be used, so callers that otherwise swallow errors can let it through. */
|
|
27
|
-
export class VersionTagFormatError extends Error {
|
|
28
|
-
constructor(format, problem, source = VERSION_TAG_FORMAT_CONFIG_PATH) {
|
|
29
|
-
super(`Invalid version tag format "${format}" (${source}): ${problem}`);
|
|
30
|
-
this.name = 'VersionTagFormatError';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Why `tag` isn't a legal git tag name, or `undefined` when it is. Mirrors `git check-ref-format`'s
|
|
35
|
-
* rules for `refs/tags/<tag>`, plus git's refusal of tag names starting with `-`.
|
|
36
|
-
*/
|
|
37
|
-
function findRefNameProblem(tag) {
|
|
38
|
-
if (tag.startsWith('-'))
|
|
39
|
-
return 'a tag cannot start with "-"';
|
|
40
|
-
// eslint-disable-next-line no-control-regex -- control characters are exactly what git refuses
|
|
41
|
-
if (/[\x00-\x20\x7f~^:?*[\\]/.test(tag))
|
|
42
|
-
return 'contains a space, a control character, or one of ~^:?*[\\';
|
|
43
|
-
if (tag.includes('..'))
|
|
44
|
-
return 'contains ".."';
|
|
45
|
-
if (tag.includes('@{'))
|
|
46
|
-
return 'contains "@{"';
|
|
47
|
-
if (tag === '@')
|
|
48
|
-
return 'cannot be "@"';
|
|
49
|
-
if (tag.endsWith('.'))
|
|
50
|
-
return 'cannot end with "."';
|
|
51
|
-
if (tag.startsWith('/') || tag.endsWith('/') || tag.includes('//'))
|
|
52
|
-
return 'has an empty "/"-separated component';
|
|
53
|
-
if (tag.split('/').some((component) => component.startsWith('.') || component.endsWith('.lock'))) {
|
|
54
|
-
return 'has a "/"-separated component starting with "." or ending with ".lock"';
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
function tokenize(format, source) {
|
|
59
|
-
const segments = [];
|
|
60
|
-
const placeholderPattern = /\{(?<name>[^{}]*)\}/g;
|
|
61
|
-
let lastIndex = 0;
|
|
62
|
-
for (const match of format.matchAll(placeholderPattern)) {
|
|
63
|
-
const name = match.groups?.name ?? '';
|
|
64
|
-
if (!PLACEHOLDERS.includes(name)) {
|
|
65
|
-
throw new VersionTagFormatError(format, `unknown placeholder "{${name}}"; use {MAJOR}, {MINOR}, {PATCH}, and {BUILD}`, source);
|
|
66
|
-
}
|
|
67
|
-
if (match.index > lastIndex) {
|
|
68
|
-
segments.push({ kind: 'literal', text: format.slice(lastIndex, match.index) });
|
|
69
|
-
}
|
|
70
|
-
segments.push({ kind: 'placeholder', name: name });
|
|
71
|
-
lastIndex = match.index + match[0].length;
|
|
72
|
-
}
|
|
73
|
-
if (lastIndex < format.length) {
|
|
74
|
-
segments.push({ kind: 'literal', text: format.slice(lastIndex) });
|
|
75
|
-
}
|
|
76
|
-
return segments;
|
|
77
|
-
}
|
|
78
|
-
function validate(format, segments, source) {
|
|
79
|
-
if (segments.some((segment) => segment.kind === 'literal' && /[{}]/.test(segment.text))) {
|
|
80
|
-
throw new VersionTagFormatError(format, 'contains an unmatched "{" or "}"', source);
|
|
81
|
-
}
|
|
82
|
-
for (const name of PLACEHOLDERS) {
|
|
83
|
-
const count = segments.filter((segment) => segment.kind === 'placeholder' && segment.name === name).length;
|
|
84
|
-
if (count !== 1) {
|
|
85
|
-
throw new VersionTagFormatError(format, `{${name}} must appear exactly once, found ${count}`, source);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
segments.forEach((segment, index) => {
|
|
89
|
-
const next = segments[index + 1];
|
|
90
|
-
if (segment.kind === 'placeholder' && next?.kind === 'placeholder') {
|
|
91
|
-
throw new VersionTagFormatError(format, `{${segment.name}}{${next.name}} must be separated by a non-digit`, source);
|
|
92
|
-
}
|
|
93
|
-
const following = segments[index + 2];
|
|
94
|
-
if (segment.kind === 'placeholder' &&
|
|
95
|
-
next?.kind === 'literal' &&
|
|
96
|
-
following?.kind === 'placeholder' &&
|
|
97
|
-
/^\d+$/.test(next.text)) {
|
|
98
|
-
throw new VersionTagFormatError(format, `{${segment.name}} and {${following.name}} must be separated by a non-digit`, source);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const problem = findRefNameProblem(renderSegments(segments, { major: '1', minor: '2', patch: '3', build: '4' }));
|
|
102
|
-
if (problem) {
|
|
103
|
-
throw new VersionTagFormatError(format, `the tags it produces aren't valid git tag names: ${problem}`, source);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function renderSegments(segments, values, missing = '') {
|
|
107
|
-
return segments
|
|
108
|
-
.map((segment) => segment.kind === 'literal' ? segment.text : (values[segment.name.toLowerCase()] ?? missing))
|
|
109
|
-
.join('');
|
|
110
|
-
}
|
|
111
|
-
function escapeRegExp(text) {
|
|
112
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* A validated version tag format. Every command that writes or reads a package version's git tag
|
|
116
|
-
* goes through one of these, so they agree on the tag's shape.
|
|
117
|
-
*/
|
|
118
|
-
export class VersionTagFormat {
|
|
119
|
-
format;
|
|
120
|
-
segments;
|
|
121
|
-
tagPattern;
|
|
122
|
-
constructor(format, source) {
|
|
123
|
-
this.format = format;
|
|
124
|
-
this.segments = tokenize(format, source);
|
|
125
|
-
validate(format, this.segments, source);
|
|
126
|
-
const versionPattern = this.segments
|
|
127
|
-
.map((segment) => segment.kind === 'literal' ? escapeRegExp(segment.text) : `(?<${segment.name.toLowerCase()}>\\d+)`)
|
|
128
|
-
.join('');
|
|
129
|
-
this.tagPattern = new RegExp(`^(?<versionTag>${versionPattern})(?:-(?<rest>.*))?$`);
|
|
130
|
-
}
|
|
131
|
-
/** @throws {VersionTagFormatError} If the format can't produce distinct, parseable, legal tags. */
|
|
132
|
-
static parse(format) {
|
|
133
|
-
return new VersionTagFormat(format);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The format in `SIMPLY_CICD_VERSION_TAG_FORMAT` when it's set, otherwise the one declared under
|
|
137
|
-
* `plugins.simply.versionTagFormat`, otherwise the default.
|
|
138
|
-
*
|
|
139
|
-
* @throws {VersionTagFormatError} If the chosen format is invalid.
|
|
140
|
-
*/
|
|
141
|
-
static fromProject(project) {
|
|
142
|
-
const override = process.env[VERSION_TAG_FORMAT_ENV_VAR];
|
|
143
|
-
if (override) {
|
|
144
|
-
return new VersionTagFormat(override, VERSION_TAG_FORMAT_ENV_VAR);
|
|
145
|
-
}
|
|
146
|
-
const declared = project ? getPluginConfig(project, VERSION_TAG_FORMAT_CONFIG_PATH) : undefined;
|
|
147
|
-
if (declared === undefined || declared === null || declared === '') {
|
|
148
|
-
return new VersionTagFormat(DEFAULT_VERSION_TAG_FORMAT);
|
|
149
|
-
}
|
|
150
|
-
if (typeof declared !== 'string') {
|
|
151
|
-
throw new VersionTagFormatError(JSON.stringify(declared), 'must be a string');
|
|
152
|
-
}
|
|
153
|
-
return new VersionTagFormat(declared);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* The tag for `salesforceVersion` (`major.minor.patch.build`), with `-<suffix>` appended when given.
|
|
157
|
-
*
|
|
158
|
-
* @throws {Error} If the version isn't four numeric parts.
|
|
159
|
-
*/
|
|
160
|
-
render(salesforceVersion, suffix) {
|
|
161
|
-
const match = SALESFORCE_VERSION_PATTERN.exec(salesforceVersion.trim());
|
|
162
|
-
if (!match?.groups) {
|
|
163
|
-
throw new Error(`Cannot render a version tag for Salesforce package version "${salesforceVersion}": expected major.minor.patch.build.`);
|
|
164
|
-
}
|
|
165
|
-
const versionTag = renderSegments(this.segments, match.groups);
|
|
166
|
-
return suffix ? `${versionTag}-${suffix}` : versionTag;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* A `git describe --match` / `git tag --list` glob for tags of the `major.minor.patch` that
|
|
170
|
-
* `versionNumber` (e.g. `6.40.0.NEXT`) declares, with any build and suffix. Without a usable
|
|
171
|
-
* `versionNumber`, any tag starting the way the format starts.
|
|
172
|
-
*/
|
|
173
|
-
matchPattern(versionNumber) {
|
|
174
|
-
const parts = versionNumber?.split('.') ?? [];
|
|
175
|
-
if (parts.length >= 3) {
|
|
176
|
-
const glob = renderSegments(this.segments, { major: parts[0], minor: parts[1], patch: parts[2] }, '*');
|
|
177
|
-
return glob.endsWith('*') ? glob : `${glob}*`;
|
|
178
|
-
}
|
|
179
|
-
const first = this.segments[0];
|
|
180
|
-
return `${first.kind === 'literal' ? first.text : ''}*`;
|
|
181
|
-
}
|
|
182
|
-
/** Splits a tag this format rendered back into its version and suffix; `undefined` if it doesn't match. */
|
|
183
|
-
parseTag(tag) {
|
|
184
|
-
const groups = this.tagPattern.exec(tag)?.groups;
|
|
185
|
-
if (!groups)
|
|
186
|
-
return undefined;
|
|
187
|
-
return {
|
|
188
|
-
versionTag: groups.versionTag,
|
|
189
|
-
version: { major: groups.major, minor: groups.minor, patch: groups.patch, build: groups.build },
|
|
190
|
-
rest: groups.rest ?? '',
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=versionTagFormat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versionTagFormat.js","sourceRoot":"","sources":["../../../src/common/build/versionTagFormat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAoB,MAAM,uBAAuB,CAAC;AAE1E,+FAA+F;AAC/F,MAAM,CAAC,MAAM,0BAA0B,GAAG,kCAAkC,CAAC;AAE7E,sEAAsE;AACtE,MAAM,CAAC,MAAM,8BAA8B,GAAG,iCAAiC,CAAC;AAEhF,qGAAqG;AACrG,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAE3E,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AAMnE,kFAAkF;AAClF,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAIlG,2GAA2G;AAC3G,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAmB,MAAc,EAAE,OAAe,EAAE,MAAM,GAAG,8BAA8B;QACzF,KAAK,CAAC,+BAA+B,MAAM,MAAM,MAAM,MAAM,OAAO,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;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C/F,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;SACxB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import { type VcsProviderKind } from '@simplysf/simply-cicd-core';
|
|
3
|
-
import { type DeployConfig } from '../schemas/deployConfig.js';
|
|
4
|
-
import { type DeployProgress } from '../schemas/deployProgress.js';
|
|
5
|
-
/**
|
|
6
|
-
* A Salesforce org this command operates on, referenced by an alias the calling pipeline has
|
|
7
|
-
* already authenticated — `simply-cicd` never authenticates orgs itself. Optional here because not
|
|
8
|
-
* every stage needs one (e.g. `deployment-close-out`); commands that do require it declare
|
|
9
|
-
* `alias` as `required: true` on the flag itself.
|
|
10
|
-
*/
|
|
11
|
-
export type OrgAuthConfig = {
|
|
12
|
-
alias?: string;
|
|
13
|
-
};
|
|
14
|
-
/** A deployment entry from `deploy.json`, plus the synthetic `{ name: 'local' }` project deployment. */
|
|
15
|
-
export type StageDeployment = {
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
name: string;
|
|
18
|
-
slug?: string;
|
|
19
|
-
ref?: string;
|
|
20
|
-
postDeploy?: boolean;
|
|
21
|
-
postDestructive?: boolean;
|
|
22
|
-
preDestructive?: boolean;
|
|
23
|
-
unpackagedDeploy?: boolean;
|
|
24
|
-
testLevel?: string;
|
|
25
|
-
tests?: string;
|
|
26
|
-
};
|
|
27
|
-
export type StageProperty = 'postDeploy' | 'postDestructive' | 'preDestructive' | 'unpackagedDeploy';
|
|
28
|
-
/** Validates `data` against a zod schema, throwing a formatted error (one bullet per issue) if it fails. */
|
|
29
|
-
export declare function validateWithSchema<T>(schema: z.ZodType<T>, data: unknown, fileName: string): T;
|
|
30
|
-
/**
|
|
31
|
-
* Read a JSON file and validate it against a zod schema.
|
|
32
|
-
*
|
|
33
|
-
* @param filePath - The file to read. Its name appears in the error on a schema violation.
|
|
34
|
-
* @param schema - The schema to validate against.
|
|
35
|
-
* @returns The validated contents.
|
|
36
|
-
* @throws {Error} With one bullet per schema issue, via {@link validateWithSchema}.
|
|
37
|
-
* @throws {NodeJS.ErrnoException} If the file can't be read — callers check for `ENOENT` to
|
|
38
|
-
* treat a missing file as non-fatal.
|
|
39
|
-
* @throws {SyntaxError} If the file isn't valid JSON.
|
|
40
|
-
*/
|
|
41
|
-
export declare function loadValidatedJsonFile<T>(filePath: string, schema: z.ZodType<T>): Promise<T>;
|
|
42
|
-
/** Validates a deployment configuration against a set of deployment rules (e.g. "prod must run postDeploy"). */
|
|
43
|
-
export declare function validateDeploymentRules(deploymentConfig: DeployConfig, rulesFile: string): Promise<void>;
|
|
44
|
-
export declare const STAGE_TO_SCRIPT_NAME_MAP: Record<string, string>;
|
|
45
|
-
export declare const STAGE_TO_PROPERTY_MAP: Record<string, string>;
|
|
46
|
-
export declare const STAGE_CONFIG: Record<string, {
|
|
47
|
-
property: StageProperty;
|
|
48
|
-
}>;
|
|
49
|
-
/** Atomically updates a progress file: writes to a temp file first, then renames it into place. */
|
|
50
|
-
export declare function updateProgress(deployProgressFile: string, newProgress: DeployProgress): Promise<void>;
|
|
51
|
-
export type ExecuteStageScriptConfig = {
|
|
52
|
-
alias?: string;
|
|
53
|
-
testLevel?: string;
|
|
54
|
-
tests?: string;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Executes a stage-specific script (e.g. `bin/preDestructive.sh`) for a deployment: installs npm
|
|
58
|
-
* production dependencies if a `package.json` exists, sets executable/writable permissions on the
|
|
59
|
-
* repo's working directories, and runs the script with `--target-org`/`--test-level`/`--tests`.
|
|
60
|
-
*/
|
|
61
|
-
export declare function executeStageScript(deployment: StageDeployment, stage: string, repoDir: string, config: ExecuteStageScriptConfig): Promise<void>;
|
|
62
|
-
export type InstallPackageDependenciesConfig = OrgAuthConfig & {
|
|
63
|
-
wait?: string;
|
|
64
|
-
installType?: 'All' | 'Delta' | 'Upgrade';
|
|
65
|
-
upgradeType?: 'DeprecateOnly' | 'Mixed' | 'Delete';
|
|
66
|
-
};
|
|
67
|
-
/** Installs the target org's packaged dependencies. The org must already be authenticated. */
|
|
68
|
-
export declare function installPackageDependencies(config: InstallPackageDependenciesConfig): Promise<void>;
|
|
69
|
-
/** Logs a per-job duration summary for the given stage, from the recorded progress file durations. */
|
|
70
|
-
export declare function printDeploymentSummary(deployProgress: DeployProgress, stage: string): void;
|
|
71
|
-
export type RunApexTestsConfig = OrgAuthConfig & {
|
|
72
|
-
testLevel?: string;
|
|
73
|
-
testSuite?: string;
|
|
74
|
-
wait?: string;
|
|
75
|
-
debugMode?: boolean;
|
|
76
|
-
};
|
|
77
|
-
/** Runs Apex tests on the target org. The org must already be authenticated. */
|
|
78
|
-
export declare function runApexTests(config: RunApexTestsConfig): Promise<void>;
|
|
79
|
-
export declare function loadProgress(deployProgressFile: string): Promise<DeployProgress>;
|
|
80
|
-
export type RunDeploymentStepsConfig = OrgAuthConfig & {
|
|
81
|
-
deployConfigFile: string;
|
|
82
|
-
deployRulesFile: string;
|
|
83
|
-
deployProgressFile: string;
|
|
84
|
-
stage: string;
|
|
85
|
-
startFrom?: string;
|
|
86
|
-
isProjectDeployment?: boolean;
|
|
87
|
-
debug?: boolean;
|
|
88
|
-
testLevel?: string;
|
|
89
|
-
tests?: string;
|
|
90
|
-
ciJobToken: string;
|
|
91
|
-
vcsHost?: string;
|
|
92
|
-
vcsProvider: VcsProviderKind;
|
|
93
|
-
};
|
|
94
|
-
export type RunDeploymentStepsResult = {
|
|
95
|
-
deployProgress: DeployProgress;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Runs a complete set of deployment jobs for a stage: loads (and validates) the progress and
|
|
99
|
-
* config files, determines where to resume from, then clones/prepares/executes each job in order
|
|
100
|
-
* — persisting progress after every job so a mid-run crash can resume cleanly. The target org
|
|
101
|
-
* (`config.alias`) must already be authenticated.
|
|
102
|
-
*/
|
|
103
|
-
export declare function runDeploymentSteps(config: RunDeploymentStepsConfig): Promise<RunDeploymentStepsResult>;
|
|
104
|
-
/** Determines the deploy config file path: explicit path wins, else derived from the branch name. */
|
|
105
|
-
export declare function determineDeployConfigFile(sourceBranchName?: string, deployConfigFile?: string): string | undefined;
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026, SimplySF.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { promises as fs } from 'node:fs';
|
|
17
|
-
import path from 'node:path';
|
|
18
|
-
import chalk from 'chalk';
|
|
19
|
-
import { execa } from 'execa';
|
|
20
|
-
import { createVcsProvider } from '@simplysf/simply-cicd-core';
|
|
21
|
-
import { cloneRepo } from '../git.js';
|
|
22
|
-
import { logger } from '../logger.js';
|
|
23
|
-
import { runApexTests as runApexTestsCommon } from '../sfApex.js';
|
|
24
|
-
import { installPackageDependencies as installPackageDependenciesCommon } from '../sfPackages.js';
|
|
25
|
-
import { installDeploymentPlugins } from '../sfPlugins.js';
|
|
26
|
-
import { deployConfigSchema } from '../schemas/deployConfig.js';
|
|
27
|
-
import { deployProgressSchema } from '../schemas/deployProgress.js';
|
|
28
|
-
import { deployRulesSchema } from '../schemas/deployRules.js';
|
|
29
|
-
/** Validates `data` against a zod schema, throwing a formatted error (one bullet per issue) if it fails. */
|
|
30
|
-
export function validateWithSchema(schema, data, fileName) {
|
|
31
|
-
const result = schema.safeParse(data);
|
|
32
|
-
if (!result.success) {
|
|
33
|
-
const errorMessages = result.error.issues
|
|
34
|
-
.map((issue) => ` - ${issue.path.join('.') || 'root'}: ${issue.message}`)
|
|
35
|
-
.join('');
|
|
36
|
-
throw new Error(`Invalid format for ${fileName}: ${errorMessages}`);
|
|
37
|
-
}
|
|
38
|
-
return result.data;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Read a JSON file and validate it against a zod schema.
|
|
42
|
-
*
|
|
43
|
-
* @param filePath - The file to read. Its name appears in the error on a schema violation.
|
|
44
|
-
* @param schema - The schema to validate against.
|
|
45
|
-
* @returns The validated contents.
|
|
46
|
-
* @throws {Error} With one bullet per schema issue, via {@link validateWithSchema}.
|
|
47
|
-
* @throws {NodeJS.ErrnoException} If the file can't be read — callers check for `ENOENT` to
|
|
48
|
-
* treat a missing file as non-fatal.
|
|
49
|
-
* @throws {SyntaxError} If the file isn't valid JSON.
|
|
50
|
-
*/
|
|
51
|
-
export async function loadValidatedJsonFile(filePath, schema) {
|
|
52
|
-
const contents = await fs.readFile(filePath, 'utf-8');
|
|
53
|
-
return validateWithSchema(schema, JSON.parse(contents), filePath);
|
|
54
|
-
}
|
|
55
|
-
/** Validates a deployment configuration against a set of deployment rules (e.g. "prod must run postDeploy"). */
|
|
56
|
-
export async function validateDeploymentRules(deploymentConfig, rulesFile) {
|
|
57
|
-
let rulesConfig;
|
|
58
|
-
try {
|
|
59
|
-
rulesConfig = await loadValidatedJsonFile(rulesFile, deployRulesSchema);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
if (error.code === 'ENOENT') {
|
|
63
|
-
logger.info(`Deployment rules file not found at ${rulesFile}. Skipping rules validation.`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
logger.error(`Failed to read or validate ${rulesFile}: ${error.message}`);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
const errors = [];
|
|
70
|
-
for (const rule of rulesConfig.rules) {
|
|
71
|
-
const deployment = deploymentConfig.deployments.find((d) => {
|
|
72
|
-
const matchesName = Boolean(rule.deploymentName) && d.name === rule.deploymentName;
|
|
73
|
-
const matchesSlug = Boolean(rule.deploymentSlug) && d.slug === rule.deploymentSlug;
|
|
74
|
-
return matchesName || matchesSlug;
|
|
75
|
-
});
|
|
76
|
-
if (deployment) {
|
|
77
|
-
for (const requiredStage of rule.requireStages) {
|
|
78
|
-
if (!deployment[requiredStage]) {
|
|
79
|
-
let identifier;
|
|
80
|
-
if (rule.deploymentName && rule.deploymentSlug) {
|
|
81
|
-
identifier = `name '${rule.deploymentName}' or slug '${rule.deploymentSlug}'`;
|
|
82
|
-
}
|
|
83
|
-
else if (rule.deploymentName) {
|
|
84
|
-
identifier = `name '${rule.deploymentName}'`;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
identifier = `slug '${rule.deploymentSlug ?? 'unknown'}'`;
|
|
88
|
-
}
|
|
89
|
-
errors.push(`Deployment with ${identifier} is missing required stage '${requiredStage}'.`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (errors.length > 0) {
|
|
95
|
-
throw new Error(`Deployment configuration failed validation against deployment rules:\n${errors.join('\n')}`);
|
|
96
|
-
}
|
|
97
|
-
logger.success('Deployment configuration passed validation against deployment rules.');
|
|
98
|
-
}
|
|
99
|
-
export const STAGE_TO_SCRIPT_NAME_MAP = {
|
|
100
|
-
'pre-destructive': 'preDestructive.sh',
|
|
101
|
-
'deploy-unpackaged': 'unpackagedDeploy.sh',
|
|
102
|
-
'post-deploy': 'postDeploy.sh',
|
|
103
|
-
'post-destructive': 'postDestructive.sh',
|
|
104
|
-
};
|
|
105
|
-
export const STAGE_TO_PROPERTY_MAP = {
|
|
106
|
-
'pre-destructive': 'preDestructive',
|
|
107
|
-
'install-packaged': 'installPackaged',
|
|
108
|
-
'deploy-unpackaged': 'unpackagedDeploy',
|
|
109
|
-
'post-deploy': 'postDeploy',
|
|
110
|
-
'post-destructive': 'postDestructive',
|
|
111
|
-
};
|
|
112
|
-
export const STAGE_CONFIG = {
|
|
113
|
-
'pre-destructive': { property: 'preDestructive' },
|
|
114
|
-
'deploy-unpackaged': { property: 'unpackagedDeploy' },
|
|
115
|
-
'post-deploy': { property: 'postDeploy' },
|
|
116
|
-
'post-destructive': { property: 'postDestructive' },
|
|
117
|
-
};
|
|
118
|
-
/** Atomically updates a progress file: writes to a temp file first, then renames it into place. */
|
|
119
|
-
export async function updateProgress(deployProgressFile, newProgress) {
|
|
120
|
-
const tempFile = `${deployProgressFile}.${Date.now()}.tmp`;
|
|
121
|
-
await fs.writeFile(tempFile, JSON.stringify(newProgress, null, 2));
|
|
122
|
-
await fs.rename(tempFile, deployProgressFile);
|
|
123
|
-
}
|
|
124
|
-
const DIRS_TO_CHMOD = [
|
|
125
|
-
{ dir: 'logs', mode: '+rw' },
|
|
126
|
-
{ dir: 'data', mode: '+rw' },
|
|
127
|
-
{ dir: 'bin', mode: '+rx' },
|
|
128
|
-
{ dir: 'scripts', mode: '+rw' },
|
|
129
|
-
];
|
|
130
|
-
async function chmodStageDirectories(repoDir, jobName) {
|
|
131
|
-
for (const { dir, mode } of DIRS_TO_CHMOD) {
|
|
132
|
-
const dirPath = path.join(repoDir, dir);
|
|
133
|
-
try {
|
|
134
|
-
// eslint-disable-next-line no-await-in-loop
|
|
135
|
-
await fs.access(dirPath);
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
logger.info(`[${jobName}] Modifying permissions of ${dir} to ${mode}...`);
|
|
142
|
-
// eslint-disable-next-line no-await-in-loop
|
|
143
|
-
await execa('chmod', ['-R', mode, `./${dir}`], { cwd: repoDir });
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
logger.warn(`[${jobName}] Could not modify permissions for ${dir}. This might cause issues on non-Windows systems.`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Executes a stage-specific script (e.g. `bin/preDestructive.sh`) for a deployment: installs npm
|
|
152
|
-
* production dependencies if a `package.json` exists, sets executable/writable permissions on the
|
|
153
|
-
* repo's working directories, and runs the script with `--target-org`/`--test-level`/`--tests`.
|
|
154
|
-
*/
|
|
155
|
-
export async function executeStageScript(deployment, stage, repoDir, config) {
|
|
156
|
-
const { alias } = config;
|
|
157
|
-
const jobName = deployment.name.toUpperCase();
|
|
158
|
-
const scriptName = STAGE_TO_SCRIPT_NAME_MAP[stage];
|
|
159
|
-
if (!scriptName) {
|
|
160
|
-
logger.info(`No script configured for stage ${stage}, skipping script execution.`);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const scriptPath = path.join(repoDir, 'bin', scriptName);
|
|
164
|
-
try {
|
|
165
|
-
await fs.access(scriptPath);
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
logger.info(`Script ${scriptPath} not found for deployment ${deployment.name}, skipping.`);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
logger.info(`[${jobName}] Preparing to run ${scriptName}`);
|
|
172
|
-
const packageJsonPath = path.join(repoDir, 'package.json');
|
|
173
|
-
try {
|
|
174
|
-
await fs.access(packageJsonPath);
|
|
175
|
-
logger.info(`[${jobName}] Installing npm dependencies...`);
|
|
176
|
-
await execa('npm', ['install', '--omit=dev'], { cwd: repoDir, env: { HUSKY_SKIP_INSTALL: '1' } });
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
// No package.json for this repo; nothing to install.
|
|
180
|
-
}
|
|
181
|
-
await chmodStageDirectories(repoDir, jobName);
|
|
182
|
-
const testLevel = deployment.testLevel ?? config.testLevel ?? 'RunLocalTests';
|
|
183
|
-
const tests = deployment.tests ?? config.tests ?? '';
|
|
184
|
-
const scriptArgs = ['--target-org', alias ?? '', '--test-level', testLevel];
|
|
185
|
-
if (tests) {
|
|
186
|
-
scriptArgs.push('--tests', tests);
|
|
187
|
-
}
|
|
188
|
-
logger.info(`[${jobName}] Executing: ./${path.join('bin', scriptName)} ${scriptArgs.join(' ')}`);
|
|
189
|
-
await execa(path.resolve(scriptPath), scriptArgs, { cwd: repoDir, stdio: 'inherit' });
|
|
190
|
-
}
|
|
191
|
-
/** Installs the target org's packaged dependencies. The org must already be authenticated. */
|
|
192
|
-
export async function installPackageDependencies(config) {
|
|
193
|
-
const { alias, wait = '120', installType = 'Upgrade', upgradeType } = config;
|
|
194
|
-
await installPackageDependenciesCommon({ alias, wait, installType, upgradeType });
|
|
195
|
-
}
|
|
196
|
-
/** Logs a per-job duration summary for the given stage, from the recorded progress file durations. */
|
|
197
|
-
export function printDeploymentSummary(deployProgress, stage) {
|
|
198
|
-
try {
|
|
199
|
-
const stageConfig = STAGE_CONFIG[stage];
|
|
200
|
-
if (!stageConfig) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const stageProperty = stageConfig.property;
|
|
204
|
-
if (!deployProgress.durations) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const jobs = [];
|
|
208
|
-
for (const [jobName, durations] of Object.entries(deployProgress.durations)) {
|
|
209
|
-
if (durations?.[stageProperty] !== undefined) {
|
|
210
|
-
jobs.push({ name: jobName.toUpperCase(), duration: durations[stageProperty] });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (jobs.length === 0) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
logger.raw('\n');
|
|
217
|
-
logger.info(`Job Summary: ${chalk.bold(stage)}`);
|
|
218
|
-
for (const job of jobs) {
|
|
219
|
-
logger.info(` - Job: ${job.name} | Duration: ${job.duration}s`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
logger.warn(`Could not generate deployment summary: ${error.message}`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/** Runs Apex tests on the target org. The org must already be authenticated. */
|
|
227
|
-
export async function runApexTests(config) {
|
|
228
|
-
const { alias, testLevel = 'RunLocalTests', testSuite, wait = '360' } = config;
|
|
229
|
-
logger.info(`Running Apex tests on org ${alias ?? 'unknown'}...`);
|
|
230
|
-
await runApexTestsCommon({ alias, testLevel, testSuite, wait, debugMode: config.debugMode });
|
|
231
|
-
}
|
|
232
|
-
export async function loadProgress(deployProgressFile) {
|
|
233
|
-
try {
|
|
234
|
-
return await loadValidatedJsonFile(deployProgressFile, deployProgressSchema);
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
if (error.code === 'ENOENT') {
|
|
238
|
-
return {};
|
|
239
|
-
}
|
|
240
|
-
logger.warn(`Could not read or validate ${deployProgressFile}: ${error.message}. Starting fresh.`);
|
|
241
|
-
return {};
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
async function loadDeployConfig(deployConfigFile, deployRulesFile) {
|
|
245
|
-
try {
|
|
246
|
-
const deploymentConfig = await loadValidatedJsonFile(deployConfigFile, deployConfigSchema);
|
|
247
|
-
await validateDeploymentRules(deploymentConfig, deployRulesFile);
|
|
248
|
-
return { found: true, config: deploymentConfig };
|
|
249
|
-
}
|
|
250
|
-
catch (error) {
|
|
251
|
-
if (error.code === 'ENOENT') {
|
|
252
|
-
logger.warn(`Deployment config file not found at ${deployConfigFile}. Skipping deployments from config for this stage.`);
|
|
253
|
-
return { found: false };
|
|
254
|
-
}
|
|
255
|
-
logger.error(`Failed to read or validate ${deployConfigFile}: ${error.message}`);
|
|
256
|
-
throw error;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function resolveStartFrom(progress, stage, stageProperty, startFrom) {
|
|
260
|
-
if (startFrom) {
|
|
261
|
-
logger.info(`Starting ${chalk.bold(stage)} from job: ${chalk.bold(startFrom)} (forced by CLI option)`);
|
|
262
|
-
return { effectiveStartFrom: startFrom, idxOffset: 0 };
|
|
263
|
-
}
|
|
264
|
-
const resumePoint = progress[stageProperty];
|
|
265
|
-
if (resumePoint && resumePoint !== 'COMPLETE') {
|
|
266
|
-
logger.info(`Resuming ${chalk.bold(stage)} from job: ${chalk.bold(resumePoint)} (offset 1) based on progress file`);
|
|
267
|
-
return { effectiveStartFrom: resumePoint, idxOffset: 1 };
|
|
268
|
-
}
|
|
269
|
-
return { idxOffset: 0 };
|
|
270
|
-
}
|
|
271
|
-
function buildDeploymentsToRun(deploymentConfig, isProjectDeployment, stageProperty, effectiveStartFrom, idxOffset) {
|
|
272
|
-
let deploymentsToRun = deploymentConfig?.deployments ?? [];
|
|
273
|
-
if (isProjectDeployment) {
|
|
274
|
-
const localDeployment = { name: 'local' };
|
|
275
|
-
localDeployment[stageProperty] = true;
|
|
276
|
-
deploymentsToRun = [...deploymentsToRun, localDeployment];
|
|
277
|
-
}
|
|
278
|
-
if (effectiveStartFrom) {
|
|
279
|
-
const startIndex = deploymentsToRun.findIndex((d) => d.name === effectiveStartFrom);
|
|
280
|
-
if (startIndex === -1) {
|
|
281
|
-
throw new Error(`Start job ${chalk.bold(effectiveStartFrom)} not found in deployments configuration.`);
|
|
282
|
-
}
|
|
283
|
-
deploymentsToRun = deploymentsToRun.slice(startIndex + idxOffset);
|
|
284
|
-
}
|
|
285
|
-
return deploymentsToRun.filter((d) => Boolean(d[stageProperty]));
|
|
286
|
-
}
|
|
287
|
-
async function runDeploymentJob(deployment, stage, stageProperty, progress, deployProgressFile, config, vcsProvider) {
|
|
288
|
-
const jobName = deployment.name.toUpperCase();
|
|
289
|
-
logger.raw('\n' + '='.repeat(80));
|
|
290
|
-
logger.info(`>>> Starting Job: ${chalk.bold(jobName)} <<<`);
|
|
291
|
-
logger.raw('='.repeat(80) + '\n');
|
|
292
|
-
const startTime = Date.now();
|
|
293
|
-
try {
|
|
294
|
-
const repoDir = deployment.name.toLowerCase() === 'local'
|
|
295
|
-
? process.cwd()
|
|
296
|
-
: await cloneRepo({ name: deployment.name, slug: deployment.slug ?? '', ref: deployment.ref }, { ciJobToken: config.ciJobToken, vcsProvider });
|
|
297
|
-
await installDeploymentPlugins(config.debug, repoDir);
|
|
298
|
-
await executeStageScript(deployment, stage, repoDir, config);
|
|
299
|
-
const durationSeconds = Number(((Date.now() - startTime) / 1000).toFixed(2));
|
|
300
|
-
progress[stageProperty] = deployment.name;
|
|
301
|
-
progress.durations ??= {};
|
|
302
|
-
progress.durations[deployment.name] ??= {};
|
|
303
|
-
progress.durations[deployment.name][stageProperty] = durationSeconds;
|
|
304
|
-
await updateProgress(deployProgressFile, progress);
|
|
305
|
-
logger.raw('\n' + '='.repeat(80));
|
|
306
|
-
logger.success(`Completed Job: ${chalk.bold(jobName)} in ${durationSeconds}s`);
|
|
307
|
-
logger.raw('='.repeat(80) + '\n');
|
|
308
|
-
}
|
|
309
|
-
catch (error) {
|
|
310
|
-
error.job = jobName;
|
|
311
|
-
throw error;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Runs a complete set of deployment jobs for a stage: loads (and validates) the progress and
|
|
316
|
-
* config files, determines where to resume from, then clones/prepares/executes each job in order
|
|
317
|
-
* — persisting progress after every job so a mid-run crash can resume cleanly. The target org
|
|
318
|
-
* (`config.alias`) must already be authenticated.
|
|
319
|
-
*/
|
|
320
|
-
export async function runDeploymentSteps(config) {
|
|
321
|
-
const { deployConfigFile, deployRulesFile, isProjectDeployment, deployProgressFile, stage, startFrom } = config;
|
|
322
|
-
const progress = await loadProgress(deployProgressFile);
|
|
323
|
-
const deployConfigResult = await loadDeployConfig(deployConfigFile, deployRulesFile);
|
|
324
|
-
if (!deployConfigResult.found && !isProjectDeployment) {
|
|
325
|
-
return { deployProgress: progress };
|
|
326
|
-
}
|
|
327
|
-
const stageConfig = STAGE_CONFIG[stage];
|
|
328
|
-
if (!stageConfig) {
|
|
329
|
-
throw new Error(`Invalid or unsupported stage for deployment jobs: ${chalk.bold(stage)}`);
|
|
330
|
-
}
|
|
331
|
-
const stageProperty = stageConfig.property;
|
|
332
|
-
const { effectiveStartFrom, idxOffset } = resolveStartFrom(progress, stage, stageProperty, startFrom);
|
|
333
|
-
const deploymentsToRun = buildDeploymentsToRun(deployConfigResult.found ? deployConfigResult.config : undefined, isProjectDeployment, stageProperty, effectiveStartFrom, idxOffset);
|
|
334
|
-
if (deploymentsToRun.length === 0) {
|
|
335
|
-
logger.info(`No deployments configured for ${chalk.bold(stage)}.`);
|
|
336
|
-
return { deployProgress: progress };
|
|
337
|
-
}
|
|
338
|
-
const vcsProvider = createVcsProvider(config.vcsProvider, { host: config.vcsHost, token: config.ciJobToken });
|
|
339
|
-
for (const deployment of deploymentsToRun) {
|
|
340
|
-
// eslint-disable-next-line no-await-in-loop
|
|
341
|
-
await runDeploymentJob(deployment, stage, stageProperty, progress, deployProgressFile, config, vcsProvider);
|
|
342
|
-
}
|
|
343
|
-
progress[stageProperty] = 'COMPLETE';
|
|
344
|
-
await updateProgress(deployProgressFile, progress);
|
|
345
|
-
return { deployProgress: progress };
|
|
346
|
-
}
|
|
347
|
-
/** Determines the deploy config file path: explicit path wins, else derived from the branch name. */
|
|
348
|
-
export function determineDeployConfigFile(sourceBranchName, deployConfigFile) {
|
|
349
|
-
if (deployConfigFile) {
|
|
350
|
-
return deployConfigFile;
|
|
351
|
-
}
|
|
352
|
-
if (!sourceBranchName) {
|
|
353
|
-
return undefined;
|
|
354
|
-
}
|
|
355
|
-
const branchNamePart = sourceBranchName.includes('/') ? sourceBranchName.split('/')[1] : sourceBranchName;
|
|
356
|
-
return `deployment-configs/${branchNamePart}.json`;
|
|
357
|
-
}
|
|
358
|
-
//# sourceMappingURL=deployCommon.js.map
|