@jayree/sfdx-plugin-org 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE.txt +12 -0
  3. package/README.md +107 -0
  4. package/bin/is-sfdx.js +3 -0
  5. package/lib/commands/jayree/org/configure/country.d.ts +11 -0
  6. package/lib/commands/jayree/org/configure/country.js +138 -0
  7. package/lib/commands/jayree/org/configure/country.js.map +1 -0
  8. package/lib/commands/jayree/org/configure/index.d.ts +14 -0
  9. package/lib/commands/jayree/org/configure/index.js +130 -0
  10. package/lib/commands/jayree/org/configure/index.js.map +1 -0
  11. package/lib/commands/jayree/org/configure/state.d.ts +15 -0
  12. package/lib/commands/jayree/org/configure/state.js +242 -0
  13. package/lib/commands/jayree/org/configure/state.js.map +1 -0
  14. package/lib/hooks/changelog.d.ts +2 -0
  15. package/lib/hooks/changelog.js +26 -0
  16. package/lib/hooks/changelog.js.map +1 -0
  17. package/lib/index.d.ts +2 -0
  18. package/lib/index.js +8 -0
  19. package/lib/index.js.map +1 -0
  20. package/lib/utils/config.d.ts +22 -0
  21. package/lib/utils/config.js +72 -0
  22. package/lib/utils/config.js.map +1 -0
  23. package/lib/utils/puppeteer/configuretasks.d.ts +50 -0
  24. package/lib/utils/puppeteer/configuretasks.js +270 -0
  25. package/lib/utils/puppeteer/configuretasks.js.map +1 -0
  26. package/lib/utils/puppeteer/countrystateconfig.d.ts +29 -0
  27. package/lib/utils/puppeteer/countrystateconfig.js +100 -0
  28. package/lib/utils/puppeteer/countrystateconfig.js.map +1 -0
  29. package/lib/utils/puppeteer/statetasks.d.ts +58 -0
  30. package/lib/utils/puppeteer/statetasks.js +302 -0
  31. package/lib/utils/puppeteer/statetasks.js.map +1 -0
  32. package/lib/utils/renderer.d.ts +47 -0
  33. package/lib/utils/renderer.js +499 -0
  34. package/lib/utils/renderer.js.map +1 -0
  35. package/messages/configure.md +12 -0
  36. package/messages/createstatecountry.md +27 -0
  37. package/oclif.manifest.json +184 -0
  38. package/package.json +209 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # 1.0.0 (2023-04-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * add configure commands ([e4c1435](https://github.com/jayree/sfdx-plugin-org/commit/e4c14357d99be655ea74e1b406cdd41232457741))
