@simplysf/simply-plugin-kit 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @simplysf/simply-plugin-kit
2
+
3
+ [![NPM](https://img.shields.io/npm/v/@simplysf/simply-plugin-kit?label=@simplysf/simply-plugin-kit)](https://npmjs.com/@simplysf/simply-plugin-kit) [![Downloads/week](https://img.shields.io/npm/dw/@simplysf/simply-plugin-kit.svg)](https://npmjs.com/@simplysf/simply-plugin-kit) [![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
+ Shared oclif command building blocks for [`@simplysf`](https://github.com/SimplySF/simply-node) Salesforce CLI plugins. This is not a Salesforce CLI plugin itself — it's a plain library consumed by the other packages in this monorepo.
6
+
7
+ It exists as its own package rather than living in [`@simplysf/simply-core`](https://npmjs.com/@simplysf/simply-core) so that `simply-core` stays free of a `@salesforce/sf-plugins-core` dependency. Anything here that needs the oclif flag layer belongs on this side of that line.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @simplysf/simply-plugin-kit
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { Messages } from '@salesforce/core';
19
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
20
+ import { requireConnection, targetOrgFlags } from '@simplysf/simply-plugin-kit';
21
+
22
+ export default class MyCommand extends SfCommand<void> {
23
+ public static readonly flags = {
24
+ ...SfCommand.baseFlags,
25
+ ...targetOrgFlags,
26
+ sobject: Flags.string({ summary: messages.getMessage('flags.sobject.summary'), required: true }),
27
+ };
28
+
29
+ public async run(): Promise<void> {
30
+ const { flags } = await this.parse(MyCommand);
31
+ const connection = requireConnection(flags);
32
+ // ...
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## API
38
+
39
+ | Export | Description |
40
+ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
41
+ | `targetOrgFlags` | The `--target-org` / `--api-version` flag pair every org-touching command declares. |
42
+ | `requireConnection(flags)` | Resolves the connection for `--target-org` at `--api-version`, throwing `TargetOrgConnectionFailedError` if none could be established. |
43
+ | `TargetOrgFlagValues` | Structural type for the parsed flags `requireConnection` reads. |
@@ -0,0 +1,21 @@
1
+ import type { OptionFlag } from '@oclif/core/interfaces';
2
+ import type { Org } from '@salesforce/core';
3
+ /**
4
+ * The `--target-org` / `--api-version` pair every org-touching command declares.
5
+ *
6
+ * These two always travel together — an API version is only meaningful against an org — and
7
+ * neither carries per-command help text, since `sf-plugins-core` supplies both summaries. Spread
8
+ * this into a command's `flags`, then read the result with {@link requireConnection}.
9
+ *
10
+ * ```ts
11
+ * public static readonly flags = {
12
+ * ...SfCommand.baseFlags,
13
+ * ...targetOrgFlags,
14
+ * sobject: Flags.string({ summary: messages.getMessage('flags.sobject.summary'), required: true }),
15
+ * };
16
+ * ```
17
+ */
18
+ export declare const targetOrgFlags: {
19
+ 'api-version': OptionFlag<string | undefined>;
20
+ 'target-org': OptionFlag<Org>;
21
+ };
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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 { Flags } from '@salesforce/sf-plugins-core';
17
+ /**
18
+ * The `--target-org` / `--api-version` pair every org-touching command declares.
19
+ *
20
+ * These two always travel together — an API version is only meaningful against an org — and
21
+ * neither carries per-command help text, since `sf-plugins-core` supplies both summaries. Spread
22
+ * this into a command's `flags`, then read the result with {@link requireConnection}.
23
+ *
24
+ * ```ts
25
+ * public static readonly flags = {
26
+ * ...SfCommand.baseFlags,
27
+ * ...targetOrgFlags,
28
+ * sobject: Flags.string({ summary: messages.getMessage('flags.sobject.summary'), required: true }),
29
+ * };
30
+ * ```
31
+ */
32
+ export const targetOrgFlags = {
33
+ 'api-version': Flags.orgApiVersion(),
34
+ 'target-org': Flags.requiredOrg(),
35
+ };
36
+ //# sourceMappingURL=orgFlags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgFlags.js","sourceRoot":"","sources":["../../src/flags/orgFlags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAGvB;IACF,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;IACpC,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;CAClC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { targetOrgFlags } from './flags/orgFlags.js';
2
+ export { requireConnection, type TargetOrgFlagValues } from './org/requireConnection.js';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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
+ export { targetOrgFlags } from './flags/orgFlags.js';
17
+ export { requireConnection } from './org/requireConnection.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Connection, type Org } from '@salesforce/core';
2
+ /**
3
+ * The parsed flags this needs: whatever a command's `target-org`/`api-version` flags produced.
4
+ * Structural rather than tied to a specific command's flag type, so any command whose flags
5
+ * include this pair satisfies it.
6
+ */
7
+ export type TargetOrgFlagValues = {
8
+ 'target-org'?: Org;
9
+ 'api-version'?: string;
10
+ };
11
+ /**
12
+ * Resolve the connection for a command's `--target-org`, at its `--api-version` if one was given.
13
+ *
14
+ * `Flags.requiredOrg()` already guarantees an org is present, so the undefined case here is
15
+ * defensive — but every command was writing the same four lines to handle it, against its own
16
+ * copy of the same error message. This is that, once.
17
+ *
18
+ * @param flags - The command's parsed flags.
19
+ * @returns The org connection.
20
+ * @throws {SfError} `TargetOrgConnectionFailedError` if no connection could be established.
21
+ */
22
+ export declare function requireConnection(flags: TargetOrgFlagValues): Connection;
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
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 { Messages } from '@salesforce/core';
17
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
18
+ const messages = Messages.loadMessages('@simplysf/simply-plugin-kit', 'simply.plugin-kit');
19
+ /**
20
+ * Resolve the connection for a command's `--target-org`, at its `--api-version` if one was given.
21
+ *
22
+ * `Flags.requiredOrg()` already guarantees an org is present, so the undefined case here is
23
+ * defensive — but every command was writing the same four lines to handle it, against its own
24
+ * copy of the same error message. This is that, once.
25
+ *
26
+ * @param flags - The command's parsed flags.
27
+ * @returns The org connection.
28
+ * @throws {SfError} `TargetOrgConnectionFailedError` if no connection could be established.
29
+ */
30
+ export function requireConnection(flags) {
31
+ const connection = flags['target-org']?.getConnection(flags['api-version']);
32
+ if (!connection) {
33
+ throw messages.createError('error.targetOrgConnectionFailed');
34
+ }
35
+ return connection;
36
+ }
37
+ //# sourceMappingURL=requireConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireConnection.js","sourceRoot":"","sources":["../../src/org/requireConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAc,QAAQ,EAAY,MAAM,kBAAkB,CAAC;AAElE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC;AAY3F;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA0B;IAC1D,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,QAAQ,CAAC,WAAW,CAAC,iCAAiC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ # error.targetOrgConnectionFailed
2
+
3
+ Unable to establish connection to the org.
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "name": "@simplysf/simply-plugin-kit",
3
+ "description": "Shared oclif command building blocks for SimplySF Salesforce CLI plugins",
4
+ "version": "1.0.1",
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-plugin-kit"
12
+ },
13
+ "engines": {
14
+ "node": ">=22.0.0"
15
+ },
16
+ "files": [
17
+ "/lib",
18
+ "/messages"
19
+ ],
20
+ "keywords": [
21
+ "force",
22
+ "salesforce",
23
+ "sfdx",
24
+ "salesforcedx",
25
+ "sfdx-plugin",
26
+ "sf-plugin",
27
+ "sf"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "exports": "./lib/index.js",
31
+ "type": "module",
32
+ "dependencies": {
33
+ "@oclif/core": "^4.11.2",
34
+ "@salesforce/core": "^8.30.0",
35
+ "@salesforce/sf-plugins-core": "^12.2.16"
36
+ },
37
+ "devDependencies": {
38
+ "@vitest/coverage-v8": "^4.1.10",
39
+ "vitest": "^4.1.10"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "build": "wireit",
46
+ "compile": "wireit",
47
+ "fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
48
+ "format": "wireit",
49
+ "lint": "wireit",
50
+ "test": "wireit",
51
+ "test:coverage": "vitest run --coverage --project simply-plugin-kit",
52
+ "test:only": "wireit",
53
+ "test:watch": "vitest watch --project simply-plugin-kit"
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-plugin-kit",
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
+ }