@simplysf/simply-cicd-core 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +32 -3
  2. package/lib/build/checkPermissionSets.d.ts +22 -0
  3. package/lib/build/checkPermissionSets.js +102 -0
  4. package/lib/build/checkPermissionSets.js.map +1 -0
  5. package/lib/build/cleanupScratchOrgs.d.ts +6 -0
  6. package/lib/build/cleanupScratchOrgs.js +91 -0
  7. package/lib/build/cleanupScratchOrgs.js.map +1 -0
  8. package/lib/build/createFallbackTag.d.ts +24 -0
  9. package/lib/build/createFallbackTag.js +147 -0
  10. package/lib/build/createFallbackTag.js.map +1 -0
  11. package/lib/build/createPackageVersion.d.ts +42 -0
  12. package/lib/build/createPackageVersion.js +191 -0
  13. package/lib/build/createPackageVersion.js.map +1 -0
  14. package/lib/build/createScratchOrg.d.ts +14 -0
  15. package/lib/build/createScratchOrg.js +182 -0
  16. package/lib/build/createScratchOrg.js.map +1 -0
  17. package/lib/build/deleteScratchOrg.d.ts +13 -0
  18. package/lib/build/deleteScratchOrg.js +62 -0
  19. package/lib/build/deleteScratchOrg.js.map +1 -0
  20. package/lib/build/deltaRunner.d.ts +73 -0
  21. package/lib/build/deltaRunner.js +109 -0
  22. package/lib/build/deltaRunner.js.map +1 -0
  23. package/lib/build/determinePackageChanges.d.ts +11 -0
  24. package/lib/build/determinePackageChanges.js +90 -0
  25. package/lib/build/determinePackageChanges.js.map +1 -0
  26. package/lib/build/devHubs.d.ts +12 -0
  27. package/lib/build/devHubs.js +42 -0
  28. package/lib/build/devHubs.js.map +1 -0
  29. package/lib/build/flexipageDelta.d.ts +18 -0
  30. package/lib/build/flexipageDelta.js +35 -0
  31. package/lib/build/flexipageDelta.js.map +1 -0
  32. package/lib/build/flowDelta.d.ts +17 -0
  33. package/lib/build/flowDelta.js +34 -0
  34. package/lib/build/flowDelta.js.map +1 -0
  35. package/lib/build/installDependencies.d.ts +10 -0
  36. package/lib/build/installDependencies.js +39 -0
  37. package/lib/build/installDependencies.js.map +1 -0
  38. package/lib/build/lwcJest.d.ts +25 -0
  39. package/lib/build/lwcJest.js +126 -0
  40. package/lib/build/lwcJest.js.map +1 -0
  41. package/lib/build/publishUtamPageObjects.d.ts +50 -0
  42. package/lib/build/publishUtamPageObjects.js +274 -0
  43. package/lib/build/publishUtamPageObjects.js.map +1 -0
  44. package/lib/build/pushScratch.d.ts +9 -0
  45. package/lib/build/pushScratch.js +60 -0
  46. package/lib/build/pushScratch.js.map +1 -0
  47. package/lib/build/scratchOrgAuth.d.ts +18 -0
  48. package/lib/build/scratchOrgAuth.js +52 -0
  49. package/lib/build/scratchOrgAuth.js.map +1 -0
  50. package/lib/build/scratchOrgInfo.d.ts +14 -0
  51. package/lib/build/scratchOrgInfo.js +21 -0
  52. package/lib/build/scratchOrgInfo.js.map +1 -0
  53. package/lib/build/skipGuard.d.ts +8 -0
  54. package/lib/build/skipGuard.js +42 -0
  55. package/lib/build/skipGuard.js.map +1 -0
  56. package/lib/build/testScratch.d.ts +15 -0
  57. package/lib/build/testScratch.js +42 -0
  58. package/lib/build/testScratch.js.map +1 -0
  59. package/lib/build/utamPageObjects.d.ts +143 -0
  60. package/lib/build/utamPageObjects.js +258 -0
  61. package/lib/build/utamPageObjects.js.map +1 -0
  62. package/lib/build/versionTagFormat.d.ts +57 -0
  63. package/lib/build/versionTagFormat.js +194 -0
  64. package/lib/build/versionTagFormat.js.map +1 -0
  65. package/lib/config/defaultDeploymentPlugins.d.ts +2 -0
  66. package/lib/config/defaultDeploymentPlugins.js +18 -0
  67. package/lib/config/defaultDeploymentPlugins.js.map +1 -0
  68. package/lib/config/trustedPlugins.d.ts +2 -0
  69. package/lib/config/trustedPlugins.js +18 -0
  70. package/lib/config/trustedPlugins.js.map +1 -0
  71. package/lib/deploy/deployCommon.d.ts +105 -0
  72. package/lib/deploy/deployCommon.js +358 -0
  73. package/lib/deploy/deployCommon.js.map +1 -0
  74. package/lib/deploy/deployHappySoup.d.ts +56 -0
  75. package/lib/deploy/deployHappySoup.js +159 -0
  76. package/lib/deploy/deployHappySoup.js.map +1 -0
  77. package/lib/deploy/deployProject.d.ts +27 -0
  78. package/lib/deploy/deployProject.js +114 -0
  79. package/lib/deploy/deployProject.js.map +1 -0
  80. package/lib/deploy/runDeployStage.d.ts +16 -0
  81. package/lib/deploy/runDeployStage.js +65 -0
  82. package/lib/deploy/runDeployStage.js.map +1 -0
  83. package/lib/deploy/stageOptions.d.ts +49 -0
  84. package/lib/deploy/stageOptions.js +70 -0
  85. package/lib/deploy/stageOptions.js.map +1 -0
  86. package/lib/deploy/validate.d.ts +11 -0
  87. package/lib/deploy/validate.js +54 -0
  88. package/lib/deploy/validate.js.map +1 -0
  89. package/lib/env.d.ts +9 -0
  90. package/lib/env.js +47 -0
  91. package/lib/env.js.map +1 -0
  92. package/lib/exec/sfCli.d.ts +27 -0
  93. package/lib/exec/sfCli.js +50 -0
  94. package/lib/exec/sfCli.js.map +1 -0
  95. package/lib/flags/env.d.ts +44 -0
  96. package/lib/flags/env.js +81 -0
  97. package/lib/flags/env.js.map +1 -0
  98. package/lib/git.d.ts +32 -0
  99. package/lib/git.js +106 -0
  100. package/lib/git.js.map +1 -0
  101. package/lib/happySoup/resolveOriginProject.d.ts +22 -0
  102. package/lib/happySoup/resolveOriginProject.js +61 -0
  103. package/lib/happySoup/resolveOriginProject.js.map +1 -0
  104. package/lib/index.d.ts +52 -0
  105. package/lib/index.js +64 -2
  106. package/lib/index.js.map +1 -1
  107. package/lib/logger.d.ts +10 -0
  108. package/lib/logger.js +33 -0
  109. package/lib/logger.js.map +1 -0
  110. package/lib/notify/buildNotification.d.ts +53 -0
  111. package/lib/notify/buildNotification.js +176 -0
  112. package/lib/notify/buildNotification.js.map +1 -0
  113. package/lib/notify/getCommitStories.d.ts +30 -0
  114. package/lib/notify/getCommitStories.js +70 -0
  115. package/lib/notify/getCommitStories.js.map +1 -0
  116. package/lib/notify/getRemoteCommitStories.d.ts +10 -0
  117. package/lib/notify/getRemoteCommitStories.js +45 -0
  118. package/lib/notify/getRemoteCommitStories.js.map +1 -0
  119. package/lib/notify/happySoupNotification.d.ts +26 -0
  120. package/lib/notify/happySoupNotification.js +140 -0
  121. package/lib/notify/happySoupNotification.js.map +1 -0
  122. package/lib/notify/projectNotification.d.ts +46 -0
  123. package/lib/notify/projectNotification.js +167 -0
  124. package/lib/notify/projectNotification.js.map +1 -0
  125. package/lib/notify/renderTemplate.d.ts +3 -0
  126. package/lib/notify/renderTemplate.js +24 -0
  127. package/lib/notify/renderTemplate.js.map +1 -0
  128. package/lib/notify/sendNotification.d.ts +2 -0
  129. package/lib/notify/sendNotification.js +50 -0
  130. package/lib/notify/sendNotification.js.map +1 -0
  131. package/lib/notify/templates.d.ts +13 -0
  132. package/lib/notify/templates.js +118 -0
  133. package/lib/notify/templates.js.map +1 -0
  134. package/lib/schemas/deployConfig.d.ts +25 -0
  135. package/lib/schemas/deployConfig.js +55 -0
  136. package/lib/schemas/deployConfig.js.map +1 -0
  137. package/lib/schemas/deployProgress.d.ts +33 -0
  138. package/lib/schemas/deployProgress.js +46 -0
  139. package/lib/schemas/deployProgress.js.map +1 -0
  140. package/lib/schemas/deployRules.d.ts +34 -0
  141. package/lib/schemas/deployRules.js +40 -0
  142. package/lib/schemas/deployRules.js.map +1 -0
  143. package/lib/sfApex.d.ts +22 -0
  144. package/lib/sfApex.js +169 -0
  145. package/lib/sfApex.js.map +1 -0
  146. package/lib/sfAuth.d.ts +19 -0
  147. package/lib/sfAuth.js +78 -0
  148. package/lib/sfAuth.js.map +1 -0
  149. package/lib/sfConfig.d.ts +23 -0
  150. package/lib/sfConfig.js +82 -0
  151. package/lib/sfConfig.js.map +1 -0
  152. package/lib/sfOrg.d.ts +13 -0
  153. package/lib/sfOrg.js +39 -0
  154. package/lib/sfOrg.js.map +1 -0
  155. package/lib/sfPackages.d.ts +63 -0
  156. package/lib/sfPackages.js +185 -0
  157. package/lib/sfPackages.js.map +1 -0
  158. package/lib/sfPlugins.d.ts +11 -0
  159. package/lib/sfPlugins.js +134 -0
  160. package/lib/sfPlugins.js.map +1 -0
  161. package/lib/sfdxDependabot/dependabotRun.d.ts +95 -0
  162. package/lib/sfdxDependabot/dependabotRun.js +287 -0
  163. package/lib/sfdxDependabot/dependabotRun.js.map +1 -0
  164. package/lib/sfdxDependabot/updater.d.ts +14 -0
  165. package/lib/sfdxDependabot/updater.js +94 -0
  166. package/lib/sfdxDependabot/updater.js.map +1 -0
  167. package/package.json +16 -4