package/LICENSE.txt ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2022, jayree
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @jayree/sfdx-plugin-org
2
+
3
+ A Salesforce CLI plugin containing commands to configure State and Country/Territory Picklists and other org settings.
4
+
5
+ [![sfdx](https://img.shields.io/badge/cli-sfdx-brightgreen.svg)](https://developer.salesforce.com/tools/sfdxcli)
6
+ [![NPM](https://img.shields.io/npm/v/@jayree/sfdx-plugin-org.svg?label=@jayree/sfdx-plugin-org)](https://npmjs.org/package/@jayree/sfdx-plugin-org)
7
+ [![test-and-release](https://github.com/jayree/sfdx-plugin-org/actions/workflows/release.yml/badge.svg)](https://github.com/jayree/sfdx-plugin-org/actions/workflows/release.yml)
8
+ [![Downloads/week](https://img.shields.io/npm/dw/@jayree/sfdx-plugin-org.svg)](https://npmjs.org/package/@jayree/sfdx-plugin-org)
9
+ [![License](https://img.shields.io/npm/l/@jayree/sfdx-plugin-org.svg)](https://github.com/jayree-plugins/sfdx-plugin-org/blob/main/package.json)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ sfdx plugins:install @jayree/sfdx-plugin-org
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ <!-- commands -->
20
+ * [`sfdx jayree:org:configure`](#sfdx-jayreeorgconfigure)
21
+ * [`sfdx jayree:org:configure:country`](#sfdx-jayreeorgconfigurecountry)
22
+ * [`sfdx jayree:org:configure:state`](#sfdx-jayreeorgconfigurestate)
23
+
24
+ ### `sfdx jayree:org:configure`
25
+
26
+ make configuration changes that are not covered by the metadata API
27
+
28
+ ```
29
+ USAGE
30
+ $ sfdx jayree:org:configure -o <value> [--json] [--api-version <value>] [-t <value>] [--concurrent]
31
+
32
+ FLAGS
33
+ -o, --target-org=<value> (required) Username or alias of the target org.
34
+ -t, --tasks=<value>... list of task titles, if no tasks are specified, all tasks marked as active will be executed
35
+ --api-version=<value> Override the api version used for api requests made by this command
36
+ --concurrent execute tasks in parallel
37
+
38
+ GLOBAL FLAGS
39
+ --json Format output as json.
40
+
41
+ DESCRIPTION
42
+ make configuration changes that are not covered by the metadata API
43
+ See example configuration on how to define tasks
44
+
45
+ make configuration changes that are not covered by the metadata API
46
+ See example configuration on how to define tasks
47
+
48
+ EXAMPLES
49
+ $ sfdx jayree:org:configure
50
+ $ sfdx jayree:org:configure -u me@my.org
51
+ $ sfdx jayree:org:configure --tasks="Asset Settings","Activity Settings"
52
+ $ sfdx jayree:org:configure --concurrent --tasks="Asset Settings","Activity Settings"
53
+ ```
54
+
55
+ _See code: [src/commands/jayree/org/configure/index.ts](https://github.com/jayree/sfdx-plugin-org/blob/v1.0.0/src/commands/jayree/org/configure/index.ts)_
56
+
57
+ ### `sfdx jayree:org:configure:country`
58
+
59
+ update country integration values in the State/Country Picklists
60
+
61
+ ```
62
+ USAGE
63
+ $ sfdx jayree:org:configure:country -o <value> [--json] [--api-version <value>]
64
+
65
+ FLAGS
66
+ -o, --target-org=<value> (required) Username or alias of the target org.
67
+ --api-version=<value> Override the api version used for api requests made by this command
68
+
69
+ GLOBAL FLAGS
70
+ --json Format output as json.
71
+
72
+ DESCRIPTION
73
+ update country integration values in the State/Country Picklists
74
+
75
+ update country integration values in the State/Country Picklists
76
+ ```
77
+
78
+ _See code: [src/commands/jayree/org/configure/country.ts](https://github.com/jayree/sfdx-plugin-org/blob/v1.0.0/src/commands/jayree/org/configure/country.ts)_
79
+
80
+ ### `sfdx jayree:org:configure:state`
81
+
82
+ import (create/update) states into the State/Country Picklists
83
+
84
+ ```
85
+ USAGE
86
+ $ sfdx jayree:org:configure:state -o <value> [--json] [--api-version <value>] [--country-code <value>] [--category <value>]
87
+ [--language <value>] [--concurrent <value>]
88
+
89
+ FLAGS
90
+ -o, --target-org=<value> (required) Username or alias of the target org.
91
+ --api-version=<value> Override the api version used for api requests made by this command
92
+ --category=<value> Subdivision category
93
+ --concurrent=<value> [default: 1] execute tasks in parallel
94
+ --country-code=<value> Alpha-2 code
95
+ --language=<value> Language code
96
+
97
+ GLOBAL FLAGS
98
+ --json Format output as json.
99
+
100
+ DESCRIPTION
101
+ import (create/update) states into the State/Country Picklists
102
+
103
+ import (create/update) states into the State/Country Picklists
104
+ ```
105
+
106
+ _See code: [src/commands/jayree/org/configure/state.ts](https://github.com/jayree/sfdx-plugin-org/blob/v1.0.0/src/commands/jayree/org/configure/state.ts)_
107
+ <!-- commandsstop -->
package/bin/is-sfdx.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ process.exit(process.env.SFDX_BINPATH || process.env.SFDX_UPDATE_INSTRUCTIONS ? 0 : 1);
@@ -0,0 +1,11 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export default class UpdateCountry extends SfCommand<void> {
3
+ static readonly summary: string;
4
+ static readonly description: string;
5
+ static readonly flags: {
6
+ 'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ 'api-version': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ silent: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,138 @@
1
+ /*
2
+ * Copyright (c) 2021, jayree
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ import { dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Flags, SfCommand, requiredOrgFlagWithDeprecations, orgApiVersionFlagWithDeprecations, } from '@salesforce/sf-plugins-core';
10
+ import { Messages } from '@salesforce/core';
11
+ import { ux } from '@oclif/core';
12
+ import playwright from 'playwright-chromium';
13
+ import { Tabletojson as tabletojson } from 'tabletojson';
14
+ import config from '../../../../utils/config.js';
15
+ import { configSelectors } from '../../../../utils/puppeteer/countrystateconfig.js';
16
+ // eslint-disable-next-line no-underscore-dangle
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ // eslint-disable-next-line no-underscore-dangle
19
+ const __dirname = dirname(__filename);
20
+ Messages.importMessagesDirectory(__dirname);
21
+ const messages = Messages.loadMessages('@jayree/sfdx-plugin-org', 'createstatecountry');
22
+ // eslint-disable-next-line sf-plugin/command-example
23
+ class UpdateCountry extends SfCommand {
24
+ async run() {
25
+ const { flags } = await this.parse(UpdateCountry);
26
+ let spinnermessage = '';
27
+ const browser = await playwright['chromium'].launch(config().puppeteer);
28
+ const context = await browser.newContext();
29
+ const page = await context.newPage();
30
+ const setHTMLInputElementValue = async (newvalue, element) => {
31
+ element = element.replace(/:/g, '\\:');
32
+ const elementDisabled = await page.evaluate((s) => {
33
+ const result = document.querySelector(s);
34
+ if (result != null) {
35
+ return result.disabled;
36
+ }
37
+ else {
38
+ return true;
39
+ }
40
+ }, element);
41
+ if (!elementDisabled) {
42
+ return page.fill(element, newvalue);
43
+ }
44
+ };
45
+ const bar = ux.progress({
46
+ barCompleteChar: '\u2588',
47
+ barIncompleteChar: '\u2591',
48
+ format: 'State and Country/Territory Picklist | [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | {text}',
49
+ stream: process.stdout,
50
+ });
51
+ try {
52
+ // eslint-disable-next-line no-unused-expressions
53
+ !flags.silent
54
+ ? this.spinner.start('State and Country/Territory Picklist')
55
+ : process.stdout.write('State and Country/Territory Picklist');
56
+ const conn = flags['target-org'].getConnection(flags['api-version']);
57
+ spinnermessage = `login to ${conn.instanceUrl}`;
58
+ // eslint-disable-next-line no-unused-expressions
59
+ !flags.silent ? this.spinner.start(spinnermessage) : process.stdout.write('.');
60
+ await page.goto(`${conn.instanceUrl}/secur/frontdoor.jsp?sid=${conn.accessToken}`, {
61
+ waitUntil: 'networkidle',
62
+ });
63
+ spinnermessage = 'retrieve list of countries';
64
+ // eslint-disable-next-line no-unused-expressions
65
+ !flags.silent ? this.spinner.start(spinnermessage) : process.stdout.write('.');
66
+ try {
67
+ await page.goto(conn.instanceUrl + '/i18n/ConfigStateCountry.apexp?setupid=AddressCleanerOverview', {
68
+ waitUntil: 'networkidle',
69
+ });
70
+ await page.waitForSelector('.list', { state: 'visible' });
71
+ }
72
+ catch (error) {
73
+ throw Error("list of countries couldn't be loaded");
74
+ }
75
+ this.spinner.stop();
76
+ const table = await page.evaluate(() => {
77
+ const list = document.querySelector('.list');
78
+ if (list) {
79
+ return list.outerHTML;
80
+ }
81
+ });
82
+ const list = tabletojson.convert(table)[0];
83
+ let curr = 0;
84
+ if (!flags.silent) {
85
+ bar.start(list.length, 0, {
86
+ text: '',
87
+ });
88
+ }
89
+ for await (const value of list) {
90
+ const countryCode = value['Country/Territory Code'];
91
+ const countryName = value.Country;
92
+ curr = curr + 1;
93
+ // eslint-disable-next-line no-unused-expressions
94
+ !flags.silent
95
+ ? bar.update(curr, {
96
+ text: 'update ' + countryName + '/' + countryCode,
97
+ })
98
+ : process.stdout.write('.');
99
+ await page.goto(conn.instanceUrl + `/i18n/ConfigureCountry.apexp?countryIso=${countryCode}&setupid=AddressCleanerOverview`, {
100
+ waitUntil: 'networkidle',
101
+ });
102
+ const setCountrySelector = configSelectors.setCountry;
103
+ await setHTMLInputElementValue(countryCode, setCountrySelector.editIntVal);
104
+ await page.click(setCountrySelector.save.replace(/:/g, '\\:'));
105
+ await page.waitForSelector('.message.confirmM3', { state: 'visible' });
106
+ }
107
+ }
108
+ catch (error) {
109
+ throw new Error(error.message);
110
+ }
111
+ finally {
112
+ // eslint-disable-next-line no-unused-expressions
113
+ !flags.silent ? bar.update(bar.getTotal(), { text: '' }) : process.stdout.write('.');
114
+ this.spinner.stop();
115
+ bar.stop();
116
+ if (page) {
117
+ await page.close();
118
+ if (browser) {
119
+ await browser.close();
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ UpdateCountry.summary = messages.getMessage('commandCountryDescription');
126
+ UpdateCountry.description = messages.getMessage('commandCountryDescription');
127
+ UpdateCountry.flags = {
128
+ 'target-org': requiredOrgFlagWithDeprecations,
129
+ 'api-version': orgApiVersionFlagWithDeprecations,
130
+ silent: Flags.boolean({
131
+ summary: messages.getMessage('silentFlagDescription'),
132
+ required: false,
133
+ default: false,
134
+ hidden: true,
135
+ }),
136
+ };
137
+ export default UpdateCountry;
138
+ //# sourceMappingURL=country.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.js","sourceRoot":"","sources":["../../../../../src/commands/jayree/org/configure/country.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,KAAK,EACL,SAAS,EACT,+BAA+B,EAC/B,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAEpF,gDAAgD;AAChD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,gDAAgD;AAChD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,QAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;AAExF,qDAAqD;AACrD,MAAqB,aAAc,SAAQ,SAAe;IAejD,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAClD,IAAI,cAAc,GAA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AC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;SAC3C;gBAAS;YACR,iDAAiD;YACjD,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAErF,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,GAAG,CAAC,IAAI,EAAE,CAAC;YACX,IAAI,IAAI,EAAE;gBACR,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;gBACnB,IAAI,OAAO,EAAE;oBACX,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;iBACvB;aACF;SACF;IACH,CAAC;;AAxIsB,qBAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAC3D,yBAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAE/D,mBAAK,GAAG;IAC7B,YAAY,EAAE,+BAA+B;IAC7C,aAAa,EAAE,iCAAiC;IAChD,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;QACrD,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI;KACb,CAAC;CACH,CAAC;eAbiB,aAAa"}
@@ -0,0 +1,14 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class ConfigureOrg extends SfCommand<AnyJson> {
4
+ static readonly summary: string;
5
+ static readonly description: string;
6
+ static readonly examples: string[];
7
+ static readonly flags: {
8
+ 'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ 'api-version': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ tasks: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ concurrent: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<AnyJson>;
14
+ }
@@ -0,0 +1,130 @@
1
+ /*
2
+ * Copyright (c) 2021, jayree
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ import { dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Flags, SfCommand, requiredOrgFlagWithDeprecations, orgApiVersionFlagWithDeprecations, arrayWithDeprecation, } from '@salesforce/sf-plugins-core';
10
+ import { Messages } from '@salesforce/core';
11
+ import { traverse } from '@salesforce/core/lib/util/internal.js';
12
+ import { ListrLogger, Listr, PRESET_TIMER } from 'listr2';
13
+ import Debug from 'debug';
14
+ import config from '../../../../utils/config.js';
15
+ import { PuppeteerConfigureTasks } from '../../../../utils/puppeteer/configuretasks.js';
16
+ // eslint-disable-next-line no-underscore-dangle
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ // eslint-disable-next-line no-underscore-dangle
19
+ const __dirname = dirname(__filename);
20
+ Messages.importMessagesDirectory(__dirname);
21
+ const messages = Messages.loadMessages('@jayree/sfdx-plugin-org', 'configure');
22
+ const logger = new ListrLogger({ useIcons: false });
23
+ const debug = Debug('jayree:org:configure');
24
+ class ConfigureOrg extends SfCommand {
25
+ async run() {
26
+ const { flags } = await this.parse(ConfigureOrg);
27
+ const configPath = await traverse.forFile(process.cwd(), '.sfdx-jayree.json');
28
+ let allTasks = [];
29
+ let selectedSetupTasks = [];
30
+ const configSetupTasks = config(configPath).setupTasks;
31
+ if (configSetupTasks) {
32
+ if (flags.tasks) {
33
+ flags.tasks.forEach((task) => {
34
+ selectedSetupTasks = selectedSetupTasks.concat(configSetupTasks.filter((t) => task === t.title));
35
+ });
36
+ allTasks = selectedSetupTasks;
37
+ }
38
+ else {
39
+ selectedSetupTasks = configSetupTasks.filter((t) => t.isactive === true);
40
+ allTasks = configSetupTasks;
41
+ }
42
+ }
43
+ const setupTaskRunner = new PuppeteerConfigureTasks({
44
+ accessToken: flags['target-org'].getConnection(flags['api-version']).accessToken,
45
+ instanceUrl: flags['target-org'].getConnection(flags['api-version']).instanceUrl,
46
+ }, selectedSetupTasks);
47
+ const setupTasks = new Listr([], { concurrent: flags.concurrent, exitOnError: false });
48
+ allTasks.forEach((el) => {
49
+ setupTasks.add({
50
+ title: el.title,
51
+ skip: () => !selectedSetupTasks.includes(el),
52
+ task: async (ctx, task) => {
53
+ const sTask = setupTaskRunner.getNext();
54
+ if (!(await sTask.execute(task))) {
55
+ task.skip();
56
+ }
57
+ },
58
+ options: { persistentOutput: false, bottomBar: 5 },
59
+ });
60
+ });
61
+ const mainTasks = new Listr([
62
+ {
63
+ title: 'Open Browser',
64
+ skip: () => !(selectedSetupTasks.length > 0),
65
+ task: async () => {
66
+ await setupTaskRunner.open();
67
+ },
68
+ },
69
+ {
70
+ title: 'Execute SetupTasks',
71
+ skip: () => !(selectedSetupTasks.length > 0),
72
+ task: () => setupTasks,
73
+ },
74
+ {
75
+ title: 'Close Browser',
76
+ skip: () => !(selectedSetupTasks.length > 0),
77
+ task: async () => {
78
+ await setupTaskRunner.close();
79
+ },
80
+ },
81
+ ], {
82
+ rendererOptions: {
83
+ timer: {
84
+ ...PRESET_TIMER,
85
+ condition: (duration) => duration > 250,
86
+ },
87
+ collapseErrors: false,
88
+ collapseSubtasks: false,
89
+ },
90
+ silentRendererCondition: this.jsonEnabled(),
91
+ fallbackRendererCondition: debug.enabled,
92
+ exitOnError: false,
93
+ });
94
+ try {
95
+ const context = await mainTasks.run();
96
+ if (debug.enabled && !this.jsonEnabled()) {
97
+ logger.toStderr(`Context: ${JSON.stringify(context, null, 2)}`);
98
+ }
99
+ return context;
100
+ }
101
+ catch (e) {
102
+ if (!this.jsonEnabled()) {
103
+ logger.toStderr(e.message);
104
+ }
105
+ throw e;
106
+ }
107
+ }
108
+ }
109
+ ConfigureOrg.summary = messages.getMessage('commandDescription');
110
+ ConfigureOrg.description = messages.getMessage('commandDescription');
111
+ ConfigureOrg.examples = [
112
+ `$ sfdx jayree:org:configure
113
+ $ sfdx jayree:org:configure -u me@my.org
114
+ $ sfdx jayree:org:configure --tasks="Asset Settings","Activity Settings"
115
+ $ sfdx jayree:org:configure --concurrent --tasks="Asset Settings","Activity Settings"`,
116
+ ];
117
+ ConfigureOrg.flags = {
118
+ 'target-org': requiredOrgFlagWithDeprecations,
119
+ 'api-version': orgApiVersionFlagWithDeprecations,
120
+ tasks: arrayWithDeprecation({
121
+ char: 't',
122
+ summary: messages.getMessage('tasks'),
123
+ }),
124
+ concurrent: Flags.boolean({
125
+ summary: messages.getMessage('concurrent'),
126
+ default: false,
127
+ }),
128
+ };
129
+ export default ConfigureOrg;
130
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/jayree/org/configure/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,KAAK,EACL,SAAS,EACT,+BAA+B,EAC/B,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM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CAAC,CAAC,EAAE,CAAC,CAAC;aACjE;YAED,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;gBACvB,MAAM,CAAC,QAAQ,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;aACvC;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;;AArHsB,oBAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AACpD,wBAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAExD,qBAAQ,GAAG;IAChC;;;sFAGkF;CACnF,CAAC;AAEqB,kBAAK,GAAG;IAC7B,YAAY,EAAE,+BAA+B;IAC7C,aAAa,EAAE,iCAAiC;IAChD,KAAK,EAAE,oBAAoB,CAAC;QAC1B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;KACtC,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC;QACxB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;QAC1C,OAAO,EAAE,KAAK;KACf,CAAC;CACH,CAAC;eAtBiB,YAAY"}
@@ -0,0 +1,15 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import { AnyJson } from '@salesforce/ts-types';
3
+ export default class ImportState extends SfCommand<AnyJson> {
4
+ static readonly summary: string;
5
+ static readonly description: string;
6
+ static readonly flags: {
7
+ 'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ 'api-version': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ 'country-code': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ category: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ language: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ concurrent: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ };
14
+ run(): Promise<AnyJson>;
15
+ }