@simplysf/simply-cicd 0.16.0 → 0.18.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.
@@ -0,0 +1,123 @@
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 { checkPermissionSets, loadPermissionSetsFile, PermissionSetBuildError, } from '@simplysf/simply-permissions-core';
18
+ import { logger } from '../logger.js';
19
+ /** The suffix that marks a permission sets file (the `simply permissions build --file` format). Also defined in `simply-permissions`. */
20
+ export const PERMISSION_SETS_FILE_SUFFIX = '.psbuild.json';
21
+ /** Directories never searched: dependencies, VCS data, and Salesforce CLI state. */
22
+ const SKIPPED_DIRECTORIES = new Set(['node_modules', '.git', '.sf', '.sfdx']);
23
+ /**
24
+ * Every permission sets file under the current directory: each file whose name ends in
25
+ * {@link PERMISSION_SETS_FILE_SUFFIX}, found by walking the tree. Skipped directories are pruned
26
+ * rather than filtered afterwards, so `node_modules` is never read, and symbolic links aren't followed.
27
+ * Doesn't consult git: tracked, untracked, and ignored files are all found.
28
+ *
29
+ * @returns Paths relative to the current directory with `/` separators, sorted.
30
+ */
31
+ export async function findPermissionSetsFiles() {
32
+ const matches = [];
33
+ const walk = async (dir) => {
34
+ const entries = await fs.readdir(dir, { withFileTypes: true });
35
+ for (const entry of entries) {
36
+ const relativePath = dir === '.' ? entry.name : `${dir}/${entry.name}`;
37
+ if (entry.isDirectory()) {
38
+ if (!SKIPPED_DIRECTORIES.has(entry.name)) {
39
+ // eslint-disable-next-line no-await-in-loop -- depth-first keeps the open directory handles to one
40
+ await walk(relativePath);
41
+ }
42
+ }
43
+ else if (entry.isFile() && entry.name.endsWith(PERMISSION_SETS_FILE_SUFFIX)) {
44
+ matches.push(relativePath);
45
+ }
46
+ }
47
+ };
48
+ await walk('.');
49
+ return matches.sort();
50
+ }
51
+ /** The same text `simply permissions build` reports for each `PermissionSetBuildError` code. */
52
+ function describeBuildError(error) {
53
+ switch (error.code) {
54
+ case 'scan-failed':
55
+ return `Failed to scan the Salesforce project directory: ${error.args[0]}`;
56
+ case 'invalid-config':
57
+ return `The configuration file ${error.args[0]} is invalid: ${error.args[1]}`;
58
+ case 'config-not-found':
59
+ return `The configuration file ${error.args[0]} does not exist.`;
60
+ case 'directory-not-found':
61
+ return `The source directory ${error.args[0]} for permission set ${error.args[1]} does not exist.`;
62
+ }
63
+ }
64
+ async function checkFile(file) {
65
+ try {
66
+ return { file, permissionSets: await checkPermissionSets(await loadPermissionSetsFile(file)) };
67
+ }
68
+ catch (error) {
69
+ if (error instanceof PermissionSetBuildError) {
70
+ const message = `Permission sets file ${file}: ${describeBuildError(error)}`;
71
+ logger.error(message);
72
+ throw new Error(message, { cause: error });
73
+ }
74
+ throw error;
75
+ }
76
+ }
77
+ /**
78
+ * Finds every permission sets file in the repo and checks each permission set it declares against
79
+ * the generated file on disk, writing nothing. A repo with no permission sets files is a skip. Every
80
+ * file is checked before failing, so one run reports every stale permission set; an invalid file
81
+ * fails at once.
82
+ *
83
+ * @throws When any permission set has drifted or is missing, or a permission sets file is invalid.
84
+ */
85
+ export async function runCheckPermissionSets(options) {
86
+ if (options.disabled) {
87
+ logger.warn('check-permission-sets is disabled. Skipping.');
88
+ return { skipped: true, files: [] };
89
+ }
90
+ const files = await findPermissionSetsFiles();
91
+ if (files.length === 0) {
92
+ logger.warn('No permission sets files found. Skipping.');
93
+ return { skipped: true, files: [] };
94
+ }
95
+ const checks = [];
96
+ let total = 0;
97
+ let stale = 0;
98
+ for (const file of files) {
99
+ logger.info(`Checking permission sets file ${file}...`);
100
+ // eslint-disable-next-line no-await-in-loop -- files are checked in order so the log reads top to bottom
101
+ const check = await checkFile(file);
102
+ checks.push(check);
103
+ const staleSets = check.permissionSets.filter((permissionSet) => permissionSet.status !== 'up-to-date');
104
+ total += check.permissionSets.length;
105
+ stale += staleSets.length;
106
+ if (staleSets.length === 0) {
107
+ logger.success(`${check.permissionSets.length} permission set(s) up to date.`);
108
+ continue;
109
+ }
110
+ for (const permissionSet of staleSets) {
111
+ logger.error(`${permissionSet.name} ${permissionSet.status} ${permissionSet.path}`);
112
+ }
113
+ logger.log(`Regenerate with: sf simply permissions build --file ${file}`);
114
+ }
115
+ if (stale > 0) {
116
+ const message = `${stale} of ${total} permission set(s) have drifted from their source metadata or are missing.`;
117
+ logger.error(message);
118
+ throw new Error(message);
119
+ }
120
+ logger.success(`All ${total} permission set(s) in ${files.length} permission sets file(s) are up to date.`);
121
+ return { skipped: false, files: checks };
122
+ }
123
+ //# sourceMappingURL=checkPermissionSets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkPermissionSets.js","sourceRoot":"","sources":["../../../src/common/build/checkPermissionSets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,yIAAyI;AACzI,MAAM,CAAC,MAAM,2BAA2B,GAAG,eAAe,CAAC;AAE3D,oFAAoF;AACpF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAM9E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,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AED,MAAM,CAAC,OAAO,CAAC,OAAO,KAAK,yBAAyB,KAAK,CAAC,MAAM,0CAA0C,CAAC,CAAC;IAC5G,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3C,CAAC"}
@@ -1,9 +1,25 @@
1
+ /** Where `runLwcJest` writes the JUnit report, mirroring `runApexTests`'s `./test-results/apex`. */
2
+ export declare const LWC_JEST_RESULTS_DIR = "./test-results/lwc";
3
+ export declare const LWC_JEST_RESULTS_FILE = "test-result.xml";
1
4
  export type RunLwcJestOptions = {
2
5
  disabled?: boolean;
6
+ failOnTestFailure?: boolean;
7
+ projectDir?: string;
3
8
  };