@@ -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
+ import { logger } from '../logger.js';
17
+ import { runApexTests as runApexTestsCommon } from '../sfApex.js';
18
+ import { ensureScratchOrgSession } from './scratchOrgAuth.js';
19
+ import { readScratchOrgInfo } from './scratchOrgInfo.js';
20
+ /**
21
+ * Authenticates to the scratch org and runs its Apex tests.
22
+ *
23
+ * The original `--disable-apex-tests` flag was checked against the wrong option name internally
24
+ * (it re-checked the generic `--disabled` flag), making it a no-op. Here it actually gates the
25
+ * test run.
26
+ */
27
+ export async function runScratchApexTests(options) {
28
+ if (options.disableApexTests) {
29
+ logger.warn('Apex tests are disabled via --disable-apex-tests. Skipping.');
30
+ return;
31
+ }
32
+ logger.info('Authenticating to scratch org for tests...');
33
+ const scratchOrgInfo = await readScratchOrgInfo();
34
+ await ensureScratchOrgSession(scratchOrgInfo.authFields, {
35
+ jwtKeyFile: options.jwtKeyFile,
36
+ setDefault: true,
37
+ debug: options.debug,
38
+ });
39
+ // A default org is now set, so no alias is needed.
40
+ await runApexTestsCommon({ testLevel: 'RunLocalTests', wait: '60' });
41
+ }
42
+ //# sourceMappingURL=testScratch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testScratch.js","sourceRoot":"","sources":["../../src/build/testScratch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAUzD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAmC;IAC3E,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAClD,MAAM,uBAAuB,CAAC,cAAc,CAAC,UAAU,EAAE;QACvD,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;IAEH,mDAAmD;IACnD,MAAM,kBAAkB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,143 @@
1
+ import { type SfdxProject } from '@simplysf/simply-core';
2
+ import { VersionTagFormat } from './versionTagFormat.js';
3
+ /** The dotenv key `create-package-version` and `create-fallback-tag` both write their `04t` under. */
4
+ export declare const SUBSCRIBER_PACKAGE_VERSION_ID_KEY = "SUBSCRIBER_PACKAGE_VERSION_ID";
5
+ /** The dotenv keys this feature writes, for a downstream UI-test job to install by. */
6
+ export declare const UTAM_PACKAGE_KEY = "UTAM_PAGE_OBJECTS_PACKAGE";
7
+ export declare const UTAM_VERSION_KEY = "UTAM_PAGE_OBJECTS_VERSION";
8
+ /** The compiler's own default mask, restated so the generated config never depends on it drifting. */
9
+ export declare const PAGE_OBJECTS_FILE_MASK: string[];
10
+ /** `plugins.simply.utam` in `sfdx-project.json`. Every field is optional. */
11
+ export type UtamPluginConfig = {
12
+ /** npm package name to publish under. Required unless `--npm-package-name` is passed. */
13
+ packageName?: string;
14
+ /** UTAM compiler type-alias map, passed through to the generated compiler config. */
15
+ alias?: Record<string, string>;
16
+ /** Peer dependencies to merge into the generated package, e.g. `salesforce-pageobjects`. */
17
+ peerDependencies?: Record<string, string>;
18
+ /** Path to a compiler config whose keys the command doesn't own (`profiles`, `lint`, …). */
19
+ compilerConfig?: string;
20
+ };
21
+ /** @returns `plugins.simply.utam`, or an empty object when the project declares none. */
22
+ export declare function readUtamPluginConfig(project: SfdxProject): UtamPluginConfig;
23
+ /**
24
+ * Reduce a git tag suffix to something semver accepts as a prerelease identifier.
25
+ *
26
+ * Semver's prerelease alphabet is `[0-9A-Za-z-]`; a branch name's `/` and `.` are the common
27
+ * offenders, so each run of anything else collapses to a single hyphen.
28
+ */
29
+ export declare function sanitizePrereleaseId(raw: string): string;
30
+ /** @returns The git tag `create-package-version` recorded this package version under. */
31
+ export declare function toVersionTag(salesforceVersion: string, tagSuffix?: string, versionTagFormat?: VersionTagFormat): string;
32
+ /**
33
+ * Map a Salesforce package version onto a semver version.
34
+ *
35
+ * The build number becomes the first prerelease identifier and the git tag's suffix, if any, the
36
+ * second — so `1.2.3.4` on a release branch is `1.2.3-4`, and the same version built from `beta`
37
+ * is `1.2.3-4.beta`. This is the transformation `sfdx-project.json` already uses for a dependency
38
+ * pin (`"package": "MyPackage@1.2.3-4"`), not a new convention.
39
+ *
40
+ * @throws {Error} If the version isn't `major.minor.patch.build`. Publishing a version derived
41
+ * from something unrecognised is worse than failing the job.
42
+ */
43
+ export declare function toNpmVersion(salesforceVersion: string, tagSuffix?: string): string;
44
+ /**
45
+ * The npm dist-tag for a build: `latest` for a release-branch build, else the sanitized tag suffix,
46
+ * so `npm install <pkg>@beta` reaches the newest build off the `beta` package branch.
47
+ */
48
+ export declare function toDistTag(tagSuffix?: string): string;
49
+ /**
50
+ * The `@utam/core` range the generated package declares as a peer, derived from the compiler that
51
+ * actually produced the output rather than hardcoded — generated page objects import `@utam/core`
52
+ * directly, and a consumer must resolve one copy of it across everything they load.
53
+ */
54
+ export declare function toUtamCoreRange(utamVersion: string): string;
55
+ /** The one line identifying which package version produced this output, used as both description and file header. */
56
+ export declare function buildProvenanceLine(packageName: string, salesforceVersion: string, subscriberPackageVersionId: string): string;
57
+ export type PackageManifestOptions = {
58
+ /** npm package name to publish under. */
59
+ npmPackageName: string;
60
+ /** The derived semver version. */
61
+ version: string;
62
+ /** The Salesforce package's name, for the provenance block. */
63
+ salesforcePackageName: string;
64
+ /** The Salesforce version, as `major.minor.patch.build`. */
65
+ salesforceVersion: string;
66
+ subscriberPackageVersionId: string;
67
+ /** The git tag `create-package-version` recorded this version under. */
68
+ versionTag: string;
69
+ /** The commit this package version was built from — the package version's `Tag` field. */
70
+ commitSha?: string;
71
+ /** The pipeline that built it — the package version's `Description` field. */
72
+ pipelineUrl?: string;
73
+ /** The `@utam/core` peer range, from {@link toUtamCoreRange}. */
74
+ utamCoreRange: string;
75
+ /** Extra peers from `plugins.simply.utam.peerDependencies`. */
76
+ projectPeerDependencies?: Record<string, string>;
77
+ };
78
+ /**
79
+ * The `package.json` for the published page-object package.
80
+ *
81
+ * Shaped after `salesforce-pageobjects`, which is what every UTAM consumer already imports from:
82
+ * ESM with a CJS fallback, page objects addressed by path (`<pkg>/pageObjects/<name>`), and the
83
+ * source JSON shipped alongside. The one deliberate difference is that `@utam/core` is declared as
84
+ * a peer here instead of being left to whatever the test's adapter drags in.
85
+ */
86
+ export declare function buildPackageManifest(options: PackageManifestOptions): Record<string, unknown>;
87
+ export type CompilerConfigOptions = {
88
+ /** Absolute path to the default package directory the page objects are authored under. */
89
+ pageObjectsRootDir: string;
90
+ /** Absolute path to the staging directory the compiler writes into. */
91
+ stagingDir: string;
92
+ npmPackageName: string;
93
+ version: string;
94
+ /** The provenance line, stamped as each generated file's header comment. */
95
+ copyright: string;
96
+ alias?: Record<string, string>;
97
+ /** Parsed `plugins.simply.utam.compilerConfig`, whose keys this command doesn't own. */
98
+ baseConfig?: Record<string, unknown>;
99
+ };
100
+ /**
101
+ * The `utam.config.json` the compiler is invoked with.
102
+ *
103
+ * Generated per build rather than read from the repo because the compiler has no flag for
104
+ * `version` — the only way to stamp the Salesforce version into the output is through the config
105
+ * file, so it cannot be a static artifact. A project's own config is merged underneath: the command
106
+ * owns the root, the masks, the output directories, `module`, `version`, and `copyright`; the
107
+ * project keeps everything else (`profiles`, `lint`, `interruptCompilerOnError`, …).
108
+ */
109
+ export declare function buildCompilerConfig(options: CompilerConfigOptions): Record<string, unknown>;
110
+ /**
111
+ * Every `.utam.json` authored under `rootDir`, matching the compiler's own `__utam__` convention.
112
+ *
113
+ * Walks the tree rather than globbing so this package takes on no glob dependency for one lookup.
114
+ *
115
+ * @returns Absolute paths, sorted. Empty when `rootDir` doesn't exist — a project that hasn't
116
+ * adopted UTAM is a skip, not an error.
117
+ */
118
+ export declare function findPageObjectSources(rootDir: string): Promise<string[]>;
119
+ /** @returns The last value assigned to `key` in dotenv-shaped `content`, or `undefined`. */
120
+ export declare function readEnvFileValue(content: string, key: string): string | undefined;
121
+ export type ResolveSubscriberPackageVersionIdOptions = {
122
+ /** `--subscriber-package-version-id`, if passed. */
123
+ flagValue?: string;
124
+ /** The environment to read `SUBSCRIBER_PACKAGE_VERSION_ID` from. Defaults to `process.env`. */
125
+ env?: NodeJS.ProcessEnv;
126
+ /** Dotenv file to fall back to — the one `create-package-version` wrote earlier in this job. */
127
+ envFile: string;
128
+ };
129
+ /**
130
+ * Find the `04t` this run should publish page objects for.
131
+ *
132
+ * Three sources, because the command is useful from two pipeline shapes and they surface the value
133
+ * differently: an explicit flag; `SUBSCRIBER_PACKAGE_VERSION_ID` in the environment, which is how a
134
+ * *separate* job receives `create-package-version`'s dotenv report artifact; and the dotenv file
135
+ * itself, which is how the *same* job sees it, since a dotenv report only ever reaches other jobs.
136
+ *
137
+ * An explicit flag that isn't a `04t` throws — the caller asked for something specific and got it
138
+ * wrong. A malformed value discovered rather than passed only warns, and the search continues.
139
+ *
140
+ * @returns The ID, or `undefined` when no source has one.
141
+ * @throws {Error} If `flagValue` is not a subscriber package version ID.
142
+ */
143
+ export declare function resolveSubscriberPackageVersionId(options: ResolveSubscriberPackageVersionIdOptions): Promise<string | undefined>;
@@ -0,0 +1,258 @@
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 { getPluginConfig, isSubscriberPackageVersionId } from '@simplysf/simply-core';
19
+ import { logger } from '../logger.js';
20
+ import { DEFAULT_VERSION_TAG_FORMAT, VersionTagFormat } from './versionTagFormat.js';
21
+ /** The dotenv key `create-package-version` and `create-fallback-tag` both write their `04t` under. */
22
+ export const SUBSCRIBER_PACKAGE_VERSION_ID_KEY = 'SUBSCRIBER_PACKAGE_VERSION_ID';
23
+ /** The dotenv keys this feature writes, for a downstream UI-test job to install by. */
24
+ export const UTAM_PACKAGE_KEY = 'UTAM_PAGE_OBJECTS_PACKAGE';
25
+ export const UTAM_VERSION_KEY = 'UTAM_PAGE_OBJECTS_VERSION';
26
+ /** The compiler's own default mask, restated so the generated config never depends on it drifting. */
27
+ export const PAGE_OBJECTS_FILE_MASK = ['**/__utam__/**/*.utam.json'];
28
+ /** `sf package version report` returns `Version` as `major.minor.patch.build`, which is not semver. */
29
+ const SALESFORCE_VERSION_PATTERN = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\.(?<build>\d+)$/;
30
+ /** @returns `plugins.simply.utam`, or an empty object when the project declares none. */
31
+ export function readUtamPluginConfig(project) {
32
+ return getPluginConfig(project, 'plugins.simply.utam') ?? {};
33
+ }
34
+ /**
35
+ * Strip leading and trailing hyphens. Done by index rather than `/^-+|-+$/`, whose trailing
36
+ * alternative backtracks quadratically on a long run of interior hyphens.
37
+ */
38
+ function trimHyphens(value) {
39
+ let start = 0;
40
+ let end = value.length;
41
+ while (start < end && value[start] === '-')
42
+ start++;
43
+ while (end > start && value[end - 1] === '-')
44
+ end--;
45
+ return value.slice(start, end);
46
+ }
47
+ /**
48
+ * Reduce a git tag suffix to something semver accepts as a prerelease identifier.
49
+ *
50
+ * Semver's prerelease alphabet is `[0-9A-Za-z-]`; a branch name's `/` and `.` are the common
51
+ * offenders, so each run of anything else collapses to a single hyphen.
52
+ */
53
+ export function sanitizePrereleaseId(raw) {
54
+ const cleaned = trimHyphens(raw.replace(/[^0-9A-Za-z-]+/g, '-'));
55
+ // Semver forbids leading zeros in an all-numeric identifier, so a branch literally named `007`
56
+ // would otherwise produce a version every registry rejects. Prefixing keeps it traceable.
57
+ return /^0\d+$/.test(cleaned) ? `v${cleaned}` : cleaned;
58
+ }
59
+ /** @returns The git tag `create-package-version` recorded this package version under. */
60
+ export function toVersionTag(salesforceVersion, tagSuffix, versionTagFormat = VersionTagFormat.parse(DEFAULT_VERSION_TAG_FORMAT)) {
61
+ return versionTagFormat.render(salesforceVersion, tagSuffix);
62
+ }
63
+ /**
64
+ * Map a Salesforce package version onto a semver version.
65
+ *
66
+ * The build number becomes the first prerelease identifier and the git tag's suffix, if any, the
67
+ * second — so `1.2.3.4` on a release branch is `1.2.3-4`, and the same version built from `beta`
68
+ * is `1.2.3-4.beta`. This is the transformation `sfdx-project.json` already uses for a dependency
69
+ * pin (`"package": "MyPackage@1.2.3-4"`), not a new convention.
70
+ *
71
+ * @throws {Error} If the version isn't `major.minor.patch.build`. Publishing a version derived
72
+ * from something unrecognised is worse than failing the job.
73
+ */
74
+ export function toNpmVersion(salesforceVersion, tagSuffix) {
75
+ const match = SALESFORCE_VERSION_PATTERN.exec(salesforceVersion.trim());
76
+ if (!match?.groups) {
77
+ throw new Error(`Cannot derive an npm version from Salesforce package version "${salesforceVersion}": expected major.minor.patch.build.`);
78
+ }
79
+ const { major, minor, patch, build } = match.groups;
80
+ const sanitizedSuffix = tagSuffix ? sanitizePrereleaseId(tagSuffix) : '';
81
+ const prerelease = sanitizedSuffix ? `${build}.${sanitizedSuffix}` : build;
82
+ return `${major}.${minor}.${patch}-${prerelease}`;
83
+ }
84
+ /**
85
+ * The npm dist-tag for a build: `latest` for a release-branch build, else the sanitized tag suffix,
86
+ * so `npm install <pkg>@beta` reaches the newest build off the `beta` package branch.
87
+ */
88
+ export function toDistTag(tagSuffix) {
89
+ const sanitized = tagSuffix ? sanitizePrereleaseId(tagSuffix) : '';
90
+ return sanitized.length > 0 ? sanitized : 'latest';
91
+ }
92
+ /**
93
+ * The `@utam/core` range the generated package declares as a peer, derived from the compiler that
94
+ * actually produced the output rather than hardcoded — generated page objects import `@utam/core`
95
+ * directly, and a consumer must resolve one copy of it across everything they load.
96
+ */
97
+ export function toUtamCoreRange(utamVersion) {
98
+ const match = /^(?<major>\d+)\.(?<minor>\d+)\./.exec(utamVersion.trim());
99
+ if (!match?.groups) {
100
+ throw new Error(`Could not read a major.minor version from the installed utam compiler: "${utamVersion}".`);
101
+ }
102
+ return `^${match.groups.major}.${match.groups.minor}.0`;
103
+ }
104
+ /** The one line identifying which package version produced this output, used as both description and file header. */
105
+ export function buildProvenanceLine(packageName, salesforceVersion, subscriberPackageVersionId) {
106
+ return `UTAM page objects for ${packageName} ${salesforceVersion} (${subscriberPackageVersionId})`;
107
+ }
108
+ /**
109
+ * The `package.json` for the published page-object package.
110
+ *
111
+ * Shaped after `salesforce-pageobjects`, which is what every UTAM consumer already imports from:
112
+ * ESM with a CJS fallback, page objects addressed by path (`<pkg>/pageObjects/<name>`), and the
113
+ * source JSON shipped alongside. The one deliberate difference is that `@utam/core` is declared as
114
+ * a peer here instead of being left to whatever the test's adapter drags in.
115
+ */
116
+ export function buildPackageManifest(options) {
117
+ return {
118
+ name: options.npmPackageName,
119
+ version: options.version,
120
+ description: buildProvenanceLine(options.salesforcePackageName, options.salesforceVersion, options.subscriberPackageVersionId),
121
+ type: 'module',
122
+ files: ['pageObjects', 'utils', 'source'],
123
+ exports: {
124
+ './package.json': './package.json',
125
+ './*': {
126
+ import: { types: './*.d.ts', default: './*.js' },
127
+ require: { types: './*.d.cts', default: './*.cjs' },
128
+ },
129
+ },
130
+ peerDependencies: {
131
+ '@utam/core': options.utamCoreRange,
132
+ ...options.projectPeerDependencies,
133
+ },
134
+ salesforce: {
135
+ package: options.salesforcePackageName,
136
+ versionNumber: options.salesforceVersion,
137
+ subscriberPackageVersionId: options.subscriberPackageVersionId,
138
+ tag: options.versionTag,
139
+ ...(options.commitSha ? { commitSha: options.commitSha } : {}),
140
+ ...(options.pipelineUrl ? { pipelineUrl: options.pipelineUrl } : {}),
141
+ },
142
+ };
143
+ }
144
+ /**
145
+ * The `utam.config.json` the compiler is invoked with.
146
+ *
147
+ * Generated per build rather than read from the repo because the compiler has no flag for
148
+ * `version` — the only way to stamp the Salesforce version into the output is through the config
149
+ * file, so it cannot be a static artifact. A project's own config is merged underneath: the command
150
+ * owns the root, the masks, the output directories, `module`, `version`, and `copyright`; the
151
+ * project keeps everything else (`profiles`, `lint`, `interruptCompilerOnError`, …).
152
+ */
153
+ export function buildCompilerConfig(options) {
154
+ return {
155
+ ...options.baseConfig,
156
+ pageObjectsRootDir: options.pageObjectsRootDir,
157
+ pageObjectsFileMask: PAGE_OBJECTS_FILE_MASK,
158
+ pageObjectsOutputDir: path.join(options.stagingDir, 'pageObjects'),
159
+ extensionsOutputDir: path.join(options.stagingDir, 'utils'),
160
+ moduleTarget: 'module',
161
+ // The package's own name, so a page object can reference a sibling as
162
+ // `<npm name>/pageObjects/<name>` and have the generated import resolve once installed.
163
+ module: options.npmPackageName,
164
+ version: options.version,
165
+ copyright: [options.copyright],
166
+ ...(options.alias ? { alias: options.alias } : {}),
167
+ };
168
+ }
169
+ /**
170
+ * Every `.utam.json` authored under `rootDir`, matching the compiler's own `__utam__` convention.
171
+ *
172
+ * Walks the tree rather than globbing so this package takes on no glob dependency for one lookup.
173
+ *
174
+ * @returns Absolute paths, sorted. Empty when `rootDir` doesn't exist — a project that hasn't
175
+ * adopted UTAM is a skip, not an error.
176
+ */
177
+ export async function findPageObjectSources(rootDir) {
178
+ let entries;
179
+ try {
180
+ entries = await fs.readdir(rootDir, { recursive: true, withFileTypes: true });
181
+ }
182
+ catch (error) {
183
+ if (error.code === 'ENOENT') {
184
+ return [];
185
+ }
186
+ throw error;
187
+ }
188
+ return entries
189
+ .filter((entry) => entry.isFile() && entry.name.endsWith('.utam.json'))
190
+ .map((entry) => path.join(entry.parentPath, entry.name))
191
+ .filter((file) => path.relative(rootDir, file).split(/[\\/]/).includes('__utam__'))
192
+ .sort();
193
+ }
194
+ /** @returns The last value assigned to `key` in dotenv-shaped `content`, or `undefined`. */
195
+ export function readEnvFileValue(content, key) {
196
+ let found;
197
+ for (const line of content.split(/\r?\n/)) {
198
+ const trimmed = line.trim();
199
+ if (trimmed.length === 0 || trimmed.startsWith('#')) {
200
+ continue;
201
+ }
202
+ const separator = trimmed.indexOf('=');
203
+ if (separator !== -1 && trimmed.slice(0, separator).trim() === key) {
204
+ // Last wins: the file is appended to, so a later line is the newer value.
205
+ found = trimmed.slice(separator + 1).trim();
206
+ }
207
+ }
208
+ return found;
209
+ }
210
+ /**
211
+ * Find the `04t` this run should publish page objects for.
212
+ *
213
+ * Three sources, because the command is useful from two pipeline shapes and they surface the value
214
+ * differently: an explicit flag; `SUBSCRIBER_PACKAGE_VERSION_ID` in the environment, which is how a
215
+ * *separate* job receives `create-package-version`'s dotenv report artifact; and the dotenv file
216
+ * itself, which is how the *same* job sees it, since a dotenv report only ever reaches other jobs.
217
+ *
218
+ * An explicit flag that isn't a `04t` throws — the caller asked for something specific and got it
219
+ * wrong. A malformed value discovered rather than passed only warns, and the search continues.
220
+ *
221
+ * @returns The ID, or `undefined` when no source has one.
222
+ * @throws {Error} If `flagValue` is not a subscriber package version ID.
223
+ */
224
+ export async function resolveSubscriberPackageVersionId(options) {
225
+ const { flagValue, env = process.env, envFile } = options;
226
+ if (flagValue) {
227
+ if (!isSubscriberPackageVersionId(flagValue)) {
228
+ throw new Error(`--subscriber-package-version-id must be a subscriber package version ID (04t), got "${flagValue}".`);
229
+ }
230
+ return flagValue;
231
+ }
232
+ const fromEnv = env[SUBSCRIBER_PACKAGE_VERSION_ID_KEY];
233
+ if (fromEnv) {
234
+ if (isSubscriberPackageVersionId(fromEnv)) {
235
+ logger.info(`Using ${SUBSCRIBER_PACKAGE_VERSION_ID_KEY} from the environment: ${fromEnv}`);
236
+ return fromEnv;
237
+ }
238
+ logger.warn(`Ignoring ${SUBSCRIBER_PACKAGE_VERSION_ID_KEY}="${fromEnv}" from the environment: not a 04t ID.`);
239
+ }
240
+ let content;
241
+ try {
242
+ content = await fs.readFile(envFile, 'utf8');
243
+ }
244
+ catch {
245
+ return undefined;
246
+ }
247
+ const fromFile = readEnvFileValue(content, SUBSCRIBER_PACKAGE_VERSION_ID_KEY);
248
+ if (!fromFile) {
249
+ return undefined;
250
+ }
251
+ if (!isSubscriberPackageVersionId(fromFile)) {
252
+ logger.warn(`Ignoring ${SUBSCRIBER_PACKAGE_VERSION_ID_KEY}="${fromFile}" in ${envFile}: not a 04t ID.`);
253
+ return undefined;
254
+ }
255
+ logger.info(`Using ${SUBSCRIBER_PACKAGE_VERSION_ID_KEY} from ${envFile}: ${fromFile}`);
256
+ return fromFile;
257
+ }
258
+ //# sourceMappingURL=utamPageObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utamPageObjects.js","sourceRoot":"","sources":["../../src/build/utamPageObjects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,4BAA4B,EAAoB,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAErF,sGAAsG;AACtG,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC;AAEjF,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D,sGAAsG;AACtG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAErE,uGAAuG;AACvG,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAclG,yFAAyF;AACzF,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,eAAe,CAAmB,OAAO,EAAE,qBAAqB,CAAC,IAAI,EAAE,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IACvB,OAAO,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC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CAAC;YAC3F,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,YAAY,iCAAiC,KAAK,OAAO,uCAAuC,CAAC,CAAC;IAChH,CAAC;IAED,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAC;IAC9E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,YAAY,iCAAiC,KAAK,QAAQ,QAAQ,OAAO,iBAAiB,CAAC,CAAC;QACxG,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,SAAS,iCAAiC,SAAS,OAAO,KAAK,QAAQ,EAAE,CAAC,CAAC;IACvF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type SfdxProject } from '@simplysf/simply-core';
2
+ /** The tag shape every `simply cicd build` command used before the format was configurable. */
3
+ export declare const DEFAULT_VERSION_TAG_FORMAT = "v{MAJOR}.{MINOR}.{PATCH}.{BUILD}";
4
+ /** Where in `sfdx-project.json` a project declares its own format. */
5
+ export declare const VERSION_TAG_FORMAT_CONFIG_PATH = "plugins.simply.versionTagFormat";
6
+ /** Overrides the project's format, in every command that reads it, when set to a non-empty value. */
7
+ export declare const VERSION_TAG_FORMAT_ENV_VAR = "SIMPLY_CICD_VERSION_TAG_FORMAT";
8
+ declare const PLACEHOLDERS: readonly ["MAJOR", "MINOR", "PATCH", "BUILD"];
9
+ type Placeholder = (typeof PLACEHOLDERS)[number];
10
+ /** A Salesforce package version's four numeric parts. */
11
+ export type VersionParts = Record<Lowercase<Placeholder>, string>;
12
+ /** Thrown for a format that can't be used, so callers that otherwise swallow errors can let it through. */
13
+ export declare class VersionTagFormatError extends Error {
14
+ constructor(format: string, problem: string, source?: string);
15
+ }
16
+ /** A tag split back into the version the format rendered and whatever was appended after it. */
17
+ export type ParsedVersionTag = {
18
+ /** The rendered version, exactly as it appears at the start of the tag. */
19
+ versionTag: string;
20
+ version: VersionParts;
21
+ /** Everything after the rendered version, without its leading `-`; `''` when there is none. */
22
+ rest: string;
23
+ };
24
+ /**
25
+ * A validated version tag format. Every command that writes or reads a package version's git tag
26
+ * goes through one of these, so they agree on the tag's shape.
27
+ */
28
+ export declare class VersionTagFormat {
29
+ readonly format: string;
30
+ private readonly segments;
31
+ private readonly tagPattern;
32
+ private constructor();
33
+ /** @throws {VersionTagFormatError} If the format can't produce distinct, parseable, legal tags. */
34
+ static parse(format: string): VersionTagFormat;
35
+ /**
36
+ * The format in `SIMPLY_CICD_VERSION_TAG_FORMAT` when it's set, otherwise the one declared under
37
+ * `plugins.simply.versionTagFormat`, otherwise the default.
38
+ *
39
+ * @throws {VersionTagFormatError} If the chosen format is invalid.
40
+ */
41
+ static fromProject(project: SfdxProject | undefined): VersionTagFormat;
42
+ /**
43
+ * The tag for `salesforceVersion` (`major.minor.patch.build`), with `-<suffix>` appended when given.
44
+ *
45
+ * @throws {Error} If the version isn't four numeric parts.
46
+ */
47
+ render(salesforceVersion: string, suffix?: string): string;
48
+ /**
49
+ * A `git describe --match` / `git tag --list` glob for tags of the `major.minor.patch` that
50
+ * `versionNumber` (e.g. `6.40.0.NEXT`) declares, with any build and suffix. Without a usable
51
+ * `versionNumber`, any tag starting the way the format starts.
52
+ */
53
+ matchPattern(versionNumber?: string): string;
54
+ /** Splits a tag this format rendered back into its version and suffix; `undefined` if it doesn't match. */
55
+ parseTag(tag: string): ParsedVersionTag | undefined;
56
+ }
57
+ export {};