@simplysf/simply-cicd-core 0.2.1 → 0.3.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 -7
- package/lib/build/checkPermissionSets.d.ts +22 -0
- package/lib/build/checkPermissionSets.js +102 -0
- package/lib/build/checkPermissionSets.js.map +1 -0
- package/lib/build/cleanupScratchOrgs.d.ts +6 -0
- package/lib/build/cleanupScratchOrgs.js +91 -0
- package/lib/build/cleanupScratchOrgs.js.map +1 -0
- package/lib/build/createFallbackTag.d.ts +24 -0
- package/lib/build/createFallbackTag.js +147 -0
- package/lib/build/createFallbackTag.js.map +1 -0
- package/lib/build/createPackageVersion.d.ts +42 -0
- package/lib/build/createPackageVersion.js +198 -0
- package/lib/build/createPackageVersion.js.map +1 -0
- package/lib/build/createScratchOrg.d.ts +14 -0
- package/lib/build/createScratchOrg.js +192 -0
- package/lib/build/createScratchOrg.js.map +1 -0
- package/lib/build/deleteScratchOrg.d.ts +13 -0
- package/lib/build/deleteScratchOrg.js +62 -0
- package/lib/build/deleteScratchOrg.js.map +1 -0
- package/lib/build/deltaRunner.d.ts +73 -0
- package/lib/build/deltaRunner.js +109 -0
- package/lib/build/deltaRunner.js.map +1 -0
- package/lib/build/determinePackageChanges.d.ts +11 -0
- package/lib/build/determinePackageChanges.js +90 -0
- package/lib/build/determinePackageChanges.js.map +1 -0
- package/lib/build/devHubs.d.ts +12 -0
- package/lib/build/devHubs.js +42 -0
- package/lib/build/devHubs.js.map +1 -0
- package/lib/build/flexipageDelta.d.ts +18 -0
- package/lib/build/flexipageDelta.js +35 -0
- package/lib/build/flexipageDelta.js.map +1 -0
- package/lib/build/flowDelta.d.ts +17 -0
- package/lib/build/flowDelta.js +34 -0
- package/lib/build/flowDelta.js.map +1 -0
- package/lib/build/installDependencies.d.ts +10 -0
- package/lib/build/installDependencies.js +39 -0
- package/lib/build/installDependencies.js.map +1 -0
- package/lib/build/lwcJest.d.ts +25 -0
- package/lib/build/lwcJest.js +126 -0
- package/lib/build/lwcJest.js.map +1 -0
- package/lib/build/publishUtamPageObjects.d.ts +50 -0
- package/lib/build/publishUtamPageObjects.js +283 -0
- package/lib/build/publishUtamPageObjects.js.map +1 -0
- package/lib/build/pushScratch.d.ts +9 -0
- package/lib/build/pushScratch.js +60 -0
- package/lib/build/pushScratch.js.map +1 -0
- package/lib/build/scratchOrgAuth.d.ts +18 -0
- package/lib/build/scratchOrgAuth.js +52 -0
- package/lib/build/scratchOrgAuth.js.map +1 -0
- package/lib/build/scratchOrgInfo.d.ts +14 -0
- package/lib/build/scratchOrgInfo.js +21 -0
- package/lib/build/scratchOrgInfo.js.map +1 -0
- package/lib/build/skipGuard.d.ts +8 -0
- package/lib/build/skipGuard.js +42 -0
- package/lib/build/skipGuard.js.map +1 -0
- package/lib/build/testScratch.d.ts +15 -0
- package/lib/build/testScratch.js +42 -0
- package/lib/build/testScratch.js.map +1 -0
- package/lib/build/utamPageObjects.d.ts +143 -0
- package/lib/build/utamPageObjects.js +258 -0
- package/lib/build/utamPageObjects.js.map +1 -0
- package/lib/build/versionTagFormat.d.ts +57 -0
- package/lib/build/versionTagFormat.js +194 -0
- package/lib/build/versionTagFormat.js.map +1 -0
- package/lib/config/defaultDeploymentPlugins.d.ts +2 -0
- package/lib/config/defaultDeploymentPlugins.js +18 -0
- package/lib/config/defaultDeploymentPlugins.js.map +1 -0
- package/lib/config/trustedPlugins.d.ts +2 -0
- package/lib/config/trustedPlugins.js +18 -0
- package/lib/config/trustedPlugins.js.map +1 -0
- package/lib/deploy/deployCommon.d.ts +105 -0
- package/lib/deploy/deployCommon.js +358 -0
- package/lib/deploy/deployCommon.js.map +1 -0
- package/lib/deploy/deployHappySoup.d.ts +56 -0
- package/lib/deploy/deployHappySoup.js +160 -0
- package/lib/deploy/deployHappySoup.js.map +1 -0
- package/lib/deploy/deployProject.d.ts +27 -0
- package/lib/deploy/deployProject.js +114 -0
- package/lib/deploy/deployProject.js.map +1 -0
- package/lib/deploy/runDeployStage.d.ts +16 -0
- package/lib/deploy/runDeployStage.js +65 -0
- package/lib/deploy/runDeployStage.js.map +1 -0
- package/lib/deploy/stageOptions.d.ts +49 -0
- package/lib/deploy/stageOptions.js +70 -0
- package/lib/deploy/stageOptions.js.map +1 -0
- package/lib/deploy/validate.d.ts +11 -0
- package/lib/deploy/validate.js +54 -0
- package/lib/deploy/validate.js.map +1 -0
- package/lib/env.d.ts +9 -0
- package/lib/env.js +47 -0
- package/lib/env.js.map +1 -0
- package/lib/exec/sfCli.d.ts +27 -0
- package/lib/exec/sfCli.js +50 -0
- package/lib/exec/sfCli.js.map +1 -0
- package/lib/flags/env.d.ts +44 -0
- package/lib/flags/env.js +81 -0
- package/lib/flags/env.js.map +1 -0
- package/lib/git.d.ts +32 -0
- package/lib/git.js +106 -0
- package/lib/git.js.map +1 -0
- package/lib/happySoup/resolveOriginProject.d.ts +22 -0
- package/lib/happySoup/resolveOriginProject.js +61 -0
- package/lib/happySoup/resolveOriginProject.js.map +1 -0
- package/lib/index.d.ts +51 -0
- package/lib/index.js +63 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +10 -0
- package/lib/logger.js +33 -0
- package/lib/logger.js.map +1 -0
- package/lib/notify/buildNotification.d.ts +53 -0
- package/lib/notify/buildNotification.js +176 -0
- package/lib/notify/buildNotification.js.map +1 -0
- package/lib/notify/getCommitStories.d.ts +30 -0
- package/lib/notify/getCommitStories.js +70 -0
- package/lib/notify/getCommitStories.js.map +1 -0
- package/lib/notify/getRemoteCommitStories.d.ts +10 -0
- package/lib/notify/getRemoteCommitStories.js +45 -0
- package/lib/notify/getRemoteCommitStories.js.map +1 -0
- package/lib/notify/happySoupNotification.d.ts +26 -0
- package/lib/notify/happySoupNotification.js +140 -0
- package/lib/notify/happySoupNotification.js.map +1 -0
- package/lib/notify/projectNotification.d.ts +46 -0
- package/lib/notify/projectNotification.js +177 -0
- package/lib/notify/projectNotification.js.map +1 -0
- package/lib/notify/renderTemplate.d.ts +3 -0
- package/lib/notify/renderTemplate.js +24 -0
- package/lib/notify/renderTemplate.js.map +1 -0
- package/lib/notify/sendNotification.d.ts +2 -0
- package/lib/notify/sendNotification.js +50 -0
- package/lib/notify/sendNotification.js.map +1 -0
- package/lib/notify/templates.d.ts +13 -0
- package/lib/notify/templates.js +118 -0
- package/lib/notify/templates.js.map +1 -0
- package/lib/schemas/deployConfig.d.ts +25 -0
- package/lib/schemas/deployConfig.js +55 -0
- package/lib/schemas/deployConfig.js.map +1 -0
- package/lib/schemas/deployProgress.d.ts +33 -0
- package/lib/schemas/deployProgress.js +46 -0
- package/lib/schemas/deployProgress.js.map +1 -0
- package/lib/schemas/deployRules.d.ts +34 -0
- package/lib/schemas/deployRules.js +40 -0
- package/lib/schemas/deployRules.js.map +1 -0
- package/lib/sfApex.d.ts +22 -0
- package/lib/sfApex.js +169 -0
- package/lib/sfApex.js.map +1 -0
- package/lib/sfAuth.d.ts +19 -0
- package/lib/sfAuth.js +78 -0
- package/lib/sfAuth.js.map +1 -0
- package/lib/sfConfig.d.ts +23 -0
- package/lib/sfConfig.js +82 -0
- package/lib/sfConfig.js.map +1 -0
- package/lib/sfPackages.d.ts +31 -0
- package/lib/sfPackages.js +143 -0
- package/lib/sfPackages.js.map +1 -0
- package/lib/sfPlugins.d.ts +11 -0
- package/lib/sfPlugins.js +134 -0
- package/lib/sfPlugins.js.map +1 -0
- package/lib/sfdxDependabot/dependabotRun.d.ts +95 -0
- package/lib/sfdxDependabot/dependabotRun.js +287 -0
- package/lib/sfdxDependabot/dependabotRun.js.map +1 -0
- package/lib/sfdxDependabot/updater.d.ts +14 -0
- package/lib/sfdxDependabot/updater.js +94 -0
- package/lib/sfdxDependabot/updater.js.map +1 -0
- package/package.json +18 -7
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type NpmAccess = 'public' | 'restricted';
|
|
2
|
+
export type PublishUtamPageObjectsOptions = {
|
|
3
|
+
/** The packaging Dev Hub's alias. Must already be authenticated. */
|
|
4
|
+
packagingDevhub: string;
|
|
5
|
+
subscriberPackageVersionId?: string;
|
|
6
|
+
/** Overrides `plugins.simply.utam.packageName`. */
|
|
7
|
+
npmPackageName?: string;
|
|
8
|
+
npmRegistry?: string;
|
|
9
|
+
npmAccess?: NpmAccess;
|
|
10
|
+
/** Overrides the dist-tag derived from the git tag's suffix. */
|
|
11
|
+
npmDistTag?: string;
|
|
12
|
+
ciCommitRefName?: string;
|
|
13
|
+
packageReleaseBranchPrefix?: string;
|
|
14
|
+
/** npm spec of the UTAM compiler to install into the staging directory. */
|
|
15
|
+
utamVersion?: string;
|
|
16
|
+
/** Compile and `npm pack`, but don't publish. */
|
|
17
|
+
dryRun?: boolean;
|
|
18
|
+
/** Dotenv file to append the published name and version to. */
|
|
19
|
+
out?: string;
|
|
20
|
+
/** Dotenv file to read `SUBSCRIBER_PACKAGE_VERSION_ID` from. */
|
|
21
|
+
envFile?: string;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type PublishUtamPageObjectsResult = {
|
|
26
|
+
skipped: boolean;
|
|
27
|
+
published: boolean;
|
|
28
|
+
/** True when this exact version was already on the registry, so nothing needed publishing. */
|
|
29
|
+
alreadyPublished?: boolean;
|
|
30
|
+
packageName?: string;
|
|
31
|
+
version?: string;
|
|
32
|
+
distTag?: string;
|
|
33
|
+
/** Path to the packed tarball, on `--dry-run` only. */
|
|
34
|
+
tarball?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Compile the project's UTAM page objects for one package version and publish them as an npm
|
|
38
|
+
* package whose version is derived from the Salesforce version number.
|
|
39
|
+
*
|
|
40
|
+
* Runs after `create-package-version`, whose `04t` it takes as input, so that every Unlocked
|
|
41
|
+
* Package version has a corresponding page-object package a UI-test suite can pin to. See
|
|
42
|
+
* `docs/design/0037-utam-page-objects-publish.md` for the reasoning, particularly the version
|
|
43
|
+
* mapping and why the compiler config is generated per build rather than read from the repo.
|
|
44
|
+
*
|
|
45
|
+
* Skips (without failing) when the package didn't change, when the job is disabled, when no `04t`
|
|
46
|
+
* can be found, when the project authors no page objects, or when this exact version is already on
|
|
47
|
+
* the registry. Everything past those guards throws on failure: a missing page-object package would
|
|
48
|
+
* silently break every UI test pinned to that version.
|
|
49
|
+
*/
|
|
50
|
+
export declare function publishUtamPageObjects(options: PublishUtamPageObjectsOptions): Promise<PublishUtamPageObjectsResult>;
|
|
@@ -0,0 +1,283 @@
|
|
|
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 os from 'node:os';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { execa } from 'execa';
|
|
20
|
+
import { getDefaultPackageDirectory, readSfdxProject } from '@simplysf/simply-core';
|
|
21
|
+
import { runSfJson } from '../exec/sfCli.js';
|
|
22
|
+
import { appendToEnvFile } from '../env.js';
|
|
23
|
+
import { logger } from '../logger.js';
|
|
24
|
+
import { determineTagSuffix } from './createPackageVersion.js';
|
|
25
|
+
import { getSkipReason } from './skipGuard.js';
|
|
26
|
+
import { VersionTagFormat } from './versionTagFormat.js';
|
|
27
|
+
import { buildCompilerConfig, buildPackageManifest, buildProvenanceLine, findPageObjectSources, readUtamPluginConfig, resolveSubscriberPackageVersionId, toDistTag, toNpmVersion, toUtamCoreRange, toVersionTag, UTAM_PACKAGE_KEY, UTAM_VERSION_KEY, } from './utamPageObjects.js';
|
|
28
|
+
/** The default dotenv file, matching what `create-package-version`/`create-fallback-tag` write. */
|
|
29
|
+
const DEFAULT_ENV_FILE = 'subscriberPackageVersionId.env';
|
|
30
|
+
/** A run that did nothing, in the shape every guard returns. */
|
|
31
|
+
function skip() {
|
|
32
|
+
return { skipped: true, published: false };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether `spec` already resolves on the target registry.
|
|
36
|
+
*
|
|
37
|
+
* A failure is read as "not published" rather than propagated: the overwhelmingly common cause is
|
|
38
|
+
* the 404 for a version that doesn't exist yet, and any other cause (auth, network) will fail the
|
|
39
|
+
* publish immediately afterwards with a better message than this check could give.
|
|
40
|
+
*/
|
|
41
|
+
async function isAlreadyPublished(spec, cwd, registry) {
|
|
42
|
+
const args = ['view', spec, 'version'];
|
|
43
|
+
if (registry) {
|
|
44
|
+
args.push('--registry', registry);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const { stdout } = await execa('npm', args, { cwd });
|
|
48
|
+
return stdout.trim().length > 0;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Install the UTAM compiler into the staging directory and return the version installed alongside
|
|
56
|
+
* the entry point to run it with.
|
|
57
|
+
*
|
|
58
|
+
* Installed at run time rather than declared as a dependency of this plugin: the compiler pulls in
|
|
59
|
+
* rollup and the whole `@utam/*` family, which every `simply-cicd` user would otherwise carry for a
|
|
60
|
+
* feature most of them never enable. `lwc-jest` sets the same precedent.
|
|
61
|
+
*/
|
|
62
|
+
async function installCompiler(stagingDir, utamVersion, debug) {
|
|
63
|
+
logger.info(`Installing the UTAM compiler (utam@${utamVersion})...`);
|
|
64
|
+
await execa('npm', ['install', '--no-save', '--no-audit', '--no-fund', `utam@${utamVersion}`], {
|
|
65
|
+
cwd: stagingDir,
|
|
66
|
+
stdio: debug ? 'inherit' : 'pipe',
|
|
67
|
+
});
|
|
68
|
+
const moduleDir = path.join(stagingDir, 'node_modules', 'utam');
|
|
69
|
+
const manifest = JSON.parse(await fs.readFile(path.join(moduleDir, 'package.json'), 'utf8'));
|
|
70
|
+
const binRelative = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.utam;
|
|
71
|
+
if (!manifest.version || !binRelative) {
|
|
72
|
+
throw new Error(`The installed utam@${utamVersion} declares no version or no "utam" bin entry.`);
|
|
73
|
+
}
|
|
74
|
+
logger.info(`Installed utam@${manifest.version}.`);
|
|
75
|
+
return { version: manifest.version, entry: path.join(moduleDir, binRelative) };
|
|
76
|
+
}
|
|
77
|
+
/** Copy each `.utam.json` into the staged package, preserving its path under the package directory. */
|
|
78
|
+
async function stageSources(sources, pageObjectsRootDir, stagingDir) {
|
|
79
|
+
for (const source of sources) {
|
|
80
|
+
const destination = path.join(stagingDir, 'source', path.relative(pageObjectsRootDir, source));
|
|
81
|
+
// eslint-disable-next-line no-await-in-loop -- a handful of small files; ordering keeps the log readable
|
|
82
|
+
await fs.mkdir(path.dirname(destination), { recursive: true });
|
|
83
|
+
// eslint-disable-next-line no-await-in-loop -- as above
|
|
84
|
+
await fs.copyFile(source, destination);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve every input the publish needs, or decide there is nothing to publish.
|
|
89
|
+
*
|
|
90
|
+
* Holds the four guards that depend on reading something — the package version ID, the project,
|
|
91
|
+
* its page objects — so that the caller is left with the flow rather than the lookups.
|
|
92
|
+
*
|
|
93
|
+
* @returns `undefined` when a guard says to skip, having already logged why.
|
|
94
|
+
*/
|
|
95
|
+
async function resolveTarget(options) {
|
|
96
|
+
const envFile = options.envFile ?? DEFAULT_ENV_FILE;
|
|
97
|
+
const subscriberPackageVersionId = await resolveSubscriberPackageVersionId({
|
|
98
|
+
flagValue: options.subscriberPackageVersionId,
|
|
99
|
+
envFile,
|
|
100
|
+
});
|
|
101
|
+
if (!subscriberPackageVersionId) {
|
|
102
|
+
logger.warn(`No package version ID given, in the environment, or in ${envFile}. ` +
|
|
103
|
+
'This build created no package version, so there are no page objects to publish. Skipping.');
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const sfdxProjectJson = await readSfdxProject();
|
|
107
|
+
const defaultPackageDir = getDefaultPackageDirectory(sfdxProjectJson);
|
|
108
|
+
if (!defaultPackageDir?.path) {
|
|
109
|
+
throw new Error('A default package directory with a `path` must be specified in sfdx-project.json.');
|
|
110
|
+
}
|
|
111
|
+
const pageObjectsRootDir = path.resolve(defaultPackageDir.path);
|
|
112
|
+
const sources = await findPageObjectSources(pageObjectsRootDir);
|
|
113
|
+
if (sources.length === 0) {
|
|
114
|
+
logger.info(`No UTAM page objects found under ${defaultPackageDir.path}. Skipping.`);
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
logger.info(`Found ${sources.length} UTAM page object(s) under ${defaultPackageDir.path}.`);
|
|
118
|
+
const versionTagFormat = VersionTagFormat.fromProject(sfdxProjectJson);
|
|
119
|
+
const utamPluginConfig = readUtamPluginConfig(sfdxProjectJson);
|
|
120
|
+
const npmPackageName = options.npmPackageName ?? utamPluginConfig.packageName;
|
|
121
|
+
if (!npmPackageName) {
|
|
122
|
+
throw new Error('No npm package name to publish under. Pass --npm-package-name, or set `plugins.simply.utam.packageName` in sfdx-project.json.');
|
|
123
|
+
}
|
|
124
|
+
const { result: report } = await runSfJson([
|
|
125
|
+
'package',
|
|
126
|
+
'version',
|
|
127
|
+
'report',
|
|
128
|
+
'--package',
|
|
129
|
+
subscriberPackageVersionId,
|
|
130
|
+
'--target-dev-hub',
|
|
131
|
+
options.packagingDevhub,
|
|
132
|
+
'--json',
|
|
133
|
+
]);
|
|
134
|
+
if (!report.Version) {
|
|
135
|
+
throw new Error(`Could not read a version number for ${subscriberPackageVersionId} from its package version report.`);
|
|
136
|
+
}
|
|
137
|
+
const tagSuffix = determineTagSuffix(defaultPackageDir.branch, options.ciCommitRefName, options.packageReleaseBranchPrefix);
|
|
138
|
+
return {
|
|
139
|
+
subscriberPackageVersionId,
|
|
140
|
+
pageObjectsRootDir,
|
|
141
|
+
sources,
|
|
142
|
+
utamPluginConfig,
|
|
143
|
+
npmPackageName,
|
|
144
|
+
salesforcePackageName: report.Package2Name ?? defaultPackageDir.package ?? 'package',
|
|
145
|
+
salesforceVersion: report.Version,
|
|
146
|
+
version: toNpmVersion(report.Version, tagSuffix),
|
|
147
|
+
distTag: options.npmDistTag ?? toDistTag(tagSuffix),
|
|
148
|
+
versionTag: toVersionTag(report.Version, tagSuffix, versionTagFormat),
|
|
149
|
+
commitSha: report.Tag,
|
|
150
|
+
pipelineUrl: report.Description,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Fill the staging directory with a publishable package: the compiler, its generated config, the
|
|
155
|
+
* compiled output, the source JSON, and the manifest describing all of it.
|
|
156
|
+
*/
|
|
157
|
+
async function buildStagedPackage(stagingDir, target, options) {
|
|
158
|
+
const compiler = await installCompiler(stagingDir, options.utamVersion ?? '^3', options.debug ?? false);
|
|
159
|
+
const baseConfig = target.utamPluginConfig.compilerConfig
|
|
160
|
+
? JSON.parse(await fs.readFile(target.utamPluginConfig.compilerConfig, 'utf8'))
|
|
161
|
+
: undefined;
|
|
162
|
+
const compilerConfigPath = path.join(stagingDir, 'utam.config.json');
|
|
163
|
+
await fs.writeFile(compilerConfigPath, JSON.stringify(buildCompilerConfig({
|
|
164
|
+
pageObjectsRootDir: target.pageObjectsRootDir,
|
|
165
|
+
stagingDir,
|
|
166
|
+
npmPackageName: target.npmPackageName,
|
|
167
|
+
version: target.version,
|
|
168
|
+
copyright: buildProvenanceLine(target.salesforcePackageName, target.salesforceVersion, target.subscriberPackageVersionId),
|
|
169
|
+
alias: target.utamPluginConfig.alias,
|
|
170
|
+
baseConfig,
|
|
171
|
+
}), null, 2));
|
|
172
|
+
logger.info('Compiling page objects...');
|
|
173
|
+
// Run the installed compiler's entry point with this same Node rather than going through npx,
|
|
174
|
+
// which would be free to reach the network for a package that is already sitting right here.
|
|
175
|
+
await execa(process.execPath, [compiler.entry, '-c', compilerConfigPath], {
|
|
176
|
+
cwd: stagingDir,
|
|
177
|
+
stdio: options.debug ? 'inherit' : 'pipe',
|
|
178
|
+
});
|
|
179
|
+
await stageSources(target.sources, target.pageObjectsRootDir, stagingDir);
|
|
180
|
+
await fs.writeFile(path.join(stagingDir, 'package.json'), `${JSON.stringify(buildPackageManifest({
|
|
181
|
+
npmPackageName: target.npmPackageName,
|
|
182
|
+
version: target.version,
|
|
183
|
+
salesforcePackageName: target.salesforcePackageName,
|
|
184
|
+
salesforceVersion: target.salesforceVersion,
|
|
185
|
+
subscriberPackageVersionId: target.subscriberPackageVersionId,
|
|
186
|
+
versionTag: target.versionTag,
|
|
187
|
+
commitSha: target.commitSha,
|
|
188
|
+
pipelineUrl: target.pipelineUrl,
|
|
189
|
+
utamCoreRange: toUtamCoreRange(compiler.version),
|
|
190
|
+
projectPeerDependencies: target.utamPluginConfig.peerDependencies,
|
|
191
|
+
}), null, 2)}\n`);
|
|
192
|
+
}
|
|
193
|
+
/** `npm publish` the staged package, targeting the registry and access level the pipeline asked for. */
|
|
194
|
+
async function publishStaged(stagingDir, distTag, options) {
|
|
195
|
+
const args = ['publish', '--tag', distTag];
|
|
196
|
+
if (options.npmRegistry) {
|
|
197
|
+
args.push('--registry', options.npmRegistry);
|
|
198
|
+
}
|
|
199
|
+
if (options.npmAccess) {
|
|
200
|
+
args.push('--access', options.npmAccess);
|
|
201
|
+
}
|
|
202
|
+
await execa('npm', args, { cwd: stagingDir, stdio: options.debug ? 'inherit' : 'pipe' });
|
|
203
|
+
}
|
|
204
|
+
/** `npm pack` the staged package and copy the tarball where a CI job can collect it as an artifact. */
|
|
205
|
+
async function packTarball(stagingDir) {
|
|
206
|
+
const { stdout } = await execa('npm', ['pack', '--json'], { cwd: stagingDir });
|
|
207
|
+
const packed = JSON.parse(stdout);
|
|
208
|
+
const filename = packed[0]?.filename;
|
|
209
|
+
if (!filename) {
|
|
210
|
+
throw new Error('npm pack did not report a tarball filename.');
|
|
211
|
+
}
|
|
212
|
+
const destination = path.join(process.cwd(), filename);
|
|
213
|
+
await fs.copyFile(path.join(stagingDir, filename), destination);
|
|
214
|
+
return destination;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Compile the project's UTAM page objects for one package version and publish them as an npm
|
|
218
|
+
* package whose version is derived from the Salesforce version number.
|
|
219
|
+
*
|
|
220
|
+
* Runs after `create-package-version`, whose `04t` it takes as input, so that every Unlocked
|
|
221
|
+
* Package version has a corresponding page-object package a UI-test suite can pin to. See
|
|
222
|
+
* `docs/design/0037-utam-page-objects-publish.md` for the reasoning, particularly the version
|
|
223
|
+
* mapping and why the compiler config is generated per build rather than read from the repo.
|
|
224
|
+
*
|
|
225
|
+
* Skips (without failing) when the package didn't change, when the job is disabled, when no `04t`
|
|
226
|
+
* can be found, when the project authors no page objects, or when this exact version is already on
|
|
227
|
+
* the registry. Everything past those guards throws on failure: a missing page-object package would
|
|
228
|
+
* silently break every UI test pinned to that version.
|
|
229
|
+
*/
|
|
230
|
+
export async function publishUtamPageObjects(options) {
|
|
231
|
+
const skipReason = getSkipReason('publish-utam-page-objects');
|
|
232
|
+
if (skipReason) {
|
|
233
|
+
logger.warn(skipReason);
|
|
234
|
+
return skip();
|
|
235
|
+
}
|
|
236
|
+
if (options.disabled) {
|
|
237
|
+
logger.warn('publish-utam-page-objects is disabled. Skipping.');
|
|
238
|
+
return skip();
|
|
239
|
+
}
|
|
240
|
+
const target = await resolveTarget(options);
|
|
241
|
+
if (!target) {
|
|
242
|
+
return skip();
|
|
243
|
+
}
|
|
244
|
+
const { npmPackageName, version, distTag } = target;
|
|
245
|
+
const outFile = options.out ?? DEFAULT_ENV_FILE;
|
|
246
|
+
const publishedKeys = { [UTAM_PACKAGE_KEY]: npmPackageName, [UTAM_VERSION_KEY]: version };
|
|
247
|
+
logger.info(`Publishing ${npmPackageName}@${version} (dist-tag ${distTag}) for ${target.salesforceVersion}.`);
|
|
248
|
+
// Never inside the repo: the checkout is what gets compiled, and a generated package.json next to
|
|
249
|
+
// sfdx-project.json would be picked up by anything else the job runs.
|
|
250
|
+
const stagingDir = await fs.mkdtemp(path.join(os.tmpdir(), 'simply-cicd-utam-'));
|
|
251
|
+
if (options.debug) {
|
|
252
|
+
logger.debug(`Staging directory: ${stagingDir}`);
|
|
253
|
+
}
|
|
254
|
+
// Registry auth is the job's to set up, not this command's. Because npm runs from the staging
|
|
255
|
+
// directory, it sees user, global, and environment config, but never the repo's own .npmrc.
|
|
256
|
+
try {
|
|
257
|
+
if (!options.dryRun &&
|
|
258
|
+
(await isAlreadyPublished(`${npmPackageName}@${version}`, stagingDir, options.npmRegistry))) {
|
|
259
|
+
logger.info(`${npmPackageName}@${version} is already published. Skipping.`);
|
|
260
|
+
appendToEnvFile(outFile, publishedKeys);
|
|
261
|
+
return { skipped: true, published: false, alreadyPublished: true, packageName: npmPackageName, version, distTag };
|
|
262
|
+
}
|
|
263
|
+
await buildStagedPackage(stagingDir, target, options);
|
|
264
|
+
if (options.dryRun) {
|
|
265
|
+
const tarball = await packTarball(stagingDir);
|
|
266
|
+
logger.success(`Dry run: packed ${npmPackageName}@${version} to ${tarball}. Nothing was published.`);
|
|
267
|
+
return { skipped: false, published: false, packageName: npmPackageName, version, distTag, tarball };
|
|
268
|
+
}
|
|
269
|
+
await publishStaged(stagingDir, distTag, options);
|
|
270
|
+
logger.success(`Published ${npmPackageName}@${version} (dist-tag ${distTag}).`);
|
|
271
|
+
appendToEnvFile(outFile, publishedKeys);
|
|
272
|
+
return { skipped: false, published: true, packageName: npmPackageName, version, distTag };
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
if (options.debug) {
|
|
276
|
+
logger.debug(`Leaving the staging directory in place for inspection: ${stagingDir}`);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
await fs.rm(stagingDir, { recursive: true, force: true });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=publishUtamPageObjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishUtamPageObjects.js","sourceRoot":"","sources":["../../src/build/publishUtamPageObjects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,iCAAiC,EACjC,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAE9B,mGAAmG;AACnG,MAAM,gBAAgB,GAAG,gCAAgC,CAAC;AAoD1D,gEAAgE;AAChE,SAAS,IAAI;IACX,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;A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Aa,cAAc,IAAI,OAAO,cAAc,OAAO,IAAI,CAAC,CAAC;QAChF,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAExC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC5F,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,CAAC,KAAK,CAAC,0DAA0D,UAAU,EAAE,CAAC,CAAC;QACvF,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PushScratchOptions = {
|
|
2
|
+
/** Required only when the scratch org's Dev Hub was JWT-authenticated (no refresh token available). */
|
|
3
|
+
jwtKeyFile?: string;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
ignoreWarnings?: boolean;
|
|
6
|
+
scratchOrgSourceDir?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Authenticates to the scratch org, strips ECA-related metadata, and pushes source to it. */
|
|
9
|
+
export declare function pushToScratch(options: PushScratchOptions): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 { execa } from 'execa';
|
|
17
|
+
import { getDefaultPackageDirectory, readSfdxProject } from '@simplysf/simply-core';
|
|
18
|
+
import { runSf } from '../exec/sfCli.js';
|
|
19
|
+
import { logger } from '../logger.js';
|
|
20
|
+
import { ensureScratchOrgSession } from './scratchOrgAuth.js';
|
|
21
|
+
import { readScratchOrgInfo } from './scratchOrgInfo.js';
|
|
22
|
+
const INCOMPATIBLE_METADATA_PATTERNS = [
|
|
23
|
+
'*.eca-meta.xml',
|
|
24
|
+
'*.ecaGlblOauth-meta.xml',
|
|
25
|
+
'*.ecaOauth-meta.xml',
|
|
26
|
+
'*.ecaOauthPlcy-meta.xml',
|
|
27
|
+
'*.ecaPlcy-meta.xml',
|
|
28
|
+
];
|
|
29
|
+
async function removeIncompatibleMetadata() {
|
|
30
|
+
logger.info('Removing incompatible metadata before push...');
|
|
31
|
+
for (const pattern of INCOMPATIBLE_METADATA_PATTERNS) {
|
|
32
|
+
// eslint-disable-next-line no-await-in-loop -- deletions must not race each other on the same tree
|
|
33
|
+
await execa('find', [process.cwd(), '-type', 'f', '-name', pattern, '-delete']);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Authenticates to the scratch org, strips ECA-related metadata, and pushes source to it. */
|
|
37
|
+
export async function pushToScratch(options) {
|
|
38
|
+
logger.info('Pushing source to scratch org...');
|
|
39
|
+
const scratchOrgInfo = await readScratchOrgInfo();
|
|
40
|
+
await ensureScratchOrgSession(scratchOrgInfo.authFields, {
|
|
41
|
+
jwtKeyFile: options.jwtKeyFile,
|
|
42
|
+
setDefault: true,
|
|
43
|
+
debug: options.debug,
|
|
44
|
+
});
|
|
45
|
+
await removeIncompatibleMetadata();
|
|
46
|
+
const pushArgs = ['project', 'deploy', 'start', '--ignore-conflicts', '--wait', '120'];
|
|
47
|
+
if (options.ignoreWarnings) {
|
|
48
|
+
pushArgs.push('--ignore-warnings');
|
|
49
|
+
}
|
|
50
|
+
if (options.scratchOrgSourceDir) {
|
|
51
|
+
pushArgs.push('--source-dir', options.scratchOrgSourceDir);
|
|
52
|
+
const seedMetadataDir = getDefaultPackageDirectory(await readSfdxProject())?.seedMetadata?.path;
|
|
53
|
+
if (seedMetadataDir) {
|
|
54
|
+
pushArgs.push('--source-dir', seedMetadataDir);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await runSf(pushArgs, { stdio: 'inherit' });
|
|
58
|
+
logger.success('Source pushed to scratch org.');
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=pushScratch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pushScratch.js","sourceRoot":"","sources":["../../src/build/pushScratch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,8BAA8B,GAAG;IACrC,gBAAgB;IAChB,yBAAyB;IACzB,qBAAqB;IACrB,yBAAyB;IACzB,oBAAoB;CACrB,CAAC;AAEF,KAAK,UAAU,0BAA0B;IACvC,MAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC7D,KAAK,MAAM,OAAO,IAAI,8BAA8B,EAAE,CAAC;QACrD,mGAAmG;QACnG,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,G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sureScratchOrgSessionOptions = {
|
|
3
|
+
/** Required only when the scratch org's Dev Hub was JWT-authenticated (no refresh token available). */
|
|
4
|
+
jwtKeyFile?: string;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
setDefault?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Ensures the scratch org recorded in `SCRATCH_ORG_INFO.json` has a live session, using whichever
|
|
10
|
+
* renewable credential it actually has.
|
|
11
|
+
*
|
|
12
|
+
* A scratch org whose Dev Hub authenticated via web/SFDX auth-url gets its own `refreshToken` at
|
|
13
|
+
* creation time (Salesforce's OAuth "web server" flow always returns one) — that's used directly
|
|
14
|
+
* via `@salesforce/core`, no shell-out. A JWT-authenticated Dev Hub never produces a refresh token
|
|
15
|
+
* (JWT bearer grants don't have one), so that case still falls back to the existing
|
|
16
|
+
* `authenticateOrg()` JWT re-auth.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ensureScratchOrgSession(authFields: ScratchOrgInfo['authFields'], options: EnsureScratchOrgSessionOptions): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { AuthInfo, SfError } from '@salesforce/core';
|
|
17
|
+
import { authenticateOrg } from '../sfAuth.js';
|
|
18
|
+
/**
|
|
19
|
+
* Ensures the scratch org recorded in `SCRATCH_ORG_INFO.json` has a live session, using whichever
|
|
20
|
+
* renewable credential it actually has.
|
|
21
|
+
*
|
|
22
|
+
* A scratch org whose Dev Hub authenticated via web/SFDX auth-url gets its own `refreshToken` at
|
|
23
|
+
* creation time (Salesforce's OAuth "web server" flow always returns one) — that's used directly
|
|
24
|
+
* via `@salesforce/core`, no shell-out. A JWT-authenticated Dev Hub never produces a refresh token
|
|
25
|
+
* (JWT bearer grants don't have one), so that case still falls back to the existing
|
|
26
|
+
* `authenticateOrg()` JWT re-auth.
|
|
27
|
+
*/
|
|
28
|
+
export async function ensureScratchOrgSession(authFields, options) {
|
|
29
|
+
const { username, clientId, instanceUrl, refreshToken, clientSecret } = authFields;
|
|
30
|
+
if (refreshToken) {
|
|
31
|
+
const authInfo = await AuthInfo.create({
|
|
32
|
+
oauth2Options: { clientId, clientSecret, refreshToken, loginUrl: instanceUrl },
|
|
33
|
+
});
|
|
34
|
+
await authInfo.save();
|
|
35
|
+
if (options.setDefault) {
|
|
36
|
+
await authInfo.handleAliasAndDefaultSettings({ setDefault: true, setDefaultDevHub: false });
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!options.jwtKeyFile) {
|
|
41
|
+
throw new SfError(`No refresh token available for org ${username} and no --jwt-key-file was provided; cannot re-authenticate.`, 'ScratchOrgReauthError');
|
|
42
|
+
}
|
|
43
|
+
await authenticateOrg({
|
|
44
|
+
username,
|
|
45
|
+
clientId,
|
|
46
|
+
instanceUrl,
|
|
47
|
+
jwtKeyFile: options.jwtKeyFile,
|
|
48
|
+
setDefault: options.setDefault,
|
|
49
|
+
debug: options.debug,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=scratchOrgAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratchOrgAuth.js","sourceRoot":"","sources":["../../src/build/scratchOrgAuth.ts"],"names":[],"mappings":"AAAA;;;;;;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?: string;
|
|
7
|
+
/** Present when the owning Dev Hub wasn't JWT-authenticated. */
|
|
8
|
+
refreshToken?: string;
|
|
9
|
+
/** Present alongside `refreshToken` for a custom connected app. */
|
|
10
|
+
clientSecret?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** Reads and parses `SCRATCH_ORG_INFO.json` (written by `build create-scratch`) from the current directory. */
|
|
14
|
+
export declare function readScratchOrgInfo(): Promise<ScratchOrgInfo>;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
/** Reads and parses `SCRATCH_ORG_INFO.json` (written by `build create-scratch`) from the current directory. */
|
|
18
|
+
export async function readScratchOrgInfo() {
|
|
19
|
+
return JSON.parse(await fs.readFile('SCRATCH_ORG_INFO.json', 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=scratchOrgInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratchOrgInfo.js","sourceRoot":"","sources":["../../src/build/scratchOrgInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAezC,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAmB,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a warning message (and thus "should skip") if `job` should be skipped given the current
|
|
3
|
+
* `PACKAGE_CHANGED` environment variable set by `determine-package-changes` earlier in the
|
|
4
|
+
* pipeline: scratch-org-lifecycle jobs skip when nothing changed, `create-fallback-tag` skips when
|
|
5
|
+
* something did (since a real package version will be created instead). Returns `undefined`
|
|
6
|
+
* (don't skip) otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSkipReason(job: string): string | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/** Jobs that only make sense to run when the package actually changed. */
|
|
17
|
+
const PACKAGE_CHANGED_GATED_JOBS = new Set([
|
|
18
|
+
'create-scratch',
|
|
19
|
+
'install-dependencies',
|
|
20
|
+
'push-scratch',
|
|
21
|
+
'test-scratch',
|
|
22
|
+
'delete-scratch',
|
|
23
|
+
'create-package-version',
|
|
24
|
+
'publish-utam-page-objects',
|
|
25
|
+
]);
|
|
26
|
+
/**
|
|
27
|
+
* Returns a warning message (and thus "should skip") if `job` should be skipped given the current
|
|
28
|
+
* `PACKAGE_CHANGED` environment variable set by `determine-package-changes` earlier in the
|
|
29
|
+
* pipeline: scratch-org-lifecycle jobs skip when nothing changed, `create-fallback-tag` skips when
|
|
30
|
+
* something did (since a real package version will be created instead). Returns `undefined`
|
|
31
|
+
* (don't skip) otherwise.
|
|
32
|
+
*/
|
|
33
|
+
export function getSkipReason(job) {
|
|
34
|
+
if (PACKAGE_CHANGED_GATED_JOBS.has(job) && process.env.PACKAGE_CHANGED === 'FALSE') {
|
|
35
|
+
return `No package changes detected (PACKAGE_CHANGED=FALSE). Skipping job: ${job}`;
|
|
36
|
+
}
|
|
37
|
+
if (job === 'create-fallback-tag' && process.env.PACKAGE_CHANGED === 'TRUE') {
|
|
38
|
+
return 'Package changes detected (PACKAGE_CHANGED=TRUE). Skipping fallback tag creation.';
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=skipGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skipGuard.js","sourceRoot":"","sources":["../../src/build/skipGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,0EAA0E;AAC1E,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IACzC,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,wBAAwB;IACxB,2BAA2B;CAC5B,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,OAAO,EAAE,CAAC;QACnF,OAAO,sEAAsE,GAAG,EAAE,CAAC;IACrF,CAAC;IAED,IAAI,GAAG,KAAK,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM,EAAE,CAAC;QAC5E,OAAO,kFAAkF,CAAC;IAC5F,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type RunScratchApexTestsOptions = {
|
|
2
|
+
/** Required only when the scratch org's Dev Hub was JWT-authenticated (no refresh token available). */
|
|
3
|
+
jwtKeyFile?: string;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
/** Skips just the Apex test run, independent of the job-level --disabled flag. */
|
|
6
|
+
disableApexTests?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Authenticates to the scratch org and runs its Apex tests.
|
|
10
|
+
*
|
|
11
|
+
* The original `--disable-apex-tests` flag was checked against the wrong option name internally
|
|
12
|
+
* (it re-checked the generic `--disabled` flag), making it a no-op. Here it actually gates the
|
|
13
|
+
* test run.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runScratchApexTests(options: RunScratchApexTestsOptions): Promise<void>;
|