4
9
  export type RunLwcJestResult = {
5
10
  skipped: boolean;
6
11
  success: boolean;
7
12
  };
8
- /** Installs the LWC Jest test libraries and runs the project's LWC Jest tests with coverage. */
13
+ /**
14
+ * Builds an ES module Jest config that loads the project's own config and adds `jest-junit` to its
15
+ * reporters, rather than replacing them the way a CLI `--reporters` would. `rootDir` is pinned to the
16
+ * project, since Jest would otherwise default it to the wrapper's own (temporary) directory.
17
+ */
18
+ export declare function buildJunitJestConfig(projectConfigFile: string, projectDir: string): string;
19
+ /**
20
+ * Installs the LWC Jest test libraries and runs the project's LWC Jest tests with coverage, writing
21
+ * a JUnit report to `./test-results/lwc/test-result.xml` alongside any reporters the project's own
22
+ * Jest config sets. A failure is logged and returned, unless `failOnTestFailure` is set, in which
23
+ * case it also throws.
24
+ */
9
25
  export declare function runLwcJest(options: RunLwcJestOptions): Promise<RunLwcJestResult>;
@@ -13,24 +13,114 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { promises as fs } from 'node:fs';
17
+ import os from 'node:os';
18
+ import path from 'node:path';
19
+ import { pathToFileURL } from 'node:url';
16
20
  import { execa } from 'execa';
17
21
  import { logger } from '../logger.js';
