@sharinpix/sharinpix-sf-cli 1.0.0 → 1.2.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/README.md CHANGED
@@ -1,24 +1,8 @@
1
- # sharinpix-sf-cli
1
+ # SharinPix Salesforce CLI Plugin
2
2
 
3
- [![NPM](https://img.shields.io/npm/v/sharinpix-sf-cli.svg?label=sharinpix-sf-cli)](https://www.npmjs.com/package/sharinpix-sf-cli) [![Downloads/week](https://img.shields.io/npm/dw/sharinpix-sf-cli.svg)](https://npmjs.org/package/sharinpix-sf-cli) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/sharinpix-sf-cli/main/LICENSE.txt)
3
+ [![NPM](https://img.shields.io/npm/v/@sharinpix/sharinpix-sf-cli.svg?label=@sharinpix/sharinpix-sf-cli)](https://www.npmjs.com/package/@sharinpix/sharinpix-sf-cli) [![Downloads/week](https://img.shields.io/npm/dw/@sharinpix/sharinpix-sf-cli.svg)](https://npmjs.org/package/@sharinpix/sharinpix-sf-cli) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/sharinpix/sharinpix-sf-cli/main/LICENSE.txt)
4
4
 
5
- ## Using the template
6
-
7
- This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
8
-
9
- 1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
10
- 2. Generate your plugin:
11
-
12
- ```
13
- sf plugins install dev
14
- sf dev generate plugin
15
-
16
- git init -b main
17
- git add . && git commit -m "chore: initial commit"
18
- ```
19
-
20
- 3. Create your plugin's repo in the salesforcecli github org
21
- 4. When you're ready, replace the contents of this README with the information you want.
5
+ The SharinPix Salesforce CLI plugin provides tools to interact with SharinPix form templates in your Salesforce orgs. This plugin allows you to pull form templates from your Salesforce org and save them as local JSON files for version control and deployment management.
22
6
 
23
7
  ## Learn about `sf` plugins
24
8
 
@@ -53,12 +37,12 @@ We always recommend using the latest version of these commands bundled with the
53
37
  ## Install
54
38
 
55
39
  ```bash
56
- sf plugins install sharinpix-sf-cli@x.y.z
40
+ sf plugins install @sharinpix/sharinpix-sf-cli@x.y.z
57
41
  ```
58
42
 
59
43
  ## Issues
60
44
 
61
- Please report any issues at https://github.com/forcedotcom/cli/issues
45
+ Please report any issues at https://github.com/sharinpix/sharinpix-sf-cli/issues
62
46
 
63
47
  ## Contributing
64
48
 
@@ -81,21 +65,21 @@ Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
81
65
 
82
66
  ### Build
83
67
 
84
- To build the plugin locally, make sure to have yarn installed and run the following commands:
68
+ To build the plugin locally, make sure to have npm installed and run the following commands:
85
69
 
86
70
  ```bash
87
71
  # Clone the repository
88
- git clone git@github.com:salesforcecli/sharinpix-sf-cli
72
+ git clone git@github.com:sharinpix/sharinpix-sf-cli
89
73
 
90
74
  # Install the dependencies and compile
91
- yarn && yarn build
75
+ npm install && npm run build
92
76
  ```
93
77
 
94
78
  To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
95
79
 
96
80
  ```bash
97
81
  # Run using local run file.
98
- ./bin/dev hello world
82
+ ./bin/dev sharinpix form pull --target-org myorg@example.com
99
83
  ```
100
84
 
101
85
  There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
@@ -110,36 +94,42 @@ sf plugins
110
94
  ## Commands
111
95
 
112
96
  <!-- commands -->
97
+ * [`sf sharinpix form pull`](#sf-sharinpix-form-pull)
113
98
 
114
- - [`sf hello world`](#sf-hello-world)
99
+ ## `sf sharinpix form pull`
115
100
 
116
- ## `sf hello world`
117
-
118
- Say hello either to the world or someone you know.
101
+ Pull SharinPix form templates from Salesforce org.
119
102
 
120
103
  ```
121
104
  USAGE
122
- $ sf hello world [--json] [-n <value>]
105
+ $ sf sharinpix form pull -o <value> [--json] [--flags-dir <value>]
123
106
 
124
107
  FLAGS
125
- -n, --name=<value> [default: World] The name of the person you'd like to say hello to.
108
+ -o, --org=<value> (required) The Salesforce org to pull form templates from.
126
109
 
127
110
  GLOBAL FLAGS
128
- --json Format output as json.
111
+ --flags-dir=<value> Import flag values from a directory.
112
+ --json Format output as json.
129
113
 
130
114
  DESCRIPTION
131
- Say hello either to the world or someone you know.
115
+ Pull SharinPix form templates from Salesforce org.
132
116
 
133
- Say hello either to the world or someone you know.
117
+ Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local
118
+ sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition
119
+ files.
134
120
 
135
121
  EXAMPLES
136
- Say hello to the world:
122
+ Pull all form templates from the default org:
137
123
 
138
- $ sf hello world
124
+ $ sf sharinpix form pull
139
125
 
140
- Say hello to someone you know:
126
+ Pull form templates from a specific org:
141
127
 
142
- $ sf hello world --name Astro
143
- ```
128
+ $ sf sharinpix form pull --target-org myorg@example.com
144
129
 
130
+ FLAG DESCRIPTIONS
131
+ -o, --org=<value> The Salesforce org to pull form templates from.
132
+
133
+ The target Salesforce org containing the SharinPix form templates to be pulled.
134
+ ```
145
135
  <!-- commandsstop -->
@@ -0,0 +1,15 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type PullResult = {
3
+ name: string;
4
+ formsDownloaded?: number;
5
+ formsFailed?: number;
6
+ };
7
+ export default class Pull extends SfCommand<PullResult> {
8
+ static readonly summary: string;
9
+ static readonly description: string;
10
+ static readonly examples: string[];
11
+ static readonly flags: {
12
+ org: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ run(): Promise<PullResult>;
15
+ }
@@ -0,0 +1,55 @@
1
+ /* eslint-disable no-console */
2
+ /* eslint-disable no-await-in-loop */
3
+ import fs from 'node:fs';
4
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
5
+ import { Messages } from '@salesforce/core';
6
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
7
+ const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'sharinpix.form.pull');
8
+ export default class Pull extends SfCommand {
9
+ static summary = messages.getMessage('summary');
10
+ static description = messages.getMessage('description');
11
+ static examples = messages.getMessages('examples');
12
+ static flags = {
13
+ org: Flags.requiredOrg({
14
+ char: 'o',
15
+ summary: messages.getMessage('flags.org.summary'),
16
+ description: messages.getMessage('flags.org.description'),
17
+ }),
18
+ };
19
+ async run() {
20
+ const { flags } = await this.parse(Pull);
21
+ const connection = flags.org.getConnection('63.0');
22
+ fs.mkdirSync('sharinpix/forms', { recursive: true });
23
+ const records = (await connection.query('SELECT Id, sharinpix__FormUrl__c, Name, sharinpix__Description__c FROM sharinpix__FormTemplate__c order by LastModifiedDate desc')).records;
24
+ let formsDownloaded = 0;
25
+ let formsFailed = 0;
26
+ for (const record of records) {
27
+ try {
28
+ const response = await fetch(record.sharinpix__FormUrl__c + '.json', {
29
+ headers: {
30
+ 'Accept': 'application/json',
31
+ }
32
+ });
33
+ if (!response.ok) {
34
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
35
+ }
36
+ const form = await response.json();
37
+ fs.writeFileSync(`sharinpix/forms/${record.Name}.json`, JSON.stringify(form, null, 2));
38
+ this.log(messages.getMessage('info.hello', [record.Name, record.sharinpix__FormUrl__c]));
39
+ formsDownloaded++;
40
+ }
41
+ catch (error) {
42
+ // Skip forms that can't be fetched (e.g., network errors, invalid URLs)
43
+ this.warn(`Failed to fetch form template ${record.Name}: ${error instanceof Error ? error.message : 'Unknown error'}`);
44
+ formsFailed++;
45
+ }
46
+ }
47
+ this.log(`Successfully downloaded ${formsDownloaded} form template(s). ${formsFailed} failed.`);
48
+ return {
49
+ name: 'OK',
50
+ formsDownloaded,
51
+ formsFailed,
52
+ };
53
+ }
54
+ }
55
+ //# sourceMappingURL=pull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/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Ae;YACf,WAAW;SACZ,CAAC;IACJ,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export default {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ # summary
2
+
3
+ Pull SharinPix form templates from Salesforce org.
4
+
5
+ # description
6
+
7
+ Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition files.
8
+
9
+ # flags.org.summary
10
+
11
+ The Salesforce org to pull form templates from.
12
+
13
+ # flags.org.description
14
+
15
+ The target Salesforce org containing the SharinPix form templates to be pulled.
16
+
17
+ # examples
18
+
19
+ - Pull all form templates from the default org:
20
+
21
+ <%= config.bin %> <%= command.id %>
22
+
23
+ - Pull form templates from a specific org:
24
+
25
+ <%= config.bin %> <%= command.id %> --target-org myorg@example.com
26
+
27
+ # info.hello
28
+
29
+ Pulled form template %s from %s