@simplysf/simply-community-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,206 @@
1
+ Apache License Version 2.0
2
+
3
+ Copyright (c) 2026, Clay Chipps.
4
+ All rights reserved.
5
+
6
+ Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "{}"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright {yyyy} {name of copyright owner}
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @simplysf/simply-community-core
2
+
3
+ [![NPM](https://img.shields.io/npm/v/@simplysf/simply-community-core?label=@simplysf/simply-community-core)](https://npmjs.com/@simplysf/simply-community-core) [![Downloads/week](https://img.shields.io/npm/dw/@simplysf/simply-community-core.svg)](https://npmjs.com/@simplysf/simply-community-core) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://raw.githubusercontent.com/SimplySF/simply-node/main/LICENSE.txt)
4
+
5
+ Community publish/deploy/domain-verification logic and site-file discovery. This is not a Salesforce CLI plugin — it's the library layer behind [`@simplysf/simply-community`](https://github.com/SimplySF/simply-plugins/tree/main/packages/simply-community)'s publish/URL commands, published separately so it can be imported directly by anything that wants the same logic (an editor extension, a CI job, a script) without pulling in the CLI framework.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @simplysf/simply-community-core
11
+ ```
12
+
13
+ Requires Node.js `>=22` and either `"type": "module"` or a dynamic `import()` — this package ships ESM only.
14
+
15
+ ## API
16
+
17
+ Everything below is exported from the package root. Removing or renaming an export is a breaking change; see [`src/index.ts`](src/index.ts).
18
+
19
+ | Export | Description |
20
+ | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
21
+ | `publishCommunity(options)` | Triggers a community publish via the Connect REST API and polls until it completes. |
22
+ | `checkPublishStatus(connection, jobId)` | Builds the `PollingClient`-compatible poll function `publishCommunity` uses. |
23
+ | `deployChangedFiles(options)` | Deploys a specific file list and polls until the deploy reaches a terminal state. |
24
+ | `retrieveCustomSite(connection, site, outputDirectory)` | Retrieves a single `CustomSite` component by name. |
25
+ | `resolveSearchRoots(directory?, projectDir?)` | Resolves the root directories a site/network lookup should search under. |
26
+ | `resolveRetrieveDestination(directory?, projectDir?)` | Resolves the single directory a retrieve should write into. |
27
+ | `resolveSiteFile(site, roots)` | Finds the `sites/<site>.site-meta.xml` file for a CustomSite API name. |
28
+ | `resolveNetworkFile(site, roots)` | Finds the `networks/*.network-meta.xml` file whose `<site>` element names a CustomSite. |
29
+ | `patchCustomSiteXml(xml, options)` | Pure function: replaces a `CustomSite` metadata document's custom URLs with exactly one. |
30
+ | `patchNetworkXml(xml, pathPrefix)` | Pure function: patches a `Network` metadata document's `urlPathPrefix`. |
31
+ | `readNetworkSiteName(xml)` | Pure function: reads a `Network` metadata document's `<site>` element. |
32
+ | `verifyDomain(connection, domain)` | Checks whether a custom domain is registered in the target org, and what it's already bound to. |
33
+
34
+ ```ts
35
+ import { publishCommunity } from '@simplysf/simply-community-core';
36
+
37
+ const result = await publishCommunity({ connection, networkId: '0DM000000000001', wait: 10 });
38
+ ```
39
+
40
+ ```ts
41
+ import { resolveSearchRoots, resolveSiteFile } from '@simplysf/simply-community-core';
42
+
43
+ const roots = await resolveSearchRoots(undefined, process.cwd());
44
+ const siteFile = await resolveSiteFile('MySite', roots);
45
+ ```
46
+
47
+ ```ts
48
+ import { patchCustomSiteXml } from '@simplysf/simply-community-core';
49
+
50
+ const currentXml = await fs.readFile(siteFile, 'utf-8');
51
+ const { xml, previousDomains } = patchCustomSiteXml(currentXml, { domain: 'my.example.com', primary: true });
52
+ ```
53
+
54
+ ```ts
55
+ import { verifyDomain } from '@simplysf/simply-community-core';
56
+
57
+ const check = await verifyDomain(connection, 'my.example.com');
58
+ ```
59
+
60
+ ## Issues
61
+
62
+ Please report any issues at https://github.com/SimplySF/simply-node/issues
63
+
64
+ ## Contributing
65
+
66
+ This package is part of the [`@simplysf/simply`](https://github.com/SimplySF/simply-node) monorepo. See [CONTRIBUTING.md](CONTRIBUTING.md) for what's specific to this package, and the repo's [root CONTRIBUTING.md](https://github.com/SimplySF/simply-node/blob/main/CONTRIBUTING.md) for repo structure, setup, commit conventions, and how to submit a pull request. Please also read our [Code of Conduct](https://github.com/SimplySF/simply-node/blob/main/CODE_OF_CONDUCT.md).
67
+
68
+ ## License
69
+
70
+ Licensed under the [Apache-2.0](https://raw.githubusercontent.com/SimplySF/simply-node/main/LICENSE.txt) license.
@@ -0,0 +1,15 @@
1
+ import { type Connection, type StatusResult } from '@salesforce/core';
2
+ /**
3
+ * Builds a `PollingClient`-compatible `poll()` function for a community publish job.
4
+ *
5
+ * `BackgroundOperation.FinishedAt` (populated once the job reaches a terminal state) is used as
6
+ * the completion signal rather than matching specific `Status` picklist values, since that's a
7
+ * reliable signal regardless of exact status wording. `Error` (populated on failure) determines
8
+ * success vs. failure once finished.
9
+ *
10
+ * @param connection - The org connection to poll against.
11
+ * @param jobId - The `jobId` returned by `POST /connect/communities/{id}/publish`.
12
+ * @returns A `poll()` function for `PollingClient.create({ poll, ... })`.
13
+ * @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
14
+ */
15
+ export declare function checkPublishStatus(connection: Connection, jobId: string): () => Promise<StatusResult>;
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { SfError } from '@salesforce/core';
17
+ /**
18
+ * Builds a `PollingClient`-compatible `poll()` function for a community publish job.
19
+ *
20
+ * `BackgroundOperation.FinishedAt` (populated once the job reaches a terminal state) is used as
21
+ * the completion signal rather than matching specific `Status` picklist values, since that's a
22
+ * reliable signal regardless of exact status wording. `Error` (populated on failure) determines
23
+ * success vs. failure once finished.
24
+ *
25
+ * @param connection - The org connection to poll against.
26
+ * @param jobId - The `jobId` returned by `POST /connect/communities/{id}/publish`.
27
+ * @returns A `poll()` function for `PollingClient.create({ poll, ... })`.
28
+ * @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
29
+ */
30
+ export function checkPublishStatus(connection, jobId) {
31
+ return async () => {
32
+ const result = await connection.query(`SELECT Id, Status, FinishedAt, Error FROM BackgroundOperation WHERE Id = '${jobId}'`);
33
+ const operation = result.records[0];
34
+ // The BackgroundOperation record may not be queryable in the instant right after the publish
35
+ // request is submitted — treat "not found yet" the same as "still running", not as a failure.
36
+ if (!operation?.FinishedAt) {
37
+ return { completed: false };
38
+ }
39
+ if (operation.Error) {
40
+ throw new SfError(`Community publish failed (status: ${operation.Status ?? 'unknown'}): ${operation.Error}`, 'CommunityPublishFailedError');
41
+ }
42
+ return { completed: true, payload: { status: operation.Status } };
43
+ };
44
+ }
45
+ //# sourceMappingURL=checkPublishStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkPublishStatus.js","sourceRoot":"","sources":["../src/checkPublishStatus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAsC,MAAM,kBAAkB,CAAC;AAU/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,KAAa;IACtE,OAAO,KAAK,IAA2B,EAAE;QACvC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CACnC,6EAA6E,KAAK,GAAG,CACtF,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAA0C,CAAC;QAE7E,6FAA6F;QAC7F,8FAA8F;QAC9F,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;YAC3B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC;QAED,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACpB,MAAM,IAAI,OAAO,CACf,qCAAqC,SAAS,CAAC,MAAM,IAAI,SAAS,MAAM,SAAS,CAAC,KAAK,EAAE,EACzF,6BAA6B,CAC9B,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import type { Duration } from '@salesforce/kit';
3
+ export type DeployChangedFilesOptions = {
4
+ connection: Connection;
5
+ /** The exact files the command just wrote — the component set is scoped to only these. */
6
+ filePaths: string[];
7
+ wait: Duration;
8
+ };
9
+ export type DeployComponentFailure = {
10
+ fullName: string;
11
+ type: string;
12
+ filePath?: string;
13
+ error: string;
14
+ };
15
+ export type DeployChangedFilesResult = {
16
+ id: string;
17
+ status: string;
18
+ success: boolean;
19
+ componentsDeployed: string[];
20
+ failures: DeployComponentFailure[];
21
+ };
22
+ /**
23
+ * Deploy exactly the given files and poll until the deploy reaches a terminal state.
24
+ *
25
+ * Scoped to `filePaths` rather than a whole directory: the command already knows precisely which
26
+ * one or two files it just patched, so the component set is built from that list instead of
27
+ * rediscovering it from `--directory`.
28
+ *
29
+ * Does not throw on a failed deploy — a failure is reported in the returned result (`success:
30
+ * false`, populated `failures`) so the caller's restore `finally` still runs before it decides
31
+ * whether to throw. An error here means the deploy request or polling itself broke (auth,
32
+ * network, timeout), not that components failed to deploy.
33
+ *
34
+ * @param options - The connection to deploy against, the changed files, and how long to wait.
35
+ * @returns The deploy outcome: id, terminal status, and per-component successes/failures.
36
+ */
37
+ export declare function deployChangedFiles(options: DeployChangedFilesOptions): Promise<DeployChangedFilesResult>;
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { ComponentSet, ComponentStatus } from '@salesforce/source-deploy-retrieve';
17
+ /**
18
+ * Deploy exactly the given files and poll until the deploy reaches a terminal state.
19
+ *
20
+ * Scoped to `filePaths` rather than a whole directory: the command already knows precisely which
21
+ * one or two files it just patched, so the component set is built from that list instead of
22
+ * rediscovering it from `--directory`.
23
+ *
24
+ * Does not throw on a failed deploy — a failure is reported in the returned result (`success:
25
+ * false`, populated `failures`) so the caller's restore `finally` still runs before it decides
26
+ * whether to throw. An error here means the deploy request or polling itself broke (auth,
27
+ * network, timeout), not that components failed to deploy.
28
+ *
29
+ * @param options - The connection to deploy against, the changed files, and how long to wait.
30
+ * @returns The deploy outcome: id, terminal status, and per-component successes/failures.
31
+ */
32
+ export async function deployChangedFiles(options) {
33
+ const componentSet = ComponentSet.fromSource(options.filePaths);
34
+ const deploy = await componentSet.deploy({ usernameOrConnection: options.connection });
35
+ const result = await deploy.pollStatus({ timeout: options.wait });
36
+ const failures = [];
37
+ const componentsDeployed = [];
38
+ for (const fileResponse of result.getFileResponses()) {
39
+ if (fileResponse.state === ComponentStatus.Failed) {
40
+ failures.push({
41
+ fullName: fileResponse.fullName,
42
+ type: fileResponse.type,
43
+ filePath: fileResponse.filePath,
44
+ error: fileResponse.error,
45
+ });
46
+ }
47
+ else {
48
+ componentsDeployed.push(fileResponse.fullName);
49
+ }
50
+ }
51
+ return {
52
+ id: result.response.id,
53
+ status: result.response.status,
54
+ success: result.response.success,
55
+ componentsDeployed,
56
+ failures,
57
+ };
58
+ }
59
+ //# sourceMappingURL=deployChangedFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployChangedFiles.js","sourceRoot":"","sources":["../src/deployChangedFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAwBnF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACzE,MAAM,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAElE,MAAM,QAAQ,GAA6B,EAAE,CAAC;IAC9C,MAAM,kBAAkB,GAAa,EAAE,CAAC;IAExC,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC;QACrD,IAAI,YAAY,CAAC,KAAK,KAAK,eAAe,CAAC,MAAM,EAAE,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC;gBACZ,QAAQ,EAAE,YAAY,CAAC,QAAQ;gBAC/B,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,QAAQ,EAAE,YAAY,CAAC,QAAQ;gBAC/B,KAAK,EAAE,YAAY,CAAC,KAAK;aAC1B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QACtB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC9B,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO;QAChC,kBAAkB;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { checkPublishStatus } from './checkPublishStatus.js';
2
+ export { deployChangedFiles, type DeployChangedFilesOptions, type DeployComponentFailure, type DeployChangedFilesResult, } from './deployChangedFiles.js';
3
+ export { publishCommunity, type PublishCommunityOptions } from './publishCommunity.js';
4
+ export { resolveSearchRoots, resolveRetrieveDestination, resolveSiteFile, resolveNetworkFile, } from './resolveSiteFiles.js';
5
+ export { retrieveCustomSite } from './retrieveCustomSite.js';
6
+ export { patchCustomSiteXml, type PatchCustomSiteXmlOptions, type PatchCustomSiteXmlResult, patchNetworkXml, readNetworkSiteName, } from './siteMetadataXml.js';
7
+ export { verifyDomain, type DomainCheckStatus, type DomainCheckResult } from './verifyDomain.js';
package/lib/index.js ADDED
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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
+ // Everything exported from this file is this package's public API and is semver-covered: adding an
17
+ // export is a minor/patch change, but removing or renaming one is breaking. `test/index.test.ts`
18
+ // pins the exported-key list down so an accidental removal fails a test instead of silently shipping
19
+ // in a patch release. See docs/design/0030-simply-community-core.md for why this package is split
20
+ // out from `@simplysf/simply-community` (the CLI) rather than being one more relative import inside
21
+ // it.
22
+ export { checkPublishStatus } from './checkPublishStatus.js';
23
+ export { deployChangedFiles, } from './deployChangedFiles.js';
24
+ export { publishCommunity } from './publishCommunity.js';
25
+ export { resolveSearchRoots, resolveRetrieveDestination, resolveSiteFile, resolveNetworkFile, } from './resolveSiteFiles.js';
26
+ export { retrieveCustomSite } from './retrieveCustomSite.js';
27
+ export { patchCustomSiteXml, patchNetworkXml, readNetworkSiteName, } from './siteMetadataXml.js';
28
+ export { verifyDomain } from './verifyDomain.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,kGAAkG;AAClG,oGAAoG;AACpG,MAAM;AAEN,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,kBAAkB,GAInB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAgC,MAAM,uBAAuB,CAAC;AACvF,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAGlB,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAkD,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ /** The response shape of `POST /connect/communities/{id}/publish`. */
3
+ type CommunityPublishResponse = {
4
+ id: string;
5
+ jobId: string;
6
+ name: string;
7
+ url: string;
8
+ };
9
+ export type PublishCommunityOptions = {
10
+ connection: Connection;
11
+ /** The `Network.Id` to publish. */
12
+ networkId: string;
13
+ /** Minutes to wait for the publish job to reach a terminal state. */
14
+ wait: number;
15
+ /** Additional attempts to make if the initial publish request fails. Defaults to 0. */
16
+ retryAttempts?: number;
17
+ /** Factor the retry delay grows by after each failed attempt. Defaults to 2. */
18
+ retryBackoff?: number;
19
+ };
20
+ /**
21
+ * Trigger a community publish via the Connect REST API and poll until the job reaches a terminal
22
+ * state, throwing if it fails.
23
+ *
24
+ * Shared by `simply community publish` and `simply community url set --publish` so the Connect
25
+ * API call and the poll for completion exist in exactly one place.
26
+ *
27
+ * @param options - The connection, the `Network.Id` to publish, and wait/retry settings.
28
+ * @returns The Connect API's publish response: id, jobId, name, and url.
29
+ * @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
30
+ * @throws If the initial publish request fails and retries (if any) are exhausted.
31
+ */
32
+ export declare function publishCommunity(options: PublishCommunityOptions): Promise<CommunityPublishResponse>;
33
+ export {};
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { Duration } from '@salesforce/kit';
17
+ import { PollingClient } from '@salesforce/core';
18
+ import { retryWithBackoff } from '@simplysf/simply-core';
19
+ import { checkPublishStatus } from './checkPublishStatus.js';
20
+ /**
21
+ * Trigger a community publish via the Connect REST API and poll until the job reaches a terminal
22
+ * state, throwing if it fails.
23
+ *
24
+ * Shared by `simply community publish` and `simply community url set --publish` so the Connect
25
+ * API call and the poll for completion exist in exactly one place.
26
+ *
27
+ * @param options - The connection, the `Network.Id` to publish, and wait/retry settings.
28
+ * @returns The Connect API's publish response: id, jobId, name, and url.
29
+ * @throws {SfError} `CommunityPublishFailedError` if the job reaches a terminal failure state.
30
+ * @throws If the initial publish request fails and retries (if any) are exhausted.
31
+ */
32
+ export async function publishCommunity(options) {
33
+ const publishResponse = await retryWithBackoff(async () => options.connection.request({
34
+ method: 'POST',
35
+ url: `/connect/communities/${options.networkId}/publish`,
36
+ }), { retryAttempts: options.retryAttempts ?? 0, backoffFactor: options.retryBackoff ?? 2 });
37
+ const client = await PollingClient.create({
38
+ poll: checkPublishStatus(options.connection, publishResponse.jobId),
39
+ frequency: Duration.seconds(15),
40
+ timeout: Duration.minutes(options.wait),
41
+ timeoutErrorName: 'CommunityPublishTimeoutError',
42
+ });
43
+ await client.subscribe();
44
+ return publishResponse;
45
+ }
46
+ //# sourceMappingURL=publishCommunity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publishCommunity.js","sourceRoot":"","sources":["../src/publishCommunity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAiB7D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgC;IACrE,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAC5C,KAAK,IAAI,EAAE,CACT,OAAO,CAAC,UAAU,CAAC,OAAO,CAA2B;QACnD,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,wBAAwB,OAAO,CAAC,SAAS,UAAU;KACzD,CAAC,EACJ,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC,EAAE,CACxF,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;QACxC,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC;QACnE,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QACvC,gBAAgB,EAAE,8BAA8B;KACjD,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IAEzB,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Resolve the root directories a site/network lookup should search under.
3
+ *
4
+ * When `--directory` is given, it's the sole root. Otherwise every package directory declared in
5
+ * `sfdx-project.json` is searched — a project can (and often does) spread `sites`/`networks`
6
+ * across more than one package directory.
7
+ *
8
+ * @param directory - The `--directory` flag value, if given.
9
+ * @param projectDir - Directory to read `sfdx-project.json` from. Defaults to the current working
10
+ * directory, matching `readSfdxProject`.
11
+ * @returns Absolute root directories to search.
12
+ */
13
+ export declare function resolveSearchRoots(directory?: string, projectDir?: string): Promise<string[]>;
14
+ /**
15
+ * Resolve the single directory a retrieve should write into, when the site file wasn't found
16
+ * among {@link resolveSearchRoots}'s (possibly multiple) roots.
17
+ *
18
+ * Unlike search, retrieval needs exactly one destination: `--directory` if given, otherwise the
19
+ * project's default package directory — the same directory a plain `sf project retrieve start`
20
+ * would use absent other guidance.
21
+ *
22
+ * @param directory - The `--directory` flag value, if given.
23
+ * @param projectDir - Directory to read `sfdx-project.json` from. Defaults to the current working
24
+ * directory, matching `readSfdxProject`.
25
+ * @returns The absolute destination directory.
26
+ * @throws {SfError} `CommunityUrlNoRetrieveDestinationError` if `--directory` wasn't given and the
27
+ * project has no default package directory to fall back to.
28
+ */
29
+ export declare function resolveRetrieveDestination(directory?: string, projectDir?: string): Promise<string>;
30
+ /**
31
+ * Find the `sites/<site>.site-meta.xml` file for a CustomSite API name.
32
+ *
33
+ * @param site - The CustomSite API name (the basename of the site file, without its extension).
34
+ * @param roots - Root directories to search, from {@link resolveSearchRoots}.
35
+ * @returns The absolute path to the matched site file.
36
+ * @throws {SfError} `CommunityUrlSiteFileNotFoundError` if no file matches.
37
+ * @throws {SfError} `CommunityUrlSiteFileAmbiguousError` if more than one file matches.
38
+ */
39
+ export declare function resolveSiteFile(site: string, roots: string[]): Promise<string>;
40
+ /**
41
+ * Find the `networks/*.network-meta.xml` file whose `<site>` element names a CustomSite.
42
+ *
43
+ * Every `.network-meta.xml` file under the search roots is opened to check its `<site>` value,
44
+ * since the Network's own file name doesn't have to match the CustomSite's API name.
45
+ *
46
+ * @param site - The CustomSite API name to search for.
47
+ * @param roots - Root directories to search, from {@link resolveSearchRoots}.
48
+ * @returns The absolute path to the matched network file.
49
+ * @throws {SfError} `CommunityUrlNetworkFileNotFoundError` if no file's `<site>` matches.
50
+ * @throws {SfError} `CommunityUrlNetworkFileAmbiguousError` if more than one file's `<site>` matches.
51
+ */
52
+ export declare function resolveNetworkFile(site: string, roots: string[]): Promise<string>;
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 fs from 'node:fs/promises';
17
+ import path from 'node:path';
18
+ import { glob } from 'glob';
19
+ import { SfError } from '@salesforce/core';
20
+ import { getDefaultPackageDirectory, readSfdxProject } from '@simplysf/simply-core';
21
+ import { readNetworkSiteName } from './siteMetadataXml.js';
22
+ /** Normalize a filesystem path to forward slashes, which is what `glob` patterns expect. */
23
+ function toGlobPath(fsPath) {
24
+ return fsPath.split(path.sep).join('/');
25
+ }
26
+ /**
27
+ * Resolve the root directories a site/network lookup should search under.
28
+ *
29
+ * When `--directory` is given, it's the sole root. Otherwise every package directory declared in
30
+ * `sfdx-project.json` is searched — a project can (and often does) spread `sites`/`networks`
31
+ * across more than one package directory.
32
+ *
33
+ * @param directory - The `--directory` flag value, if given.
34
+ * @param projectDir - Directory to read `sfdx-project.json` from. Defaults to the current working
35
+ * directory, matching `readSfdxProject`.
36
+ * @returns Absolute root directories to search.
37
+ */
38
+ export async function resolveSearchRoots(directory, projectDir = process.cwd()) {
39
+ if (directory) {
40
+ return [path.resolve(directory)];
41
+ }
42
+ const project = await readSfdxProject(projectDir);
43
+ return project.packageDirectories.map((packageDirectory) => path.resolve(projectDir, packageDirectory.path ?? '.'));
44
+ }
45
+ /**
46
+ * Resolve the single directory a retrieve should write into, when the site file wasn't found
47
+ * among {@link resolveSearchRoots}'s (possibly multiple) roots.
48
+ *
49
+ * Unlike search, retrieval needs exactly one destination: `--directory` if given, otherwise the
50
+ * project's default package directory — the same directory a plain `sf project retrieve start`
51
+ * would use absent other guidance.
52
+ *
53
+ * @param directory - The `--directory` flag value, if given.
54
+ * @param projectDir - Directory to read `sfdx-project.json` from. Defaults to the current working
55
+ * directory, matching `readSfdxProject`.
56
+ * @returns The absolute destination directory.
57
+ * @throws {SfError} `CommunityUrlNoRetrieveDestinationError` if `--directory` wasn't given and the
58
+ * project has no default package directory to fall back to.
59
+ */
60
+ export async function resolveRetrieveDestination(directory, projectDir = process.cwd()) {
61
+ if (directory) {
62
+ return path.resolve(directory);
63
+ }
64
+ const project = await readSfdxProject(projectDir);
65
+ const defaultPackageDirectory = getDefaultPackageDirectory(project);
66
+ if (!defaultPackageDirectory?.path) {
67
+ throw new SfError('No --directory was given, and the project has no default package directory to retrieve into.', 'CommunityUrlNoRetrieveDestinationError');
68
+ }
69
+ return path.resolve(projectDir, defaultPackageDirectory.path);
70
+ }
71
+ /**
72
+ * Find the `sites/<site>.site-meta.xml` file for a CustomSite API name.
73
+ *
74
+ * @param site - The CustomSite API name (the basename of the site file, without its extension).
75
+ * @param roots - Root directories to search, from {@link resolveSearchRoots}.
76
+ * @returns The absolute path to the matched site file.
77
+ * @throws {SfError} `CommunityUrlSiteFileNotFoundError` if no file matches.
78
+ * @throws {SfError} `CommunityUrlSiteFileAmbiguousError` if more than one file matches.
79
+ */
80
+ export async function resolveSiteFile(site, roots) {
81
+ const patterns = roots.map((root) => `${toGlobPath(root)}/**/sites/${site}.site-meta.xml`);
82
+ const matches = [...new Set((await Promise.all(patterns.map((pattern) => glob(pattern)))).flat())];
83
+ if (matches.length === 0) {
84
+ throw new SfError(`No site file found matching any of: ${patterns.join(', ')}`, 'CommunityUrlSiteFileNotFoundError');
85
+ }
86
+ if (matches.length > 1) {
87
+ throw new SfError(`Multiple site files matched "${site}": ${matches.join(', ')}`, 'CommunityUrlSiteFileAmbiguousError');
88
+ }
89
+ return matches[0];
90
+ }
91
+ /**
92
+ * Find the `networks/*.network-meta.xml` file whose `<site>` element names a CustomSite.
93
+ *
94
+ * Every `.network-meta.xml` file under the search roots is opened to check its `<site>` value,
95
+ * since the Network's own file name doesn't have to match the CustomSite's API name.
96
+ *
97
+ * @param site - The CustomSite API name to search for.
98
+ * @param roots - Root directories to search, from {@link resolveSearchRoots}.
99
+ * @returns The absolute path to the matched network file.
100
+ * @throws {SfError} `CommunityUrlNetworkFileNotFoundError` if no file's `<site>` matches.
101
+ * @throws {SfError} `CommunityUrlNetworkFileAmbiguousError` if more than one file's `<site>` matches.
102
+ */
103
+ export async function resolveNetworkFile(site, roots) {
104
+ const patterns = roots.map((root) => `${toGlobPath(root)}/**/networks/*.network-meta.xml`);
105
+ const candidates = [...new Set((await Promise.all(patterns.map((pattern) => glob(pattern)))).flat())];
106
+ const matches = [];
107
+ for (const candidate of candidates) {
108
+ // eslint-disable-next-line no-await-in-loop
109
+ const xml = await fs.readFile(candidate, 'utf-8');
110
+ if (readNetworkSiteName(xml) === site) {
111
+ matches.push(candidate);
112
+ }
113
+ }
114
+ if (matches.length === 0) {
115
+ throw new SfError(`No network file found whose <site> element is "${site}" under: ${patterns.join(', ')}`, 'CommunityUrlNetworkFileNotFoundError');
116
+ }
117
+ if (matches.length > 1) {
118
+ throw new SfError(`Multiple network files reference site "${site}": ${matches.join(', ')}`, 'CommunityUrlNetworkFileAmbiguousError');
119
+ }
120
+ return matches[0];
121
+ }
122
+ //# sourceMappingURL=resolveSiteFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSiteFiles.js","sourceRoot":"","sources":["../src/resolveSiteFiles.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,21 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ /**
3
+ * Retrieve a single `CustomSite` component by name into a destination directory.
4
+ *
5
+ * Used when the site file isn't found locally (see `resolveSiteFile`) but a `--target-org`
6
+ * connection is available — the fallback that lets the command work against a checkout that never
7
+ * had `sites/` committed at all.
8
+ *
9
+ * The component set is built directly from `{ fullName, type: 'CustomSite' }` rather than resolved
10
+ * from source, since there's nothing on disk yet for this component; `merge: true` is passed
11
+ * anyway so a same-named file elsewhere under `outputDirectory` gets merged into rather than
12
+ * duplicated, on the off chance the local search missed something the registry wouldn't.
13
+ *
14
+ * @param connection - The org connection to retrieve from.
15
+ * @param site - The CustomSite API name to retrieve.
16
+ * @param outputDirectory - Where to write the retrieved file, from `resolveRetrieveDestination`.
17
+ * @returns The retrieved file's path, or `undefined` if the org has no `CustomSite` by that name.
18
+ * @throws If the retrieve request or polling itself fails (auth, network, timeout) — only "the
19
+ * component doesn't exist" is reported as `undefined` rather than thrown.
20
+ */
21
+ export declare function retrieveCustomSite(connection: Connection, site: string, outputDirectory: string): Promise<string | undefined>;
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { ComponentSet, ComponentStatus } from '@salesforce/source-deploy-retrieve';
17
+ /**
18
+ * Retrieve a single `CustomSite` component by name into a destination directory.
19
+ *
20
+ * Used when the site file isn't found locally (see `resolveSiteFile`) but a `--target-org`
21
+ * connection is available — the fallback that lets the command work against a checkout that never
22
+ * had `sites/` committed at all.
23
+ *
24
+ * The component set is built directly from `{ fullName, type: 'CustomSite' }` rather than resolved
25
+ * from source, since there's nothing on disk yet for this component; `merge: true` is passed
26
+ * anyway so a same-named file elsewhere under `outputDirectory` gets merged into rather than
27
+ * duplicated, on the off chance the local search missed something the registry wouldn't.
28
+ *
29
+ * @param connection - The org connection to retrieve from.
30
+ * @param site - The CustomSite API name to retrieve.
31
+ * @param outputDirectory - Where to write the retrieved file, from `resolveRetrieveDestination`.
32
+ * @returns The retrieved file's path, or `undefined` if the org has no `CustomSite` by that name.
33
+ * @throws If the retrieve request or polling itself fails (auth, network, timeout) — only "the
34
+ * component doesn't exist" is reported as `undefined` rather than thrown.
35
+ */
36
+ export async function retrieveCustomSite(connection, site, outputDirectory) {
37
+ const componentSet = new ComponentSet([{ fullName: site, type: 'CustomSite' }]);
38
+ const operation = await componentSet.retrieve({
39
+ usernameOrConnection: connection,
40
+ output: outputDirectory,
41
+ merge: true,
42
+ });
43
+ const result = await operation.pollStatus();
44
+ const fileResponse = result
45
+ .getFileResponses()
46
+ .find((response) => response.type === 'CustomSite' && response.fullName === site);
47
+ if (!fileResponse || fileResponse.state === ComponentStatus.Failed) {
48
+ return undefined;
49
+ }
50
+ return fileResponse.filePath;
51
+ }
52
+ //# sourceMappingURL=retrieveCustomSite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrieveCustomSite.js","sourceRoot":"","sources":["../src/retrieveCustomSite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAAsB,EACtB,IAAY,EACZ,eAAuB;IAEvB,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAChF,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC;QAC5C,oBAAoB,EAAE,UAAU;QAChC,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAE5C,MAAM,YAAY,GAAG,MAAM;SACxB,gBAAgB,EAAE;SAClB,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;IAEpF,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,KAAK,KAAK,eAAe,CAAC,MAAM,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,YAAY,CAAC,QAAQ,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,42 @@
1
+ /** What `patchCustomSiteXml` should write into `sites/<Site>.site-meta.xml`. */
2
+ export type PatchCustomSiteXmlOptions = {
3
+ domain: string;
4
+ primary: boolean;
5
+ pathPrefix?: string;
6
+ };
7
+ export type PatchCustomSiteXmlResult = {
8
+ xml: string;
9
+ /** The `domainName` values of every `customWebAddresses` entry the replace-all discarded. */
10
+ previousDomains: string[];
11
+ };
12
+ /**
13
+ * Patch a `CustomSite` metadata document: replace every `customWebAddresses` entry with exactly
14
+ * one, and optionally set `urlPathPrefix`.
15
+ *
16
+ * Per the CustomSite metadata reference, saving or deploying a CustomSite replaces all root
17
+ * custom URLs with the list being written — so this replaces rather than appends, matching what
18
+ * the deploy is going to do regardless.
19
+ *
20
+ * @param xml - The current contents of the `sites/<Site>.site-meta.xml` file.
21
+ * @param options - The domain (and whether it's primary) to write, and an optional path prefix.
22
+ * @returns The rewritten document, plus the domains the replace-all discarded.
23
+ * @throws {Error} If `xml` isn't parseable.
24
+ */
25
+ export declare function patchCustomSiteXml(xml: string, options: PatchCustomSiteXmlOptions): PatchCustomSiteXmlResult;
26
+ /**
27
+ * Patch a `Network` metadata document's `urlPathPrefix`.
28
+ *
29
+ * @param xml - The current contents of the `networks/<Network>.network-meta.xml` file.
30
+ * @param pathPrefix - The URL path prefix to write.
31
+ * @returns The rewritten document.
32
+ * @throws {Error} If `xml` isn't parseable.
33
+ */
34
+ export declare function patchNetworkXml(xml: string, pathPrefix: string): string;
35
+ /**
36
+ * Read a `Network` metadata document's `<site>` element — the CustomSite API name it belongs to.
37
+ *
38
+ * @param xml - The contents of a `networks/*.network-meta.xml` file.
39
+ * @returns The `<site>` value, or `undefined` if the element is absent.
40
+ * @throws {Error} If `xml` isn't parseable.
41
+ */
42
+ export declare function readNetworkSiteName(xml: string): string | undefined;
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { create } from 'xmlbuilder2';
17
+ /**
18
+ * Find the direct child elements of `root` with the given tag name.
19
+ *
20
+ * `filter`'s second argument (`self`) excludes `root` itself from consideration, and the third
21
+ * (`recursive`) is left `false` so a same-named descendant nested under an unrelated element
22
+ * (there are none today, but the metadata schema isn't ours to fix) can't be matched by mistake.
23
+ */
24
+ function childrenNamed(root, tagName) {
25
+ return root.filter((node) => node.node.nodeName === tagName, false, false);
26
+ }
27
+ /**
28
+ * Patch a `CustomSite` metadata document: replace every `customWebAddresses` entry with exactly
29
+ * one, and optionally set `urlPathPrefix`.
30
+ *
31
+ * Per the CustomSite metadata reference, saving or deploying a CustomSite replaces all root
32
+ * custom URLs with the list being written — so this replaces rather than appends, matching what
33
+ * the deploy is going to do regardless.
34
+ *
35
+ * @param xml - The current contents of the `sites/<Site>.site-meta.xml` file.
36
+ * @param options - The domain (and whether it's primary) to write, and an optional path prefix.
37
+ * @returns The rewritten document, plus the domains the replace-all discarded.
38
+ * @throws {Error} If `xml` isn't parseable.
39
+ */
40
+ export function patchCustomSiteXml(xml, options) {
41
+ const doc = create(xml);
42
+ const root = doc.root();
43
+ const previousDomains = [];
44
+ for (const node of childrenNamed(root, 'customWebAddresses')) {
45
+ const domainNameNode = childrenNamed(node, 'domainName')[0];
46
+ if (domainNameNode?.node.textContent) {
47
+ previousDomains.push(domainNameNode.node.textContent);
48
+ }
49
+ node.remove();
50
+ }
51
+ root
52
+ .ele('customWebAddresses')
53
+ .ele('domainName')
54
+ .txt(options.domain)
55
+ .up()
56
+ .ele('primary')
57
+ .txt(String(options.primary))
58
+ .up()
59
+ .up();
60
+ if (options.pathPrefix !== undefined) {
61
+ setUrlPathPrefix(root, options.pathPrefix);
62
+ }
63
+ return { xml: doc.end({ prettyPrint: true }), previousDomains };
64
+ }
65
+ /**
66
+ * Patch a `Network` metadata document's `urlPathPrefix`.
67
+ *
68
+ * @param xml - The current contents of the `networks/<Network>.network-meta.xml` file.
69
+ * @param pathPrefix - The URL path prefix to write.
70
+ * @returns The rewritten document.
71
+ * @throws {Error} If `xml` isn't parseable.
72
+ */
73
+ export function patchNetworkXml(xml, pathPrefix) {
74
+ const doc = create(xml);
75
+ const root = doc.root();
76
+ setUrlPathPrefix(root, pathPrefix);
77
+ return doc.end({ prettyPrint: true });
78
+ }
79
+ /**
80
+ * Read a `Network` metadata document's `<site>` element — the CustomSite API name it belongs to.
81
+ *
82
+ * @param xml - The contents of a `networks/*.network-meta.xml` file.
83
+ * @returns The `<site>` value, or `undefined` if the element is absent.
84
+ * @throws {Error} If `xml` isn't parseable.
85
+ */
86
+ export function readNetworkSiteName(xml) {
87
+ const root = create(xml).root();
88
+ return childrenNamed(root, 'site')[0]?.node.textContent ?? undefined;
89
+ }
90
+ /** Set `urlPathPrefix`'s text, creating the element (appended as the last child) if absent. */
91
+ function setUrlPathPrefix(root, pathPrefix) {
92
+ const existing = childrenNamed(root, 'urlPathPrefix')[0];
93
+ if (existing) {
94
+ existing.node.textContent = pathPrefix;
95
+ }
96
+ else {
97
+ root.ele('urlPathPrefix').txt(pathPrefix).up();
98
+ }
99
+ }
100
+ //# sourceMappingURL=siteMetadataXml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteMetadataXml.js","sourceRoot":"","sources":["../src/siteMetadataXml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrC;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,IAAgB,EAAE,OAAe;IACtD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,OAAkC;IAChF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAExB,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,IAAI,EAAE,oBAAoB,CAAC,EAAE,CAAC;QAC7D,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,cAAc,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,IAAI;SACD,GAAG,CAAC,oBAAoB,CAAC;SACzB,GAAG,CAAC,YAAY,CAAC;SACjB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;SACnB,EAAE,EAAE;SACJ,GAAG,CAAC,SAAS,CAAC;SACd,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SAC5B,EAAE,EAAE;SACJ,EAAE,EAAE,CAAC;IAER,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,UAAkB;IAC7D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAExB,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAEnC,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAEhC,OAAO,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS,CAAC;AACvE,CAAC;AAED,+FAA+F;AAC/F,SAAS,gBAAgB,CAAC,IAAgB,EAAE,UAAkB;IAC5D,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC;IACjD,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ export type DomainCheckStatus = 'found' | 'missing' | 'unavailable';
3
+ export type DomainCheckResult = {
4
+ status: DomainCheckStatus;
5
+ domainId?: string;
6
+ /** `SiteId` of every `DomainSite` this domain is already bound to. Empty when unbound. */
7
+ boundToSiteIds: string[];
8
+ };
9
+ /**
10
+ * Check whether a custom domain is registered in the target org, and what it's already bound to.
11
+ *
12
+ * `Domain` and `DomainSite` are read-only but SOQL-queryable (API 26.0+); they aren't in the
13
+ * source-deploy-retrieve metadata registry, so this is the only way to catch a typo'd or
14
+ * unregistered domain before a deploy fails with a less specific Salesforce-side error.
15
+ *
16
+ * Deliberately pure over a connection and a domain string — it doesn't know which site the
17
+ * caller intends to bind, so it can't itself decide whether `boundToSiteIds` is a problem. The
18
+ * caller compares those ids against whatever site it resolved and decides what's fatal.
19
+ *
20
+ * A query failure (missing permission, API error) is reported as `'unavailable'` rather than
21
+ * thrown, since an inability to run an advisory check isn't the same as the check failing.
22
+ *
23
+ * @param connection - The org connection to query against.
24
+ * @param domain - The fully qualified custom domain to look up.
25
+ * @returns Whether the domain was found, its Id, and the sites it's already bound to.
26
+ */
27
+ export declare function verifyDomain(connection: Connection, domain: string): Promise<DomainCheckResult>;
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps.
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 { escapeSoqlLiteral } from '@simplysf/simply-core';
17
+ /**
18
+ * Check whether a custom domain is registered in the target org, and what it's already bound to.
19
+ *
20
+ * `Domain` and `DomainSite` are read-only but SOQL-queryable (API 26.0+); they aren't in the
21
+ * source-deploy-retrieve metadata registry, so this is the only way to catch a typo'd or
22
+ * unregistered domain before a deploy fails with a less specific Salesforce-side error.
23
+ *
24
+ * Deliberately pure over a connection and a domain string — it doesn't know which site the
25
+ * caller intends to bind, so it can't itself decide whether `boundToSiteIds` is a problem. The
26
+ * caller compares those ids against whatever site it resolved and decides what's fatal.
27
+ *
28
+ * A query failure (missing permission, API error) is reported as `'unavailable'` rather than
29
+ * thrown, since an inability to run an advisory check isn't the same as the check failing.
30
+ *
31
+ * @param connection - The org connection to query against.
32
+ * @param domain - The fully qualified custom domain to look up.
33
+ * @returns Whether the domain was found, its Id, and the sites it's already bound to.
34
+ */
35
+ export async function verifyDomain(connection, domain) {
36
+ try {
37
+ const result = await connection.query(`SELECT Id, Domain, DomainType, OptionsExternalHttps, CnameTarget, (SELECT Id, SiteId, PathPrefix FROM DomainSites) FROM Domain WHERE Domain = '${escapeSoqlLiteral(domain)}'`);
38
+ const record = result.records[0];
39
+ if (!record) {
40
+ return { status: 'missing', boundToSiteIds: [] };
41
+ }
42
+ return {
43
+ status: 'found',
44
+ domainId: record.Id,
45
+ boundToSiteIds: (record.DomainSites?.records ?? []).map((domainSite) => domainSite.SiteId),
46
+ };
47
+ }
48
+ catch {
49
+ return { status: 'unavailable', boundToSiteIds: [] };
50
+ }
51
+ }
52
+ //# sourceMappingURL=verifyDomain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifyDomain.js","sourceRoot":"","sources":["../src/verifyDomain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAwB1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAsB,EAAE,MAAc;IACvE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CACnC,kJAAkJ,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAC/K,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QACnD,CAAC;QAED,OAAO;YACL,MAAM,EAAE,OAAO;YACf,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,cAAc,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;SAC3F,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;IACvD,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,138 @@
1
+ {
2
+ "name": "@simplysf/simply-community-core",
3
+ "description": "Community publish/deploy/domain-verification logic and site-file discovery — the library layer behind @simplysf/simply-community, published separately for direct consumption (e.g. editor tooling, CI scripts) without the CLI framework",
4
+ "version": "0.1.0",
5
+ "author": "@ClayChipps",
6
+ "homepage": "https://github.com/SimplySF/simply-node",
7
+ "bugs": "https://github.com/SimplySF/simply-node/issues",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/SimplySF/simply-node",
11
+ "directory": "packages/simply-community-core"
12
+ },
13
+ "engines": {
14
+ "node": ">=22.0.0"
15
+ },
16
+ "files": [
17
+ "/lib"
18
+ ],
19
+ "keywords": [
20
+ "force",
21
+ "salesforce",
22
+ "sfdx",
23
+ "salesforcedx",
24
+ "sfdx-plugin",
25
+ "sf-plugin",
26
+ "sf",
27
+ "community",
28
+ "experience-cloud"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "main": "./lib/index.js",
32
+ "types": "./lib/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./lib/index.d.ts",
36
+ "default": "./lib/index.js"
37
+ }
38
+ },
39
+ "type": "module",
40
+ "dependencies": {
41
+ "@salesforce/core": "^8.30.0",
42
+ "@salesforce/kit": "^3.2.6",
43
+ "@salesforce/source-deploy-retrieve": "^12.37.2",
44
+ "@simplysf/simply-core": "^1.5.1",
45
+ "glob": "^13.0.6",
46
+ "xmlbuilder2": "^4.0.3"
47
+ },
48
+ "devDependencies": {
49
+ "@vitest/coverage-v8": "^4.1.10",
50
+ "vitest": "^4.1.10"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "wireit": {
56
+ "build": {
57
+ "dependencies": [
58
+ "compile",
59
+ "lint"
60
+ ]
61
+ },
62
+ "compile": {
63
+ "command": "tsc -p . --pretty --incremental",
64
+ "files": [
65
+ "src/**/*.ts",
66
+ "**/tsconfig.json",
67
+ "../../tsconfig.json"
68
+ ],
69
+ "output": [
70
+ "lib/**",
71
+ "*.tsbuildinfo"
72
+ ],
73
+ "clean": "if-file-deleted"
74
+ },
75
+ "format": {
76
+ "command": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
77
+ "files": [
78
+ "src/**/*.ts",
79
+ "test/**/*.ts",
80
+ ".prettier*"
81
+ ],
82
+ "output": []
83
+ },
84
+ "lint": {
85
+ "command": "eslint src test --color --cache --cache-location .eslintcache",
86
+ "files": [
87
+ "src/**/*.ts",
88
+ "test/**/*.ts",
89
+ "**/.eslint*",
90
+ "**/tsconfig.json",
91
+ "../../eslint.config.mjs",
92
+ "../../tsconfig.json"
93
+ ],
94
+ "output": []
95
+ },
96
+ "test": {
97
+ "dependencies": [
98
+ "test:compile",
99
+ "test:only",
100
+ "lint"
101
+ ]
102
+ },
103
+ "test:compile": {
104
+ "command": "tsc -p \"./test\" --pretty",
105
+ "files": [
106
+ "test/**/*.ts",
107
+ "**/tsconfig.json",
108
+ "../../tsconfig.json"
109
+ ],
110
+ "output": []
111
+ },
112
+ "test:only": {
113
+ "command": "vitest run --project simply-community-core",
114
+ "env": {
115
+ "FORCE_COLOR": "2"
116
+ },
117
+ "files": [
118
+ "test/**/*.ts",
119
+ "src/**/*.ts",
120
+ "**/tsconfig.json",
121
+ "../../tsconfig.json",
122
+ "vitest.config.ts"
123
+ ],
124
+ "output": []
125
+ }
126
+ },
127
+ "scripts": {
128
+ "build": "wireit",
129
+ "compile": "wireit",
130
+ "fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
131
+ "format": "wireit",
132
+ "lint": "wireit",
133
+ "test": "wireit",
134
+ "test:coverage": "vitest run --coverage --project simply-community-core",
135
+ "test:only": "wireit",
136
+ "test:watch": "vitest watch --project simply-community-core"
137
+ }
138
+ }