18
- /** Installs the LWC Jest test libraries and runs the project's LWC Jest tests with coverage. */
22
+ /** Where `runLwcJest` writes the JUnit report, mirroring `runApexTests`'s `./test-results/apex`. */
23
+ export const LWC_JEST_RESULTS_DIR = './test-results/lwc';
24
+ export const LWC_JEST_RESULTS_FILE = 'test-result.xml';
25
+ /** The project config files `sfdx-lwc-jest` recognizes; with none present it passes its own default `--config`. */
26
+ const PROJECT_JEST_CONFIG_FILES = ['jest.config.js', 'jest.config.mjs', 'jest.config.cjs'];
27
+ async function findProjectJestConfig(projectDir) {
28
+ for (const file of PROJECT_JEST_CONFIG_FILES) {
29
+ const configPath = path.join(projectDir, file);
30
+ try {
31
+ // eslint-disable-next-line no-await-in-loop -- first match wins, in sfdx-lwc-jest's order
32
+ await fs.access(configPath);
33
+ return configPath;
34
+ }
35
+ catch {
36
+ // not present; try the next name
37
+ }
38
+ }
39
+ return undefined;
40
+ }
41
+ /**
42
+ * Builds an ES module Jest config that loads the project's own config and adds `jest-junit` to its
43
+ * reporters, rather than replacing them the way a CLI `--reporters` would. `rootDir` is pinned to the
44
+ * project, since Jest would otherwise default it to the wrapper's own (temporary) directory.
45
+ */
46
+ export function buildJunitJestConfig(projectConfigFile, projectDir) {
47
+ // A config function rather than top-level await: Jest loads config files with require() first, and
48
+ // require() can't load an ES module that uses top-level await.
49
+ return `import path from 'node:path';
50
+
51
+ export default async () => {
52
+ const mod = await import(${JSON.stringify(pathToFileURL(projectConfigFile).href)});
53
+ let config = mod.default ?? mod;
54
+ if (typeof config === 'function') {
55
+ config = await config();
56
+ }
57
+
58
+ const reporters = config.reporters ?? ['default'];
59
+ const hasJunit = reporters.some((reporter) => (Array.isArray(reporter) ? reporter[0] : reporter) === 'jest-junit');
60
+
61
+ return {
62
+ ...config,
63
+ rootDir: path.resolve(${JSON.stringify(projectDir)}, config.rootDir ?? '.'),
64
+ reporters: hasJunit ? reporters : [...reporters, 'jest-junit'],
65
+ };
66
+ };
67
+ `;
68
+ }
69
+ function failRun(options, message, error) {
70
+ logger.error(message);
71
+ if (options.failOnTestFailure) {
72
+ throw new Error(message, { cause: error });
73
+ }
74
+ return { skipped: false, success: false };
75
+ }
76
+ /**
77
+ * Installs the LWC Jest test libraries and runs the project's LWC Jest tests with coverage, writing
78
+ * a JUnit report to `./test-results/lwc/test-result.xml` alongside any reporters the project's own
79
+ * Jest config sets. A failure is logged and returned, unless `failOnTestFailure` is set, in which
80
+ * case it also throws.
81
+ */
19
82
  export async function runLwcJest(options) {
20
83
  if (options.disabled) {
21
84
  logger.warn('lwc-jest is disabled. Skipping.');
22
85
  return { skipped: true, success: false };
23
86
  }
87
+ const projectDir = options.projectDir ?? process.cwd();
24
88
  logger.info('Running LWC Jest tests...');
89
+ // Created up front so a pipeline's `when: always` artifact path exists even if Jest never starts.
90
+ await fs.mkdir(path.join(projectDir, LWC_JEST_RESULTS_DIR), { recursive: true });
25
91
  try {
26
- await execa('npm', ['install', '@salesforce/sfdx-lwc-jest', '@sa11y/jest'], { stdio: 'pipe' });
27
- await execa('npx', ['sfdx-lwc-jest', '--coverage', '--', '--passWithNoTests'], { stdio: 'inherit' });
28
- logger.success('LWC Jest tests completed.');
29
- return { skipped: false, success: true };
92
+ await execa('npm', ['install', '@salesforce/sfdx-lwc-jest', '@sa11y/jest', 'jest-junit'], {
93
+ cwd: projectDir,
94
+ stdio: 'pipe',
95
+ });
96
+ }
97
+ catch (error) {
98
+ return failRun(options, 'Failed to install the LWC Jest test libraries.', error);
99
+ }
100
+ const projectConfig = await findProjectJestConfig(projectDir);
101
+ const wrapperDir = projectConfig ? await fs.mkdtemp(path.join(os.tmpdir(), 'lwc-jest-')) : undefined;
102
+ try {
103
+ let reporterArgs = ['--reporters=default', '--reporters=jest-junit'];
104
+ if (projectConfig && wrapperDir) {
105
+ const wrapperConfig = path.join(wrapperDir, 'jest.config.mjs');
106
+ await fs.writeFile(wrapperConfig, buildJunitJestConfig(projectConfig, projectDir));
107
+ reporterArgs = [`--config=${wrapperConfig}`];
108
+ }
109
+ await execa('npx', ['sfdx-lwc-jest', '--coverage', '--', '--passWithNoTests', ...reporterArgs], {
110
+ cwd: projectDir,
111
+ stdio: 'inherit',
112
+ env: { JEST_JUNIT_OUTPUT_DIR: LWC_JEST_RESULTS_DIR, JEST_JUNIT_OUTPUT_NAME: LWC_JEST_RESULTS_FILE },
113
+ });
114
+ }
115
+ catch (error) {
116
+ return failRun(options, 'LWC Jest tests failed.', error);
30
117
  }
31
- catch {
32
- logger.error('LWC Jest tests failed.');
33
- return { skipped: false, success: false };
118
+ finally {
119
+ if (wrapperDir) {
120
+ await fs.rm(wrapperDir, { recursive: true, force: true });
121
+ }
34
122
  }
123
+ logger.success('LWC Jest tests completed.');
124
+ return { skipped: false, success: true };
35
125
  }
36
126
  //# sourceMappingURL=lwcJest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lwcJest.js","sourceRoot":"","sources":["../../../src/common/build/lwcJest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,gGAAgG;AAChG,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAA0B;IACzD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/F,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;Q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C,CAAC;IAC3D,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,13 @@
1
+ # summary
2
+
3
+ Fail the pipeline when any generated permission set in the repo has drifted from its source metadata.
4
+
5
+ # description
6
+
7
+ Finds every permission sets file in the repo, meaning every file whose name ends in `.psbuild.json` (the JSON format `sf simply permissions build --file` reads), and checks each permission set it declares, the same way `sf simply permissions build --file <file> --check` does. Nothing is written. Files are found by walking the directory tree from the current directory, skipping `node_modules`, `.git`, `.sf`, and `.sfdx`, so `find . -name '*.psbuild.json'` lists what will be checked. Relative paths in a permission sets file resolve against the current directory, so run this from the repo root.
8
+
9
+ Every file is checked before the command fails, so one run lists every permission set that has drifted or is missing, along with the command that regenerates each file. A `.psbuild.json` file that fails validation fails the command immediately. A repo with no `.psbuild.json` files is skipped with exit code 0, so the job is safe to include in a shared pipeline template. Formatting differences, such as indentation, line endings, or comments, don't count as drift.
10
+
11
+ # examples
12
+
13
+ - <%= config.bin %> <%= command.id %>
@@ -4,8 +4,16 @@ Install the LWC Jest test libraries and run the project's LWC Jest tests with co
4
4
 
5
5
  # description
6
6
 
7
- Installs `@salesforce/sfdx-lwc-jest` and `@sa11y/jest`, then runs `sfdx-lwc-jest --coverage -- --passWithNoTests`. Failures are logged, not thrown.
7
+ Installs `@salesforce/sfdx-lwc-jest`, `@sa11y/jest`, and `jest-junit`, then runs `sfdx-lwc-jest --coverage -- --passWithNoTests` with the `jest-junit` reporter added to any reporters the project's own Jest config sets, writing a JUnit report to `./test-results/lwc/test-result.xml` for the pipeline to upload as an artifact. By default failures are logged, not thrown, so they don't fail the pipeline; pass `--lwc-jest-fail-on-test-failure` to make them exit non-zero.
8
+
9
+ # flags.lwc-jest-fail-on-test-failure.summary
10
+
11
+ Exit non-zero when the LWC Jest tests (or their install) fail, failing the pipeline. By default failures are only logged.
8
12
 
9
13
  # examples
10
14
 
11
15
  - <%= config.bin %> <%= command.id %>
16
+
17
+ - Fail the pipeline when a test fails:
18
+
19
+ <%= config.bin %> <%= command.id %> --lwc-jest-fail-on-test-failure